X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2FUser.php;h=0a70c9801402f8038d1dc59bb72bf0204ce1f3c7;hb=b89878511f1f30b4e18858940a5468b8999ab7ea;hp=bea81af4d256950251b0bbc79fd407223e7b2db6;hpb=6c069312e2911d3b2fe54d051354f579fde7bb63;p=quix0rs-gnu-social.git diff --git a/classes/User.php b/classes/User.php index bea81af4d2..0a70c98014 100644 --- a/classes/User.php +++ b/classes/User.php @@ -227,11 +227,9 @@ class User extends Memcached_DataObject } } - $inboxes = common_config('inboxes', 'enabled'); + // This flag is ignored but still set to 1 - if ($inboxes === true || $inboxes == 'transitional') { - $user->inboxed = 1; - } + $user->inboxed = 1; $user->created = common_sql_now(); $user->uri = common_user_uri($user); @@ -433,55 +431,16 @@ class User extends Memcached_DataObject function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) { - $enabled = common_config('inboxes', 'enabled'); - - // Complicated code, depending on whether we support inboxes yet - // XXX: make this go away when inboxes become mandatory - - if ($enabled === false || - ($enabled == 'transitional' && $this->inboxed == 0)) { - $qry = - 'SELECT notice.* ' . - 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d ' . - 'AND notice.is_local != ' . Notice::GATEWAY; - return Notice::getStream(sprintf($qry, $this->id), - 'user:notices_with_friends:' . $this->id, - $offset, $limit, $since_id, $before_id, - $order, $since); - } else if ($enabled === true || - ($enabled == 'transitional' && $this->inboxed == 1)) { - - $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false); + $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false); - return Notice::getStreamByIds($ids); - } + return Notice::getStreamByIds($ids); } function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) { - $enabled = common_config('inboxes', 'enabled'); - - // Complicated code, depending on whether we support inboxes yet - // XXX: make this go away when inboxes become mandatory - - if ($enabled === false || - ($enabled == 'transitional' && $this->inboxed == 0)) { - $qry = - 'SELECT notice.* ' . - 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d '; - return Notice::getStream(sprintf($qry, $this->id), - 'user:notices_with_friends:' . $this->id, - $offset, $limit, $since_id, $before_id, - $order, $since); - } else if ($enabled === true || - ($enabled == 'transitional' && $this->inboxed == 1)) { + $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true); - $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true); - - return Notice::getStreamByIds($ids); - } + return Notice::getStreamByIds($ids); } function blowFavesCache() @@ -726,15 +685,59 @@ class User extends Memcached_DataObject function hasRight($right) { - switch ($right) - { - case Right::deleteOthersNotice: - return $this->hasRole('moderator'); - break; - default: - $result = false; - Event::handle('UserRightsCheck', array($this, &$result)); - return $result; + $result = false; + if (Event::handle('UserRightsCheck', array($this, $right, &$result))) { + switch ($right) + { + case Right::deleteOthersNotice: + $result = $this->hasRole('moderator'); + break; + default: + $result = false; + break; + } } + return $result; + } + + function delete() + { + $profile = $this->getProfile(); + $profile->delete(); + + $related = array('Fave', + 'User_openid', + 'Confirm_address', + 'Remember_me', + 'Foreign_link', + 'Invitation', + 'Notice_inbox', + ); + + foreach ($related as $cls) { + $inst = new $cls(); + $inst->user_id = $this->id; + $inst->delete(); + } + + $this->_deleteTags(); + $this->_deleteBlocks(); + + parent::delete(); + } + + function _deleteTags() + { + $tag = new Profile_tag(); + $tag->tagger = $this->id; + $tag->delete(); + } + + function _deleteBlocks() + { + $block = new Profile_block(); + $block->blocker = $this->id; + $block->delete(); + // XXX delete group block? Reset blocker? } }