*/
public $user = null;
+ /**
+ * @see wcf\acp\form\AbstractOptionListForm::$loadActiveOptions
+ */
+ public $loadActiveOptions = false;
+
/**
* @see wcf\page\IPage::readParameters()
*/
if (!UserGroup::isAccessibleGroup($this->user->getGroupIDs())) {
throw new PermissionDeniedException();
}
+
+ $this->optionHandler->setUser($this->user->getDecoratedObject());
+ $this->optionHandler->showEmptyOptions();
}
/**
use wcf\system\menu\acp\ACPMenu;
use wcf\data\user\User;
use wcf\data\user\group\UserGroup;
+use wcf\data\user\option\ViewableUserOption;
use wcf\page\SortablePage;
use wcf\system\cache\CacheHandler;
use wcf\system\clipboard\ClipboardHandler;
use wcf\system\event\EventHandler;
use wcf\system\exception\SystemException;
use wcf\system\request\LinkHandler;
-use wcf\system\user\option\UserOptions;
use wcf\system\WCF;
use wcf\util\DateUtil;
use wcf\util\StringUtil;
public $columnHeads = array();
public $sqlConditions = '';
+ protected $optionHandler = null;
+
/**
* @see wcf\page\IPage::readParameters()
*/
// get special columns
foreach ($this->users as $key => $user) {
foreach ($this->columns as $column) {
- if (isset($this->options[$column])) {
- if ($this->options[$column]->outputClass) {
- $outputObj = UserOptions::getInstance()->getOutputObject($this->options[$column]->outputClass);
- $this->columnValues[$user->userID][$column] = $outputObj->getOutput($user, $this->options[$column], $user->{$column});
- }
- else {
- $this->columnValues[$user->userID][$column] = StringUtil::encodeHTML($user->{$column});
- }
- }
- else {
- switch ($column) {
- case 'email':
- $this->columnValues[$user->userID][$column] = '<a href="mailto:'.StringUtil::encodeHTML($user->email).'">'.StringUtil::encodeHTML($user->email).'</a>';
- break;
- case 'registrationDate':
- $this->columnValues[$user->userID][$column] = DateUtil::format(DateUtil::getDateTimeByTimestamp($user->{$column}), DateUtil::DATE_FORMAT);
- break;
- }
+ switch ($column) {
+ case 'email':
+ $this->columnValues[$user->userID][$column] = '<a href="mailto:'.StringUtil::encodeHTML($user->email).'">'.StringUtil::encodeHTML($user->email).'</a>';
+ break;
+
+ case 'registrationDate':
+ $this->columnValues[$user->userID][$column] = DateUtil::format(DateUtil::getDateTimeByTimestamp($user->{$column}), DateUtil::DATE_FORMAT);
+ break;
+
+ default:
+ if (isset($this->options[$column])) {
+ if ($this->options[$column]->outputClass) {
+ $this->options[$column]->setOptionValue($user);
+ $outputObj = $this->options[$column]->getOutputObject();
+ $this->columnValues[$user->userID][$column] = $outputObj->getOutput($user, $this->options[$column]->getDecoratedObject(), $user->{$column});
+ }
+ else {
+ $this->columnValues[$user->userID][$column] = StringUtil::encodeHTML($user->{$column});
+ }
+ }
+ break;
}
}
}
'wcf\system\cache\builder\OptionCacheBuilder'
);
$this->options = CacheHandler::getInstance()->get($cacheName, 'options');
+
+ foreach ($this->options as &$option) {
+ $option = new ViewableUserOption($option);
+ }
+ unset($option);
}
/**
if ($level <= 1) {
$superCategory['categories'] = $this->getOptionTree($superCategoryName, $level + 1);
}
- if ($level > 1 || count($superCategory['categories']) == 0) {
+
+ if ($level > 1 || empty($superCategory['categories'])) {
$superCategory['options'] = $this->getCategoryOptions($superCategoryName);
}
else {
$superCategory['options'] = $this->getCategoryOptions($superCategoryName, false);
}
- if (count($superCategory['categories']) > 0 || count($superCategory['options']) > 0) {
+ if (!empty($superCategory['categories']) || !empty($superCategory['options'])) {
$tree[] = $superCategory;
}
}
if (!isset($this->options[$optionName]) || !$this->checkOption($this->options[$optionName])) continue;
// add option to list
- $children[] = $this->getOption($optionName);
+ $option = $this->getOption($optionName);
+ if ($option !== null) {
+ $children[] = $this->getOption($optionName);
+ }
}
}
* @category Community Framework
*/
class UserOptionHandler extends OptionHandler {
+ /**
+ * true, if empty options should be removed
+ * @var boolean
+ */
+ public $removeEmptyOptions = false;
+
/**
* current user
* @var wcf\data\user\User
*/
public $user = null;
+ /**
+ * Hides empty options.
+ */
+ public function hideEmptyOptions() {
+ $this->removeEmptyOptions = true;
+ }
+
+ /**
+ * Shows empty options.
+ */
+ public function showEmptyOptions() {
+ $this->removeEmptyOptions = false;
+ }
+
/**
* Sets option values for a certain user.
*
}
/**
- * @see wcf\system\option\OptionHandler::getCategoryOptions()
+ * @see wcf\system\option\OptionHandler::getOption()
*/
- public function getCategoryOptions($categoryName = '', $inherit = true) {
- $options = parent::getCategoryOptions($categoryName, $inherit);
+ public function getOption($optionName) {
+ $optionData = parent::getOption($optionName);
+
+ $optionData['object'] = new ViewableUserOption($optionData['object']);
+ $optionData['object']->setOptionValue($this->user);
- foreach ($options as $optionData) {
- $optionData['object'] = new ViewableUserOption($optionData['object']);
- $optionData['object']->setOptionValue($this->user);
+ if ($this->removeEmptyOptions && empty($optionData['object']->optionValue)) {
+ return null;
}
- die('<pre>'.print_r($options, true));
+
+ return $optionData;
}
/**