/**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     $userIDs = array();
     $eventGroups = array();
     foreach ($this->objects as &$event) {
         $userIDs[] = $event->userID;
         $event = new ViewableUserActivityEvent($event);
         if (!isset($eventGroups[$event->objectTypeID])) {
             $objectType = UserActivityEventHandler::getInstance()->getObjectType($event->objectTypeID);
             $eventGroups[$event->objectTypeID] = array('className' => $objectType->className, 'objects' => array());
         }
         $eventGroups[$event->objectTypeID]['objects'][] = $event;
     }
     unset($event);
     // set user profiles
     if (!empty($userIDs)) {
         $userIDs = array_unique($userIDs);
         $users = UserProfile::getUserProfiles($userIDs);
         foreach ($this->objects as $event) {
             $event->setUserProfile($users[$event->userID]);
         }
     }
     // parse events
     foreach ($eventGroups as $eventData) {
         $eventClass = call_user_func(array($eventData['className'], 'getInstance'));
         $eventClass->prepare($eventData['objects']);
     }
 }
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     // get user ids
     $userIDs = array();
     foreach ($this->objects as &$response) {
         if (!$this->minResponseTime || $response->time < $this->minResponseTime) {
             $this->minResponseTime = $response->time;
         }
         $userIDs[] = $response->userID;
         $response = new StructuredCommentResponse($response);
         $response->setIsDeletable($this->commentManager->canDeleteResponse($response->getDecoratedObject()));
         $response->setIsEditable($this->commentManager->canEditResponse($response->getDecoratedObject()));
     }
     unset($response);
     // fetch user data and avatars
     if (!empty($userIDs)) {
         $userIDs = array_unique($userIDs);
         $users = UserProfile::getUserProfiles($userIDs);
         foreach ($this->objects as $response) {
             if (isset($users[$response->userID])) {
                 $response->setUserProfile($users[$response->userID]);
             }
         }
     }
 }
 /**
  * Validates the 'unignore' action.
  */
 public function validateUnignore()
 {
     $this->readInteger('ignoreUserID', false, 'data');
     $userProfile = UserProfile::getUserProfile($this->parameters['data']['ignoreUserID']);
     if ($userProfile === null) {
         throw new IllegalLinkException();
     }
 }
示例#4
0
 /**
  * @see	\wcf\page\IPage::show()
  */
 public function show()
 {
     WCF::getSession()->checkPermissions(array('user.profile.canMail'));
     if (!$this->user->isAccessible('canMail')) {
         throw new PermissionDeniedException();
     }
     parent::show();
 }
 /**
  * @see	\wcf\data\IGroupedUserListAction::validateGetGroupedUserList()
  */
 public function validateGetGroupedUserList()
 {
     $this->readInteger('pageNo');
     $this->readInteger('userID');
     $this->userProfile = UserProfile::getUserProfile($this->parameters['userID']);
     if ($this->userProfile->isProtected()) {
         throw new PermissionDeniedException();
     }
 }
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     $reportUser = UserProfile::getUserProfile($this->queue->userID);
     if ($reportUser === null) {
         $reportUser = new UserProfile(new User(null, array()));
     }
     WCF::getTPL()->assign(array('reportedContent' => ModerationQueueReportManager::getInstance()->getReportedContent($this->queue), 'queueManager' => ModerationQueueReportManager::getInstance(), 'reportUser' => $reportUser));
 }
 /**
  * Returns the user-object which received this statement.
  * @return	wcf\data\user\UserProfile
  */
 public function getUser()
 {
     if ($this->user === null) {
         if ($this->userID) {
             $this->user = UserProfile::getUserProfile($this->userID);
         } else {
             $this->user = new UserProfile(new User(null, array()));
         }
     }
     return $this->user;
 }
 /**
  * @see \wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     EventHandler::getInstance()->fireAction($this, 'afterReadObjects');
     // cache userids
     $userIDs = array();
     foreach ($this->objects as $object) {
         $userIDs[] = $object->userID;
         $userIDs[] = $object->executedUserID;
     }
     array_unique($userIDs);
     UserProfile::getUserProfiles($userIDs);
 }
 /**
  * Returns a structured response.
  * 
  * @param	integer		$responseID
  * @return	\wcf\data\comment\response\StructuredCommentResponse
  */
 public static function getResponse($responseID)
 {
     $response = new CommentResponse($responseID);
     if (!$response->responseID) {
         return null;
     }
     // prepare structured response
     $response = new StructuredCommentResponse($response);
     // add user profile
     $userProfile = UserProfile::getUserProfile($response->userID);
     $response->setUserProfile($userProfile);
     return $response;
 }
示例#10
0
 /**
  * @see	\cms\system\content\type\IContentType::getOutput()
  */
 public function getOutput(Content $content)
 {
     if ($content->userID) {
         $user = UserProfile::getUserProfile($content->userID);
     } else {
         if ($content->name) {
             $user = UserProfile::getUserProfileByUsername($content->name);
         } else {
             throw new SystemException('Neither user id nor username provided');
         }
     }
     WCF::getTPL()->assign(array('user' => $user));
     return parent::getOutput($content);
 }
