]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Msn/msn_waiting_message.php
More info for a proper, fancy-url lighttpd setup
[quix0rs-gnu-social.git] / plugins / Msn / msn_waiting_message.php
index 0af7c4f3ec25df3bf3a9655b7acdd650b720e49d..cfb69def004f0c9b8aac9eda129ba1fc1f652d29 100644 (file)
@@ -4,77 +4,32 @@
  */\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
-    }\r
-\r
-    /**\r
-    * return table definition for DB_DataObject\r
-    *\r
-    * DB_DataObject needs to know something about the table to manipulate\r
-    * instances. This method provides all the DB_DataObject needs to know.\r
-    *\r
-    * @return array array of column definitions\r
-    */\r
-    public function table() {\r
-        return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,\r
-                     'screenname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
-                     'message' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
-                     'created' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
-                     'claimed' => DB_DATAOBJECT_TIME + DB_DATAOBJECT_STR);\r
-    }\r
-\r
-    /**\r
-    * return key definitions for DB_DataObject\r
-    *\r
-    * DB_DataObject needs to know about keys that the table has, since it\r
-    * won't appear in StatusNet's own keys list. In most cases, this will\r
-    * simply reference your keyTypes() function.\r
-    *\r
-    * @return array list of key field names\r
-    */\r
-    public function keys() {\r
-        return array_keys($this->keyTypes());\r
-    }\r
-\r
-    /**\r
-    * return key definitions for Memcached_DataObject\r
-    *\r
-    * Our caching system uses the same key definitions, but uses a different\r
-    * method to get them. This key information is used to store and clear\r
-    * cached data, so be sure to list any key that will be used for static\r
-    * lookups.\r
-    *\r
-    * @return array associative array of key definitions, field name to type:\r
-    *         'K' for primary key: for compound keys, add an entry for each component;\r
-    *         'U' for unique keys: compound keys are not well supported here.\r
-    */\r
-    public function keyTypes() {\r
-        return array('id' => 'K');\r
-    }\r
-\r
-    /**\r
-    * Magic formula for non-autoincrementing integer primary keys\r
-    *\r
-    * If a table has a single integer column as its primary key, DB_DataObject\r
-    * assumes that the column is auto-incrementing and makes a sequence table\r
-    * to do this incrementation. Since we don't need this for our class, we\r
-    * overload this method and return the magic formula that DB_DataObject needs.\r
-    *\r
-    * @return array magic three-false array that stops auto-incrementing.\r
-    */\r
-    function sequenceKey() {\r
-        return array(false, false, false);\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
@@ -100,9 +55,9 @@ class Msn_waiting_message extends Memcached_DataObject {
         $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