/**
  * Returns a list of all available user groups.
  * 
  * @return	array
  */
 protected function getAvailableGroups()
 {
     $userGroups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
     // work-around for PHP 5.3.3 randomly failing in uasort()
     foreach ($userGroups as $userGroup) {
         $userGroup->getName();
     }
     uasort($userGroups, function (UserGroup $groupA, UserGroup $groupB) {
         return strcmp($groupA->getName(), $groupB->getName());
     });
     return $userGroups;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function readData()
 {
     parent::readData();
     if (empty($_POST)) {
         // get marked user ids
         if (empty($this->action)) {
             // get type id
             $objectTypeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
             if ($objectTypeID === null) {
                 throw new SystemException("Unknown clipboard item type 'com.woltlab.wcf.user'");
             }
             // get user ids
             $users = ClipboardHandler::getInstance()->getMarkedItems($objectTypeID);
             if (empty($users)) {
                 throw new IllegalLinkException();
             }
             // load users
             $this->userIDs = array_keys($users);
         }
         if (MAIL_USE_FORMATTED_ADDRESS) {
             $this->from = MAIL_FROM_NAME . ' <' . MAIL_FROM_ADDRESS . '>';
         } else {
             $this->from = MAIL_FROM_ADDRESS;
         }
     }
     if (!empty($this->userIDs)) {
         $this->userList = new UserList();
         $this->userList->getConditionBuilder()->add("user_table.userID IN (?)", array($this->userIDs));
         $this->userList->sqlOrderBy = "user_table.username ASC";
         $this->userList->readObjects();
     }
     $this->groups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE));
 }
Esempio n. 4
0
	/**
	 * Reads accessible user groups.
	 */
	protected function readAccessibleGroups() {
		$this->groups = UserGroup::getAccessibleGroups();
		$this->canEditEveryone = false;
		foreach ($this->groups as $groupID => $group) {
			if ($group->groupType == UserGroup::EVERYONE) {
				$this->canEditEveryone = true;
				
				// remove 'Everyone' from groups
				$this->groupEveryone = $group;
				unset($this->groups[$groupID]);
			}
		}
		
		// add 'Everyone' group
		if (!$this->canEditEveryone) {
			$this->groupEveryone = UserGroup::getGroupByType(UserGroup::EVERYONE);
		}
	}