示例#11
0
 /**
  * Saves changes to user profile.
  * 
  * @return	array
  */
 public function save()
 {
     $userTitle = null;
     if (isset($this->parameters['values']['__userTitle'])) {
         $userTitle = StringUtil::trim(MessageUtil::stripCrap($this->parameters['values']['__userTitle']));
         unset($this->parameters['values']['__userTitle']);
     }
     $optionHandler = $this->getOptionHandler($this->userProfile->getDecoratedObject());
     $optionHandler->readUserInput($this->parameters);
     $errors = $optionHandler->validate();
     // validate user title
     if ($userTitle !== null) {
         try {
             if (mb_strlen($userTitle) > USER_TITLE_MAX_LENGTH) {
                 throw new UserInputException('__userTitle', 'tooLong');
             }
             if (!StringUtil::executeWordFilter($userTitle, USER_FORBIDDEN_TITLES)) {
                 throw new UserInputException('__userTitle', 'forbidden');
             }
         } catch (UserInputException $e) {
             $errors[$e->getField()] = $e->getType();
         }
     }
     // validation was successful
     if (empty($errors)) {
         $saveOptions = $optionHandler->save();
         $data = array('options' => $saveOptions);
         // save user title
         if ($userTitle !== null) {
             $data['data'] = array('userTitle' => $userTitle);
         }
         $userAction = new UserAction(array($this->userProfile->userID), 'update', $data);
         $userAction->executeAction();
         // check if the user will be automatically added to new
         // user groups because of the changed user options
         UserGroupAssignmentHandler::getInstance()->checkUsers(array($this->userProfile->userID));
         // return parsed template
         $user = new User($this->userProfile->userID);
         // reload option handler
         $optionHandler = $this->getOptionHandler($user, false);
         $options = $optionHandler->getOptionTree();
         WCF::getTPL()->assign(array('options' => $options, 'userID' => $this->userProfile->userID));
         return array('success' => true, 'template' => WCF::getTPL()->fetch('userProfileAbout'));
     } else {
         // validation failed
         WCF::getTPL()->assign(array('errorType' => $errors, 'optionTree' => $optionHandler->getOptionTree(), '__userTitle' => $userTitle !== null ? $userTitle : $this->userProfile->userTitle));
         return array('success' => false, 'template' => WCF::getTPL()->fetch('userProfileAboutEditable'));
     }
 }
示例#12
0
 /**
  * @see	\wcf\page\IPage::show()
  */
 public function show()
 {
     // update profile hits
     if ($this->user->userID != WCF::getUser()->userID && !WCF::getSession()->spiderID && !$this->user->isProtected()) {
         $editor = new UserEditor($this->user->getDecoratedObject());
         $editor->updateCounters(array('profileHits' => 1));
         // save visitor
         if (PROFILE_ENABLE_VISITORS && WCF::getUser()->userID && !WCF::getUser()->canViewOnlineStatus) {
             if (($visitor = UserProfileVisitor::getObject($this->user->userID, WCF::getUser()->userID)) !== null) {
                 $editor = new UserProfileVisitorEditor($visitor);
                 $editor->update(array('time' => TIME_NOW));
             } else {
                 UserProfileVisitorEditor::create(array('ownerID' => $this->user->userID, 'userID' => WCF::getUser()->userID, 'time' => TIME_NOW));
             }
         }
     }
     parent::show();
 }
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     if (!empty($this->objects)) {
         $objects = array();
         foreach ($this->objects as &$object) {
             $object = new ViewableModerationQueue($object);
             if (!isset($objects[$object->objectTypeID])) {
                 $objects[$object->objectTypeID] = array();
             }
             $objects[$object->objectTypeID][] = $object;
         }
         unset($object);
         foreach ($objects as $objectTypeID => $queueItems) {
             ModerationQueueManager::getInstance()->populate($objectTypeID, $queueItems);
         }
         // check for non-existant items
         $queueIDs = array();
         foreach ($this->objects as $index => $object) {
             if ($object->isOrphaned()) {
                 $queueIDs[] = $object->queueID;
                 unset($this->objects[$index]);
             }
         }
         // remove orphaned queues
         if (!empty($queueIDs)) {
             $this->indexToObject = array_keys($this->objects);
             ModerationQueueManager::getInstance()->removeOrphans($queueIDs);
         }
         if ($this->loadUserProfiles) {
             $userIDs = array();
             foreach ($this->objects as $object) {
                 $userIDs[] = $object->getAffectedObject()->getUserID();
             }
             $userProfiles = UserProfile::getUserProfiles($userIDs);
             foreach ($this->objects as $object) {
                 if (isset($userProfiles[$object->getAffectedObject()->getUserID()])) {
                     $object->setUserProfile($userProfiles[$object->getAffectedObject()->getUserID()]);
                 }
             }
         }
     }
 }
