Fixed default value for accessibleGroups
authorAlexander Ebert <ebert@woltlab.com>
Wed, 18 Feb 2015 10:56:22 +0000 (11:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 18 Feb 2015 11:15:34 +0000 (12:15 +0100)
com.woltlab.wcf/package.xml
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/acp/update_accessibleGroups_com.woltlab.wcf_2.1.0_rc_2.php [new file with mode: 0644]
wcfsetup/install/files/acp/update_com.woltlab.wcf_2.1.0_rc_1.php [deleted file]
wcfsetup/install/files/lib/system/WCF.class.php

index bbf32ad88167790e75a231fcb41bda90b46fc462..c4c11b0d64827a7b9e9dc07460634d127a51e2b4 100644 (file)
@@ -5,7 +5,7 @@
                <packagedescription><![CDATA[Free web-framework, designed and developed for complex community applications.]]></packagedescription>
                <packagedescription language="de"><![CDATA[Freies Web-Framework, das für komplexe Community-Anwendungen entworfen und entwickelt wurde.]]></packagedescription>
                <isapplication>1</isapplication>
-               <version>2.1.0 RC 1</version> <!-- codename: typhoon -->
+               <version>2.1.0 RC 2</version> <!-- codename: typhoon -->
                <date>2015-02-16</date>
        </packageinformation>
        
                <instruction type="script" run="standalone">acp/rebuild_comments_com.woltlab.wcf_2.1.php</instruction>
        </instructions>
        
-       <instructions type="update" fromversion="2.1.0 Beta 4">
-               <instruction type="option">option.xml</instruction>
+       <instructions type="update" fromversion="2.1.0 RC 1">
                <instruction type="file">files_update.tar</instruction>
-               <instruction type="script">acp/update_com.woltlab.wcf_2.1.0_rc_1.php</instruction>
-               
-               <instruction type="language" run="standalone">language/*.xml</instruction>
-               
-               <instruction type="acpTemplate">acptemplates_update.tar</instruction>
-               <instruction type="template">templates_update.tar</instruction>
-               
-               <instruction type="sql">update_2.1.0_rc_1.sql</instruction>
-               
-               <instruction type="userGroupOption">userGroupOption.xml</instruction>
+               <instruction type="script">acp/update_accessibleGroups_com.woltlab.wcf_2.1.0_rc_2.php</instruction>
        </instructions>
 </package>
index 8e61456a0da9315cd57181369a190be5ea5aba15..e9914de0ea9bd6a4ab4509f1a00b83c8009248f8 100644 (file)
                                <categoryname>admin.user.group</categoryname>
                                <optiontype>userGroups</optiontype>
                                <defaultvalue></defaultvalue>
-                               <admindefaultvalue>1,2,3,4,5,6</admindefaultvalue>
+                               <admindefaultvalue>1,2,3,4,5</admindefaultvalue>
                                <usersonly>1</usersonly>
                        </option>
                        <option name="admin.user.canAddUser">
diff --git a/wcfsetup/install/files/acp/update_accessibleGroups_com.woltlab.wcf_2.1.0_rc_2.php b/wcfsetup/install/files/acp/update_accessibleGroups_com.woltlab.wcf_2.1.0_rc_2.php
new file mode 100644 (file)
index 0000000..06214f7
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+use wcf\system\WCF;
+
+/**
+ * @author     Alexander Ebert
+ * @copyright  2001-2015 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+
+// fix superfluous group ID in accessibleGroups list
+$sql = "SELECT groupID
+       FROM    wcf".WCF_N."_user_group";
+$statement = WCF::getDB()->prepareStatement($sql);
+$statement->execute();
+$validGroupIDs = array();
+while ($row = $statement->fetchArray()) {
+       $validGroupIDs[] = $row['groupID'];
+}
+
+$sql = "SELECT *
+       FROM    wcf".WCF_N."_user_group_option_value
+       WHERE   optionID = (
+                       SELECT  optionID
+                       FROM    wcf".WCF_N."_user_group_option
+                       WHERE   optionName = 'admin.user.accessibleGroups'
+               )";
+$statement = WCF::getDB()->prepareStatement($sql);
+$statement->execute();
+$updateData = array();
+$optionID = 0;
+while ($row = $statement->fetchArray()) {
+       $optionID = $row['optionID'];
+       $groupIDs = explode(',', $row['optionValue']);
+       $newGroupIDs = array();
+       for ($i = 0, $length = count($groupIDs); $i < $length; $i++) {
+               $groupID = $groupIDs[$i];
+               if (in_array($groupID, $validGroupIDs)) {
+                       $newGroupIDs[] = $groupID;
+               }
+       }
+       
+       $updateData[$row['groupID']] = implode(',', $newGroupIDs);
+}
+
+$sql = "UPDATE wcf".WCF_N."_user_group_option_value
+       SET     optionValue = ?
+       WHERE   groupID = ?
+               AND optionID = ?";
+$statement = WCF::getDB()->prepareStatement($sql);
+
+WCF::getDB()->beginTransaction();
+foreach ($updateData as $groupID => $optionValue) {
+       $statement->execute(array(
+               $optionValue,
+               $groupID,
+               $optionID
+       ));
+}
+WCF::getDB()->commitTransaction();
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.1.0_rc_1.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.1.0_rc_1.php
deleted file mode 100644 (file)
index 737910a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-use wcf\data\option\OptionEditor;
-
-/**
- * @author     Alexander Ebert
- * @copyright  2001-2015 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @category   Community Framework
- */
-
-// rebuild options during update to properly handle new option
-OptionEditor::resetCache();
index 6bd98e09b039970c9f2f87279140ac4337cb3867..46501e4e2630be14de925d3081ca6f34023aca7f 100644 (file)
@@ -38,7 +38,7 @@ if (!@ini_get('date.timezone')) {
 }
 
 // define current wcf version
-define('WCF_VERSION', '2.1.0 RC 1 (Typhoon)');
+define('WCF_VERSION', '2.1.0 RC 2 (Typhoon)');
 
 // define current unix timestamp
 define('TIME_NOW', time());