Add "usersonly" setting for user group options
authorMatthias Schmidt <gravatronics@live.com>
Fri, 20 Jun 2014 18:26:58 +0000 (20:26 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 20 Jun 2014 18:26:58 +0000 (20:26 +0200)
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php
wcfsetup/install/files/lib/system/cache/builder/UserGroupOptionCacheBuilder.class.php
wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php
wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/session/SessionHandler.class.php
wcfsetup/setup/db/install.sql

index 5a864cd00ed09b697d7aa3a2f139a2822631c1a0..0f9e318c9770e393c1418b6487e6f3c053afc25e 100644 (file)
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.general.canViewPageDuringOfflineMode">
                                <categoryname>admin.general</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.canEditOption">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.canViewLog">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.canManageApplication">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.canImportData">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.canRebuildData">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.canManageCronjob">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.package.canUpdatePackage">
                                <categoryname>admin.system.package</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.package.canUninstallPackage">
                                <categoryname>admin.system.package</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.system.package.canEditServer">
                                <categoryname>admin.system.package</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.accessibleGroups">
                                <categoryname>admin.user.group</categoryname>
                                <optiontype>userGroups</optiontype>
                                <defaultvalue></defaultvalue>
                                <admindefaultvalue>1,2,3,4,5,6</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canAddUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canSearchUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canEditUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canEditMailAddress">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canEditPassword">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canDeleteUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canBanUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canDisableAvatar">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canDisableSignature">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canMailUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.user.canAddGroup">
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canDeleteGroup">
                                <categoryname>admin.user.group</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canManageGroupAssignment">
                                <categoryname>admin.user.group</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.user.canManageUserOption">
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.language.canManageLanguage">
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.style.canManageStyle">
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.style.canUseDisabledStyle">
                                <categoryname>admin.style</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.display.canManagePageMenu">
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.template.canManageTemplate">
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="user.attachment.maxSize">
                                <defaultvalue>1000000</defaultvalue>
                                <minvalue>10000</minvalue>
                                <options>module_attachment</options>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.attachment.allowedExtensions">
                                <categoryname>user.message.attachment</categoryname>
@@ -340,6 +372,7 @@ pdf]]></defaultvalue>
                                <minvalue>1</minvalue>
                                <options>module_attachment</options>
                                <maxvalue>100</maxvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.attachment.canManageAttachment">
@@ -348,6 +381,7 @@ pdf]]></defaultvalue>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                                <options>module_attachment</options>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.content.bbcode.canManageBBCode">
@@ -355,6 +389,7 @@ pdf]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.content.smiley.canManageSmiley">
@@ -362,6 +397,7 @@ pdf]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <!-- user.message -->
@@ -403,24 +439,28 @@ pdf]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canViewIpAddress">
                                <categoryname>admin.general</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canEnableUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canEditActivityPoints">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.content.dashboard.canEditDashboard">
@@ -428,12 +468,14 @@ pdf]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.rank.canManageRank">
                                <categoryname>admin.user.rank</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <!-- user.signature -->
@@ -441,17 +483,20 @@ pdf]]></defaultvalue>
                                <categoryname>user.signature</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>1</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.signature.canUseHtml">
                                <categoryname>user.signature</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.signature.canUseBBCodes">
                                <categoryname>user.signature</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>1</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.signature.maxLength">
                                <categoryname>user.signature</categoryname>
@@ -460,11 +505,13 @@ pdf]]></defaultvalue>
                                <admindefaultvalue>10000</admindefaultvalue>
                                <minvalue>100</minvalue>
                                <maxvalue>65535</maxvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.signature.allowedBBCodes">
                                <categoryname>user.signature</categoryname>
                                <optiontype>BBCodeSelect</optiontype>
                                <defaultvalue>all</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <!-- /user.signature -->
                        
@@ -479,28 +526,33 @@ pdf]]></defaultvalue>
                                <categoryname>user.profile</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>1</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.canQuit">
                                <categoryname>user.profile</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.canRename">
                                <categoryname>user.profile</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>1</defaultvalue>
                                <enableoptions>user.profile.renamePeriod</enableoptions>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.renamePeriod">
                                <categoryname>user.profile</categoryname>
                                <optiontype>inverseInteger</optiontype>
                                <defaultvalue>182</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.canEditUserTitle">
                                <categoryname>user.profile</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.canViewMembersList">
                                <categoryname>user.profile</categoryname>
@@ -523,6 +575,7 @@ pdf]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.canReportContent">
                                <categoryname>user.profile</categoryname>
@@ -536,6 +589,7 @@ pdf]]></defaultvalue>
                                <admindefaultvalue>10000</admindefaultvalue>
                                <minvalue>100</minvalue>
                                <maxvalue>65535</maxvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="user.profile.avatar.canSeeAvatars">
