Verified Commit 1c203654 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(code) Switch to shorthand array syntax

issue #5925
parent 5d4d0936
......@@ -23,28 +23,28 @@
class aliasManagement extends management
{
/* Default columns */
public static $columns = array(
array('ObjectTypeColumn', array()),
array('LinkColumn', array('attributes' => 'nameAttr', 'label' => 'Name')),
array('LinkColumn', array('attributes' => 'description', 'label' => 'Description')),
array('UnixTimestampColumn', array('attributes' => 'aliasExpirationDate', 'label' => 'Expiration date')),
array('ActionsColumn', array('label' => 'Actions')),
);
public static $columns = [
['ObjectTypeColumn', []],
['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']],
['LinkColumn', ['attributes' => 'description', 'label' => 'Description']],
['UnixTimestampColumn', ['attributes' => 'aliasExpirationDate', 'label' => 'Expiration date']],
['ActionsColumn', ['label' => 'Actions']],
];
public static function plInfo (): array
{
return array(
return [
'plShortName' => _('Aliases'),
'plTitle' => _('Alias management'),
'plDescription' => _('Manage aliases'),
'plIcon' => 'geticon.php?context=applications&icon=alias&size=48',
'plSection' => 'accounts',
'plPriority' => 26,
'plCategory' => array('alias' => array('description' => _('Mail aliases'),
'objectClass' => array('mailAliasRedirection','mailAliasDistribution'))),
'plManages' => array('mailAliasDistribution','mailAliasRedirection'),
'plCategory' => ['alias' => ['description' => _('Mail aliases'),
'objectClass' => ['mailAliasRedirection','mailAliasDistribution']]],
'plManages' => ['mailAliasDistribution','mailAliasRedirection'],
'plProvidedAcls' => array()
);
'plProvidedAcls' => []
];
}
}
......@@ -22,28 +22,28 @@ class mailAliasDistribution extends simplePlugin
{
public static function plInfo (): array
{
return array(
return [
'plShortName' => _('Temporary mail distribution'),
'plDescription' => _('Temporary mail distribution'),
'plObjectClass' => array('mailAliasDistribution'),
'plObjectType' => array('mailAliasDistribution' => array(
'plObjectClass' => ['mailAliasDistribution'],
'plObjectType' => ['mailAliasDistribution' => [
'name' => _('Temporary mail distribution'),
'aclCategory' => 'alias',
'icon' => 'geticon.php?context=applications&icon=alias-distribution&size=16',
'ou' => get_ou('aliasRDN'),
)),
]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
// The main function : information about attributes
static function getAttributesInfo (): array
{
return array(
'main' => array(
return [
'main' => [
'name' => _('Mail distribution'),
'attrs' => array(
'attrs' => [
new BaseSelectorAttribute(get_ou('aliasRDN')),
new HostNameAttribute(_('Name'), _('Name to identify this alias'), 'cn', TRUE),
new TextAreaAttribute(
......@@ -72,8 +72,8 @@ class mailAliasDistribution extends simplePlugin
'U',
''
)
)
),
);
]
],
];
}
}
......@@ -22,29 +22,29 @@ class mailAliasRedirection extends simplePlugin
{
public static function plInfo (): array
{
return array(
return [
'plShortName' => _('Temporary mail redirection'),
'plDescription' => _('Temporary mail redirection'),
'plObjectClass' => array('mailAliasRedirection'),
'plObjectType' => array('mailAliasRedirection' => array(
'plObjectClass' => ['mailAliasRedirection'],
'plObjectType' => ['mailAliasRedirection' => [
'name' => _('Temporary mail redirection'),
'aclCategory' => 'alias',
'icon' => 'geticon.php?context=applications&icon=alias-redirection&size=16',
'ou' => get_ou('aliasRDN'),
)),
]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
// The main function : information about attributes
static function getAttributesInfo (): array
{
return array(
return [
// Attributes are grouped by section
'main' => array(
'main' => [
'name' => _('Mail redirection'),
'attrs' => array(
'attrs' => [
new BaseSelectorAttribute(get_ou('aliasRDN')),
new HostNameAttribute(_('Name'), _('Name to identify this redirection'), 'cn', TRUE),
new TextAreaAttribute(
......@@ -70,8 +70,8 @@ class mailAliasRedirection extends simplePlugin
'U',
''
)
)
),
);
]
],
];
}
}
......@@ -22,30 +22,30 @@ class aliasConfig extends simplePlugin
{
static function plInfo (): array
{
return array(
return [
'plShortName' => _('Alias configuration'),
'plDescription' => _('FusionDirectory alias plugin configuration'),
'plObjectClass' => array('fdAliasPluginConf'),
'plCategory' => array('configuration'),
'plObjectType' => array('smallConfig'),
'plObjectClass' => ['fdAliasPluginConf'],
'plCategory' => ['configuration'],
'plObjectType' => ['smallConfig'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
static function getAttributesInfo (): array
{
return array(
'main' => array(
return [
'main' => [
'name' => _('Alias'),
'attrs' => array(
'attrs' => [
new StringAttribute(
_('Alias RDN'), _('Branch in which aliases will be stored'),
'fdAliasRDN', TRUE,
'ou=alias'
),
)
),
);
]
],
];
}
}
......@@ -23,26 +23,26 @@ class application extends simplePlugin
{
static function plInfo (): array
{
return array(
return [
'plShortName' => _('Application'),
'plDescription' => _('Application information'),
'plObjectClass' => array('fdDesktopApplication'),
'plObjectType' => array('application' => array(
'plObjectClass' => ['fdDesktopApplication'],
'plObjectType' => ['application' => [
'name' => _('Application'),
'ou' => get_ou('applicationsRDN'),
'icon' => 'geticon.php?context=mimetypes&icon=application-x-executable&size=16',
)),
]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
static function getAttributesInfo (): array
{
return array(
'main' => array(
return [
'main' => [
'name' => _('Application'),
'attrs' => array(
'attrs' => [
new BaseSelectorAttribute(get_ou('applicationsRDN')),
new HostNameAttribute(
_('Application name'), _('The name of this application'),
......@@ -60,21 +60,21 @@ class application extends simplePlugin
_('Display name'), _('The displayed name for this application'),
'fdApplicationTitle', FALSE
),
)
),
'icon' => array(
]
],
'icon' => [
'name' => _('Icon'),
'attrs' => array(
'attrs' => [
new ImageAttribute(
'', _('The icon for this application'),
'fdApplicationImage', FALSE,
48, 48, 'png'
),
)
),
'options' => array(
]
],
'options' => [
'name' => _('Options'),
'attrs' => array(
'attrs' => [
new BooleanAttribute(
_('Only executable for member'), _('Only executable by the memebers of the group'),
'flag_group', FALSE, FALSE, '',
......@@ -102,11 +102,11 @@ class application extends simplePlugin
),
new FlagsAttribute(
'fdApplicationFlags',
array('flag_group','flag_overwrite','flag_desktop','flag_menu','flag_launchbar')
['flag_group','flag_overwrite','flag_desktop','flag_menu','flag_launchbar']
),
)
),
);
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
......
......@@ -23,17 +23,17 @@ class applicationManagement extends management
{
static function plInfo (): array
{
return array(
return [
'plShortName' => _('Applications'),
'plTitle' => _('Applications management'),
'plDescription' => _('Manage applications and web applications'),
'plIcon' => 'geticon.php?context=categories&icon=applications-other&size=48',
'plSection' => 'accounts',
'plPriority' => 60,
'plManages' => array('application', 'webApplication'),
'plManages' => ['application', 'webApplication'],
'plMenuProvider' => TRUE,
);
];
}
static function getMenuEntries (): array
......@@ -41,28 +41,28 @@ class applicationManagement extends management
global $config, $ui;
$mode = $config->get_cfg_value('WebappsMenu', 'none');
if ($mode == 'none') {
return array(array(), array());
return [[], []];
}
$ldap = $config->get_ldap_link();
if ($mode == 'all') {
/* using raw to have the same results than with allowed mode */
$apps = objects::ls(
'webApplication',
array(
[
'cn' => 'raw',
'description' => 'raw',
'labeledURI' => 'raw',
'fdApplicationTitle' => 'raw',
'fdApplicationImageLocation' => 'raw',
'fdApplicationImage' => 'raw',
)
]
);
} else { /* allowed */
$apps = array();
$apps = [];
if (is_object($ui) && isset($ui->dn)) {
$roles = objects::ls(
'role',
array('fdApplicationAllowed' => '*'),
['fdApplicationAllowed' => '*'],
NULL,
'(&(objectClass=fdApplicationRights)(roleOccupant='.$ui->dn.'))'
);
......@@ -82,25 +82,25 @@ class applicationManagement extends management
}
}
ksort($apps);
$sections = array(
'webapps' => array('name' => _('Web applications'), 'priority' => 100)
);
$entries = array(
'webapps' => array()
);
$sections = [
'webapps' => ['name' => _('Web applications'), 'priority' => 100]
];
$entries = [
'webapps' => []
];
foreach ($apps as $dn => $app) {
$base = preg_replace('/^[^,]+,'.preg_quote(get_ou('webappsRDN'), '/').'/', '', $dn);
$section = 'webapps';
if ($base != $config->current['BASE']) {
$ldap->cat($base, array('dn', 'ou', 'description'), '(&(ou=*)(description=*))');
$ldap->cat($base, ['dn', 'ou', 'description'], '(&(ou=*)(description=*))');
if ($attrs = $ldap->fetch()) {
$section = $attrs['ou'][0];
if (!isset($sections[$section])) {
$sections[$section] = array(
$sections[$section] = [
'name' => $attrs['description'][0],
'priority' => 101
);
$entries[$section] = array();
];
$entries[$section] = [];
}
}
}
......@@ -115,17 +115,17 @@ class applicationManagement extends management
}
$name = $app['cn'][0];
$title = (isset($app['fdApplicationTitle'][0]) ? $app['fdApplicationTitle'][0] : $name);
$entries[$section][] = array(
$entries[$section][] = [
'NAME' => $name,
'TITLE' => $title,
'DESCRIPTION' => (isset($app['description'][0]) ? $app['description'][0] : $title),
'LINK' => $app['labeledURI'][0],
'ICONPATH' => $path,
);
];
}
return array(
return [
$sections,
$entries
);
];
}
}
......@@ -22,26 +22,26 @@ class webApplication extends simplePlugin
{
public static function plInfo (): array
{
return array(
return [
'plShortName' => _('Web application'),
'plDescription' => _('Web applicationts names, icons and links'),
'plObjectClass' => array('fdWebApplication'),
'plObjectType' => array('webApplication' => array(
'plObjectClass' => ['fdWebApplication'],
'plObjectType' => ['webApplication' => [
'name' => _('Web application'),
'ou' => get_ou('webappsRDN'),
'icon' => 'geticon.php?context=categories&icon=applications-internet&size=16'
)),
]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
static function getAttributesInfo (): array
{
return array(
'main' => array(
return [
'main' => [
'name' => _('Application'),
'attrs' => array(
'attrs' => [
new BaseSelectorAttribute(get_ou('webappsRDN')),
new HostNameAttribute(
_('Name'), _('Name or id for application'),
......@@ -59,11 +59,11 @@ class webApplication extends simplePlugin
_('Display Name'), _('Displayed name for links to this application'),
'fdApplicationTitle', TRUE
),
)
),
'icon' => array(
]
],
'icon' => [
'name' => _('Icon'),
'attrs' => array(
'attrs' => [
new ImageAttribute(
'', _('The icon for this application'),
'fdApplicationImage', FALSE,
......@@ -73,8 +73,8 @@ class webApplication extends simplePlugin
_('Icon location'), _('Usual path to this application icon'),
'fdApplicationImageLocation', FALSE
),
)
),
);
]
],
];
}
}
......@@ -24,35 +24,35 @@ class applicationRights extends simplePlugin
static function plInfo (): array
{
return array(
return [
'plShortName' => _('Applications'),
'plDescription' => _('Applications allowed for this role'),
'plSmallIcon' => 'geticon.php?context=mimetypes&icon=application-x-executable&size=16',
'plObjectClass' => array('fdApplicationRights'),
'plObjectType' => array('role'),
'plForeignKeys' => array(
'plObjectClass' => ['fdApplicationRights'],
'plObjectType' => ['role'],
'plForeignKeys' => [
'fdApplicationAllowed' => 'webApplication',
),
],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
static function getAttributesInfo (): array
{
return array(
'main' => array(
return [
'main' => [
'name' => _('Application list'),
'attrs' => array(
'attrs' => [
new SetAttribute(
new SelectAttribute(
_('Applications'), _('The applications users with this role are allowed to launch'),
'fdApplicationAllowed', TRUE
)
)
)
),
);
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
......
......@@ -22,23 +22,23 @@ class applicationsPluginConfig extends simplePlugin
{
static function plInfo (): array
{
return array(
return [
'plShortName' => _('Applications'),
'plDescription' => _('Applications plugin configuration'),
'plObjectClass' => array('fdApplicationsPluginConf'),
'plCategory' => array('configuration'),
'plObjectType' => array('smallConfig'),
'plObjectClass' => ['fdApplicationsPluginConf'],
'plCategory' => ['configuration'],
'plObjectType' => ['smallConfig'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
static function getAttributesInfo (): array
{
return array(
'rdns' => array(
return [
'rdns' => [
'name' => _('Applications'),
'attrs' => array(
'attrs' => [
new StringAttribute(
_('Application RDN'), _('Branch in which applications will be stored'),
'fdApplicationsRDN', TRUE,
......@@ -52,11 +52,11 @@ class applicationsPluginConfig extends simplePlugin
new SelectAttribute(
_('Show web applications in menu'), _('Whether to show web applications in FD main menu'),
'fdWebappsMenu', TRUE,
array('none', 'allowed', 'all'), 'none',
array(_('None'), _('Only allowed'), _('All'))
['none', 'allowed', 'all'], 'none',
[_('None'), _('Only allowed'), _('All')]
),
)
)
);
]
]
];
}
}
......@@ -22,7 +22,7 @@ class MacsAttribute extends GenericDialogAttribute
{
protected $dialogClass = 'SystemSelectDialog';
function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $display_attr = 'cn', $acl = '')
function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $display_attr = 'cn', $acl = '')
{
parent::__construct($label, $description, $ldapName, $required, $defaultValue, 'macAddress', $display_attr, $acl);
}
......@@ -32,26 +32,26 @@ class argonautAction extends simplePlugin
{
static function plInfo (): array
{
return array(
return [
'plShortName' => _('Argonaut task'),
'plDescription' => _('Schedule an argonaut task'),
'plObjectType' => array('argonautTask' => array(
'plObjectType' => ['argonautTask' => [
'name' => _('Argonaut task'),
'aclCategory' => 'argonautQueue',
'icon' => 'geticon.php?context=applications&icon=argonaut&size=16',
)),
]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
];
}
static function getAttributesInfo (): array
{
$events = argonautEventTypes::get_event_types();
return array(
'main' => array(
return [
'main' => [
'name' => _('Schedule'),
'attrs' => array(
'attrs' => [
new SelectAttribute(
_('Action'), _('The action you are about to schedule'),
'action', TRUE,
......@@ -79,7 +79,7 @@ class argonautAction extends simplePlugin
),
new CompositeAttribute(
_('How often this task should be repeated'), 'period',
array(
[
new IntAttribute(
'', '',
'periodValue', FALSE,
......@@ -88,27 +88,27 @@ class argonautAction extends simplePlugin