public function __construct(array $params = array()) { parent::__construct(); $service = HOTLIST_BOL_Service::getInstance(); $authMsg = ''; $authorized = OW::getUser()->isAuthorized('hotlist', 'add_to_list'); $status = BOL_AuthorizationService::getInstance()->getActionStatus('hotlist', 'add_to_list'); if (!$authorized) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('hotlist', 'add_to_list'); $authMsg = json_encode($status['msg']); } $this->assign('authorized', $authorized); $this->assign('authMsg', $authMsg); if (empty($params)) { $this->settingList = array('number_of_users' => 8); } else { $this->settingList = $params; } OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('hotlist')->getStaticJsUrl() . 'jquery.cycle.js'); $userList = HOTLIST_BOL_Service::getInstance()->getHotList(); $info = array(); foreach ($userList as $id => $user) { $userDto = BOL_UserService::getInstance()->findUserById($user->userId); if (empty($userDto)) { continue; } $info[$id]['userId'] = $user->userId; $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($user->userId)); $event = new OW_Event('bookmarks.is_mark', array(), $avatars); OW::getEventManager()->trigger($event); if ($event->getData()) { $avatars = $event->getData(); } $info[$id]['avatarUrl'] = $avatars[$user->userId]['src']; $info[$id]['url'] = $avatars[$user->userId]['url']; $info[$id]['username'] = BOL_UserService::getInstance()->getUserName($user->userId); $info[$id]['displayName'] = empty($avatars[$user->userId]['title']) ? BOL_UserService::getInstance()->getUserName($user->userId) : $avatars[$user->userId]['title']; $fields = $this->getFields($user->userId); $info[$id]['sex'] = empty($fields['sex']) ? '' : $fields['sex']; $info[$id]['age'] = empty($fields['age']) ? '' : $fields['age']; $info[$id]['googlemap_location'] = empty($fields['googlemap_location']) ? '' : $fields['googlemap_location']; $info[$id]['avatar'] = $avatars[$user->userId]; $info[$id]['isMarked'] = !empty($avatars[$user->userId]['isMarked']); } if (!empty($info)) { $this->assign('userList', $info); } else { $this->assign('userList', null); } $user = $service->findUserById(OW::getUser()->getId()); $this->assign('userInList', !empty($user)); $this->assign('number_of_users', $this->settingList['number_of_users']); $this->assign('number_of_rows', 1); $this->assign('count', count($info)); $js = "\n\$(document).ready(function() {\n \$('.users_slideshow').cycle({\n\t\tfx: 'scrollUp',\n\t\tspeed: 300,\n\t\ttimeout: 4500\n\t});\n});"; if (count($info) > $this->settingList['number_of_users']) { OW::getDocument()->addOnloadScript($js); } }
public static function process($data) { $resp = array(); $lang = OW::getLanguage(); $service = HOTLIST_BOL_Service::getInstance(); if (!OW::getUser()->isAuthenticated()) { $resp['error'] = $lang->text('base', 'base_sign_in_cap_label'); echo json_encode($resp); exit; } if ($service->findUserById(OW::getUser()->getId())) { if ($data['remove_from_list']) { $service->deleteUser(OW::getUser()->getId()); // //Newsfeed // OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array( // 'entityType' => 'add_to_hotlist', // 'entityId' => OW::getUser()->getId() // ))); $resp['message'] = OW::getLanguage()->text('hotlist', 'user_removed'); $resp['removed'] = 1; echo json_encode($resp); exit; } } else { if ($data['add_to_list']) { if (!OW::getUser()->isAuthorized('hotlist', 'add_to_list')) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('hotlist', 'add_to_list'); $resp['error'] = $status['msg']; echo json_encode($resp); exit; } BOL_AuthorizationService::getInstance()->trackAction('hotlist', 'add_to_list'); $service->addUser(OW::getUser()->getId()); // //Newsfeed // $event = new OW_Event('feed.action', array( // 'pluginKey' => 'hotlist', // 'entityType' => 'add_to_hotlist', // 'entityId' => OW::getUser()->getId(), // 'userId' => OW::getUser()->getId() // ), array( // 'string' => OW::getLanguage()->text('hotlist', 'user_entered_hot_list', array('displayName'=>BOL_UserService::getInstance()->getDisplayName(OW::getUser()->getId()))), // 'view' => array('iconClass' => 'ow_ic_heart'), // 'toolbar' => array(array( // 'href' => OW::getRouter()->urlForRoute('hotlist-add-to-list'), // 'label' => OW::getLanguage()->text('hotlist', 'are_you_hot_too') // )) // )); // OW::getEventManager()->trigger($event); $resp['message'] = OW::getLanguage()->text('hotlist', 'user_added'); $resp['added'] = 1; echo json_encode($resp); exit; } } }
public function clearExpiredUsers() { HOTLIST_BOL_Service::getInstance()->clearExpiredUsers(); }
public function __construct() { $this->service = HOTLIST_BOL_Service::getInstance(); parent::__construct(); }