示例#14
0
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     $userIDs = array();
     $likeGroups = array();
     foreach ($this->objects as &$like) {
         $userIDs[] = $like->userID;
         $like = new ViewableLike($like);
         if (!isset($likeGroups[$like->objectTypeID])) {
             $objectType = ObjectTypeCache::getInstance()->getObjectType($like->objectTypeID);
             $likeGroups[$like->objectTypeID] = array('provider' => $objectType->getProcessor(), 'objects' => array());
         }
         $likeGroups[$like->objectTypeID]['objects'][] = $like;
     }
     unset($like);
     // set user profiles
     if (!empty($userIDs)) {
         $userIDs = array_unique($userIDs);
         $users = UserProfile::getUserProfiles($userIDs);
         foreach ($this->objects as $like) {
             $like->setUserProfile($users[$like->userID]);
         }
     }
     // parse like
     foreach ($likeGroups as $likeData) {
         if ($likeData['provider'] instanceof IViewableLikeProvider) {
             $likeData['provider']->prepare($likeData['objects']);
         }
     }
     // validate permissions
     foreach ($this->objects as $index => $like) {
         if (!$like->isAccessible()) {
             unset($this->objects[$index]);
         }
     }
     $this->indexToObject = array_keys($this->objects);
 }
示例#15
0
 /**
  * Loads user profiles for outstanding user ids.
  */
 public static function loadUsers()
 {
     $userIDs = array();
     foreach (self::$users as $userID => $user) {
         if ($user === null) {
             $userIDs[] = $userID;
         }
     }
     // load user profiles
     if (!empty($userIDs)) {
         $userProfiles = UserProfile::getUserProfiles($userIDs);
         foreach ($userProfiles as $userID => $userProfile) {
             self::$users[$userID] = $userProfile;
         }
     }
 }
示例#16
0
 /**
  * Validates parameters to begin profile inline editing.
  */
 public function validateBeginEdit()
 {
     if (!empty($this->objectIDs) && count($this->objectIDs) == 1) {
         $userID = reset($this->objectIDs);
         $this->userProfile = UserProfile::getUserProfile($userID);
     }
     if ($this->userProfile === null || !$this->userProfile->userID) {
         throw new UserInputException('objectIDs');
     }
     if ($this->userProfile->userID != WCF::getUser()->userID) {
         if (!$this->userProfile->canEdit()) {
             throw new PermissionDeniedException();
         }
     } else {
         if (!$this->userProfile->canEditOwnProfile()) {
             throw new PermissionDeniedException();
         }
     }
 }
 /**
  * @see    \wcf\system\like\IViewableLikeProvider::prepare()
  */
 public function prepare(array $likes)
 {
     if (!WCF::getSession()->getPermission('user.news.canReadEntry')) {
         return;
     }
     $commentLikeObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.like.likeableObject', 'com.woltlab.wcf.comment');
     $commentIDs = $responseIDs = array();
     foreach ($likes as $like) {
         if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) {
             $commentIDs[] = $like->objectID;
         } else {
             $responseIDs[] = $like->objectID;
         }
     }
     // fetch response
     $userIDs = $responses = array();
     if (!empty($responseIDs)) {
         $responseList = new CommentResponseList();
         $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs));
         $responseList->readObjects();
         $responses = $responseList->getObjects();
         foreach ($responses as $response) {
             $commentIDs[] = $response->commentID;
             if ($response->userID) {
                 $userIDs[] = $response->userID;
             }
         }
     }
     // fetch comments
     $commentList = new CommentList();
     $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
     $commentList->readObjects();
     $comments = $commentList->getObjects();
     // fetch users
     $users = array();
     $entryIDs = array();
     foreach ($comments as $comment) {
         $entryIDs[] = $comment->objectID;
         if ($comment->userID) {
             $userIDs[] = $comment->userID;
         }
     }
     if (!empty($userIDs)) {
         $users = UserProfile::getUserProfiles(array_unique($userIDs));
     }
     $entries = array();
     if (!empty($entryIDs)) {
         $entryList = new EntryList();
         $entryList->setObjectIDs($entryIDs);
         $entryList->readObjects();
         $entries = $entryList->getObjects();
     }
     // set message
     foreach ($likes as $like) {
         if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) {
             // comment like
             if (isset($comments[$like->objectID])) {
                 $comment = $comments[$like->objectID];
                 if (isset($entries[$comment->objectID]) && $entries[$comment->objectID]->canRead()) {
                     $like->setIsAccessible();
                     // short output
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.news.comment', array('commentAuthor' => $comment->userID ? $users[$comment->userID] : null, 'entry' => $entries[$comment->objectID], 'like' => $like));
                     $like->setTitle($text);
                     // output
                     $like->setDescription($comment->getExcerpt());
                 }
             }
         } else {
             // response like
             if (isset($responses[$like->objectID])) {
                 $response = $responses[$like->objectID];
                 $comment = $comments[$response->commentID];
                 if (isset($entries[$comment->objectID]) && $entries[$comment->objectID]->canRead()) {
                     $like->setIsAccessible();
                     // short output
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.news.comment.response', array('responseAuthor' => $comment->userID ? $users[$response->userID] : null, 'commentAuthor' => $comment->userID ? $users[$comment->userID] : null, 'entry' => $entries[$comment->objectID], 'like' => $like));
                     $like->setTitle($text);
                     // output
                     $like->setDescription($response->getExcerpt());
                 }
             }
         }
     }
 }
