/** * @see \wcf\system\importer\IImporter::import() */ public function import($oldID, array $data, array $additionalData = array()) { $data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']); if (!$data['groupID']) { $data['groupID'] = UserGroup::getGroupByType(UserGroup::USERS)->groupID; } $rank = UserRankEditor::create($data); ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.rank', $oldID, $rank->rankID); return $rank->rankID; }
/** * @see \wcf\system\importer\IImporter::import() */ public function import($oldID, array $data, array $additionalData = array()) { if ($data['groupType'] < 4) { $newGroupID = UserGroup::getGroupByType($data['groupType'])->groupID; } else { $action = new UserGroupAction(array(), 'create', array('data' => $data)); $returnValues = $action->executeAction(); $newGroupID = $returnValues['returnValues']->groupID; } ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.group', $oldID, $newGroupID); return $newGroupID; }
/** * @see \wcf\system\option\IOptionHandler::readData() */ public function readData() { $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE); foreach ($this->options as $option) { $this->optionValues[$option->optionName] = $defaultGroup->getGroupOption($option->optionName); // use group values over default values if ($this->group !== null) { $groupValue = $this->group->getGroupOption($option->optionName); if ($groupValue !== null) { $this->optionValues[$option->optionName] = $groupValue; } } } }
/** * 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); } }
/** * @see wcf\form\IForm::save() */ public function save() { parent::save(); // get default group $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE); $optionValues = $this->optionHandler->save(); $saveOptions = array(); foreach ($this->optionHandler->getCategoryOptions() as $option) { $option = $option['object']; $defaultValue = $defaultGroup->getGroupOption($option->optionName); $typeObject = $this->optionHandler->getTypeObject($option->optionType); $newValue = $typeObject->diff($defaultValue, $optionValues[$option->optionID]); if ($newValue !== null) { $saveOptions[$option->optionID] = $newValue; } } $data = array( 'data' => array_merge($this->additionalFields, array('groupName' => $this->groupName)), 'options' => $saveOptions ); $this->objectAction = new UserGroupAction(array(), 'create', $data); $this->objectAction->executeAction(); if (!I18nHandler::getInstance()->isPlainValue('groupName')) { $returnValues = $this->objectAction->getReturnValues(); $groupID = $returnValues['returnValues']->groupID; I18nHandler::getInstance()->save('groupName', 'wcf.acp.group.group'.$groupID, 'wcf.acp.group', 1); // update group name $groupEditor = new UserGroupEditor($returnValues['returnValues']); $groupEditor->update(array( 'groupName' => 'wcf.acp.group.group'.$groupID )); } $this->saved(); // show success message WCF::getTPL()->assign(array( 'success' => true )); // reset values $this->groupName = ''; $this->optionValues = array(); }
/** * @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(); }
/** * @see wcf\form\IForm::save() */ public function save() { AbstractForm::save(); // save group $optionValues = $this->optionHandler->save(); $saveOptions = array(); if ($this->group->groupType == UserGroup::EVERYONE) { $saveOptions = $optionValues; } else { // get default group $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE); foreach ($this->optionHandler->getCategoryOptions() as $option) { $option = $option['object']; if ($optionValues[$option->optionID] != $defaultGroup->getGroupOption($option->optionName)) { $saveOptions[$option->optionID] = $optionValues[$option->optionID]; } } } $this->groupName = 'wcf.acp.group.group' . $this->group->groupID; if (I18nHandler::getInstance()->isPlainValue('groupName')) { I18nHandler::getInstance()->remove($this->groupName, 1); $this->groupName = I18nHandler::getInstance()->getValue('groupName'); } else { I18nHandler::getInstance()->save('groupName', $this->groupName, 'wcf.acp.group', 1); } $data = array('data' => array_merge(array('groupName' => $this->groupName), $this->additionalFields), 'options' => $saveOptions); $this->objectAction = new UserGroupAction(array($this->groupID), 'update', $data); $this->objectAction->executeAction(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { if (empty($_POST)) { I18nHandler::getInstance()->setOptions('groupName', 1, $this->group->groupName, 'wcf.acp.group.group\\d+'); I18nHandler::getInstance()->setOptions('groupDescription', 1, $this->group->groupDescription, 'wcf.acp.group.groupDescription\\d+'); $this->groupName = $this->group->groupName; $this->groupDescription = $this->group->groupDescription; $this->priority = $this->group->priority; $this->userOnlineMarking = $this->group->userOnlineMarking; $this->showOnTeamPage = $this->group->showOnTeamPage; $options = $this->optionHandler->getCategoryOptions(); // get default values if ($this->group->groupType != UserGroup::EVERYONE) { $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE); foreach ($options as $option) { $value = $defaultGroup->getGroupOption($option['object']->optionName); if ($value !== null) { $this->optionValues[$option['object']->optionName] = $value; } } } foreach ($options as $option) { $value = $this->group->getGroupOption($option['object']->optionName); if ($value !== null) { $this->optionValues[$option['object']->optionName] = $value; } } } parent::readData(); }