Esempio n. 5
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // handle avatar
     if ($this->avatarType != 'custom') {
         // delete custom avatar
         if ($this->user->avatarID) {
             $action = new UserAvatarAction(array($this->user->avatarID), 'delete');
             $action->executeAction();
         }
     }
     switch ($this->avatarType) {
         case 'none':
             $avatarData = array('avatarID' => null, 'enableGravatar' => 0);
             break;
         case 'custom':
             $avatarData = array('enableGravatar' => 0);
             break;
         case 'gravatar':
             $avatarData = array('avatarID' => null, 'enableGravatar' => 1);
             break;
     }
     $this->additionalFields = array_merge($this->additionalFields, $avatarData);
     // add default groups
     $defaultGroups = UserGroup::getAccessibleGroups(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
     $oldGroupIDs = $this->user->getGroupIDs();
     foreach ($oldGroupIDs as $oldGroupID) {
         if (isset($defaultGroups[$oldGroupID])) {
             $this->groupIDs[] = $oldGroupID;
         }
     }
     $this->groupIDs = array_unique($this->groupIDs);
     // save user
     $saveOptions = $this->optionHandler->save();
     $data = array('data' => array_merge($this->additionalFields, array('username' => $this->username, 'email' => $this->email, 'password' => $this->password, 'languageID' => $this->languageID, 'userTitle' => $this->userTitle, 'signature' => $this->signature, 'signatureEnableBBCodes' => $this->signatureEnableBBCodes, 'signatureEnableSmilies' => $this->signatureEnableSmilies, 'signatureEnableHtml' => $this->signatureEnableHtml)), 'groups' => $this->groupIDs, 'languageIDs' => $this->visibleLanguages, 'options' => $saveOptions);
     // handle ban
     if (WCF::getSession()->getPermission('admin.user.canBanUser')) {
         if ($this->banExpires) {
             $this->banExpires = strtotime($this->banExpires);
         } else {
             $this->banExpires = 0;
         }
         $data['data']['banned'] = $this->banned;
         $data['data']['banReason'] = $this->banReason;
         $data['data']['banExpires'] = $this->banExpires;
     }
     // handle disabled signature
     if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) {
         if ($this->disableSignatureExpires) {
             $this->disableSignatureExpires = strtotime($this->disableSignatureExpires);
         } else {
             $this->disableSignatureExpires = 0;
         }
         $data['data']['disableSignature'] = $this->disableSignature;
         $data['data']['disableSignatureReason'] = $this->disableSignatureReason;
         $data['data']['disableSignatureExpires'] = $this->disableSignatureExpires;
     }
     // handle disabled avatar
     if (WCF::getSession()->getPermission('admin.user.canDisableAvatar')) {
         if ($this->disableAvatarExpires) {
             $this->disableAvatarExpires = strtotime($this->disableAvatarExpires);
         } else {
             $this->disableAvatarExpires = 0;
         }
         $data['data']['disableAvatar'] = $this->disableAvatar;
         $data['data']['disableAvatarReason'] = $this->disableAvatarReason;
         $data['data']['disableAvatarExpires'] = $this->disableAvatarExpires;
     }
     $this->objectAction = new UserAction(array($this->userID), 'update', $data);
     $this->objectAction->executeAction();
     // update user rank
     $editor = new UserEditor(new User($this->userID));
     if (MODULE_USER_RANK) {
         $action = new UserProfileAction(array($editor), 'updateUserRank');
         $action->executeAction();
     }
     if (MODULE_USERS_ONLINE) {
         $action = new UserProfileAction(array($editor), 'updateUserOnlineMarking');
         $action->executeAction();
     }
     // remove assignments
     $sql = "DELETE FROM\twcf" . WCF_N . "_moderation_queue_to_user\n\t\t\tWHERE\t\tuserID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->user->userID));
     // reset moderation count
     ModerationQueueManager::getInstance()->resetModerationCount($this->user->userID);
     $this->saved();
     // reset password
     $this->password = $this->confirmPassword = '';
     // show success message
     WCF::getTPL()->assign('success', true);
 }
Esempio n. 6
0
 /**
  * Returns a list of users and -groups based upon given search criteria.
  * 
  * @return	array<array>
  */
 public function getList()
 {
     $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 = StringUtil::indexOfIgnoreCase($groupName, $searchString);
                 if ($pos !== false && $pos == 0) {
                     $list[] = array('label' => $groupName, 'objectID' => $group->groupID, 'type' => 'group');
                 }
             }
         }
     }
     $conditionBuilder = new PreparedStatementConditionBuilder();
     $conditionBuilder->add("username LIKE ?", array($searchString . '%'));
     if (count($excludedSearchValues)) {
         $conditionBuilder->add("username NOT IN (?)", array($excludedSearchValues));
     }
     // find users
     $sql = "SELECT\tuserID, username\n\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t" . $conditionBuilder;
     $statement = WCF::getDB()->prepareStatement($sql, 10);
     /* TODO: add limit parameter */
     $statement->execute($conditionBuilder->getParameters());
     while ($row = $statement->fetchArray()) {
         $list[] = array('label' => $row['username'], 'objectID' => $row['userID'], 'type' => 'user');
     }
     return $list;
 }
 /**
  * Get a list of available groups.
  */
 protected function readGroups()
 {
     $this->groups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['id'])) {
         $this->userGroupOptionID = intval($_REQUEST['id']);
     }
     $this->userGroupOption = new UserGroupOption($this->userGroupOptionID);
     if (!$this->userGroupOption) {
         throw new IllegalLinkException();
     }
     // verify options and permissions for current option
     if ($this->verifyPermissions($this->userGroupOption)) {
         // read all categories
         $categoryList = new UserGroupOptionCategoryList();
         $categoryList->readObjects();
         $categories = array();
         foreach ($categoryList as $category) {
             $categories[$category->categoryName] = $category;
         }
         // verify categories
         $category = $categories[$this->userGroupOption->categoryName];
         while ($category != null) {
             if (!$this->verifyPermissions($category)) {
                 throw new PermissionDeniedException();
             }
             array_unshift($this->parentCategories, $category);
             $category = $category->parentCategoryName != '' ? $categories[$category->parentCategoryName] : null;
         }
     } else {
         throw new PermissionDeniedException();
     }
     // read accessible groups
     $this->groups = UserGroup::getAccessibleGroups();
     if ($this->userGroupOption->usersOnly) {
         $guestGroup = UserGroup::getGroupByType(UserGroup::GUESTS);
         if (isset($this->groups[$guestGroup->groupID])) {
             unset($this->groups[$guestGroup->groupID]);
         }
     }
     if (empty($this->groups)) {
         throw new PermissionDeniedException();
     }
     // get option type
     $className = 'wcf\\system\\option\\user\\group\\' . ucfirst($this->userGroupOption->optionType) . 'UserGroupOptionType';
     if (!class_exists($className)) {
         throw new SystemException("Unable to find option type for '" . $this->userGroupOption->optionType . "'");
     }
     $this->optionType = new $className();
 }
 /**
  * Returns a list of all available user groups.
  * 
  * @return	array
  */
 protected function getAvailableGroups()
 {
     return UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     I18nHandler::getInstance()->register('description');
     I18nHandler::getInstance()->register('title');
     // get available user groups
     $this->availableUserGroups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
     if (!count(PaymentMethodHandler::getInstance()->getPaymentMethods())) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.acp.paidSubscription.error.noPaymentMethods'));
     }
     // get available currencies
     foreach (PaymentMethodHandler::getInstance()->getPaymentMethods() as $paymentMethod) {
         $this->availableCurrencies = array_merge($this->availableCurrencies, $paymentMethod->getSupportedCurrencies());
     }
     $this->availableCurrencies = array_unique($this->availableCurrencies);
     sort($this->availableCurrencies);
     // get available subscriptions
     $this->getAvailableSubscriptions();
 }
