public function index(array $params) { if (!($userId = OW::getUser()->getId())) { throw new AuthenticateException(); } $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1; $lang = OW::getLanguage(); $perPage = (int) OW::getConfig()->getValue('base', OW::getPluginManager()->isPluginActive('skadate') ? 'users_on_page' : 'users_count_on_page'); $guests = OCSGUESTS_BOL_Service::getInstance()->findGuestsForUser($userId, $page, $perPage); $guestList = array(); if ($guests) { foreach ($guests as $guest) { $guestList[$guest->guestId] = array('last_visit' => $lang->text('ocsguests', 'visited') . ' ' . '<span class="ow_remark">' . $guest->visitTimestamp . '</span>'); } $itemCount = OCSGUESTS_BOL_Service::getInstance()->countGuestsForUser($userId); if (OW::getPluginManager()->isPluginActive('skadate')) { $cmp = OW::getClassInstance('BASE_CMP_Users', $guestList, array(), $itemCount); } else { $guestsUsers = OCSGUESTS_BOL_Service::getInstance()->findGuestUsers($userId, $page, $perPage); $cmp = new OCSGUESTS_CMP_Users($guestsUsers, $itemCount, $perPage, true, $guestList); } $this->addComponent('guests', $cmp); } else { $this->assign('guests', null); } $this->setPageHeading($lang->text('ocsguests', 'viewed_profile')); $this->setPageTitle($lang->text('ocsguests', 'viewed_profile')); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard'); }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $count = (int) $params->customParamList['count']; $service = OCSGUESTS_BOL_Service::getInstance(); $userId = OW::getUser()->getId(); $guests = $service->findGuestsForUser($userId, 1, $count); if (!$guests) { $this->setVisible(false); return; } $userIdList = array(); foreach ($guests as $guest) { array_push($userIdList, $guest->guestId); } $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIdList); foreach ($avatars as &$item) { $item['class'] = 'ow_guest_avatar'; } $event = new OW_Event('bookmarks.is_mark', array(), $avatars); OW::getEventManager()->trigger($event); if ($event->getData()) { $avatars = $event->getData(); } $this->assign('avatars', $avatars); $this->assign('guests', $guests); $total = $service->countGuestsForUser($userId); if ($total > $count) { $toolbar = array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('ocsguests.list')); $this->setSettingValue(self::SETTING_TOOLBAR, array($toolbar)); } }
/** * Returns class instance * * @return OCSGUESTS_BOL_Service */ public static function getInstance() { if (null === self::$classInstance) { self::$classInstance = new self(); } return self::$classInstance; }
public function index(array $params) { if (!($userId = OW::getUser()->getId())) { throw new AuthenticationException(); } $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1; $perPage = (int) OW::getConfig()->getValue('base', 'users_count_on_page'); $guests = OCSGUESTS_BOL_Service::getInstance()->findGuestsForUser($userId, $page, $perPage); $guestsUsers = OCSGUESTS_BOL_Service::getInstance()->findGuestUsers($userId, $page, $perPage); $guestList = array(); if ($guests) { foreach ($guests as $guest) { $guestList[$guest->guestId] = $guest; } $itemCount = OCSGUESTS_BOL_Service::getInstance()->countGuestsForUser($userId); $cmp = new OCSGUESTS_CMP_Users($guestsUsers, $itemCount, $perPage, true, $guestList); $this->addComponent('guests', $cmp); } else { $this->assign('guests', null); } $this->setPageHeading(OW::getLanguage()->text('ocsguests', 'viewed_profile')); $this->setPageHeadingIconClass('ow_ic_user'); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard'); }
public function onUserUnregister(OW_Event $event) { $params = $event->getParams(); $userId = $params['userId']; OCSGUESTS_BOL_Service::getInstance()->deleteUserGuests($userId); }
public function markViewed(OW_Event $event) { $params = $event->getParams(); if (empty($params['guestIds'])) { return; } $userId = $params['userId']; $guestIds = $params['guestIds']; OCSGUESTS_BOL_Service::getInstance()->setViewedStatusByGuestIds($userId, $guestIds); }
public function guestsCheckProcess() { OCSGUESTS_BOL_Service::getInstance()->checkExpiredGuests(); }