]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User.php
File class no longer depends on MIME
[quix0rs-gnu-social.git] / classes / User.php
index 7b53877a31f60234833be5cbde9541dd2cef1b5b..d0eba7f75b4d8c21b816d8452f1b1a3a6ecd1726 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Table Definition for user
  */
 
-require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-require_once 'Validate.php';
-
 class User extends Managed_DataObject
 {
     const SUBSCRIBE_POLICY_OPEN = 0;
@@ -60,7 +55,6 @@ class User extends Managed_DataObject
     public $autosubscribe;                   // tinyint(1)
     public $subscribe_policy;                // tinyint(1)
     public $urlshorteningservice;            // varchar(50)   default_ur1.ca
-    public $inboxed;                         // tinyint(1)
     public $private_stream;                  // tinyint(1)   default_0
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
@@ -96,7 +90,6 @@ class User extends Managed_DataObject
                 'autosubscribe' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'automatically subscribe to users who subscribe to us'),
                 'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'),
                 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
-                'inboxed' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'has an inbox been created for this user?'),
                 'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'),
 
                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
@@ -139,7 +132,7 @@ class User extends Managed_DataObject
         return $this->_profile;
     }
 
-    function isSubscribed($other)
+    function isSubscribed(Profile $other)
     {
         return $this->getProfile()->isSubscribed($other);
     }
@@ -155,7 +148,7 @@ class User extends Managed_DataObject
     {
         $this->_connect();
         $parts = array();
-        foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
+        foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail') as $k) {
             if (strcmp($this->$k, $orig->$k) != 0) {
                 $parts[] = $k . ' = ' . $this->_quote($this->$k);
             }
@@ -233,7 +226,7 @@ class User extends Managed_DataObject
         try {
             $profile->nickname = Nickname::normalize($nickname, true);
         } catch (NicknameException $e) {
-            common_log(LOG_WARNING, sprintf('Bad nickname during User registration for %s: %s', $profile->nickname, $e->getMessage()), __FILE__);
+            common_log(LOG_WARNING, sprintf('Bad nickname during User registration for %s: %s', $nickname, $e->getMessage()), __FILE__);
             return false;
         }
 
@@ -282,10 +275,6 @@ class User extends Managed_DataObject
             $user->email = $email;
         }
 
-        // This flag is ignored but still set to 1
-
-        $user->inboxed = 1;
-
         // Set default-on options here, otherwise they'll be disabled
         // initially for sites using caching, since the initial encache
         // doesn't know about the defaults in the database.
@@ -305,7 +294,7 @@ class User extends Managed_DataObject
             $profile->query('BEGIN');
 
             $id = $profile->insert();
-            if (empty($id)) {
+            if ($id === false) {
                 common_log_db_error($profile, 'INSERT', __FILE__);
                 return false;
             }
@@ -324,26 +313,12 @@ class User extends Managed_DataObject
 
             $result = $user->insert();
 
-            if (!$result) {
+            if ($result === false) {
                 common_log_db_error($user, 'INSERT', __FILE__);
                 $profile->query('ROLLBACK');
                 return false;
             }
 
-            // Everyone gets an inbox
-
-            $inbox = new Inbox();
-
-            $inbox->user_id = $user->id;
-            $inbox->notice_ids = '';
-
-            $result = $inbox->insert();
-
-            if (!$result) {
-                common_log_db_error($inbox, 'INSERT', __FILE__);
-                return false;
-            }
-
             // Everyone is subscribed to themself
 
             $subscription = new Subscription();
@@ -499,47 +474,6 @@ class User extends Managed_DataObject
         return $this->getProfile()->favoriteNotices($own, $offset, $limit, $since_id, $max_id);
     }
 
-    function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
-    {
-        $stream = new InboxNoticeStream($this);
-        return $stream->getNotices($offset, $limit, $since_id, $before_id);
-    }
-
-    // DEPRECATED, use noticeInbox()
-
-    function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
-    {
-        return $this->noticeInbox($offset, $limit, $since_id, $before_id);
-    }
-
-    // DEPRECATED, use noticeInbox()
-
-    function noticesWithFriendsThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
-    {
-        return $this->noticeInbox($offset, $limit, $since_id, $before_id);
-    }
-
-    // DEPRECATED, use noticeInbox()
-
-    function noticeInboxThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
-    {
-        return $this->noticeInbox($offset, $limit, $since_id, $before_id);
-    }
-
-    // DEPRECATED, use noticeInbox()
-
-    function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
-    {
-        return $this->noticeInbox($offset, $limit, $since_id, $before_id);
-    }
-
-    // DEPRECATED, use noticeInbox()
-
-    function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
-    {
-        $this->noticeInbox($offset, $limit, $since_id, $before_id);
-    }
-
     function blowFavesCache()
     {
         $this->getProfile()->blowFavesCache();
@@ -621,12 +555,12 @@ class User extends Managed_DataObject
         return true;
     }
 
-    function isMember($group)
+    function isMember(User_group $group)
     {
         return $this->getProfile()->isMember($group);
     }
 
-    function isAdmin($group)
+    function isAdmin(User_group $group)
     {
         return $this->getProfile()->isAdmin($group);
     }
@@ -683,11 +617,11 @@ class User extends Managed_DataObject
         return $this->getProfile()->hasRight($right);
     }
 
-    function delete()
+    function delete($useWhere=false)
     {
         if (empty($this->id)) {
             common_log(LOG_WARNING, "Ambiguous User->delete(); skipping related tables.");
-            return parent::delete();
+            return parent::delete($useWhere);
         }
 
         try {
@@ -715,7 +649,7 @@ class User extends Managed_DataObject
         $this->_deleteTags();
         $this->_deleteBlocks();
 
-        parent::delete();
+        return parent::delete($useWhere);
     }
 
     function _deleteTags()