]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Msn/msn_waiting_message.php
Merge branch '1.1.x'
[quix0rs-gnu-social.git] / plugins / Msn / msn_waiting_message.php
index 0efd8b02037881ac3b5009154fd2269dd12ae51c..707cd04389a6dc9d527fa40ffe798cb0a791d073 100644 (file)
@@ -1,6 +1,6 @@
 <?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
@@ -19,7 +19,66 @@ class Msn_waiting_message extends Memcached_DataObject {
     }\r
 \r
     /**\r
-     * @param mixed $screenname screenname or array of screennames to pull from\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
+    }\r
+\r
+    /**\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
@@ -27,8 +86,8 @@ class Msn_waiting_message extends Memcached_DataObject {
         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
@@ -41,9 +100,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