public function ping(BASE_CLASS_ConsoleDataEvent $event) { $userId = OW::getUser()->getId(); $data = $event->getItemData(self::CONSOLE_ITEM_KEY); $allInvitationCount = $this->service->count(null, $userId, FRIENDS_BOL_Service::STATUS_PENDING); $newInvitationCount = $this->service->count(null, $userId, FRIENDS_BOL_Service::STATUS_PENDING, null, false); $data['counter'] = array('all' => $allInvitationCount, 'new' => $newInvitationCount); $event->setItemData('friend_requests', $data); }
public function onBeforeRender() { parent::onBeforeRender(); $limit = MBOL_ConsoleService::SECTION_ITEMS_LIMIT; $this->addComponent('itemsCmp', new FRIENDS_MCMP_ConsoleItems($limit)); $this->assign('loadMore', $this->service->count(null, OW::getUser()->getId(), FRIENDS_BOL_Service::STATUS_PENDING) > $limit); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('friends')->getStaticJsUrl() . 'mobile.js'); $params = array('acceptUrl' => OW::getRouter()->urlFor('FRIENDS_MCTRL_Action', 'accept'), 'ignoreUrl' => OW::getRouter()->urlFor('FRIENDS_MCTRL_Action', 'ignore')); $script = 'var friendsConsole = new OWM_FriendsConsole(' . json_encode($params) . ');'; OW::getDocument()->addOnloadScript($script); }
public function onCollectQuickLinks(BASE_CLASS_EventCollector $event) { $userId = OW::getUser()->getId(); $count = (int) $this->service->countFriends($userId); $activeCount = (int) $this->service->count(null, $userId, FRIENDS_BOL_Service::STATUS_PENDING); if ($count == 0 && $activeCount == 0) { return; } $event->add(array(BASE_CMP_QuickLinksWidget::DATA_KEY_LABEL => OW::getLanguage()->text('friends', 'widget_title'), BASE_CMP_QuickLinksWidget::DATA_KEY_URL => OW::getRouter()->urlForRoute('friends_list'), BASE_CMP_QuickLinksWidget::DATA_KEY_COUNT => $count, BASE_CMP_QuickLinksWidget::DATA_KEY_COUNT_URL => OW::getRouter()->urlForRoute('friends_list'), BASE_CMP_QuickLinksWidget::DATA_KEY_ACTIVE_COUNT => $activeCount, BASE_CMP_QuickLinksWidget::DATA_KEY_ACTIVE_COUNT_URL => OW::getRouter()->urlForRoute('friends_lists', array('list' => 'got-requests')))); }