示例#18
0
 /**
  * init one user by condition
  *
  * @param  Mixed  $var
  * @param  Array  $mbqOpt
  * $mbqOpt['case'] = 'oUserProfile' means init user by oUserProfile.$var is oUserProfile.
  * $mbqOpt['case'] = 'byUserId' means init user by user id.$var is user id.
  * $mbqOpt['case'] = 'byLoginName' means init user by login name.$var is login name.
  * @return  Mixed
  */
 public function initOMbqEtUser($var = null, $mbqOpt = array())
 {
     if ($mbqOpt['case'] == 'oUserProfile') {
         $oMbqEtUser = MbqMain::$oClk->newObj('MbqEtUser');
         $oUser = $var->getDecoratedObject();
         $oMbqEtUser->userId->setOriValue($oUser->userID);
         $oMbqEtUser->loginName->setOriValue($oUser->username);
         $oMbqEtUser->userName->setOriValue($oUser->username);
         $oMbqEtUser->userEmail->setOriValue($oUser->email);
         $oMbqEtUser->userGroupIds->setOriValue($oUser->getGroupIDs());
         $oMbqEtUser->iconUrl->setOriValue($var->getAvatar()->getURL());
         $oMbqEtUser->postCount->setOriValue($oUser->wbbPosts);
         $oMbqEtUser->canSearch->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canSearch.range.yes'));
         $oMbqEtUser->canWhosonline->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canWhosonline.range.yes'));
         $oMbqEtUser->regTime->setOriValue($oUser->registrationDate);
         $oMbqEtUser->lastActivityTime->setOriValue($oUser->lastActivityTime);
         if ($var->isOnline()) {
             $oMbqEtUser->isOnline->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.isOnline.range.yes'));
         } else {
             $oMbqEtUser->isOnline->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.isOnline.range.no'));
         }
         if (MODULE_CONVERSATION && $var->getPermission('user.conversation.canUseConversation')) {
             $oMbqEtUser->canPm->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canPm.range.yes'));
             $oMbqEtUser->acceptPm->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.acceptPm.range.yes'));
             $oMbqEtUser->canSendPm->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canSendPm.range.yes'));
         }
         $oMbqEtUser->maxAttachment->setOriValue(10);
         //todo,hard code
         $oMbqEtUser->maxPngSize->setOriValue(1024 * 1024);
         //todo,hard code
         $oMbqEtUser->maxJpgSize->setOriValue(1024 * 1024);
         //todo,hard code
         $group = UserGroup::getGroupByID($oUser->groupID);
         if ($oUser->banned) {
             $oMbqEtUser->userType->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.userType.range.banned'));
         } else {
             if (empty($oUser->groupID) || empty($group)) {
                 if (REGISTER_ACTIVATION_METHOD == 1) {
                     $oMbqEtUser->userType->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.userType.range.inactive'));
                 } else {
                     $oMbqEtUser->userType->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.userType.range.unapproved'));
                 }
             } else {
                 if ($group->isAdminGroup()) {
                     $oMbqEtUser->userType->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.userType.range.admin'));
                 } else {
                     if (method_exists($group, 'isModGroup') && $group->isModGroup()) {
                         $oMbqEtUser->userType->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.userType.range.mod'));
                     } else {
                         $oMbqEtUser->userType->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.userType.range.normal'));
                     }
                 }
             }
         }
         $oMbqEtUser->mbqBind['oUser'] = $oUser;
         $oMbqEtUser->mbqBind['oUserProfile'] = $var;
         return $oMbqEtUser;
     } elseif ($mbqOpt['case'] == 'byUserId') {
         $userIds = array($var);
         $objsMbqEtUser = $this->getObjsMbqEtUser($userIds, array('case' => 'byUserIds'));
         if (is_array($objsMbqEtUser) && count($objsMbqEtUser) == 1) {
             return $objsMbqEtUser[0];
         }
         return;
     } elseif ($mbqOpt['case'] == 'byLoginName') {
         $oUserProfile = UserProfile::getUserProfileByUsername($var);
         if ($oUserProfile) {
             return $this->initOMbqEtUser($oUserProfile, array('case' => 'oUserProfile'));
         }
         return;
     } elseif ($mbqOpt['case'] == 'byEmail') {
         $userList = new UserProfileList();
         $userList->getConditionBuilder()->add("user_table.email IN (?)", array(array($var)));
         $userList->readObjects();
         $oUserProfile = current($userList->objects);
         if ($oUserProfile) {
             return $this->initOMbqEtUser($oUserProfile, array('case' => 'oUserProfile'));
         }
         return;
     }
     MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE);
 }
 /**
  * Returns a user profile by id, fetches user profiles on first call.
  * 
  * @param	integer		$userID
  * @return	\wcf\data\user\UserProfile
  */
 public function getUser($userID)
 {
     if (!empty($this->userIDs)) {
         UserProfile::getUserProfiles($this->userIDs);
         $this->userIDs = array();
     }
     return UserProfile::getUserProfile($userID);
 }