@@ -548,12 +602,14 @@ pdf]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>1</defaultvalue>
                                <enableoptions>user.profile.avatar.maxSize,user.profile.avatar.allowedFileExtensions</enableoptions>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.avatar.maxSize">
                                <categoryname>user.profile.avatar</categoryname>
                                <optiontype>fileSize</optiontype>
                                <defaultvalue>100000</defaultvalue>
                                <minvalue>10000</minvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <option name="user.profile.avatar.allowedFileExtensions">
                                <categoryname>user.profile.avatar</categoryname>
@@ -562,6 +618,7 @@ pdf]]></defaultvalue>
 jpg
 jpeg
 png]]></defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <!-- /user.profile -->
                        
@@ -570,6 +627,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <moddefaultvalue>1</moddefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="user.like.canViewLike">
@@ -583,6 +641,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>1</defaultvalue>
                                <options>module_like</options>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <!-- mod.general -->
@@ -627,6 +686,7 @@ png]]></defaultvalue>
                                <categoryname>user.profileComment</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        <!-- /user.profileComment -->
                        
@@ -635,6 +695,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.content.tag.canManageTag">
@@ -642,6 +703,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.content.notice.canManageNotice">
@@ -649,6 +711,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.content.ad.canManageAd">
@@ -656,6 +719,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                        
                        <option name="admin.captcha.canManageCaptchaQuestion">
@@ -663,6 +727,7 @@ png]]></defaultvalue>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
                        </option>
                </options>
        </import>
index fd52b8a2884be8a5201c0201e08bc004e4856201..a57e8322ed89c190a25b38f4d7264427a415e2d9 100755 (executable)
@@ -59,7 +59,17 @@ class UserGroupEditForm extends UserGroupAddForm {
                }
                
                $this->group = new UserGroupEditor($group);
+               
                $this->optionHandler->setUserGroup($group);
+               $this->optionHandler->init();
+       }
+       
+       /**
+        * @see \wcf\acp\form\AbstractOptionListForm::initOptionHandler()
+        */
+       protected function initOptionHandler() {
+               // does nothing, we call OptionHandler::init() after we set the
+               // user group
        }
        
        /**
index 898bd96ab0f9804058104bffe315103139e9c390..f980054a1c325eeb058678e6c7706ad54c34fc1a 100644 (file)
@@ -116,6 +116,12 @@ class UserGroupOptionForm extends AbstractForm {
                
                // 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();
                }
index 4afbdb18bd0ed1f0d012d59613eb62c8a15107c6..1e7aee3f0ec9e316a3fc321b0805e6ba7c6f32a0 100644 (file)
@@ -21,4 +21,22 @@ class UserGroupOptionCacheBuilder extends OptionCacheBuilder {
         * @see \wcf\system\cache\builder\OptionCacheBuilder::$tableName
         */
        protected $tableName = 'user_group_option';
+       
+       /**
+        * @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
+        */
+       public function rebuild(array $parameters) {
+               $data = parent::rebuild($parameters);
+               
+               $usersOnlyPermissions = array();
+               foreach ($data['options'] as $option) {
+                       if ($option->usersOnly) {
+                               $usersOnlyPermissions[] = $option->optionName;
+                       }
+               }
+               
+               $data['usersOnlyOptions'] = $usersOnlyPermissions;
+               
+               return $data;
+       }
 }
index dcfe454a63dbeb4da14d0f544c4846d8724067ce..4b2f34505cb6fa303221f2a174edd8ef4e24f868 100644 (file)
@@ -45,6 +45,22 @@ class UserGroupOptionHandler extends OptionHandler {
                $this->group = $group;
        }
        
+       /**
+        * @see \wcf\system\option\OptionHandler::checkOption()
+        */
+       protected function checkOption(Option $option) {
+               if (parent::checkOption($option)) {
+                       // check if permission is available for guests if group is guests
+                       if ($this->group && $this->group->groupType == UserGroup::GUESTS && $option->usersOnly) {
+                               return false;
+                       }
+                       
+                       return true;
+               }
+               
+               return false;
+       }
+       
        /**
         * @see \wcf\system\option\OptionHandler::getClassName()
         */
index 87385de3d94d5e786bc224d801aa917e6bf549e6..cc3006d9fbe7997d5f01a7e647b1bb4962cfe9c8 100644 (file)
@@ -39,6 +39,7 @@ class UserGroupOptionPackageInstallationPlugin extends AbstractOptionPackageInst
        protected function saveOption($option, $categoryName, $existingOptionID = 0) {
                // default values
                $optionName = $optionType = $defaultValue = $adminDefaultValue = $modDefaultValue = $userDefaultValue = $validationPattern = $enableOptions = $permissions = $options = '';
+               $usersOnly = 0;
                $showOrder = null;
                
                // get values
@@ -54,6 +55,7 @@ class UserGroupOptionPackageInstallationPlugin extends AbstractOptionPackageInst
                if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
                if (isset($option['permissions'])) $permissions = $option['permissions'];
                if (isset($option['options'])) $options = $option['options'];
+               if (isset($option['usersonly'])) $usersOnly = $option['usersonly'];
                
                // collect additional tags and their values
                $additionalData = array();
@@ -82,6 +84,7 @@ class UserGroupOptionPackageInstallationPlugin extends AbstractOptionPackageInst
                        'enableOptions' => $enableOptions,
                        'permissions' => $permissions,
                        'options' => $options,
+                       'usersOnly' => $usersOnly,
                        'additionalData' => serialize($additionalData)
                );
                
