<?php\r
/**\r
- * Table Definition for msn_plugin_message\r
+ * Table Definition for msn_waiting_message\r
*/\r
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';\r
\r
-class Msn_waiting_message extends Memcached_DataObject {\r
+class Msn_waiting_message extends Managed_DataObject {\r
\r
public $__table = 'msn_waiting_message'; // table name\r
public $id; // int primary_key not_null auto_increment\r
public $screenname; // varchar(255) not_null\r
public $message; // text not_null\r
- public $created; // datetime() not_null\r
public $claimed; // datetime()\r
+ public $created; // datetime() not_null\r
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP\r
\r
- /* Static get */\r
- public function staticGet($k, $v = null) {\r
- return Memcached_DataObject::staticGet('Msn_waiting_message', $k, $v);\r
+ public static function schemaDef()\r
+ {\r
+ return array(\r
+ 'fields' => array(\r
+ 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique ID for entry'),\r
+ 'screenname' => array('type' => 'varchar', 'length' => 255, 'description' => 'from screenname'),\r
+ 'message' => array('type' => 'text', 'not null' => true, 'description' => 'MSN message text'),\r
+ 'claimed' => array('type' => 'datetime', 'description' => 'date this irc message was claimed'),\r
+ 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),\r
+ 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),\r
+ ),\r
+ 'primary key' => array('id'),\r
+ 'indexes' => array(\r
+ 'msn_waiting_message_prioritise_idx' => array('screenname'),\r
+ ),\r
+ );\r
}\r
\r
/**\r
- * @param mixed $screenname screenname or array of screennames to pull from\r
+ * @param string $screenname screenname or array of screennames to pull from\r
* If not specified, checks all queues in the system.\r
*/\r
public static function top($screenname = null) {\r
if ($screenname) {\r
if (is_array($screenname)) {\r
// @fixme use safer escaping\r
- $list = implode("','", array_map('addslashes', $transports));\r
- $wm->whereAdd("screename in ('$list')");\r
+ $list = implode("','", array_map('addslashes', $screenname));\r
+ $wm->whereAdd("screenname in ('$list')");\r
} else {\r
$wm->screenname = $screenname;\r
}\r
$cnt = $wm->find(true);\r
\r
if ($cnt) {\r
- # XXX: potential race condition\r
- # can we force it to only update if claimed is still null\r
- # (or old)?\r
+ // XXX: potential race condition\r
+ // can we force it to only update if claimed is still null\r
+ // (or old)?\r
common_log(LOG_INFO, 'claiming msn waiting message id = ' . $wm->id);\r
$orig = clone($wm);\r
$wm->claimed = common_sql_now();\r