]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile_list.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / classes / Profile_list.php
index 0d6c6f284de9e7b9f477c9c0d260aa858d409ff8..000e10b41f5fb7cc598c7c7a2d7ffa37378e98ed 100644 (file)
  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-/**
- * Table Definition for profile_list
- */
-require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 class Profile_list extends Managed_DataObject
 {
-    ###START_AUTOCODE
-    /* the code below is auto generated do not remove the above tag */
-
     public $__table = 'profile_list';                      // table name
     public $id;                              // int(4)  primary_key not_null
     public $tagger;                          // int(4)
@@ -43,14 +33,11 @@ class Profile_list extends Managed_DataObject
     public $private;                         // tinyint(1)
     public $created;                         // datetime   not_null default_0000-00-00%2000%3A00%3A00
     public $modified;                        // timestamp   not_null default_CURRENT_TIMESTAMP
-    public $uri;                             // varchar(255)  unique_key
-    public $mainpage;                        // varchar(255)
+    public $uri;                             // varchar(191)  unique_key   not 255 because utf8mb4 takes more space
+    public $mainpage;                        // varchar(191)   not 255 because utf8mb4 takes more space
     public $tagged_count;                    // smallint
     public $subscriber_count;                // smallint
 
-    /* the code above is auto generated do not remove the tag below */
-    ###END_AUTOCODE
-
     public static function schemaDef()
     {
         return array(
@@ -64,8 +51,8 @@ class Profile_list extends Managed_DataObject
                 'created' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'),
                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'),
 
-                'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'),
-                'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page to link to'),
+                'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
+                'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page to link to'),
                 'tagged_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'),
                 'subscriber_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of subscribers to this tag'),
             ),
@@ -94,7 +81,7 @@ class Profile_list extends Managed_DataObject
 
     function getTagger()
     {
-        return Profile::getKV('id', $this->tagger);
+        return Profile::getByID($this->tagger);
     }
 
     /**
@@ -145,7 +132,7 @@ class Profile_list extends Managed_DataObject
                 $url = $this->mainpage;
             } else {
                 $url = common_local_url('showprofiletag',
-                                        array('tagger' => $this->getTagger()->nickname,
+                                        array('nickname' => $this->getTagger()->nickname,
                                               'tag'    => $this->tag));
             }
         }
@@ -334,7 +321,7 @@ class Profile_list extends Managed_DataObject
      * @return boolean success
      */
 
-    function delete()
+    function delete($useWhere=false)
     {
         // force delete one item at a time.
         if (empty($this->id)) {
@@ -349,30 +336,30 @@ class Profile_list extends Managed_DataObject
 
         self::blow('profile:lists:%d', $this->tagger);
 
-        return parent::delete();
+        return parent::delete($useWhere);
     }
 
     /**
      * Update a people tag gracefully
      * also change "tag" fields in profile_tag table
      *
-     * @param Profile_list $orig    Object's original form
+     * @param Profile_list $dataObject    Object's original form
      *
      * @return boolean success
      */
 
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        $result = true;
-
-        if (!is_object($orig) && !$orig instanceof Profile_list) {
-            parent::update($orig);
+        if (!is_object($dataObject) && !$dataObject instanceof Profile_list) {
+            return parent::update($dataObject);
         }
 
+        $result = true;
+
         // if original tag was different
         // check to see if the new tag already exists
         // if not, rename the tag correctly
-        if($orig->tag != $this->tag || $orig->tagger != $this->tagger) {
+        if($dataObject->tag != $this->tag || $dataObject->tagger != $this->tagger) {
             $existing = Profile_list::getByTaggerAndTag($this->tagger, $this->tag);
             if(!empty($existing)) {
                 // TRANS: Server exception.
@@ -381,10 +368,9 @@ class Profile_list extends Managed_DataObject
             }
             // move the tag
             // XXX: allow OStatus plugin to send out profile tag
-            $result = Profile_tag::moveTag($orig, $this);
+            $result = Profile_tag::moveTag($dataObject, $this);
         }
-        parent::update($orig);
-        return $result;
+        return parent::update($dataObject);
     }
 
     /**
@@ -407,18 +393,6 @@ class Profile_list extends Managed_DataObject
         return $xs->getString();
     }
 
-    /**
-     * return an xml string to represent this people tag
-     * as the subject of an activitystreams feed.
-     *
-     * @return string activitystreams subject
-     */
-
-    function asActivitySubject()
-    {
-        return $this->asActivityNoun('subject');
-    }
-
     /**
      * return an xml string to represent this people tag
      * as a noun in an activitystreams feed.
@@ -602,7 +576,7 @@ class Profile_list extends Managed_DataObject
      *
      * @return mixed Profile_list on success, false on fail
      */
-    static function saveNew($fields) {
+    static function saveNew(array $fields) {
         extract($fields);
 
         $ptag = new Profile_list();
@@ -672,7 +646,7 @@ class Profile_list extends Managed_DataObject
             $orig = clone($ptag);
             $user = User::getKV('id', $ptag->tagger);
             if(!empty($user)) {
-                $ptag->mainpage = common_local_url('showprofiletag', array('tag' => $ptag->tag, 'tagger' => $user->nickname));
+                $ptag->mainpage = common_local_url('showprofiletag', array('tag' => $ptag->tag, 'nickname' => $user->getNickname()));
             } else {
                 $ptag->mainpage = $uri; // assume this is a remote peopletag and the uri works
             }
@@ -713,7 +687,7 @@ class Profile_list extends Managed_DataObject
 
      // XXX: This should be in Memcached_DataObject... eventually.
 
-    static function getAtCursor($fn, $args, $cursor, $count=20)
+    static function getAtCursor($fn, array $args, $cursor, $count=20)
     {
         $items = array();
 
@@ -886,7 +860,7 @@ class Profile_list extends Managed_DataObject
      * @return Profile_list results
      */
 
-    static function getByKeys($keys) {
+    static function getByKeys(array $keys) {
         $cache = Cache::instance();
 
         if (!empty($cache)) {