X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser_group.php;h=cffc7864586d7a542764fcb1ec3d621725ca6ee1;hb=9a6ceb3303a98d1c5fba3587f32d0377e55062cc;hp=1f700578523a35ca9fa53efd82110ff59f19ac15;hpb=112b6c40793a18262425ca039e4fe4a6eb68bce4;p=quix0rs-gnu-social.git diff --git a/classes/User_group.php b/classes/User_group.php index 1f70057852..cffc786458 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -100,15 +100,10 @@ class User_group extends Memcached_DataObject $inbox->selectAdd(); $inbox->selectAdd('notice_id'); - if ($since_id != 0) { - $inbox->whereAdd('notice_id > ' . $since_id); - } - - if ($max_id != 0) { - $inbox->whereAdd('notice_id <= ' . $max_id); - } + Notice::addWhereSinceId($inbox, $since_id, 'notice_id'); + Notice::addWhereMaxId($inbox, $max_id, 'notice_id'); - $inbox->orderBy('notice_id DESC'); + $inbox->orderBy('created DESC, notice_id DESC'); if (!is_null($offset)) { $inbox->limit($offset, $limit); @@ -234,6 +229,22 @@ class User_group extends Memcached_DataObject return ($this->fullname) ? $this->fullname : $this->nickname; } + /** + * Gets the full name (if filled) with nickname as a parenthetical, or the nickname alone + * if no fullname is provided. + * + * @return string + */ + function getFancyName() + { + if ($this->fullname) { + // TRANS: Full name of a profile or group followed by nickname in parens + return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->fullname, $this->nickname); + } else { + return $this->nickname; + } + } + function getAliases() { $aliases = array(); @@ -559,16 +570,27 @@ class User_group extends Memcached_DataObject function delete() { if ($this->id) { + // Safe to delete in bulk for now + $related = array('Group_inbox', 'Group_block', 'Group_member', 'Related_group'); + Event::handle('UserGroupDeleteRelated', array($this, &$related)); + foreach ($related as $cls) { + $inst = new $cls(); $inst->group_id = $this->id; - $inst->delete(); + + if ($inst->find()) { + while ($inst->fetch()) { + $dup = clone($inst); + $dup->delete(); + } + } } // And related groups in the other direction... @@ -584,6 +606,10 @@ class User_group extends Memcached_DataObject if ($local) { $local->delete(); } + + // blow the cached ids + self::blow('user_group:notice_ids:%d', $this->id); + } else { common_log(LOG_WARN, "Ambiguous user_group->delete(); skipping related tables."); }