/**
  * @see	\wcf\system\dashboard\box\IDashboardBox::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     // get current date
     $currentDay = DateUtil::format(null, 'm-d');
     $date = explode('-', DateUtil::format(null, 'Y-n-j'));
     // get user ids
     $userIDs = UserBirthdayCache::getInstance()->getBirthdays($date[1], $date[2]);
     $userIDs = array_intersect($userIDs, WCF::getUserProfileHandler()->getFollowingUsers());
     if (!empty($userIDs)) {
         $userProfileList = new UserProfileList();
         $userProfileList->setObjectIDs($userIDs);
         $userProfileList->readObjects();
         $i = 0;
         foreach ($userProfileList as $userProfile) {
             if ($i == 10) {
                 break;
             }
             if (!$userProfile->isProtected() && substr($userProfile->birthday, 5) == $currentDay) {
                 $this->userProfiles[] = $userProfile;
                 $i++;
             }
         }
     }
     $this->fetched();
 }
 /**
  * @see	\wcf\system\dashboard\box\IDashboardBox::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     // get current date
     $currentDay = DateUtil::format(null, 'm-d');
     $date = explode('-', DateUtil::format(null, 'Y-n-j'));
     // get user ids
     $userIDs = UserBirthdayCache::getInstance()->getBirthdays($date[1], $date[2]);
     if (!empty($userIDs)) {
         $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
         if (isset($userOptions['birthday'])) {
             $birthdayUserOption = $userOptions['birthday'];
             $userProfileList = new UserProfileList();
             $userProfileList->setObjectIDs($userIDs);
             $userProfileList->readObjects();
             $i = 0;
             foreach ($userProfileList as $userProfile) {
                 if ($i == 10) {
                     break;
                 }
                 $birthdayUserOption->setUser($userProfile->getDecoratedObject());
                 if (!$userProfile->isProtected() && $birthdayUserOption->isVisible() && substr($userProfile->birthday, 5) == $currentDay) {
                     $this->userProfiles[] = $userProfile;
                     $i++;
                 }
             }
         }
     }
     $this->fetched();
 }
 /**
  * @see	\wcf\data\IGroupedUserListAction::getGroupedUserList()
  */
 public function getGroupedUserList()
 {
     $year = $month = $day = 0;
     $value = explode('-', $this->parameters['date']);
     if (isset($value[0])) {
         $year = intval($value[0]);
     }
     if (isset($value[1])) {
         $month = intval($value[1]);
     }
     if (isset($value[2])) {
         $day = intval($value[2]);
     }
     // get users
     $users = array();
     $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
     if (isset($userOptions['birthday'])) {
         $birthdayUserOption = $userOptions['birthday'];
         $userIDs = UserBirthdayCache::getInstance()->getBirthdays($month, $day);
         $userList = new UserProfileList();
         $userList->setObjectIDs($userIDs);
         $userList->readObjects();
         foreach ($userList->getObjects() as $user) {
             $birthdayUserOption->setUser($user->getDecoratedObject());
             if (!$user->isProtected() && $birthdayUserOption->isVisible() && $user->getAge($year) >= 0) {
                 $users[] = $user;
             }
         }
     }
     WCF::getTPL()->assign(array('users' => $users, 'year' => $year));
     return array('pageCount' => 1, 'template' => WCF::getTPL()->fetch('userBirthdayList'));
 }
 /**
  * @see	\wcf\system\user\activity\event\IUserActivityEvent::prepare()
  */
 public function prepare(array $events)
 {
     if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
         return;
     }
     $responses = $responseIDs = array();
     foreach ($events as $event) {
         $responseIDs[] = $event->objectID;
     }
     // fetch responses
     $responseList = new CommentResponseList();
     $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs));
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     // fetch comments
     $commentIDs = $comments = array();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     if (!empty($commentIDs)) {
         $commentList = new CommentList();
         $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
         $commentList->readObjects();
         $comments = $commentList->getObjects();
     }
     // fetch users
     $userIDs = $users = array();
     foreach ($comments as $comment) {
         $userIDs[] = $comment->objectID;
         $userIDs[] = $comment->userID;
     }
     if (!empty($userIDs)) {
         $userList = new UserProfileList();
         $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs));
         $userList->readObjects();
         $users = $userList->getObjects();
     }
     // set message
     foreach ($events as $event) {
         if (isset($responses[$event->objectID])) {
             $response = $responses[$event->objectID];
             $comment = $comments[$response->commentID];
             if (isset($users[$comment->objectID]) && isset($users[$comment->userID])) {
                 if (!$users[$comment->objectID]->isProtected()) {
                     $event->setIsAccessible();
                     // title
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', array('commentAuthor' => $users[$comment->userID], 'user' => $users[$comment->objectID]));
                     $event->setTitle($text);
                     // description
                     $event->setDescription($response->getExcerpt());
                 }
                 continue;
             }
         }
         $event->setIsOrphaned();
     }
 }
 /**
  * @see	\wcf\system\dashboard\box\AbstractDashboardBoxContent::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     // get ids
     $mostActiveMemberIDs = MostActiveMembersCacheBuilder::getInstance()->getData();
     if (!empty($mostActiveMemberIDs)) {
         // get profile data
         $this->userProfileList = new UserProfileList();
         $this->userProfileList->sqlOrderBy = 'user_table.activityPoints DESC';
         $this->userProfileList->setObjectIDs($mostActiveMemberIDs);
         $this->userProfileList->readObjects();
     }
     $this->fetched();
 }
Example #6
0
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     $sql = "SELECT\t\tuser_to_group.*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_group user_group,\n\t\t\t\t\twcf" . WCF_N . "_user_to_group user_to_group\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\tON\t\t(user_table.userID = user_to_group.userID)\n\t\t\tWHERE\t\tuser_to_group.groupID = user_group.groupID\n\t\t\t\t\tAND user_group.showOnTeamPage = 1\n\t\t\tORDER BY\tuser_group.priority DESC" . (!empty($this->sqlOrderBy) ? ", " . $this->sqlOrderBy : '');
     $statement = WCF::getDB()->prepareStatement($sql, $this->sqlLimit, $this->sqlOffset);
     $statement->execute();
     while ($row = $statement->fetchArray()) {
         if (!isset($this->teams[$row['groupID']])) {
             $userGroup = UserGroup::getGroupByID($row['groupID']);
             $this->teams[$row['groupID']] = new Team($userGroup);
         }
         $this->teams[$row['groupID']]->addMember($this->objects[$row['userID']]);
     }
 }
 /**
  * @see	\wcf\data\user\UserProfileList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     // check for deleted users
     $sql = "SELECT\tusername\n\t\t\tFROM\twcf" . WCF_N . "_conversation_to_user\n\t\t\tWHERE\tconversationID = ?\n\t\t\t\tAND participantID IS NULL";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->conversationID));
     $i = 0;
     while ($row = $statement->fetchArray()) {
         // create fake user profiles
         $user = new User(null, array('userID' => 0, 'username' => $row['username']));
         $this->objects['x' . ++$i] = new UserProfile($user);
         $this->indexToObject[] = 'x' . $i;
     }
 }
Example #8
0
 /**
  * @see	\wcf\data\ISearchAction::getSearchResultList()
  */
 public function getSearchResultList()
 {
     $searchString = $this->parameters['data']['searchString'];
     $excludedSearchValues = array();
     if (isset($this->parameters['data']['excludedSearchValues'])) {
         $excludedSearchValues = $this->parameters['data']['excludedSearchValues'];
     }
     $list = array();
     if ($this->parameters['data']['includeUserGroups']) {
         $accessibleGroups = UserGroup::getAccessibleGroups();
         foreach ($accessibleGroups as $group) {
             $groupName = $group->getName();
             if (!in_array($groupName, $excludedSearchValues)) {
                 $pos = mb_strripos($groupName, $searchString);
                 if ($pos !== false && $pos == 0) {
                     $list[] = array('label' => $groupName, 'objectID' => $group->groupID, 'type' => 'group');
                 }
             }
         }
     }
     // find users
     $userProfileList = new UserProfileList();
     $userProfileList->getConditionBuilder()->add("username LIKE ?", array($searchString . '%'));
     if (!empty($excludedSearchValues)) {
         $userProfileList->getConditionBuilder()->add("username NOT IN (?)", array($excludedSearchValues));
     }
     $userProfileList->sqlLimit = 10;
     $userProfileList->readObjects();
     foreach ($userProfileList as $userProfile) {
         $list[] = array('icon' => $userProfile->getAvatar()->getImageTag(16), 'label' => $userProfile->username, 'objectID' => $userProfile->userID, 'type' => 'user');
     }
     return $list;
 }
