function prefill($notices) { // XXX: this should probably only be in the scoping one. Notice::fillGroups($notices); Notice::fillReplies($notices); if (common_config('notice', 'hidespam')) { $profiles = Notice::getProfiles($notices); foreach ($profiles as $profile) { $pids[] = $profile->id; } Memcached_DataObject::pivotGet('Profile_role', 'profile_id', $pids, array('role' => Profile_role::SILENCED)); } }
function getNotices($offset, $limit, $sinceId, $maxId) { $all = array(); do { $ids = $this->getNoticeIds($offset, $limit, $sinceId, $maxId); $notices = Memcached_DataObject::pivotGet('Notice', 'id', $ids); // By default, takes out false values $notices = array_filter($notices); $all = array_merge($all, $notices); if (count($notices < count($ids))) { $offset += $limit; $limit -= count($notices); } } while (count($notices) < count($ids) && count($ids) > 0); return new ArrayWrapper($all); }
static function fillAttachments(&$notices) { $ids = self::_idsOf($notices); $f2pMap = Memcached_DataObject::listGet('File_to_post', 'post_id', $ids); $fileIds = array(); foreach ($f2pMap as $noticeId => $f2ps) { foreach ($f2ps as $f2p) { $fileIds[] = $f2p->file_id; } } $fileIds = array_unique($fileIds); $fileMap = Memcached_DataObject::pivotGet('File', 'id', $fileIds); foreach ($notices as $notice) { $files = array(); $f2ps = $f2pMap[$notice->id]; foreach ($f2ps as $f2p) { $files[] = $fileMap[$f2p->file_id]; } $notice->_setAttachments($files); } }
static function pivotGet($key, $values, $otherCols = array()) { return Memcached_DataObject::pivotGet('Profile', $key, $values, $otherCols); }
static function pivotGet($keyCol, $keyVals, $otherCols) { return Memcached_DataObject::pivotGet('Avatar', $keyCol, $keyVals, $otherCols); }
static function prefill(&$notices, $avatarSize = AVATAR_STREAM_SIZE) { if (Event::handle('StartNoticeListPrefill', array(&$notices, $avatarSize))) { // Prefill attachments Notice::fillAttachments($notices); // Prefill attachments Notice::fillFaves($notices); // Prefill repeat data Notice::fillRepeats($notices); // Prefill the profiles $profiles = Notice::fillProfiles($notices); // Prefill the avatars Profile::fillAvatars($profiles, $avatarSize); $p = Profile::current(); if (!empty($p)) { $ids = array(); foreach ($notices as $notice) { $ids[] = $notice->id; } Memcached_DataObject::pivotGet('Fave', 'notice_id', $ids, array('user_id' => $p->id)); Memcached_DataObject::pivotGet('Notice', 'repeat_of', $ids, array('profile_id' => $p->id)); } Event::handle('EndNoticeListPrefill', array(&$notices, &$profiles, $avatarSize)); } }