* @category Community Framework
*/
class UserGroupOptionPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
+ /**
+ * group id of group 'Everyone'
+ * @var integer
+ */
+ protected $everyoneGroupID = null;
+
/**
* @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
*/
$groupOptionEditor = UserGroupOptionEditor::create($data);
$optionID = $groupOptionEditor->optionID;
- // get default group ("everyone")
- $sql = "SELECT groupID
- FROM wcf".WCF_N."_user_group
- WHERE groupType = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(UserGroup::EVERYONE));
- $row = $statement->fetchArray();
-
// save default value
$sql = "INSERT INTO wcf".WCF_N."_user_group_option_value
(groupID, optionID, optionValue)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($row['groupID'], $optionID, $defaultValue));
+ $statement->execute(array(
+ $this->getEveryoneGroupID(),
+ $optionID,
+ $defaultValue
+ ));
if ($adminDefaultValue && $defaultValue != $adminDefaultValue) {
$adminGroupIDs = self::getAdminGroupIDs();
}
}
+ /**
+ * Returns group id of 'Everyone' group.
+ *
+ * @return integer
+ */
+ protected function getEveryoneGroupID() {
+ if ($this->everyoneGroupID === null) {
+ $sql = "SELECT groupID
+ FROM wcf".WCF_N."_user_group
+ WHERE groupType = ?";
+ $statement = WCF::getDB()->prepareStatement($sql, 1);
+ $statement->execute(array(UserGroup::EVERYONE));
+ $row = $statement->fetchArray();
+
+ $this->everyoneGroupID = $row['groupID'];
+ }
+
+ return $this->everyoneGroupID;
+ }
+
/**
* Returns an array of ids of admin groups.
*