/**
  * @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);
 }
Beispiel #2
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);
 }
Beispiel #3
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);
 }