]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile_tag_subscription.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / classes / Profile_tag_subscription.php
index 031405f531983c5b30ea2a43c2db51d93a6faddf..f7b1553300b52010faae091c0fb69916028cd61a 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
-class Profile_tag_subscription extends Memcached_DataObject
+class Profile_tag_subscription extends Managed_DataObject
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -15,16 +15,30 @@ class Profile_tag_subscription extends Memcached_DataObject
     public $created;                                // datetime   not_null default_0000-00-00%2000%3A00%3A00
     public $modified;                               // timestamp()   not_null default_CURRENT_TIMESTAMP
 
-    /* Static get */
-    function staticGet($k,$v=null)
-    { return Memcached_DataObject::staticGet('Profile_tag_subscription',$k,$v); }
-
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
-    function pkeyGet($kv)
+    public static function schemaDef()
     {
-        return Memcached_DataObject::pkeyGet('Profile_tag_subscription', $kv);
+        return array(
+            'fields' => array(
+                'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'),
+                'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
+
+                '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_tag_id', 'profile_id'),
+            'foreign keys' => array(
+                'profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')),
+                'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
+            ),
+            'indexes' => array(
+                // @fixme probably we want a (profile_id, created) index here?
+                'profile_tag_subscription_profile_id_idx' => array('profile_id'),
+                'profile_tag_subscription_created_idx' => array('created'),
+            ),
+        );
     }
 
     static function add($peopletag, $profile)
@@ -54,7 +68,7 @@ class Profile_tag_subscription extends Memcached_DataObject
                 throw new Exception(_('Adding list subscription failed.'));
             }
 
-            $ptag = Profile_list::staticGet('id', $peopletag->id);
+            $ptag = Profile_list::getKV('id', $peopletag->id);
             $ptag->subscriberCount(true);
 
             Event::handle('EndSubscribePeopletag', array($peopletag, $profile));
@@ -95,7 +109,7 @@ class Profile_tag_subscription extends Memcached_DataObject
         $subs->find();
 
         while($subs->fetch()) {
-            $profile = Profile::staticGet('id', $subs->profile_id);
+            $profile = Profile::getKV('id', $subs->profile_id);
             Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile));
             // Delete anyway
             $subs->delete();
@@ -113,10 +127,10 @@ class Profile_tag_subscription extends Memcached_DataObject
         return $result;
     }
 
-    function delete()
+    function delete($useWhere=false)
     {
-        $result = parent::delete();
-        if ($result) {
+        $result = parent::delete($useWhere);
+        if ($result !== false) {
             self::blow('profile_list:subscriber_count:%d', 
                        $this->profile_tag_id);
         }