예제 #1
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $avatarData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($this->user->id));
     $avatarDto = BOL_AvatarService::getInstance()->findByUserId($this->user->id);
     $owner = false;
     if (OW::getUser()->getId() == $this->user->getId()) {
         $owner = true;
     }
     $isModerator = OW::getUser()->isAuthorized('base') || OW::getUser()->isAdmin();
     $avatarData[$this->user->id]['src'] = BOL_AvatarService::getInstance()->getAvatarUrl($this->user->getId(), 1, null, true, !($owner || $isModerator));
     $default_avatar['src'] = BOL_AvatarService::getInstance()->getDefaultAvatarUrl(1);
     $user = array();
     $user["avatar"] = !empty($avatarData[$this->user->id]['src']) ? $avatarData[$this->user->id] : $default_avatar;
     $user["displayName"] = $avatarData[$this->user->id]["title"];
     $this->assign("user", $user);
     $this->addComponent('toolbar', OW::getClassInstance("BASE_MCMP_ProfileActionToolbar", $this->user->id));
     $eventParams = array('action' => 'base_view_my_presence_on_site', 'ownerIdList' => array($this->user->id), 'viewerId' => OW::getUser()->getId());
     $permissions = OW::getEventManager()->getInstance()->call('privacy_check_permission_for_user_list', $eventParams);
     $showPresence = !(isset($permissions[$this->user->id]['blocked']) && $permissions[$this->user->id]['blocked'] == true);
     $this->assign("showPresence", $showPresence);
     $isOnline = null;
     $activityStamp = null;
     if ($showPresence) {
         $onlineInfo = BOL_UserService::getInstance()->findOnlineStatusForUserList(array($this->user->id));
         $isOnline = $onlineInfo[$this->user->id];
         $activityStamp = $this->user->activityStamp;
     }
     $this->assign("isOnline", $isOnline);
     $this->assign("avatarDto", $avatarDto);
     $this->assign("activityStamp", $activityStamp);
     $this->assign('owner', $owner);
     $this->assign('isModerator', $isModerator);
 }
예제 #2
0
파일: user.php 프로젝트: hardikamutech/loov
 /**
  * Get user id
  *
  * @return int
  */
 public function getId()
 {
     return $this->user === null ? 0 : $this->user->getId();
 }
예제 #3
0
파일: service.php 프로젝트: vazahat/dudex
 /**
  *
  * @param BOL_User $user
  */
 public function getOnlinePeople($user)
 {
     $users = array();
     $count = 0;
     if ((bool) OW::getEventManager()->call('plugin.friends')) {
         $count_friends = (int) OW::getEventManager()->call('plugin.friends.count_friends', array('userId' => $user->getId()));
         $idList = OW::getEventManager()->call('plugin.friends.get_friend_list', array('userId' => $user->getId(), 'count' => $count_friends));
         if (!empty($idList)) {
             $statusForUserList = BOL_UserService::getInstance()->findOnlineStatusForUserList($idList);
             foreach ($statusForUserList as $userId => $isOnline) {
                 if (!$isOnline) {
                     continue;
                 }
                 $eventParams = array('action' => 'ajaxim_invite_to_chat', 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
                 try {
                     OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
                 } catch (RedirectException $e) {
                     continue;
                 }
                 if (BOL_UserService::getInstance()->isBlocked($userId, OW::getUser()->getId()) || BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId)) {
                     continue;
                 }
                 $count++;
                 $users[$userId] = BOL_UserService::getInstance()->findUserById($userId);
             }
         }
     } else {
         $onlineCount = (int) BOL_UserService::getInstance()->countOnline();
         $onlineList = BOL_UserService::getInstance()->findOnlineList(0, $onlineCount);
         foreach ($onlineList as $user) {
             if ($user->getId() == OW::getUser()->getId()) {
                 continue;
             }
             $eventParams = array('action' => 'ajaxim_invite_to_chat', 'ownerId' => $user->getId(), 'viewerId' => OW::getUser()->getId());
             try {
                 OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
             } catch (RedirectException $e) {
                 continue;
             }
             if (BOL_UserService::getInstance()->isBlocked($user->getId(), OW::getUser()->getId()) || BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $user->getId())) {
                 continue;
             }
             $users[$user->getId()] = $user;
             $count++;
         }
     }
     return array('users' => $users, 'count' => $count);
 }