IMPORTANT: Making prev. Memcached_DataObject working again with schemaDef
Lots of the Memcached_DataObject classes stopped working when upgraded to Managed_DataObject because they lacked schemaDef(). I have _hopefully_ made it so that all the references to the table uses each class' schemaDef, rather than the more manual ColumnDef stuff. Not all plugins have been tested thoroughly yet. NOTE: This is applied with getKV calls instead of staticGet, as it was important for PHP Strict Standards compliance to avoid calling the non- static functions statically. (unfortunately DB and DB_DataObject still do this within themselves...)
This commit is contained in:
parent
b1465a7559
commit
3a7261f70a
@ -19,6 +19,23 @@ class User_username extends Managed_DataObject
|
|||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
|
public static function schemaDef()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'fields' => array(
|
||||||
|
'provider_name' => array('type' => 'varchar', 'length' => 255, 'description' => 'provider name'),
|
||||||
|
'username' => array('type' => 'varchar', 'length' => 255, 'description' => 'username'),
|
||||||
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
|
),
|
||||||
|
'primary key' => array('provider_name', 'username'),
|
||||||
|
'foreign keys' => array(
|
||||||
|
'user_username_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a user with a username on a given provider
|
* Register a user with a username on a given provider
|
||||||
* @param User User object
|
* @param User User object
|
||||||
@ -40,18 +57,4 @@ class User_username extends Managed_DataObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function table() {
|
|
||||||
return array(
|
|
||||||
'user_id' => DB_DATAOBJECT_INT,
|
|
||||||
'username' => DB_DATAOBJECT_STR,
|
|
||||||
'provider_name' => DB_DATAOBJECT_STR ,
|
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// now define the keys.
|
|
||||||
function keys() {
|
|
||||||
return array('provider_name' => 'K', 'username' => 'K');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -250,16 +250,7 @@ abstract class AuthenticationPlugin extends Plugin
|
|||||||
|
|
||||||
function onCheckSchema() {
|
function onCheckSchema() {
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
$schema->ensureTable('user_username',
|
$schema->ensureTable('user_username', User_username::schemaDef());
|
||||||
array(new ColumnDef('provider_name', 'varchar',
|
|
||||||
'255', false, 'PRI'),
|
|
||||||
new ColumnDef('username', 'varchar',
|
|
||||||
'255', false, 'PRI'),
|
|
||||||
new ColumnDef('user_id', 'integer',
|
|
||||||
null, false),
|
|
||||||
new ColumnDef('created', 'datetime',
|
|
||||||
null, false),
|
|
||||||
new ColumnDef('modified', 'timestamp')));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,22 +80,7 @@ class AnonymousFavePlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing total number of times a notice has been faved
|
// For storing total number of times a notice has been faved
|
||||||
|
$schema->ensureTable('fave_tally', Fave_tally::schemaDef());
|
||||||
$schema->ensureTable('fave_tally',
|
|
||||||
array(
|
|
||||||
new ColumnDef('notice_id', 'integer', null, false, 'PRI'),
|
|
||||||
new ColumnDef('count', 'integer', null, false),
|
|
||||||
new ColumnDef(
|
|
||||||
'modified',
|
|
||||||
'timestamp',
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
null,
|
|
||||||
'CURRENT_TIMESTAMP',
|
|
||||||
'on update CURRENT_TIMESTAMP'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -52,72 +52,28 @@ class Fave_tally extends Managed_DataObject
|
|||||||
public $__table = 'fave_tally'; // table name
|
public $__table = 'fave_tally'; // table name
|
||||||
public $notice_id; // int(4) primary_key not_null
|
public $notice_id; // int(4) primary_key not_null
|
||||||
public $count; // int(4) not_null
|
public $count; // int(4) not_null
|
||||||
|
public $created; // datetime() not_null
|
||||||
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||||
|
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'count' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id'),
|
||||||
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL
|
'count' => array('type' => 'int', 'not null' => true, 'description' => 'the fave tally count'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
|
),
|
||||||
|
'primary key' => array('notice_id'),
|
||||||
|
'foreign keys' => array(
|
||||||
|
'fave_tally_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
|
||||||
* simply reference your keyTypes() function.
|
|
||||||
*
|
|
||||||
* @return array list of key field names
|
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('notice_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment a notice's tally
|
* Increment a notice's tally
|
||||||
*
|
*
|
||||||
|
@ -80,27 +80,8 @@ class BlacklistPlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing blacklist patterns for nicknames
|
// For storing blacklist patterns for nicknames
|
||||||
$schema->ensureTable('nickname_blacklist',
|
$schema->ensureTable('nickname_blacklist', Nickname_blacklist::schemaDef());
|
||||||
array(new ColumnDef('pattern',
|
$schema->ensureTable('homepage_blacklist', Homepage_blacklist::schemaDef());
|
||||||
'varchar',
|
|
||||||
255,
|
|
||||||
false,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('created',
|
|
||||||
'datetime',
|
|
||||||
null,
|
|
||||||
false)));
|
|
||||||
|
|
||||||
$schema->ensureTable('homepage_blacklist',
|
|
||||||
array(new ColumnDef('pattern',
|
|
||||||
'varchar',
|
|
||||||
255,
|
|
||||||
false,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('created',
|
|
||||||
'datetime',
|
|
||||||
null,
|
|
||||||
false)));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -47,47 +47,20 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
|||||||
class Homepage_blacklist extends Managed_DataObject
|
class Homepage_blacklist extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'homepage_blacklist'; // table name
|
public $__table = 'homepage_blacklist'; // table name
|
||||||
public $pattern; // string pattern
|
public $pattern; // varchar(255) pattern
|
||||||
public $created; // datetime
|
public $created; // datetime not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('pattern' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'fields' => array(
|
||||||
}
|
'pattern' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'blacklist pattern'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
/**
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
* return key definitions for DB_DataObject
|
),
|
||||||
*
|
'primary key' => array('pattern'),
|
||||||
* DB_DataObject needs to know about keys that the table has; this function
|
);
|
||||||
* defines them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('pattern' => 'K');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,38 +47,20 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
|||||||
class Nickname_blacklist extends Managed_DataObject
|
class Nickname_blacklist extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'nickname_blacklist'; // table name
|
public $__table = 'nickname_blacklist'; // table name
|
||||||
public $pattern; // string pattern
|
public $pattern; // varchar(255) pattern
|
||||||
public $created; // datetime
|
public $created; // datetime not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('pattern' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'fields' => array(
|
||||||
}
|
'pattern' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'blacklist pattern'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
/**
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
* return key definitions for DB_DataObject
|
),
|
||||||
*
|
'primary key' => array('pattern'),
|
||||||
* @return array key definitions
|
);
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('pattern' => 'K');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,19 +55,7 @@ class EmailSummaryPlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
$schema->ensureTable('email_summary_status',
|
$schema->ensureTable('email_summary_status', Email_summary_status::schemaDef());
|
||||||
array(new ColumnDef('user_id', 'integer', null,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('send_summary', 'tinyint', null,
|
|
||||||
false, null, 1),
|
|
||||||
new ColumnDef('last_summary_id', 'integer', null,
|
|
||||||
true),
|
|
||||||
new ColumnDef('created', 'datetime', null,
|
|
||||||
false),
|
|
||||||
new ColumnDef('modified', 'datetime', null,
|
|
||||||
false),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,58 +55,21 @@ class Email_summary_status extends Managed_DataObject
|
|||||||
public $created; // datetime not_null
|
public $created; // datetime not_null
|
||||||
public $modified; // datetime not_null
|
public $modified; // datetime not_null
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'send_summary' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'last_summary_id' => DB_DATAOBJECT_INT,
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||||
'created' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'send_summary' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'not null' => true, 'description' => 'whether to send a summary or not'),
|
||||||
'modified' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'last_summary_id' => array('type' => 'int', 'description' => 'last summary id'),
|
||||||
}
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
/**
|
),
|
||||||
* return key definitions for DB_DataObject
|
'primary key' => array('user_id'),
|
||||||
*
|
'foreign keys' => array(
|
||||||
* @return array list of key field names
|
'email_summary_status_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||||
*/
|
),
|
||||||
function keys()
|
);
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('user_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,11 +114,7 @@ class FollowEveryonePlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
$schema->ensureTable('user_followeveryone_prefs',
|
$schema->ensureTable('user_followeveryone_prefs', User_followeveryone_prefs::schemaDef());
|
||||||
array(new ColumnDef('user_id', 'integer', null,
|
|
||||||
true, 'PRI'),
|
|
||||||
new ColumnDef('followeveryone', 'tinyint', null,
|
|
||||||
false, null, 1)));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -57,65 +57,23 @@ class User_followeveryone_prefs extends Managed_DataObject
|
|||||||
public $__table = 'user_followeveryone_prefs'; // table name
|
public $__table = 'user_followeveryone_prefs'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $followeveryone; // tinyint(1)
|
public $followeveryone; // tinyint(1)
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'followeveryone' => DB_DATAOBJECT_INT + DB_DATAOBJECT_BOOL);
|
'fields' => array(
|
||||||
}
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||||
|
'followeveryone' => array('type' => 'int', 'default' => 1, 'size' => 'tiny', 'description' => 'whether to follow everyone'),
|
||||||
/**
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
* return key definitions for DB_DataObject
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
*
|
),
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
'primary key' => array('user_id'),
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
'foreign keys' => array(
|
||||||
* simply reference your keyTypes() function.
|
'user_followeveryone_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||||
*
|
),
|
||||||
* @return array list of key field names
|
);
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('user_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function followEveryone($user_id)
|
static function followEveryone($user_id)
|
||||||
|
@ -71,20 +71,8 @@ class GNUsocialPhotosPlugin extends Plugin
|
|||||||
function onCheckSchema()
|
function onCheckSchema()
|
||||||
{
|
{
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
$schema->ensureTable('GNUsocialPhoto',
|
$schema->ensureTable('GNUsocialPhoto', GNUsocialPhoto::schemaDef());
|
||||||
array(new ColumnDef('id', 'int(11)', null, false, 'PRI', null, null, true),
|
$schema->ensureTable('GNUsocialPhotoAlbum', GNUsocialPhotoAlbum::schemaDef());
|
||||||
new ColumnDef('notice_id', 'int(11)', null, false),
|
|
||||||
new ColumnDef('album_id', 'int(11)', null, false),
|
|
||||||
new ColumnDef('uri', 'varchar(512)', null, false),
|
|
||||||
new ColumnDef('thumb_uri', 'varchar(512)', null, false),
|
|
||||||
new ColumnDef('title', 'varchar(512)', null, false),
|
|
||||||
new ColumnDef('photo_description', 'text', null, false)));
|
|
||||||
$schema->ensureTable('GNUsocialPhotoAlbum',
|
|
||||||
array(new ColumnDef('album_id', 'int(11)', null, false, 'PRI', null, null, true),
|
|
||||||
new ColumnDef('profile_id', 'int(11)', null, false),
|
|
||||||
new ColumnDef('album_name', 'varchar(256)', null, false),
|
|
||||||
new ColumnDef('album_description', 'text', null, false)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRouterInitialized($m)
|
function onRouterInitialized($m)
|
||||||
|
@ -38,10 +38,12 @@ class GNUsocialPhoto extends Managed_DataObject
|
|||||||
public $id; // int(11)
|
public $id; // int(11)
|
||||||
public $notice_id; // int(11)
|
public $notice_id; // int(11)
|
||||||
public $album_id; // int(11)
|
public $album_id; // int(11)
|
||||||
public $uri; // varchar(512)
|
public $uri; // varchar(255)
|
||||||
public $thumb_uri; // varchar(512)
|
public $thumb_uri; // varchar(255)
|
||||||
public $title; // varchar(512)
|
public $title; // varchar(255)
|
||||||
public $photo_description; // text
|
public $photo_description; // text
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/* function delete()
|
/* function delete()
|
||||||
{
|
{
|
||||||
@ -54,34 +56,32 @@ class GNUsocialPhoto extends Managed_DataObject
|
|||||||
return parent::delete();
|
return parent::delete();
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
public static function schemaDef()
|
||||||
/*
|
|
||||||
* TODO: Foriegn key on album_id.
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'album_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for Photo'),
|
||||||
'uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'Notice ID for the related notice'),
|
||||||
'thumb_uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'album_id' => array('type' => 'int', 'not null' => true, 'description' => 'The parent album ID'),
|
||||||
'title' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'unique address for this photo'),
|
||||||
'photo_description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
|
'thumb_uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'unique address for this photo thumbnail'),
|
||||||
}
|
'title' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'The Photo title'),
|
||||||
|
'photo_description' => array('type' => 'text', 'not null' => true, 'description' => 'A description for this photo'),
|
||||||
function keys()
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
{
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
return array_keys($this->keyTypes());
|
),
|
||||||
}
|
'primary key' => array('id'),
|
||||||
|
'unique keys' => array(
|
||||||
function keyTypes()
|
'gnusocialphoto_uri' => array('uri'),
|
||||||
{
|
),
|
||||||
return array('notice_id' => 'K');
|
'foreign keys' => array(
|
||||||
}
|
'gnusocialphoto_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||||
|
'gnusocialphoto_album_id_fkey' => array('GNUsocialPhotoAlbum', array('album_id' => 'id')),
|
||||||
function sequenceKey()
|
),
|
||||||
{
|
'indexes' => array(
|
||||||
return array(false, false, false);
|
'gnusocialphoto_title_idx' => array('title'),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveNew($profile_id, $album_id, $thumb_uri, $uri, $source, $insert_now, $title = null, $photo_description = null)
|
function saveNew($profile_id, $album_id, $thumb_uri, $uri, $source, $insert_now, $title = null, $photo_description = null)
|
||||||
|
@ -38,33 +38,31 @@ class GNUsocialPhotoAlbum extends Managed_DataObject
|
|||||||
public $__table = 'GNUsocialPhotoAlbum';
|
public $__table = 'GNUsocialPhotoAlbum';
|
||||||
public $album_id; // int(11) -- Unique identifier for the album
|
public $album_id; // int(11) -- Unique identifier for the album
|
||||||
public $profile_id; // int(11) -- Profile ID for the owner of the album
|
public $profile_id; // int(11) -- Profile ID for the owner of the album
|
||||||
public $album_name; // varchar(256) -- Title for this album
|
public $album_name; // varchar(255) -- Title for this album
|
||||||
public $album_description; // text -- A description of the album
|
public $album_description; // text -- A description of the album
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/* TODO: Primary key on both album_id, profile_id / foriegn key on profile_id */
|
/* TODO: Primary key on both album_id, profile_id / foriegn key on profile_id */
|
||||||
function table()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
return array('album_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'album_name' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'album_id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique identifier for the album'),
|
||||||
'album_description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile ID for the owner of the album'),
|
||||||
}
|
'album_name' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'Title for this album'),
|
||||||
|
'album_description' => array('type' => 'text', 'not null' => true, 'description' => 'A description for this album'),
|
||||||
function keys()
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
{
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
return array_keys($this->keyTypes());
|
),
|
||||||
}
|
'primary key' => array('user_id'),
|
||||||
|
'foreign keys' => array(
|
||||||
|
'gnusocialphotoalbum_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||||
/* Using album_id as the primary key for now.. */
|
),
|
||||||
function keyTypes()
|
'indexes' => array(
|
||||||
{
|
'gnusocialphotoalbum_album_name_idx' => array('album_name'),
|
||||||
return array('album_id' => 'K');
|
),
|
||||||
}
|
);
|
||||||
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array('album_id', true, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPageLink()
|
function getPageLink()
|
||||||
|
@ -59,17 +59,8 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
|
|||||||
function onCheckSchema()
|
function onCheckSchema()
|
||||||
{
|
{
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
$schema->ensureTable('GNUsocialProfileExtensionField',
|
$schema->ensureTable('GNUsocialProfileExtensionField', GNUsocialProfileExtensionField::schemaDef());
|
||||||
array(new ColumnDef('id', 'int(11)', null, false, 'PRI', null, null, true),
|
$schema->ensureTable('GNUsocialProfileExtensionResponse', GNUsocialProfileExtensionResponse::schemaDef());
|
||||||
new ColumnDef('systemname', 'varchar(64)', null, false),
|
|
||||||
new ColumnDef('title', 'varchar(256)', null, false),
|
|
||||||
new ColumnDef('description', 'text', null, false),
|
|
||||||
new ColumnDef('type', 'varchar(256)', null, false)));
|
|
||||||
$schema->ensureTable('GNUsocialProfileExtensionResponse',
|
|
||||||
array(new ColumnDef('id', 'int(11)', null, false, 'PRI', null, null, true),
|
|
||||||
new ColumnDef('extension_id', 'int(11)', null, false),
|
|
||||||
new ColumnDef('profile_id', 'int(11)', null, false),
|
|
||||||
new ColumnDef('value', 'text', null, false)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,22 +37,29 @@ class GNUsocialProfileExtensionField extends Managed_DataObject
|
|||||||
public $__table = 'GNUsocialProfileExtensionField';
|
public $__table = 'GNUsocialProfileExtensionField';
|
||||||
public $id; // int(11)
|
public $id; // int(11)
|
||||||
public $systemname; // varchar(64)
|
public $systemname; // varchar(64)
|
||||||
public $title; // varchar(256)
|
public $title; // varchar(255)
|
||||||
public $description; // text
|
public $description; // text
|
||||||
public $type; // varchar(256)
|
public $type; // varchar(255)
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
function table()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'systemname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'title' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension field'),
|
||||||
'description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'systemname' => array('type' => 'varchar', 'not null' => true, 'length' => 64, 'description' => 'field systemname'),
|
||||||
'type' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
|
'title' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field title'),
|
||||||
}
|
'description' => array('type' => 'text', 'not null' => true, 'description' => 'field description'),
|
||||||
|
'type' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field type'),
|
||||||
function keys()
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
{
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
return array_keys($this->keyTypes());
|
),
|
||||||
|
'primary key' => array('id'),
|
||||||
|
'indexes' => array(
|
||||||
|
'gnusocialprofileextensionfield_title_idx' => array('title'),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyTypes()
|
function keyTypes()
|
||||||
|
@ -39,28 +39,29 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject
|
|||||||
public $extension_id; // int(11)
|
public $extension_id; // int(11)
|
||||||
public $profile_id; // int(11)
|
public $profile_id; // int(11)
|
||||||
public $value; // text
|
public $value; // text
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
function table()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'extension_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension response'),
|
||||||
'value' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
|
'extension_id' => array('type' => 'int', 'not null' => true, 'description' => 'The extension field ID'),
|
||||||
}
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile id that made the response'),
|
||||||
|
'value' => array('type' => 'text', 'not null' => true, 'description' => 'response entry'),
|
||||||
function keys()
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
{
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
return array_keys($this->keyTypes());
|
),
|
||||||
}
|
'primary key' => array('id'),
|
||||||
|
'foreign keys' => array(
|
||||||
function keyTypes()
|
'gnusocialprofileextensionresponse_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||||
{
|
'gnusocialprofileextensionresponse_extension_id_fkey' => array('GNUsocialProfileExtensionField', array('extension_id' => 'id')),
|
||||||
return array('id' => 'K');
|
),
|
||||||
}
|
'indexes' => array(
|
||||||
|
'gnusocialprofileextensionresponse_extension_id_idx' => array('extension_id'),
|
||||||
function sequenceKey()
|
),
|
||||||
{
|
);
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function newResponse($extension_id, $profile_id, $value)
|
static function newResponse($extension_id, $profile_id, $value)
|
||||||
|
@ -61,69 +61,9 @@ class GroupPrivateMessagePlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
|
$schema->ensureTable('group_privacy_settings', Group_privacy_settings::schemaDef());
|
||||||
$schema->ensureTable('group_privacy_settings',
|
$schema->ensureTable('group_message', Group_message::schemaDef());
|
||||||
array(new ColumnDef('group_id',
|
$schema->ensureTable('group_message_profile', Group_message_profile::schemaDef());
|
||||||
'integer',
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('allow_privacy',
|
|
||||||
'integer'),
|
|
||||||
new ColumnDef('allow_sender',
|
|
||||||
'integer'),
|
|
||||||
new ColumnDef('created',
|
|
||||||
'datetime'),
|
|
||||||
new ColumnDef('modified',
|
|
||||||
'timestamp')));
|
|
||||||
|
|
||||||
$schema->ensureTable('group_message',
|
|
||||||
array(new ColumnDef('id',
|
|
||||||
'char',
|
|
||||||
36,
|
|
||||||
false,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('uri',
|
|
||||||
'varchar',
|
|
||||||
255,
|
|
||||||
false,
|
|
||||||
'UNI'),
|
|
||||||
new ColumnDef('from_profile',
|
|
||||||
'integer',
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
'MUL'),
|
|
||||||
new ColumnDef('to_group',
|
|
||||||
'integer',
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
'MUL'),
|
|
||||||
new ColumnDef('content',
|
|
||||||
'text'),
|
|
||||||
new ColumnDef('rendered',
|
|
||||||
'text'),
|
|
||||||
new ColumnDef('url',
|
|
||||||
'varchar',
|
|
||||||
255,
|
|
||||||
false,
|
|
||||||
'UNI'),
|
|
||||||
new ColumnDef('created',
|
|
||||||
'datetime')));
|
|
||||||
|
|
||||||
$schema->ensureTable('group_message_profile',
|
|
||||||
array(new ColumnDef('to_profile',
|
|
||||||
'integer',
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('group_message_id',
|
|
||||||
'char',
|
|
||||||
36,
|
|
||||||
false,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('created',
|
|
||||||
'datetime')));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,59 +47,44 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
|||||||
class Group_message extends Managed_DataObject
|
class Group_message extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'group_message'; // table name
|
public $__table = 'group_message'; // table name
|
||||||
public $id; // char(36) primary_key not_null
|
public $id; // varchar(36) primary_key not_null
|
||||||
public $uri; // varchar(255)
|
public $uri; // varchar(255)
|
||||||
public $from_profile; // int
|
public $from_profile; // int
|
||||||
public $to_group; // int
|
public $to_group; // int
|
||||||
public $content;
|
public $content;
|
||||||
public $rendered;
|
public $rendered;
|
||||||
public $url;
|
public $url;
|
||||||
public $created;
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('id' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'from_profile' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'id' => array('type' => 'varchar', 'not null' => true, 'length' => 36, 'description' => 'message uuid'),
|
||||||
'to_group' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'message uri'),
|
||||||
'content' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'url' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'representation url'),
|
||||||
'rendered' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'from_profile' => array('type' => 'int', 'not null' => true, 'description' => 'sending profile ID'),
|
||||||
'url' => DB_DATAOBJECT_STR,
|
'to_group' => array('type' => 'int', 'not null' => true, 'description' => 'receiving group ID'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'content' => array('type' => 'text', 'not null' => true, 'description' => 'message content'),
|
||||||
}
|
'rendered' => array('type' => 'text', 'not null' => true, 'description' => 'rendered message'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
/**
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
* return key definitions for DB_DataObject
|
),
|
||||||
*
|
'primary key' => array('id'),
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
'unique keys' => array(
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
'group_message_uri_key' => array('uri'),
|
||||||
* simply reference your keyTypes() function.
|
),
|
||||||
*
|
'foreign keys' => array(
|
||||||
* @return array list of key field names
|
'group_message_from_profile_fkey' => array('profile', array('from_profile' => 'id')),
|
||||||
*/
|
'group_message_to_group_fkey' => array('user_group', array('to_group' => 'id')),
|
||||||
function keys()
|
),
|
||||||
{
|
'indexes' => array(
|
||||||
return array_keys($this->keyTypes());
|
'group_message_from_profile_idx' => array('from_profile'),
|
||||||
}
|
'group_message_to_group_idx' => array('to_group'),
|
||||||
|
'group_message_url_idx' => array('url'),
|
||||||
/**
|
),
|
||||||
* return key definitions for Memcached_DataObject
|
);
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('id' => 'K', 'uri' => 'U');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function send($user, $group, $text)
|
static function send($user, $group, $text)
|
||||||
|
@ -48,56 +48,25 @@ class Group_message_profile extends Managed_DataObject
|
|||||||
{
|
{
|
||||||
public $__table = 'group_message_profile'; // table name
|
public $__table = 'group_message_profile'; // table name
|
||||||
public $to_profile; // int
|
public $to_profile; // int
|
||||||
public $group_message_id; // char(36) primary_key not_null
|
public $group_message_id; // varchar(36) primary_key not_null
|
||||||
public $created;
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('to_profile' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'group_message_id' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'to_profile' => array('type' => 'int', 'not null' => true, 'description' => 'id of group direct message'),
|
||||||
}
|
'group_message_id' => array('type' => 'varchar', 'not null' => true, 'length' => 36, 'description' => 'group message uuid'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
/**
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
* return key definitions for DB_DataObject
|
),
|
||||||
*
|
'primary key' => array('to_profile', 'group_message_id'),
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
'foreign keys' => array(
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
'group_message_profile_to_profile_fkey' => array('profile', array('to_profile' => 'id')),
|
||||||
* simply reference your keyTypes() function.
|
'group_message_profile_group_message_id_fkey' => array('group_message', array('group_message_id' => 'id')),
|
||||||
*
|
),
|
||||||
* @return array list of key field names
|
);
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('to_profile' => 'K', 'group_message_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No sequence keys in this table.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function send($gm, $profile)
|
function send($gm, $profile)
|
||||||
|
@ -70,58 +70,21 @@ class Group_privacy_settings extends Managed_DataObject
|
|||||||
const MEMBER = 2;
|
const MEMBER = 2;
|
||||||
const ADMIN = 4;
|
const ADMIN = 4;
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('group_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'allow_privacy' => DB_DATAOBJECT_INT,
|
'fields' => array(
|
||||||
'allow_sender' => DB_DATAOBJECT_INT,
|
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group_privacy_settings'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'allow_privacy' => array('type' => 'int', 'not null' => true, 'description' => 'sometimes=-1, never=0, always=1'),
|
||||||
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'allow_sender' => array('type' => 'int', 'not null' => true, 'description' => 'list of bit-mappy values in source code'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
}
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
|
),
|
||||||
/**
|
'primary key' => array('group_id'),
|
||||||
* return key definitions for DB_DataObject
|
'foreign keys' => array(
|
||||||
*
|
'group_privacy_settings_group_id_fkey' => array('user_group', array('group_id' => 'id')),
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
),
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
);
|
||||||
* simply reference your keyTypes() function.
|
|
||||||
*
|
|
||||||
* @return array list of key field names
|
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('group_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function forGroup($group)
|
function forGroup($group)
|
||||||
|
@ -160,15 +160,7 @@ class IrcPlugin extends ImPlugin {
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing messages while sessions become ready
|
// For storing messages while sessions become ready
|
||||||
$schema->ensureTable('irc_waiting_message',
|
$schema->ensureTable('irc_waiting_message', Irc_waiting_message::schemaDef());
|
||||||
array(new ColumnDef('id', 'integer', null,
|
|
||||||
false, 'PRI', null, null, true),
|
|
||||||
new ColumnDef('data', 'blob', null, false),
|
|
||||||
new ColumnDef('prioritise', 'tinyint', 1, false),
|
|
||||||
new ColumnDef('attempts', 'integer', null, false),
|
|
||||||
new ColumnDef('created', 'datetime', null, false),
|
|
||||||
new ColumnDef('claimed', 'datetime')));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,66 +12,27 @@ class Irc_waiting_message extends Managed_DataObject {
|
|||||||
public $data; // blob not_null
|
public $data; // blob not_null
|
||||||
public $prioritise; // tinyint(1) not_null
|
public $prioritise; // tinyint(1) not_null
|
||||||
public $attempts; // int not_null
|
public $attempts; // int not_null
|
||||||
public $created; // datetime() not_null
|
|
||||||
public $claimed; // datetime()
|
public $claimed; // datetime()
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
{
|
||||||
*
|
return array(
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
'fields' => array(
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for entry'),
|
||||||
*
|
'data' => array('type' => 'blob', 'not null' => true, 'description' => 'data blob'),
|
||||||
* @return array array of column definitions
|
'prioritise' => array('type' => 'int', 'size' => 'tiny', 'description' => 'tinyint priority value'),
|
||||||
*/
|
'attempts' => array('type' => 'int', 'not null' => true, 'description' => 'attempts count'),
|
||||||
public function table() {
|
'claimed' => array('type' => 'datetime', 'description' => 'date this irc message was claimed'),
|
||||||
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
'data' => DB_DATAOBJECT_BLOB + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
'prioritise' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
),
|
||||||
'created' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'primary key' => array('id'),
|
||||||
'claimed' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR);
|
'indexes' => array(
|
||||||
}
|
'irc_waiting_message_prioritise_idx' => array('prioritise'),
|
||||||
|
),
|
||||||
/**
|
);
|
||||||
* return key definitions for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
|
||||||
* simply reference your keyTypes() function.
|
|
||||||
*
|
|
||||||
* @return array list of key field names
|
|
||||||
*/
|
|
||||||
public function keys() {
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
public function keyTypes() {
|
|
||||||
return array('id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
public function sequenceKey() {
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,14 +133,7 @@ class MsnPlugin extends ImPlugin {
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing messages while sessions become ready
|
// For storing messages while sessions become ready
|
||||||
$schema->ensureTable('msn_waiting_message',
|
$schema->ensureTable('msn_waiting_message', Msn_waiting_message::schemaGet());
|
||||||
array(new ColumnDef('id', 'integer', null,
|
|
||||||
false, 'PRI', null, null, true),
|
|
||||||
new ColumnDef('screenname', 'varchar', 255, false),
|
|
||||||
new ColumnDef('message', 'text', null, false),
|
|
||||||
new ColumnDef('created', 'datetime', null, false),
|
|
||||||
new ColumnDef('claimed', 'datetime')));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,66 +10,26 @@ class Msn_waiting_message extends Managed_DataObject {
|
|||||||
public $id; // int primary_key not_null auto_increment
|
public $id; // int primary_key not_null auto_increment
|
||||||
public $screenname; // varchar(255) not_null
|
public $screenname; // varchar(255) not_null
|
||||||
public $message; // text not_null
|
public $message; // text not_null
|
||||||
public $created; // datetime() not_null
|
|
||||||
public $claimed; // datetime()
|
public $claimed; // datetime()
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
{
|
||||||
*
|
return array(
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
'fields' => array(
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for entry'),
|
||||||
*
|
'screenname' => array('type' => 'varchar', 'length' => 255, 'description' => 'from screenname'),
|
||||||
* @return array array of column definitions
|
'message' => array('type' => 'text', 'not null' => true, 'description' => 'MSN message text'),
|
||||||
*/
|
'claimed' => array('type' => 'datetime', 'description' => 'date this irc message was claimed'),
|
||||||
public function table() {
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
'screenname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
),
|
||||||
'message' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'primary key' => array('id'),
|
||||||
'created' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'indexes' => array(
|
||||||
'claimed' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR);
|
'msn_waiting_message_prioritise_idx' => array('screenname'),
|
||||||
}
|
),
|
||||||
|
);
|
||||||
/**
|
|
||||||
* return key definitions for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
|
||||||
* simply reference your keyTypes() function.
|
|
||||||
*
|
|
||||||
* @return array list of key field names
|
|
||||||
*/
|
|
||||||
public function keys() {
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
public function keyTypes() {
|
|
||||||
return array('id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey() {
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,18 +71,7 @@ class NoticeTitlePlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing titles for notices
|
// For storing titles for notices
|
||||||
|
$schema->ensureTable('notice_title', Notice_title::schemaDef());
|
||||||
$schema->ensureTable('notice_title',
|
|
||||||
array(new ColumnDef('notice_id',
|
|
||||||
'integer',
|
|
||||||
null,
|
|
||||||
true,
|
|
||||||
'PRI'),
|
|
||||||
new ColumnDef('title',
|
|
||||||
'varchar',
|
|
||||||
Notice_title::MAXCHARS,
|
|
||||||
false)));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,51 +49,25 @@ class Notice_title extends Managed_DataObject
|
|||||||
const MAXCHARS = 255;
|
const MAXCHARS = 255;
|
||||||
|
|
||||||
public $__table = 'notice_title'; // table name
|
public $__table = 'notice_title'; // table name
|
||||||
public $notice_id; // int(4) primary_key not_null
|
public $notice_id; // int(11) primary_key not_null
|
||||||
public $title; // varchar(255)
|
public $title; // varchar(255)
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'title' => DB_DATAOBJECT_STR);
|
'fields' => array(
|
||||||
}
|
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
|
||||||
|
'title' => array('type' => 'varchar', 'length' => Notice_title::MAXCHARS, 'description' => 'title to notice'),
|
||||||
/**
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
* return key definitions for DB_DataObject
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
*
|
),
|
||||||
* @return array list of key field names
|
'primary key' => array('notice_id'),
|
||||||
*/
|
'foreign keys' => array(
|
||||||
function keys()
|
'notice_title_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||||
{
|
),
|
||||||
return array_keys($this->keyTypes());
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* @return array list mapping field names to key types
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('notice_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,25 +554,8 @@ class OpenIDPlugin extends Plugin
|
|||||||
function onCheckSchema()
|
function onCheckSchema()
|
||||||
{
|
{
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
$schema->ensureTable('user_openid',
|
$schema->ensureTable('user_openid', User_openid::schemaDef());
|
||||||
array(new ColumnDef('canonical', 'varchar',
|
$schema->ensureTable('user_openid_trustroot', User_openid_trustroot::schemaDef());
|
||||||
'255', false, 'PRI'),
|
|
||||||
new ColumnDef('display', 'varchar',
|
|
||||||
'255', false, 'UNI'),
|
|
||||||
new ColumnDef('user_id', 'integer',
|
|
||||||
null, false, 'MUL'),
|
|
||||||
new ColumnDef('created', 'datetime',
|
|
||||||
null, false),
|
|
||||||
new ColumnDef('modified', 'timestamp')));
|
|
||||||
$schema->ensureTable('user_openid_trustroot',
|
|
||||||
array(new ColumnDef('trustroot', 'varchar',
|
|
||||||
'255', false, 'PRI'),
|
|
||||||
new ColumnDef('user_id', 'integer',
|
|
||||||
null, false, 'PRI'),
|
|
||||||
new ColumnDef('created', 'datetime',
|
|
||||||
null, false),
|
|
||||||
new ColumnDef('modified', 'timestamp')));
|
|
||||||
|
|
||||||
$schema->ensureTable('user_openid_prefs', User_openid_prefs::schemaDef());
|
$schema->ensureTable('user_openid_prefs', User_openid_prefs::schemaDef());
|
||||||
|
|
||||||
/* These are used by JanRain OpenID library */
|
/* These are used by JanRain OpenID library */
|
||||||
|
@ -22,41 +22,27 @@ class User_openid extends Managed_DataObject
|
|||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
function table()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
$db = $this->getDatabaseConnection();
|
return array(
|
||||||
$dbtype = $db->phptype; // Database type is stored here. Crazy but true.
|
'fields' => array(
|
||||||
|
'canonical' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'OpenID canonical string'),
|
||||||
return array('canonical' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'display' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'OpenID display string'),
|
||||||
'display' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'User ID for OpenID owner'),
|
||||||
'user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
'modified' => ($dbtype == 'mysql' || $dbtype == 'mysqli') ?
|
),
|
||||||
DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL :
|
'primary key' => array('canonical'),
|
||||||
DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
|
'unique keys' => array(
|
||||||
);
|
'user_openid_display_key' => array('display'),
|
||||||
}
|
),
|
||||||
|
'indexes' => array(
|
||||||
/**
|
'user_openid_user_id_idx' => array('user_id'),
|
||||||
* List primary and unique keys in this table.
|
),
|
||||||
* Unique keys used for lookup *MUST* be listed to ensure proper caching.
|
'foreign keys' => array(
|
||||||
*/
|
'user_openid_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||||
function keys()
|
),
|
||||||
{
|
);
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('canonical' => 'K', 'display' => 'U', 'user_id' => 'U');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No sequence keys in this table.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function hasOpenID($user_id)
|
static function hasOpenID($user_id)
|
||||||
|
@ -21,27 +21,16 @@ class User_openid_trustroot extends Managed_DataObject
|
|||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
function table()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
$db = $this->getDatabaseConnection();
|
return array(
|
||||||
$dbtype = $db->phptype; // Database type is stored here. Crazy but true.
|
'fields' => array(
|
||||||
|
'trustroot' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'OpenID trustroot string'),
|
||||||
return array('trustroot' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'User ID for OpenID trustroot owner'),
|
||||||
'user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
'modified' => ($dbtype == 'mysql' || $dbtype == 'mysqli') ?
|
),
|
||||||
DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL :
|
'primary key' => array('trustroot', 'user_id'),
|
||||||
DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('trustroot' => 'K', 'user_id' => 'K');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,7 @@ class RegisterThrottlePlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
$schema->ensureTable('registration_ip',
|
$schema->ensureTable('registration_ip', Registration_ip::schemaDef());
|
||||||
array(new ColumnDef('user_id', 'integer', null,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('ipaddress', 'varchar', 15, false, 'MUL'),
|
|
||||||
new ColumnDef('created', 'timestamp', null, false, 'MUL')));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,59 +47,27 @@ class Registration_ip extends Managed_DataObject
|
|||||||
public $__table = 'registration_ip'; // table name
|
public $__table = 'registration_ip'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $ipaddress; // varchar(15)
|
public $ipaddress; // varchar(15)
|
||||||
public $created; // timestamp
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'ipaddress' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'created' => DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL);
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id this registration relates to'),
|
||||||
}
|
'ipaddress' => array('type' => 'varchar', 'length' => 45, 'description' => 'IP address, max 45+null in IPv6'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
/**
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
* return key definitions for DB_DataObject
|
),
|
||||||
*
|
'primary key' => array('user_id'),
|
||||||
* DB_DataObject needs to know about keys that the table has; this function
|
'foreign keys' => array(
|
||||||
* defines them.
|
'registration_ip_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||||
*
|
),
|
||||||
* @return array key definitions
|
'indexes' => array(
|
||||||
*/
|
'registration_ip_ipaddress_idx' => array('ipaddress'),
|
||||||
function keys()
|
'registration_ip_created_idx' => array('created'),
|
||||||
{
|
),
|
||||||
return array('user_id' => 'K');
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return $this->keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,23 +170,7 @@ class SamplePlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
|
$schema->ensureTable('user_greeting_count', User_greeting_count::schemaDef());
|
||||||
$schema->ensureTable('user_greeting_count',
|
|
||||||
array(
|
|
||||||
'fields' => array(
|
|
||||||
'user_id' => array('type' => 'int', 'not null' => true),
|
|
||||||
'greeting_count' => array('type' => 'int'),
|
|
||||||
),
|
|
||||||
'primary key' => array('user_id'),
|
|
||||||
'foreign keys' => array(
|
|
||||||
// Not all databases will support foreign keys, but even
|
|
||||||
// when not enforced it's helpful to include these definitions
|
|
||||||
// as documentation.
|
|
||||||
'user_greeting_count_user_id_fkey' => array('user', array('user_id' => 'id')),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,65 +57,23 @@ class User_greeting_count extends Managed_DataObject
|
|||||||
public $__table = 'user_greeting_count'; // table name
|
public $__table = 'user_greeting_count'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $greeting_count; // int(4)
|
public $greeting_count; // int(4)
|
||||||
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'greeting_count' => DB_DATAOBJECT_INT);
|
'fields' => array(
|
||||||
}
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||||
|
'greeting_count' => array('type' => 'int', 'not null' => true, 'description' => 'the greeting count'),
|
||||||
/**
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
* return key definitions for DB_DataObject
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
*
|
),
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
'primary key' => array('user_id'),
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
'foreign keys' => array(
|
||||||
* simply reference your keyTypes() function.
|
'user_greeting_count_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||||
*
|
),
|
||||||
* @return array list of key field names
|
);
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('user_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,22 +180,8 @@ class SitemapPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
$schema->ensureTable('sitemap_user_count',
|
$schema->ensureTable('sitemap_user_count', Sitemap_user_count::schemaDef());
|
||||||
array(new ColumnDef('registration_date', 'date', null,
|
$schema->ensureTable('sitemap_notice_count', Sitemap_notice_count::schemaDef());
|
||||||
true, 'PRI'),
|
|
||||||
new ColumnDef('user_count', 'integer'),
|
|
||||||
new ColumnDef('created', 'datetime',
|
|
||||||
null, false),
|
|
||||||
new ColumnDef('modified', 'timestamp')));
|
|
||||||
|
|
||||||
$schema->ensureTable('sitemap_notice_count',
|
|
||||||
array(new ColumnDef('notice_date', 'date', null,
|
|
||||||
true, 'PRI'),
|
|
||||||
new ColumnDef('notice_count', 'integer'),
|
|
||||||
new ColumnDef('created', 'datetime',
|
|
||||||
null, false),
|
|
||||||
new ColumnDef('modified', 'timestamp')));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,49 +57,20 @@ class Sitemap_notice_count extends Managed_DataObject
|
|||||||
|
|
||||||
public $notice_date; // date primary_key not_null
|
public $notice_date; // date primary_key not_null
|
||||||
public $notice_count; // int(4)
|
public $notice_count; // int(4)
|
||||||
public $created;
|
public $created; // datetime() not_null
|
||||||
public $modified;
|
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('notice_date' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'notice_count' => DB_DATAOBJECT_INT,
|
'fields' => array(
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'notice_date' => array('type' => 'date', 'not null' => true, 'description' => 'record date'),
|
||||||
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'notice_count' => array('type' => 'int', 'not null' => true, 'description' => 'the notice count'),
|
||||||
}
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
/**
|
),
|
||||||
* return key definitions for DB_DataObject
|
'primary key' => array('notice_date'),
|
||||||
*
|
);
|
||||||
* DB_DataObject needs to know about keys that the table has; this function
|
|
||||||
* defines them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array('notice_date' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return $this->keys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAll()
|
static function getAll()
|
||||||
|
@ -53,55 +53,20 @@ class Sitemap_user_count extends Managed_DataObject
|
|||||||
|
|
||||||
public $registration_date; // date primary_key not_null
|
public $registration_date; // date primary_key not_null
|
||||||
public $user_count; // int(4)
|
public $user_count; // int(4)
|
||||||
public $created;
|
public $created; // datetime() not_null
|
||||||
public $modified;
|
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('registration_date' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'user_count' => DB_DATAOBJECT_INT,
|
'fields' => array(
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'registration_date' => array('type' => 'date', 'not null' => true, 'description' => 'record date'),
|
||||||
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'user_count' => array('type' => 'int', 'not null' => true, 'description' => 'the user count of the recorded date'),
|
||||||
}
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
/**
|
),
|
||||||
* return key definitions for DB_DataObject
|
'primary key' => array('registration_date'),
|
||||||
*
|
);
|
||||||
* DB_DataObject needs to know about keys that the table has; this function
|
|
||||||
* defines them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array('registration_date' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them.
|
|
||||||
*
|
|
||||||
* @return array key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return $this->keys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAll()
|
static function getAll()
|
||||||
|
@ -57,68 +57,27 @@ class Notice_to_status extends Managed_DataObject
|
|||||||
{
|
{
|
||||||
public $__table = 'notice_to_status'; // table name
|
public $__table = 'notice_to_status'; // table name
|
||||||
public $notice_id; // int(4) primary_key not_null
|
public $notice_id; // int(4) primary_key not_null
|
||||||
public $status_id; // int(4)
|
public $status_id; // bigint not_null
|
||||||
public $created; // datetime
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'status_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'local notice id'),
|
||||||
}
|
'status_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'twitter status id'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
/**
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
* return key definitions for DB_DataObject
|
),
|
||||||
*
|
'primary key' => array('notice_id'),
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
'unique keys' => array(
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
'status_id_key' => array('status_id'),
|
||||||
* simply reference your keyTypes() function.
|
),
|
||||||
*
|
'foreign keys' => array(
|
||||||
* @return array list of key field names
|
'notice_to_status_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||||
*/
|
),
|
||||||
function keys()
|
);
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('notice_id' => 'K', 'status_id' => 'U');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,28 +404,10 @@ class TwitterBridgePlugin extends Plugin
|
|||||||
|
|
||||||
// For saving the last-synched status of various timelines
|
// For saving the last-synched status of various timelines
|
||||||
// home_timeline, messages (in), messages (out), ...
|
// home_timeline, messages (in), messages (out), ...
|
||||||
|
$schema->ensureTable('twitter_synch_status', Twitter_sync_status::schemaDef());
|
||||||
$schema->ensureTable('twitter_synch_status',
|
|
||||||
array(new ColumnDef('foreign_id', 'bigint', null,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('timeline', 'varchar', 255,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('last_id', 'bigint', null, // XXX: check for PostgreSQL
|
|
||||||
false),
|
|
||||||
new ColumnDef('created', 'datetime', null,
|
|
||||||
false),
|
|
||||||
new ColumnDef('modified', 'datetime', null,
|
|
||||||
false)));
|
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
|
$schema->ensureTable('notice_to_status', Notice_to_status::schemaDef());
|
||||||
$schema->ensureTable('notice_to_status',
|
|
||||||
array(new ColumnDef('notice_id', 'integer', null,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('status_id', 'bigint', null, // XXX: check for PostgreSQL
|
|
||||||
false, 'UNI'),
|
|
||||||
new ColumnDef('created', 'datetime', null,
|
|
||||||
false)));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,75 +51,24 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
|||||||
class Twitter_synch_status extends Managed_DataObject
|
class Twitter_synch_status extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'twitter_synch_status'; // table name
|
public $__table = 'twitter_synch_status'; // table name
|
||||||
public $foreign_id; // int(4) primary_key not_null
|
public $foreign_id; // bigint primary_key not_null
|
||||||
public $timeline; // varchar(255) primary_key not_null
|
public $timeline; // varchar(255) primary_key not_null
|
||||||
public $last_id; // bigint not_null
|
public $last_id; // bigint not_null
|
||||||
public $created; // datetime not_null
|
public $created; // datetime() not_null
|
||||||
public $modified; // datetime not_null
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array('foreign_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
return array(
|
||||||
'timeline' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'last_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'Foreign message ID'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'timeline' => array('type' => 'varchar', 'length' => 255, 'description' => 'timeline name'),
|
||||||
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL
|
'last_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'last id fetched'),
|
||||||
);
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
}
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
|
),
|
||||||
/**
|
'primary key' => array('foreign_id', 'timeline'),
|
||||||
* return key definitions for DB_DataObject
|
);
|
||||||
*
|
|
||||||
* DB_DataObject needs to know about keys that the table has, since it
|
|
||||||
* won't appear in StatusNet's own keys list. In most cases, this will
|
|
||||||
* simply reference your keyTypes() function.
|
|
||||||
*
|
|
||||||
* @return array list of key field names
|
|
||||||
*/
|
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* Our caching system uses the same key definitions, but uses a different
|
|
||||||
* method to get them. This key information is used to store and clear
|
|
||||||
* cached data, so be sure to list any key that will be used for static
|
|
||||||
* lookups.
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions, field name to type:
|
|
||||||
* 'K' for primary key: for compound keys, add an entry for each component;
|
|
||||||
* 'U' for unique keys: compound keys are not well supported here.
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('foreign_id' => 'K',
|
|
||||||
'timeline' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLastId($foreign_id, $timeline)
|
static function getLastId($foreign_id, $timeline)
|
||||||
|
@ -60,17 +60,7 @@ class UserFlagPlugin extends Plugin
|
|||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
// For storing user-submitted flags on profiles
|
// For storing user-submitted flags on profiles
|
||||||
|
$schema->ensureTable('user_flag_profile', User_flag_profile::schemaDef());
|
||||||
$schema->ensureTable('user_flag_profile',
|
|
||||||
array(new ColumnDef('profile_id', 'integer', null,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('user_id', 'integer', null,
|
|
||||||
false, 'PRI'),
|
|
||||||
new ColumnDef('created', 'datetime', null,
|
|
||||||
false, 'MUL'),
|
|
||||||
new ColumnDef('cleared', 'datetime', null,
|
|
||||||
true, 'MUL')));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,62 +50,31 @@ class User_flag_profile extends Managed_DataObject
|
|||||||
/* the code below is auto generated do not remove the above tag */
|
/* the code below is auto generated do not remove the above tag */
|
||||||
|
|
||||||
public $__table = 'user_flag_profile'; // table name
|
public $__table = 'user_flag_profile'; // table name
|
||||||
public $profile_id; // int(4) primary_key not_null
|
public $profile_id; // int(11) primary_key not_null
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(11) primary_key not_null
|
||||||
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $cleared; // datetime default_0000-00-00%2000%3A00%3A00
|
||||||
public $cleared; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null
|
||||||
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* return table definition for DB_DataObject
|
|
||||||
*
|
|
||||||
* @return array array of column definitions
|
|
||||||
*/
|
|
||||||
function table()
|
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'fields' => array(
|
||||||
'user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile id flagged'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id of the actor'),
|
||||||
'cleared' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
|
'cleared' => array('type' => 'datetime', 'description' => 'when flag was removed'),
|
||||||
);
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
}
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
|
),
|
||||||
/**
|
'primary key' => array('profile_id', 'user_id'),
|
||||||
* return key definitions for DB_DataObject
|
'indexes' => array(
|
||||||
*
|
'user_flag_profile_cleared_idx' => array('cleared'),
|
||||||
* @return array of key names
|
'user_flag_profile_created_idx' => array('created'),
|
||||||
*/
|
),
|
||||||
function keys()
|
);
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for DB_DataObject
|
|
||||||
*
|
|
||||||
* @return array map of key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('profile_id' => 'K', 'user_id' => 'K');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* If a table has a single integer column as its primary key, DB_DataObject
|
|
||||||
* assumes that the column is auto-incrementing and makes a sequence table
|
|
||||||
* to do this incrementation. Since we don't need this for our class, we
|
|
||||||
* overload this method and return the magic formula that DB_DataObject needs.
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user