Example #9
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 user profile preview.
  * 
  * @return	array
  */
 public function getUserProfile()
 {
     $userID = reset($this->objectIDs);
     if ($userID) {
         $userProfileList = new UserProfileList();
         $userProfileList->getConditionBuilder()->add("user_table.userID = ?", array($userID));
         $userProfileList->readObjects();
         $userProfiles = $userProfileList->getObjects();
         if (empty($userProfiles)) {
             WCF::getTPL()->assign('unknownUser', true);
         } else {
             WCF::getTPL()->assign('user', reset($userProfiles));
         }
     } else {
         WCF::getTPL()->assign('unknownUser', true);
     }
     return array('template' => WCF::getTPL()->fetch('userProfilePreview'), 'userID' => $userID);
 }
Example #11
0
 /**
  * Returns the user profiles of the users with the given names.
  * 
  * @param	array<string>			$usernames
  * @return	array<\wcf\data\user\UserProfile>
  */
 public static function getUserProfilesByUsername(array $usernames)
 {
     $users = array();
     // save case sensitive usernames
     $caseSensitiveUsernames = array();
     foreach ($usernames as &$username) {
         $tmp = mb_strtolower($username);
         $caseSensitiveUsernames[$tmp] = $username;
         $username = $tmp;
     }
     unset($username);
     // check cache
     foreach ($usernames as $index => $username) {
         foreach (self::$userProfiles as $user) {
             if (mb_strtolower($user->username) === $username) {
                 $users[$username] = $user;
                 unset($usernames[$index]);
             }
         }
     }
     if (!empty($usernames)) {
         $userList = new UserProfileList();
         $userList->getConditionBuilder()->add("user_table.username IN (?)", array($usernames));
         $userList->readObjects();
         foreach ($userList as $user) {
             $users[mb_strtolower($user->username)] = $user;
             self::$userProfiles[$user->userID] = $user;
         }
         foreach ($usernames as $username) {
             if (!isset($users[$username])) {
                 $users[$username] = null;
             }
         }
     }
     // revert usernames to original case
     foreach ($users as $username => $user) {
         unset($users[$username]);
         if (isset($caseSensitiveUsernames[$username])) {
             $users[$caseSensitiveUsernames[$username]] = $user;
         }
     }
     return $users;
 }