示例#20
0
 /**
  * Validates the 'cropAvatar' action.
  */
 public function validateCropAvatar()
 {
     $this->avatar = $this->getSingleObject();
     // check if user can edit the given avatar
     if ($this->avatar->userID != WCF::getUser()->userID && !WCF::getSession()->getPermission('admin.user.canEditUser')) {
         throw new PermissionDeniedException();
     }
     if (!WCF::getSession()->getPermission('user.profile.avatar.canUploadAvatar') || UserProfile::getUserProfile($this->avatar->userID)->disableAvatar) {
         throw new PermissionDeniedException();
     }
     // check parameters
     $this->readInteger('cropX', true);
     $this->readInteger('cropY', true);
     if ($this->parameters['cropX'] < 0 || $this->parameters['cropX'] > $this->avatar->width - UserAvatar::$maxThumbnailSize) {
         throw new UserInputException('cropX');
     }
     if ($this->parameters['cropY'] < 0 || $this->parameters['cropY'] > $this->avatar->height - UserAvatar::$maxThumbnailSize) {
         throw new UserInputException('cropY');
     }
 }
示例#21
0
 /**
  * init one user by condition
  *
  * @param  Mixed  $var
  * @param  Array  $mbqOpt
  * $mbqOpt['case'] = 'oUserProfile' means init user by oUserProfile.$var is oUserProfile.
  * $mbqOpt['case'] = 'byUserId' means init user by user id.$var is user id.
  * $mbqOpt['case'] = 'byLoginName' means init user by login name.$var is login name.
  * @return  Mixed
  */
 public function initOMbqEtUser($var, $mbqOpt)
 {
     if ($mbqOpt['case'] == 'oUserProfile') {
         $oMbqEtUser = MbqMain::$oClk->newObj('MbqEtUser');
         $oUser = $var->getDecoratedObject();
         $oMbqEtUser->userId->setOriValue($oUser->userID);
         $oMbqEtUser->loginName->setOriValue($oUser->username);
         $oMbqEtUser->userName->setOriValue($oUser->username);
         $oMbqEtUser->userGroupIds->setOriValue($oUser->getGroupIDs());
         $oMbqEtUser->iconUrl->setOriValue($var->getAvatar()->getURL());
         $oMbqEtUser->postCount->setOriValue($oUser->wbbPosts);
         $oMbqEtUser->canSearch->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canSearch.range.yes'));
         $oMbqEtUser->canWhosonline->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canWhosonline.range.yes'));
         $oMbqEtUser->regTime->setOriValue($oUser->registrationDate);
         $oMbqEtUser->lastActivityTime->setOriValue($oUser->lastActivityTime);
         if ($var->isOnline()) {
             $oMbqEtUser->isOnline->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.isOnline.range.yes'));
         } else {
             $oMbqEtUser->isOnline->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.isOnline.range.no'));
         }
         if (MODULE_CONVERSATION && $var->getPermission('user.conversation.canUseConversation')) {
             $oMbqEtUser->canPm->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canPm.range.yes'));
             $oMbqEtUser->acceptPm->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.acceptPm.range.yes'));
             $oMbqEtUser->canSendPm->setOriValue(MbqBaseFdt::getFdt('MbqFdtUser.MbqEtUser.canSendPm.range.yes'));
         }
         $oMbqEtUser->maxAttachment->setOriValue(10);
         //todo,hard code
         $oMbqEtUser->maxPngSize->setOriValue(1024 * 1024);
         //todo,hard code
         $oMbqEtUser->maxJpgSize->setOriValue(1024 * 1024);
         //todo,hard code
         $oMbqEtUser->mbqBind['oUserProfile'] = $var;
         return $oMbqEtUser;
     } elseif ($mbqOpt['case'] == 'byUserId') {
         $userIds = array($var);
         $objsMbqEtUser = $this->getObjsMbqEtUser($userIds, array('case' => 'byUserIds'));
         if (is_array($objsMbqEtUser) && count($objsMbqEtUser) == 1) {
             return $objsMbqEtUser[0];
         }
         return false;
     } elseif ($mbqOpt['case'] == 'byLoginName') {
         $oUserProfile = UserProfile::getUserProfileByUsername($var);
         if ($oUserProfile) {
             return $this->initOMbqEtUser($oUserProfile, array('case' => 'oUserProfile'));
         }
         return false;
     }
     MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE);
 }
