$this->clearReplies();
$this->clearRepeats();
- $this->clearFaves();
$this->clearTags();
$this->clearGroupInboxes();
$this->clearFiles();
// favorite and repeated
+ $scoped = null;
if (!empty($cur)) {
- $cp = $cur->getProfile();
- $noticeInfoAttr['favorite'] = ($cp->hasFave($this)) ? "true" : "false";
- $noticeInfoAttr['repeated'] = ($cp->hasRepeated($this)) ? "true" : "false";
+ $scoped = $cur->getProfile();
+ $noticeInfoAttr['repeated'] = ($scoped->hasRepeated($this)) ? "true" : "false";
}
if (!empty($this->repeat_of)) {
$noticeInfoAttr['repeat_of'] = $this->repeat_of;
}
+ Event::handle('StatusNetApiNoticeInfo', array($this, &$noticeInfoAttr, $scoped));
+
return array('statusnet:notice_info', $noticeInfoAttr, null);
}
}
}
- function clearFaves()
- {
- $fave = new Fave();
- $fave->notice_id = $this->id;
-
- if ($fave->find()) {
- while ($fave->fetch()) {
- self::blow('fave:ids_by_user_own:%d', $fave->user_id);
- self::blow('fave:ids_by_user_own:%d;last', $fave->user_id);
- self::blow('fave:ids_by_user:%d', $fave->user_id);
- self::blow('fave:ids_by_user:%d;last', $fave->user_id);
- $fave->delete();
- }
- }
-
- $fave->free();
- }
-
function clearTags()
{
$tag = new Notice_tag();
}
}
- static function _idsOf(&$notices)
+ static function _idsOf(array &$notices)
{
$ids = array();
foreach ($notices as $notice) {
- $ids[] = $notice->id;
+ $ids[$notice->id] = true;
}
- $ids = array_unique($ids);
- return $ids;
+ return array_keys($ids);
}
static function fillAttachments(&$notices)
}
}
- protected $_faves = array();
-
- /**
- * All faves of this notice
- *
- * @return array Array of Fave objects
- */
-
- function getFaves()
- {
- if (isset($this->_faves[$this->id])) {
- return $this->_faves[$this->id];
- }
- $faveMap = Fave::listGet('notice_id', array($this->id));
- $this->_faves[$this->id] = $faveMap[$this->id];
- return $this->_faves[$this->id];
- }
-
- function _setFaves($faves)
- {
- $this->_faves[$this->id] = $faves;
- }
-
- static function fillFaves(&$notices)
- {
- $ids = self::_idsOf($notices);
- $faveMap = Fave::listGet('notice_id', $ids);
- $cnt = 0;
- $faved = array();
- foreach ($faveMap as $id => $faves) {
- $cnt += count($faves);
- if (count($faves) > 0) {
- $faved[] = $id;
- }
- }
- foreach ($notices as $notice) {
- $faves = $faveMap[$notice->id];
- $notice->_setFaves($faves);
- }
- }
-
static function fillReplies(&$notices)
{
$ids = self::_idsOf($notices);