Exemplo n.º 1
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     // get profile options
     require_once WCF_DIR . 'lib/data/user/option/UserOptions.class.php';
     $userOptions = new UserOptions();
     $this->categories = $userOptions->getOptionTree('profile', $this->frame->getUser());
     // move contact information and about me
     foreach ($this->categories as $category => $categoryData) {
         if ($category == 'profile.contact' || $category == 'profile.messenger') {
             foreach ($categoryData['options'] as $key => $option) {
                 if (isset($option['outputData'])) {
                     $this->contactInformation[] = $option['outputData'];
                 } else {
                     if (!empty($option['optionValue']) && (empty($option['outputClass']) || !$userOptions->getOutputObject($option['outputClass']) instanceof UserOptionOutputContactInformation)) {
                         $this->contactInformation[] = array('icon' => '', 'title' => WCF::getLanguage()->get('wcf.user.option.' . $option['optionName']), 'value' => $option['optionValue'], 'url' => '');
                     }
                 }
             }
             unset($this->categories[$category]);
         }
     }
     // add vcard link
     $this->contactInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('vCardM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.downloadVCard'), 'value' => StringUtil::encodeHTML($this->frame->getUser()->username), 'url' => 'index.php?page=VCard&userID=' . $this->frame->getUserID() . SID_ARG_2ND);
     // add general informations
     // registration date
     $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('registerM.png'), 'title' => WCF::getLanguage()->get('wcf.user.registrationDate'), 'value' => DateUtil::formatTime(null, $this->frame->getUser()->registrationDate));
     // languages
     require_once WCF_DIR . 'lib/acp/form/UserOptionListForm.class.php';
     $languages = array();
     $availableLanguages = UserOptionListForm::getAvailableContentLanguages();
     if (!$this->frame->getUser()->languageIDs) {
         $this->languages = $availableLanguages;
     } else {
         $languageIDs = explode(',', $this->frame->getUser()->languageIDs);
         foreach ($languageIDs as $languageID) {
             if (isset($availableLanguages[$languageID])) {
                 $languages[$languageID] = $availableLanguages[$languageID];
             }
         }
         // sort languages
         StringUtil::sort($languages);
     }
     if (count($languages)) {
         $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('languageM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.languages'), 'value' => implode(', ', $languages));
     }
     // last activity
     if (!$this->frame->getUser()->isOnline() && (!$this->frame->getUser()->invisible || WCF::getUser()->getPermission('admin.general.canViewInvisible')) && $this->frame->getUser()->lastActivityTime != 0) {
         $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('offlineM.png'), 'title' => WCF::getLanguage()->get('wcf.user.lastActivity'), 'value' => DateUtil::formatTime(null, $this->frame->getUser()->lastActivityTime, true));
     }
     // profile visits
     WCF::getTPL()->assign('user', $this->frame->getUser());
     $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('visitsM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.hits'), 'value' => StringUtil::formatNumeric($this->frame->getUser()->profileHits) . ($this->frame->getUser()->getProfileAge() > 1 ? ' ' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.hitsPerDay') : ''));
     // get profile visitors
     $sql = "SELECT\t\tavatar.*, user_table.*, visitor.*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_profile_visitor visitor\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user_table\n\t\t\tON \t\t(user_table.userID = visitor.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\tWHERE\t\townerID = " . $this->frame->getUserID() . "\n\t\t\t\t\tAND user_table.userID IS NOT NULL\n\t\t\tORDER BY\ttime DESC";
     $result = WCF::getDB()->sendQuery($sql, 5);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->profileVisitors[] = new UserProfile(null, $row);
     }
     // friends
     if (MODULE_MEMBERS_LIST == 1 && $this->frame->getUser()->shareWhitelist) {
         $sql = "SELECT\t\tavatar.*, user_table.*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist friends\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user_table\n\t\t\t\tON \t\t(user_table.userID = friends.whiteUserID)\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\t\tWHERE\t\tfriends.userID = " . $this->frame->getUserID() . "\n\t\t\t\t\t\tAND confirmed = 1\n\t\t\t\t\t\tAND user_table.userID IS NOT NULL\n\t\t\t\tORDER BY\tfriends.time DESC";
         $result = WCF::getDB()->sendQuery($sql, 5);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $this->friends[] = new UserProfile(null, $row);
         }
     }
 }