示例#22
0
 /**
  * @see	wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['sum'])) {
         $this->sum = (int) $_POST['sum'];
     }
     if (isset($_POST['reason'])) {
         $this->reason = StringUtil::trim($_POST['reason']);
     }
     if (isset($_POST['username'])) {
         $this->usernames = StringUtil::trim($_POST['username']);
     }
     if (isset($_POST['isModerativ']) && $_POST['isModerativ'] == 1 && WCF::getSession()->getPermission('mod.jcoins.canModTransfer')) {
         $this->isModerativ = 1;
     }
     if (count(explode(',', $this->usernames)) > 0) {
         $users = explode(',', $this->usernames);
         $this->user = UserProfile::getUserProfilesByUsername(ArrayUtil::trim(explode(',', $this->usernames)));
     }
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     MessageForm::readData();
     if (empty($_POST)) {
         $this->text = $this->message->message;
         if ($this->isFirstMessage) {
             $this->participantCanInvite = $this->conversation->participantCanInvite;
             $this->subject = $this->conversation->subject;
             if ($this->conversation->isDraft && $this->conversation->draftData) {
                 $draftData = @unserialize($this->conversation->draftData);
                 if (!empty($draftData['participants'])) {
                     foreach (UserProfile::getUserProfiles($draftData['participants']) as $user) {
                         if (!empty($this->participants)) {
                             $this->participants .= ', ';
                         }
                         $this->participants .= $user->username;
                     }
                 }
                 if (!empty($draftData['invisibleParticipants'])) {
                     foreach (UserProfile::getUserProfiles($draftData['invisibleParticipants']) as $user) {
                         if (!empty($this->invisibleParticipants)) {
                             $this->invisibleParticipants .= ', ';
                         }
                         $this->invisibleParticipants .= $user->username;
                     }
                 }
             }
         }
     }
     // add breadcrumbs
     WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.conversation.conversations'), LinkHandler::getInstance()->getLink('ConversationList')));
     WCF::getBreadcrumbs()->add($this->conversation->getBreadcrumb());
     // get message list
     $this->messageList = new ViewableConversationMessageList();
     $this->messageList->setConversation($this->conversation);
     $this->messageList->sqlLimit = CONVERSATION_REPLY_SHOW_MESSAGES_MAX;
     $this->messageList->sqlOrderBy = 'conversation_message.time DESC';
     $this->messageList->getConditionBuilder()->add('conversation_message.conversationID = ?', array($this->message->conversationID));
     $this->messageList->getConditionBuilder()->add("conversation_message.messageID <> ?", array($this->message->messageID));
     $this->messageList->readObjects();
 }
 /**
  * Returns associated user profile object.
  * 
  * @return	\wcf\data\user\UserProfile
  */
 public function getUserProfile()
 {
     if ($this->affectedObject !== null && $this->userProfile === null) {
         if ($this->affectedObject->getUserID()) {
             $this->userProfile = UserProfile::getUserProfile($this->affectedObject->getUserID());
         } else {
             $this->userProfile = new UserProfile(new User(null, array()));
         }
     }
     return $this->userProfile;
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::isAffectedUser()
  */
 public function isAffectedUser(ModerationQueue $queue, $userID)
 {
     $user = new UserProfile(new User($userID));
     return $user->getPermission($this->requiredPermission);
 }
 /**
  * Processes a list of notification objects.
  * 
  * @param	array<\wcf\data\user\notification\UserNotification>	$notificationObjects
  * @return	array
  */
 public function processNotifications(array $notificationObjects)
 {
     // return an empty set if no notifications exist
     if (empty($notificationObjects)) {
         return array('count' => 0, 'notifications' => array());
     }
     $authorIDs = $eventIDs = $notificationIDs = $objectTypes = array();
     foreach ($notificationObjects as $notification) {
         // cache object types
         if (!isset($objectTypes[$notification->objectType])) {
             $objectTypes[$notification->objectType] = array('objectType' => $this->availableObjectTypes[$notification->objectType], 'objectIDs' => array(), 'objects' => array());
         }
         $objectTypes[$notification->objectType]['objectIDs'][] = $notification->objectID;
         $eventIDs[] = $notification->eventID;
         $notificationIDs[] = $notification->notificationID;
     }
     // load authors
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("notificationID IN (?)", array($notificationIDs));
     $sql = "SELECT\t\tnotificationID, authorID\n\t\t\tFROM\t\twcf" . WCF_N . "_user_notification_author\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\ttime ASC";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $authorIDs = $authorToNotification = array();
     while ($row = $statement->fetchArray()) {
         if ($row['authorID']) {
             $authorIDs[] = $row['authorID'];
         }
         if (!isset($authorToNotification[$row['notificationID']])) {
             $authorToNotification[$row['notificationID']] = array();
         }
         $authorToNotification[$row['notificationID']][] = $row['authorID'];
     }
     // load authors
     $authors = UserProfile::getUserProfiles($authorIDs);
     $unknownAuthor = new UserProfile(new User(null, array('userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest'))));
     // load objects associated with each object type
     foreach ($objectTypes as $objectType => $objectData) {
         $objectTypes[$objectType]['objects'] = $objectData['objectType']->getObjectsByIDs($objectData['objectIDs']);
     }
     // load required events
     $eventList = new UserNotificationEventList();
     $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", array($eventIDs));
     $eventList->readObjects();
     $eventObjects = $eventList->getObjects();
     // build notification data
     $notifications = array();
     $deleteNotifications = array();
     foreach ($notificationObjects as $notification) {
         $object = $objectTypes[$notification->objectType]['objects'][$notification->objectID];
         if ($object->__unknownNotificationObject) {
             $deleteNotifications[] = $notification;
             continue;
         }
         $className = $eventObjects[$notification->eventID]->className;
         $class = new $className($eventObjects[$notification->eventID]);
         $class->setObject($notification, $object, isset($authors[$notification->authorID]) ? $authors[$notification->authorID] : $unknownAuthor, $notification->additionalData);
         if (isset($authorToNotification[$notification->notificationID])) {
             $eventAuthors = array();
             foreach ($authorToNotification[$notification->notificationID] as $userID) {
                 if (!$userID) {
                     $eventAuthors[0] = $unknownAuthor;
                 } else {
                     if (isset($authors[$userID])) {
                         $eventAuthors[$userID] = $authors[$userID];
                     }
                 }
             }
             if (!empty($eventAuthors)) {
                 $class->setAuthors($eventAuthors);
             }
         }
         $data = array('authors' => count($class->getAuthors()), 'event' => $class, 'notificationID' => $notification->notificationID, 'time' => $notification->time);
         $data['confirmed'] = $notification->confirmTime > 0;
         $notifications[] = $data;
     }
     // check access
     foreach ($notifications as $index => $notificationData) {
         if (!$notificationData['event']->checkAccess()) {
             if ($notificationData['event']->deleteNoAccessNotification()) {
                 $deleteNotifications[] = $notificationData['event']->getNotification();
             }
             unset($notifications[$index]);
         }
     }
     if (!empty($deleteNotifications)) {
         $notificationAction = new UserNotificationAction($deleteNotifications, 'delete');
         $notificationAction->executeAction();
         // reset notification counter
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'userNotificationCount');
     }
     return array('count' => count($notifications), 'notifications' => $notifications);
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (!WCF::getUser()->userID) {
         return;
     }
     // check max pc permission
     if (ConversationHandler::getInstance()->getConversationCount() >= WCF::getSession()->getPermission('user.conversation.maxConversations')) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.conversation.error.mailboxIsFull'));
     }
     if (isset($_REQUEST['userID'])) {
         $userID = intval($_REQUEST['userID']);
         $user = UserProfile::getUserProfile($userID);
         if ($user === null || $user->userID == WCF::getUser()->userID) {
             throw new IllegalLinkException();
         }
         // validate user
         try {
             Conversation::validateParticipant($user);
         } catch (UserInputException $e) {
             throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.conversation.participants.error.' . $e->getType(), array('errorData' => array('username' => $user->username))));
         }
         $this->participants = $user->username;
     }
     // get max text length
     $this->maxTextLength = WCF::getSession()->getPermission('user.conversation.maxLength');
     // quotes
     MessageQuoteManager::getInstance()->readParameters();
 }
