本文整理汇总了PHP中BOL_AuthorizationService::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP BOL_AuthorizationService::getInstance方法的具体用法?PHP BOL_AuthorizationService::getInstance怎么用?PHP BOL_AuthorizationService::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOL_AuthorizationService
的用法示例。
在下文中一共展示了BOL_AuthorizationService::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
public function getList($params)
{
$service = SKADATEIOS_ABOL_Service::getInstance();
$auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'), 'base.search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
$this->assign('auth', $auth);
if ($auth["base.search_users"]["status"] != BOL_AuthorizationService::STATUS_AVAILABLE) {
$this->assign("list", array());
$this->assign("total", 0);
return;
}
$_criteriaList = array_filter($params["criteriaList"]);
$userId = OW::getUser()->getId();
$userInfo = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("sex"));
$_criteriaList["sex"] = !empty($userInfo[$userId]["sex"]) ? $userInfo[$userId]["sex"] : null;
$questionList = BOL_QuestionService::getInstance()->findQuestionByNameList(array_keys($_criteriaList));
$criteriaList = array();
foreach ($_criteriaList as $questionName => $questionValue) {
if (empty($questionList[$questionName])) {
continue;
}
$criteriaList[$questionName] = $this->convertQuestionValue($questionList[$questionName]->presentation, $questionValue);
}
$idList = OW::getEventManager()->call("usearch.get_user_id_list", array("criterias" => $criteriaList, "limit" => array($params["first"], $params["count"])));
$idList = empty($idList) ? array() : $idList;
//$idList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $params["first"], $params["count"]);
$total = BOL_UserService::getInstance()->countUsersByQuestionValues($params["criteriaList"]);
$userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
$questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
foreach ($questionsData as $userId => $data) {
$date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
$userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
}
$photoList = array();
$avatarList = array();
foreach ($idList as $userId) {
$bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
$avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
$event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
OW::getEventManager()->trigger($event);
$album = $event->getData();
$photos = !empty($album['photoList']) ? $album['photoList'] : array();
foreach ($photos as $photo) {
$photoList[$userId][] = array("src" => $photo["url"]["main"]);
}
}
$bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
$bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
$list = array();
foreach ($idList as $userId) {
$list[] = array("userId" => $userId, "photos" => empty($photoList[$userId]) ? array() : $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
}
$this->assign("list", $list);
$this->assign("total", $total);
$allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
$this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
BOL_AuthorizationService::getInstance()->trackAction("base", "search_users");
$mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
$this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
}
示例2: profile
public function profile($paramList)
{
$userService = BOL_UserService::getInstance();
/* @var $userDao BOL_User */
$userDto = $userService->findByUsername($paramList['username']);
if ($userDto === null) {
throw new Redirect404Exception();
}
if (!OW::getUser()->isAuthorized('base', 'view_profile')) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('base', 'view_profile');
$this->assign('permissionMessage', $status['msg']);
return;
}
$eventParams = array('action' => 'base_view_profile', 'ownerId' => $userDto->id, 'viewerId' => OW::getUser()->getId());
$displayName = BOL_UserService::getInstance()->getDisplayName($userDto->id);
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $ex) {
throw new RedirectException(OW::getRouter()->urlForRoute('base_user_privacy_no_permission', array('username' => $displayName)));
}
$this->setPageTitle(OW::getLanguage()->text('base', 'profile_view_title', array('username' => $displayName)));
$this->setPageHeading(OW::getLanguage()->text('base', 'profile_view_heading', array('username' => $displayName)));
$this->setPageHeadingIconClass('ow_ic_user');
$profileHeader = OW::getClassInstance("BASE_MCMP_ProfileHeader", $userDto->id);
$this->addComponent("header", $profileHeader);
//Profile Info
$displayNameQuestion = OW::getConfig()->getValue('base', 'display_name_question');
$profileInfo = OW::getClassInstance("BASE_MCMP_ProfileInfo", $userDto->id, false, array($displayNameQuestion, "birthdate"));
$this->addComponent("info", $profileInfo);
$this->addComponent('contentMenu', OW::getClassInstance("BASE_MCMP_ProfileContentMenu", $userDto->id));
$this->addComponent('about', OW::getClassInstance("BASE_MCMP_ProfileAbout", $userDto->id, 80));
$place = BOL_MobileWidgetService::PLACE_MOBILE_PROFILE;
$this->initDragAndDrop($place, $userDto->id);
}
示例3: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
if (!BOL_AuthorizationService::getInstance()->isModerator() && !OW::getUser()->isAdmin()) {
$this->setVisible(false);
return;
}
$uniqId = uniqid("mp-");
$this->assign("uniqId", $uniqId);
$event = new BASE_CLASS_EventCollector(self::EVENT_COLLECT_CONTENTS);
OW::getEventManager()->trigger($event);
$tplContents = array();
$activeTab = null;
foreach ($event->getData() as $content) {
$tplContent = array_merge(array("name" => null, "content" => null, "active" => false), $content);
$activeTab = $tplContent["active"] ? $tplContent["name"] : $activeTab;
$tplContents[$tplContent["name"]] = $tplContent;
}
if (empty($tplContents)) {
$this->setVisible(false);
return;
}
if ($activeTab === null) {
$firstTab = reset($tplContents);
$activeTab = $firstTab["name"];
$tplContents[$activeTab]["active"] = true;
}
$this->assign("items", $tplContents);
}
示例4: __construct
public function __construct($layout)
{
parent::__construct();
$status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
if ($status['status'] == BOL_AuthorizationService::STATUS_DISABLED) {
$this->assign('authError', $status['msg']);
return;
}
$class = "";
switch ($layout) {
case 'page':
$class = ' ow_photoview_info_onpage';
break;
default:
if ((bool) OW::getConfig()->getValue('photo', 'photo_view_classic')) {
$class = ' ow_photoview_pint_mode';
} else {
$class = '';
}
break;
}
$this->assign('class ', $class);
$this->assign('layout ', $layout);
$document = OW::getDocument();
$js = "\$('#btn-save-as-avatar').off().on('click', function() {\n console.log('photo floatbox call js');\n var photoId = \$('#btn-photo-edit') . attr('rel');\n\n document.avatarFloatBox = OW.ajaxFloatBox(\n 'BASE_CMP_AvatarChange', {\n params: {\n step: 2, entityType: 'photo_album', entityId: '', id: photoId\n }}, {\n width: 749, title: OW.getLanguageText('base', 'avatar_change')}\n );\n })";
$document->addOnloadScript($js);
}
示例5: __construct
public function __construct($data)
{
$script = UTIL_JsGenerator::composeJsString('
OWM.bind("mailbox.ready", function(readyStatus){
if (readyStatus == 2){
OWM.conversation = new MAILBOX_Conversation({$params});
OWM.conversationView = new MAILBOX_MailConversationView({model: OWM.conversation});
}
});
', array('params' => $data));
OW::getDocument()->addOnloadScript($script);
OW::getLanguage()->addKeyForJs('mailbox', 'text_message_invitation');
$form = new MAILBOX_MCLASS_NewMailMessageForm($data['conversationId'], $data['opponentId']);
$this->addForm($form);
$this->assign('data', $data);
$this->assign('defaultAvatarUrl', BOL_AvatarService::getInstance()->getDefaultAvatarUrl());
$firstMessage = MAILBOX_BOL_ConversationService::getInstance()->getFirstMessage($data['conversationId']);
if (empty($firstMessage)) {
$actionName = 'send_message';
} else {
$actionName = 'reply_to_message';
}
$isAuthorized = OW::getUser()->isAuthorized('mailbox', $actionName);
if (!$isAuthorized) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
$this->assign('sendAuthMessage', $status['msg']);
} elseif ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
$this->assign('sendAuthMessage', OW::getLanguage()->text('mailbox', $actionName . '_permission_denied'));
}
}
}
示例6: __construct
/**
* @param BASE_CLASS_WidgetParameter $params
* @return \BASE_CMP_UserViewWidget
*/
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
$userId = $params->additionalParamList['entityId'];
$viewerId = OW::getUser()->getId();
$ownerMode = $userId == $viewerId;
$adminMode = OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base');
$isSuperAdmin = BOL_AuthorizationService::getInstance()->isSuperModerator($userId);
$user = BOL_UserService::getInstance()->findUserById($userId);
$accountType = $user->accountType;
$questionService = BOL_QuestionService::getInstance();
$questions = self::getUserViewQuestions($userId, $adminMode);
$questionArray = $questions['questions'];
$questionData = $questions['data'];
$questionLabelList = $questions['labels'];
$sections = array_keys($questionArray);
$template = OW::getPluginManager()->getPlugin('base')->getViewDir() . 'components' . DS . 'user_view_widget_table.html';
$userViewPresntation = OW::getConfig()->getValue('base', 'user_view_presentation');
if ($userViewPresntation === self::USER_VIEW_PRESENTATION_TABS) {
$template = OW::getPluginManager()->getPlugin('base')->getViewDir() . 'components' . DS . 'user_view_widget_tabs.html';
OW::getDocument()->addOnloadScript(" view = new UserViewWidget(); ");
$jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
OW::getDocument()->addScript($jsDir . "user_view_widget.js");
$this->addMenu($sections);
}
$script = ' $(".profile_hidden_field").bind( "mouseover.hiddenfield",
function() {
OW.showTip($(this), {side: "top", hideEvent: "mouseout", timeout:0, show: "' . OW::getLanguage()->text('base', 'base_invisible_profile_field_tooltip') . '"});
} );';
OW::getDocument()->addOnloadScript($script);
$this->setTemplate($template);
$accountTypes = $questionService->findAllAccountTypes();
if (!isset($sections[0])) {
$sections[0] = 0;
}
if (count($accountTypes) > 1) {
if (!isset($questionArray[$sections[0]])) {
$questionArray[$sections[0]] = array();
}
array_unshift($questionArray[$sections[0]], array('name' => 'accountType', 'presentation' => 'select'));
$questionData[$userId]['accountType'] = $questionService->getAccountTypeLang($accountType);
}
if (!isset($questionData[$userId])) {
$questionData[$userId] = array();
}
$this->assign('firstSection', $sections[0]);
$this->assign('questionArray', $questionArray);
$this->assign('questionData', $questionData[$userId]);
$this->assign('ownerMode', $ownerMode);
$this->assign('adminMode', $adminMode);
$this->assign('superAdminProfile', $isSuperAdmin);
$this->assign('profileEditUrl', OW::getRouter()->urlForRoute('base_edit'));
if ($adminMode && !$ownerMode) {
$this->assign('profileEditUrl', OW::getRouter()->urlForRoute('base_edit_user_datails', array('userId' => $userId)));
}
$this->assign('avatarUrl', BOL_AvatarService::getInstance()->getAvatarUrl($userId));
$this->assign('displayName', BOL_UserService::getInstance()->getDisplayName($userId));
$this->assign('questionLabelList', $questionLabelList);
$this->assign('userId', $userId);
}
示例7: addToList
public function addToList(OW_Event $event)
{
$params = $event->getParams();
$userId = $params["userId"];
$data = array("result" => true, "message" => null, "buyCredits" => false);
$available = true;
if (!isset($params["checkCredits"]) || $params["checkCredits"]) {
if (!OW::getUser()->isAuthorized("hotlist", "add_to_list")) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus("hotlist", "add_to_list");
$available = false;
$data["result"] = false;
if ($status["status"] == BOL_AuthorizationService::STATUS_PROMOTED) {
$data["message"] = $status["msg"];
$data["buyCredits"] = true;
}
}
}
if ($available) {
$this->service->addUser($userId);
BOL_AuthorizationService::getInstance()->trackAction('hotlist', 'add_to_list');
$data["result"] = true;
$data['message'] = OW::getLanguage()->text('hotlist', 'user_added');
}
$event->setData($data);
return $data;
}
示例8: __construct
/**
* Constructor.
*
* @param BASE_CommentsParams $params
*/
public function __construct(BASE_CommentsParams $params)
{
parent::__construct();
$this->params = $params;
$this->batchData = $params->getBatchData();
$this->staticData = empty($this->batchData['_static']) ? array() : $this->batchData['_static'];
$this->batchData = isset($this->batchData[$params->getEntityType()][$params->getEntityId()]) ? $this->batchData[$params->getEntityType()][$params->getEntityId()] : array();
srand(time());
$this->id = $params->getEntityType() . $params->getEntityId() . rand(1, 10000);
$this->cmpContextId = "comments-{$this->id}";
$this->assign('cmpContext', $this->cmpContextId);
$this->assign('wrapInBox', $params->getWrapInBox());
$this->assign('topList', in_array($params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI)));
$this->assign('bottomList', $params->getDisplayType() == BASE_CommentsParams::DISPLAY_TYPE_WITH_PAGING);
$this->assign('mini', $params->getDisplayType() == BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
$this->isAuthorized = OW::getUser()->isAuthorized($params->getPluginKey(), 'add_comment') && $params->getAddComment();
if (!$this->isAuthorized) {
$errorMessage = $params->getErrorMessage();
if (empty($errorMessage)) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus($params->getPluginKey(), 'add_comment');
$errorMessage = OW::getUser()->isAuthenticated() ? $status['msg'] : OW::getLanguage()->text('base', 'comments_add_login_message');
}
$this->assign('authErrorMessage', $errorMessage);
}
$this->initForm();
}
示例9: render
public function render()
{
$defaultAvatarUrl = BOL_AvatarService::getInstance()->getDefaultAvatarUrl();
$this->assign('defaultAvatarUrl', $defaultAvatarUrl);
$js = "OW.Mailbox.conversationController = new MAILBOX_ConversationView();";
OW::getDocument()->addOnloadScript($js, 3006);
//TODO check this config
$enableAttachments = OW::getConfig()->getValue('mailbox', 'enable_attachments');
$this->assign('enableAttachments', $enableAttachments);
$replyToMessageActionPromotedText = '';
$isAuthorizedReplyToMessage = OW::getUser()->isAuthorized('mailbox', 'reply_to_message');
$isAuthorizedReplyToMessage = $isAuthorizedReplyToMessage || OW::getUser()->isAuthorized('mailbox', 'send_chat_message');
if (!$isAuthorizedReplyToMessage) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', 'reply_to_message');
if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
$replyToMessageActionPromotedText = $status['msg'];
}
}
$this->assign('isAuthorizedReplyToMessage', $isAuthorizedReplyToMessage);
$isAuthorizedReplyToChatMessage = OW::getUser()->isAuthorized('mailbox', 'reply_to_chat_message');
if (!$isAuthorizedReplyToChatMessage) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', 'reply_to_chat_message');
if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
$replyToMessageActionPromotedText = $status['msg'];
}
}
$this->assign('isAuthorizedReplyToChatMessage', $isAuthorizedReplyToChatMessage);
$this->assign('replyToMessageActionPromotedText', $replyToMessageActionPromotedText);
if ($isAuthorizedReplyToMessage) {
$text = new WysiwygTextarea('mailbox_message');
$text->setId('conversationTextarea');
$this->assign('mailbox_message', $text->renderInput());
}
return parent::render();
}
示例10: onBeforeRender
public function onBeforeRender()
{
parent::onBeforeRender();
$viewAllUrl = OW::getRouter()->urlForRoute('mailbox_messages_default');
$this->assign('viewAllUrl', $viewAllUrl);
$conversationService = MAILBOX_BOL_ConversationService::getInstance();
$activeModeList = $conversationService->getActiveModeList();
$mailModeEnabled = in_array('mail', $activeModeList) ? true : false;
$this->assign('mailModeEnabled', $mailModeEnabled);
$actionName = 'send_message';
$event = new OW_Event('mailbox.show_send_message_button', array(), false);
OW::getEventManager()->trigger($event);
$showSendMessage = $event->getData();
$isAuthorizedSendMessage = $showSendMessage && OW::getUser()->isAuthorized('mailbox', $actionName);
if (!$isAuthorizedSendMessage) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
$script = '$("#mailboxConsoleListSendMessageBtn").click(function(){
OW.authorizationLimitedFloatbox(' . json_encode($status['msg']) . ');
});';
OW::getDocument()->addOnloadScript($script);
$isAuthorizedSendMessage = true;
//this service is promoted
}
}
$this->assign('isAuthorizedSendMessage', $isAuthorizedSendMessage);
}
示例11: request
/**
* Request new friendship controller
*
* @param array $params
* @throws Redirect404Exception
* @throws AuthenticateException
*/
public function request($params)
{
if (!OW::getUser()->isAuthenticated()) {
throw new AuthenticateException();
}
$requesterId = OW::getUser()->getId();
$userId = (int) $params['id'];
if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId)) {
throw new Redirect404Exception();
}
if (!OW::getUser()->isAuthorized('friends', 'add_friend')) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('friends', 'add_friend');
OW::getFeedback()->error($status['msg']);
}
$service = FRIENDS_BOL_Service::getInstance();
if ($service->findFriendship($requesterId, $userId) === null) {
$service->request($requesterId, $userId);
$service->onRequest($requesterId, $userId);
OW::getFeedback()->info(OW::getLanguage()->text('friends', 'feedback_request_was_sent'));
} else {
OW::getFeedback()->error(OW::getLanguage()->text('friends', 'feedback_request_already_sent_error_message'));
}
if (isset($params['backUri'])) {
$this->redirect($params['backUri']);
}
$this->redirect($_SERVER['HTTP_REFERER']);
}
示例12: isAuthorized
/**
*
* @param string $groupName
* @param string $actionName
* @param array $extra
* @return boolean
*/
public function isAuthorized($groupName, $actionName = null, $extra = null)
{
if ($extra !== null && !is_array($extra)) {
trigger_error("`ownerId` parameter has been deprecated, pass `extra` parameter instead\n" . OW_ErrorManager::getInstance()->debugBacktrace(), E_USER_WARNING);
}
return BOL_AuthorizationService::getInstance()->isActionAuthorized($groupName, $actionName, $extra);
}
示例13: index
/**
* Default action
*/
public function index()
{
$language = OW::getLanguage();
$clipService = VIDEO_BOL_ClipService::getInstance();
$userId = OW::getUser()->getId();
if (!OW::getUser()->isAuthorized('video', 'add')) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'add');
throw new AuthorizationException($status['msg']);
}
if (!($clipService->findUserClipsCount($userId) <= $clipService->getUserQuotaConfig())) {
$this->assign('auth_msg', $language->text('video', 'quota_exceeded', array('limit' => $clipService->getUserQuotaConfig())));
} else {
$this->assign('auth_msg', null);
$videoAddForm = new videoAddForm();
$this->addForm($videoAddForm);
if (OW::getRequest()->isPost() && $videoAddForm->isValid($_POST)) {
$values = $videoAddForm->getValues();
$code = $clipService->validateClipCode($values['code']);
if (!mb_strlen($code)) {
OW::getFeedback()->warning($language->text('video', 'resource_not_allowed'));
$this->redirect();
}
$res = $videoAddForm->process();
OW::getFeedback()->info($language->text('video', 'clip_added'));
$this->redirect(OW::getRouter()->urlForRoute('view_clip', array('id' => $res['id'])));
}
}
if (!OW::getRequest()->isAjax()) {
OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'video', 'video');
}
OW::getDocument()->setHeading($language->text('video', 'page_title_add_video'));
OW::getDocument()->setHeadingIconClass('ow_ic_video');
OW::getDocument()->setTitle($language->text('video', 'meta_title_video_add'));
OW::getDocument()->setDescription($language->text('video', 'meta_description_video_add'));
}
示例14: __construct
/**
* @return Constructor.
*/
public function __construct(BASE_CLASS_WidgetParameter $paramObj)
{
parent::__construct();
$avatarService = BOL_AvatarService::getInstance();
$viewerId = OW::getUser()->getId();
$userId = $paramObj->additionalParamList['entityId'];
if ($viewerId == $userId) {
$this->assign('owner', true);
$this->assign('changeAvatarUrl', OW::getRouter()->urlForRoute('base_avatar_crop'));
} else {
$this->assign('owner', false);
}
$avatar = $avatarService->getAvatarUrl($userId, 2);
$this->assign('avatar', $avatar ? $avatar : $avatarService->getDefaultAvatarUrl(2));
$roles = BOL_AuthorizationService::getInstance()->getRoleListOfUsers(array($userId));
$this->assign('role', !empty($roles[$userId]) ? $roles[$userId] : null);
$userService = BOL_UserService::getInstance();
$showPresence = true;
// Check privacy permissions
$eventParams = array('action' => 'base_view_my_presence_on_site', 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $e) {
$showPresence = false;
}
$this->assign('isUserOnline', $userService->findOnlineUserById($userId) && $showPresence);
$this->assign('userId', $userId);
$this->assign('avatarSize', OW::getConfig()->getValue('base', 'avatar_big_size'));
}
示例15: __construct
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);
}
}