index 828f0370f33da5e8b943b713a8ee53132338d5c0..aac5fdc4237bac721ac39b0c72c67db72973a08b 100644 (file)
@@ -7,6 +7,7 @@ use wcf\data\user\User;
 use wcf\data\user\UserEditor;
 use wcf\page\ITrackablePage;
 use wcf\system\cache\builder\SpiderCacheBuilder;
+use wcf\system\cache\builder\UserGroupOptionCacheBuilder;
 use wcf\system\cache\builder\UserGroupPermissionCacheBuilder;
 use wcf\system\database\DatabaseException;
 use wcf\system\exception\PermissionDeniedException;
@@ -127,6 +128,12 @@ class SessionHandler extends SingletonFactory {
         */
        protected $firstVisit = false;
        
+       /**
+        * list of names of permissions only available for users
+        * @var array<string>
+        */
+       protected $usersOnlyPermissions = array();
+       
        /**
         * Provides access to session data.
         * 
@@ -141,6 +148,13 @@ class SessionHandler extends SingletonFactory {
                return $this->session->{$key};
        }
        
+       /**
+        * @see \wcf\system\SingletonFactory::init()
+        */
+       protected function init() {
+               $this->usersOnlyPermissions = UserGroupOptionCacheBuilder::getInstance()->getData(array(), 'usersOnlyOptions');
+       }
+       
        /**
         * Loads an existing session or creates a new one.
         * 
@@ -462,6 +476,12 @@ class SessionHandler extends SingletonFactory {
         * @return      mixed           permission value
         */
        public function getPermission($permission) {
+               // check if a users only permission is checked for a guest and return
+               // false if that is the case
+               if (!$this->user->userID && in_array($permission, $this->usersOnlyPermissions)) {
+                       return false;
+               }
+               
                $this->loadGroupData();
                
                if (!isset($this->groupData[$permission])) return false;
index 681158ccc1efe6b15465c8c8de029983df3b83bb..ddde915215ab53f7b553791eefb3696d5b4b7e20 100644 (file)
@@ -1157,6 +1157,7 @@ CREATE TABLE wcf1_user_group_option (
        showOrder INT(10) NOT NULL DEFAULT 0,
        permissions TEXT,
        options TEXT,
+       usersOnly TINYINT(1) NOT NULL DEFAULT 0,
        additionalData MEDIUMTEXT,
        UNIQUE KEY optionName (optionName, packageID)
 );
@@ -1645,9 +1646,9 @@ INSERT INTO wcf1_user_group (groupID, groupName, groupType) VALUES (4, 'wcf.acp.
 INSERT INTO wcf1_user_group (groupID, groupName, groupType) VALUES (5, 'wcf.acp.group.group5', 4); -- Moderators
 
 -- default user group options
-INSERT INTO wcf1_user_group_option (optionID, optionName, categoryName, optionType, defaultValue, showOrder) VALUES (1, 'admin.general.canUseAcp', 'admin.general', 'boolean', '0', 1);
-INSERT INTO wcf1_user_group_option (optionID, optionName, categoryName, optionType, defaultValue, showOrder) VALUES (2, 'admin.system.package.canInstallPackage', 'admin.system.package', 'boolean', '0', 1);
-INSERT INTO wcf1_user_group_option (optionID, optionName, categoryName, optionType, defaultValue, showOrder) VALUES (3, 'admin.user.canEditGroup', 'admin.user.group', 'boolean', '0', 1);
+INSERT INTO wcf1_user_group_option (optionID, optionName, categoryName, optionType, defaultValue, showOrder, usersOnly) VALUES (1, 'admin.general.canUseAcp', 'admin.general', 'boolean', '0', 1, 1);
+INSERT INTO wcf1_user_group_option (optionID, optionName, categoryName, optionType, defaultValue, showOrder, usersOnly) VALUES (2, 'admin.system.package.canInstallPackage', 'admin.system.package', 'boolean', '0', 1, 1);
+INSERT INTO wcf1_user_group_option (optionID, optionName, categoryName, optionType, defaultValue, showOrder, usersOnly) VALUES (3, 'admin.user.canEditGroup', 'admin.user.group', 'boolean', '0', 1, 1);
 
 -- default user group option values
 INSERT INTO wcf1_user_group_option_value (groupID, optionID, optionValue) VALUES (1, 1, '0');  -- Everyone