namespace wcf\system\package\plugin;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Abstract implementation of a package installation plugin for menu items.
'menuItem' => $data['attributes']['name'],
'menuItemController' => isset($data['elements']['controller']) ? $data['elements']['controller'] : '',
'menuItemLink' => isset($data['elements']['link']) ? $data['elements']['link'] : '',
- 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
+ 'options' => isset($data['elements']['options']) ? StringUtil::normalizeCsv($data['elements']['options']) : '',
'parentMenuItem' => isset($data['elements']['parent']) ? $data['elements']['parent'] : '',
- 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '',
+ 'permissions' => isset($data['elements']['permissions']) ? StringUtil::normalizeCsv($data['elements']['permissions']) : '',
'showOrder' => $showOrder
];
}
use wcf\data\package\Package;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Abstract implementation of a package installation plugin for options.
// build data block with defaults
$data = [
'categoryName' => $element->getAttribute('name'),
- 'options' => isset($data['options']) ? $data['options'] : '',
+ 'options' => isset($data['options']) ? StringUtil::normalizeCsv($data['options']) : '',
'parentCategoryName' => isset($data['parent']) ? $data['parent'] : '',
- 'permissions' => isset($data['permissions']) ? $data['permissions'] : '',
+ 'permissions' => isset($data['permissions']) ? StringUtil::normalizeCsv($data['permissions']) : '',
'showOrder' => isset($data['showorder']) ? intval($data['showorder']) : null
];
use wcf\data\cronjob\CronjobEditor;
use wcf\system\WCF;
use wcf\util\CronjobUtil;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes cronjobs.
'cronjobName' => isset($data['attributes']['name']) ? $data['attributes']['name'] : '',
'description' => isset($data['elements']['description']) ? $data['elements']['description'] : '',
'isDisabled' => isset($data['elements']['isdisabled']) ? intval($data['elements']['isdisabled']) : 0,
- 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
+ 'options' => isset($data['elements']['options']) ? StringUtil::normalizeCsv($data['elements']['options']) : '',
'startDom' => $data['elements']['startdom'],
'startDow' => $data['elements']['startdow'],
'startHour' => $data['elements']['starthour'],
use wcf\data\event\listener\EventListenerEditor;
use wcf\system\cache\builder\EventListenerCacheBuilder;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes event listeners.
return [
'environment' => isset($data['elements']['environment']) ? $data['elements']['environment'] : 'user',
'eventClassName' => $data['elements']['eventclassname'],
- 'eventName' => $data['elements']['eventname'],
+ 'eventName' => StringUtil::normalizeCsv($data['elements']['eventname']),
'inherit' => isset($data['elements']['inherit']) ? intval($data['elements']['inherit']) : 0,
'listenerClassName' => $data['elements']['listenerclassname'],
'listenerName' => isset($data['attributes']['name']) ? $data['attributes']['name'] : '',
'niceValue' => $nice,
- 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
- 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''
+ 'options' => isset($data['elements']['options']) ? StringUtil::normalizeCsv($data['elements']['options']) : '',
+ 'permissions' => isset($data['elements']['permissions']) ? StringUtil::normalizeCsv($data['elements']['permissions']) : ''
];
}
use wcf\data\package\Package;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes options.
if (isset($option['optiontype'])) $optionType = $option['optiontype'];
if (isset($option['defaultvalue'])) $defaultValue = WCF::getLanguage()->get($option['defaultvalue']);
if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
- if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
+ if (isset($option['enableoptions'])) $enableOptions = StringUtil::normalizeCsv($option['enableoptions']);
if (isset($option['showorder'])) $showOrder = intval($option['showorder']);
if (isset($option['hidden'])) $hidden = intval($option['hidden']);
$showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
if (isset($option['selectoptions'])) $selectOptions = $option['selectoptions'];
- if (isset($option['permissions'])) $permissions = $option['permissions'];
- if (isset($option['options'])) $options = $option['options'];
+ if (isset($option['permissions'])) $permissions = StringUtil::normalizeCsv($option['permissions']);
+ if (isset($option['options'])) $options = StringUtil::normalizeCsv($option['options']);
if (isset($option['supporti18n'])) $supportI18n = $option['supporti18n'];
if (isset($option['requirei18n'])) $requireI18n = $option['requirei18n'];
use wcf\data\template\listener\TemplateListenerEditor;
use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes template listeners.
'eventName' => $data['elements']['eventname'],
'niceValue' => $niceValue,
'name' => $data['attributes']['name'],
- 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
- 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '',
+ 'options' => isset($data['elements']['options']) ? StringUtil::normalizeCsv($data['elements']['options']) : '',
+ 'permissions' => isset($data['elements']['permissions']) ? StringUtil::normalizeCsv($data['elements']['permissions']) : '',
'templateCode' => $data['elements']['templatecode'],
'templateName' => $data['elements']['templatename']
];
use wcf\data\user\group\option\UserGroupOptionEditor;
use wcf\data\user\group\UserGroup;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes user group options.
if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
if (!empty($option['showorder'])) $showOrder = intval($option['showorder']);
$showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
- if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
- if (isset($option['permissions'])) $permissions = $option['permissions'];
- if (isset($option['options'])) $options = $option['options'];
+ if (isset($option['enableoptions'])) $enableOptions = StringUtil::normalizeCsv($option['enableoptions']);
+ if (isset($option['permissions'])) $permissions = StringUtil::normalizeCsv($option['permissions']);
+ if (isset($option['options'])) $options = StringUtil::normalizeCsv($option['options']);
if (isset($option['usersonly'])) $usersOnly = $option['usersonly'];
// collect additional tags and their values
use wcf\data\user\notification\event\UserNotificationEventEditor;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes user notification events.
'eventName' => $data['elements']['name'],
'className' => $data['elements']['classname'],
'objectTypeID' => $this->getObjectTypeID($data['elements']['objecttype']),
- 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '',
- 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
+ 'permissions' => isset($data['elements']['permissions']) ? StringUtil::normalizeCsv($data['elements']['permissions']) : '',
+ 'options' => isset($data['elements']['options']) ? StringUtil::normalizeCsv($data['elements']['options']) : '',
'preset' => !empty($data['elements']['preset']) ? 1 : 0,
'presetMailNotificationType' => $presetMailNotificationType
];
use wcf\data\user\option\UserOptionEditor;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes user options.
if (isset($option['showorder'])) $showOrder = intval($option['showorder']);
if (isset($option['outputclass'])) $outputClass = $option['outputclass'];
if (isset($option['selectoptions'])) $selectOptions = $option['selectoptions'];
- if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
+ if (isset($option['enableoptions'])) $enableOptions = StringUtil::normalizeCsv($option['enableoptions']);
if (isset($option['isdisabled'])) $isDisabled = intval($option['isdisabled']);
$showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
- if (isset($option['permissions'])) $permissions = $option['permissions'];
- if (isset($option['options'])) $options = $option['options'];
+ if (isset($option['permissions'])) $permissions = StringUtil::normalizeCsv($option['permissions']);
+ if (isset($option['options'])) $options = StringUtil::normalizeCsv($option['options']);
// collect additional tags and their values
$additionalData = [];
namespace wcf\system\package\plugin;
use wcf\data\user\profile\menu\item\UserProfileMenuItemEditor;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Installs, updates and deletes user profile menu items.
// merge values and default values
return [
'menuItem' => $data['attributes']['name'],
- 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
- 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '',
+ 'options' => isset($data['elements']['options']) ? StringUtil::normalizeCsv($data['elements']['options']) : '',
+ 'permissions' => isset($data['elements']['permissions']) ? StringUtil::normalizeCsv($data['elements']['permissions']) : '',
'showOrder' => $showOrder,
'className' => $data['elements']['classname']
];
return self::formatNumeric($number) . $unitPrefix;
}
+ /**
+ * Normalizes a string representing comma-separated values by making sure
+ * that the separator is just a comma, not a combination of whitespace and
+ * a comma.
+ *
+ * @param string $string
+ * @return string
+ * @since 3.1
+ */
+ public static function normalizeCsv($string) {
+ return implode(',', ArrayUtil::trim(explode(',', $string)));
+ }
+
/**
* Forbid creation of StringUtil objects.
*/