示例#28
0
 /**
  * get users by user login names except me
  *
  * @param  Array  $loginNames
  * @return  Array
  */
 protected function getUsersByUserLoginNamesExceptMe(array $loginNames)
 {
     foreach ($loginNames as $key => $loginName) {
         $loginNames[$key] = str_replace('\\\\', '\\', $loginNames[$key]);
         $loginNames[$key] = str_replace("\\'", "'", $loginNames[$key]);
     }
     $objsUserProfile = UserProfile::getUserProfilesByUsername($loginNames);
     $objsUser = array();
     foreach ($objsUserProfile as $oUserProfile) {
         if (empty($oUserProfile)) {
             continue;
         }
         $oUser = $oUserProfile->getDecoratedObject();
         if ($oUser->userID && $oUser->userID != $this->oUser->userID) {
             $objsUser[] = $oUser;
         }
     }
     return $objsUser;
 }
 /**
  * @see	\wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::loadObjects()
  */
 public function loadObjects(array $objectIDs)
 {
     return UserProfile::getUserProfiles($objectIDs);
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get user ids
     $userIDs = array();
     $sql = "SELECT\tDISTINCT userID\n\t\t\tFROM\twcf" . WCF_N . "_user_notification\n\t\t\tWHERE\tmailNotified = ?\n\t\t\t\tAND time < ?\n\t\t\t\tAND confirmTime = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(0, TIME_NOW - 3600 * 23, 0));
     while ($row = $statement->fetchArray()) {
         $userIDs[] = $row['userID'];
     }
     if (empty($userIDs)) {
         return;
     }
     // get users
     $userList = new UserList();
     $userList->setObjectIDs($userIDs);
     $userList->readObjects();
     $users = $userList->getObjects();
     // get notifications
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("notification.userID IN (?)", array($userIDs));
     $conditions->add("notification.mailNotified = ?", array(0));
     $conditions->add("notification.confirmTime = ?", array(0));
     $sql = "SELECT\t\tnotification.*, notification_event.eventID, object_type.objectType\n\t\t\tFROM\t\twcf" . WCF_N . "_user_notification notification\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_notification_event notification_event\n\t\t\tON\t\t(notification_event.eventID = notification.eventID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_object_type object_type\n\t\t\tON\t\t(object_type.objectTypeID = notification_event.objectTypeID)\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tnotification.time";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     // mark notifications as done
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("userID IN (?)", array($userIDs));
     $conditions->add("mailNotified = ?", array(0));
     $sql = "UPDATE\twcf" . WCF_N . "_user_notification\n\t\t\tSET\tmailNotified = 1\n\t\t\t" . $conditions;
     $statement2 = WCF::getDB()->prepareStatement($sql);
     $statement2->execute($conditions->getParameters());
     // collect data
     $eventsToUser = $objectTypes = $eventIDs = $notificationObjects = array();
     $availableObjectTypes = UserNotificationHandler::getInstance()->getAvailableObjectTypes();
     while ($row = $statement->fetchArray()) {
         if (!isset($eventsToUser[$row['userID']])) {
             $eventsToUser[$row['userID']] = array();
         }
         $eventsToUser[$row['userID']][] = $row['notificationID'];
         // cache object types
         if (!isset($objectTypes[$row['objectType']])) {
             $objectTypes[$row['objectType']] = array('objectType' => $availableObjectTypes[$row['objectType']], 'objectIDs' => array(), 'objects' => array());
         }
         $objectTypes[$row['objectType']]['objectIDs'][] = $row['objectID'];
         $eventIDs[] = $row['eventID'];
         $notificationObjects[$row['notificationID']] = new UserNotification(null, $row);
     }
     // load authors
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("notificationID IN (?)", array(array_keys($notificationObjects)));
     $sql = "SELECT\t\tnotificationID, authorID\n\t\t\tFROM\t\twcf" . WCF_N . "_user_notification_author\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\ttime ASC";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $authorIDs = $authorToNotification = array();
     while ($row = $statement->fetchArray()) {
         if ($row['authorID']) {
             $authorIDs[] = $row['authorID'];
         }
         if (!isset($authorToNotification[$row['notificationID']])) {
             $authorToNotification[$row['notificationID']] = array();
         }
         $authorToNotification[$row['notificationID']][] = $row['authorID'];
     }
     // load authors
     $authors = UserProfile::getUserProfiles($authorIDs);
     $unknownAuthor = new UserProfile(new User(null, array('userID' => null, 'username' => WCF::getLanguage()->get('wcf.user.guest'))));
     // load objects associated with each object type
     foreach ($objectTypes as $objectType => $objectData) {
         $objectTypes[$objectType]['objects'] = $objectData['objectType']->getObjectsByIDs($objectData['objectIDs']);
     }
     // load required events
     $eventList = new UserNotificationEventList();
     $eventList->getConditionBuilder()->add("user_notification_event.eventID IN (?)", array($eventIDs));
     $eventList->readObjects();
     $eventObjects = $eventList->getObjects();
     foreach ($eventsToUser as $userID => $events) {
         if (!isset($users[$userID])) {
             continue;
         }
         $user = $users[$userID];
         // no notifications for disabled or banned users
         if ($user->activationCode) {
             continue;
         }
         if ($user->banned) {
             continue;
         }
         // add mail header
         $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', array('user' => $user));
         foreach ($events as $notificationID) {
             $notification = $notificationObjects[$notificationID];
             $className = $eventObjects[$notification->eventID]->className;
             $class = new $className($eventObjects[$notification->eventID]);
             $class->setObject($notification, $objectTypes[$notification->objectType]['objects'][$notification->objectID], isset($authors[$notification->authorID]) ? $authors[$notification->authorID] : $unknownAuthor, $notification->additionalData);
             $class->setLanguage($user->getLanguage());
             if (isset($authorToNotification[$notification->notificationID])) {
                 $eventAuthors = array();
                 foreach ($authorToNotification[$notification->notificationID] as $userID) {
                     if (!$userID) {
                         $eventAuthors[0] = $unknownAuthor;
                     } else {
                         if (isset($authors[$userID])) {
                             $eventAuthors[$userID] = $authors[$userID];
                         }
                     }
                 }
                 if (!empty($eventAuthors)) {
                     $class->setAuthors($eventAuthors);
                 }
             }
             $message .= "\n\n";
             $message .= $class->getEmailMessage('daily');
         }
         // append notification mail footer
         $token = $user->notificationMailToken;
         if (!$token) {
             // generate token if not present
             $token = mb_substr(StringUtil::getHash(serialize(array($user->userID, StringUtil::getRandomID()))), 0, 20);
             $editor = new UserEditor($user);
             $editor->update(array('notificationMailToken' => $token));
         }
         $message .= "\n\n";
         $message .= $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.footer', array('user' => $user, 'token' => $token));
         // build mail
         $mail = new Mail(array($user->username => $user->email), $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.subject', array('count' => count($events))), $message);
         $mail->setLanguage($user->getLanguage());
         $mail->send();
     }
 }