Esempio n. 11
0
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     I18nHandler::getInstance()->assignVariables(!empty($_POST));
     WCF::getTPL()->assign(array('groupID' => $this->group->groupID, 'group' => $this->group, 'action' => 'edit', 'availableUserGroups' => UserGroup::getAccessibleGroups()));
     // add warning when the initiator is in the group
     if ($this->group->isMember()) {
         WCF::getTPL()->assign('warningSelfEdit', true);
     }
 }
Esempio n. 12
0
 /**
  * @see wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // add default groups
     $defaultGroups = UserGroup::getAccessibleGroups(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
     $oldGroupIDs = $this->user->getGroupIDs();
     foreach ($oldGroupIDs as $oldGroupID) {
         if (isset($defaultGroups[$oldGroupID])) {
             $this->groupIDs[] = $oldGroupID;
         }
     }
     $this->groupIDs = array_unique($this->groupIDs);
     // save user
     $saveOptions = $this->optionHandler->save();
     $this->additionalFields['languageID'] = $this->languageID;
     $data = array('data' => array_merge($this->additionalFields, array('username' => $this->username, 'email' => $this->email, 'password' => $this->password)), 'groups' => $this->groupIDs, 'languages' => $this->visibleLanguages, 'options' => $saveOptions);
     $this->objectAction = new UserAction(array($this->userID), 'update', $data);
     $this->objectAction->executeAction();
     $this->saved();
     // reset password
     $this->password = $this->confirmPassword = '';
     // show success message
     WCF::getTPL()->assign('success', true);
 }
Esempio n. 13
0
 /**
  * Returns the selectable user groups.
  * 
  * @return	array<\wcf\data\user\group\UserGroup>
  */
 protected function getUserGroups()
 {
     if ($this->userGroups == null) {
         $invalidGroupTypes = array(UserGroup::EVERYONE, UserGroup::USERS);
         if (!$this->includeguests) {
             $invalidGroupTypes[] = UserGroup::GUESTS;
         }
         $this->userGroups = UserGroup::getAccessibleGroups(array(), $invalidGroupTypes);
         uasort($this->userGroups, function (UserGroup $groupA, UserGroup $groupB) {
             return strcmp($groupA->getName(), $groupB->getName());
         });
     }
     return $this->userGroups;
 }