From 46b03343f23f09147dcf21c640321df690389fa5 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <dockx.thibault@gmail.com> Date: Tue, 12 Jul 2022 19:21:12 +0100 Subject: [PATCH] :ambulance: Fix(1.3-fixes) - Codestyle Fixing codestyle --- contrib/smarty/plugins/block.render.php | 8 +- contrib/smarty/plugins/function.msgPool.php | 4 +- html/autocomplete.php | 4 +- html/class_passwordRecovery.inc | 28 +- html/getbin.php | 4 +- html/geticon.php | 4 +- html/index.php | 30 +- html/main.php | 16 +- html/progress.php | 2 +- html/setup.php | 2 +- include/accept-to-gettext.inc | 8 +- include/class_Combinations.inc | 2 +- include/class_CopyPasteHandler.inc | 30 +- include/class_IconTheme.inc | 320 +++++++++--------- include/class_Language.inc | 12 +- include/class_SnapshotDialogs.inc | 72 ++-- include/class_SnapshotHandler.inc | 52 +-- include/class_acl.inc | 40 +-- include/class_baseSelector.inc | 2 +- include/class_config.inc | 134 ++++---- include/class_divSelectBox.inc | 2 +- include/class_filter.inc | 44 +-- include/class_filterLDAP.inc | 10 +- include/class_ldap.inc | 112 +++--- include/class_ldapFilter.inc | 20 +- include/class_ldapMultiplexer.inc | 4 +- include/class_listing.inc | 112 +++--- include/class_logging.inc | 14 +- include/class_msgPool.inc | 14 +- include/class_msg_dialog.inc | 8 +- include/class_objects.inc | 44 +-- include/class_pluglist.inc | 56 +-- include/class_template.inc | 32 +- include/class_templateHandling.inc | 92 ++--- include/class_tests.inc | 4 +- include/class_timezone.inc | 4 +- include/class_userinfo.inc | 82 ++--- include/class_xml.inc | 16 +- include/exporter/class_cvsExporter.inc | 4 +- include/exporter/class_pdfExporter.inc | 6 +- include/functions.inc | 128 +++---- include/functions_debug.inc | 4 +- .../class_password-methods-crypt.inc | 2 +- .../class_password-methods-sasl.inc | 2 +- .../class_password-methods.inc | 8 +- include/php_setup.inc | 28 +- include/select/class_filterLDAPBlacklist.inc | 2 +- .../select/groupSelect/class_groupSelect.inc | 2 +- .../objectSelect/class_objectSelect.inc | 6 +- .../systemSelect/class_systemSelect.inc | 6 +- .../userGroupSelect/class_userGroupSelect.inc | 8 +- .../select/userSelect/class_userSelect.inc | 12 +- .../class_BaseSelectorAttribute.inc | 4 +- .../attributes/class_BooleanAttribute.inc | 4 +- .../attributes/class_CompositeAttribute.inc | 6 +- .../attributes/class_DateAttribute.inc | 16 +- .../attributes/class_FileAttribute.inc | 22 +- .../attributes/class_IntAttribute.inc | 8 +- .../attributes/class_PhoneNumberAttribute.inc | 20 +- .../attributes/class_SelectAttribute.inc | 6 +- .../attributes/class_SetAttribute.inc | 74 ++-- .../attributes/class_StringAttribute.inc | 10 +- include/simpleplugin/class_Attribute.inc | 42 +-- .../simpleplugin/class_dialogAttributes.inc | 70 ++-- .../simpleplugin/class_helpersAttribute.inc | 26 +- include/simpleplugin/class_multiPlugin.inc | 12 +- .../simpleplugin/class_simpleManagement.inc | 112 +++--- include/simpleplugin/class_simplePlugin.inc | 212 ++++++------ include/simpleplugin/class_simpleService.inc | 2 +- include/simpleplugin/class_simpleTabs.inc | 24 +- plugins/addons/dashboard/class_dashBoard.inc | 34 +- .../dashboard/class_dashBoardPasswords.inc | 34 +- .../addons/dashboard/class_dashBoardUsers.inc | 102 +++--- plugins/admin/acl/class_aclAssignment.inc | 94 ++--- plugins/admin/acl/class_aclManagement.inc | 40 +-- .../admin/aclrole/class_aclEditionDialog.inc | 24 +- plugins/admin/aclrole/class_aclRole.inc | 36 +- .../admin/aclrole/class_aclRoleManagement.inc | 12 +- plugins/admin/departments/class_country.inc | 16 +- plugins/admin/departments/class_dcObject.inc | 18 +- .../admin/departments/class_department.inc | 48 +-- .../class_departmentManagement.inc | 12 +- plugins/admin/departments/class_domain.inc | 18 +- plugins/admin/departments/class_locality.inc | 18 +- .../admin/departments/class_organization.inc | 18 +- .../admin/groups/class_groupManagement.inc | 70 ++-- plugins/admin/groups/class_roleGeneric.inc | 54 +-- plugins/admin/groups/tabs_ogroups.inc | 24 +- plugins/admin/users/class_userManagement.inc | 34 +- plugins/config/class_configInLdap.inc | 240 ++++++------- plugins/config/class_dashBoardConfig.inc | 34 +- plugins/config/class_mainPluginsConfig.inc | 32 +- plugins/config/class_pluginsConfigInLdap.inc | 10 +- plugins/config/class_recoveryConfig.inc | 54 +-- .../generic/references/class_reference.inc | 46 +-- plugins/personal/generic/class_user.inc | 136 ++++---- plugins/personal/roles/class_userRoles.inc | 90 ++--- setup/class_setup.inc | 32 +- setup/class_setupStep.inc | 30 +- setup/class_setupStepChecks.inc | 74 ++-- setup/class_setupStepConfig.inc | 50 +-- setup/class_setupStepFinish.inc | 26 +- setup/class_setupStepLanguage.inc | 26 +- setup/class_setupStepLdap.inc | 46 +-- setup/class_setupStepMigrate.inc | 262 +++++++------- setup/class_setupStepWelcome.inc | 22 +- 106 files changed, 2124 insertions(+), 2124 deletions(-) diff --git a/contrib/smarty/plugins/block.render.php b/contrib/smarty/plugins/block.render.php index 0727cc211..90770bcb7 100644 --- a/contrib/smarty/plugins/block.render.php +++ b/contrib/smarty/plugins/block.render.php @@ -62,17 +62,17 @@ function smarty_block_render($params, $text, &$smarty) } /* Remove select options */ - $from = array( + $from = [ "#<option.*<\/option>#is", "/(<textarea.*>).*(<\/textarea>)/is", "/^(.*<input.*)checked(.*>.*)$/isD" - ); + ]; - $to = array( + $to = [ " ", "\\1\\2", "\\1 \\2" - ); + ]; $text = preg_replace($from, $to, $text); diff --git a/contrib/smarty/plugins/function.msgPool.php b/contrib/smarty/plugins/function.msgPool.php index c63fc95f4..ae72af0ca 100644 --- a/contrib/smarty/plugins/function.msgPool.php +++ b/contrib/smarty/plugins/function.msgPool.php @@ -21,14 +21,14 @@ function smarty_function_msgPool($params, &$smarty) { if (class_available('msgPool') && isset($params['type'])) { - $parameter = array(); + $parameter = []; foreach ($params as $para => $value) { if (!preg_match('/^type$/i', $para)) { $parameter[$para] = $value; } } if (is_callable('msgPool::'.$params['type'])) { - echo call_user_func_array(array('msgPool',$params['type']), $parameter); + echo call_user_func_array(['msgPool',$params['type']], $parameter); } else { trigger_error('Unknown msgPool function '.$params['type']); } diff --git a/html/autocomplete.php b/html/autocomplete.php index c8f5437b2..0b0bce54d 100644 --- a/html/autocomplete.php +++ b/html/autocomplete.php @@ -26,11 +26,11 @@ session_cache_limiter("private"); session::start(); -session::set('errorsAlreadyPosted', array()); +session::set('errorsAlreadyPosted', []); /* Logged in? Simple security check */ if (!session::is_set('ui')) { - logging::log('security', 'unknown', '', array(), 'Error: autocomplete.php called without session'); + logging::log('security', 'unknown', '', [], 'Error: autocomplete.php called without session'); header ('Location: index.php'); exit; } diff --git a/html/class_passwordRecovery.inc b/html/class_passwordRecovery.inc index 825525d38..e8a91ee66 100644 --- a/html/class_passwordRecovery.inc +++ b/html/class_passwordRecovery.inc @@ -59,7 +59,7 @@ class standAlonePage { $smarty = get_smarty(); /* Generate server list */ - $servers = array(); + $servers = []; foreach ($config->data['LOCATIONS'] as $key => $ignored) { $servers[$key] = $key; } @@ -248,7 +248,7 @@ class standAlonePage { class passwordRecovery extends standAlonePage { protected $loginAttribute; protected $login; - var $message = array(); + var $message = []; var $email_address; var $step = 1; @@ -401,7 +401,7 @@ class passwordRecovery extends standAlonePage { // Check if token branch is here $token = get_ou('recoveryTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']; - $ldap->cat($token, array('dn')); + $ldap->cat($token, ['dn']); if (!$ldap->count()) { /* It's not, let's create it */ $ldap->cd ($config->current['BASE']); @@ -414,15 +414,15 @@ class passwordRecovery extends standAlonePage { } $dn = 'ou='.$this->login.','.$token; - $ldap->cat($dn, array('dn')); + $ldap->cat($dn, ['dn']); $add = ($ldap->count() == 0); /* We store the token and its validity due date */ - $attrs = array( - 'objectClass' => array('organizationalUnit'), + $attrs = [ + 'objectClass' => ['organizationalUnit'], 'ou' => $this->login, 'userPassword' => $sha1_temp_password, 'description' => time() + $this->delay_allowed * 60, - ); + ]; $ldap->cd($dn); if ($add) { $ldap->add($attrs); @@ -466,7 +466,7 @@ class passwordRecovery extends standAlonePage { /* Retrieve dn from the ldap */ $ldap = $config->get_ldap_link(); - $objectClasses = array('gosaMailAccount'); + $objectClasses = ['gosaMailAccount']; if (class_available('personalInfo') && ($config->get_cfg_value('privateEmailPasswordRecovery', 'FALSE') == 'TRUE')) { $objectClasses[] = 'fdPersonalInfo'; } @@ -475,7 +475,7 @@ class passwordRecovery extends standAlonePage { } $filter = '(&(|(objectClass='.join(')(objectClass=', $objectClasses).'))('.$this->loginAttribute.'='.ldap_escape_f($this->login).'))'; $ldap->cd($config->current['BASE']); - $ldap->search($filter, array('dn')); + $ldap->search($filter, ['dn']); if ($ldap->count() < 1) { $this->message[] = sprintf(_('Did not find an account with login "%s"'), htmlentities($this->login, ENT_COMPAT, 'UTF-8')); @@ -510,7 +510,7 @@ class passwordRecovery extends standAlonePage { } $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - $ldap->search($filter, array('dn', 'userPassword', $this->loginAttribute)); + $ldap->search($filter, ['dn', 'userPassword', $this->loginAttribute]); /* Only one ldap node should be found */ if ($ldap->count() < 1) { @@ -536,7 +536,7 @@ class passwordRecovery extends standAlonePage { $smarty->assign('login', $this->login); $smarty->assign('email_address', $this->email_address); - $params = $this->encodeParams(array('login', 'directory', 'email_address')); + $params = $this->encodeParams(['login', 'directory', 'email_address']); $smarty->assign('params', $params); } @@ -603,7 +603,7 @@ class passwordRecovery extends standAlonePage { $this->uniq = $uniq_id_from_mail; $this->step = 4; $smarty->assign('login', $this->login); - $params = $this->encodeParams(array('login', 'directory', 'email_address', 'uniq')); + $params = $this->encodeParams(['login', 'directory', 'email_address', 'uniq']); $smarty->assign('params', $params); if (isset($_POST['change'])) { @@ -620,13 +620,13 @@ class passwordRecovery extends standAlonePage { $userTabs = objects::open($dn, 'user'); $userTab = $userTabs->getBaseObject(); - $userTab->userPassword = array( + $userTab->userPassword = [ '', $new_password, $new_password_repeated, $userTab->userPassword, $userTab->attributesAccess['userPassword']->isLocked() - ); + ]; /* Is there any problem with entered passwords? */ $userTabs->save_object(); diff --git a/html/getbin.php b/html/getbin.php index 0598ea917..a41a60e74 100644 --- a/html/getbin.php +++ b/html/getbin.php @@ -27,11 +27,11 @@ error_reporting (0); session_cache_limiter('private'); session::start(); -session::set('errorsAlreadyPosted', array()); +session::set('errorsAlreadyPosted', []); /* Logged in? Simple security check */ if (!session::is_set('ui')) { - logging::log('security', 'unknown', '', array(), 'Error: getbin.php called without session'); + logging::log('security', 'unknown', '', [], 'Error: getbin.php called without session'); header ('Location: index.php'); exit; } diff --git a/html/geticon.php b/html/geticon.php index 2e338e288..0e2fc5ae2 100644 --- a/html/geticon.php +++ b/html/geticon.php @@ -25,7 +25,7 @@ session_cache_limiter("private"); session::start(); -session::set('errorsAlreadyPosted', array()); +session::set('errorsAlreadyPosted', []); $theme = ''; if (session::is_set('config')) { @@ -34,7 +34,7 @@ if (session::is_set('config')) { } else { header("cache-control: no-cache"); } -IconTheme::$extensions = array('png'); +IconTheme::$extensions = ['png']; if (!isset($_GET['context']) || !isset($_GET['icon']) || !isset($_GET['size'])) { trigger_error('Missing information in query string: '.$_SERVER['QUERY_STRING']); exit; diff --git a/html/index.php b/html/index.php index a72e361f9..a444fc69b 100644 --- a/html/index.php +++ b/html/index.php @@ -70,7 +70,7 @@ function displayLogin() } /* Generate server list */ - $servers = array(); + $servers = []; if (isset($_POST['server'])) { $selected = $_POST['server']; } else { @@ -246,7 +246,7 @@ class Index { if ($config->get_cfg_value('schemaCheck') != 'TRUE') { return TRUE; } - $cfg = array(); + $cfg = []; $cfg['admin'] = $config->current['ADMINDN']; $cfg['password'] = $config->current['ADMINPASSWORD']; $cfg['connection'] = $config->current['SERVER']; @@ -269,7 +269,7 @@ class Index { { global $config; $ldap = $config->get_ldap_link(); - $ldap->cat(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'], array('dn')); + $ldap->cat(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'], ['dn']); $attrs = $ldap->fetch(); if (!count($attrs)) { $ldap->cd($config->current['BASE']); @@ -302,9 +302,9 @@ class Index { $ui = ldap_login_user(static::$username, static::$password); if ($ui === NULL) { if (isset($_SERVER['REMOTE_ADDR'])) { - logging::log('security', 'login', '', array(), 'Authentication failed for user "'.static::$username.'" [from '.$_SERVER['REMOTE_ADDR'].']'); + logging::log('security', 'login', '', [], 'Authentication failed for user "'.static::$username.'" [from '.$_SERVER['REMOTE_ADDR'].']'); } else { - logging::log('security', 'login', '', array(), 'Authentication failed for user "'.static::$username.'"'); + logging::log('security', 'login', '', [], 'Authentication failed for user "'.static::$username.'"'); } $message = _('Please check the username/password combination.'); $smarty->assign ('focusfield', 'password'); @@ -340,7 +340,7 @@ class Index { $expired = $ui->expired_status(); if ($expired == POSIX_ACCOUNT_EXPIRED) { - logging::log('security', 'login', '', array(), 'Account for user "'.static::$username.'" has expired'); + logging::log('security', 'login', '', [], 'Account for user "'.static::$username.'" has expired'); $message = _('Account locked. Please contact your system administrator!'); $smarty->assign ('focusfield', 'username'); return FALSE; @@ -354,7 +354,7 @@ class Index { { global $config; /* Not account expired or password forced change go to main page */ - logging::log('security', 'login', '', array(), 'User "'.static::$username.'" logged in successfully.'); + logging::log('security', 'login', '', [], 'User "'.static::$username.'" logged in successfully.'); session::set('connected', 1); session::set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL')); header ('Location: main.php?global_check=1'); @@ -398,13 +398,13 @@ class Index { static::$username = $_POST['username']; static::$password = $_POST['password']; - $success = static::runSteps(array( + $success = static::runSteps([ 'validateUserInput', 'ldapLoginUser', 'checkForLockingBranch', 'loginAndCheckExpired', 'runSchemaCheck', - )); + ]); if ($success) { /* Everything went well, redirect to main.php */ @@ -430,13 +430,13 @@ class Index { static::$username = $_SERVER['PHP_AUTH_USER']; static::$password = $_SERVER['PHP_AUTH_PW']; - $success = static::runSteps(array( + $success = static::runSteps([ 'validateUserInput', 'ldapLoginUser', 'checkForLockingBranch', 'loginAndCheckExpired', 'runSchemaCheck', - )); + ]); if ($success) { /* Everything went well, redirect to main.php */ @@ -499,11 +499,11 @@ class Index { $ui->loadACL(); - $success = static::runSteps(array( + $success = static::runSteps([ 'checkForLockingBranch', 'loginAndCheckExpired', 'runSchemaCheck', - )); + ]); if ($success) { /* Everything went well, redirect to main.php */ @@ -566,11 +566,11 @@ class Index { $ui->loadACL(); - $success = static::runSteps(array( + $success = static::runSteps([ 'checkForLockingBranch', 'loginAndCheckExpired', 'runSchemaCheck', - )); + ]); if ($success) { /* Everything went well, redirect to main.php */ diff --git a/html/main.php b/html/main.php index 00a1e3100..367e90533 100644 --- a/html/main.php +++ b/html/main.php @@ -40,8 +40,8 @@ textdomain($domain); /* Remember everything we did after the last click */ session::start(); -session::set('errorsAlreadyPosted', array()); -session::set('runtime_cache', array()); +session::set('errorsAlreadyPosted', []); +session::set('runtime_cache', []); session::set('limit_exceeded', FALSE); if ($_SERVER["REQUEST_METHOD"] == "POST") { @@ -51,7 +51,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { /* Logged in? Simple security check */ if (!session::is_set('connected')) { - logging::log('security', 'login', '', array(), 'main.php called without session - logging out'); + logging::log('security', 'login', '', [], 'main.php called without session - logging out'); header ('Location: index.php?message=nosession'); exit; } @@ -83,7 +83,7 @@ if (session::get('_LAST_PAGE_REQUEST') != '') { */ if ($request_time > $max_life) { session::destroy(); - logging::log('security', 'login', '', array(), 'main.php called with expired session - logging out'); + logging::log('security', 'login', '', [], 'main.php called with expired session - logging out'); header ('Location: index.php?signout=1&message=expired'); exit; } @@ -114,7 +114,7 @@ if (isset($global_check) && $config->get_cfg_value("forceglobals") == "TRUE") { _("Fatal error: Register globals is on. FusionDirectory will refuse to login unless this is fixed by an administrator."), FATAL_ERROR_DIALOG); - logging::log('security', 'login', '', array(), 'Register globals is on. For security reasons, this should be turned off.'); + logging::log('security', 'login', '', [], 'Register globals is on. For security reasons, this should be turned off.'); session::destroy (); exit; } @@ -136,7 +136,7 @@ if ($config->get_cfg_value("handleExpiredAccounts") == "TRUE") { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account ('.$ui->uid.') is about to expire'); // The users password is about to xpire soon, display a warning message. - logging::log('security', 'fusiondirectory', '', array(), 'password for user "'.$ui->uid.'" is about to expire'); + logging::log('security', 'fusiondirectory', '', [], 'password for user "'.$ui->uid.'" is about to expire'); msg_dialog::display(_('Password change'), _('Your password is about to expire, please change your password!'), INFO_DIALOG); session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE); } elseif ($expired == POSIX_FORCE_PASSWORD_CHANGE) { @@ -166,7 +166,7 @@ if (isset($_GET['plug']) && $plist->plugin_access_allowed($_GET['plug'])) { $plugin_dir = $plist->get_path($plug); session::set('plugin_dir', $plugin_dir); if ($plugin_dir == '') { - logging::log('security', 'fusiondirectory', '', array(), "main.php called with invalid plug parameter \"$plug\""); + logging::log('security', 'fusiondirectory', '', [], "main.php called with invalid plug parameter \"$plug\""); header ('Location: index.php?signout=1&message=invalidparameter&plug='.$plug); exit; } @@ -346,4 +346,4 @@ echo $display; /* Save plist and config */ session::set('plist', $plist); session::set('config', $config); -session::set('errorsAlreadyPosted', array()); +session::set('errorsAlreadyPosted', []); diff --git a/html/progress.php b/html/progress.php index 782bb2759..352aaa539 100644 --- a/html/progress.php +++ b/html/progress.php @@ -58,7 +58,7 @@ if (!function_exists("imagecreate")) { $x_matches = FALSE; $y_matches = FALSE; - foreach (array(7,6,5,4,3,2,1,0) as $font) { + foreach ([7,6,5,4,3,2,1,0] as $font) { $fx = ImageFontWidth($font) * strlen("$p%"); $fy = ImageFontHeight($font); diff --git a/html/setup.php b/html/setup.php index 48f981613..4695b6ad1 100644 --- a/html/setup.php +++ b/html/setup.php @@ -50,7 +50,7 @@ ini_set("session.gc_maxlifetime", 24 * 60 * 60); /* Start session */ session::start(); session::set('DEBUGLEVEL', 0); -session::set('errorsAlreadyPosted', array()); +session::set('errorsAlreadyPosted', []); CSRFProtection::check(); diff --git a/include/accept-to-gettext.inc b/include/accept-to-gettext.inc index d4f171469..0995f1db7 100644 --- a/include/accept-to-gettext.inc +++ b/include/accept-to-gettext.inc @@ -74,7 +74,7 @@ */ function parse_scores ($str) { - $scores = array(); + $scores = []; $parts = preg_split('/,/', $str); foreach ($parts as $part) { $part = trim(strtolower($part)); @@ -109,7 +109,7 @@ function max_scores ($scores, $testvals) function parse_gettext_lang ($str) { if (preg_match("/^([^_]*)(_([^_]*))?\.(.*)$/", $str, $m)) { - return array(strtolower($m[1]), strtolower($m[3]), strtolower($m[4])); + return [strtolower($m[1]), strtolower($m[3]), strtolower($m[4])]; } else { return FALSE; } @@ -157,8 +157,8 @@ function al2gt($gettextlangs) } list ($lang, $country, $char) = $infos; - $lang_score = max_scores($lang_scores, array($lang,$lang.'-'.$country,'*')); - $char_score = max_scores($char_scores, array($char,'*')); + $lang_score = max_scores($lang_scores, [$lang,$lang.'-'.$country,'*']); + $char_score = max_scores($char_scores, [$char,'*']); if ($char_score == 0) { // exclude charsets the user refuses continue; diff --git a/include/class_Combinations.inc b/include/class_Combinations.inc index 2821f6df5..d2776767f 100644 --- a/include/class_Combinations.inc +++ b/include/class_Combinations.inc @@ -43,7 +43,7 @@ class Combinations implements Iterator function current() { - $r = array(); + $r = []; for ($i = 0; $i < $this->size; $i++) { $r[] = $this->input[$this->current[$i]]; } diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc index 15586d2de..9a8e6b6ea 100644 --- a/include/class_CopyPasteHandler.inc +++ b/include/class_CopyPasteHandler.inc @@ -34,20 +34,20 @@ class CopyPasteHandler /*! * \brief This array contains all dns of the currently copied objects */ - protected $objectList = array(); + protected $objectList = []; /*! * \brief This array contains all remaining objects to paste */ - protected $queue = array(); + protected $queue = []; /*! * \brief The dn of the last edited object */ var $lastdn = ""; - var $disallowed_objects = array(); - var $objects_to_fix = array(); - var $clean_objects = array(); + var $disallowed_objects = []; + var $objects_to_fix = []; + var $clean_objects = []; var $require_update = FALSE; /*! @@ -56,7 +56,7 @@ class CopyPasteHandler function __construct() { $this->current = NULL; - $this->queue = array(); + $this->queue = []; } @@ -77,12 +77,12 @@ class CopyPasteHandler { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue'); - if (!in_array($action, array('cut','copy'))) { + if (!in_array($action, ['cut','copy'])) { trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action)); return FALSE; } - $tmp = array(); + $tmp = []; $tmp['method'] = $action; $tmp['dn'] = $dn; @@ -112,8 +112,8 @@ class CopyPasteHandler { $this->current = FALSE; $this->require_update = TRUE; - $this->queue = array(); - $this->objectList = array(); + $this->queue = []; + $this->objectList = []; } /*! @@ -141,7 +141,7 @@ class CopyPasteHandler { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap'); if (!isset($entry['tab_class']) && !isset($entry['type'])) { - return array(); + return []; } $entry['object'] = objects::open($entry['dn'], $entry['type']); @@ -172,9 +172,9 @@ class CopyPasteHandler * Create a list of all entries that can be pasted directly. */ if ($this->require_update) { - $this->clean_objects = array(); - $this->objects_to_fix = array(); - $this->disallowed_objects = array(); + $this->clean_objects = []; + $this->objects_to_fix = []; + $this->disallowed_objects = []; /* Put each queued object in one of the above arrays */ foreach ($this->queue as $key => $entry) { @@ -199,7 +199,7 @@ class CopyPasteHandler } } if (count($this->disallowed_objects)) { - $dns = array(); + $dns = []; foreach ($this->disallowed_objects as $entry) { $dns[] = $entry['dn']; } diff --git a/include/class_IconTheme.inc b/include/class_IconTheme.inc index 72b3618f1..495f88d2f 100644 --- a/include/class_IconTheme.inc +++ b/include/class_IconTheme.inc @@ -54,7 +54,7 @@ class IconThemeDir $this->Size = $infos['Size']; $this->MinSize = $infos['Size']; $this->MaxSize = $infos['Size']; - foreach (array('Type', 'MaxSize', 'MinSize', 'Threshold') as $key) { + foreach (['Type', 'MaxSize', 'MinSize', 'Threshold'] as $key) { if (isset($infos[$key])) { $this->$key = $infos[$key]; } @@ -102,7 +102,7 @@ class IconThemeDir */ class IconTheme { - private $subdirs = array(); + private $subdirs = []; private $path; private $parent; @@ -200,14 +200,14 @@ class IconTheme } static public $default_theme = 'breezy'; - static public $extensions = array('png', 'xpm', 'svg'); + static public $extensions = ['png', 'xpm', 'svg']; static public $find_closest = FALSE; /* We store themes in the session. To do otherwise, override these methods. */ static public $session_var = 'IconThemes'; static public function loadThemes($path) { - $themes = array(); + $themes = []; if ($dir = opendir("$path")) { while (($file = readdir($dir)) !== FALSE) { if (file_exists("$path/$file/index.theme") && !preg_match("/^\./", $file)) { @@ -246,162 +246,162 @@ class IconTheme } /* Fallback system */ - static public $fallbacks = array( - 'types/user-group' => array( - array('applications','system-users') - ), - 'types/resource-group' => array( - array('actions','resource-group') - ), - 'types/user' => array( - array('places','user-identity'), - array('status','avatar-default'), - ), - 'types/contact' => array( - array('mimetypes','x-office-contact'), - ), - 'types/certificate' => array( - array('mimetypes','stock_certificate'), - array('mimetypes','application-certificate'), - array('actions','view-certificate'), - ), - 'applications/user-info' => array( - array('actions','user-properties'), - array('types','contact'), - array('mimetypes','x-office-contact'), - array('types','user'), - array('places','user-identity'), - array('status','avatar-default'), - ), - 'applications/office-calendar' => array( - array('mimetypes','x-office-calendar'), - ), - 'applications/os-linux' => array( - array('applications','linux'), - ), - 'applications/os-windows' => array( - array('applications','windows'), - ), - 'applications/samba' => array( - array('applications','os-windows'), - array('applications','windows'), - ), - 'applications/config-language' => array( - array('applications','locale'), - array('applications','preferences-desktop-locale'), - ), - 'mimetypes/text-csv' => array( - array('mimetypes','x-office-spreadsheet'), - array('mimetypes','text-x-generic'), - ), - 'mimetypes/application-pdf' => array( - array('mimetypes','x-office-document'), - ), - 'actions/application-exit' => array( - array('actions','system-log-out'), - ), - 'actions/document-export' => array( - array('actions','document-send'), - ), - 'actions/download' => array( - array('actions','document-save'), - ), - 'actions/document-restore' => array( - array('actions','document-import'), - array('actions','document-open'), - ), - 'actions/document-edit' => array( - array('actions','edit'), - array('applications','text-editor'), - array('applications','accessories-text-editor'), - array('actions','document-open'), - ), - 'actions/snapshot' => array( - array('actions','document-save'), - ), - 'actions/system-reboot' => array( - array('actions','view-refresh'), - ), - 'actions/system-update' => array( - array('applications','system-software-update'), - ), - 'actions/system-reinstall' => array( - array('applications','system-installer'), - ), - 'actions/task-start' => array( - array('actions','media-playback-start'), - ), - 'actions/task-stop' => array( - array('actions','media-playback-stop'), - ), - 'actions/task-schedule' => array( - array('actions','chronometer'), - array('actions','smallclock'), - ), - 'actions/up' => array( - array('actions','go-up'), - array('actions','arrow-up'), - ), - 'actions/upload' => array( - array('actions','document-import'), - array('actions','up'), - ), - 'actions/down' => array( - array('actions','go-down'), - array('actions','arrow-down'), - ), - 'actions/previous' => array( - array('actions','go-previous'), - array('actions','arrow-left'), - ), - 'actions/next' => array( - array('actions','go-next'), - array('actions','arrow-right'), - ), - 'actions/submit' => array( - array('actions','go-jump'), - ), - 'categories/settings' => array( - array('categories','gnome-settings'), - array('categories','preferences-other'), - array('categories','preferences-system'), - ), - 'categories/checks' => array( - array('actions','view-task'), - array('actions','view-calendar-tasks'), - array('actions','checkbox'), - array('status','task-complete'), - ), - 'devices/server' => array( - array('places','server'), - array('places','network-server'), - ), - 'devices/media-cdrom' => array( - array('devices','media-optical'), - ), - 'devices/terminal' => array( - array('applications','utilities-terminal'), - ), - 'devices/computer-windows' => array( - array('applications','os-windows'), - array('applications','windows'), - ), - 'devices/template' => array( - array('actions','document-new'), - ), - 'status/object-locked' => array( - array('status','changes-prevent'), - ), - 'status/object-unlocked' => array( - array('status','changes-allow'), - ), - 'status/task-waiting' => array( - array('actions','task-schedule'), - ), - 'places/folder-network' => array( - array('places','folder-remote'), - ), - ); + static public $fallbacks = [ + 'types/user-group' => [ + ['applications','system-users'] + ], + 'types/resource-group' => [ + ['actions','resource-group'] + ], + 'types/user' => [ + ['places','user-identity'], + ['status','avatar-default'], + ], + 'types/contact' => [ + ['mimetypes','x-office-contact'], + ], + 'types/certificate' => [ + ['mimetypes','stock_certificate'], + ['mimetypes','application-certificate'], + ['actions','view-certificate'], + ], + 'applications/user-info' => [ + ['actions','user-properties'], + ['types','contact'], + ['mimetypes','x-office-contact'], + ['types','user'], + ['places','user-identity'], + ['status','avatar-default'], + ], + 'applications/office-calendar' => [ + ['mimetypes','x-office-calendar'], + ], + 'applications/os-linux' => [ + ['applications','linux'], + ], + 'applications/os-windows' => [ + ['applications','windows'], + ], + 'applications/samba' => [ + ['applications','os-windows'], + ['applications','windows'], + ], + 'applications/config-language' => [ + ['applications','locale'], + ['applications','preferences-desktop-locale'], + ], + 'mimetypes/text-csv' => [ + ['mimetypes','x-office-spreadsheet'], + ['mimetypes','text-x-generic'], + ], + 'mimetypes/application-pdf' => [ + ['mimetypes','x-office-document'], + ], + 'actions/application-exit' => [ + ['actions','system-log-out'], + ], + 'actions/document-export' => [ + ['actions','document-send'], + ], + 'actions/download' => [ + ['actions','document-save'], + ], + 'actions/document-restore' => [ + ['actions','document-import'], + ['actions','document-open'], + ], + 'actions/document-edit' => [ + ['actions','edit'], + ['applications','text-editor'], + ['applications','accessories-text-editor'], + ['actions','document-open'], + ], + 'actions/snapshot' => [ + ['actions','document-save'], + ], + 'actions/system-reboot' => [ + ['actions','view-refresh'], + ], + 'actions/system-update' => [ + ['applications','system-software-update'], + ], + 'actions/system-reinstall' => [ + ['applications','system-installer'], + ], + 'actions/task-start' => [ + ['actions','media-playback-start'], + ], + 'actions/task-stop' => [ + ['actions','media-playback-stop'], + ], + 'actions/task-schedule' => [ + ['actions','chronometer'], + ['actions','smallclock'], + ], + 'actions/up' => [ + ['actions','go-up'], + ['actions','arrow-up'], + ], + 'actions/upload' => [ + ['actions','document-import'], + ['actions','up'], + ], + 'actions/down' => [ + ['actions','go-down'], + ['actions','arrow-down'], + ], + 'actions/previous' => [ + ['actions','go-previous'], + ['actions','arrow-left'], + ], + 'actions/next' => [ + ['actions','go-next'], + ['actions','arrow-right'], + ], + 'actions/submit' => [ + ['actions','go-jump'], + ], + 'categories/settings' => [ + ['categories','gnome-settings'], + ['categories','preferences-other'], + ['categories','preferences-system'], + ], + 'categories/checks' => [ + ['actions','view-task'], + ['actions','view-calendar-tasks'], + ['actions','checkbox'], + ['status','task-complete'], + ], + 'devices/server' => [ + ['places','server'], + ['places','network-server'], + ], + 'devices/media-cdrom' => [ + ['devices','media-optical'], + ], + 'devices/terminal' => [ + ['applications','utilities-terminal'], + ], + 'devices/computer-windows' => [ + ['applications','os-windows'], + ['applications','windows'], + ], + 'devices/template' => [ + ['actions','document-new'], + ], + 'status/object-locked' => [ + ['status','changes-prevent'], + ], + 'status/object-unlocked' => [ + ['status','changes-allow'], + ], + 'status/task-waiting' => [ + ['actions','task-schedule'], + ], + 'places/folder-network' => [ + ['places','folder-remote'], + ], + ]; } ?> diff --git a/include/class_Language.inc b/include/class_Language.inc index bd99cb243..13bc7dff8 100644 --- a/include/class_Language.inc +++ b/include/class_Language.inc @@ -118,7 +118,7 @@ class Language $languages = static::getList(); /* Move supported languages to flat list */ - $langs = array(); + $langs = []; foreach (array_keys($languages) as $lang) { $langs[] = $lang.'.UTF-8'; } @@ -135,7 +135,7 @@ class Language public static function getList($ownLanguage = FALSE) { /* locales in english */ - $tmp_english = array( + $tmp_english = [ 'en_US' => 'English', 'af_ZA' => 'Afrikaans', 'ar_EG' => 'Arabic', @@ -166,12 +166,12 @@ class Language 'vi_VN' => 'Vietnamese', 'zh_TW' => 'Taiwanese', 'zh_CN' => 'Chinese', - ); + ]; - $ret = array(); + $ret = []; if ($ownLanguage) { /* locales in their own language */ - $tmp_ownlang = array( + $tmp_ownlang = [ 'en_US' => 'English', 'ar_EG' => 'عربية', 'af_ZA' => 'Afrikaans', @@ -202,7 +202,7 @@ class Language 'vi_VN' => 'Tiếng Việt', 'zh_TW' => 'Taiwanese', 'zh_CN' => '䏿–‡, 汉è¯, 漢語', - ); + ]; foreach ($tmp_english as $key => $name) { $ret[$key] = _($name).' ('.$tmp_ownlang[$key].')'; diff --git a/include/class_SnapshotDialogs.inc b/include/class_SnapshotDialogs.inc index 034241092..ced9d6910 100644 --- a/include/class_SnapshotDialogs.inc +++ b/include/class_SnapshotDialogs.inc @@ -28,17 +28,17 @@ class SnapshotCreateDialog extends simplePlugin static function plInfo() { - return array( + return [ 'plShortName' => 'SnapshotCreateDialog', - ); + ]; } static function getAttributesInfo () { - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('Creating an object snapshot'), - 'attrs' => array( + 'attrs' => [ new DisplayAttribute ( _('Object'), _('DN of the object you are creating a snapshot of'), 'object_dn', FALSE @@ -53,9 +53,9 @@ class SnapshotCreateDialog extends simplePlugin '', 'SnapshotHandler' ), - ) - ), - ); + ] + ], + ]; } function __construct ($dn, $parent, $aclCategory) @@ -124,7 +124,7 @@ class SnapshotCreateDialog extends simplePlugin */ class SnapshotsAttribute extends OrderedArrayAttribute { - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $acl = '') + function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $acl = '') { Attribute::__construct($label, $description, $ldapName, $required, $defaultValue, $acl); $this->edit_enabled = FALSE; @@ -138,18 +138,18 @@ class SnapshotsAttribute extends OrderedArrayAttribute parent::setParent($plugin); if (is_object($this->plugin)) { if ($this->plugin->global) { - $this->setHeaders(array( + $this->setHeaders([ _('DN'), _('Date'), _('Description'), '' - )); + ]); } else { - $this->setHeaders(array( + $this->setHeaders([ _('Date'), _('Description'), '' - )); + ]); } } } @@ -183,10 +183,10 @@ class SnapshotsAttribute extends OrderedArrayAttribute protected function getAttributeArrayValue($key, $value) { - $values = array( + $values = [ date(_('Y-m-d, H:i:s'), preg_replace('/\-.*$/', '', $value['gosaSnapshotTimestamp'][0])), $value['description'][0] - ); + ]; if ($this->plugin->global) { array_unshift($values, $value['gosaSnapshotDN'][0]); } @@ -199,16 +199,16 @@ class SnapshotsAttribute extends OrderedArrayAttribute list ($img, $nbicons) = parent::genRowIcons($key, $value); $img = $this->renderInputField( 'image', $id.'_restore_'.$key, - array( + [ 'src' => 'geticon.php?context=actions&icon=document-restore&size=16', 'title' => _('Restore'), 'alt' => _('Restore'), 'class' => 'center' - ) + ] ).$img; $nbicons++; - return array ($img, $nbicons); + return [$img, $nbicons]; } protected function handlePostValueActions($id, $postValue) @@ -245,18 +245,18 @@ class SnapshotRestoreDialog extends simplePlugin static function plInfo() { - return array( + return [ 'plShortName' => 'SnapshotRestoreDialog', - ); + ]; } static function getAttributesInfo () { - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('Restoring snapshots'), - 'class' => array('fullwidth'), - 'attrs' => array( + 'class' => ['fullwidth'], + 'attrs' => [ new DisplayAttribute ( _('Object'), _('DN of the object you are creating a snapshot of'), 'object_dn', FALSE @@ -264,12 +264,12 @@ class SnapshotRestoreDialog extends simplePlugin new SnapshotsAttribute ( _('Snapshots'), _('Existing snapshots for this object'), 'snapshots', FALSE, - array(), + [], 'SnapshotHandler' ), - ) - ), - ); + ] + ], + ]; } function __construct ($dn, $parent, $global, $aclCategory) @@ -298,28 +298,28 @@ class SnapshotRestoreDialog extends simplePlugin { global $ui; if ($this->dialog == 'delete') { - $objects = array( - array( + $objects = [ + [ 'name' => 'snapshot', 'dn' => $this->snapDn, 'icon' => 'geticon.php?context=actions&icon=document-restore&size=16', 'type' => 'Snapshot' - ) - ); + ] + ]; // Display confirmation dialog. $smarty = get_smarty(); $smarty->assign('objects', $objects); $str = $smarty->fetch(get_template_path('simple-remove.tpl')); } elseif ($this->dialog == 'restore') { - $objects = array( - array( + $objects = [ + [ 'name' => 'snapshot', 'dn' => $this->snapDn, 'icon' => 'geticon.php?context=actions&icon=document-restore&size=16', 'type' => 'Snapshot' - ) - ); + ] + ]; // Display confirmation dialog. $smarty = get_smarty(); diff --git a/include/class_SnapshotHandler.inc b/include/class_SnapshotHandler.inc index 185fec9dd..08072cab8 100644 --- a/include/class_SnapshotHandler.inc +++ b/include/class_SnapshotHandler.inc @@ -30,23 +30,23 @@ */ class SnapshotHandler { - var $snapshotBases = array(); + var $snapshotBases = []; protected $enabled; static function plInfo() { - return array( + return [ 'plShortName' => _('Snapshot'), 'plDescription' => _('Snapshot handler'), /* Categories for snapshots are computed in config class */ - 'plCategory' => array(), + 'plCategory' => [], - 'plProvidedAcls' => array( + 'plProvidedAcls' => [ 'restore_over' => _('Restore over an existing object'), 'restore_deleted' => _('Restore a deleted object'), - ) - ); + ] + ]; } /*! @@ -137,10 +137,10 @@ class SnapshotHandler /* Fetch all objects with */ $ldap->cd($base); - $ldap->search('(&(objectClass=gosaSnapshotObject)(gosaSnapshotDN=*))', array('gosaSnapshotDN')); + $ldap->search('(&(objectClass=gosaSnapshotObject)(gosaSnapshotDN=*))', ['gosaSnapshotDN']); /* Store for which object we have snapshots */ - $this->snapshotsCache = array(); + $this->snapshotsCache = []; while ($entry = $ldap->fetch()) { $this->snapshotsCache[$entry['gosaSnapshotDN'][0]] = TRUE; } @@ -167,7 +167,7 @@ class SnapshotHandler { global $config; if (!$this->enabled()) { - return array(); + return []; } $ldap = $config->get_ldap_link(); @@ -181,12 +181,12 @@ class SnapshotHandler $ldap->cd($base); $ldap->search( '(&(objectClass=gosaSnapshotObject)(gosaSnapshotDN='.ldap_escape_f($dn).'))', - array('gosaSnapshotTimestamp','gosaSnapshotDN','description'), + ['gosaSnapshotTimestamp','gosaSnapshotDN','description'], 'one' ); /* Put results into a list and add description if missing */ - $objects = array(); + $objects = []; while ($entry = $ldap->fetch()) { if (!isset($entry['description'][0])) { $entry['description'][0] = ""; @@ -198,7 +198,7 @@ class SnapshotHandler if ($raw) { return $objects; } else { - $tmp = array(); + $tmp = []; foreach ($objects as $entry) { $tmp[base64_encode($entry['dn'])] = $entry['description'][0]; } @@ -214,7 +214,7 @@ class SnapshotHandler * * \param array $description Snapshot description */ - function createSnapshot($dn, $description = array()) + function createSnapshot($dn, $description = []) { global $config; if (!$this->enabled()) { @@ -226,7 +226,7 @@ class SnapshotHandler $dns = $dn; $dn = $dns[0]; } else { - $dns = array($dn); + $dns = [$dn]; } $ldap = $config->get_ldap_link(); @@ -252,9 +252,9 @@ class SnapshotHandler } } - $target = array(); + $target = []; - $target['objectClass'] = array('top', 'gosaSnapshotObject'); + $target['objectClass'] = ['top', 'gosaSnapshotObject']; $target['gosaSnapshotData'] = gzcompress($data, 6); $target['gosaSnapshotDN'] = $dn; $target['description'] = $description; @@ -307,7 +307,7 @@ class SnapshotHandler { global $config; if (!$this->enabled()) { - return array(); + return []; } $ldap = $config->get_ldap_link(); @@ -315,13 +315,13 @@ class SnapshotHandler /* Prepare bases and some other infos */ $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn); $new_base = $this->snapshot_dn($base_of_object); - $tmp = array(); + $tmp = []; /* Fetch all objects with gosaSnapshotDN=$dn */ $ldap->cd($new_base); $ldap->search( '(&(objectClass=gosaSnapshotObject)(gosaSnapshotDN='.ldap_escape_f($dn).'))', - array('gosaSnapshotTimestamp','gosaSnapshotDN','description'), + ['gosaSnapshotTimestamp','gosaSnapshotDN','description'], 'one' ); @@ -345,7 +345,7 @@ class SnapshotHandler { global $config; if (!$this->enabled()) { - return array(); + return []; } $ldap = $config->get_ldap_link(); @@ -353,11 +353,11 @@ class SnapshotHandler /* Prepare bases */ $new_base = $this->snapshot_dn($base_of_object); /* Fetch all objects and check if they do not exist anymore */ - $tmp = array(); + $tmp = []; $ldap->cd($new_base); $ldap->search( '(objectClass=gosaSnapshotObject)', - array('gosaSnapshotTimestamp','gosaSnapshotDN','description'), + ['gosaSnapshotTimestamp','gosaSnapshotDN','description'], 'one' ); while ($entry = $ldap->fetch()) { @@ -394,23 +394,23 @@ class SnapshotHandler global $config; if (!$this->enabled()) { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'Snaptshot are disabled but tried to restore snapshot'); - return array(); + return []; } $ldap = $config->get_ldap_link(); /* Get the snapshot */ - $ldap->cat($dn, array('gosaSnapshotData'), '(gosaSnapshotData=*)'); + $ldap->cat($dn, ['gosaSnapshotData'], '(gosaSnapshotData=*)'); if ($attrs = $ldap->fetch()) { /* Prepare import string */ $data = gzuncompress($attrs['gosaSnapshotData'][0]); if ($data === FALSE) { msg_dialog::display(_('Error'), _('There was a problem uncompressing snapshot data'), ERROR_DIALOG); - return array(); + return []; } } else { msg_dialog::display(_('Error'), _('Snapshot data could not be fetched'), ERROR_DIALOG); - return array(); + return []; } /* Import the given data */ diff --git a/include/class_acl.inc b/include/class_acl.inc index 203b6adad..452eca871 100644 --- a/include/class_acl.inc +++ b/include/class_acl.inc @@ -31,19 +31,19 @@ class acl { static function plInfo() { - return array( + return [ 'plShortName' => _('ACL'), 'plDescription' => _('Manage access control lists'), - 'plCategory' => array( - 'acl' => array( + 'plCategory' => [ + 'acl' => [ 'description' => _('ACL').' & '._('ACL roles'), - 'objectClass' => array('gosaAcl','gosaRole') - ) - ), - 'plObjectType' => array(), + 'objectClass' => ['gosaAcl','gosaRole'] + ] + ], + 'plObjectType' => [], - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } /*! @@ -78,10 +78,10 @@ class acl static function explodeRole($role) { if (!is_array($role)) { - $role = array($role); + $role = [$role]; } unset($role['count']); - $result = array(); + $result = []; foreach ($role as $aclTemplate) { $list = explode(':', $aclTemplate, 2); $result[$list[0]] = static::extractACL($list[1]); @@ -106,17 +106,17 @@ class acl list($index, $type,$role,$members) = $list; } - $a = array( $index => array( + $a = [ $index => [ 'type' => $type, 'filter' => $filter, 'members' => acl::extractMembers($members), 'acl' => base64_decode($role), - )); + ]]; /* Handle unknown types */ - if (!in_array($type, array('subtree', 'base'))) { + if (!in_array($type, ['subtree', 'base'])) { msg_dialog::display(_("Internal error"), sprintf(_("Unkown ACL type '%s'!\nYou might need to run \"fusiondirectory-setup --migrate-acls\" to migrate your acls to the new format."), $type), ERROR_DIALOG); - $a = array(); + $a = []; } return $a; } @@ -131,7 +131,7 @@ class acl static function extractMembers($ms) { global $config; - $a = array(); + $a = []; /* Seperate by ',' and place it in an array */ $ma = explode(',', $ms); @@ -147,7 +147,7 @@ class acl continue; } - $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid')); + $ldap->cat($dn, ['cn', 'objectClass', 'description', 'uid']); /* Found entry... */ if ($ldap->count()) { @@ -187,7 +187,7 @@ class acl /* Rip acl off the string, seperate by ',' and place it in an array */ $as = preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl); $aa = explode(',', $as); - $a = array(); + $a = []; /* Dis-assemble single ACLs */ foreach ($aa as $sacl) { @@ -203,11 +203,11 @@ class acl if ($idx == 0) { /* Create hash for this object */ $gobject = $object; - $a[$gobject] = array(); + $a[$gobject] = []; /* Append ACL if set */ if ($gacl != "") { - $a[$gobject] = array($gacl); + $a[$gobject] = [$gacl]; } } else { /* All other entries get appended... */ diff --git a/include/class_baseSelector.inc b/include/class_baseSelector.inc index 4acac0237..6a378ce82 100644 --- a/include/class_baseSelector.inc +++ b/include/class_baseSelector.inc @@ -119,7 +119,7 @@ class baseSelector { global $config; - $this->pathMapping = array(); + $this->pathMapping = []; foreach ($bases as $base => $dummy) { // Build path style display diff --git a/include/class_config.inc b/include/class_config.inc index 1585daca9..81d3777ae 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -33,7 +33,7 @@ class config /* XML parser */ var $parser; var $config_found = FALSE; - var $tags = array(); + var $tags = []; var $level = 0; var $gpc = 0; var $section = ''; @@ -42,28 +42,28 @@ class config /*! * \brief Store configuration for current location */ - var $current = array(); + var $current = []; /* Link to LDAP-server */ var $ldap = NULL; - var $referrals = array(); + var $referrals = []; /* * \brief Configuration data * * - $data['SERVERS'] contains server informations. */ - var $data = array( - 'LOCATIONS' => array(), - 'SERVERS' => array(), - 'MAIN' => array(), - ); + var $data = [ + 'LOCATIONS' => [], + 'SERVERS' => [], + 'MAIN' => [], + ]; var $basedir = ''; /* Keep a copy of the current department list */ - var $departments = array(); - var $idepartments = array(); - var $department_info = array(); + var $departments = []; + var $idepartments = []; + var $department_info = []; var $filename = ''; var $last_modified = 0; @@ -106,7 +106,7 @@ class config if (($this->filename != '') && ((filemtime($this->filename) != $this->last_modified) || $force)) { $this->config_found = FALSE; - $this->tags = array(); + $this->tags = []; $this->level = 0; $this->gpc = 0; $this->section = ''; @@ -137,11 +137,11 @@ class config function parse_data ($xmldata) { - $this->data = array( - 'LOCATIONS' => array(), - 'SERVERS' => array(), - 'MAIN' => array(), - ); + $this->data = [ + 'LOCATIONS' => [], + 'SERVERS' => [], + 'MAIN' => [], + ]; $this->parser = xml_parser_create(); xml_set_object($this->parser, $this); @@ -223,7 +223,7 @@ class config /* Add location elements */ if (!isset($this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'])) { - $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'] = array(); + $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'] = []; } $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'][$server] = $attrs; @@ -271,7 +271,7 @@ class config { if (isset($_SERVER['HTTP_FDKEY'])) { if (!session::is_set('HTTP_FDKEY_CACHE')) { - session::set('HTTP_FDKEY_CACHE', array()); + session::set('HTTP_FDKEY_CACHE', []); } $cache = session::get('HTTP_FDKEY_CACHE'); if (!isset($cache[$creds])) { @@ -328,7 +328,7 @@ class config /* Move referrals */ if (!isset($this->current['REFERRAL'])) { - $this->ldap->referrals = array(); + $this->ldap->referrals = []; } else { $this->ldap->referrals = $this->current['REFERRAL']; } @@ -362,7 +362,7 @@ class config /* Sort referrals, if present */ if (isset($this->current['REFERRAL'])) { - $servers = array(); + $servers = []; foreach ($this->current['REFERRAL'] as $server => $ref) { $servers[$server] = strlen($ref['BASE']); } @@ -424,12 +424,12 @@ class config $ldap = $this->get_ldap_link(); /* Get samba servers from LDAP */ - $this->data['SERVERS']['SAMBA'] = array(); + $this->data['SERVERS']['SAMBA'] = []; if (class_available('sambaAccount')) { $ldap->cd($this->current['BASE']); $ldap->search('(objectClass=sambaDomain)'); while ($attrs = $ldap->fetch()) { - $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]] = array( 'SID' => '','RIDBASE' => ''); + $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]] = [ 'SID' => '','RIDBASE' => '']; if (isset($attrs['sambaSID'][0])) { $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]['SID'] = $attrs['sambaSID'][0]; } @@ -441,10 +441,10 @@ class config /* If no samba servers are found, look for configured sid/ridbase */ if (count($this->data['SERVERS']['SAMBA']) == 0) { if (isset($this->current['SAMBASID']) && isset($this->current['SAMBARIDBASE'])) { - $this->data['SERVERS']['SAMBA']['DEFAULT'] = array( + $this->data['SERVERS']['SAMBA']['DEFAULT'] = [ 'SID' => $this->get_cfg_value('SAMBASID'), 'RIDBASE' => $this->get_cfg_value('SAMBARIDBASE') - ); + ]; } } } @@ -459,7 +459,7 @@ class config if (!$forceReload) { $ldap = $this->get_ldap_link(); - $ldap->cat($dn, array('fusionConfigMd5')); + $ldap->cat($dn, ['fusionConfigMd5']); if ($attrs = $ldap->fetch()) { if (isset($attrs['fusionConfigMd5'][0]) && ($attrs['fusionConfigMd5'][0] == md5_file(CACHE_DIR.'/'.CLASS_CACHE))) { return; @@ -488,10 +488,10 @@ class config $mode = strtoupper($parts[1]); $cmd = $parts[2]; if (!isset($this->data['HOOKS'][$class])) { - $this->data['HOOKS'][$class] = array('CLASS' => $parts[0]); + $this->data['HOOKS'][$class] = ['CLASS' => $parts[0]]; } if (!isset($this->data['HOOKS'][$class][$mode])) { - $this->data['HOOKS'][$class][$mode] = array(); + $this->data['HOOKS'][$class][$mode] = []; } $this->data['HOOKS'][$class][$mode][] = $cmd; } @@ -515,7 +515,7 @@ class config function get_departments() { /* Initialize result hash */ - $result = array(); + $result = []; $result['/'] = $this->current['BASE']; @@ -528,7 +528,7 @@ class config /* Create a list of attributes to fetch */ $filter = ''; - $ldap_values = array('objectClass', 'description'); + $ldap_values = ['objectClass', 'description']; foreach ($types as $type) { $i = objects::infos($type); $filter .= $i['filter']; @@ -559,11 +559,11 @@ class config $dn = $attrs['dn']; $data = objects::infos($oc); - $this->department_info[$dn] = array( + $this->department_info[$dn] = [ 'img' => $data['icon'], 'description' => (isset($attrs['description'][0]) ? $attrs['description'][0] : ''), 'name' => $attrs[$data['mainAttr']][0] - ); + ]; /* Only assign non-root departments */ if ($dn != $result['/']) { @@ -580,9 +580,9 @@ class config $base = $this->current['BASE']; $qbase = preg_quote($base, '/'); - $arr = array(); + $arr = []; - $this->idepartments = array(); + $this->idepartments = []; /* Create multidimensional array, with all departments. */ foreach ($this->departments as $key => $val) { @@ -634,7 +634,7 @@ class config */ function generateDepartmentArray($arr, $depth = -1, $max_size = 256) { - $ret = array(); + $ret = []; $depth++; /* Walk through array */ @@ -691,7 +691,7 @@ class config { $class = strtoupper($class); $value = strtoupper($value); - return (isset($this->data['HOOKS'][$class][$value]) ? $this->data['HOOKS'][$class][$value] : array()); + return (isset($this->data['HOOKS'][$class][$value]) ? $this->data['HOOKS'][$class][$value] : []); } /*! @@ -725,7 +725,7 @@ class config } if (is_array($default) && !is_array($res)) { - $res = array($res); + $res = [$res]; } return $res; @@ -794,14 +794,14 @@ class config function loadPlist (pluglist $plist) { - $this->data['OBJECTS'] = array(); - $this->data['SECTIONS'] = array(); - $this->data['CATEGORIES'] = array(); - $this->data['MENU'] = array(); - $this->data['TABS'] = array(); + $this->data['OBJECTS'] = []; + $this->data['SECTIONS'] = []; + $this->data['CATEGORIES'] = []; + $this->data['MENU'] = []; + $this->data['TABS'] = []; foreach ($plist->info as $class => &$plInfo) { if (isset($plInfo['plObjectType'])) { - $entry = array('CLASS' => $class,'NAME' => $plInfo['plShortName']); + $entry = ['CLASS' => $class,'NAME' => $plInfo['plShortName']]; if (isset($plInfo['plSubTabs'])) { $entry['SUBTABS'] = strtoupper($plInfo['plSubTabs']); } @@ -814,7 +814,7 @@ class config } @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class to tab list"); if (!isset($this->data['TABS'][$tabclass])) { - $this->data['TABS'][$tabclass] = array(); + $this->data['TABS'][$tabclass] = []; } $this->data['TABS'][$tabclass][] = $entry; } else { @@ -827,7 +827,7 @@ class config $value['mainTab'] = $class; $value['templateActive'] = FALSE; $value['snapshotActive'] = FALSE; - foreach (array('ou', 'tabClass') as $i) { + foreach (['ou', 'tabClass'] as $i) { if (!isset($value[$i])) { $value[$i] = NULL; } @@ -854,7 +854,7 @@ class config $this->data['OBJECTS'][strtoupper($key)] = $value; @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class as main tab of"); if (!isset($this->data['TABS'][$tabclass])) { - $this->data['TABS'][$tabclass] = array(); + $this->data['TABS'][$tabclass] = []; } array_unshift($this->data['TABS'][$tabclass], $entry); } @@ -862,22 +862,22 @@ class config } elseif (class_available($class) && is_subclass_of($class, 'simpleService')) { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, "Adding service"); if (!isset($this->data['TABS']['SERVERSERVICE'])) { - $this->data['TABS']['SERVERSERVICE'] = array(); + $this->data['TABS']['SERVERSERVICE'] = []; } - $this->data['TABS']['SERVERSERVICE'][] = array( + $this->data['TABS']['SERVERSERVICE'][] = [ 'CLASS' => $class, 'NAME' => $plInfo['plShortName'] - ); + ]; } /* Feed categories */ if (isset($plInfo['plCategory'])) { /* Walk through supplied list and feed only translated categories */ - $cats = array(); + $cats = []; foreach ($plInfo['plCategory'] as $idx => $data) { $cat = (is_numeric($idx) ? $data : $idx); $cats[] = $cat; if (!isset($this->data['CATEGORIES'][$cat])) { - $this->data['CATEGORIES'][$cat] = array( 'classes' => array('0') ); + $this->data['CATEGORIES'][$cat] = [ 'classes' => ['0'] ]; } if (!empty($plInfo['plProvidedAcls'])) { $this->data['CATEGORIES'][$cat]['classes'][] = $class; @@ -886,7 +886,7 @@ class config /* Non numeric index means -> base object containing more informations */ $this->data['CATEGORIES'][$cat]['description'] = $data['description']; if (!is_array($data['objectClass'])) { - $data['objectClass'] = array($data['objectClass']); + $data['objectClass'] = [$data['objectClass']]; } $this->data['CATEGORIES'][$cat]['objectClass'] = $data['objectClass']; } @@ -895,18 +895,18 @@ class config } } unset($plInfo); - $this->data['CATEGORIES']['all'] = array( - 'classes' => array('all'), + $this->data['CATEGORIES']['all'] = [ + 'classes' => ['all'], 'description' => '* '._('All categories'), - 'objectClass' => array(), - ); + 'objectClass' => [], + ]; /* Extract categories definitions from object types */ foreach ($this->data['OBJECTS'] as $key => $infos) { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $infos['aclCategory'], "ObjectType $key category"); if (strtoupper($infos['aclCategory']) == $key) { $cat = $infos['aclCategory']; if (!isset($this->data['CATEGORIES'][$cat])) { - $this->data['CATEGORIES'][$cat] = array('classes' => array('0')); + $this->data['CATEGORIES'][$cat] = ['classes' => ['0']]; } if (!isset($this->data['CATEGORIES'][$cat]['description'])) { $this->data['CATEGORIES'][$cat]['description'] = $infos['name']; @@ -917,11 +917,11 @@ class config } /* Now that OBJECTS are filled, place tabs in categories */ foreach ($plist->info as $class => &$plInfo) { - $acl = array(); + $acl = []; if (isset($plInfo['plCategory'])) { $acl = $plInfo['plCategory']; if (!is_array($acl)) { - $acl = array($acl); + $acl = [$acl]; } } if (isset($plInfo['plObjectType'])) { @@ -985,7 +985,7 @@ class config if (isset($plInfo['plSection'])) { $section = $plInfo['plSection']; if (!is_array($acl)) { - $acl = array($acl); + $acl = [$acl]; } if (!is_numeric(key($acl))) { $acl = array_keys($acl); @@ -1004,9 +1004,9 @@ class config $this->data['SECTIONS'][$section] = array_change_key_case($plInfo['plSection'][$section], CASE_UPPER); } if (!isset($this->data['MENU'][$section])) { - $this->data['MENU'][$section] = array(); + $this->data['MENU'][$section] = []; } - $attrs = array('CLASS' => $class); + $attrs = ['CLASS' => $class]; if (!empty($acl)) { $attrs['ACL'] = $acl; } @@ -1019,7 +1019,7 @@ class config $this->data['SECTIONS'][$section] = array_change_key_case($infos, CASE_UPPER); } if (!isset($this->data['MENU'][$section])) { - $this->data['MENU'][$section] = array(); + $this->data['MENU'][$section] = []; } } foreach ($entries as $section => $section_entries) { @@ -1035,15 +1035,15 @@ class config $infos['classes'] = array_unique($infos['classes']); if (!isset($infos['description'])) { $infos['description'] = $name; - $infos['objectClass'] = array(); + $infos['objectClass'] = []; } } unset($infos); - $this->data['SECTIONS']['personal'] = array('NAME' => _('My account'), 'PRIORITY' => 40); - $personal = array(); + $this->data['SECTIONS']['personal'] = ['NAME' => _('My account'), 'PRIORITY' => 40]; + $personal = []; foreach ($this->data['TABS']['USERTABS'] as $tab) { if ($plist->info[$tab['CLASS']]['plSelfModify']) { - $personal[] = array('CLASS' => $tab['CLASS'], 'ACL' => 'user/'.$tab['CLASS'].':self'); + $personal[] = ['CLASS' => $tab['CLASS'], 'ACL' => 'user/'.$tab['CLASS'].':self']; } } if (!isset($this->data['MENU']['personal'])) { diff --git a/include/class_divSelectBox.inc b/include/class_divSelectBox.inc index 1964e81c9..1aa8908f3 100644 --- a/include/class_divSelectBox.inc +++ b/include/class_divSelectBox.inc @@ -47,7 +47,7 @@ class divSelectBox function __construct($id) { $this->s_summary = ''; - $this->a_entries = array(); + $this->a_entries = []; $this->cols = 0; $this->id = $id; } diff --git a/include/class_filter.inc b/include/class_filter.inc index 964a390a9..ab7cc9c44 100644 --- a/include/class_filter.inc +++ b/include/class_filter.inc @@ -30,19 +30,19 @@ class filter { var $xmlData; - var $elements = array(); - var $elementValues = array(); - var $alphabetElements = array(); - var $autocompleter = array(); + var $elements = []; + var $elementValues = []; + var $alphabetElements = []; + var $autocompleter = []; var $category = ''; - var $objectStorage = array(); + var $objectStorage = []; var $base = ''; var $scope = ''; var $query; var $initial = FALSE; var $scopeMode = 'auto'; var $alphabet = NULL; - var $converter = array(); + var $converter = []; var $pid; var $headpage; @@ -79,7 +79,7 @@ class filter // Load filter if (!isset($this->xmlData['search']['query'][0])) { - $this->xmlData['search']['query'] = array($this->xmlData['search']['query']); + $this->xmlData['search']['query'] = [$this->xmlData['search']['query']]; } // Move information @@ -101,7 +101,7 @@ class filter // Generate formular data if (isset($this->xmlData['element'])) { if (!isset($this->xmlData['element'][0])) { - $this->xmlData['element'] = array($this->xmlData['element']); + $this->xmlData['element'] = [$this->xmlData['element']]; } foreach ($this->xmlData['element'] as $element) { // Ignore elements without type @@ -113,7 +113,7 @@ class filter // Fix arrays if (isset($element['value']) && !isset($element['value'][0])) { - $element['value'] = array($element['value']); + $element['value'] = [$element['value']]; } // Store element for quick access @@ -266,9 +266,9 @@ class filter function setComboBoxOptions($tag, $options) { if (isset($this->elements[$tag]) && ($this->elements[$tag]['type'] == "combobox")) { - $this->elements[$tag]['value'] = array(); + $this->elements[$tag]['value'] = []; foreach ($options as $key => $label) { - $this->elements[$tag]['value'][] = array('label' => $label, 'key' => $key); + $this->elements[$tag]['value'][] = ['label' => $label, 'key' => $key]; } } } @@ -440,7 +440,7 @@ class filter function query() { global $class_mapping; - $result = array(); + $result = []; // Return empty list if initial is not set if (!$this->initial) { @@ -465,10 +465,10 @@ class filter $attributes = $query['attribute']; if ($attributes === '*') { - $attributes = array($attributes); + $attributes = [$attributes]; } else { if (!is_array($attributes)) { - $attributes = array($attributes); + $attributes = [$attributes]; } // ObjectClass is required to check permissions later. if (!in_array('objectClass', $attributes)) { @@ -485,8 +485,8 @@ class filter // Handle converters if present if (isset($this->converter[$tag])) { preg_match('/([^:]+)::(.*)$/', $this->converter[$tag], $m); - $e_set = call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->elementValues[$tag], is_array($element['set']) ? '' : $element['set'])); - $e_unset = call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->elementValues[$tag], is_array($element['unset']) ? '' : $element['unset'])); + $e_set = call_user_func([$m[1], $m[2]], preg_replace('/\$/', $this->elementValues[$tag], is_array($element['set']) ? '' : $element['set'])); + $e_unset = call_user_func([$m[1], $m[2]], preg_replace('/\$/', $this->elementValues[$tag], is_array($element['unset']) ? '' : $element['unset'])); } else { $e_set = (is_array($element['set']) ? '' : $element['set']); $e_unset = (is_array($element['unset']) ? '' : $element['unset']); @@ -519,7 +519,7 @@ class filter ); } // Now call filter method and merge resulting entries. - $result = array_merge($result, call_user_func(array($backend, 'query'), + $result = array_merge($result, call_user_func([$backend, 'query'], $this, $this->base, $this->scope, $filter, $attributes, $this->category, $objectStorage)); } @@ -596,7 +596,7 @@ class filter function getCompletitionList($cfg, $tag, $value = "*") { global $class_mapping; - $res = array(); + $res = []; // Is backend available? $backend = "filter".$cfg['backend']; @@ -608,7 +608,7 @@ class filter $filter = $cfg['filter']; $attributes = $cfg['attribute']; if (!is_array($attributes)) { - $attributes = array($attributes); + $attributes = [$attributes]; } // ObjectClass is required to check permissions later. @@ -619,10 +619,10 @@ class filter // Make filter $filter = preg_replace("/\\$$tag/", ldap_escape_f($value), $filter); if (isset($cfg['base']) && isset($cfg['scope']) && isset($cfg['category'])) { - $result = call_user_func(array($backend, 'query'), $this, $cfg['base'], $cfg['scope'], $filter, $attributes, + $result = call_user_func([$backend, 'query'], $this, $cfg['base'], $cfg['scope'], $filter, $attributes, $cfg["category"], $cfg["objectStorage"]); } else { - $result = call_user_func(array($backend, 'query'), $this, $this->base, $this->scope, $filter, $attributes, + $result = call_user_func([$backend, 'query'], $this, $this->base, $this->scope, $filter, $attributes, $this->category, $this->objectStorage); } @@ -648,7 +648,7 @@ class filter */ function processAutocomplete() { - $result = array(); + $result = []; // Introduce maximum number of entries $max = 25; diff --git a/include/class_filterLDAP.inc b/include/class_filterLDAP.inc index 5e677b4bb..6e6cd13a4 100644 --- a/include/class_filterLDAP.inc +++ b/include/class_filterLDAP.inc @@ -48,7 +48,7 @@ class filterLDAP * * \param array $objectStorage */ - static function query($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = array("")) + static function query($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = [""]) { return static::get_list($parent, $base, $filter, $attributes, $category, $objectStorage, (($scope == 'sub') ? 'subtree' : 'one'), TRUE); } @@ -80,11 +80,11 @@ class filterLDAP // Move to arrays for category and objectStorage if (!is_array($category)) { - $category = array($category); + $category = [$category]; } // Initialize search bases - $bases = array(); + $bases = []; foreach ($objectStorage as $oc) { $oc = preg_replace('/,$/', '', $oc); @@ -103,7 +103,7 @@ class filterLDAP } $parts = ldap_explode_dn($oc, 0); unset($parts['count']); - $dnFilter = array(); + $dnFilter = []; foreach ($parts as $part) { preg_match('/([^=]+)=(.*)$/', $part, $m); $dnFilter[] = '('.$m[1].':dn:='.$m[2].')'; @@ -120,7 +120,7 @@ class filterLDAP $ldap = $config->get_ldap_link($sizelimit); // Do search for every base - $result = array(); + $result = []; $limit_exceeded = FALSE; $ui->getSizeLimitHandler()->setLimitExceeded(FALSE); diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 0b18f481d..58e784ffb 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -40,13 +40,13 @@ class LDAP /* connection identifier */ var $cid; - var $hasres = array(); - var $sr = array(); - var $re = array(); + var $hasres = []; + var $sr = []; + var $re = []; var $basedn = ""; /* 0 if we are fetching the first entry, otherwise 1 */ - var $start = array(); + var $start = []; /* Any error messages to be returned can be put here */ var $error = ""; @@ -54,14 +54,14 @@ class LDAP var $srp = 0; /* Information read from slapd.oc.conf */ - var $objectClasses = array(); + var $objectClasses = []; /* the dn for the bind */ var $binddn = ""; /* the dn's password for the bind */ var $bindpw = ""; var $hostname = ""; var $follow_referral = FALSE; - var $referrals = array(); + var $referrals = []; /* 0, empty or negative values will disable this check */ var $max_ldap_query_time = 0; @@ -134,7 +134,7 @@ class LDAP @ldap_set_option($this->cid, LDAP_OPT_PROTOCOL_VERSION, 3); if (function_exists("ldap_set_rebind_proc") && $this->follow_referral) { @ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1); - @ldap_set_rebind_proc($this->cid, array(&$this, "rebind")); + @ldap_set_rebind_proc($this->cid, [&$this, "rebind"]); } if (function_exists("ldap_start_tls") && $this->tls) { @ldap_start_tls($this->cid); @@ -245,7 +245,7 @@ class LDAP * * \param string $scope Scope of the search: subtree/base/one */ - function search($srp, $filter, $attrs = array(), $scope = 'subtree') + function search($srp, $filter, $attrs = [], $scope = 'subtree') { if ($this->hascon) { if ($this->reconnect) { @@ -297,7 +297,7 @@ class LDAP * * \param array $attrs */ - function ls($srp, $filter = "(objectclass=*)", $basedn = "", $attrs = array("*")) + function ls($srp, $filter = "(objectclass=*)", $basedn = "", $attrs = ["*"]) { trigger_error('deprecated'); $this->cd($basedn); @@ -315,7 +315,7 @@ class LDAP * * \param string $filter Initialized at "(objectclass=*)" */ - function cat($srp, $dn, $attrs = array("*"), $filter = "(objectclass=*)") + function cat($srp, $dn, $attrs = ["*"], $filter = "(objectclass=*)") { if ($this->hascon) { if ($this->reconnect) { @@ -347,7 +347,7 @@ class LDAP if ($this->reconnect) { $this->connect(); } - $res = @ldap_read($this->cid, $dn, $filter, array("objectClass")); + $res = @ldap_read($this->cid, $dn, $filter, ["objectClass"]); $rv = @ldap_count_entries($this->cid, $res); return $rv; } else { @@ -381,7 +381,7 @@ class LDAP */ function fetch($srp) { - $att = array(); + $att = []; if ($this->hascon) { if ($this->hasres[$srp]) { if ($this->start[$srp] == 0) { @@ -389,7 +389,7 @@ class LDAP $this->start[$srp] = 1; $this->re[$srp] = @ldap_first_entry($this->cid, $this->sr[$srp]); } else { - return array(); + return []; } } else { $this->re[$srp] = @ldap_next_entry($this->cid, $this->re[$srp]); @@ -400,7 +400,7 @@ class LDAP } $this->error = @ldap_error($this->cid); if (!isset($att)) { - $att = array(); + $att = []; } return $att; } else { @@ -621,11 +621,11 @@ class LDAP if ($this->reconnect) { $this->connect(); } - $delarray = array(); + $delarray = []; /* Get sorted list of dn's to delete */ $this->cd($deletedn); - $this->search($srp, '(objectClass=*)', array('dn')); + $this->search($srp, '(objectClass=*)', ['dn']); while ($attrs = $this->fetch($srp)) { $delarray[$attrs['dn']] = strlen($attrs['dn']); } @@ -658,7 +658,7 @@ class LDAP if (isset($attrs['objectClass'])) { $ocs = $attrs['objectClass']; if (!is_array($ocs)) { - $ocs = array($ocs); + $ocs = [$ocs]; } if (isset($ocs[$m[1]])) { $str .= " - <b>objectClass: ".$ocs[$m[1]]."</b>"; @@ -733,7 +733,7 @@ class LDAP $real_path = substr($target, 0, strlen($target) - strlen($this->basedn) - 1); if ($target == $this->basedn) { - $l = array('dummy'); + $l = ['dummy']; } else { $l = array_reverse(ldap_explode_dn($real_path, 0)); } @@ -767,29 +767,29 @@ class LDAP $type = preg_replace('/^([^=]+)=.*$/', '\\1', $cdn); $param = preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn); - $param = preg_replace(array('/\\\\,/','/\\\\"/'), array(',','"'), $param); + $param = preg_replace(['/\\\\,/','/\\\\"/'], [',','"'], $param); - $attrs = array($type => $param); + $attrs = [$type => $param]; /* Hardcoded classes */ switch ($type) { case 'ou': - $attrs['objectClass'] = array('organizationalUnit'); + $attrs['objectClass'] = ['organizationalUnit']; break; case 'd': - $attrs['objectClass'] = array('domain'); + $attrs['objectClass'] = ['domain']; break; case 'dc': - $attrs['objectClass'] = array('dcObject'); + $attrs['objectClass'] = ['dcObject']; break; case 'o': - $attrs['objectClass'] = array('organization'); + $attrs['objectClass'] = ['organization']; break; case 'l': - $attrs['objectClass'] = array('locality'); + $attrs['objectClass'] = ['locality']; break; case 'c': - $attrs['objectClass'] = array('country'); + $attrs['objectClass'] = ['country']; break; default: /* Fallback to autodetection of objectClass */ @@ -798,22 +798,22 @@ class LDAP exit(); } /* Get name of first matching objectClass */ - $attrs['objectClass'] = array(); + $attrs['objectClass'] = []; foreach ($classes as $class) { if (isset($class['MUST']) && in_array($type, $class['MUST'])) { /* Look for first class that is structural... */ if (isset($class['STRUCTURAL'])) { - $attrs['objectClass'] = array($class['NAME']); + $attrs['objectClass'] = [$class['NAME']]; break; } /* Look for class that is auxiliary... */ if (empty($attrs['objectClass']) && isset($class['AUXILIARY'])) { - $attrs['objectClass'] = array($class['NAME']); + $attrs['objectClass'] = [$class['NAME']]; } } elseif (empty($attrs['objectClass']) && isset($class['MAY']) && in_array($type, $class['MAY'])) { /* Better than nothing */ - $attrs['objectClass'] = array($class['NAME']); + $attrs['objectClass'] = [$class['NAME']]; } } @@ -929,7 +929,7 @@ class LDAP function get_credentials($url, $referrals = NULL) { - $ret = array(); + $ret = []; $url = preg_replace('!\?\?.*$!', '', $url); $server = preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url); @@ -970,7 +970,7 @@ class LDAP // Check scope values $scope = trim($scope); - if (!empty($scope) && !in_array($scope, array('base', 'one', 'sub', 'children'))) { + if (!empty($scope) && !in_array($scope, ['base', 'one', 'sub', 'children'])) { trigger_error(sprintf("Invalid parameter for scope '%s', please use 'base', 'one', 'sub' or 'children'."), $scope); return NULL; } @@ -986,11 +986,11 @@ class LDAP $cmd = 'ldapsearch'.($this->tls ? ' -ZZ' : '')." -x -LLLL -D {$admin} {$filter} {$limit} {$scope} -H {$host} -b {$dn} -w {$pwd} "; // Create list of process pipes - $descriptorspec = array( - 0 => array("pipe", "r"), // stdin - 1 => array("pipe", "w"), // stdout - 2 => array("pipe", "w") // stderr - ); + $descriptorspec = [ + 0 => ["pipe", "r"], // stdin + 1 => ["pipe", "w"], // stdout + 2 => ["pipe", "w"] // stderr + ]; // Try to open the process $process = proc_open($cmd, $descriptorspec, $pipes); @@ -1017,7 +1017,7 @@ class LDAP function dn_exists($dn) { - return @ldap_read($this->cid, $dn, "(objectClass=*)", array("objectClass")); + return @ldap_read($this->cid, $dn, "(objectClass=*)", ["objectClass"]); } /*! @@ -1049,8 +1049,8 @@ class LDAP /* Joining lines */ $line = NULL; - $entry = array(); - $entries = array(); + $entry = []; + $entries = []; $entryStart = -1; foreach ($fileLines as $lineNumber => $fileLine) { if (preg_match('/^ /', $fileLine)) { @@ -1088,7 +1088,7 @@ class LDAP throw new LDIFImportException(sprintf(_('Error line %s, an entry bloc should start with the dn'), $lineNumber)); } else { if (!isset($entry[$key])) { - $entry[$key] = array(); + $entry[$key] = []; } $entry[$key][] = $value; } @@ -1102,7 +1102,7 @@ class LDAP $entries[$entryStart] = $entry; } /* Start a new entry */ - $entry = array(); + $entry = []; $entryStart = -1; $line = NULL; } @@ -1184,11 +1184,11 @@ class LDAP $attrs = $this->fetch($srp); foreach (array_keys($attrs) as $name) { if (!is_numeric($name)) { - if (in_array($name, array('dn','count'))) { + if (in_array($name, ['dn','count'])) { continue; } if (!isset($data[$name])) { - $data[$name] = array(); + $data[$name] = []; } } } @@ -1217,7 +1217,7 @@ class LDAP */ function get_objectclasses($force_reload = FALSE) { - $objectclasses = array(); + $objectclasses = []; /* Return the cached results. */ if (class_available('session') && session::is_set('LDAP_CACHE::get_objectclasses') && !$force_reload) { @@ -1226,19 +1226,19 @@ class LDAP } // Get base to look for schema - $sr = @ldap_read($this->cid, '', 'objectClass=*', array('subschemaSubentry')); + $sr = @ldap_read($this->cid, '', 'objectClass=*', ['subschemaSubentry']); $attr = @ldap_get_entries($this->cid, $sr); if (!isset($attr[0]['subschemasubentry'][0])) { - return array(); + return []; } /* Get list of objectclasses and fill array */ $nb = $attr[0]['subschemasubentry'][0]; - $objectclasses = array(); - $sr = ldap_read ($this->cid, $nb, 'objectClass=*', array('objectclasses')); + $objectclasses = []; + $sr = ldap_read ($this->cid, $nb, 'objectClass=*', ['objectclasses']); $attrs = ldap_get_entries($this->cid, $sr); if (!isset($attrs[0])) { - return array(); + return []; } foreach ($attrs[0]['objectclasses'] as $val) { if (preg_match('/^[0-9]+$/', $val)) { @@ -1247,7 +1247,7 @@ class LDAP $name = "OID"; $pattern = explode(' ', $val); $ocname = preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val); - $objectclasses[$ocname] = array(); + $objectclasses[$ocname] = []; foreach ($pattern as $chunk) { switch ($chunk) { @@ -1259,8 +1259,8 @@ class LDAP case ')': if ($name != '') { $v = $this->value2container($value); - if (in_array($name, array('MUST', 'MAY')) && !is_array($v)) { - $v = array($v); + if (in_array($name, ['MUST', 'MAY']) && !is_array($v)) { + $v = [$v]; } $objectclasses[$ocname][$name] = $v; } @@ -1278,8 +1278,8 @@ class LDAP case 'MAY': if ($name != '') { $v = $this->value2container($value); - if (in_array($name, array('MUST','MAY')) && !is_array($v)) { - $v = array($v); + if (in_array($name, ['MUST','MAY']) && !is_array($v)) { + $v = [$v]; } $objectclasses[$ocname][$name] = $v; } @@ -1367,7 +1367,7 @@ class LDAP ldap_bind ($ds, $admin, $password); /* Get base to look for naming contexts */ - $sr = @ldap_read ($ds, '', 'objectClass=*', array('namingContexts')); + $sr = @ldap_read ($ds, '', 'objectClass=*', ['namingContexts']); $attr = @ldap_get_entries($ds, $sr); return $attr[0]['namingcontexts']; diff --git a/include/class_ldapFilter.inc b/include/class_ldapFilter.inc index b9921b855..2d3bc3c1b 100644 --- a/include/class_ldapFilter.inc +++ b/include/class_ldapFilter.inc @@ -36,7 +36,7 @@ */ class ldapFilter { - static $operators = array('!', '&', '|'); + static $operators = ['!', '&', '|']; protected $operator; protected $subparts; @@ -82,7 +82,7 @@ class ldapFilter return $this->subparts; } - function listUsedAttributes(&$result = array()) + function listUsedAttributes(&$result = []) { foreach ($this->subparts as $subpart) { $subpart->listUsedAttributes($result); @@ -93,10 +93,10 @@ class ldapFilter static function parse($filter) { // Remove starting and ending parenthesis - $filter = preg_replace(array('/^\\s*\\(/', '/\\)\\s*$/'), '', $filter); + $filter = preg_replace(['/^\\s*\\(/', '/\\)\\s*$/'], '', $filter); if (in_array($filter[0], ldapFilter::$operators)) { - $subfilters = array(); + $subfilters = []; /* We need an ending parenthesis in order to catch last subpart correctly */ $filter .= ')'; $offset = 0; @@ -116,7 +116,7 @@ class ldapFilter } } } - if (in_array($filter[0], array('&', '|')) && (count($subfilters) == 1)) { + if (in_array($filter[0], ['&', '|']) && (count($subfilters) == 1)) { /* Avoid empty levels */ return $subfilters[0]; } else { @@ -135,7 +135,7 @@ class ldapFilter */ class ldapFilterLeaf extends ldapFilter { - static $operators = array('=','~=','>=','<='); + static $operators = ['=','~=','>=','<=']; protected $pattern; protected $dnFilter = FALSE; @@ -146,7 +146,7 @@ class ldapFilterLeaf extends ldapFilter $this->dnFilter = TRUE; $left = substr($left, 0, -4); } - parent::__construct($operator, array($left, $right)); + parent::__construct($operator, [$left, $right]); if (($this->operator == '=') || ($this->operator == '~=')) { $prefix = ''; $suffix = ''; @@ -156,7 +156,7 @@ class ldapFilterLeaf extends ldapFilter if (preg_match('/\\*$/', $this->subparts[1])) { $suffix = '.*'; } - $search = preg_replace(array('/^\\*/','/\\*$/'), '', $this->subparts[1]); + $search = preg_replace(['/^\\*/','/\\*$/'], '', $this->subparts[1]); if ($this->dnFilter) { $this->pattern = '/'.$left.'='.$prefix.preg_quote($search, '/').$suffix.',/'; } elseif ($this->subparts[1] == '*') { @@ -192,7 +192,7 @@ class ldapFilterLeaf extends ldapFilter if (isset($array[$this->subparts[0]])) { $values = $array[$this->subparts[0]]; if (!is_array($values)) { - $values = array($values); + $values = [$values]; } foreach ($values as $value) { switch ($this->operator) { @@ -221,7 +221,7 @@ class ldapFilterLeaf extends ldapFilter return FALSE; } - function listUsedAttributes(&$result = array()) + function listUsedAttributes(&$result = []) { if ($this->dnFilter) { $result['dn'] = 'dn'; diff --git a/include/class_ldapMultiplexer.inc b/include/class_ldapMultiplexer.inc index 5563720a8..03f1f0cda 100644 --- a/include/class_ldapMultiplexer.inc +++ b/include/class_ldapMultiplexer.inc @@ -60,11 +60,11 @@ class ldapMultiplexer { public function __call($methodName, $parameters) { /* Add resource pointer if the mentioned methods are used */ - if (in_array($methodName, array('search','ls','cat','fetch','clearResult','resetResult','count','getDN','rmdir_recursive','create_missing_trees','import_single_entry','import_complete_ldif'))) { + if (in_array($methodName, ['search','ls','cat','fetch','clearResult','resetResult','count','getDN','rmdir_recursive','create_missing_trees','import_single_entry','import_complete_ldif'])) { array_unshift($parameters, $this->sr); } - return call_user_func_array(array($this->object, $methodName), $parameters); + return call_user_func_array([$this->object, $methodName], $parameters); } /* diff --git a/include/class_listing.inc b/include/class_listing.inc index 2bd3d5178..4d1d6e890 100644 --- a/include/class_listing.inc +++ b/include/class_listing.inc @@ -32,7 +32,7 @@ class listing { var $xmlData; var $entries; - var $departments = array(); + var $departments = []; var $departmentBrowser = FALSE; var $departmentRootVisible = FALSE; var $multiSelect = FALSE; @@ -45,24 +45,24 @@ class listing var $sortType; var $numColumns; var $baseMode = FALSE; - var $bases = array(); - var $header = array(); - var $colprops = array(); - var $filters = array(); + var $bases = []; + var $header = []; + var $colprops = []; + var $filters = []; var $filter = NULL; var $pid; - protected $departmentTypes = array(); - var $objectTypes = array(); - var $objectTypeCount = array(); - protected $objectDnMapping = array(); + protected $departmentTypes = []; + var $objectTypes = []; + var $objectTypeCount = []; + protected $objectDnMapping = []; protected $copyPasteHandler = NULL; protected $snapshotHandler = NULL; - var $exporter = array(); - var $exportColumns = array(); + var $exporter = []; + var $exportColumns = []; var $height = 0; var $scrollPosition = 0; var $baseSelector; - protected $filterCache = array(); + protected $filterCache = []; /*! * \brief Create a listing @@ -110,7 +110,7 @@ class listing // Load exporters foreach (array_keys($class_mapping) as $class) { if (preg_match('/Exporter$/', $class)) { - $info = call_user_func(array($class, "getInfo")); + $info = call_user_func([$class, "getInfo"]); if ($info != NULL) { $this->exporter = array_merge($this->exporter, $info); } @@ -207,7 +207,7 @@ class listing $this->xmlData = xml::xml2array($contents, 1); } - $this->filterCache = array(); + $this->filterCache = []; if (!isset($this->xmlData['list'])) { return FALSE; @@ -216,7 +216,7 @@ class listing $this->xmlData = $this->xmlData["list"]; // Load some definition values - foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect", "baseMode") as $token) { + foreach (["departmentBrowser", "departmentRootVisible", "multiSelect", "baseMode"] as $token) { if (isset($this->xmlData['definition'][$token]) && $this->xmlData['definition'][$token] == "true") { $this->$token = TRUE; @@ -227,19 +227,19 @@ class listing $types = departmentManagement::getDepartmentTypes(); foreach ($types as $type) { $i = objects::infos($type); - $this->departmentTypes[strtoupper($type)] = array( + $this->departmentTypes[strtoupper($type)] = [ 'label' => $i['name'], 'image' => $i['icon'], 'category' => $i['aclCategory'], 'class' => $i['mainTab'], 'filter' => objects::getFilterObject($type), 'nameAttr' => $i['nameAttr'], - ); + ]; } - $this->categories = array(); + $this->categories = []; if (isset($this->xmlData['definition']['objectType'])) { if (isset($this->xmlData['definition']['objectType']['label'])) { - $this->xmlData['definition']['objectType'] = array($this->xmlData['definition']['objectType']); + $this->xmlData['definition']['objectType'] = [$this->xmlData['definition']['objectType']]; } foreach ($this->xmlData['definition']['objectType'] as $index => $otype) { $this->objectTypes[$otype['objectClass']] = $otype; @@ -259,7 +259,7 @@ class listing // Assign headline/Categories $this->headline = _($this->xmlData['definition']['label']); if (!is_array($this->categories)) { - $this->categories = array($this->categories); + $this->categories = [$this->categories]; } // Evaluate columns to be exported @@ -272,7 +272,7 @@ class listing } if (isset($this->xmlData['actiontriggers']['action']['type'])) { - $this->xmlData['actiontriggers']['action'] = array($this->xmlData['actiontriggers']['action']); + $this->xmlData['actiontriggers']['action'] = [$this->xmlData['actiontriggers']['action']]; } return TRUE; @@ -281,8 +281,8 @@ class listing function renderHeader() { - $this->header = array(); - $this->plainHeader = array(); + $this->header = []; + $this->plainHeader = []; // Initialize sort? $sortInit = FALSE; @@ -293,7 +293,7 @@ class listing } else { $this->sortAttribute = ""; } - $this->sortDirection = array(); + $this->sortDirection = []; $sortInit = TRUE; } @@ -540,8 +540,8 @@ class listing } // Reset object counter / DN mapping - $this->objectTypeCount = array(); - $this->objectDnMapping = array(); + $this->objectTypeCount = []; + $this->objectDnMapping = []; // Do not do anything if this is not our PID if ($refresh || !(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid)) { @@ -566,12 +566,12 @@ class listing $exporter = $this->exporter[$_POST['act']]; $userinfo = ", "._("created by")." ".$ui->cn." - ".strftime('%A, %d. %B %Y, %H:%M:%S'); $entryIterator = new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType); - $sortedEntries = array(); + $sortedEntries = []; foreach ($entryIterator as $entry) { $sortedEntries[] = $entry; } $instance = new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $sortedEntries, $this->exportColumns); - $type = call_user_func(array($exporter['class'], "getInfo")); + $type = call_user_func([$exporter['class'], "getInfo"]); $type = $type[$_POST['act']]; send_binary_content($instance->query(), $type['filename'], $type = $type['mime']); } @@ -628,10 +628,10 @@ class listing // Fix filter if querie returns NULL if ($this->entries == NULL) { - $this->entries = array(); + $this->entries = []; } - $this->dnToRow = array(); + $this->dnToRow = []; foreach ($this->entries as $row => $entry) { $this->dnToRow[$entry['dn']] = $row; } @@ -682,7 +682,7 @@ class listing */ function parseLayout($layout) { - $result = array(); + $result = []; $layout = preg_replace("/^\|/", "", $layout); $layout = preg_replace("/\|$/", "", $layout); $cols = explode("|", $layout); @@ -778,7 +778,7 @@ class listing } else { preg_match_all('/%{filter:([^(]+)\((.*)\)}/', $data, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); - $filters = array(); + $filters = []; foreach ($matches as $match) { $cl = ''; $method = ''; @@ -794,7 +794,7 @@ class listing // Prepare params for function call preg_match_all('/"[^"]+"|[^,]+/', $match[2][0], $parts); - $filters[$match[0][0]] = array($cl, $method, $parts[0], $match[0][1]); + $filters[$match[0][0]] = [$cl, $method, $parts[0], $match[0][1]]; } $this->filterCache[$type.$index] = $filters; @@ -802,7 +802,7 @@ class listing foreach ($filters as $filterstring => $filter) { list ($cl, $method, $parts, $offset) = $filter; - $params = array(); + $params = []; foreach ($parts as $param) { switch ($param) { case 'row': @@ -844,10 +844,10 @@ class listing // Replace information if ($cl == 'listing') { // Non static call - $data = substr_replace($data, call_user_func_array(array($this, $method), $params), $offset, strlen($filterstring)); + $data = substr_replace($data, call_user_func_array([$this, $method], $params), $offset, strlen($filterstring)); } else { // Static call - $data = substr_replace($data, call_user_func_array(array($cl, $method), $params), $offset, strlen($filterstring)); + $data = substr_replace($data, call_user_func_array([$cl, $method], $params), $offset, strlen($filterstring)); } } @@ -897,7 +897,7 @@ class listing } $ocs = $objectType['objectClass']; if (!is_array($ocs)) { - $ocs = array($ocs); + $ocs = [$ocs]; } $found = TRUE; @@ -1114,7 +1114,7 @@ class listing $row = func_get_arg(0); $pid = $this->pid; $dn = func_get_arg(1); - $params = array(func_get_arg(2)); + $params = [func_get_arg(2)]; // Collect sprintf params for ($i = 3;$i < func_num_args();$i++) { @@ -1123,7 +1123,7 @@ class listing continue; } if (!is_array($val)) { - $val = array($val); + $val = [$val]; } $val = array_map( function ($v) @@ -1149,7 +1149,7 @@ class listing function renderNavigation() { - $result = array(); + $result = []; $enableBack = TRUE; $enableRoot = TRUE; $enableHome = TRUE; @@ -1217,7 +1217,7 @@ class listing $this->scrollPosition = $_POST['position_'.$this->pid]; } - $result = array("targets" => array(), "action" => ""); + $result = ["targets" => [], "action" => ""]; // Filter GET with "act" attributes if (isset($_GET['act'])) { @@ -1293,7 +1293,7 @@ class listing $target = preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key); if (isset($this->entries[$target]['dn'])) { $result['action'] = preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key); - $result['targets'] = array($this->entries[$target]['dn']); + $result['targets'] = [$this->entries[$target]['dn']]; } break; } @@ -1333,7 +1333,7 @@ class listing // Make sure we got an array of actions if (isset($this->xmlData['actionmenu']['action']['type'])) { - $this->xmlData['actionmenu']['action'] = array($this->xmlData['actionmenu']['action']); + $this->xmlData['actionmenu']['action'] = [$this->xmlData['actionmenu']['action']]; } // Load shortcut @@ -1374,7 +1374,7 @@ class listing // Skip entry if there're missing dependencies if (isset($action['depends'])) { - $deps = is_array($action['depends']) ? $action['depends'] : array($action['depends']); + $deps = is_array($action['depends']) ? $action['depends'] : [$action['depends']]; foreach ($deps as $clazz) { if (!isset($class_mapping[$clazz])) { continue 2; @@ -1400,7 +1400,7 @@ class listing // Ensure we've an array of actions, this enables sub menus with only one action. if (isset($action['action']['type'])) { - $action['action'] = array($action['action']); + $action['action'] = [$action['action']]; } $result .= $this->recurseActions($action['action'])."</li>"; @@ -1469,14 +1469,14 @@ class listing } $acls = $action['acl']; if (!is_array($acls)) { - $acls = array($acls); + $acls = [$acls]; } - $aclInfos = array(); + $aclInfos = []; // Every ACL has to pass foreach ($acls as $acl) { $module = $this->categories; - $aclList = array(); + $aclList = []; // Replace %acl if available if ($otype) { @@ -1486,12 +1486,12 @@ class listing // Split for category and plugins if needed if (preg_match('/^\[([rwcdm]+)\]$/', $acl, $match)) { // match for "[rw]" style entries - $aclList = array($match[1]); + $aclList = [$match[1]]; } elseif (preg_match('/^([a-zA-Z0-9]+\/?[a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)) { // match for "user[rw]" style entries // match for "user/user[rw]" style entries $module = $match[1]; - $aclList = array($match[2]); + $aclList = [$match[2]]; } elseif (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([a-zA-Z0-9]+:[rwcdm]+(,[a-zA-Z0-9]+:[rwcdm]+)*)\]$/', $acl, $match)) { // match "user/user[userPassword:rw(,...)*]" style entries $module = $match[1]; @@ -1500,10 +1500,10 @@ class listing $modules = $module; if (!is_array($modules)) { - $modules = array($modules); + $modules = [$modules]; } - $aclInfos[] = array($aclList, $modules); + $aclInfos[] = [$aclList, $modules]; } $action['aclInfos'] = $aclInfos; } @@ -1552,7 +1552,7 @@ class listing $ui = get_userinfo(); // Fill internal bases list - $this->bases = array(); + $this->bases = []; $deps = $ui->get_module_departments($this->categories); foreach ($config->idepartments as $key => $dep) { if (in_array_ics($key, $deps)) { @@ -1575,7 +1575,7 @@ class listing /*! \brief Get the departments */ function getDepartments() { - $departments = array(); + $departments = []; $ui = get_userinfo(); // Get list of supported department types @@ -1589,12 +1589,12 @@ class listing $i = objects::infos($type); $deps = objects::ls( $type, - array( + [ 'dn' => 'raw', 'objectClass' => 'raw', 'description' => 'raw', $i['mainAttr'] => 'raw' - ), + ], $this->base, '', FALSE, diff --git a/include/class_logging.inc b/include/class_logging.inc index fb9ebb402..dbb91c114 100644 --- a/include/class_logging.inc +++ b/include/class_logging.inc @@ -34,7 +34,7 @@ * \date 11.04.2007 */ class logging { - static $validActions = array('modify','create','remove','copy','snapshot','view','security','debug'); + static $validActions = ['modify','create','remove','copy','snapshot','view','security','debug']; /*! * \brief logging method @@ -49,7 +49,7 @@ class logging { * * \param $result A status message, containing errors or success messages */ - static function log ($action, $objecttype, $object, array $changes_array = array(), $result = '') + static function log ($action, $objecttype, $object, array $changes_array = [], $result = '') { global $config, $ui; @@ -59,14 +59,14 @@ class logging { } /* Create data object */ - $entry = array( + $entry = [ 'timestamp' => microtime(TRUE), 'action' => $action, 'objecttype' => $objecttype, 'object' => $object, 'changes' => $changes_array, 'result' => $result - ); + ]; if (isset($ui->dn) && !empty($ui->dn)) { $entry['user'] = $ui->dn; } else { @@ -83,7 +83,7 @@ class logging { } else { if (is_object($config) && preg_match('/true/i', $config->get_cfg_value('logging', ''))) { static::log_into_syslog($entry); - if (in_array($action, $config->get_cfg_value('auditActions', array()))) { + if (in_array($action, $config->get_cfg_value('auditActions', []))) { static::log_into_ldap($entry); } } @@ -95,9 +95,9 @@ class logging { * * \param Array $entry to be checked */ - static protected function check($entry = array()) + static protected function check($entry = []) { - $msgs = array(); + $msgs = []; if (!isset($entry['action']) || !in_array($entry['action'], static::$validActions)) { $msgs[] = sprintf(_('Invalid option "%s" specified!'), $entry['action']); diff --git a/include/class_msgPool.inc b/include/class_msgPool.inc index 5cd99f74a..a4284e99d 100644 --- a/include/class_msgPool.inc +++ b/include/class_msgPool.inc @@ -598,7 +598,7 @@ class msgPool { * * \param array $conflicts Tabs this tab conflicts with */ - public static function featuresDisabled($name, array $depends = array(), array $conflicts = array()) + public static function featuresDisabled($name, array $depends = [], array $conflicts = []) { if (empty($depends) && empty($conflicts)) { return sprintf(_('This account has %s settings disabled. You can enable them by clicking below.'), $name); @@ -643,9 +643,9 @@ class msgPool { */ public static function months() { - return array(_("January"), _("February"), _("March"), _("April"), + return [_("January"), _("February"), _("March"), _("April"), _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); + _("October"), _("November"), _("December")]; } /*! @@ -654,7 +654,7 @@ class msgPool { */ public static function weekdays() { - return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")); + return [ _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")]; } /*! @@ -671,8 +671,8 @@ class msgPool { public static function ldaperror($error, $dn = '', $type = 0, $plugin = '') { /* Assign headline depending on type */ - $typemap = array(1 => _('read operation'), _('add operation'), _('modify operation'), - _('delete operation'), _('search operation'), _('authentication')); + $typemap = [1 => _('read operation'), _('add operation'), _('modify operation'), + _('delete operation'), _('search operation'), _('authentication')]; if (isset($typemap[$type])) { $msg = sprintf(_('LDAP %s failed!'), $typemap[$type]); @@ -724,7 +724,7 @@ class msgPool { * * \param array $objects */ - public static function stillInUse($type, $objects = array()) + public static function stillInUse($type, $objects = []) { if (!is_array($objects)) { return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects); diff --git a/include/class_msg_dialog.inc b/include/class_msg_dialog.inc index 800a3c28a..dcae37de2 100644 --- a/include/class_msg_dialog.inc +++ b/include/class_msg_dialog.inc @@ -41,7 +41,7 @@ class msg_dialog private $s_Message = 'Undefined'; private $i_Type = INFO_DIALOG; private $i_ID = 0; - private $a_Trace = array(); + private $a_Trace = []; /*! * \brief Message dialog constructor @@ -54,7 +54,7 @@ class msg_dialog */ public function __construct($s_title, $s_message, $i_type) { - if (!in_array($i_type, array(INFO_DIALOG,WARNING_DIALOG,ERROR_DIALOG,CONFIRM_DIALOG,FATAL_ERROR_DIALOG))) { + if (!in_array($i_type, [INFO_DIALOG,WARNING_DIALOG,ERROR_DIALOG,CONFIRM_DIALOG,FATAL_ERROR_DIALOG])) { trigger_error('Invalid msg_dialog type.'); $i_type = INFO_DIALOG; } @@ -74,7 +74,7 @@ class msg_dialog } if ((!session::is_set('errorsAlreadyPosted')) || !is_array(session::get('errorsAlreadyPosted'))) { - session::set('errorsAlreadyPosted', array()); + session::set('errorsAlreadyPosted', []); } $errorsAlreadyPosted = session::get('errorsAlreadyPosted'); @@ -103,7 +103,7 @@ class msg_dialog if (session::is_set('msg_dialogs')) { $msg_dialogs = session::get('msg_dialogs'); } else { - $msg_dialogs = array(); + $msg_dialogs = []; } $msg_dialogs[] = $this; session::set('msg_dialogs', $msg_dialogs); diff --git a/include/class_objects.inc b/include/class_objects.inc index 4f6716d26..2c795c046 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -51,7 +51,7 @@ class objects } if (!is_array($types)) { - $types = array($types); + $types = [$types]; } if ($checkAcl) { @@ -62,9 +62,9 @@ class objects $acl = $infos['aclCategory'].'/'.$infos['mainTab']; } - $attrsAcls = array(); + $attrsAcls = []; if ($attrs === NULL) { - $attrs = array(); + $attrs = []; foreach ($types as $type) { $infos = static::infos($type); if ($infos['mainAttr']) { @@ -75,13 +75,13 @@ class objects if (count($attrs) == 1) { $attrs = $attrs[0]; } elseif (count($attrs) == 0) { - $attrs = array('dn' => 'raw'); + $attrs = ['dn' => 'raw']; } } elseif ($checkAcl) { if (is_array($attrs)) { $search_attrs = array_keys($attrs); } else { - $search_attrs = array($attrs); + $search_attrs = [$attrs]; } foreach ($search_attrs as $search_attr) { $category = $ui->getAttributeCategory($types[0], $search_attr); @@ -92,7 +92,7 @@ class objects continue; } if (strpos($ui->get_permissions($ou, $category, $search_attr), 'r') === FALSE) { - $attrsAcls[$search_attr] = array($category, $search_attr); + $attrsAcls[$search_attr] = [$category, $search_attr]; } } } @@ -100,15 +100,15 @@ class objects if (is_array($attrs)) { $search_attrs = array_keys($attrs); } else { - $search_attrs = array($attrs); + $search_attrs = [$attrs]; } try { $ldap = static::search($types, $search_attrs, $ou, $filter, $checkAcl, $scope, FALSE, $partialFilterAcls); } catch (NonExistingBranchException $e) { - return array(); + return []; } - $result = array(); + $result = []; while ($fetched_attrs = $ldap->fetch()) { $key = $fetched_attrs['dn']; if ($checkAcl) { @@ -122,7 +122,7 @@ class objects } } if (is_array($attrs)) { - $result[$key] = array(); + $result[$key] = []; foreach ($attrs as $attr => $mode) { if (isset($fetched_attrs[$attr])) { if (isset($attrsAcls[$attr]) && @@ -168,7 +168,7 @@ class objects static function count ($types, $ou = NULL, $filter = '', $checkAcl = FALSE) { try { - $ldap = static::search($types, array('dn'), $ou, $filter, $checkAcl, 'subtree', FALSE, $partialFilterAcls); + $ldap = static::search($types, ['dn'], $ou, $filter, $checkAcl, 'subtree', FALSE, $partialFilterAcls); if (!empty($partialFilterAcls)) { throw new FusionDirectoryException('Not enough rights to use "'.$partialFilterAcls[0][1].'" in filter'); } @@ -180,21 +180,21 @@ class objects return $ldap->count(); } - private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, &$partialFilterAcls = array()) + private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, &$partialFilterAcls = []) { global $config, $ui; - $partialFilterAcls = array(); + $partialFilterAcls = []; if (!is_array($types)) { - $types = array($types); + $types = [$types]; } if ($ou === NULL) { $ou = $config->current['BASE']; } - $typeFilters = array(); + $typeFilters = []; foreach ($types as $type) { $infos = static::infos($type); @@ -236,7 +236,7 @@ class objects continue; } if (strpos($ui->get_permissions($ou, $category, $acl), 'r') === FALSE) { - $partialFilterAcls[] = array($category, $acl); + $partialFilterAcls[] = [$category, $acl]; } } } @@ -248,10 +248,10 @@ class objects if ($templateSearch) { $templateFilterObject = new ldapFilter( '&', - array( + [ new ldapFilterLeaf('objectClass', '=', 'fdTemplate'), fdTemplateFilter(ldapFilter::parse($filter)), - ) + ] ); $filter = "$templateFilterObject"; } @@ -301,7 +301,7 @@ class objects if ($text === NULL) { $ldap = $config->get_ldap_link(); - $ldap->cat($dn, array($infos['nameAttr'])); + $ldap->cat($dn, [$infos['nameAttr']]); if ($attrs = $ldap->fetch()) { if (isset($attrs[$infos['nameAttr']][0])) { $text = $attrs[$infos['nameAttr']][0]; @@ -343,7 +343,7 @@ class objects } else { $parts = ldap_explode_dn(preg_replace('/,$/', '', $infos['ou']), 0); unset($parts['count']); - $dnFilter = array(); + $dnFilter = []; foreach ($parts as $part) { preg_match('/([^=]+)=(.*)$/', $part, $m); $dnFilter[] = '('.$m[1].':dn:='.$m[2].')'; @@ -396,11 +396,11 @@ class objects $infos = static::infos($type); - $templates = array(); + $templates = []; foreach ($config->departments as $key => $value) { // Search all templates from the current dn. try { - $ldap = static::search($type, array('cn'), $infos['ou'].$value, $filter, FALSE, 'subtree', TRUE); + $ldap = static::search($type, ['cn'], $infos['ou'].$value, $filter, FALSE, 'subtree', TRUE); } catch (NonExistingBranchException $e) { continue; } diff --git a/include/class_pluglist.inc b/include/class_pluglist.inc index efadea480..499dde5aa 100644 --- a/include/class_pluglist.inc +++ b/include/class_pluglist.inc @@ -40,23 +40,23 @@ class pluglist { * \brief The plInfo result for all plugin, using class as key. * Contains the plugin index in 'INDEX' and the path in 'PATH' */ - var $info = array(); + var $info = []; /*! * \brief Foreign references on DNs */ - var $dnForeignRefs = array(); + var $dnForeignRefs = []; /*! * \brief Using the plugin index as a key, the class of the plugin. */ - var $dirlist = array(); + var $dirlist = []; /*! * \brief List plugin indexes of all plugin that the user have acl for */ - var $allowed_plugins = array(); - var $silly_cache = array(); + var $allowed_plugins = []; + var $silly_cache = []; /*! * \brief List the plugins @@ -71,13 +71,13 @@ class pluglist { sort($classes); $index = 0; - $depends_infos = array(); - $conflicts_infos = array(); - $foreign_refs = array(); + $depends_infos = []; + $conflicts_infos = []; + $foreign_refs = []; foreach ($classes as $cname) { $cmethods = get_class_methods($cname); if (in_array_ics('plInfo', $cmethods)) { - $infos = call_user_func(array($cname, 'plInfo')); + $infos = call_user_func([$cname, 'plInfo']); if (empty($infos)) { continue; } @@ -85,7 +85,7 @@ class pluglist { $infos['plSelfModify'] = FALSE; /* services are not part of any objectType */ unset($infos['plObjectType']); - $infos['plCategory'] = array('server'); + $infos['plCategory'] = ['server']; } else { if (!isset($infos['plSelfModify'])) { $infos['plSelfModify'] = FALSE; @@ -103,10 +103,10 @@ class pluglist { if (isset($infos['plForeignKeys'])) { foreach ($infos['plForeignKeys'] as $ofield => &$pfks) { if (!is_array($pfks)) { - $pfks = array($pfks); + $pfks = [$pfks]; } if (!is_array($pfks[0])) { - $pfks = array($pfks); + $pfks = [$pfks]; } foreach ($pfks as &$pfk) { $class = $pfk[0]; @@ -125,32 +125,32 @@ class pluglist { } $pfk[2] = $filter; if (!isset($foreign_refs[$class])) { - $foreign_refs[$class] = array(); + $foreign_refs[$class] = []; } if (!isset($foreign_refs[$class][$field])) { - $foreign_refs[$class][$field] = array(); + $foreign_refs[$class][$field] = []; } - $foreign_refs[$class][$field][] = array($cname, $ofield, $filter); + $foreign_refs[$class][$field][] = [$cname, $ofield, $filter]; if ($field == 'dn') { - $this->dnForeignRefs[] = array($cname, $ofield, $filter, (isset($pfk[3]) ? $pfk[3] : "$ofield=*%oldvalue%")); + $this->dnForeignRefs[] = [$cname, $ofield, $filter, (isset($pfk[3]) ? $pfk[3] : "$ofield=*%oldvalue%")]; } } unset($pfk); } unset($pfks); } else { - $infos['plForeignKeys'] = array(); + $infos['plForeignKeys'] = []; } if (!isset($infos['plProvidedAcls'])) { - $infos['plProvidedAcls'] = array(); + $infos['plProvidedAcls'] = []; } if (!isset($infos['plCategory'])) { - $infos['plCategory'] = array(); + $infos['plCategory'] = []; } if (!isset($infos['plTitle']) && isset($infos['plShortName'])) { $infos['plTitle'] = $infos['plShortName']; } - $infos['plForeignRefs'] = array(); + $infos['plForeignRefs'] = []; $infos['INDEX'] = $index; $this->info[$cname] = $infos; $this->dirlist[$index++] = $cname; @@ -163,7 +163,7 @@ class pluglist { if (isset($this->info[$depend]['plDepending'])) { $this->info[$depend]['plDepending'][] = $cname; } else { - $this->info[$depend]['plDepending'] = array($cname); + $this->info[$depend]['plDepending'] = [$cname]; } } else { trigger_error("$cname depends of the inexisting plugin $depend"); @@ -178,7 +178,7 @@ class pluglist { $this->info[$conflict]['plConflicts'][] = $cname; } } else { - $this->info[$conflict]['plConflicts'] = array($cname); + $this->info[$conflict]['plConflicts'] = [$cname]; } } } @@ -190,9 +190,9 @@ class pluglist { } /* Provide field for 'all' */ - $this->info['all'] = array(); + $this->info['all'] = []; - $this->info['all']['plProvidedAcls'] = array(); + $this->info['all']['plProvidedAcls'] = []; $this->info['all']['plDescription'] = _("All objects in this category"); $this->info['all']['plSelfModify'] = FALSE; @@ -248,11 +248,11 @@ class pluglist { /* Split given acl string into an array. e.g. "user,systems" => array("user","systems"); */ - $acls_to_check = array(); + $acls_to_check = []; if (preg_match("/,/", $aclname)) { $acls_to_check = explode(",", $aclname); } else { - $acls_to_check = array($aclname); + $acls_to_check = [$aclname]; } foreach ($acls_to_check as $acl_to_check) { @@ -309,7 +309,7 @@ class pluglist { $plDescription = $this->info[$cname]['plDescription']; } if ($plHeadline && $plIcon && $plDescription) { - return array($plHeadline,$plDescription,$href,$plIcon); + return [$plHeadline,$plDescription,$href,$plIcon]; } } $vars = get_class_vars($cname); @@ -329,7 +329,7 @@ class pluglist { if (!$plIcon) { $plIcon = "icon.png"; } - return array($plHeadline,$plDescription,$href,$plIcon); + return [$plHeadline,$plDescription,$href,$plIcon]; } /*! diff --git a/include/class_template.inc b/include/class_template.inc index 3dab9c506..62ca74cbe 100644 --- a/include/class_template.inc +++ b/include/class_template.inc @@ -35,25 +35,25 @@ class template protected $applied = FALSE; - static protected $uiSpecialAttributes = array('dn','cn','uid','sn','givenName'); + static protected $uiSpecialAttributes = ['dn','cn','uid','sn','givenName']; static function plInfo() { - return array( + return [ 'plShortName' => _('Template'), 'plDescription' => _('Object template, used to create several objects with similar values'), /* Categories for templates are computed in config class */ - 'plCategory' => array(), + 'plCategory' => [], - 'plProvidedAcls' => array( + 'plProvidedAcls' => [ 'template_cn' => _('Template name') - ) - ); + ] + ]; } static function getTemplatedTypes() { - $result = array(); + $result = []; $types = objects::types(); foreach ($types as $type) { if (in_array($type, departmentManagement::getDepartmentTypes())) { @@ -82,11 +82,11 @@ class template $this->tabObject = objects::open($this->dn, $this->type); } $tempTabObject = objects::open($this->dn, $this->type); /* Used to know which tab is activated */ - $this->attributes = array(); + $this->attributes = []; $tempTabObject->setActiveTabs($this->tabObject); foreach ($this->tabObject->by_object as $class => $tab) { if ($tab->is_account || $tab->ignore_account) { - $this->attributes[$class] = array(); + $this->attributes[$class] = []; $attrs = array_unique(array_merge($tab->getRequiredAttributes(), $this->needed)); foreach (array_keys($tab->attributesAccess) as $attr) { if (!$tab->showInTemplate($attr, $this->attrs)) { @@ -140,12 +140,12 @@ class template function serialize() { - $attributes = array(); + $attributes = []; foreach ($this->tabObject->by_object as $class => $plugin) { if (!isset($this->attributes[$class])) { continue; } - $attributes[$class] = array('name' => $this->tabObject->by_name[$class], 'attrs' => array()); + $attributes[$class] = ['name' => $this->tabObject->by_name[$class], 'attrs' => []]; foreach ($this->attributes[$class] as $attr) { $plugin->attributesAccess[$attr]->serializeAttribute($attributes[$class]['attrs'], FALSE); } @@ -181,8 +181,8 @@ class template function execute() { $smarty = get_smarty(); - $sections = array(); - $posted = array(); + $sections = []; + $posted = []; $smarty->assign('baseACL', 'rw'); foreach ($this->tabObject->by_object as $class => &$plugin) { if (!isset($this->attributes[$class])) { @@ -197,7 +197,7 @@ class template return $dialogResult; } } - $attributes = array(); + $attributes = []; foreach ($this->attributes[$class] as $attr) { if ($plugin->attributesAccess[$attr]->getAclInfo() !== FALSE) { // We assign ACLs so that attributes can use them in their template code @@ -262,7 +262,7 @@ class template unset($plugin); foreach ($this->attrs as &$array) { if (!is_array($array)) { - $array = array($array); + $array = [$array]; } if (!isset($array['count'])) { $array['count'] = count($array); @@ -271,7 +271,7 @@ class template unset($array); $ui = get_userinfo(); - $specialAttrs = array(); + $specialAttrs = []; foreach (static::$uiSpecialAttributes as $attr) { $specialAttrs['caller'.strtoupper($attr)] = $ui->$attr; } diff --git a/include/class_templateHandling.inc b/include/class_templateHandling.inc index 2b56786c2..ae4059eea 100644 --- a/include/class_templateHandling.inc +++ b/include/class_templateHandling.inc @@ -39,7 +39,7 @@ class templateHandling list($depends, $errors) = static::attributesDependencies($attrs); msg_dialog::displayChecks($errors); $attrs = static::sortAttributes($attrs, $depends); - return array($attrs, $depends); + return [$attrs, $depends]; } /*! \brief Translate template attrs into $attrs as if taken from LDAP */ @@ -47,14 +47,14 @@ class templateHandling { unset($template_attrs['fdTemplateField']['count']); sort($template_attrs['fdTemplateField']); - $attrs = array(); + $attrs = []; foreach ($template_attrs['fdTemplateField'] as $field) { preg_match('/^([^:]+):(.*)$/s', $field, $m); if (isset($attrs[$m[1]])) { $attrs[$m[1]][] = $m[2]; $attrs[$m[1]]['count']++; } else { - $attrs[$m[1]] = array($m[2]); + $attrs[$m[1]] = [$m[2]]; $attrs[$m[1]]['count'] = 1; } } @@ -119,16 +119,16 @@ class templateHandling public static function parseMask($mask, array $attrs) { if ($mask == '|') { - return array('%'); + return ['%']; } $modifiers = ''; if (preg_match('/^([^|]+)\|/', $mask, $m)) { $modifiers = $m[1]; $mask = substr($mask, strlen($m[0])); } - $result = array(''); + $result = ['']; if (isset($attrs[$mask])) { - $result = array($attrs[$mask]); + $result = [$attrs[$mask]]; if (is_array($result[0])) { unset($result[0]['count']); } @@ -137,14 +137,14 @@ class templateHandling } $len = strlen($modifiers); for ($i = 0; $i < $len; ++$i) { - $args = array(); + $args = []; $modifier = $modifiers[$i]; if (preg_match('/^\[([^\]]+)\].*$/', substr($modifiers, $i + 1), $m)) { /* get modifier args */ $args = explode(',', $m[1]); $i += strlen($m[1]) + 2; } - $result_tmp = array(); + $result_tmp = []; foreach ($result as $r) { $result_tmp = array_merge($result_tmp, static::applyModifier($modifier, $args, $r)); } @@ -166,7 +166,7 @@ class templateHandling */ public static function neededAttrs(array &$attrs, array $flatdepends) { - $needed = array(); + $needed = []; foreach ($flatdepends as $attr => $depends) { if ((isset($depends[0])) && ($depends[0] == 'askme')) { $needed[] = $attr; @@ -233,7 +233,7 @@ class templateHandling */ public static function listFields($string) { - $fields = array(); + $fields = []; $offset = 0; while (preg_match('/%([^%]+)%/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) { $mask = $m[1][0]; @@ -257,15 +257,15 @@ class templateHandling // handle ligatures $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // delete unhandled characters - return array(preg_replace('#&[^;]+;#', '', $str)); + return [preg_replace('#&[^;]+;#', '', $str)]; } private static function modifierTranslit(array $args, $str) { $localesaved = setlocale(LC_CTYPE, 0); - $ret = array(); + $ret = []; foreach ($args as $arg) { - setlocale(LC_CTYPE, array($arg,"$arg.UTF8")); + setlocale(LC_CTYPE, [$arg,"$arg.UTF8"]); $ret[] = iconv('UTF8', 'ASCII//TRANSLIT', $str); } setlocale(LC_CTYPE, $localesaved); @@ -283,7 +283,7 @@ class templateHandling } } - return array(preg_replace($pattern.'u', $replace, $str)); + return [preg_replace($pattern.'u', $replace, $str)]; } private static function modifierSubString(array $args, $str) @@ -295,13 +295,13 @@ class templateHandling array_unshift($args, 0); } if (preg_match('/^(\d+)-(\d+)$/', $args[1], $m)) { - $res = array(); + $res = []; for ($i = $m[1];$i < $m[2]; ++$i) { $res[] = mb_substr($str, $args[0], $i); } return array_unique($res); } else { - return array(mb_substr($str, $args[0], $args[1])); + return [mb_substr($str, $args[0], $args[1])]; } } @@ -366,9 +366,9 @@ class templateHandling $dateObject = new DateTime($args[0], new DateTimeZone('UTC')); if ($args[1] == 'epoch') { /* Special handling for shadowExpire: days since epoch */ - return array(floor($dateObject->format('U') / 86400)); + return [floor($dateObject->format('U') / 86400)]; } - return array($dateObject->format($args[1])); + return [$dateObject->format($args[1])]; } /*! \brief Apply a modifier @@ -387,27 +387,27 @@ class templateHandling /* $str is an array and $m is lowercase, so it's a string modifier */ $str = reset($str); } - $result = array($str); + $result = [$str]; switch ($m) { case 'F': // First - $result = array(reset($str)); + $result = [reset($str)]; break; case 'L': // Last - $result = array(end($str)); + $result = [end($str)]; break; case 'J': // Join if (isset($args[0])) { - $result = array(join($args[0], $str)); + $result = [join($args[0], $str)]; } else { - $result = array(join($str)); + $result = [join($str)]; } break; case 'C': // Count - $result = array(count($str)); + $result = [count($str)]; break; case 'M': // Match @@ -415,40 +415,40 @@ class templateHandling trigger_error('Missing "M" match modifier parameter'); $args[] = '/.*/'; } - $result = array(array_filter( + $result = [array_filter( $str, function ($s) use ($args) { return preg_match($args[0], $s); } - )); + )]; break; case '4': // IPv4 - $result = array(array_filter($str, 'tests::is_ipv4')); + $result = [array_filter($str, 'tests::is_ipv4')]; break; case '6': // IPv6 - $result = array(array_filter($str, 'tests::is_ipv6')); + $result = [array_filter($str, 'tests::is_ipv6')]; break; case 'c': // comment - $result = array(''); + $result = ['']; break; case 'b': // base64 if (isset($args[0]) && ($args[0] == 'd')) { - $result = array(base64_decode($str)); + $result = [base64_decode($str)]; } - $result = array(base64_encode($str)); + $result = [base64_encode($str)]; break; case 'u': // uppercase - $result = array(mb_strtoupper($str, 'UTF-8')); + $result = [mb_strtoupper($str, 'UTF-8')]; break; case 'l': // lowercase - $result = array(mb_strtolower($str, 'UTF-8')); + $result = [mb_strtolower($str, 'UTF-8')]; break; case 'a': // remove accent @@ -468,22 +468,22 @@ class templateHandling break; case 'r': // random string - $result = array(static::modifierRandomString($args)); + $result = [static::modifierRandomString($args)]; break; case 'd': // date - $result = array(static::modifierDate($args)); + $result = [static::modifierDate($args)]; break; default: trigger_error("Unkown modifier '$m'"); - $result = array($str); + $result = [$str]; break; } return $result; } /*! \brief Flattens dependencies (if a depends of b which depends of c then a depends of c) */ - protected static function flatDepends (&$cache, &$errors, $depends, $key, array $forbidden = array()) + protected static function flatDepends (&$cache, &$errors, $depends, $key, array $forbidden = []) { if (isset($cache[$key])) { return $cache[$key]; @@ -501,7 +501,7 @@ class templateHandling $key, $a ); - return array(); + return []; } $deps = static::flatDepends ($cache, $errors, $depends, $a, $forbidden); if (($askmeKey = array_search('askme', $deps)) !== FALSE) { @@ -521,11 +521,11 @@ class templateHandling protected static function attributesDependencies(array $attrs) { /* Compute dependencies of each attr */ - $depends = array(); + $depends = []; foreach ($attrs as $key => $values) { - $depends[$key] = array(); + $depends[$key] = []; if (!is_array($values)) { - $values = array($values); + $values = [$values]; } unset ($values['count']); foreach ($values as $value) { @@ -535,19 +535,19 @@ class templateHandling $depends[$key][] = $m[2][0]; if (!isset($attrs[$m[2][0]])) { /* Dependency which has no value might be missing */ - $attrs[$m[2][0]] = array(); - $depends[$m[2][0]] = array(); + $attrs[$m[2][0]] = []; + $depends[$m[2][0]] = []; } } } } /* Flattens dependencies */ - $flatdepends = array(); - $errors = array(); + $flatdepends = []; + $errors = []; foreach ($depends as $key => $value) { static::flatDepends($flatdepends, $errors, $depends, $key); } - return array($flatdepends, $errors); + return [$flatdepends, $errors]; } /*! \brief Sort attrs depending of dependencies */ diff --git a/include/class_tests.inc b/include/class_tests.inc index 80d61e696..a74a0e8d8 100644 --- a/include/class_tests.inc +++ b/include/class_tests.inc @@ -179,7 +179,7 @@ class tests public static function is_ip_with_subnetmask($ip) { /* Generate list of valid submasks */ - $res = array(); + $res = []; for ($e = 0; $e <= 32; $e++) { $res[$e] = $e; } @@ -291,7 +291,7 @@ class tests public static function is_department_name_reserved($name) { global $config; - $reservedNames = array(); + $reservedNames = []; foreach ($config->data['OBJECTS'] as $infos) { if (isset($infos['ou'])) { if ($infos['ou'] != '') { diff --git a/include/class_timezone.inc b/include/class_timezone.inc index 315b1b5ca..2b8991aaf 100644 --- a/include/class_timezone.inc +++ b/include/class_timezone.inc @@ -77,9 +77,9 @@ class timezone $tz = $config->get_cfg_value('timezone'); $tz_delta = date('Z', $stamp); $tz_delta = $tz_delta / 3600; - return array('name' => $tz, 'value' => $tz_delta); + return ['name' => $tz, 'value' => $tz_delta]; } else { - return array('name' => 'unconfigured', 'value' => 0); + return ['name' => 'unconfigured', 'value' => 0]; } } diff --git a/include/class_userinfo.inc b/include/class_userinfo.inc index 430e8c000..55a0eac87 100644 --- a/include/class_userinfo.inc +++ b/include/class_userinfo.inc @@ -39,15 +39,15 @@ class userinfo var $givenName = ''; var $gidNumber = -1; var $language = ""; - var $subtreeACL = array(); - var $ACL = array(); - var $groups = array(); - var $roles = array(); - var $result_cache = array(); + var $subtreeACL = []; + var $ACL = []; + var $groups = []; + var $roles = []; + var $result_cache = []; var $ignoreACL = FALSE; - var $ACLperPath = array(); - var $ACLperPath_usesFilter = array(); + var $ACLperPath = []; + var $ACLperPath_usesFilter = []; /*! \brief LDAP size limit handler */ protected $sizeLimitHandler; @@ -73,7 +73,7 @@ class userinfo { global $config; $ldap = $config->get_ldap_link(); - $ldap->cat($this->dn, array('cn', 'sn', 'givenName', 'uid', 'gidNumber', 'preferredLanguage')); + $ldap->cat($this->dn, ['cn', 'sn', 'givenName', 'uid', 'gidNumber', 'preferredLanguage']); $attrs = $ldap->fetch(); $this->uid = $attrs['uid'][0]; @@ -107,7 +107,7 @@ class userinfo public function reset_acl_cache() { /* Initialize ACL_CACHE */ - session::set('ACL_CACHE', array()); + session::set('ACL_CACHE', []); } /*! @@ -116,42 +116,42 @@ class userinfo function loadACL() { global $config; - $this->ACL = array(); - $this->groups = array(); - $this->roles = array(); - $this->result_cache = array(); + $this->ACL = []; + $this->groups = []; + $this->roles = []; + $this->result_cache = []; $this->reset_acl_cache(); $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); /* Get member groups... */ - $ldap->search('(&(objectClass=groupOfNames)(member='.ldap_escape_f($this->dn).'))', array('dn')); + $ldap->search('(&(objectClass=groupOfNames)(member='.ldap_escape_f($this->dn).'))', ['dn']); while ($attrs = $ldap->fetch()) { $this->groups[$attrs['dn']] = $attrs['dn']; } /* Get member POSIX groups... */ - $ldap->search('(&(objectClass=posixGroup)(memberUid='.ldap_escape_f($this->uid).'))', array('dn')); + $ldap->search('(&(objectClass=posixGroup)(memberUid='.ldap_escape_f($this->uid).'))', ['dn']); while ($attrs = $ldap->fetch()) { $this->groups[$attrs['dn']] = $attrs['dn']; } /* Get member roles... */ - $ldap->search('(&(objectClass=organizationalRole)(roleOccupant='.ldap_escape_f($this->dn).'))', array('dn')); + $ldap->search('(&(objectClass=organizationalRole)(roleOccupant='.ldap_escape_f($this->dn).'))', ['dn']); while ($attrs = $ldap->fetch()) { $this->roles[$attrs['dn']] = $attrs['dn']; } /* Crawl through ACLs and move relevant to the tree */ - $ldap->search("(objectClass=gosaACL)", array('dn', 'gosaAclEntry')); - $aclp = array(); - $aclc = array(); + $ldap->search("(objectClass=gosaACL)", ['dn', 'gosaAclEntry']); + $aclp = []; + $aclc = []; while ($attrs = $ldap->fetch()) { /* Insert links in ACL array */ $aclp[$attrs['dn']] = substr_count($attrs['dn'], ','); - $aclc[$attrs['dn']] = array(); - $ol = array(); + $aclc[$attrs['dn']] = []; + $ol = []; for ($i = 0; $i < $attrs['gosaAclEntry']['count']; $i++) { $ol = array_merge($ol, acl::explodeAcl($attrs['gosaAclEntry'][$i])); } @@ -163,18 +163,18 @@ class userinfo foreach ($data as $prio => $aclc_value) { unset($aclc[$dn][$prio]); - $ldap->cat($aclc_value['acl'], array("gosaAclTemplate")); + $ldap->cat($aclc_value['acl'], ["gosaAclTemplate"]); $attrs = $ldap->fetch(); if (isset($attrs['gosaAclTemplate'])) { $roleAcls = acl::explodeRole($attrs['gosaAclTemplate']); foreach ($roleAcls as $roleAcl) { - $aclc[$dn][] = array( + $aclc[$dn][] = [ 'acl' => $roleAcl, 'type' => $aclc_value['type'], 'members' => $aclc_value['members'], 'filter' => $aclc_value['filter'] - ); + ]; } } } @@ -219,7 +219,7 @@ class userinfo if ($interresting) { if (!isset($this->ACL[$dn])) { - $this->ACL[$dn] = array(); + $this->ACL[$dn] = []; } $this->ACL[$dn][$idx] = $type; } @@ -240,7 +240,7 @@ class userinfo For object located in 'ou=dep1,ou=base' we have to both ACLs, for objects in 'ou=base' we only have to apply on ACL. */ - $without_self_acl = $all_acl = array(); + $without_self_acl = $all_acl = []; foreach ($this->ACL as $dn => $acl) { $sdn = $dn; do { @@ -403,11 +403,11 @@ class userinfo function get_snapshot_permissions($dn, $categories) { if (!is_array($categories)) { - $categories = array($categories); + $categories = [$categories]; } /* Possible permissions for snapshots */ - $objectPermissions = array('r', 'c', 'd'); - $attributePermissions = array('restore_over', 'restore_deleted'); + $objectPermissions = ['r', 'c', 'd']; + $attributePermissions = ['restore_over', 'restore_deleted']; foreach ($categories as $category) { $acl = $this->get_permissions($dn, $category.'/SnapshotHandler'); foreach ($objectPermissions as $i => $perm) { @@ -455,7 +455,7 @@ class userinfo if (isset($ACL_CACHE["$dn+$object+$attribute"])) { $ret = $ACL_CACHE["$dn+$object+$attribute"]; if ($skip_write) { - $ret = str_replace(array('w','c','d','m'), '', $ret); + $ret = str_replace(['w','c','d','m'], '', $ret); } return $ret; } @@ -485,7 +485,7 @@ class userinfo $ACL_CACHE["$orig_dn+$object+$attribute"] = $ret; } if ($skip_write) { - $ret = str_replace(array('w','c','d','m'), '', $ret); + $ret = str_replace(['w','c','d','m'], '', $ret); } return $ret; } @@ -494,7 +494,7 @@ class userinfo /* Get ldap object, for later filter checks */ $ldap = $config->get_ldap_link(); - $acl = array('r' => '', 'w' => '', 'c' => '', 'd' => '', 'm' => '', 'a' => ''); + $acl = ['r' => '', 'w' => '', 'c' => '', 'd' => '', 'm' => '', 'a' => '']; /* Build dn array */ $path = explode(',', $dn); @@ -630,7 +630,7 @@ class userinfo /* Remove write if needed */ if ($skip_write) { - $ret = str_replace(array('w','c','d','m'), '', $ret); + $ret = str_replace(['w','c','d','m'], '', $ret); } return $ret; } @@ -661,17 +661,17 @@ class userinfo $ACL_CACHE = &session::get_ref('ACL_CACHE'); if (!is_array($module)) { - $module = array($module); + $module = [$module]; } - $res = array(); + $res = []; foreach ($module as $mod) { if (isset($ACL_CACHE['MODULE_DEPARTMENTS'][$mod])) { $res = array_merge($res, $ACL_CACHE['MODULE_DEPARTMENTS'][$mod]); continue; } - $deps = array(); + $deps = []; /* Search for per object ACLs */ foreach ($this->ACL as $dn => $infos) { @@ -733,7 +733,7 @@ class userinfo */ function mergeACL($acl, $type, $newACL) { - $at = array("subtree" => "s", "one" => "1"); + $at = ["subtree" => "s", "one" => "1"]; if ((strpos($newACL, 'w') !== FALSE) && (strpos($newACL, 'r') === FALSE)) { $newACL .= "r"; @@ -897,8 +897,8 @@ class userinfo $current = floor(date("U") / 60 / 60 / 24); // Fetch required attributes - foreach (array('shadowExpire','shadowLastChange','shadowMax','shadowMin', - 'shadowInactive','shadowWarning','sambaKickoffTime') as $attr) { + foreach (['shadowExpire','shadowLastChange','shadowMax','shadowMin', + 'shadowInactive','shadowWarning','sambaKickoffTime'] as $attr) { $$attr = (isset($attrs[$attr][0]) ? $attrs[$attr][0] : NULL); } @@ -1002,7 +1002,7 @@ class userinfo function isBlacklisted($plugin) { global $config; - $blacklist = $config->get_cfg_value('PluginsMenuBlacklist', array()); + $blacklist = $config->get_cfg_value('PluginsMenuBlacklist', []); foreach ($blacklist as $item) { list ($group, $p) = explode('|', $item, 2); if ($plugin == $p) { @@ -1023,7 +1023,7 @@ class userinfo { global $config; - if (in_array_ics($attribute, array('objectClass', 'dn'))) { + if (in_array_ics($attribute, ['objectClass', 'dn'])) { return TRUE; } diff --git a/include/class_xml.inc b/include/class_xml.inc index aeec46690..93b549ee3 100644 --- a/include/class_xml.inc +++ b/include/class_xml.inc @@ -41,12 +41,12 @@ class xml { static function xml2array($contents, $get_attributes = 1, $priority = 'tag') { if (!$contents) { - return array(); + return []; } if (!function_exists('xml_parser_create')) { trigger_error('xml_parser_create function does not exists'); - return array(); + return []; } //Get the XML parser of PHP - PHP must have this module for the parser to work @@ -62,12 +62,12 @@ class xml { } //Initializations - $xml_array = array(); + $xml_array = []; $current = &$xml_array; //Refference //Go through the tags. - $repeated_tag_index = array();//Multiple tags with same name will be turned into an array + $repeated_tag_index = [];//Multiple tags with same name will be turned into an array foreach ($xml_values as $data) { unset($attributes, $value);//Remove existing values, or there will be trouble @@ -75,8 +75,8 @@ class xml { // tag(string), type(string), level(int), attributes(array). extract($data);//We could use the array by itself, but this cooler. - $result = array(); - $attributes_data = array(); + $result = []; + $attributes_data = []; if (isset($value)) { if ($priority == 'tag') { @@ -117,7 +117,7 @@ class xml { $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; $repeated_tag_index[$tag.'_'.$level]++; } else {//This section will make the value an array if multiple tags with the same name appear together - $current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array + $current[$tag] = [$current[$tag],$result];//This will combine the existing item and the new item together to make an array $repeated_tag_index[$tag.'_'.$level] = 2; if (isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well @@ -148,7 +148,7 @@ class xml { $repeated_tag_index[$tag.'_'.$level]++; } else { //If it is not an array... - $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value + $current[$tag] = [$current[$tag],$result]; //...Make it an array using using the existing value and the new value $repeated_tag_index[$tag.'_'.$level] = 1; if ($priority == 'tag' and $get_attributes) { if (isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well diff --git a/include/exporter/class_cvsExporter.inc b/include/exporter/class_cvsExporter.inc index 10f011720..284fa361b 100644 --- a/include/exporter/class_cvsExporter.inc +++ b/include/exporter/class_cvsExporter.inc @@ -43,7 +43,7 @@ class csvExporter * * \param array $columns */ - function __construct($headline, $header, $entries, $columns = array()) + function __construct($headline, $header, $entries, $columns = []) { // If no preset, render all columns if (!count($columns)) { @@ -90,7 +90,7 @@ class csvExporter */ static function getInfo() { - return array("exportCSV" => array( "label" => _("CSV"), "image" => "geticon.php?context=mimetypes&icon=text-csv&size=16", "class" => "csvExporter", "mime" => "text/x-csv", "filename" => "export.csv" )); + return ["exportCSV" => [ "label" => _("CSV"), "image" => "geticon.php?context=mimetypes&icon=text-csv&size=16", "class" => "csvExporter", "mime" => "text/x-csv", "filename" => "export.csv" ]]; } } diff --git a/include/exporter/class_pdfExporter.inc b/include/exporter/class_pdfExporter.inc index 75d3c396f..56cd04ce8 100644 --- a/include/exporter/class_pdfExporter.inc +++ b/include/exporter/class_pdfExporter.inc @@ -51,7 +51,7 @@ class pdfExporter * * \param array $columns */ - function __construct($headline, $header, $entries, $columns = array()) + function __construct($headline, $header, $entries, $columns = []) { // Bail out if no FPDF available if (!class_exists('FPDF')) { @@ -141,7 +141,7 @@ class pdfExporter */ function calcWidth($header, $entries, $columns) { - $width = array(); + $width = []; // Locate longest value for each column foreach ($columns as $index) { @@ -193,7 +193,7 @@ class pdfExporter // Check if class defined $classes = get_declared_classes(); if (in_array('FPDF', $classes)) { - return array("exportPDF" => array( "label" => _("PDF"), "image" => "geticon.php?context=mimetypes&icon=application-pdf&size=16", "class" => "pdfExporter", "mime" => "application/pdf", "filename" => "export.pdf" )); + return ["exportPDF" => [ "label" => _("PDF"), "image" => "geticon.php?context=mimetypes&icon=application-pdf&size=16", "class" => "pdfExporter", "mime" => "application/pdf", "filename" => "export.pdf" ]]; } else { return NULL; } diff --git a/include/functions.inc b/include/functions.inc index 1a9bd6138..fb4e41a80 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -53,7 +53,7 @@ define ('POSIX_DISALLOW_PASSWORD_CHANGE', 8); /* Rewrite german 'umlauts' and spanish 'accents' to get better results */ -$REWRITE = array( "ä" => "ae", +$REWRITE = [ "ä" => "ae", "ö" => "oe", "ü" => "ue", "Ä" => "Ae", @@ -71,7 +71,7 @@ $REWRITE = array( "ä" => "ae", "Ó" => "O", "Ú" => "U", "ñ" => "ny", - "Ñ" => "Ny" ); + "Ñ" => "Ny" ]; /*! @@ -274,14 +274,14 @@ function get_template_path($filename = '', $plugin = FALSE, $path = '') } else { $nf = preg_replace('!^'.$BASE_DIR.'/!', '', $path); } - $paths = array( + $paths = [ "$BASE_DIR/ihtml/themes/$theme/$nf/$filename", "$BASE_DIR/ihtml/themes/$default_theme/$nf/$filename", "$BASE_DIR/ihtml/themes/default/$nf/$filename", $path."/$filename" - ); + ]; } else { - $paths = array( + $paths = [ "themes/$theme/$filename", "$BASE_DIR/ihtml/themes/$theme/$filename", "themes/$default_theme/$filename", @@ -289,7 +289,7 @@ function get_template_path($filename = '', $plugin = FALSE, $path = '') "themes/default/$filename", "$BASE_DIR/ihtml/themes/default/$filename", $filename - ); + ]; } foreach ($paths as $path) { @@ -441,8 +441,8 @@ function ldap_get_user ($username) exit(); } - $allowed_attributes = array('uid','mail'); - $verify_attr = array(); + $allowed_attributes = ['uid','mail']; + $verify_attr = []; $tmp = explode(',', $config->get_cfg_value('loginAttribute')); foreach ($tmp as $attr) { if (in_array($attr, $allowed_attributes)) { @@ -451,7 +451,7 @@ function ldap_get_user ($username) } if (count($verify_attr) == 0) { - $verify_attr = array('uid'); + $verify_attr = ['uid']; } $tmp = $verify_attr; $tmp[] = 'uid'; @@ -526,7 +526,7 @@ function ldap_login_user ($username, $password) } if (class_available('ppolicyAccount')) { $ldap->cd($config->current['BASE']); - $ldap->search('(objectClass=*)', array(), 'one'); + $ldap->search('(objectClass=*)', [], 'one'); if (!$ldap->success()) { msg_dialog::display( _('Authentication error'), @@ -561,7 +561,7 @@ function add_lock($object, $user) don't need to remove any locks for them later. */ if (!session::is_set('LOCK_CACHE')) { - session::set('LOCK_CACHE', array('')); + session::set('LOCK_CACHE', ['']); } if (is_array($object)) { foreach ($object as $obj) { @@ -589,7 +589,7 @@ function add_lock($object, $user) $ldap = $config->get_ldap_link(); $ldap->cd(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']); $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($user).')(fdObjectDn='.base64_encode($object).'))', - array('fdUserDn')); + ['fdUserDn']); if (!$ldap->success()) { msg_dialog::display(_('Configuration error'), sprintf(_('Cannot create locking information in LDAP tree. Please contact your administrator!').'<br><br>'._('LDAP server returned: %s'), '<br><br><i>'.$ldap->get_error().'</i>'), ERROR_DIALOG); return; @@ -597,16 +597,16 @@ function add_lock($object, $user) /* Add lock if none present */ if ($ldap->count() == 0) { - $attrs = array(); + $attrs = []; $name = md5($object); $ldap->cd('cn='.$name.','.get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']); - $attrs = array( + $attrs = [ 'objectClass' => 'fdLockEntry', 'fdUserDn' => $user, 'fdObjectDn' => base64_encode($object), 'cn' => $name, 'fdLockTimestamp' => LdapGeneralizedTime::toString(new DateTime('now')), - ); + ]; $ldap->add($attrs); if (!$ldap->success()) { msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), "cn=$name,".get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'], 0), LDAP_ERROR); @@ -653,7 +653,7 @@ function del_lock ($object) /* Check for existance and remove the entry */ $ldap = $config->get_ldap_link(); $ldap->cd(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']); - $ldap->search('(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode($object).'))', array('fdObjectDn')); + $ldap->search('(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode($object).'))', ['fdObjectDn']); $attrs = $ldap->fetch(); if (!$ldap->success()) { msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), $ldap->getDN(), LDAP_DEL, ERROR_DIALOG)); @@ -681,7 +681,7 @@ function del_user_locks($userdn) $ldap->cd(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']); /* Remove all objects of this user, drop errors silently in this case. */ - $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($userdn).'))', array('fdUserDn')); + $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($userdn).'))', ['fdUserDn']); while ($attrs = $ldap->fetch()) { $ldap->rmdir($attrs['dn']); } @@ -754,7 +754,7 @@ function get_locks($objects, $allow_readonly = FALSE) } else { if ($allow_readonly && isset($_POST['open_readonly'])) { /* If readonly is allowed and asked and there is only one object, bypass lock detection */ - return array(); + return []; } $filter = '(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode($objects).'))'; } @@ -762,20 +762,20 @@ function get_locks($objects, $allow_readonly = FALSE) /* Get LDAP link, check for presence of the lock entry */ $ldap = $config->get_ldap_link(); $ldap->cd(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']); - $ldap->search($filter, array('fdUserDn','fdObjectDn', 'fdLockTimestamp')); + $ldap->search($filter, ['fdUserDn','fdObjectDn', 'fdLockTimestamp']); if (!$ldap->success()) { msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), '', LDAP_SEARCH), LDAP_ERROR); return FALSE; } - $locks = array(); + $locks = []; while ($attrs = $ldap->fetch()) { - $locks[] = array( + $locks[] = [ 'dn' => $attrs['dn'], 'object' => base64_decode($attrs['fdObjectDn'][0]), 'user' => $attrs['fdUserDn'][0], 'timestamp' => LdapGeneralizedTime::fromString($attrs['fdLockTimestamp'][0]), - ); + ]; } if (!is_array($objects) && (count($locks) > 1)) { @@ -881,7 +881,7 @@ function get_ou($name) { global $config; - $map = array( + $map = [ 'fusiondirectoryRDN' => 'ou=fusiondirectory,', 'lockRDN' => 'ou=locks,', 'recoveryTokenRDN' => 'ou=recovery,', @@ -931,7 +931,7 @@ function get_ou($name) 'dsaRDN' => 'ou=dsa,', 'mimetypeRDN' => 'ou=mime,' - ); + ]; /* Preset ou... */ if ($config->get_cfg_value($name, '_not_set_') != '_not_set_') { @@ -1054,9 +1054,9 @@ function gen_locked_message($locks, $dn, $allow_readonly = FALSE) /* Save variables from LOCK_VARS_TO_USE in session - for further editing */ if ( session::is_set('LOCK_VARS_TO_USE') && count(session::get('LOCK_VARS_TO_USE'))) { - $LOCK_VARS_USED_GET = array(); - $LOCK_VARS_USED_POST = array(); - $LOCK_VARS_USED_REQUEST = array(); + $LOCK_VARS_USED_GET = []; + $LOCK_VARS_USED_POST = []; + $LOCK_VARS_USED_REQUEST = []; $LOCK_VARS_TO_USE = session::get('LOCK_VARS_TO_USE'); foreach ($LOCK_VARS_TO_USE as $name) { @@ -1083,7 +1083,7 @@ function gen_locked_message($locks, $dn, $allow_readonly = FALSE) } } } - session::set('LOCK_VARS_TO_USE', array()); + session::set('LOCK_VARS_TO_USE', []); session::set('LOCK_VARS_USED_GET', $LOCK_VARS_USED_GET); session::set('LOCK_VARS_USED_POST', $LOCK_VARS_USED_POST); session::set('LOCK_VARS_USED_REQUEST', $LOCK_VARS_USED_REQUEST); @@ -1335,10 +1335,10 @@ function netmask_to_bits($netmask) */ function _recurse_gen_uids($rule, array $variables) { - $result = array(); + $result = []; if (!count($variables)) { - return array($rule); + return [$rule]; } reset($variables); @@ -1373,13 +1373,13 @@ function gen_uids($rule, $attributes) // Attributes should be arrays foreach ($attributes as $name => $value) { - $attributes[$name] = array($value); + $attributes[$name] = [$value]; } /* Search for keys and fill the variables array with all possible values for that key. */ $stripped = $rule; - $variables = array(); + $variables = []; for ($pos = 0; preg_match('/%([^%]+)%/', $stripped, $m, PREG_OFFSET_CAPTURE, $pos); ) { $variables[$pos] = templateHandling::parseMask($m[1][0], $attributes); @@ -1396,7 +1396,7 @@ function gen_uids($rule, $attributes) $ldap->cd($config->current['BASE']); /* Remove used uids and watch out for id tags */ - $ret = array(); + $ret = []; foreach ($proposed as $uid) { /* Check for id tag and modify uid if needed */ if (preg_match('/\{id(:|!)(\d+)}/', $uid, $m)) { @@ -1411,7 +1411,7 @@ function gen_uids($rule, $attributes) } $res = preg_replace('/{id(:|!)\d+}/', $number, $uid); - $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $res)).')', array('dn')); + $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $res)).')', ['dn']); if ($ldap->count() == 0) { $uid = $res; break; @@ -1428,7 +1428,7 @@ function gen_uids($rule, $attributes) while (TRUE) { $number = sprintf("%0".$size."d", random_int(0, pow(10, $size) - 1)); $res = preg_replace('/{id#(\d+)}/', $number, $uid); - $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $res)).')', array('dn')); + $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $res)).')', ['dn']); if ($ldap->count() == 0) { $uid = $res; break; @@ -1440,7 +1440,7 @@ function gen_uids($rule, $attributes) } /* Don't assign used ones */ - $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $uid)).')', array('dn')); + $ldap->search('(uid='.ldap_escape_f(preg_replace('/[{}]/', '', $uid)).')', ['dn']); if ($ldap->count() == 0) { /* Add uid, but remove {} first. These are invalid anyway. */ $uid = preg_replace('/[{}]/', '', $uid); @@ -1501,7 +1501,7 @@ function to_byte($value) */ function humanReadableSize ($bytes, $precision = 2) { - $format = array( + $format = [ _('%sB'), _('%sKiB'), _('%sMiB'), @@ -1511,7 +1511,7 @@ function humanReadableSize ($bytes, $precision = 2) _('%sEiB'), _('%sZiB'), _('%sYiB') - ); + ]; if ($bytes == 0) { return sprintf($format[0], '0'); } @@ -1632,7 +1632,7 @@ function scan_directory($path, $sort_desc = FALSE) if (is_readable($path)) { /* Get contents and write it into an array */ - $ret = array(); + $ret = []; $dir = opendir($path); @@ -1857,7 +1857,7 @@ function normalizeLdap($input) */ function check_schema($cfg) { - $checks = array(); + $checks = []; /* Get objectclasses */ $ldapObj = new LDAP($cfg['admin'], $cfg['password'], $cfg['connection'], FALSE, $cfg['tls']); @@ -1871,14 +1871,14 @@ function check_schema($cfg) /* This is the default block used for each entry. * to avoid unset indexes. */ - $def_check = array( + $def_check = [ 'SCHEMA_FILE' => '', - 'CLASSES_REQUIRED' => array(), + 'CLASSES_REQUIRED' => [], 'STATUS' => FALSE, 'IS_MUST_HAVE' => FALSE, 'MSG' => '', 'INFO' => '' - ); + ]; /* FusionDirectory core schemas */ @@ -1886,7 +1886,7 @@ function check_schema($cfg) $checks['core-fd'] = $def_check; $checks['core-fd']['SCHEMA_FILE'] = 'core-fd.schema'; - $checks['core-fd']['CLASSES_REQUIRED'] = array('fdLockEntry'); + $checks['core-fd']['CLASSES_REQUIRED'] = ['fdLockEntry']; $checks['core-fd']['IS_MUST_HAVE'] = TRUE; $checks['core-fd']['INFO'] = _('Main FusionDirectory schema'); @@ -1894,7 +1894,7 @@ function check_schema($cfg) $checks['core-fd-conf'] = $def_check; $checks['core-fd-conf']['SCHEMA_FILE'] = 'core-fd-conf.schema'; - $checks['core-fd-conf']['CLASSES_REQUIRED'] = array('fusionDirectoryConf'); + $checks['core-fd-conf']['CLASSES_REQUIRED'] = ['fusionDirectoryConf']; $checks['core-fd-conf']['IS_MUST_HAVE'] = TRUE; $checks['core-fd-conf']['INFO'] = _('Schema used to store FusionDirectory configuration'); @@ -1902,7 +1902,7 @@ function check_schema($cfg) $checks['ldapns'] = $def_check; $checks['ldapns']['SCHEMA_FILE'] = 'ldapns.schema'; - $checks['ldapns']['CLASSES_REQUIRED'] = array('hostObject'); + $checks['ldapns']['CLASSES_REQUIRED'] = ['hostObject']; $checks['ldapns']['IS_MUST_HAVE'] = FALSE; $checks['ldapns']['INFO'] = _('Used to store trust mode information in users or groups.'); @@ -1910,7 +1910,7 @@ function check_schema($cfg) $checks['template-fd'] = $def_check; $checks['template-fd']['SCHEMA_FILE'] = 'template-fd.schema'; - $checks['template-fd']['CLASSES_REQUIRED'] = array('fdTemplate'); + $checks['template-fd']['CLASSES_REQUIRED'] = ['fdTemplate']; $checks['template-fd']['IS_MUST_HAVE'] = FALSE; $checks['template-fd']['INFO'] = _('Used to store templates.'); @@ -1919,7 +1919,7 @@ function check_schema($cfg) $checks['nis'] = $def_check; $checks['nis']['SCHEMA_FILE'] = 'nis.schema'; - $checks['nis']['CLASSES_REQUIRED'] = array('posixAccount'); + $checks['nis']['CLASSES_REQUIRED'] = ['posixAccount']; $checks['nis']['IS_MUST_HAVE'] = FALSE; $checks['nis']['INFO'] = _('Used to store POSIX information.'); } @@ -1943,7 +1943,7 @@ function check_schema($cfg) $checks['posixGroup'] = $def_check; $checks['posixGroup']['SCHEMA_FILE'] = 'nis.schema'; - $checks['posixGroup']['CLASSES_REQUIRED'] = array('posixGroup'); + $checks['posixGroup']['CLASSES_REQUIRED'] = ['posixGroup']; $checks['posixGroup']['STATUS'] = TRUE; $checks['posixGroup']['MSG'] = ''; $checks['posixGroup']['INFO'] = ''; @@ -2022,13 +2022,13 @@ function change_password ($dn, $password, $hash = "") { $userTabs = objects::open($dn, 'user'); $userTab = $userTabs->getBaseObject(); - $userTab->userPassword = array( + $userTab->userPassword = [ $hash, $password, $password, $userTab->userPassword, $userTab->attributesAccess['userPassword']->isLocked() - ); + ]; $userTabs->save_object(); $error = $userTabs->save(); if (!empty($error)) { @@ -2043,13 +2043,13 @@ function lock_samba_account($mode, array $attrs) { global $config; if (!isset($attrs['sambaNTPassword'][0])) { - return array(); + return []; } - $modify = array('sambaNTPassword' => $attrs['sambaNTPassword'][0]); + $modify = ['sambaNTPassword' => $attrs['sambaNTPassword'][0]]; if ($config->get_cfg_value("sambaGenLMPassword", "FALSE") == "TRUE") { $modify['sambaLMPassword'] = $attrs['sambaLMPassword'][0]; } else { - $modify['sambaLMPassword'] = array(); + $modify['sambaLMPassword'] = []; } foreach ($modify as &$pwd) { if (is_array($pwd)) { @@ -2075,7 +2075,7 @@ function lock_ssh_account($mode, array $attrs, &$modify) if (!isset($attrs['sshPublicKey'])) { return; } - $modify['sshPublicKey'] = array(); + $modify['sshPublicKey'] = []; for ($i = 0; $i < $attrs['sshPublicKey']['count']; ++$i) { if ($mode == 'LOCK') { $modify['sshPublicKey'][] = preg_replace('/^/', 'disabled-', $attrs['sshPublicKey'][$i]); @@ -2109,7 +2109,7 @@ function getEntryCSN($dn) $attr = $config->get_cfg_value('modificationDetectionAttribute'); if ($attr != '') { $ldap = $config->get_ldap_link(); - $ldap->cat($dn, array($attr)); + $ldap->cat($dn, [$attr]); $csn = $ldap->fetch(); if (isset($csn[$attr][0])) { return $csn[$attr][0]; @@ -2293,7 +2293,7 @@ function mark($needle, $haystack) function reset_errors() { session::set('errors', ''); - session::set('errorsAlreadyPosted', array()); + session::set('errorsAlreadyPosted', []); session::set('LastError', ''); } @@ -2324,14 +2324,14 @@ if (!function_exists('ldap_escape')) { /* PHP version of ldap_escape for PHP<5.6 */ function ldap_escape($subject, $ignore = '', $flags = 0) { - static $charMaps = array( - LDAP_ESCAPE_FILTER => array('\\', '*', '(', ')', "\x00"), - LDAP_ESCAPE_DN => array('\\', ',', '=', '+', '<', '>', ';', '"', '#'), - ); + static $charMaps = [ + LDAP_ESCAPE_FILTER => ['\\', '*', '(', ')', "\x00"], + LDAP_ESCAPE_DN => ['\\', ',', '=', '+', '<', '>', ';', '"', '#'], + ]; // Pre-process the char maps on first call if (!isset($charMaps[0])) { - $charMaps[0] = array(); + $charMaps[0] = []; for ($i = 0; $i < 256; $i++) { $charMaps[0][chr($i)] = sprintf('\\%02x', $i); } @@ -2351,7 +2351,7 @@ if (!function_exists('ldap_escape')) { // Create the base char map to escape $flags = (int)$flags; - $charMap = array(); + $charMap = []; if ($flags & LDAP_ESCAPE_FILTER) { $charMap += $charMaps[LDAP_ESCAPE_FILTER]; } @@ -2467,7 +2467,7 @@ function mail_utf8($to, $from_user, $from_email, $subject, $message, $replyto_us function fopenWithErrorHandling() { $args = func_get_args(); - $errors = array(); + $errors = []; set_error_handler( function ($errno, $errstr, $errfile, $errline, $errcontext) use (&$errors) { diff --git a/include/functions_debug.inc b/include/functions_debug.inc index e0a29422d..73d2761d0 100644 --- a/include/functions_debug.inc +++ b/include/functions_debug.inc @@ -154,8 +154,8 @@ class printAClass { case 'string': if ($this->look_for_leading_tabs && preg_match('/^\t/m', $value)) { - $search = array('/\t/', "/\n/"); - $replace = array(' ','<br />'); + $search = ['/\t/', "/\n/"]; + $replace = [' ','<br />']; $value = preg_replace( $search, $replace, htmlspecialchars($value)); $value_style = 'color:black;border:1px gray dotted;'; } else { diff --git a/include/password-methods/class_password-methods-crypt.inc b/include/password-methods/class_password-methods-crypt.inc index 935ae1f7d..ac7c99793 100644 --- a/include/password-methods/class_password-methods-crypt.inc +++ b/include/password-methods/class_password-methods-crypt.inc @@ -116,7 +116,7 @@ class passwordMethodCrypt extends passwordMethod */ static function get_hash_name() { - $hashes = array(); + $hashes = []; if (CRYPT_STD_DES == 1) { $hashes[] = "crypt/standard-des"; } diff --git a/include/password-methods/class_password-methods-sasl.inc b/include/password-methods/class_password-methods-sasl.inc index 3f3f5ef2f..e84c20362 100644 --- a/include/password-methods/class_password-methods-sasl.inc +++ b/include/password-methods/class_password-methods-sasl.inc @@ -57,7 +57,7 @@ class passwordMethodsasl extends passwordMethod } else { $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - $ldap->cat($dn, array($attr)); + $ldap->cat($dn, [$attr]); if ($ldap->count() == 1) { $attrs = $ldap->fetch(); $this->uid = $attrs[$attr][0]; diff --git a/include/password-methods/class_password-methods.inc b/include/password-methods/class_password-methods.inc index 713f7adc1..acc7541e9 100644 --- a/include/password-methods/class_password-methods.inc +++ b/include/password-methods/class_password-methods.inc @@ -29,7 +29,7 @@ */ class passwordMethod { - var $attrs = array(); + var $attrs = []; var $display = FALSE; var $hash = ''; @@ -170,7 +170,7 @@ class passwordMethod // Call pre hooks $userClass = new user($dn); - $errors = $userClass->callHook('PRE'.$mode, array(), $ret); + $errors = $userClass->callHook('PRE'.$mode, [], $ret); if (!empty($errors)) { msg_dialog::displayChecks($errors); return FALSE; @@ -191,7 +191,7 @@ class passwordMethod // Call the password post-lock hook, if defined. if ($ldap->success()) { $userClass = new user($dn); - $errors = $userClass->callHook('POST'.$mode, array(), $ret); + $errors = $userClass->callHook('POST'.$mode, [], $ret); if (!empty($errors)) { msg_dialog::displayChecks($errors); } @@ -221,7 +221,7 @@ class passwordMethod if ($test->is_available()) { $plugs = $test->get_hash_name(); if (!is_array($plugs)) { - $plugs = array($plugs); + $plugs = [$plugs]; } foreach ($plugs as $plugname) { diff --git a/include/php_setup.inc b/include/php_setup.inc index 2bc9c961e..52531b460 100644 --- a/include/php_setup.inc +++ b/include/php_setup.inc @@ -44,15 +44,15 @@ function htmlunescape ($html) function html_trace($errstr = "") { - static $hideArgs = array( - 'ldap_init' => array(3), - 'ldap_login_user' => array(1), - 'change_password' => array(1), - 'cred_decrypt' => array(0,1), - 'LDAP/__construct' => array(1), - ); + static $hideArgs = [ + 'ldap_init' => [3], + 'ldap_login_user' => [1], + 'change_password' => [1], + 'cred_decrypt' => [0,1], + 'LDAP/__construct' => [1], + ]; if (!function_exists('debug_backtrace')) { - return array ('', ''); + return ['', '']; } $trace = array_slice(debug_backtrace(), 1); @@ -104,7 +104,7 @@ function html_trace($errstr = "") if (isset($hideArgs[$func])) { $hideArgsIndexes = $hideArgs[$func]; } else { - $hideArgsIndexes = array(); + $hideArgsIndexes = []; } $f = function ($index, $arg) use(&$f, $hideArgsIndexes) { static $i = 0; @@ -161,7 +161,7 @@ function html_trace($errstr = "") $return_html .= "</table>"; $return_mailto .= rawurlencode("=== /Trace ==="); - return array($return_html, $return_mailto); + return [$return_html, $return_mailto]; } /*! @@ -207,7 +207,7 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline) /* Write to syslog */ if (class_exists('logging') && !preg_match('/No such object/', $errstr)) { - logging::log('view', 'error', '', array(), "PHP error: $errstr ($errfile, line $errline)"); + logging::log('view', 'error', '', [], "PHP error: $errstr ($errfile, line $errline)"); } set_error_handler('gosaRaiseError', E_WARNING | E_NOTICE | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_STRICT); @@ -216,7 +216,7 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline) /* Send all errors to logging class, except "Ldap : No such object" messages*/ if (class_exists('logging') && !preg_match('/No such object/', $errstr)) { - logging::log('debug', 'all', $errfile, array(), 'Type:'.$errno.', Message:'.$errstr.', File:'.$errfile.', Line: '.$errline); + logging::log('debug', 'all', $errfile, [], 'Type:'.$errno.', Message:'.$errstr.', File:'.$errfile.', Line: '.$errline); } /* Create header as needed */ @@ -358,8 +358,8 @@ $smarty = new Smarty; $smarty->template_dir = $BASE_DIR.'/ihtml/'; $smarty->caching = FALSE; -$smarty->assign('css_files', array()); -$smarty->assign('js_files', array()); +$smarty->assign('css_files', []); +$smarty->assign('js_files', []); $smarty->php_handling = Smarty::PHP_REMOVE; diff --git a/include/select/class_filterLDAPBlacklist.inc b/include/select/class_filterLDAPBlacklist.inc index 6f533ebf7..4603e41b5 100644 --- a/include/select/class_filterLDAPBlacklist.inc +++ b/include/select/class_filterLDAPBlacklist.inc @@ -57,7 +57,7 @@ class filterLDAPBlacklist { if (isset($entry[$attr_name])) { $test = $entry[$attr_name]; if (!is_array($test)) { - $test = array($test); + $test = [$test]; } if (in_array($match, $test)) { unset($entries[$id]); diff --git a/include/select/groupSelect/class_groupSelect.inc b/include/select/groupSelect/class_groupSelect.inc index d1bc7a529..5234796a0 100644 --- a/include/select/groupSelect/class_groupSelect.inc +++ b/include/select/groupSelect/class_groupSelect.inc @@ -23,7 +23,7 @@ */ class groupSelect extends simpleSelectManagement { - protected $objectTypes = array('group'); + protected $objectTypes = ['group']; protected $autoFilter = FALSE; function __construct() diff --git a/include/select/objectSelect/class_objectSelect.inc b/include/select/objectSelect/class_objectSelect.inc index f76215238..4c805485f 100644 --- a/include/select/objectSelect/class_objectSelect.inc +++ b/include/select/objectSelect/class_objectSelect.inc @@ -23,12 +23,12 @@ */ class objectSelect extends userSelect { - protected $objectTypes = array( + protected $objectTypes = [ 'user', 'ogroup', 'application', 'terminal', 'workstation', 'server', 'printer', 'phone', 'simpleSecurityObject' - ); - protected $autoFilterAttributes = array('dn', 'cn', 'uid', 'description', 'mail'); + ]; + protected $autoFilterAttributes = ['dn', 'cn', 'uid', 'description', 'mail']; } ?> diff --git a/include/select/systemSelect/class_systemSelect.inc b/include/select/systemSelect/class_systemSelect.inc index 0ba3bf30e..3c65d2264 100644 --- a/include/select/systemSelect/class_systemSelect.inc +++ b/include/select/systemSelect/class_systemSelect.inc @@ -23,9 +23,9 @@ */ class systemSelect extends simpleSelectManagement { - protected $autoFilterAttributes = array('dn', 'cn', 'ipHostNumber', 'macAddress'); - protected $objectTypes = array( + protected $autoFilterAttributes = ['dn', 'cn', 'ipHostNumber', 'macAddress']; + protected $objectTypes = [ 'terminal', 'workstation', 'server' - ); + ]; } ?> diff --git a/include/select/userGroupSelect/class_userGroupSelect.inc b/include/select/userGroupSelect/class_userGroupSelect.inc index 70667205b..4052d7a5e 100644 --- a/include/select/userGroupSelect/class_userGroupSelect.inc +++ b/include/select/userGroupSelect/class_userGroupSelect.inc @@ -23,13 +23,13 @@ */ class userGroupSelect extends userSelect { - protected $objectTypes = array('user', 'group'); - protected $autoFilterAttributes = array('dn', 'cn', 'uid', 'description', 'mail'); + protected $objectTypes = ['user', 'group']; + protected $autoFilterAttributes = ['dn', 'cn', 'uid', 'description', 'mail']; function __construct() { if (class_available('mixedGroup')) { - $this->objectTypes = array('user', 'ogroup'); + $this->objectTypes = ['user', 'ogroup']; } parent::__construct(); } @@ -40,6 +40,6 @@ class userGroupSelect extends userSelect */ class userGroupRoleSelect extends userGroupSelect { - protected $objectTypes = array('user', 'group', 'role', 'ogroup'); + protected $objectTypes = ['user', 'group', 'role', 'ogroup']; } ?> diff --git a/include/select/userSelect/class_userSelect.inc b/include/select/userSelect/class_userSelect.inc index 536f9adb7..2d9640afa 100644 --- a/include/select/userSelect/class_userSelect.inc +++ b/include/select/userSelect/class_userSelect.inc @@ -23,22 +23,22 @@ */ class userSelect extends simpleSelectManagement { - protected $objectTypes = array('user'); - protected $autoFilterAttributes = array('dn', 'cn', 'uid', 'description', 'mail'); + protected $objectTypes = ['user']; + protected $autoFilterAttributes = ['dn', 'cn', 'uid', 'description', 'mail']; function parseXML ($file) { $data = parent::parseXML($file); $data['list']['table']['layout'] = '|20px;c||||'; - $columns = array ( - array ( + $columns = [ + [ 'label' => _('Login'), 'sortAttribute' => 'uid', 'sortType' => 'string', 'value' => '%{filter:selectLink(pid,row,dn,uid)}', 'export' => 'true', - ), - ); + ], + ]; array_splice($data['list']['table']['column'], 2, 0, $columns); return $data; } diff --git a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc index 668edb68c..2ee2c567d 100644 --- a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc +++ b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc @@ -155,9 +155,9 @@ class BaseSelectorAttribute extends Attribute if ($this->disabled) { $display = $this->renderInputField( 'text', '', - array( + [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ) + ] ); } else { $display = '{literal}'.$this->baseSelector->render().'{/literal}'; diff --git a/include/simpleplugin/attributes/class_BooleanAttribute.inc b/include/simpleplugin/attributes/class_BooleanAttribute.inc index 4930296bb..e9a8f6f6c 100644 --- a/include/simpleplugin/attributes/class_BooleanAttribute.inc +++ b/include/simpleplugin/attributes/class_BooleanAttribute.inc @@ -93,7 +93,7 @@ class BooleanAttribute extends Attribute function renderFormInput () { $id = $this->getHtmlId(); - $attributes = ($this->value ? array('checked' => 'checked') : array()); + $attributes = ($this->value ? ['checked' => 'checked'] : []); if ($this->submitForm) { $js = 'document.mainform.submit();'; $attributes['onChange'] = 'javascript:'.htmlentities($js, ENT_COMPAT, 'UTF-8'); @@ -174,7 +174,7 @@ class ObjectClassBooleanAttribute extends BooleanAttribute if (is_array($objectclasses)) { $this->objectclasses = $objectclasses; } else { - $this->objectclasses = array($objectclasses); + $this->objectclasses = [$objectclasses]; } parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl); $this->setInLdap(FALSE); diff --git a/include/simpleplugin/attributes/class_CompositeAttribute.inc b/include/simpleplugin/attributes/class_CompositeAttribute.inc index b21936fba..d24033911 100644 --- a/include/simpleplugin/attributes/class_CompositeAttribute.inc +++ b/include/simpleplugin/attributes/class_CompositeAttribute.inc @@ -95,7 +95,7 @@ class CompositeAttribute extends Attribute $res = preg_match($this->readFormat, $value, $m); if ($res === 1) { $m = array_slice($m, 1); - $values = array(); + $values = []; foreach (array_keys($this->attributes) as $name) { if (isset($m[$name])) { $values[] = $m[$name]; @@ -250,7 +250,7 @@ class CompositeAttribute extends Attribute } } else { parent::serializeAttribute($attributes, $form); - $subattributes = array(); + $subattributes = []; foreach ($this->attributes as &$attribute) { $attribute->setDisabled($this->disabled); $attribute->serializeAttribute($subattributes, $form); @@ -276,7 +276,7 @@ class CompositeAttribute extends Attribute public function htmlIds() { - $ret = array(); + $ret = []; foreach ($this->attributes as &$attribute) { $ret = array_merge($ret, $attribute->htmlIds()); } diff --git a/include/simpleplugin/attributes/class_DateAttribute.inc b/include/simpleplugin/attributes/class_DateAttribute.inc index 3f573223f..5e104bcf6 100644 --- a/include/simpleplugin/attributes/class_DateAttribute.inc +++ b/include/simpleplugin/attributes/class_DateAttribute.inc @@ -143,10 +143,10 @@ class DateAttribute extends Attribute $id = $this->getHtmlId(); $display = $this->renderInputField( 'text', $id, - array( + [ 'value' => '{literal}'.$this->getValue().'{/literal}', 'class' => 'date' - ) + ] ); $display .= '{if $'.$this->getAcl().'ACL|regex_replace:"/[cdmr]/":"" == "w"}'. '<script type="text/javascript"> @@ -195,7 +195,7 @@ class TimeHisAttribute extends CompositeAttribute function __construct($label, $description, $ldapName, $required, $convert = TRUE, $acl = '') { $this->convert = $convert; - $attributes = array( + $attributes = [ new IntAttribute ( '', _('Hours'), $ldapName.'_hours', TRUE, @@ -211,7 +211,7 @@ class TimeHisAttribute extends CompositeAttribute $ldapName.'_seconds', TRUE, 0, 59, 0 ) - ); + ]; parent::__construct($description, $ldapName, $attributes, '/^(\d\d)(\d\d)(\d\d)$/', '%02d%02d%02d', $acl, $label); $this->setLinearRendering(TRUE); } @@ -269,7 +269,7 @@ class TimeHiAttribute extends TimeHisAttribute function __construct($label, $description, $ldapName, $required, $convert = TRUE, $acl = '') { $this->convert = $convert; - $attributes = array( + $attributes = [ new IntAttribute ( '', _('Hours'), $ldapName.'_hours', TRUE, @@ -280,7 +280,7 @@ class TimeHiAttribute extends TimeHisAttribute $ldapName.'_minutes', TRUE, 0, 59, 0 ) - ); + ]; CompositeAttribute::__construct($description, $ldapName, $attributes, '/^(\d\d)(\d\d)$/', '%02d%02d', $acl, $label); $this->setLinearRendering(TRUE); } @@ -293,7 +293,7 @@ class DateTimeAttribute extends CompositeAttribute { function __construct($label, $description, $ldapName, $required, $acl = '') { - $attributes = array( + $attributes = [ new DateAttribute( _('Date'), '', $ldapName.'_date', $required, @@ -305,7 +305,7 @@ class DateTimeAttribute extends CompositeAttribute $ldapName.'_time', $required, FALSE ) - ); + ]; parent::__construct($description, $ldapName, $attributes, '/^(\d{8})(\d{6})$/', '%s%s', $acl, $label); } } diff --git a/include/simpleplugin/attributes/class_FileAttribute.inc b/include/simpleplugin/attributes/class_FileAttribute.inc index a9475f781..54ff0aa08 100644 --- a/include/simpleplugin/attributes/class_FileAttribute.inc +++ b/include/simpleplugin/attributes/class_FileAttribute.inc @@ -162,17 +162,17 @@ class FileDownloadAttribute extends FileAttribute $display = ''; if ($this->upload) { $display .= $this->renderInputField('file', $id); - $display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload'))); + $display .= $this->renderInputField('submit', 'upload'.$id, ['value' => _('Upload')]); } if ($this->download) { $display .= $this->renderInputField( 'image', 'download'.$id, - array( + [ 'title' => _('Download'), 'alt' => _('Download'), 'class' => 'center', 'src' => 'geticon.php?context=actions&icon=document-save&size=16', - ) + ] ); } return $this->renderAcl($display); @@ -181,7 +181,7 @@ class FileDownloadAttribute extends FileAttribute public function htmlIds() { $id = $this->getHtmlId(); - $ids = array(); + $ids = []; if ($this->download) { $ids[] = 'download'.$id; } @@ -250,7 +250,7 @@ class FileTextAreaAttribute extends FileDownloadAttribute function fixPostValue ($value) { /* Replace CRLF by LF, to avoid non-ASCII chars */ - return str_replace(array("\r\n", "\r"), "\n", $value); + return str_replace(["\r\n", "\r"], "\n", $value); } function renderFormInput () @@ -412,22 +412,22 @@ class ImageAttribute extends FileAttribute $display .= $this->renderInputField('file', $id); $display .= $this->renderInputField( 'image', $id.'_upload', - array( + [ 'class' => 'center', 'src' => 'geticon.php?context=actions&icon=upload&size=16', 'title' => _('Upload'), 'alt' => _('Upload') - ) + ] ); if (!$this->isRequired()) { $display .= $this->renderInputField( 'image', $id.'_remove', - array( + [ 'class' => 'center', 'src' => 'geticon.php?context=actions&icon=remove&size=16', 'title' => _('Remove'), 'alt' => _('Remove') - ) + ] ); } if (($this->getValue() == '') && ($this->placeholder != '')) { @@ -442,7 +442,7 @@ class ImageAttribute extends FileAttribute public function htmlIds() { $id = $this->getHtmlId(); - return array($id.'_img',$id,'upload'.$id); + return [$id.'_img',$id,'upload'.$id]; } /*! \brief Fill LDAP value in the attrs array @@ -458,7 +458,7 @@ class ImageAttribute extends FileAttribute } $attrs[$this->getLdapName()] = $value; } else { - $attrs[$this->getLdapName()] = array(); + $attrs[$this->getLdapName()] = []; } } } diff --git a/include/simpleplugin/attributes/class_IntAttribute.inc b/include/simpleplugin/attributes/class_IntAttribute.inc index fe851ad2a..9ab048fca 100644 --- a/include/simpleplugin/attributes/class_IntAttribute.inc +++ b/include/simpleplugin/attributes/class_IntAttribute.inc @@ -92,9 +92,9 @@ class IntAttribute extends Attribute function renderFormInput () { $id = $this->getHtmlId(); - $attributes = array( + $attributes = [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ); + ]; if ($this->min !== FALSE) { $attributes['min'] = $this->min; } @@ -117,9 +117,9 @@ class IntAttribute extends Attribute $id = $this->getHtmlId(); $display = $this->renderInputField( 'text', $id, - array( + [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ) + ] ); return $this->renderAcl($display); } diff --git a/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc b/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc index 8b63d683c..c08350d28 100644 --- a/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc +++ b/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc @@ -24,23 +24,23 @@ class phoneSelect extends simpleSelectManagement { protected $multiSelect = FALSE; - protected $autoFilterAttributes = array('dn','cn','ipHostNumber','macAddress','telephoneNumber'); - protected $objectTypes = array('phone'); + protected $autoFilterAttributes = ['dn','cn','ipHostNumber','macAddress','telephoneNumber']; + protected $objectTypes = ['phone']; function parseXML ($file) { $data = parent::parseXML($file); /* Add column for phone number */ $data['list']['table']['layout'] .= '|'; - $columns = array ( - array ( + $columns = [ + [ 'label' => _('Number'), 'sortAttribute' => 'telephoneNumber', 'sortType' => 'string', 'value' => '%{filter:selectLink(pid,row,dn,telephoneNumber)}', 'export' => 'true', - ), - ); + ], + ]; array_splice($data['list']['table']['column'], 2, 0, $columns); return $data; } @@ -58,7 +58,7 @@ class phoneSelect extends simpleSelectManagement */ class mobilePhoneSelect extends phoneSelect { - protected $objectTypes = array('mobilePhone'); + protected $objectTypes = ['mobilePhone']; } /*! @@ -66,7 +66,7 @@ class mobilePhoneSelect extends phoneSelect */ class anyPhoneSelect extends phoneSelect { - protected $objectTypes = array('phone','mobilePhone'); + protected $objectTypes = ['phone','mobilePhone']; } /*! @@ -138,12 +138,12 @@ class PhoneNumberButtonAttribute extends PhoneNumberAttribute if ($this->type !== FALSE) { $display .= $this->renderAcl($this->renderInputField( 'image', $id.'_edit', - array( + [ 'class' => 'center', 'src' => 'geticon.php?context=actions&icon=document-edit&size=16', 'title' => _('Edit'), 'alt' => _('Edit') - ) + ] )); } return $display; diff --git a/include/simpleplugin/attributes/class_SelectAttribute.inc b/include/simpleplugin/attributes/class_SelectAttribute.inc index 58eeb1f00..b3ac11de3 100644 --- a/include/simpleplugin/attributes/class_SelectAttribute.inc +++ b/include/simpleplugin/attributes/class_SelectAttribute.inc @@ -43,7 +43,7 @@ class SelectAttribute extends Attribute * \param array $outputs The labels corresponding to the choices, leave to NULL if you want to display the choices themselves * \param string $acl The name of the acl for this attribute if he does not use its own. (Leave empty if he should use its own like most attributes do) */ - function __construct ($label, $description, $ldapName, $required = FALSE, $choices = array(), $defaultValue = "", $outputs = NULL, $acl = "") + function __construct ($label, $description, $ldapName, $required = FALSE, $choices = [], $defaultValue = "", $outputs = NULL, $acl = "") { if (!in_array($defaultValue, $choices, TRUE) && isset($choices[0])) { $defaultValue = $choices[0]; @@ -90,7 +90,7 @@ class SelectAttribute extends Attribute */ function setDisplayChoices ($values) { - $this->outputs = array(); + $this->outputs = []; $values = array_values($values); $i = 0; foreach ($this->choices as $choice) { @@ -234,7 +234,7 @@ class ObjectSelectAttribute extends SelectAttribute function __construct ($label, $description, $ldapName, $required, $objectType, $objectAttrs = NULL, $objectFilter = '', $acl = "") { - parent::__construct($label, $description, $ldapName, $required, array(), "", NULL, $acl); + parent::__construct($label, $description, $ldapName, $required, [], "", NULL, $acl); $this->objectType = $objectType; $this->objectAttrs = $objectAttrs; $this->objectFilter = $objectFilter; diff --git a/include/simpleplugin/attributes/class_SetAttribute.inc b/include/simpleplugin/attributes/class_SetAttribute.inc index 0101290fc..d206b8d1c 100644 --- a/include/simpleplugin/attributes/class_SetAttribute.inc +++ b/include/simpleplugin/attributes/class_SetAttribute.inc @@ -35,7 +35,7 @@ class SetAttribute extends Attribute * \param array $values The default values * \param boolean $valueUnicity Should the value unicity be checked */ - function __construct ($attribute, $values = array(), $valueUnicity = TRUE) + function __construct ($attribute, $values = [], $valueUnicity = TRUE) { parent::__construct( $attribute->getLabel(), $attribute->getDescription(), @@ -60,7 +60,7 @@ class SetAttribute extends Attribute protected function loadAttrValue ($attrs) { if (isset($attrs[$this->getLdapName()]["count"])) { - $this->value = array(); + $this->value = []; for ($i = 0; $i < $attrs[$this->getLdapName()]["count"]; $i++) { $this->value[] = $attrs[$this->getLdapName()][$i]; } @@ -222,20 +222,20 @@ class SetAttribute extends Attribute if ($this->linearRendering || $readOnly) { parent::renderAttribute($attributes, $readOnly); } else { - $attributes[$this->getLdapName()] = array( + $attributes[$this->getLdapName()] = [ 'htmlid' => $this->getForHtmlId(), 'label' => '{literal}'.$this->getLabel().'{/literal}'.($this->isRequired() ? '{$must}' : ''), 'description' => ($this->isRequired() ? sprintf(_("%s (required)"), $this->getDescription()) : $this->getDescription()), 'input' => $this->renderAcl($this->renderOnlyFormInput()), - ); + ]; $this->handleEditingValue(); $this->attribute->renderAttribute($attributes, $readOnly); - $attributes[$this->getLdapName().'_buttons'] = array( + $attributes[$this->getLdapName().'_buttons'] = [ 'htmlid' => 'add'.$this->getHtmlId(), 'label' => '', 'description' => '', 'input' => $this->renderAcl($this->renderButtons()), - ); + ]; } } } @@ -249,7 +249,7 @@ class SetAttribute extends Attribute if ($form) { return; } else { - $subattributes = array(); + $subattributes = []; $this->attribute->setDisabled($this->disabled); $this->attribute->serializeAttribute($subattributes, $form); $attributes[$this->getLdapName()]['attributes'] = $subattributes; @@ -270,8 +270,8 @@ class SetAttribute extends Attribute function renderButtons () { $id = $this->getHtmlId(); - $buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}')); - $buttons .= $this->renderInputField('submit', 'del'.$id, array('value' => '{msgPool type=delButton}')); + $buttons = $this->renderInputField('submit', 'add'.$id, ['value' => '{msgPool type=addButton}']); + $buttons .= $this->renderInputField('submit', 'del'.$id, ['value' => '{msgPool type=delButton}']); return $buttons; } @@ -283,7 +283,7 @@ class SetAttribute extends Attribute public function htmlIds() { $id = $this->getHtmlId(); - return array_merge(array('add'.$id,'del'.$id,'row'.$id), $this->attribute->htmlIds()); + return array_merge(['add'.$id,'del'.$id,'row'.$id], $this->attribute->htmlIds()); } /*! \brief Set the parent plugin for this attribute @@ -300,10 +300,10 @@ class SetAttribute extends Attribute function getArrayValues() { - $result = array(); + $result = []; foreach ($this->value as $value) { $this->attribute->setValue($value); - $row = array(); + $row = []; foreach ($this->attribute->getArrayValue() as $val) { $row[] = $val; } @@ -371,7 +371,7 @@ class OrderedArrayAttribute extends SetAttribute * \param array $values The default values * \param boolean $edit_enabled Can the values be edited */ - function __construct ($attribute, $order = TRUE, $values = array(), $edit_enabled = FALSE) + function __construct ($attribute, $order = TRUE, $values = [], $edit_enabled = FALSE) { parent::__construct($attribute, $values); $this->order = $order; @@ -408,7 +408,7 @@ class OrderedArrayAttribute extends SetAttribute function computeLdapValue () { - $ldapValue = array(); + $ldapValue = []; foreach ($this->value as $key => $value) { $ldapValue[] = $this->writeValue($key, $value); } @@ -418,7 +418,7 @@ class OrderedArrayAttribute extends SetAttribute protected function loadAttrValue ($attrs) { if (isset($attrs[$this->getLdapName()]["count"])) { - $this->value = array(); + $this->value = []; for ($i = 0; $i < $attrs[$this->getLdapName()]["count"]; $i++) { $value = $this->readValue($attrs[$this->getLdapName()][$i]); if (is_array($value)) { @@ -441,12 +441,12 @@ class OrderedArrayAttribute extends SetAttribute $div->SetHeight($this->height); $div->SetHeaders($this->headers); foreach ($this->value as $key => $value) { - $fields = array(); + $fields = []; foreach ($this->getAttributeArrayValue($key, $value) as $field) { if (is_array($field)) { $fields[] = $field; } else { - $fields[] = array('string' => $field); + $fields[] = ['string' => $field]; } } if (empty($fields)) { @@ -455,7 +455,7 @@ class OrderedArrayAttribute extends SetAttribute list ($img, $nbicons) = $this->genRowIcons($key, $value); - $fields[] = array("html" => $img, "attach" => 'style="border:0px;width:'.($nbicons * 20).'px;"'); + $fields[] = ["html" => $img, "attach" => 'style="border:0px;width:'.($nbicons * 20).'px;"']; $div->AddEntry($fields); } $smarty->assign("div_$id", $div->DrawList()); @@ -474,12 +474,12 @@ class OrderedArrayAttribute extends SetAttribute if ($key != 0) { $img .= $this->renderInputField( 'image', $id.'_up_'.$key, - array( + [ 'src' => 'geticon.php?context=actions&icon=view-sort-descending&size=16', 'title' => _('Sort up'), 'alt' => _('Sort up'), 'class' => 'center' - ) + ] ); } else { $img .= '<img src="images/empty.png" alt="" style="width:16px;"/>'; @@ -487,12 +487,12 @@ class OrderedArrayAttribute extends SetAttribute if (($key + 1) < count($this->value)) { $img .= $this->renderInputField( 'image', $id.'_down_'.$key, - array( + [ 'src' => 'geticon.php?context=actions&icon=view-sort-ascending&size=16', 'title' => _('Sort down'), 'alt' => _('Sort down'), 'class' => 'center' - ) + ] ); } else { $img .= '<img src="images/empty.png" alt="" style="width:16px;"/>'; @@ -502,25 +502,25 @@ class OrderedArrayAttribute extends SetAttribute $nbicons++; $img .= $this->renderInputField( 'image', $id.'_edit_'.$key, - array( + [ 'src' => 'geticon.php?context=actions&icon=document-edit&size=16', 'title' => _('Edit'), 'alt' => _('Edit'), 'class' => 'center' - ) + ] ); } $img .= $this->renderInputField( 'image', $id.'_del_'.$key, - array( + [ 'src' => 'geticon.php?context=actions&icon=edit-delete&size=16', 'title' => _('Delete'), 'alt' => _('Delete'), 'class' => 'center' - ) + ] ); - return array ($img, $nbicons); + return [$img, $nbicons]; } protected function getAttributeArrayValue($key, $value) @@ -627,7 +627,7 @@ class OrderedArrayAttribute extends SetAttribute public function htmlIds() { $id = $this->getHtmlId(); - $ids = array('add'.$id); + $ids = ['add'.$id]; if ($this->attribute !== FALSE) { $ids = array_merge($ids, $this->attribute->htmlIds()); } @@ -649,7 +649,7 @@ class OrderedArrayAttribute extends SetAttribute function renderButtons () { $id = $this->getHtmlId(); - $buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}')); + $buttons = $this->renderInputField('submit', 'add'.$id, ['value' => '{msgPool type=addButton}']); return $buttons; } } @@ -662,9 +662,9 @@ class SubNodesAttribute extends OrderedArrayAttribute protected $objectClass; protected $objectClasses; - function __construct ($label, $description, $ldapName, $objectClass, $attributes, $order = FALSE, $values = array(), $edit_enabled = FALSE, $acl = "") + function __construct ($label, $description, $ldapName, $objectClass, $attributes, $order = FALSE, $values = [], $edit_enabled = FALSE, $acl = "") { - $attributes_keys = array(); + $attributes_keys = []; foreach ($attributes as $attribute) { $attributes_keys[$attribute->getLdapName()] = $attribute; $attributes_keys[$attribute->getLdapName()]->htmlid_prefix = $ldapName.'_'; @@ -681,7 +681,7 @@ class SubNodesAttribute extends OrderedArrayAttribute $this->objectClasses = $objectClass; } else { $this->objectClass = $objectClass; - $this->objectClasses = array($objectClass); + $this->objectClasses = [$objectClass]; } } @@ -692,8 +692,8 @@ class SubNodesAttribute extends OrderedArrayAttribute if (isset($attrs['dn'])) { $ldap = $config->get_ldap_link(); $ldap->cd($attrs['dn']); - $ldap->search('objectClass='.$this->objectClass, array('*'), 'one'); - $this->value = array(); + $ldap->search('objectClass='.$this->objectClass, ['*'], 'one'); + $this->value = []; while ($subattrs = $ldap->fetch()) { $this->attribute->resetToDefault(); foreach ($this->attribute->attributes as &$attribute) { @@ -715,8 +715,8 @@ class SubNodesAttribute extends OrderedArrayAttribute { /* First delete all old nodes */ $ldap->cd($this->plugin->dn); - $ldap->search('objectClass='.$this->objectClass, array('dn'), 'one'); - $delete = array(); + $ldap->search('objectClass='.$this->objectClass, ['dn'], 'one'); + $delete = []; while ($attrs = $ldap->fetch()) { $delete[] = $attrs['dn']; } @@ -725,7 +725,7 @@ class SubNodesAttribute extends OrderedArrayAttribute } /* Then add our values */ foreach ($this->value as $val) { - $attrs = array('objectClass' => $this->objectClasses); + $attrs = ['objectClass' => $this->objectClasses]; $this->attribute->setValue($val); foreach ($this->attribute->attributes as &$attribute) { $attribute->fillLdapValue($attrs); diff --git a/include/simpleplugin/attributes/class_StringAttribute.inc b/include/simpleplugin/attributes/class_StringAttribute.inc index 19906142b..452239369 100644 --- a/include/simpleplugin/attributes/class_StringAttribute.inc +++ b/include/simpleplugin/attributes/class_StringAttribute.inc @@ -59,9 +59,9 @@ class StringAttribute extends Attribute function renderFormInput () { $id = $this->getHtmlId(); - $attributes = array( + $attributes = [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ); + ]; if (!empty($this->managedAttributes)) { $js = $this->managedAttributesJS(); $attributes['onChange'] = 'javascript:'.htmlentities($js, ENT_COMPAT, 'UTF-8'); @@ -76,7 +76,7 @@ class StringAttribute extends Attribute function fixPostValue ($value) { /* Replace CRLF by LF, to avoid non-ASCII chars in multiline values (mainly useful for textarea) */ - return str_replace(array("\r\n", "\r"), "\n", $value); + return str_replace(["\r\n", "\r"], "\n", $value); } function check () @@ -160,10 +160,10 @@ class PasswordAttribute extends StringAttribute $id = $this->getHtmlId(); $display = $this->renderInputField( 'password', $id, - array( + [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}', 'autocomplete' => ($this->autocomplete ? 'on' : 'off'), - ) + ] ); if ($this->autocomplete === FALSE) { $display = '{literal}<input autocomplete="off" value="foolautocompleteworkaround" type="text" style="display:none;"/>{/literal}'.$display; diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc index 45c49ad0f..be4b7a959 100644 --- a/include/simpleplugin/class_Attribute.inc +++ b/include/simpleplugin/class_Attribute.inc @@ -75,12 +75,12 @@ class Attribute protected $plugin; /* \brief Array of attributes to manage (prefix => value => attribute) * Prefix should be 'erase' or 'disable' */ - protected $managedAttributes = array(); + protected $managedAttributes = []; /* \brief Array of multiple values groups for managed attributes */ - protected $managedAttributesMultipleValues = array(); + protected $managedAttributesMultipleValues = []; /* \bried Array of booleans telling for each managing attributes if he's disabling us */ - protected $managingAttributesOrders = array(); + protected $managingAttributesOrders = []; /*! \brief The constructor of Attribute * @@ -201,7 +201,7 @@ class Attribute /* Return the value as an array of values to be displayed in a table columns */ function getArrayValue () { - return array($this->displayValue($this->getValue())); + return [$this->displayValue($this->getValue())]; } function getLdapName () @@ -352,7 +352,7 @@ class Attribute $this->managedAttributesMultipleValues = $mAttributes['multiplevalues']; unset($mAttributes['multiplevalues']); } else { - $this->managedAttributesMultipleValues = array(); + $this->managedAttributesMultipleValues = []; } $this->managedAttributes = $mAttributes; $this->manageAttributes($this->getValue()); @@ -420,7 +420,7 @@ class Attribute if ($value !== '') { $attrs[$this->getLdapName()] = $value; } else { - $attrs[$this->getLdapName()] = array(); + $attrs[$this->getLdapName()] = []; } } } @@ -440,7 +440,7 @@ class Attribute continue; } foreach ($attributes as $attribute) { - $attrs[$attribute] = array(); + $attrs[$attribute] = []; } } } @@ -452,11 +452,11 @@ class Attribute { global $config; $value = $this->getValue(); - if ($this->isRequired() && !$this->disabled && (($value === "") || ($value === array()))) { + if ($this->isRequired() && !$this->disabled && (($value === "") || ($value === []))) { return msgPool::required($this->getLabel()); } elseif (($this->unique !== FALSE) && !$this->disabled) { $value = $this->computeLdapValue(); - if (($value === "") || ($value === array())) { + if (($value === "") || ($value === [])) { return; } $ldap = $config->get_ldap_link(); @@ -497,10 +497,10 @@ class Attribute $filters[] = $pluginFilter; } } else { - $filters = array($this->uniqueFilter); + $filters = [$this->uniqueFilter]; } $filter = '(&'.$filter.implode($filters).')'; - $ldap->search($filter, array($this->getLdapName())); + $ldap->search($filter, [$this->getLdapName()]); $branches = array_filter( array_map( function ($key, $ot) @@ -588,12 +588,12 @@ class Attribute } else { $input = $this->renderFormInput(); } - $attributes[$this->getLdapName()] = array( + $attributes[$this->getLdapName()] = [ 'htmlid' => $this->getForHtmlId(), 'label' => '{literal}'.$this->getLabel().'{/literal}'.($this->isRequired() ? '{$must}' : ''), 'description' => ($this->isRequired() ? sprintf(_("%s (required)"), $this->getDescription()) : $this->getDescription()), 'input' => $input, - ); + ]; } } @@ -612,7 +612,7 @@ class Attribute } /* Avoid empty array */ $type[] = 'Attribute'; - $infos = array( + $infos = [ 'htmlid' => $this->getHtmlId(), 'label' => $this->getLabel(), 'required' => $this->isRequired(), @@ -621,7 +621,7 @@ class Attribute 'value' => $this->getValue(), 'default' => $this->defaultValue, 'type' => $type, - ); + ]; if (!$form) { $infos['inldap'] = $this->isInLdap(); $infos['visible'] = $this->visible; @@ -657,10 +657,10 @@ class Attribute function getAclInfo () { if (empty($this->acl)) { - return array( + return [ 'name' => $this->getHtmlId(), 'desc' => $this->getDescription() - ); + ]; } else { /* If acl is not empty, we use an acl that is not ours, we have no acl to create */ return FALSE; @@ -679,7 +679,7 @@ class Attribute public function htmlIds() { - return array($this->getHtmlId()); + return [$this->getHtmlId()]; } protected function managedAttributesJS () @@ -728,7 +728,7 @@ class Attribute return ($this->getValue() == $value); } - protected function renderInputField($type, $name, $attributes = array()) + protected function renderInputField($type, $name, $attributes = []) { $input = '<input type="'.$type.'" '. 'name="'.$name.'" id="'.$name.'"'. @@ -773,7 +773,7 @@ class HiddenArrayAttribute extends HiddenAttribute protected function loadAttrValue ($attrs) { if (isset($attrs[$this->getLdapName()]['count'])) { - $this->value = array(); + $this->value = []; for ($i = 0; $i < $attrs[$this->getLdapName()]['count']; $i++) { $this->value[] = $attrs[$this->getLdapName()][$i]; } @@ -853,7 +853,7 @@ class DisplayLDAPArrayAttribute extends Attribute protected function loadAttrValue ($attrs) { if (isset($attrs[$this->getLdapName()]['count'])) { - $this->value = array(); + $this->value = []; for ($i = 0; $i < $attrs[$this->getLdapName()]['count']; $i++) { $this->value[] = $attrs[$this->getLdapName()][$i]; } diff --git a/include/simpleplugin/class_dialogAttributes.inc b/include/simpleplugin/class_dialogAttributes.inc index 9188182b8..6f0dadf7a 100644 --- a/include/simpleplugin/class_dialogAttributes.inc +++ b/include/simpleplugin/class_dialogAttributes.inc @@ -176,7 +176,7 @@ class DialogAttribute extends SetAttribute * \param array $defaultValue The default value for this attribute * \param string $acl The name of the acl for this attribute if he does not use its own. (Leave empty if he should use its own like most attributes do) */ - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $acl = "") + function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $acl = "") { Attribute::__construct($label, $description, $ldapName, $required, $defaultValue, $acl); $this->attribute = FALSE; @@ -217,7 +217,7 @@ class DialogAttribute extends SetAttribute function getFilterWhiteList () { - return array(); + return []; } function loadPostValue () @@ -245,21 +245,21 @@ class DialogAttribute extends SetAttribute if ($this->isTemplate()) { $buttons .= $this->renderInputField( 'text', $id, - array('value' => $this->editingValue) + ['value' => $this->editingValue] ); $buttons .= $this->renderInputField( 'submit', 'add'.$id, - array('value' => '{msgPool type=addButton}') + ['value' => '{msgPool type=addButton}'] ); $dialogButtonValue = _('Add (dialog)'); } $buttons .= $this->renderInputField( 'submit', 'add'.$id.'_dialog', - array('value' => $dialogButtonValue) + ['value' => $dialogButtonValue] ); $buttons .= $this->renderInputField( 'submit', 'del'.$id, - array('value' => '{msgPool type=delButton}') + ['value' => '{msgPool type=delButton}'] ); return $buttons; } @@ -267,7 +267,7 @@ class DialogAttribute extends SetAttribute public function htmlIds() { $id = $this->getHtmlId(); - $ids = array('add'.$id.'_dialog','del'.$id,'row'.$id); + $ids = ['add'.$id.'_dialog','del'.$id,'row'.$id]; if ($this->isTemplate()) { $ids[] = $id; $ids[] = 'add'.$id; @@ -283,7 +283,7 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute { protected $dialogClass; - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $acl = "") + function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $acl = "") { Attribute::__construct($label, $description, $ldapName, $required, $defaultValue, $acl); $this->edit_enabled = TRUE; @@ -297,7 +297,7 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute function getFilterWhiteList () { - return array(); + return []; } function loadPostValue () @@ -333,7 +333,7 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute $id = $this->getHtmlId(); return $this->renderInputField( 'submit', 'add'.$id.'_dialog', - array('value' => '{msgPool type=addButton}') + ['value' => '{msgPool type=addButton}'] ); } @@ -356,11 +356,11 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute */ class GenericDialogAttribute extends DialogAttribute { - protected $displays = array(); + protected $displays = []; protected $store_attr = 'dn'; protected $display_attr = 'cn'; - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $store_attr = 'dn', $display_attr = 'cn', $acl = '') + function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $store_attr = 'dn', $display_attr = 'cn', $acl = '') { $this->store_attr = $store_attr; $this->display_attr = $display_attr; @@ -369,7 +369,7 @@ class GenericDialogAttribute extends DialogAttribute function getFilterBlackList () { - return array($this->store_attr => $this->getValue()); + return [$this->store_attr => $this->getValue()]; } function addValue ($dn, $attrs) @@ -432,7 +432,7 @@ class GenericDialogAttribute extends DialogAttribute protected function ldapAttributesToGet () { - return array($this->display_attr); + return [$this->display_attr]; } protected function fillDisplayValueFrom ($i, $attrs) @@ -503,7 +503,7 @@ class UsersGroupsAttribute extends GenericDialogAttribute protected function ldapAttributesToGet () { - return array('cn', 'uid', 'objectClass'); + return ['cn', 'uid', 'objectClass']; } protected function fillDisplayValueFrom ($i, $attrs) @@ -546,7 +546,7 @@ class GroupsAttribute extends GenericDialogAttribute { protected $dialogClass = 'GroupSelectDialog'; - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $acl = '') + function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $acl = '') { parent::__construct ($label, $description, $ldapName, $required, $defaultValue, 'dn', 'cn', $acl); } @@ -583,14 +583,14 @@ class MailsAttribute extends DialogAttribute * \param array $defaultValue The default value for this attribute * \param string $acl The name of the acl for this attribute if he does not use its own. (Leave empty if he should use its own like most attributes do) */ - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = array(), $acl = "") + function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $acl = "") { SetAttribute::__construct(new MailAttribute($label, $description, $ldapName, $required, "", $acl), $defaultValue); } function getFilterBlackList () { - return array('mail' => $this->getValue()); + return ['mail' => $this->getValue()]; } function addValue ($dn, $attrs) @@ -606,15 +606,15 @@ class MailsAttribute extends DialogAttribute $id = $this->getHtmlId(); $buttons = $this->renderInputField( 'submit', 'add'.$id, - array('value' => '{msgPool type=addButton}') + ['value' => '{msgPool type=addButton}'] ); $buttons .= $this->renderInputField( 'submit', 'add'.$id.'_dialog', - array('value' => '{msgPool type=addButton} (from list)') + ['value' => '{msgPool type=addButton} (from list)'] ); $buttons .= $this->renderInputField( 'submit', 'del'.$id, - array('value' => '{msgPool type=delButton}') + ['value' => '{msgPool type=delButton}'] ); return $buttons; } @@ -622,7 +622,7 @@ class MailsAttribute extends DialogAttribute public function htmlIds() { $id = $this->getHtmlId(); - return array('add'.$id,'add'.$id.'_dialog','del'.$id,'row'.$id); + return ['add'.$id,'add'.$id.'_dialog','del'.$id,'row'.$id]; } } @@ -643,7 +643,7 @@ class SystemsAttribute extends DialogAttribute function getFilterBlackList () { - return array('cn' => $this->getValue()); + return ['cn' => $this->getValue()]; } } @@ -670,7 +670,7 @@ class ButtonAttribute extends Attribute $id = $this->getHtmlId(); $display = $this->renderInputField( 'submit', $id, - array('value' => '{literal}'.htmlentities($this->buttonText, ENT_COMPAT, 'UTF-8').'{/literal}') + ['value' => '{literal}'.htmlentities($this->buttonText, ENT_COMPAT, 'UTF-8').'{/literal}'] ); return $this->renderAcl($display); } @@ -716,12 +716,12 @@ class DialogButtonAttribute extends ButtonAttribute function getFilterBlackList () { - return array(); + return []; } function getFilterWhiteList () { - return array(); + return []; } } @@ -748,9 +748,9 @@ class UserAttribute extends DialogButtonAttribute if ($this->isTemplate()) { $display = $this->renderInputField( 'text', $id, - array( + [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ) + ] ); } else { $display = '<img src="geticon.php?context=types&icon=user&size=16" alt="user icon" class="center"/>'; @@ -764,22 +764,22 @@ class UserAttribute extends DialogButtonAttribute } $display .= $this->renderInputField( 'image', $id.'_dialog', - array( + [ 'class' => 'center', 'src' => 'geticon.php?context=actions&icon=document-edit&size=16', 'title' => _('Edit'), 'alt' => _('Edit') - ) + ] ); if (!$this->isRequired()) { $display .= $this->renderInputField( 'image', $id.'_remove', - array( + [ 'class' => 'center', 'src' => 'geticon.php?context=actions&icon=remove&size=16', 'title' => _('Remove'), 'alt' => _('Remove') - ) + ] ); } return $this->renderAcl($display); @@ -833,7 +833,7 @@ class UserAttribute extends DialogButtonAttribute public function htmlIds() { $id = $this->getHtmlId(); - $ids = array($id.'_dialog'); + $ids = [$id.'_dialog']; if ($this->isTemplate()) { $ids[] = $id; } @@ -851,7 +851,7 @@ class GenericSimplePluginDialog extends GenericDialog { protected $initialDialogValue = NULL; - function __construct($simplePlugin, $attribute, $value = array()) + function __construct($simplePlugin, $attribute, $value = []) { $this->attribute = $attribute; $this->dialog = new $this->dialogClass('new'); @@ -895,7 +895,7 @@ class GenericSimplePluginDialog extends GenericDialog return $this->dialog->execute().$this->buttons(); } - $value = array(); + $value = []; foreach ($this->dialog->attributes as $attr) { $value[$attr] = $this->dialog->$attr; } diff --git a/include/simpleplugin/class_helpersAttribute.inc b/include/simpleplugin/class_helpersAttribute.inc index 01170c186..987ab3850 100644 --- a/include/simpleplugin/class_helpersAttribute.inc +++ b/include/simpleplugin/class_helpersAttribute.inc @@ -182,9 +182,9 @@ class CommaListAttribute extends CompositeAttribute { parent::__construct( $attribute->getDescription(), $ldapName, - array( + [ $attribute - ), '', '' + ], '', '' ); $this->sep = $sep; } @@ -192,9 +192,9 @@ class CommaListAttribute extends CompositeAttribute function readValues($value) { if ($value == '') { - return array(array()); + return [[]]; } else { - return array(explode($this->sep, $value)); + return [explode($this->sep, $value)]; } } @@ -213,10 +213,10 @@ class UnitIntAttribute extends CompositeAttribute function __construct ($label, $description, $ldapName, $required, $units, $min = FALSE, $max = FALSE, $defaultValue = "", $acl = "") { parent::__construct($description, $ldapName, - array( + [ new IntAttribute('', '', $ldapName.'_int', $required, $min, $max, $defaultValue), new SelectAttribute('', '', $ldapName.'_select', TRUE, array_keys($units), '', array_values($units)), - ), '', '', + ], '', '', $acl, $label ); $this->setLinearRendering(TRUE); @@ -226,12 +226,12 @@ class UnitIntAttribute extends CompositeAttribute function readValues($value) { if ($value === '') { - return array('', 0); + return ['', 0]; } $choices = $this->attributes[1]->getChoices(); sort($choices); if ($value == 0) { - return array($value, $choices[0]); + return [$value, $choices[0]]; } /* Find the appropriate unit */ for ( @@ -239,7 +239,7 @@ class UnitIntAttribute extends CompositeAttribute ($value % $choices[$i] != 0) && ($i > 0); $i-- ); - return array($value / $choices[$i], $choices[$i]); + return [$value / $choices[$i], $choices[$i]]; } function writeValues($values) @@ -264,13 +264,13 @@ class BytesSizeAttribute extends UnitIntAttribute { function __construct ($label, $description, $ldapName, $required, $min = FALSE, $max = FALSE, $defaultValue = "", $acl = "") { - $units = array( + $units = [ 1 => _('B'), pow(1024, 1) => _('KiB'), pow(1024, 2) => _('MiB'), pow(1024, 3) => _('GiB'), pow(1024, 4) => _('TiB'), - ); + ]; parent::__construct ($label, $description, $ldapName, $required, $units, $min, $max, $defaultValue, $acl); } } @@ -282,12 +282,12 @@ class TimeAttribute extends UnitIntAttribute { function __construct ($label, $description, $ldapName, $required, $min = FALSE, $max = FALSE, $defaultValue = "", $acl = "") { - $units = array( + $units = [ 1 => _('seconds'), 60 => _('minutes'), 3600 => _('hours'), 86400 => _('days'), - ); + ]; parent::__construct ($label, $description, $ldapName, $required, $units, $min, $max, $defaultValue, $acl); } } diff --git a/include/simpleplugin/class_multiPlugin.inc b/include/simpleplugin/class_multiPlugin.inc index b6787011f..dc3d03d4e 100644 --- a/include/simpleplugin/class_multiPlugin.inc +++ b/include/simpleplugin/class_multiPlugin.inc @@ -26,15 +26,15 @@ class multiPlugin extends simplePlugin { /* attribute list for save action */ - var $objectclasses = array(); + var $objectclasses = []; var $ignore_account = TRUE; - var $plugin = array(); + var $plugin = []; var $tabClass = ''; static function getAttributesInfo () { - return array(); + return []; } function __construct ($dn = NULL, $object = NULL, $parent = NULL) @@ -156,7 +156,7 @@ class multiPlugin extends simplePlugin /* Save to LDAP */ function save() { - $errors = array(); + $errors = []; /* Save objects */ foreach ($this->plugin as &$plug) { $plug->dn = $this->dn; @@ -175,7 +175,7 @@ class multiPlugin extends simplePlugin function remove($fulldelete = FALSE) { - $errors = array(); + $errors = []; /* Remove objects */ foreach ($this->plugin as &$plug) { $plug->dn = $this->dn; @@ -188,7 +188,7 @@ class multiPlugin extends simplePlugin return $errors; } - function adapt_from_template($attrs, $skip = array()) + function adapt_from_template($attrs, $skip = []) { /* Adapt objects */ foreach ($this->plugin as &$plug) { diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc index b372dbfe3..a25077180 100644 --- a/include/simpleplugin/class_simpleManagement.inc +++ b/include/simpleplugin/class_simpleManagement.inc @@ -132,14 +132,14 @@ class simpleManagement // The currently used object(s) (e.g. in edit, removal) // $dn is public due to some compatibility problems with class plugin.. public $dn = ''; - protected $dns = array(); + protected $dns = []; // The last used object(s). protected $last_dn = ''; - protected $last_dns = array(); + protected $last_dns = []; // The common places the displayed objects are stored in. (e.g. array("ou=groups,","..")) - protected $storagePoints = array(); + protected $storagePoints = []; // The opened object. protected $tabObject = NULL; @@ -172,14 +172,14 @@ class simpleManagement protected $filter = NULL; // A list of configured actions/events - protected $actions = array(); + protected $actions = []; // Some management classes are used in tab groups and needs this public $is_template = FALSE; - public $attributes = array(); + public $attributes = []; /* Attributes that child classes should override */ - protected $objectTypes = array(); + protected $objectTypes = []; /* Attributes that child classes can override */ protected $departmentBrowser = TRUE; @@ -193,7 +193,7 @@ class simpleManagement protected $autoActions = TRUE; protected $skipCpHandler = FALSE; - protected $autoFilterAttributes = array('dn', 'cn', 'description'); + protected $autoFilterAttributes = ['dn', 'cn', 'description']; protected $headpageClass = "listing"; @@ -216,7 +216,7 @@ class simpleManagement } unset($object); - $this->storagePoints = array(); + $this->storagePoints = []; foreach ($this->objectTypes as $key => $object) { try { $i = objects::infos($object); @@ -286,22 +286,22 @@ class simpleManagement { if ($this->autoActions) { if (static::$skipTemplates) { - $this->headpage->xmlData['actionmenu']['action'][0]['action'] = array(); + $this->headpage->xmlData['actionmenu']['action'][0]['action'] = []; } else { - $this->headpage->xmlData['actionmenu']['action'][0]['action'] = array( - array( + $this->headpage->xmlData['actionmenu']['action'][0]['action'] = [ + [ 'type' => 'sub', 'image' => 'geticon.php?context=devices&icon=template&size=16', 'label' => _('Template'), - 'action' => array(), - ), - array( + 'action' => [], + ], + [ 'type' => 'sub', 'image' => 'geticon.php?context=actions&icon=document-new&size=16', 'label' => _('From template'), - 'action' => array(), - ), - ); + 'action' => [], + ], + ]; } } $this->configureHeadline(); @@ -315,17 +315,17 @@ class simpleManagement $filterObject = objects::getFilterObject($object); $this->headpage->objectTypes[$object] = - array( + [ 'label' => $i['name'], 'category' => $i['aclCategory'], 'class' => $i['mainTab'], 'image' => $i['icon'], 'filter' => $filterObject, 'nameAttr' => $i['nameAttr'], - ); + ]; if (!static::$skipTemplates) { $this->headpage->objectTypes['template_'.$object] = - array( + [ 'label' => sprintf(_('%s template'), $i['name']), 'category' => $i['aclCategory'], 'class' => 'template', @@ -333,13 +333,13 @@ class simpleManagement 'filter' => new ldapFilter( '&', - array( + [ new ldapFilterLeaf('objectClass', '=', 'fdTemplate'), fdTemplateFilter($filterObject), - ) + ] ), 'nameAttr' => $i['nameAttr'], - ); + ]; } $this->headpage->categories[] = $i['aclCategory']; if ($this->autoActions) { @@ -353,30 +353,30 @@ class simpleManagement $icon = $infos['plIcon']; } } - $this->headpage->xmlData['actionmenu']['action'][0]['action'][] = array( + $this->headpage->xmlData['actionmenu']['action'][0]['action'][] = [ 'name' => 'new_'.$object, 'type' => 'entry', 'image' => $icon, 'label' => $i['name'], 'acl' => $i['aclCategory'].'/'.$i['mainTab'].'[c]', - ); + ]; if (!static::$skipTemplates) { $this->registerAction('new_template_'.$object, 'newEntryTemplate'); $this->registerAction('template_apply_'.$object, 'newEntryFromTemplate'); - $this->headpage->xmlData['actionmenu']['action'][0]['action'][0]['action'][] = array( + $this->headpage->xmlData['actionmenu']['action'][0]['action'][0]['action'][] = [ 'name' => 'new_template_'.$object, 'type' => 'entry', 'image' => $icon, 'label' => $i['name'], 'acl' => $i['aclCategory'].'/template[c]', - ); - $this->headpage->xmlData['actionmenu']['action'][0]['action'][1]['action'][] = array( + ]; + $this->headpage->xmlData['actionmenu']['action'][0]['action'][1]['action'][] = [ 'name' => 'template_apply_'.$object, 'type' => 'entry', 'image' => $icon, 'label' => $i['name'], 'acl' => $i['aclCategory'].'/'.$i['mainTab'].'[c]', - ); + ]; } } } @@ -426,13 +426,13 @@ class simpleManagement $tag = 'FILTER'.$object; $filter .= '$'.$tag; $i = objects::infos($object); - $this->filter->elements[$tag] = array( + $this->filter->elements[$tag] = [ 'type' => 'checkbox', 'tag' => $tag, 'default' => TRUE, - 'unset' => array(), + 'unset' => [], 'set' => preg_replace('/\$/', '\\\$', $i['filter']) - ); + ]; $this->filter->elementValues[$tag] = TRUE; if ($i['mainAttr']) { @@ -445,13 +445,13 @@ class simpleManagement if (!static::$skipTemplates) { $tag = 'FILTERTEMPLATE'; $filter .= '$'.$tag; - $this->filter->elements[$tag] = array( + $this->filter->elements[$tag] = [ 'type' => 'checkbox', 'tag' => $tag, 'default' => TRUE, - 'unset' => array(), + 'unset' => [], 'set' => '(objectClass=fdTemplate)' - ); + ]; $this->filter->elementValues[$tag] = TRUE; $attributes[] = 'fdTemplateField'; @@ -472,7 +472,7 @@ class simpleManagement { $contents = file_get_contents($file); $data = xml::xml2array($contents, 1); - foreach (array('departmentBrowser','departmentRootVisible','baseMode','multiSelect') as $var) { + foreach (['departmentBrowser','departmentRootVisible','baseMode','multiSelect'] as $var) { $data['list']['definition']["$var"] = ($this->$var ? 'true' : 'false'); } return $data; @@ -519,18 +519,18 @@ class simpleManagement { global $config; $smarty = get_smarty(); - $filters = array(); + $filters = []; foreach ($this->objectTypes as $object) { - $filters[] = array( + $filters[] = [ 'id' => 'FILTER'.$object, 'label' => sprintf(_('Show %s'), $config->data['OBJECTS'][$object]['name']) - ); + ]; } if (!static::$skipTemplates) { - $filters[] = array( + $filters[] = [ 'id' => 'FILTERTEMPLATE', 'label' => sprintf(_('Show %s'), _('Template')) - ); + ]; } $smarty->assign('objectFilters', $filters); $this->headpage->update(); @@ -545,7 +545,7 @@ class simpleManagement function execute() { // Ensure that html posts and gets are kept even if we see a 'Entry islocked' dialog. - $vars = array('/^act$/','/^listing/','/^PID$/'); + $vars = ['/^act$/','/^listing/','/^PID$/']; session::set('LOCK_VARS_TO_USE', $vars); /* Display the copy & paste dialog, if it is currently open */ @@ -593,7 +593,7 @@ class simpleManagement // Set current restore base for snapshot handling. if (is_object($this->snapHandler)) { - $bases = array(); + $bases = []; foreach ($this->storagePoints as $sp) { $bases[] = $sp.$this->headpage->getBase(); } @@ -757,7 +757,7 @@ class simpleManagement return; } if ($cancel) { - $msgs = array(); + $msgs = []; } else { $msgs = $this->tabObject->save(); } @@ -910,7 +910,7 @@ class simpleManagement { if (!is_object($this->headpage)) { trigger_error("No valid headpage given....!"); - return array(); + return []; } $action = $this->headpage->getAction(); if (isset($_POST['edit_cancel'])) { @@ -941,7 +941,7 @@ class simpleManagement if (isset($this->actions[$action['action']])) { $func = $this->actions[$action['action']]; if (!isset($action['targets'])) { - $action['targets'] = array(); + $action['targets'] = []; } return $this->$func($action['action'], $action['targets'], $action); } @@ -977,7 +977,7 @@ class simpleManagement $this->last_dn = $this->dn; $this->dn = ""; $this->last_dns = $this->dns; - $this->dns = array(); + $this->dns = []; $this->last_tabObject = $this->tabObject; $this->tabObject = NULL; @@ -1015,8 +1015,8 @@ class simpleManagement protected function removeEntryRequested($action, array $target, array $all) { global $ui; - $disallowed = array(); - $this->dns = array(); + $disallowed = []; + $this->dns = []; @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, "Entry removal requested!"); @@ -1051,7 +1051,7 @@ class simpleManagement } // Add locks - $objects = array(); + $objects = []; foreach ($this->dns as $dn) { $type = $this->getType($dn); if (preg_match('/^template_/', $type) && !static::$skipTemplates) { @@ -1062,12 +1062,12 @@ class simpleManagement $info = objects::infos($type); } $entry = $this->getHeadpage()->getEntry($dn); - $objects[] = array( + $objects[] = [ 'name' => $entry[$info['mainAttr']][0], 'dn' => $dn, 'icon' => $info['icon'], 'type' => $info['name'] - ); + ]; } add_lock ($this->dns, $ui->dn); @@ -1105,7 +1105,7 @@ class simpleManagement del_lock($this->dn); } else { msg_dialog::display(_('Permission error'), msgPool::permDelete($dn), ERROR_DIALOG); - logging::log('security', 'simpleManagement/'.get_class($this), $dn, array(), 'Tried to trick deletion.'); + logging::log('security', 'simpleManagement/'.get_class($this), $dn, [], 'Tried to trick deletion.'); } } @@ -1155,7 +1155,7 @@ class simpleManagement global $config, $ui; // Set current restore base for snapshot handling. if (is_object($this->snapHandler)) { - $bases = array(); + $bases = []; foreach ($this->storagePoints as $sp) { $bases[] = $sp.$this->headpage->getBase(); } @@ -1196,7 +1196,7 @@ class simpleManagement * @param array $target A list of object dns, which should be affected by this method. * @param array $all A combination of both 'action' and 'target'. */ - function copyPasteHandler($action = '', array $target = array(), array $all = array()) + function copyPasteHandler($action = '', array $target = [], array $all = []) { global $ui; // Return without any actions while copy&paste handler is disabled. @@ -1293,7 +1293,7 @@ class simpleManagement */ function getAllDeletedSnapshots() { - $tmp = array(); + $tmp = []; $snapshotBases = $this->snapHandler->getSnapshotBases(); if (is_array($snapshotBases)) { foreach ($snapshotBases as $base) { diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index 40aba6b15..19d85044c 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -35,7 +35,7 @@ class simplePlugin * * associative array that stores attributeLdapName => reference on object */ - public $attributesAccess = array(); + public $attributesAccess = []; /*! \brief Mark plugin as account @@ -87,13 +87,13 @@ class simplePlugin This should only be used internally. */ - public $attrs = array(); + public $attrs = []; /*! \brief The objectClasses set by this tab */ - protected $objectclasses = array(); + protected $objectclasses = []; /*! \brief The state of the attributes when we opened the object */ - protected $saved_attributes = array(); + protected $saved_attributes = []; /*! \brief Do we want a header allowing to able/disable this plugin */ protected $displayHeader = FALSE; @@ -112,14 +112,14 @@ class simplePlugin protected $needEditMode = FALSE; /*! \brief Attributes that needs to be initialized before the others */ - protected $preInitAttributes = array(); + protected $preInitAttributes = []; /*! \brief FALSE to disable inheritance. Array like array ('objectClass' => 'attribute') to specify oc of the groups it might be inherited from */ protected $inheritance = FALSE; protected $member_of_group = FALSE; protected $editing_group = NULL; - protected $group_attrs = array(); + protected $group_attrs = []; /*! \brief Used when the entry is opened as "readonly" due to locks */ protected $read_only = FALSE; @@ -163,9 +163,9 @@ class simplePlugin $this->ignore_account = TRUE; } - $this->attributesInfo = array(); + $this->attributesInfo = []; foreach ($attributesInfo as $section => $sectionInfo) { - $attrs = array(); + $attrs = []; foreach ($sectionInfo['attrs'] as $attr) { $name = $attr->getLdapName(); if (isset($attrs[$name])) { @@ -339,24 +339,24 @@ class simplePlugin if ($this->is_template && $this->mainTab) { /* Unshift special section for template infos */ $this->attributesInfo = array_merge( - array( - '_template' => array( - 'class' => array('fullwidth'), + [ + '_template' => [ + 'class' => ['fullwidth'], 'name' => _('Template settings'), - 'attrs' => array( + 'attrs' => [ '_template_cn' => new StringAttribute( _('Template name'), _('This is the name of the template'), '_template_cn', TRUE, '', 'template_cn' ) - ) - ), - '_template_dummy' => array( - 'class' => array('invisible'), + ] + ], + '_template_dummy' => [ + 'class' => ['invisible'], 'name' => '_template_dummy', - 'attrs' => array() - ) - ), + 'attrs' => [] + ] + ], $this->attributesInfo ); $this->attributesAccess['_template_cn'] =& $this->attributesInfo['_template']['attrs']['_template_cn']; @@ -385,10 +385,10 @@ class simplePlugin if (!$this->mainTab) { trigger_error('It seems main tab has not been saved.'); } - $template_attrs = array( - 'objectClass' => array('fdTemplate'), - 'fdTemplateField' => array() - ); + $template_attrs = [ + 'objectClass' => ['fdTemplate'], + 'fdTemplateField' => [] + ]; } $template_attrs = templateHandling::fieldsToLDAP($template_attrs, $this->attrs); if ($this->mainTab) { @@ -532,7 +532,7 @@ class simplePlugin function get_allowed_bases() { global $config; - $deps = array(); + $deps = []; /* Is this a new object ? Or just an edited existing object */ foreach ($config->idepartments as $dn => $name) { @@ -596,7 +596,7 @@ class simplePlugin $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $dst_dn)); if (!$ldap->rename_dn($src_dn, $dst_dn)) { logging::log('debug', 'Ldap Protocol v3 implementation error, ldap_rename failed.', - "FROM: $src_dn -- TO: $dst_dn", array(), $ldap->get_error()); + "FROM: $src_dn -- TO: $dst_dn", [], $ldap->get_error()); @DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, "Rename failed FROM: $src_dn -- TO: $dst_dn", 'Ldap Protocol v3 implementation error. Error:'.$ldap->get_error()); return $ldap->get_error(); @@ -605,13 +605,13 @@ class simplePlugin /* Update userinfo if necessary */ if (preg_match('/'.preg_quote($src_dn, '/').'$/i', $ui->dn)) { $ui_dn = preg_replace('/'.preg_quote($src_dn, '/').'$/i', $dst_dn, $ui->dn); - logging::log('view', 'acl/'.get_class($this), $this->dn, array(), 'Updated userinfo dn from "'.$ui->dn.'" to "'.$ui_dn.'"'); + logging::log('view', 'acl/'.get_class($this), $this->dn, [], 'Updated userinfo dn from "'.$ui->dn.'" to "'.$ui_dn.'"'); $ui->dn = $ui_dn; } /* Check if departments were moved. If so, force the reload of config->departments */ $ldap->cd($dst_dn); - $ldap->search('(objectClass=gosaDepartment)', array('dn')); + $ldap->search('(objectClass=gosaDepartment)', ['dn']); if ($ldap->count()) { $config->get_departments(); $config->make_idepartments(); @@ -624,7 +624,7 @@ class simplePlugin function getRequiredAttributes() { - $tmp = array(); + $tmp = []; foreach ($this->attributesAccess as $attr) { if ($attr->isRequired()) { $tmp[] = $attr->getLdapName(); @@ -658,10 +658,10 @@ class simplePlugin @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, "execute"); /* Reset Lock message POST/GET check array, to prevent preg_match errors */ - session::set('LOCK_VARS_TO_USE', array()); - session::set('LOCK_VARS_USED_GET', array()); - session::set('LOCK_VARS_USED_POST', array()); - session::set('LOCK_VARS_USED_REQUEST', array()); + session::set('LOCK_VARS_TO_USE', []); + session::set('LOCK_VARS_USED_GET', []); + session::set('LOCK_VARS_USED_POST', []); + session::set('LOCK_VARS_USED_REQUEST', []); $this->displayPlugin = TRUE; $this->header = ""; @@ -721,7 +721,7 @@ class simplePlugin $plInfo = pluglist::pluginInfos(get_class($this)); $disabled = $this->acl_skip_write(); if ($this->is_account) { - $depends = array(); + $depends = []; if (isset($plInfo['plDepending'])) { foreach ($plInfo['plDepending'] as $plugin) { if (isset($this->parent->by_object[$plugin]) && @@ -735,8 +735,8 @@ class simplePlugin $buttonText = msgPool::removeFeaturesButton($plInfo['plShortName']); $text = msgPool::featuresEnabled($plInfo['plShortName'], $depends); } else { - $depends = array(); - $conflicts = array(); + $depends = []; + $conflicts = []; if (isset($plInfo['plDepends'])) { foreach ($plInfo['plDepends'] as $plugin) { if (isset($this->parent->by_object[$plugin]) && @@ -760,7 +760,7 @@ class simplePlugin $buttonText = msgPool::addFeaturesButton($plInfo['plShortName']); $text = msgPool::featuresDisabled($plInfo['plShortName'], $depends, $conflicts); } - return array($disabled,$buttonText,$text); + return [$disabled,$buttonText,$text]; } /*! @@ -826,7 +826,7 @@ class simplePlugin } } - $sections = array(); + $sections = []; foreach ($this->attributesInfo as $section => $sectionInfo) { $legend = $sectionInfo['name']; if (isset($sectionInfo['icon'])) { @@ -842,7 +842,7 @@ class simplePlugin } else { $smarty->assign("sectionClasses", ''); } - $attributes = array(); + $attributes = []; foreach ($sectionInfo['attrs'] as $attr) { if ($attr->getAclInfo() !== FALSE) { // We assign ACLs so that attributes can use them in their template code @@ -970,18 +970,18 @@ class simplePlugin function remove($fulldelete = FALSE) { if (!$this->initially_was_account) { - return array(); + return []; } if (!$fulldelete && !$this->acl_is_removeable()) { trigger_error('remove was called on a tab without enough ACL rights'); - return array(); + return []; } $this->prepare_remove(); if ($this->is_template && (!defined('_OLD_TEMPLATES_') || !_OLD_TEMPLATES_)) { $this->attrs = $this->templateSaveAttrs(); - $this->saved_attributes = array(); + $this->saved_attributes = []; } /* Pre hooks */ $errors = $this->pre_remove(); @@ -993,14 +993,14 @@ class simplePlugin return $errors; } $this->post_remove(); - return array(); + return []; } /* Remove FusionDirectory attributes */ protected function prepare_remove () { global $config; - $this->attrs = array(); + $this->attrs = []; if (!$this->mainTab) { /* include global link_info */ @@ -1009,7 +1009,7 @@ class simplePlugin /* Get current objectClasses in order to add the required ones */ $ldap->cat($this->dn); $tmp = $ldap->fetch (); - $oc = array(); + $oc = []; if ($this->is_template) { if (isset($tmp['fdTemplateField'])) { foreach ($tmp['fdTemplateField'] as $tpl_field) { @@ -1030,7 +1030,7 @@ class simplePlugin /* Unset attributes from entry */ foreach ($this->attributes as $val) { - $this->attrs["$val"] = array(); + $this->attrs["$val"] = []; } } } @@ -1056,9 +1056,9 @@ class simplePlugin $this->ldap_error = $ldap->get_error(); if ($ldap->success()) { - return array(); + return []; } else { - return array(msgPool::ldaperror($this->ldap_error, $this->dn, LDAP_MOD, get_class())); + return [msgPool::ldaperror($this->ldap_error, $this->dn, LDAP_MOD, get_class())]; } } @@ -1211,11 +1211,11 @@ class simplePlugin return $errors; } $this->attrs = $this->templateSaveAttrs(); - $this->saved_attributes = array(); + $this->saved_attributes = []; } $this->cleanup(); if (!$this->shouldSave()) { - return array(); /* Nothing to do here */ + return []; /* Nothing to do here */ } /* Pre hooks */ $errors = $this->pre_save(); @@ -1230,7 +1230,7 @@ class simplePlugin $this->prepareNextCleanup(); /* Post hooks and logging */ $this->post_save(); - return array(); + return []; } protected function shouldSave() @@ -1256,13 +1256,13 @@ class simplePlugin $this->entryCSN = ''; /* Start with empty array */ - $this->attrs = array(); + $this->attrs = []; /* Get current objectClasses in order to add the required ones */ - $ldap->cat($this->dn, array('fdTemplateField', 'objectClass')); + $ldap->cat($this->dn, ['fdTemplateField', 'objectClass']); $tmp = $ldap->fetch(); - $oc = array(); + $oc = []; if ($this->is_template) { if (isset($tmp['fdTemplateField'])) { @@ -1294,7 +1294,7 @@ class simplePlugin } } - return array(); + return []; } protected function pre_save () @@ -1313,17 +1313,17 @@ class simplePlugin /* Check if this is a new entry ... add/modify */ $ldap = $config->get_ldap_link(); - $ldap->cat($this->dn, array("objectClass")); + $ldap->cat($this->dn, ["objectClass"]); if ($this->mainTab && !$this->initially_was_account) { if ($ldap->count()) { - return array(sprintf(_('There is already an entry with the same dn : %s'), $this->dn)); + return [sprintf(_('There is already an entry with the same dn : %s'), $this->dn)]; } $ldap->cd($config->current['BASE']); $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); $action = "add"; } else { if (!$ldap->count()) { - return array(sprintf(_('The entry %s is not existing'), $this->dn)); + return [sprintf(_('The entry %s is not existing'), $this->dn)]; } $action = "modify"; } @@ -1334,9 +1334,9 @@ class simplePlugin /* Check for errors */ if (!$ldap->success()) { - return array(msgPool::ldaperror($this->ldap_error, $this->dn, 0, get_class())); + return [msgPool::ldaperror($this->ldap_error, $this->dn, 0, get_class())]; } - return array(); + return []; } /*! \brief This function is called after LDAP save to do some post operations and logging @@ -1367,7 +1367,7 @@ class simplePlugin * * \param array $addAttrs */ - protected function handle_hooks($when, $mode, array $addAttrs = array()) + protected function handle_hooks($when, $mode, array $addAttrs = []) { switch ($mode) { case 'add': @@ -1388,7 +1388,7 @@ class simplePlugin /*! \brief Forward command execution requests * to the post hook execution method. */ - function handle_post_events($mode, array $addAttrs = array()) + function handle_post_events($mode, array $addAttrs = []) { /* Update foreign keys */ if ($mode == 'remove') { @@ -1403,7 +1403,7 @@ class simplePlugin * \brief Forward command execution requests * to the pre hook execution method. */ - function handle_pre_events($mode, array $addAttrs = array()) + function handle_pre_events($mode, array $addAttrs = []) { global $config; @@ -1412,7 +1412,7 @@ class simplePlugin /* Store information if there was subobjects before deletion */ $ldap = $config->get_ldap_link(); $ldap->cd($this->dn); - $ldap->search('(objectClass=*)', array('dn'), 'one'); + $ldap->search('(objectClass=*)', ['dn'], 'one'); $this->hadSubobjects = ($ldap->count() > 0); } return $this->handle_hooks('PRE', $mode, $addAttrs); @@ -1423,15 +1423,15 @@ class simplePlugin * Replaces placeholder by class values of this plugin instance. * Allows to a add special replacements. */ - function callHook($cmd, array $addAttrs = array(), &$returnOutput = array(), &$returnCode = NULL) + function callHook($cmd, array $addAttrs = [], &$returnOutput = [], &$returnCode = NULL) { if ($this->is_template) { - return array(); + return []; } global $config; $commands = $config->searchHooks(get_class($this), $cmd); - $messages = array(); + $messages = []; foreach ($commands as $command) { // Walk trough attributes list and add the plugins attributes. @@ -1494,7 +1494,7 @@ class simplePlugin function check () { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, 'check'); - $messages = array(); + $messages = []; foreach ($this->attributesInfo as $sectionInfo) { foreach ($sectionInfo['attrs'] as $attr) { @@ -1509,7 +1509,7 @@ class simplePlugin } } - $error = $this->callHook('CHECK', array('nbCheckErrors' => count($messages)), $returnOutput); + $error = $this->callHook('CHECK', ['nbCheckErrors' => count($messages)], $returnOutput); if (!empty($error)) { $messages = array_merge($messages, $error); } @@ -1552,14 +1552,14 @@ class simplePlugin if (preg_match('/^handle_/', $mode)) { $olddn = $param1; $newdn = $param2; - $classes = array(get_class($this)); + $classes = [get_class($this)]; if (($olddn != $newdn) && $this->mainTab) { if ($newdn === NULL) { $subobjects = $this->hadSubobjects; } else { $ldap = $config->get_ldap_link(); $ldap->cd($newdn); - $ldap->search('(objectClass=*)', array('dn'), 'one'); + $ldap->search('(objectClass=*)', ['dn'], 'one'); $subobjects = ($ldap->count() > 0); } } @@ -1567,7 +1567,7 @@ class simplePlugin $classes = array_keys($this->parent->by_object); } // We group by objectType concerned - $foreignRefs = array(); + $foreignRefs = []; if ($subobjects) { $field = 'dn'; /* Special treatment for foreign keys on DN when moving an object @@ -1586,11 +1586,11 @@ class simplePlugin } if ($class == 'aclAssignment') { /* Special case: aclAssignment foreignKey is ignored on department types as it’s handled by the aclAssignment objectType */ - $objectTypes = array('ACLASSIGNMENT'); + $objectTypes = ['ACLASSIGNMENT']; } elseif (is_subclass_of($class, 'simpleService')) { - $objectTypes = array('SERVER'); + $objectTypes = ['SERVER']; } else { - $objectTypes = array(); + $objectTypes = []; $cinfos = pluglist::pluginInfos($class); foreach ($cinfos['plObjectType'] as $key => $objectType) { if (!is_numeric($key)) { @@ -1608,13 +1608,13 @@ class simplePlugin $newvalue = $newdn; $foreignRefs[$objectType]['refs'][$class][$ofield][$field] = - array( + [ 'tab' => $classes[0], 'field' => $field, 'oldvalue' => $oldvalue, 'newvalue' => $newvalue, - ); - $filter = templateHandling::parseString($filtersub, array('oldvalue' => $oldvalue, 'newvalue' => $newvalue), 'ldap_escape_f'); + ]; + $filter = templateHandling::parseString($filtersub, ['oldvalue' => $oldvalue, 'newvalue' => $newvalue], 'ldap_escape_f'); if (!preg_match('/^\(.*\)$/', $filter)) { $filter = '('.$filter.')'; } @@ -1642,11 +1642,11 @@ class simplePlugin $cinfos = pluglist::pluginInfos($class); if ($class == 'aclAssignment') { /* Special case: aclAssignment foreignKey is ignored on department types as it’s handled by the aclAssignment objectType */ - $objectTypes = array('ACLASSIGNMENT'); + $objectTypes = ['ACLASSIGNMENT']; } elseif (is_subclass_of($class, 'simpleService')) { - $objectTypes = array('SERVER'); + $objectTypes = ['SERVER']; } else { - $objectTypes = array(); + $objectTypes = []; foreach ($cinfos['plObjectType'] as $key => $objectType) { if (!is_numeric($key)) { $objectType = $key; @@ -1671,24 +1671,24 @@ class simplePlugin $newvalue = $this->attributeValue($field); } $foreignRefs[$objectType]['refs'][$class][$ofield][$field] = - array( + [ 'tab' => $tabclass, 'field' => $field, 'oldvalue' => $oldvalue, 'newvalue' => $newvalue, - ); - $filter = templateHandling::parseString($filter, array('oldvalue' => $oldvalue, 'newvalue' => $newvalue), 'ldap_escape_f'); + ]; + $filter = templateHandling::parseString($filter, ['oldvalue' => $oldvalue, 'newvalue' => $newvalue], 'ldap_escape_f'); } elseif ($mode == 'references') { $foreignRefs[$objectType]['refs'][$class]['name'] = $cinfos['plShortName']; $foreignRefs[$objectType]['refs'][$class]['fields'][$ofield][$field] = - array( + [ 'tab' => $tabclass, 'field' => $field, 'tabname' => $this->parent->by_name[$tabclass], 'value' => $this->parent->by_object[$tabclass]->$field, - ); - $filter = templateHandling::parseString($filter, array('oldvalue' => $this->parent->by_object[$tabclass]->$field), 'ldap_escape_f'); + ]; + $filter = templateHandling::parseString($filter, ['oldvalue' => $this->parent->by_object[$tabclass]->$field], 'ldap_escape_f'); } if (!preg_match('/^\(.*\)$/', $filter)) { $filter = '('.$filter.')'; @@ -1701,7 +1701,7 @@ class simplePlugin /* Back up POST content */ $SAVED_POST = $_POST; - $refs = array(); + $refs = []; // For each concerned objectType foreach ($foreignRefs as $objectType => $tabRefs) { // Compute filter @@ -1709,7 +1709,7 @@ class simplePlugin $filter = '(|'.join($filters).')'; // Search objects try { - $objects = objects::ls($objectType, array('dn' => 'raw'), NULL, $filter); + $objects = objects::ls($objectType, ['dn' => 'raw'], NULL, $filter); } catch (NonExistingObjectTypeException $e) { continue; } catch (EmptyFilterException $e) { @@ -1718,7 +1718,7 @@ class simplePlugin // For each object of this type foreach (array_keys($objects) as $dn) { /* Avoid sending POST to opened objects */ - $_POST = array(); + $_POST = []; // Build the object $tabobject = objects::open($dn, $objectType); if (preg_match('/^handle_/', $mode)) { @@ -1735,12 +1735,12 @@ class simplePlugin $ofield, $field['oldvalue'], $field['newvalue'], - array( + [ 'CLASS' => $field['tab'], 'FIELD' => $field['field'], 'MODE' => preg_replace('/^handle_/', '', $mode), 'DN' => $this->dn, - ) + ] ); } } @@ -1761,17 +1761,17 @@ class simplePlugin if ($pluginobject->foreignKeyCheck( $ofield, $field['value'], - array( + [ 'CLASS' => $field['tab'], 'FIELD' => $field['field'], 'DN' => $this->dn, - ) + ] )) { if (!isset($refs[$dn])) { - $refs[$dn] = array( + $refs[$dn] = [ 'link' => '', - 'tabs' => array(), - ); + 'tabs' => [], + ]; try { $refs[$dn]['link'] = objects::link($dn, $objectType); } catch (FusionDirectoryException $e) { @@ -1780,10 +1780,10 @@ class simplePlugin } } if (!isset($refs[$dn]['tabs'][$tab])) { - $refs[$dn]['tabs'][$tab] = array( + $refs[$dn]['tabs'][$tab] = [ 'link' => '', - 'fields' => array(), - ); + 'fields' => [], + ]; try { if (is_subclass_of($tab, 'simpleService')) { $refs[$dn]['tabs'][$tab]['link'] = objects::link($dn, $objectType, "service_$tab", sprintf(_('Service "%s"'), $tab_infos['name'])); @@ -1831,7 +1831,7 @@ class simplePlugin } /* Build DN with multiple attributes */ - $usableAttributes = array(); + $usableAttributes = []; foreach ($this->attributes as $attr) { if (($attr != $attribute) && is_scalar($this->$attr) && ($this->$attr != '')) { $usableAttributes[] = (string)$attr; @@ -1861,7 +1861,7 @@ class simplePlugin * * \param array $skip A new array */ - function adapt_from_template($attrs, $skip = array()) + function adapt_from_template($attrs, $skip = []) { $this->attrs = $attrs; @@ -1888,7 +1888,7 @@ class simplePlugin $this->dn = 'new'; $this->orig_dn = $this->dn; - $this->saved_attributes = array(); + $this->saved_attributes = []; $this->initially_was_account = FALSE; } @@ -1970,7 +1970,7 @@ class simplePlugin */ static function plInfo() { - return array(); + return []; } /*! \brief This function generate the needed ACLs for a given attribtues array @@ -1979,7 +1979,7 @@ class simplePlugin */ static function generatePlProvidedAcls ($attributesInfo) { - $plProvidedAcls = array(); + $plProvidedAcls = []; foreach ($attributesInfo as $sectionInfo) { foreach ($sectionInfo['attrs'] as $attr) { $aclInfo = $attr->getAclInfo(); @@ -2019,7 +2019,7 @@ class simplePlugin } $objectType = $key; } - $plCategory = (isset($plInfo['plCategory']) ? $plInfo['plCategory'] : array('user')); + $plCategory = (isset($plInfo['plCategory']) ? $plInfo['plCategory'] : ['user']); $key = key($plCategory); if (is_numeric($key)) { $plCategory = $plCategory[$key]; @@ -2081,7 +2081,7 @@ class simplePlugin /* Check locking */ if ($locks = get_locks($entry_dn)) { session::set('back_plugin', $plug); - session::set('LOCK_VARS_TO_USE', array("/^edit$/", "/^plug$/")); + session::set('LOCK_VARS_TO_USE', ["/^edit$/", "/^plug$/"]); $lock_msg = gen_locked_message($locks, $entry_dn); } else { /* Lock the current entry */ diff --git a/include/simpleplugin/class_simpleService.inc b/include/simpleplugin/class_simpleService.inc index 580492891..65d06ac7f 100644 --- a/include/simpleplugin/class_simpleService.inc +++ b/include/simpleplugin/class_simpleService.inc @@ -27,7 +27,7 @@ class simpleService extends simplePlugin protected $status = ''; - public $conflicts = array(); + public $conflicts = []; public $DisplayName = ''; /*! \brief constructor diff --git a/include/simpleplugin/class_simpleTabs.inc b/include/simpleplugin/class_simpleTabs.inc index edc6049a3..57ccbb831 100644 --- a/include/simpleplugin/class_simpleTabs.inc +++ b/include/simpleplugin/class_simpleTabs.inc @@ -35,13 +35,13 @@ class simpleTabs public $objectType = FALSE; protected $specialTabs = TRUE; - protected $plNotify = array(); + protected $plNotify = []; var $last = ""; var $current = ""; var $disabled = ""; - var $by_name = array(); - var $by_object = array(); + var $by_name = []; + var $by_object = []; var $acl_category; /* A parent object if available, e.g. a management class. */ @@ -69,7 +69,7 @@ class simpleTabs $this->dn = $dn; if (!count($data)) { - $data[] = array('CLASS' => 'plugin','NAME' => 'Error'); + $data[] = ['CLASS' => 'plugin','NAME' => 'Error']; msg_dialog::display(_('Error'), sprintf(_('No plugin definitions found to initialize "%s", please check your configuration file.'), get_class($this)), ERROR_DIALOG); @@ -124,7 +124,7 @@ class simpleTabs $baseobject = NULL; foreach ($this->by_object as $name => $object) { $class = get_class($object); - if (in_array($class, array("reference","acl"))) { + if (in_array($class, ["reference","acl"])) { continue; } if ($baseobject === NULL) { @@ -251,7 +251,7 @@ class simpleTabs } $display .= '<table class="tabs-header"><tbody><tr>'; $index = 0; - $style = array('tab-left', 'tab-active', 'tab-right'); + $style = ['tab-left', 'tab-active', 'tab-right']; foreach ($this->by_name as $class => $name) { /* Activate right tabs with style "tab-right" */ @@ -334,13 +334,13 @@ class simpleTabs protected function check() { global $config; - $messages = array(); + $messages = []; if ($this->getBaseObject()->is_template) { $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); $filter = '(&(objectClass=fdTemplate)(cn='.ldap_escape_f($this->getBaseObject()->_template_cn).'))'; - $ldap->search($filter, array('dn')); + $ldap->search($filter, ['dn']); while ($attrs = $ldap->fetch()) { if ($attrs['dn'] != $this->getBaseObject()->dn) { $messages[] = msgPool::duplicated($this->getBaseObject()->attributesAccess['_template_cn']->getLabel(), $attrs['dn']); @@ -392,12 +392,12 @@ class simpleTabs $new_dn = $baseobject->compute_dn(); @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $new_dn, 'Saving'); } catch (FusionDirectoryException $e) { - return array( + return [ sprintf(_('Failed to compute DN for object: %s'), $e->getMessage()) - ); + ]; } - $errors = array(); + $errors = []; $creation = ($this->dn == 'new'); /* Move ? */ @@ -467,7 +467,7 @@ class simpleTabs * \param array $attrs an LDAP-like values array * \param array $skip Attributes to skip */ - function adapt_from_template($attrs, $skip = array()) + function adapt_from_template($attrs, $skip = []) { foreach ($this->by_object as $key => &$obj) { @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $key, "Adapting"); diff --git a/plugins/addons/dashboard/class_dashBoard.inc b/plugins/addons/dashboard/class_dashBoard.inc index 4ba70276f..cef03948f 100644 --- a/plugins/addons/dashboard/class_dashBoard.inc +++ b/plugins/addons/dashboard/class_dashBoard.inc @@ -23,36 +23,36 @@ class dashboard extends simplePlugin { static function plInfo() { - return array( + return [ 'plShortName' => _('Dashboard'), 'plTitle' => _('Dashboard'), 'plDescription' => _('Statistics and various information'), 'plIcon' => 'geticon.php?context=applications&icon=utilities-system-monitor&size=48', - 'plObjectType' => array( - 'dashboard' => array( + 'plObjectType' => [ + 'dashboard' => [ 'name' => _('Dashboard'), 'tabClass' => 'tabs_dashboard', 'mainAttr' => FALSE - ) - ), - 'plSection' => array('reporting' => array('name' => _('Reporting'), 'priority' => 30)), + ] + ], + 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 30]], 'plPriority' => 0, - 'plProvidedAcls' => array( + 'plProvidedAcls' => [ 'dashboard' => _('See dashboard') - ) - ); + ] + ]; } static function getAttributesInfo() { - return array( - 'stats' => array( + return [ + 'stats' => [ 'name' => _('Statistics'), - 'attrs' => array(new FakeAttribute('stats')), + 'attrs' => [new FakeAttribute('stats')], 'template' => get_template_path('main_stats.tpl', TRUE, dirname(__FILE__)), - ), - ); + ], + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -66,7 +66,7 @@ class dashboard extends simplePlugin function overview_stats() { global $config; - $stats = array(); + $stats = []; foreach ($config->data['OBJECTS'] as $type => $infos) { try { $nb = count(objects::ls($type, NULL, NULL, '', TRUE)); @@ -83,10 +83,10 @@ class dashboard extends simplePlugin if ($nb == 0) { continue; } - $node = array( + $node = [ 'name' => $infos['name'], 'nb' => $nb - ); + ]; if (isset($infos['icon'])) { $node['img'] = $infos['icon']; } else { diff --git a/plugins/addons/dashboard/class_dashBoardPasswords.inc b/plugins/addons/dashboard/class_dashBoardPasswords.inc index fe43bf1b0..229a61beb 100644 --- a/plugins/addons/dashboard/class_dashBoardPasswords.inc +++ b/plugins/addons/dashboard/class_dashBoardPasswords.inc @@ -22,25 +22,25 @@ class dashboardPassword extends simplePlugin { static function plInfo() { - return array( + return [ 'plShortName' => _('Passwords'), 'plDescription' => _('Statistics about passwords'), - 'plObjectType' => array('dashboard'), + 'plObjectType' => ['dashboard'], 'plPriority' => 12, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } static function getAttributesInfo() { - return array( - 'pwds' => array( + return [ + 'pwds' => [ 'name' => _('Passwords statistics'), - 'attrs' => array(new FakeAttribute('pwds_stats')), + 'attrs' => [new FakeAttribute('pwds_stats')], 'template' => get_template_path('pwd_stats.tpl', TRUE, dirname(__FILE__)), - ), - ); + ], + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -64,11 +64,11 @@ class dashboardPassword extends simplePlugin sprintf(_('Password statistics could not be computed because of the following LDAP error: %s'), $e->getMessage()), ERROR_DIALOG ); - $users = array(); + $users = []; } $nb_accounts = count($users); $nb_locked_accounts = 0; - $methods_stats = array(); + $methods_stats = []; foreach ($users as $userPassword) { if (!empty($userPassword)) { if (preg_match("/^\{[^\}]+\}!/", $userPassword)) { @@ -77,10 +77,10 @@ class dashboardPassword extends simplePlugin $method = passwordMethod::get_method($userPassword); $methodClass = get_class($method); if (!isset($methods_stats[$methodClass])) { - $methods_stats[$methodClass] = array( + $methods_stats[$methodClass] = [ 'nb' => 0, 'name' => $method->get_hash() - ); + ]; if ($method->get_hash() == $defaultMethod) { $methods_stats[$methodClass]['style'] = 'default'; } elseif ($method->get_hash() == 'clear') { @@ -95,15 +95,15 @@ class dashboardPassword extends simplePlugin } } - return array( + return [ 'methods' => $methods_stats, 'nb' => $nb_accounts, 'img' => 'geticon.php?context=types&icon=user&size=16', - 'locked_accounts' => array( + 'locked_accounts' => [ 'nb' => $nb_locked_accounts, 'img' => 'geticon.php?context=status&icon=object-locked&size=16' - ), - ); + ], + ]; } } ?> diff --git a/plugins/addons/dashboard/class_dashBoardUsers.inc b/plugins/addons/dashboard/class_dashBoardUsers.inc index e3d72351f..0a80119a2 100644 --- a/plugins/addons/dashboard/class_dashBoardUsers.inc +++ b/plugins/addons/dashboard/class_dashBoardUsers.inc @@ -23,54 +23,54 @@ class dashboardUsers extends simplePlugin { static function plInfo() { - return array( + return [ 'plShortName' => _('Users'), 'plDescription' => _('Statistics about users'), - 'plObjectType' => array('dashboard'), + 'plObjectType' => ['dashboard'], 'plPriority' => 10, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } static function getAttributesInfo() { - return array( - 'userstats' => array( + return [ + 'userstats' => [ 'name' => _('Users statistics'), - 'attrs' => array(new FakeAttribute('users_stats')), + 'attrs' => [new FakeAttribute('users_stats')], 'template' => get_template_path('users_stats.tpl', TRUE, dirname(__FILE__)), - ), - 'groupstats' => array( + ], + 'groupstats' => [ 'name' => _('Groups statistics'), - 'attrs' => array(new FakeAttribute('groups_stats')), + 'attrs' => [new FakeAttribute('groups_stats')], 'template' => get_template_path('groups_stats.tpl', TRUE, dirname(__FILE__)), - ), - 'expired_accounts' => array( + ], + 'expired_accounts' => [ 'name' => _('Expired accounts'), - 'attrs' => array(new FakeAttribute('expired')), + 'attrs' => [new FakeAttribute('expired')], 'template' => get_template_path('users_accounts.tpl', TRUE, dirname(__FILE__)), - ), - ); + ], + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) { parent::__construct($dn, $object, $parent, $mainTab); - $this->expiredAccountsColumns = array( - 'user' => array( + $this->expiredAccountsColumns = [ + 'user' => [ 'uid' => _('Login'), 'cn' => _('Name'), 'telephoneNumber' => _('Phone number'), 'expirationDate' => _('Expiration date'), - ), - 'manager' => array( + ], + 'manager' => [ 'manager_cn' => _('Name'), 'manager_mail' => _('Email'), 'manager_phone' => _('Phone number'), - ) - ); + ] + ]; $this->users_stats = $this->computeUsersStats(); $this->groups_stats = $this->computeGroupsStats(); $this->expired = $this->expired_accounts_info(); @@ -97,15 +97,15 @@ class dashboardUsers extends simplePlugin $nb_samba_accounts = 0; } - return array( - 'accounts' => array( - array('name' => 'mail', 'nb' => $nb_mail_accounts, 'img' => 'geticon.php?context=applications&icon=internet-mail&size=16'), - array('name' => 'posix', 'nb' => $nb_posix_accounts, 'img' => 'geticon.php?context=applications&icon=os-linux&size=16'), - array('name' => 'samba', 'nb' => $nb_samba_accounts, 'img' => 'geticon.php?context=applications&icon=os-windows&size=16') - ), + return [ + 'accounts' => [ + ['name' => 'mail', 'nb' => $nb_mail_accounts, 'img' => 'geticon.php?context=applications&icon=internet-mail&size=16'], + ['name' => 'posix', 'nb' => $nb_posix_accounts, 'img' => 'geticon.php?context=applications&icon=os-linux&size=16'], + ['name' => 'samba', 'nb' => $nb_samba_accounts, 'img' => 'geticon.php?context=applications&icon=os-windows&size=16'] + ], 'nb' => $nb_accounts, 'img' => 'geticon.php?context=types&icon=user&size=16', - ); + ]; } function computeGroupsStats () @@ -132,14 +132,14 @@ class dashboardUsers extends simplePlugin $nb_samba_groups = 0; } - return array( - 'groups' => array( - array('name' => 'mail', 'nb' => $nb_mail_groups, 'img' => 'geticon.php?context=applications&icon=internet-mail&size=16'), - array('name' => 'samba', 'nb' => $nb_samba_groups, 'img' => 'geticon.php?context=applications&icon=os-windows&size=16') - ), + return [ + 'groups' => [ + ['name' => 'mail', 'nb' => $nb_mail_groups, 'img' => 'geticon.php?context=applications&icon=internet-mail&size=16'], + ['name' => 'samba', 'nb' => $nb_samba_groups, 'img' => 'geticon.php?context=applications&icon=os-windows&size=16'] + ], 'nb' => $nb_groups, 'img' => 'geticon.php?context=types&icon=user-group&size=16', - ); + ]; } function expired_accounts_info () @@ -158,24 +158,24 @@ class dashboardUsers extends simplePlugin if (!class_available('posixAccount')) { /* if shadowExpire is not available no way to check expiration */ - return array( + return [ 'columns' => $this->expiredAccountsColumns, - 'accounts' => array(), - 'accounts_next_days' => array(), + 'accounts' => [], + 'accounts_next_days' => [], 'next_days' => $next_expired_days, - ); + ]; } /* search all account with all date, mail, telephone */ try { - $attributes = array( + $attributes = [ 'dn' => 'raw', 'uid' => '*', 'cn' => '*', 'telephoneNumber' => '*', 'manager' => '*', 'shadowExpire' => '*', - ); + ]; if (class_available('mailAccount')) { $attributes['mail'] = 'raw'; } @@ -186,18 +186,18 @@ class dashboardUsers extends simplePlugin sprintf(_('Expired user information could not be computed because of the following LDAP error: %s'), $e->getMessage()), ERROR_DIALOG ); - $users = array(); + $users = []; } catch (FusionDirectoryException $e) { msg_dialog::display( _('Error'), sprintf(_('Expired user information could not be computed because of the following error: %s'), $e->getMessage()), ERROR_DIALOG ); - $users = array(); + $users = []; } - $expired_accounts = array(); - $next_expired_accounts = array(); + $expired_accounts = []; + $next_expired_accounts = []; foreach ($users as $user) { // Test if account is expired now if ($user['shadowExpire'][0] <= $today) { @@ -207,15 +207,15 @@ class dashboardUsers extends simplePlugin } } - uasort($expired_accounts, array('dashboardUsers','compareUsers')); - uasort($next_expired_accounts, array('dashboardUsers','compareUsers')); + uasort($expired_accounts, ['dashboardUsers','compareUsers']); + uasort($next_expired_accounts, ['dashboardUsers','compareUsers']); - return array( + return [ 'columns' => $this->expiredAccountsColumns, 'accounts' => $expired_accounts, 'accounts_next_days' => $next_expired_accounts, 'next_days' => $next_expired_days, - ); + ]; } static function get_user_infos($attrs) @@ -224,7 +224,7 @@ class dashboardUsers extends simplePlugin if (isset($attrs['manager'][0])) { $ldap = $config->get_ldap_link(); - $ldap->cat($attrs['manager'][0], array('cn', 'mail', 'telephoneNumber')); + $ldap->cat($attrs['manager'][0], ['cn', 'mail', 'telephoneNumber']); if ($manager_attrs = $ldap->fetch()) { $manager_cn = (isset($manager_attrs['cn'][0]) ? $manager_attrs['cn'][0] : ''); $manager_mail = (isset($manager_attrs['mail'][0]) ? $manager_attrs['mail'][0] : ''); @@ -247,7 +247,7 @@ class dashboardUsers extends simplePlugin $human_shadowExpire = ''; } - return array( + return [ 'uid' => $attrs['uid'][0], 'cn' => $attrs['cn'][0], 'telephoneNumber' => (isset($attrs['telephoneNumber'][0]) ? $attrs['telephoneNumber'][0] : ''), @@ -256,7 +256,7 @@ class dashboardUsers extends simplePlugin 'manager_mail' => $manager_mail, 'manager_phone' => $manager_phone, 'expirationDate' => $human_shadowExpire, - ); + ]; } static function compareUsers ($a, $b) diff --git a/plugins/admin/acl/class_aclAssignment.inc b/plugins/admin/acl/class_aclAssignment.inc index a28f52420..1c6655f81 100644 --- a/plugins/admin/acl/class_aclAssignment.inc +++ b/plugins/admin/acl/class_aclAssignment.inc @@ -22,31 +22,31 @@ class aclAssignmentDialogWindow extends simplePlugin { static function plInfo() { - return array( + return [ 'plShortName' => _('ACL Assignment Dialog'), 'plDescription' => _('Access control roles assignment dialog'), - 'plCategory' => array('acl'), + 'plCategory' => ['acl'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo() { - return array( - 'properties' => array( + return [ + 'properties' => [ 'name' => _('Properties'), - 'attrs' => array( + 'attrs' => [ new SelectAttribute( _('Mode'), _('Is this applying on complete subtree or only the base?'), 'aclMode', TRUE, - array('subtree', 'base'), 'base', - array(_('Subtree'), _('Base only')) + ['subtree', 'base'], 'base', + [_('Subtree'), _('Base only')] ), new SelectAttribute( _('Role'), _('Role to apply'), 'aclRole', TRUE, - array() + [] ), new BooleanAttribute( _('For all users'), _('Apply this ACL for all LDAP users'), @@ -56,9 +56,9 @@ class aclAssignmentDialogWindow extends simplePlugin _('Members'), _('Users or groups to assign this role to.'), 'aclMembers', TRUE ) - ) - ), - ); + ] + ], + ]; } function __construct ($value, $isContainer = FALSE) @@ -75,11 +75,11 @@ class aclAssignmentDialogWindow extends simplePlugin $this->attributesAccess['aclRole']->setChoices(array_keys($roles), array_values($roles)); $this->attributesAccess['allUsers']->setInLdap(FALSE); $this->attributesAccess['allUsers']->setManagedAttributes( - array( - 'disable' => array( - TRUE => array('aclMembers') - ) - ) + [ + 'disable' => [ + TRUE => ['aclMembers'] + ] + ] ); if ($value !== NULL) { @@ -109,13 +109,13 @@ class aclAssignmentDialogWindow extends simplePlugin function getAclEntry() { - $entry = array( + $entry = [ 'scope' => $this->aclMode, 'role' => $this->aclRole, 'members' => $this->aclMembers, - ); + ]; if ($this->allUsers) { - $entry['members'] = array('*'); + $entry['members'] = ['*']; } return $entry; } @@ -134,7 +134,7 @@ class ACLsAssignmentDialog extends GenericDialog if (isset($simplePlugin->attrs['objectClass'])) { if (count(array_intersect( $simplePlugin->attrs['objectClass'], - array('organizationalUnit', 'organization', 'domain', 'country', 'locality')) + ['organizationalUnit', 'organization', 'domain', 'country', 'locality']) )) { $isContainer = TRUE; } @@ -196,11 +196,11 @@ class ACLsAssignmentAttribute extends DialogOrderedArrayAttribute function readValue($value) { $acl = explode(':', $value); - return array($acl[0], array( + return [$acl[0], [ 'scope' => $acl[1], 'role' => base64_decode($acl[2]), 'members' => array_map('base64_decode', explode(',', $acl[3])), - )); + ]]; } function writeValue($key, $value) @@ -248,9 +248,9 @@ class ACLsAssignmentAttribute extends DialogOrderedArrayAttribute foreach ($this->value as $value) { if (($source['CLASS'] == 'aclRole') && ($value['role'] == $oldvalue)) { return TRUE; - } elseif (in_array($source['CLASS'], array('user','posixGroup','roleGeneric')) && in_array($oldvalue, $value['members'])) { + } elseif (in_array($source['CLASS'], ['user','posixGroup','roleGeneric']) && in_array($oldvalue, $value['members'])) { return TRUE; - } elseif (!in_array($source['CLASS'], array('aclRole','user','posixGroup','roleGeneric'))) { + } elseif (!in_array($source['CLASS'], ['aclRole','user','posixGroup','roleGeneric'])) { trigger_error('unknown source '.$source['CLASS']); } } @@ -259,13 +259,13 @@ class ACLsAssignmentAttribute extends DialogOrderedArrayAttribute class aclAssignment extends simplePlugin { - var $objectclasses = array('gosaAcl'); + var $objectclasses = ['gosaAcl']; static function plInfo() { global $config; - $oc = array( - 'aclAssignment' => array( + $oc = [ + 'aclAssignment' => [ 'aclCategory' => 'acl', 'name' => _('ACL assignment'), 'filter' => 'objectClass=gosaAcl', @@ -273,44 +273,44 @@ class aclAssignment extends simplePlugin 'icon' => 'geticon.php?context=categories&icon=acl&size=16', 'tabClass' => 'simpleTabs_noSpecial', 'mainAttr' => FALSE - ), - ); + ], + ]; if ($config->get_cfg_value('aclTabOnObjects') == 'TRUE') { $oc[] = 'special'; } else { $oc = array_merge($oc, departmentManagement::getDepartmentTypes()); } - return array( + return [ 'plShortName' => _('ACL Assignment'), 'plDescription' => _('Access control roles assignment'), 'plObjectType' => $oc, - 'plForeignKeys' => array( - 'gosaAclEntry' => array( - array('aclRole', 'dn', 'gosaAclEntry=*:*:%b|oldvalue%:*', 'gosaAclEntry=*'), - array('user', 'dn', 'gosaAclEntry=*:*:*:*%b|oldvalue%*', 'gosaAclEntry=*'), - array('posixGroup', 'dn', 'gosaAclEntry=*:*:*:*%b|oldvalue%*', 'gosaAclEntry=*'), - array('roleGeneric', 'dn', 'gosaAclEntry=*:*:*:*%b|oldvalue%*', 'gosaAclEntry=*'), - ) - ), + 'plForeignKeys' => [ + 'gosaAclEntry' => [ + ['aclRole', 'dn', 'gosaAclEntry=*:*:%b|oldvalue%:*', 'gosaAclEntry=*'], + ['user', 'dn', 'gosaAclEntry=*:*:*:*%b|oldvalue%*', 'gosaAclEntry=*'], + ['posixGroup', 'dn', 'gosaAclEntry=*:*:*:*%b|oldvalue%*', 'gosaAclEntry=*'], + ['roleGeneric', 'dn', 'gosaAclEntry=*:*:*:*%b|oldvalue%*', 'gosaAclEntry=*'], + ] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo() { - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('Assignments'), - 'class' => array('fullwidth'), - 'attrs' => array( + 'class' => ['fullwidth'], + 'attrs' => [ new ACLsAssignmentAttribute( '', _('ACL role assignments for this base'), 'gosaAclEntry', FALSE ) - ) - ) - ); + ] + ] + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) diff --git a/plugins/admin/acl/class_aclManagement.inc b/plugins/admin/acl/class_aclManagement.inc index dea452766..3e949b9a2 100644 --- a/plugins/admin/acl/class_aclManagement.inc +++ b/plugins/admin/acl/class_aclManagement.inc @@ -27,24 +27,24 @@ class aclAssignmentCreationDialog extends simplePlugin static function plInfo() { - return array( + return [ 'plShortName' => _('ACL assignment creation'), 'plShortName' => _('ACL assignment creation'), 'plDescription' => _('Create an ACL assignment on an arbitrary dn'), - 'plCategory' => array('acl'), + 'plCategory' => ['acl'], - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } static function getAttributesInfo () { global $config; - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('ACL assignment creation'), - 'class' => array('fullwidth'), - 'attrs' => array( + 'class' => ['fullwidth'], + 'attrs' => [ new StringAttribute ( _('Dn'), _('DN you wish to add assignments for'), 'baseDn', TRUE, @@ -52,9 +52,9 @@ class aclAssignmentCreationDialog extends simplePlugin '/^([^=,]+=[^=,]+,)+'.preg_quote($config->current['BASE'], '/').'$/', 'ou=people,'.$config->current['BASE'] ), - ) - ), - ); + ] + ], + ]; } function __construct ($parent) @@ -107,7 +107,7 @@ class aclAssignmentCreationDialog extends simplePlugin try { $this->simpleManagement->newEntryConfirmed($this->baseDn); } catch (NonExistingLdapNodeException $e) { - msg_dialog::displayChecks(array(_('The dn you entered could not be found in the LDAP'))); + msg_dialog::displayChecks([_('The dn you entered could not be found in the LDAP')]); return TRUE; } return FALSE; @@ -122,9 +122,9 @@ class aclAssignmentCreationDialog extends simplePlugin class aclManagement extends simpleManagement { - protected $objectTypes = array('aclAssignment'); + protected $objectTypes = ['aclAssignment']; - protected $autoFilterAttributes = array('dn', 'cn', 'description', 'ou', 'dc'); + protected $autoFilterAttributes = ['dn', 'cn', 'description', 'ou', 'dc']; protected $departmentBrowser = FALSE; protected $departmentRootVisible = FALSE; @@ -136,17 +136,17 @@ class aclManagement extends simpleManagement static function plInfo() { - return array( + return [ 'plShortName' => _('ACL assignments'), 'plTitle' => _('ACL assignments management'), 'plDescription' => _('Manage ACL roles assignments to users'), 'plIcon' => 'geticon.php?context=categories&icon=acl&size=48', 'plSection' => 'accounts', 'plPriority' => 28, - 'plManages' => array('aclAssignment'), + 'plManages' => ['aclAssignment'], - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } function configureFilter() @@ -168,7 +168,7 @@ class aclManagement extends simpleManagement function configureHeadpage () { /* Remove department types so that we don't mistake assignments with them */ - $this->headpage->objectTypes = array(); + $this->headpage->objectTypes = []; $this->headpage->registerElementFilter('filterLabel', 'aclManagement::filterLabel'); parent::configureHeadpage(); } @@ -213,7 +213,7 @@ class aclManagement extends simpleManagement continue; } if (!is_array($val)) { - $val = array($val); + $val = [$val]; } $ou = htmlentities(reset($val), ENT_COMPAT, 'UTF-8'); } diff --git a/plugins/admin/aclrole/class_aclEditionDialog.inc b/plugins/admin/aclrole/class_aclEditionDialog.inc index 9f7801390..b4c579236 100644 --- a/plugins/admin/aclrole/class_aclEditionDialog.inc +++ b/plugins/admin/aclrole/class_aclEditionDialog.inc @@ -25,8 +25,8 @@ class ACLEditionDialog extends GenericDialog protected $initialAclValue; protected $dialogState = 'create'; protected $aclObject = ''; - protected $aclContents = array(); - protected $savedAclContents = array(); + protected $aclContents = []; + protected $savedAclContents = []; function __construct($simplePlugin, $attribute, $acl = NULL) { @@ -35,7 +35,7 @@ class ACLEditionDialog extends GenericDialog /* New entry gets presets... */ if ($acl === NULL) { - $this->aclContents = array(); + $this->aclContents = []; } else { $this->aclContents = $acl; } @@ -59,7 +59,7 @@ class ACLEditionDialog extends GenericDialog { global $config; - $new_acl = array(); + $new_acl = []; foreach ($_POST as $name => $post) { /* Actions... */ @@ -98,7 +98,7 @@ class ACLEditionDialog extends GenericDialog /* Ordinary ACL */ if (!isset($new_acl[$object])) { - $new_acl[$object] = array(); + $new_acl[$object] = []; } if (isset($new_acl[$object][$attribute])) { $new_acl[$object][$attribute] .= $value; @@ -164,7 +164,7 @@ class ACLEditionDialog extends GenericDialog /* Hide empty categories */ continue; } - $summary = array(); + $summary = []; foreach ($infos['classes'] as $oc) { if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) && $this->aclContents[$oc][0] != '') { @@ -193,17 +193,17 @@ class ACLEditionDialog extends GenericDialog '<input class="center" type="image" src="geticon.php?context=actions&icon=edit-delete&size=16" alt="'._('Delete').'" name="cat_del_'.$section.'" title="'._('Reset category ACL').'"/>'; - $field1 = array('html' => $infos['description'], 'attach' => 'style="width:140px"'); - $field2 = array('html' => $summary); - $field3 = array('html' => $action, 'attach' => 'style="border-right:0px;width:40px"'); - $aclList->AddEntry(array($field1, $field2, $field3)); + $field1 = ['html' => $infos['description'], 'attach' => 'style="width:140px"']; + $field2 = ['html' => $summary]; + $field3 = ['html' => $action, 'attach' => 'style="border-right:0px;width:40px"']; + $aclList->AddEntry([$field1, $field2, $field3]); } $smarty->assign('headline', _('List of available ACL categories')); $smarty->assign('aclEdition', $aclList->DrawList()); } elseif ($this->dialogState == 'edit') { /* Collect objects for selected category */ - $aclObjects = array(); + $aclObjects = []; foreach ($config->data['CATEGORIES'][$this->aclObject]['classes'] as $idx => $class) { if ($idx == 0) { continue; @@ -310,7 +310,7 @@ class ACLEditionDialog extends GenericDialog foreach ($list as $key => $name) { /* Create sub acl if it does not exist */ if (!isset($this->aclContents[$key])) { - $this->aclContents[$key] = array(); + $this->aclContents[$key] = []; } if (!isset($this->aclContents[$key][0])) { $this->aclContents[$key][0] = ''; diff --git a/plugins/admin/aclrole/class_aclRole.inc b/plugins/admin/aclrole/class_aclRole.inc index a435a5099..1856c7e77 100644 --- a/plugins/admin/aclrole/class_aclRole.inc +++ b/plugins/admin/aclrole/class_aclRole.inc @@ -36,13 +36,13 @@ class ACLsAttribute extends DialogOrderedArrayAttribute } } $summary = sprintf(_('Contains settings for these objects: %s'), preg_replace('/, $/', '', $summary)); - return array($summary); + return [$summary]; } function readValue($value) { $acl = explode(':', $value, 2); - return array($acl[0], acl::extractACL($acl[1])); + return [$acl[0], acl::extractACL($acl[1])]; } function writeValue($key, $value) @@ -69,31 +69,31 @@ class ACLsAttribute extends DialogOrderedArrayAttribute class aclRole extends simplePlugin { - var $objectclasses = array('top','gosaRole'); + var $objectclasses = ['top','gosaRole']; static function plInfo() { - return array( + return [ 'plShortName' => _('Role'), 'plDescription' => _('Access control roles'), - 'plObjectType' => array('aclRole' => array( + 'plObjectType' => ['aclRole' => [ 'aclCategory' => 'acl', 'name' => _('ACL role'), 'filter' => 'objectClass=gosaRole', 'ou' => get_ou('aclRoleRDN'), 'icon' => 'geticon.php?context=categories&icon=acl&size=16', - )), + ]], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo() { - return array( - 'properties' => array( + return [ + 'properties' => [ 'name' => _('Properties'), - 'attrs' => array( + 'attrs' => [ new BaseSelectorAttribute(get_ou('aclRoleRDN')), new HostNameAttribute( _('Name'), _('A name for this role'), @@ -103,19 +103,19 @@ class aclRole extends simplePlugin _('Description'), _('Short description of this role'), 'description', FALSE ), - ) - ), - 'acls' => array( + ] + ], + 'acls' => [ 'name' => _('ACLs'), - 'class' => array('fullwidth'), - 'attrs' => array( + 'class' => ['fullwidth'], + 'attrs' => [ new ACLsAttribute( '', _('ACLs which are part of this group'), 'gosaAclTemplate', TRUE ), - ) - ), - ); + ] + ], + ]; } } ?> diff --git a/plugins/admin/aclrole/class_aclRoleManagement.inc b/plugins/admin/aclrole/class_aclRoleManagement.inc index ca6ccda6b..3d135fe2b 100644 --- a/plugins/admin/aclrole/class_aclRoleManagement.inc +++ b/plugins/admin/aclrole/class_aclRoleManagement.inc @@ -21,7 +21,7 @@ class aclRoleManagement extends simpleManagement { // Tab definition - protected $objectTypes = array('aclRole'); + protected $objectTypes = ['aclRole']; protected $departmentBrowser = TRUE; protected $departmentRootVisible = TRUE; @@ -30,18 +30,18 @@ class aclRoleManagement extends simpleManagement /* Return plugin informations for acl handling */ public static function plInfo() { - return array( + return [ 'plShortName' => _('ACL roles'), 'plTitle' => _('ACL roles management'), 'plDescription' => _('Manage ACL roles'), 'plIcon' => 'geticon.php?context=categories&icon=acl&size=48', 'plSection' => 'accounts', 'plPriority' => 27, - 'plCategory' => array('acl'), - 'plManages' => array('aclRole'), + 'plCategory' => ['acl'], + 'plManages' => ['aclRole'], - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } } ?> diff --git a/plugins/admin/departments/class_country.inc b/plugins/admin/departments/class_country.inc index f9ed6aa35..8ce3ee17e 100644 --- a/plugins/admin/departments/class_country.inc +++ b/plugins/admin/departments/class_country.inc @@ -21,14 +21,14 @@ class country extends department { static $namingAttr = "c"; - var $structuralOC = array("country"); + var $structuralOC = ["country"]; static function plInfo() { - return array( + return [ 'plShortName' => _('Country'), 'plDescription' => _('Country'), - 'plObjectType' => array('country' => array( + 'plObjectType' => ['country' => [ 'aclCategory' => 'department', 'name' => _('Country'), 'filter' => '(&(objectClass=country)(objectClass=gosaDepartment))', @@ -36,13 +36,13 @@ class country extends department 'icon' => 'geticon.php?context=types&icon=country&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () diff --git a/plugins/admin/departments/class_dcObject.inc b/plugins/admin/departments/class_dcObject.inc index 63f5e0248..e73bd6f6e 100644 --- a/plugins/admin/departments/class_dcObject.inc +++ b/plugins/admin/departments/class_dcObject.inc @@ -21,15 +21,15 @@ class dcObject extends department { static $namingAttr = "dc"; - var $objectclasses = array("top", "dcObject", "gosaDepartment"); - var $structuralOC = array("locality"); + var $objectclasses = ["top", "dcObject", "gosaDepartment"]; + var $structuralOC = ["locality"]; static function plInfo() { - return array( + return [ 'plShortName' => _('Domain Component'), 'plDescription' => _('Domain Component'), - 'plObjectType' => array('dcObject' => array( + 'plObjectType' => ['dcObject' => [ 'aclCategory' => 'department', 'name' => _('Domain Component'), 'filter' => '(&(objectClass=dcObject)(objectClass=gosaDepartment))', @@ -37,13 +37,13 @@ class dcObject extends department 'icon' => 'geticon.php?context=types&icon=dc&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc index c907951a3..1a23f53d3 100644 --- a/plugins/admin/departments/class_department.inc +++ b/plugins/admin/departments/class_department.inc @@ -24,32 +24,32 @@ class department extends simplePlugin static $namingAttr = 'ou'; /* Do not append the structural object classes here, they are added dynamically in the constructor */ - var $objectclasses = array("top", "gosaDepartment"); - var $structuralOC = array("organizationalUnit"); + var $objectclasses = ["top", "gosaDepartment"]; + var $structuralOC = ["organizationalUnit"]; static function plInfo() { - return array( + return [ 'plShortName' => _('Department'), 'plDescription' => _('Departments'), - 'plCategory' => array('department' => array('objectClass' => 'gosaDepartment', 'description' => _('Departments'))), + 'plCategory' => ['department' => ['objectClass' => 'gosaDepartment', 'description' => _('Departments')]], 'plObjectType' => - array( - 'department' => array( + [ + 'department' => [ 'name' => _('Department'), 'filter' => '(&(objectClass=organizationalUnit)(objectClass=gosaDepartment))', 'ou' => '', 'icon' => 'geticon.php?context=places&icon=folder&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - ) - ), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ] + ], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo() @@ -58,10 +58,10 @@ class department extends simplePlugin } static function getDepartmentAttributesInfo($name) { - $attributesInfo = array( - 'properties' => array( + $attributesInfo = [ + 'properties' => [ 'name' => _('Properties'), - 'attrs' => array( + 'attrs' => [ new BaseSelectorAttribute(''), new StringAttribute( sprintf(_('Name of %s'), $name), sprintf(_('A name for this %s'), $name), @@ -84,11 +84,11 @@ class department extends simplePlugin _('Manager'), sprintf(_('Manager of this %s'), $name), 'manager', FALSE ) - ) - ), - 'location' => array( + ] + ], + 'location' => [ 'name' => _('Location'), - 'attrs' => array( + 'attrs' => [ new StringAttribute( _('State'), _('State'), 'st', FALSE ), @@ -112,9 +112,9 @@ class department extends simplePlugin _('Fax'), _('Facsimile telephone number'), 'facsimileTelephoneNumber', FALSE ), - ) - ), - ); + ] + ], + ]; if (static::$namingAttr != 'ou') { $attributesInfo['properties']['attrs'][] = new HiddenAttribute('ou'); } @@ -130,7 +130,7 @@ class department extends simplePlugin if ($dn == "" || $dn == "new" || !$ldap->dn_exists($dn)) { $this->objectclasses = array_merge($this->structuralOC, $this->objectclasses); } else { - $ldap->cat($dn, array("structuralObjectClass")); + $ldap->cat($dn, ["structuralObjectClass"]); $attrs = $ldap->fetch(); if (isset($attrs['structuralObjectClass']['count'])) { for ($i = 0; $i < $attrs['structuralObjectClass']['count']; $i++) { @@ -146,7 +146,7 @@ class department extends simplePlugin parent::__construct($dn, $object, $parent, $mainTab); - $categoriesList = $config->get_cfg_value('DepartmentCategories', array()); + $categoriesList = $config->get_cfg_value('DepartmentCategories', []); /* Insert current value to possibilities */ if (isset($this->attributesAccess['businessCategory'])) { diff --git a/plugins/admin/departments/class_departmentManagement.inc b/plugins/admin/departments/class_departmentManagement.inc index e5e349f03..6d81d0155 100644 --- a/plugins/admin/departments/class_departmentManagement.inc +++ b/plugins/admin/departments/class_departmentManagement.inc @@ -29,17 +29,17 @@ class departmentManagement extends simpleManagement /* Return plugin information for acl handling */ static function plInfo() { - return array( + return [ 'plShortName' => _('Departments'), 'plTitle' => _('Manage departments'), 'plDescription' => _('Manage departments, countries, domain components, domains, localities and organization nodes,'), 'plIcon' => 'geticon.php?context=places&icon=folder&size=48', - 'plSection' => array('accounts' => array('name' => _('Users and groups'), 'priority' => 0)), + 'plSection' => ['accounts' => ['name' => _('Users and groups'), 'priority' => 0]], 'plPriority' => 0, 'plManages' => static::getDepartmentTypes(), - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } function __construct() @@ -83,7 +83,7 @@ class departmentManagement extends simpleManagement protected function removeEntryRequested($action, array $target, array $all) { global $config; - $target = array_remove_entries(array($config->current['BASE']), $target); + $target = array_remove_entries([$config->current['BASE']], $target); return parent::removeEntryRequested($action, $target, $all); } @@ -106,7 +106,7 @@ class departmentManagement extends simpleManagement static function getDepartmentTypes() { - return array('DEPARTMENT','COUNTRY','DCOBJECT','DOMAIN','LOCALITY','ORGANIZATION'); + return ['DEPARTMENT','COUNTRY','DCOBJECT','DOMAIN','LOCALITY','ORGANIZATION']; } } ?> diff --git a/plugins/admin/departments/class_domain.inc b/plugins/admin/departments/class_domain.inc index 8cf7d844b..abc4eae16 100644 --- a/plugins/admin/departments/class_domain.inc +++ b/plugins/admin/departments/class_domain.inc @@ -21,15 +21,15 @@ class domain extends department { static $namingAttr = "dc"; - var $objectclasses = array("top", "domain", "gosaDepartment"); - var $structuralOC = array("domain"); + var $objectclasses = ["top", "domain", "gosaDepartment"]; + var $structuralOC = ["domain"]; static function plInfo() { - return array( + return [ 'plShortName' => _('Domain'), 'plDescription' => _('Domain'), - 'plObjectType' => array('domain' => array( + 'plObjectType' => ['domain' => [ 'aclCategory' => 'department', 'name' => _('Domain'), 'filter' => '(&(objectClass=domain)(objectClass=gosaDepartment))', @@ -37,13 +37,13 @@ class domain extends department 'icon' => 'geticon.php?context=types&icon=domain&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () diff --git a/plugins/admin/departments/class_locality.inc b/plugins/admin/departments/class_locality.inc index af8873e27..db2b137f8 100644 --- a/plugins/admin/departments/class_locality.inc +++ b/plugins/admin/departments/class_locality.inc @@ -21,15 +21,15 @@ class locality extends department { static $namingAttr = "l"; - var $objectclasses = array("top", "gosaDepartment"); - var $structuralOC = array("locality"); + var $objectclasses = ["top", "gosaDepartment"]; + var $structuralOC = ["locality"]; static function plInfo() { - return array( + return [ 'plShortName' => _('Locality'), 'plDescription' => _('Locality'), - 'plObjectType' => array('locality' => array( + 'plObjectType' => ['locality' => [ 'aclCategory' => 'department', 'name' => _('Locality'), 'filter' => '(&(!(objectClass=dcObject))(objectClass=locality)(objectClass=gosaDepartment))', @@ -37,13 +37,13 @@ class locality extends department 'icon' => 'geticon.php?context=types&icon=locality&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () diff --git a/plugins/admin/departments/class_organization.inc b/plugins/admin/departments/class_organization.inc index 93e82ff29..960cf5f6b 100644 --- a/plugins/admin/departments/class_organization.inc +++ b/plugins/admin/departments/class_organization.inc @@ -21,15 +21,15 @@ class organization extends department { static $namingAttr = "o"; - var $objectclasses = array("top", "gosaDepartment"); - var $structuralOC = array("organization"); + var $objectclasses = ["top", "gosaDepartment"]; + var $structuralOC = ["organization"]; static function plInfo() { - return array( + return [ 'plShortName' => _('Organization'), 'plDescription' => _('Organization'), - 'plObjectType' => array('organization' => array( + 'plObjectType' => ['organization' => [ 'aclCategory' => 'department', 'name' => _('Organization'), 'filter' => '(&(objectClass=organization)(objectClass=gosaDepartment))', @@ -37,13 +37,13 @@ class organization extends department 'icon' => 'geticon.php?context=types&icon=organization&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index 75155b3c0..9f4a7f464 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -21,7 +21,7 @@ class groupManagement extends simpleManagement { - protected $objectTypes = array('ogroup', 'role', 'group'); + protected $objectTypes = ['ogroup', 'role', 'group']; protected $autoFilter = FALSE; @@ -31,17 +31,17 @@ class groupManagement extends simpleManagement static function plInfo() { - return array( + return [ 'plShortName' => _('Groups and roles'), 'plTitle' => _('Manage groups and roles'), 'plDescription' => _('Allows you to manage object groups, POSIX groups and roles'), 'plIcon' => 'geticon.php?context=types&icon=resource-group&size=48', 'plSection' => 'accounts', - 'plManages' => array('ogroup', 'group', 'role'), + 'plManages' => ['ogroup', 'group', 'role'], 'plPriority' => 20, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } function __construct() @@ -89,24 +89,24 @@ class groupManagement extends simpleManagement // Register Daemon Events if ($this->siActive) { - $this->headpage->xmlData['actionmenu']['action'][4]['action'] = array(); - $this->headpage->xmlData['actionmenu']['action'][5]['action'] = array(); + $this->headpage->xmlData['actionmenu']['action'][4]['action'] = []; + $this->headpage->xmlData['actionmenu']['action'][5]['action'] = []; $events = argonautEventTypes::get_event_types(); foreach ($events as $name => $data) { $this->registerAction('T_'.$name, 'handleEvent'); - $this->headpage->xmlData['actionmenu']['action'][4]['action'][] = array( + $this->headpage->xmlData['actionmenu']['action'][4]['action'][] = [ 'name' => 'T_'.$name, 'type' => 'entry', 'image' => $data['img'], 'label' => $data['name'], - ); + ]; $this->registerAction('S_'.$name, 'handleEvent'); - $this->headpage->xmlData['actionmenu']['action'][5]['action'][] = array( + $this->headpage->xmlData['actionmenu']['action'][5]['action'][] = [ 'name' => 'S_'.$name, 'type' => 'entry', 'image' => $data['img'], 'label' => $data['name'], - ); + ]; } } else { unset($this->headpage->xmlData['actionmenu']['action'][3]); @@ -139,7 +139,7 @@ class groupManagement extends simpleManagement $event = preg_replace('/^[TS]_/', '', $action); // Now send FAI/Argonaut events here. - $mac = array(); + $mac = []; // Collect target mac addresses $ldap = $config->get_ldap_link(); @@ -170,12 +170,12 @@ class groupManagement extends simpleManagement /* Skip installation or update trigerred events, * if this entry is currently processing. */ - if ($triggered && in_array($event, array('reinstall','update'))) { + if ($triggered && in_array($event, ['reinstall','update'])) { foreach ($mac as $key => $mac_address) { if ($o_queue->is_currently_installing($mac_address)) { msg_dialog::display(_('Action canceled'), sprintf(_('System %s is currently installing'), $dn), ERROR_DIALOG); unset($mac[$key]); - logging::log('security', 'systems/'.get_class($this), '', array(), 'Skip adding "argonautAction::'.$event.'" for mac "'.$mac_address.'", there is already a job in progress.'); + logging::log('security', 'systems/'.get_class($this), '', [], 'Skip adding "argonautAction::'.$event.'" for mac "'.$mac_address.'", there is already a job in progress.'); } } } @@ -246,7 +246,7 @@ class groupManagement extends simpleManagement static function filterProperties($row, $dn, $objectType, $attrs, $gosaGroupObjects = NULL) { global $config; - static $grouptabs = array(); + static $grouptabs = []; // Load information if needed $result = ' '; @@ -318,42 +318,42 @@ class groupManagement extends simpleManagement function renderList() { $smarty = get_smarty(); - $filters = array( - array('id' => 'USER', 'label' => _('Show user groups')), - array('id' => 'ROLE', 'label' => _('Show organizational roles')), - array('id' => 'APPLICATION', 'label' => _('Show application groups')), - array('id' => 'GROUP', 'label' => _('Show groups of groups')), - array('id' => 'UNKNOWN', 'label' => _('Show unidentified groups')), - ); + $filters = [ + ['id' => 'USER', 'label' => _('Show user groups')], + ['id' => 'ROLE', 'label' => _('Show organizational roles')], + ['id' => 'APPLICATION', 'label' => _('Show application groups')], + ['id' => 'GROUP', 'label' => _('Show groups of groups')], + ['id' => 'UNKNOWN', 'label' => _('Show unidentified groups')], + ]; if (class_available('posixGroup')) { - $filters[] = array('id' => 'PRIMARY', 'label' => _('Show primary groups')); + $filters[] = ['id' => 'PRIMARY', 'label' => _('Show primary groups')]; if (class_available('mailAccount')) { - $filters[] = array('id' => 'MAIL', 'label' => _('Show mail groups')); + $filters[] = ['id' => 'MAIL', 'label' => _('Show mail groups')]; } if (class_available('sambaAccount')) { - $filters[] = array('id' => 'SAMBA', 'label' => _('Show samba groups')); + $filters[] = ['id' => 'SAMBA', 'label' => _('Show samba groups')]; } } if (class_available('simpleSecurityObject')) { - $filters[] = array('id' => 'SIMPLESECURITYOBJECT', 'label' => _('Show DSA entries')); + $filters[] = ['id' => 'SIMPLESECURITYOBJECT', 'label' => _('Show DSA entries')]; } if (class_available('systemManagement')) { $filters = array_merge( $filters, - array( - array('id' => 'SERVER', 'label' => _('Show server groups')), - array('id' => 'WORKSTATION', 'label' => _('Show workstation groups')), - array('id' => 'TERMINAL', 'label' => _('Show terminal groups')), - array('id' => 'PRINTER', 'label' => _('Show printer groups')), - array('id' => 'PHONE', 'label' => _('Show phone groups')), - ) + [ + ['id' => 'SERVER', 'label' => _('Show server groups')], + ['id' => 'WORKSTATION', 'label' => _('Show workstation groups')], + ['id' => 'TERMINAL', 'label' => _('Show terminal groups')], + ['id' => 'PRINTER', 'label' => _('Show printer groups')], + ['id' => 'PHONE', 'label' => _('Show phone groups')], + ] ); } if (!static::$skipTemplates) { - $filters[] = array( + $filters[] = [ 'id' => 'FILTERTEMPLATE', 'label' => sprintf(_('Show %s'), _('Template')) - ); + ]; } $smarty->assign('objectFilters', $filters); $this->headpage->update(); diff --git a/plugins/admin/groups/class_roleGeneric.inc b/plugins/admin/groups/class_roleGeneric.inc index c1e277151..55f8fab2b 100644 --- a/plugins/admin/groups/class_roleGeneric.inc +++ b/plugins/admin/groups/class_roleGeneric.inc @@ -28,48 +28,48 @@ class RoleMembersAttribute extends UsersAttribute if ($config->get_cfg_value('RestrictRoleMembers') == 'TRUE') { if ($this->whitelistDns === NULL) { /* Computes a list of members of all groups within our branch */ - $groups = objects::ls('ogroup', array('member' => '*'), $this->plugin->base); + $groups = objects::ls('ogroup', ['member' => '*'], $this->plugin->base); if (empty($groups)) { - $this->whitelistDns = array(); + $this->whitelistDns = []; } else { $this->whitelistDns = call_user_func_array('array_merge_recursive', $groups)['member']; } } - return array( - 'branches' => array($this->plugin->base), + return [ + 'branches' => [$this->plugin->base], 'dn' => $this->whitelistDns, - ); + ]; } else { - return array(); + return []; } } } class roleGeneric extends simplePlugin { - var $objectclasses = array('organizationalRole'); + var $objectclasses = ['organizationalRole']; static function plInfo() { - return array( + return [ 'plShortName' => _('Role'), 'plDescription' => _('Role information'), - 'plObjectType' => array('role' => - array( + 'plObjectType' => ['role' => + [ 'name' => _('Role'), 'description' => _('Organizational role'), 'ou' => get_ou('roleRDN'), 'filter' => '(&(objectClass=organizationalRole)(!(objectClass=simpleSecurityObject)))', 'icon' => 'geticon.php?context=types&icon=role&size=16', 'mainAttr' => 'cn', - ) - ), - 'plForeignKeys' => array( - 'roleOccupant' => array('user','dn','roleOccupant=%oldvalue%','*') - ), + ] + ], + 'plForeignKeys' => [ + 'roleOccupant' => ['user','dn','roleOccupant=%oldvalue%','*'] + ], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } /*! @@ -77,10 +77,10 @@ class roleGeneric extends simplePlugin */ static function getAttributesInfo () { - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('Information'), - 'attrs' => array( + 'attrs' => [ new BaseSelectorAttribute (get_ou('roleRDN')), new StringAttribute( _('Name'), _('Name of this group'), @@ -99,25 +99,25 @@ class roleGeneric extends simplePlugin _('Fax number'), _('Fax number'), 'facsimileTelephoneNumber' ) - ) - ), - 'members' => array( + ] + ], + 'members' => [ 'name' => _('Role members'), - 'attrs' => array( + 'attrs' => [ new RoleMembersAttribute ( '', _('Add users for the role'), 'roleOccupant', FALSE ) - ) - ) - ); + ] + ] + ]; } function ldap_save() { global $ui; - $errors = array(); + $errors = []; if (isset($this->attrs['roleOccupant'])) { $savedOccupants = $this->attributesAccess['roleOccupant']->getInitialValue(); diff --git a/plugins/admin/groups/tabs_ogroups.inc b/plugins/admin/groups/tabs_ogroups.inc index 5c26b4389..55bec8e42 100644 --- a/plugins/admin/groups/tabs_ogroups.inc +++ b/plugins/admin/groups/tabs_ogroups.inc @@ -21,16 +21,16 @@ class ogrouptabs extends simpleTabs_noSpecial { protected $groupObjects = NULL; - protected $removed_tabs = array(); + protected $removed_tabs = []; - function __construct($type, $dn, $copied_object = NULL) + function __construct ($type, $dn, $copied_object = NULL) { parent::__construct($type, $dn, $copied_object); $this->loadtabs($this->getBaseObject()->gosaGroupObjects); } - function loadtabs($gosaGroupObjects) + function loadtabs ($gosaGroupObjects) { global $config; if ($this->groupObjects == $gosaGroupObjects) { @@ -39,21 +39,21 @@ class ogrouptabs extends simpleTabs_noSpecial $this->groupObjects = $gosaGroupObjects; $objects = preg_replace('/[\[\]]/', '', $gosaGroupObjects); - $tabs = array(); + $tabs = []; if (strlen($objects)) { if (isset($config->data['TABS']['OGROUP-DYNAMICTABS'])) { $dtabs = $config->data['TABS']['OGROUP-DYNAMICTABS']; } else { - $dtabs = array(); + $dtabs = []; } $tabs = FALSE; for ($i = 0; $i < strlen($objects); $i++) { - if (in_array($objects[$i], array('I','G'))) { + if (in_array($objects[$i], ['I','G'])) { /* Ignore unknown objects and groups */ continue; } $otype = ogroup::$objectTypes[$objects[$i]]; - $otabs = array(); + $otabs = []; if (isset($config->data['TABS'][strtoupper($otype).'TABS'])) { $otabs = array_uintersect( $dtabs, @@ -129,7 +129,7 @@ class ogrouptabs extends simpleTabs_noSpecial unset($this->plNotify["$class"]); } - function gen_tabs($disabled = FALSE) + function gen_tabs ($disabled = FALSE) { $this->loadtabs($this->getBaseObject()->getGroupObjectTypes()); return parent::gen_tabs($disabled); @@ -138,7 +138,7 @@ class ogrouptabs extends simpleTabs_noSpecial /*! * \brief Sets the active tabs from this instance to an other one. Used by templates */ - function setActiveTabs(&$tabObject) + function setActiveTabs (&$tabObject) { $tabObject->loadtabs($this->groupObjects); foreach ($this->by_object as $class => $plugin) { @@ -148,12 +148,12 @@ class ogrouptabs extends simpleTabs_noSpecial } } - function check($ignore_account = FALSE) + function check ($ignore_account = FALSE) { return parent::check(FALSE); } - function save() + function save () { $errors = parent::save(); @@ -174,7 +174,7 @@ class ogrouptabs extends simpleTabs_noSpecial return $errors; } - function save_object($save_current = FALSE) + function save_object ($save_current = FALSE) { parent::save_object($save_current); diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 3424dc787..fe034506e 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -22,7 +22,7 @@ class userManagement extends simpleManagement { - protected $objectTypes = array('user'); + protected $objectTypes = ['user']; protected $departmentBrowser = TRUE; protected $departmentRootVisible = FALSE; @@ -36,22 +36,22 @@ class userManagement extends simpleManagement public static $skipTemplates = FALSE; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('Users'), 'plTitle' => _('Manage users'), 'plDescription' => _('Manage user accounts and their properties'), 'plIcon' => 'geticon.php?context=types&icon=user&size=48', 'plSection' => 'accounts', - 'plManages' => array('user'), + 'plManages' => ['user'], 'plPriority' => 10, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } - function __construct() + function __construct () { $this->filterXMLPath = get_template_path('user-filter.xml', TRUE, dirname(__FILE__)); $this->listXMLPath = get_template_path('user-list.xml', TRUE, dirname(__FILE__)); @@ -80,7 +80,7 @@ class userManagement extends simpleManagement { parent::configureFilter(); - $classes = array(); + $classes = []; if (class_available('posixAccount')) { $classes[] = 'posixAccount'; } else { @@ -121,7 +121,7 @@ class userManagement extends simpleManagement /* !\brief Lock/unlock multiple users. */ - function lockUsers($action, array $target, array $all) + function lockUsers ($action, array $target, array $all) { if (!count($target)) { return; @@ -136,12 +136,12 @@ class userManagement extends simpleManagement /* !\brief Locks/unlocks the given user(s). */ - function lockEntry($action, $entry, $all, $type = 'toggle') + function lockEntry ($action, $entry, $all, $type = 'toggle') { global $config, $ui; // Filter out entries we are not allowed to modify - $disallowed = array(); - $allowed = array(); + $disallowed = []; + $allowed = []; foreach ($entry as $dn) { if (!preg_match('/w/', $ui->get_permissions($dn, 'user/user', 'userLock'))) { $disallowed[] = $dn; @@ -156,7 +156,7 @@ class userManagement extends simpleManagement // Try to lock/unlock the rest of the entries. $ldap = $config->get_ldap_link(); foreach ($allowed as $dn) { - $ldap->cat($dn, array('userPassword')); + $ldap->cat($dn, ['userPassword']); if ($ldap->count() == 1) { // We can't lock empty passwords. @@ -207,7 +207,7 @@ class userManagement extends simpleManagement } } - static function filterLockImage($userPassword) + static function filterLockImage ($userPassword) { $image = 'images/empty.png'; if (isset($userPassword[0]) && preg_match('/^\{[^\}]/', $userPassword[0])) { @@ -220,7 +220,7 @@ class userManagement extends simpleManagement return $image; } - static function filterLockLabel($userPassword) + static function filterLockLabel ($userPassword) { $label = ''; if (isset($userPassword[0]) && preg_match('/^\{[^\}]/', $userPassword[0])) { @@ -233,10 +233,10 @@ class userManagement extends simpleManagement return $label; } - static function filterProperties($row, $dn, $attrs) + static function filterProperties ($row, $dn, $attrs) { global $config; - static $usertabs = array(); + static $usertabs = []; if (empty($usertabs)) { foreach ($config->data['TABS']['USERTABS'] as $plug) { if ($plug['CLASS'] == 'user') { diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc index c8e193537..a309d0f17 100644 --- a/plugins/config/class_configInLdap.inc +++ b/plugins/config/class_configInLdap.inc @@ -25,7 +25,7 @@ class DebugLevelAttribute extends SetAttribute { if (isset($attrs[$this->getLdapName()])) { $value = $attrs[$this->getLdapName()][0]; - $this->value = array(); + $this->value = []; foreach ($this->attribute->getChoices() as $choice) { if ($value & $choice) { $this->value[] = $choice; @@ -36,7 +36,7 @@ class DebugLevelAttribute extends SetAttribute } } - function computeLdapValue() + function computeLdapValue () { $value = 0; foreach ($this->value as $v) { @@ -48,49 +48,49 @@ class DebugLevelAttribute extends SetAttribute class configInLdap extends simplePlugin { - var $objectclasses = array("fusionDirectoryConf"); + var $objectclasses = ["fusionDirectoryConf"]; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('Configuration'), 'plTitle' => _('FusionDirectory configuration'), 'plDescription' => _('Configuration screen of FusionDirectory'), 'plIcon' => 'geticon.php?context=categories&icon=settings&size=48', - 'plObjectType' => array( - 'configuration' => array( + 'plObjectType' => [ + 'configuration' => [ 'name' => _('FusionDirectory configuration'), 'filter' => 'objectClass=fusionDirectoryConf', 'tabClass' => 'tabs_configInLdap', 'icon' => 'geticon.php?context=categories&icon=settings&size=16', 'mainAttr' => FALSE, 'ou' => preg_replace('/^[^,]+,/', '', CONFIGRDN) - ) - ), - 'plSection' => array('conf' => array('name' => _('Configuration'), 'priority' => 20)), - 'plManages' => array('configuration'), + ] + ], + 'plSection' => ['conf' => ['name' => _('Configuration'), 'priority' => 20]], + 'plManages' => ['configuration'], 'plPriority' => 0, 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () { global $config; - $plugins = array(); + $plugins = []; if (session::is_set('plist')) { $plugins = array_keys(session::get('plist')->info); } sort($plugins); - return array( - 'look_n_feel' => array( + return [ + 'look_n_feel' => [ 'name' => _('Look and feel'), - 'attrs' => array( + 'attrs' => [ new SelectAttribute ( _('Language'), _('Language of the application. If \'automatic\' or not available, the one asked by the browser will be used. This setting can be overriden per user.'), 'fdLanguage', FALSE, - array('') + [''] ), new SelectAttribute ( _('Theme'), _('Theme to be used'), @@ -101,14 +101,14 @@ class configInLdap extends simplePlugin new SelectAttribute ( _('Timezone'), _('Timezone to be used'), 'fdTimezone', TRUE, - array('America/New_York') + ['America/New_York'] ), new HiddenAttribute ('fusionConfigMd5'), - ) - ), - 'core_settings' => array( + ] + ], + 'core_settings' => [ 'name' => _('Core settings'), - 'attrs' => array( + 'attrs' => [ new IntAttribute ( _('LDAP size limit'), _('Defines the number of entries to get from LDAP by default.'), 'fdLdapSizeLimit', FALSE, @@ -118,7 +118,7 @@ class configInLdap extends simplePlugin _('Edit locking'), _('Check if a entry currently being edited has been modified outside of FusionDirectory in the meantime.'), 'fdModificationDetectionAttribute', FALSE, - array('', 'entryCSN', 'contextCSN'), 'entryCSN' + ['', 'entryCSN', 'contextCSN'], 'entryCSN' ), new BooleanAttribute ( _('Enable logging'), @@ -147,15 +147,15 @@ class configInLdap extends simplePlugin 'fdWildcardForeignKeys', FALSE, TRUE ), - ) - ), - 'password' => array( + ] + ], + 'password' => [ 'name' => _('Password settings'), - 'attrs' => array( + 'attrs' => [ new SelectAttribute ( _('Password default hash'), _('Default hash to be used'), 'fdPasswordDefaultHash', TRUE, - array('ssha') + ['ssha'] ), new BooleanAttribute ( _('Force default hash'), _('Force the use of the default password hash'), @@ -184,17 +184,17 @@ class configInLdap extends simplePlugin _('SASL Exop'), _('Attribute to be stored in the userPassword attribute'), 'fdSaslExop' ), - ) - ), - 'login' => array( + ] + ], + 'login' => [ 'name' => _('Login and session'), - 'attrs' => array( + 'attrs' => [ new SelectAttribute ( _('Login attribute'), _('Which LDAP attribute should be used as the login name during login.'), 'fdLoginAttribute', TRUE, - array('uid', 'mail', 'uid,mail'), 'uid', - array('uid', 'mail', 'both') + ['uid', 'mail', 'uid,mail'], 'uid', + ['uid', 'mail', 'both'] ), new BooleanAttribute ( _('Enforce encrypted connections'), @@ -227,11 +227,11 @@ class configInLdap extends simplePlugin 'fdHttpHeaderAuthHeaderName', FALSE, 'AUTH_USER' ), - ) - ), - 'ssl' => array( + ] + ], + 'ssl' => [ 'name' => _('SSL'), - 'attrs' => array( + 'attrs' => [ new TrimmedStringAttribute ( _('Key path'), _('Path to FusionDirectory private key. Unused for now.'), 'fdSslKeyPath', FALSE, @@ -247,11 +247,11 @@ class configInLdap extends simplePlugin 'fdSslCaCertPath', FALSE, '/etc/ssl/certs/ca.cert' ), - ) - ), - 'cas' => array( + ] + ], + 'cas' => [ 'name' => _('CAS'), - 'attrs' => array( + 'attrs' => [ new BooleanAttribute ( _('Enable CAS'), _('CAS login will be used instead of LDAP bind'), 'fdCasActivated', FALSE, @@ -277,16 +277,16 @@ class configInLdap extends simplePlugin 'fdCasContext', FALSE, '/cas' ), - ) - ), - 'people_and_group' => array( + ] + ], + 'people_and_group' => [ 'name' => _('People and group storage'), - 'class' => array('critical'), - 'attrs' => array( + 'class' => ['critical'], + 'attrs' => [ new SelectAttribute ( _('People DN attribute'), _('Attribute to use at the beginning of users dn'), 'fdAccountPrimaryAttribute', TRUE, - array('uid', 'cn') + ['uid', 'cn'] ), new StringAttribute ( _('CN pattern'), _('The pattern to use to build the common name field'), @@ -321,11 +321,11 @@ class configInLdap extends simplePlugin _('Postal address pattern'), _('When using separate address fields, you can use a pattern to fill postalAddress field.'), 'fdPostalAddressPattern' ), - ) - ), - 'debug' => array( + ] + ], + 'debug' => [ 'name' => _('Debugging'), - 'attrs' => array( + 'attrs' => [ new BooleanAttribute ( _('Display errors'), _('Shows PHP errors in the upper part of the screen. This should be disabled in productive deployments, because there might be some passwords in it.'), @@ -346,18 +346,18 @@ class configInLdap extends simplePlugin _('Debug level'), _('Display certain information on each page load.'), 'fdDebugLevel', FALSE, - array(DEBUG_TRACE, DEBUG_LDAP, DEBUG_DB, DEBUG_SHELL, DEBUG_POST, - DEBUG_SESSION, DEBUG_ACL, DEBUG_SI, DEBUG_MAIL), + [DEBUG_TRACE, DEBUG_LDAP, DEBUG_DB, DEBUG_SHELL, DEBUG_POST, + DEBUG_SESSION, DEBUG_ACL, DEBUG_SI, DEBUG_MAIL], DEBUG_TRACE, - array('Trace', 'LDAP', 'Database', 'Shell', 'POST', - 'SESSION', 'ACL', 'SI', 'Mail') + ['Trace', 'LDAP', 'Database', 'Shell', 'POST', + 'SESSION', 'ACL', 'SI', 'Mail'] ) ), - ) - ), - 'miscellaneous' => array( + ] + ], + 'miscellaneous' => [ 'name' => _('Miscellaneous'), - 'attrs' => array( + 'attrs' => [ new BooleanAttribute ( _('Display summary in listings'), _('Determines whether a status bar will be shown on the bottom of lists, displaying a short summary of type and number of elements in the list.'), @@ -374,42 +374,42 @@ class configInLdap extends simplePlugin _('Available department categories'), _('Available categories in the departments dropdown'), 'fdDepartmentCategories', FALSE ), - array() + [] ), new OrderedArrayAttribute( new PipeSeparatedCompositeAttribute( _('Use this to hide some menu entry to specific groups of users'), 'fdPluginsMenuBlacklist', - array( + [ new SelectAttribute( '', _('Group or role'), 'blacklistGroup', TRUE, - array() + [] ), new SelectAttribute( '', _('Plugin to blacklist'), 'blacklistPlugin', TRUE, - array() + [] ), - ), + ], '', _('Plugin menu blacklist') ), // no order FALSE, - array() + [] ) - ) - ), - 'hooks' => array( + ] + ], + 'hooks' => [ 'name' => _('Hooks'), - 'class' => array('fullwidth'), - 'attrs' => array( + 'class' => ['fullwidth'], + 'attrs' => [ new OrderedArrayAttribute ( new CompositeAttribute ( _('Hooks that are called when specific actions happens'), 'fdTabHook', - array( + [ new SelectAttribute( _('Tab'), _('The tab that this hook concerns'), 'hookTab', TRUE, @@ -418,22 +418,22 @@ class configInLdap extends simplePlugin new SelectAttribute( _('Mode'), _('When to call this command'), 'hookMode', TRUE, - array('postcreate', 'postremove', 'postmodify', + ['postcreate', 'postremove', 'postmodify', 'precreate', 'preremove', 'premodify', 'check', - 'prelock', 'postlock', 'preunlock', 'postunlock') + 'prelock', 'postlock', 'preunlock', 'postunlock'] ), new TextAreaAttribute( _('Command'), _('The command that will be called'), 'hookCmd', TRUE ) - ), + ], '/^([^\\|]+)\\|([^\\|]+)\\|(.*)$/', '%s|%s|%s', '', // acl _('Hooks') ), FALSE, // non-ordered - array(), + [], TRUE // edition ), new BooleanAttribute ( @@ -441,9 +441,9 @@ class configInLdap extends simplePlugin _('When enabled successful hook execution output is displayed to the user using a dialog.'), 'fdDisplayHookOutput' ), - ) - ), - ); + ] + ], + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE, $attributesInfo = NULL) @@ -453,7 +453,7 @@ class configInLdap extends simplePlugin /* Languages */ $languages = Language::getList(TRUE); asort($languages); - $languages = array_merge(array("" => _("Automatic")), $languages); + $languages = array_merge(["" => _("Automatic")], $languages); $attributesInfo['look_n_feel']['attrs'][0]->setChoices(array_keys($languages), array_values($languages)); /* Timezones */ $attributesInfo['look_n_feel']['attrs'][2]->setChoices(timezone::_get_tz_zones()); @@ -485,7 +485,7 @@ class configInLdap extends simplePlugin array_keys($groupsAndRoles), array_values($groupsAndRoles) ); - $menuPlugins = array(); + $menuPlugins = []; $plist = session::get('plist'); foreach ($config->data['SECTIONS'] as $section => $section_infos) { foreach ($config->data['MENU'][$section] as $info) { @@ -511,73 +511,73 @@ class configInLdap extends simplePlugin $this->fusionConfigMd5 = md5_file(CACHE_DIR."/".CLASS_CACHE); $this->attributesAccess['fdHttpAuthActivated']->setManagedAttributes( - array( - 'erase' => array ( - TRUE => array ( + [ + 'erase' => [ + TRUE => [ 'fdCasActivated', - ) - ) - ) + ] + ] + ] ); $this->attributesAccess['fdEnableSnapshots']->setManagedAttributes( - array( - 'disable' => array ( - FALSE => array ( + [ + 'disable' => [ + FALSE => [ 'fdSnapshotBase', - ) - ) - ) + ] + ] + ] ); $this->attributesAccess['fdTabHook']->setLinearRendering(FALSE); $this->attributesAccess['fdForceSSL']->setManagedAttributes( - array( - 'disable' => array ( - TRUE => array ( + [ + 'disable' => [ + TRUE => [ 'fdWarnSSL', - ) - ) - ) + ] + ] + ] ); $this->attributesAccess['fdCasActivated']->setManagedAttributes( - array( - 'disable' => array ( - FALSE => array ( + [ + 'disable' => [ + FALSE => [ 'fdCasServerCaCertPath', 'fdCasHost', 'fdCasPort', 'fdCasContext', - ) - ) - ) + ] + ] + ] ); $this->attributesAccess['fdHttpHeaderAuthActivated']->setManagedAttributes( - array( - 'disable' => array ( - FALSE => array ( + [ + 'disable' => [ + FALSE => [ 'fdHttpHeaderAuthHeaderName', - ) - ) - ) + ] + ] + ] ); $this->attributesAccess['fdSplitPostalAddress']->setManagedAttributes( - array( - 'disable' => array ( - FALSE => array ( + [ + 'disable' => [ + FALSE => [ 'fdPostalAddressPattern', - ) - ) - ) + ] + ] + ] ); } - function compute_dn() + function compute_dn () { return $this->dn; } - function check() + function check () { $messages = parent::check(); if (($this->fdPasswordDefaultHash == 'sasl') && ($this->fdSaslRealm == '') && ($this->fdSaslExop == '')) { @@ -586,7 +586,7 @@ class configInLdap extends simplePlugin return $messages; } - static function get_themes() + static function get_themes () { $themesdir = '../ihtml/themes/'; $themes = array_keys(session::get(IconTheme::$session_var)); diff --git a/plugins/config/class_dashBoardConfig.inc b/plugins/config/class_dashBoardConfig.inc index 38b094ad8..09993901b 100644 --- a/plugins/config/class_dashBoardConfig.inc +++ b/plugins/config/class_dashBoardConfig.inc @@ -20,27 +20,27 @@ class dashboardConfig extends simplePlugin { - var $objectclasses = array('fdDashboardPluginConf'); + var $objectclasses = ['fdDashboardPluginConf']; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('Dashboard configuration'), 'plDescription' => _('FusionDirectory dashboard plugin configuration'), 'plSelfModify' => FALSE, - 'plCategory' => array('configuration'), - 'plObjectType' => array('smallConfig'), + 'plCategory' => ['configuration'], + 'plObjectType' => ['smallConfig'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () { - return array( - 'systems' => array( + return [ + 'systems' => [ 'name' => _('Dashboard name schema'), - 'attrs' => array( + 'attrs' => [ new IntAttribute ( _('Number of digits'), _('Number of digits to use after prefix'), 'fdDashboardNumberOfDigit', FALSE, @@ -51,21 +51,21 @@ class dashboardConfig extends simplePlugin _('Prefixes'), _('Prefixes to be used for computer ids'), 'fdDashboardPrefix', TRUE ), - array("PC") + ["PC"] ) - ) - ), - 'users' => array( + ] + ], + 'users' => [ 'name' => _('Dashboard expired users'), - 'attrs' => array( + 'attrs' => [ new IntAttribute ( _('Number of days'), _('Number of days before expiration needed for an account to show in the dashboard next expired accounts list'), 'fdDashboardExpiredAccountsDays', FALSE, 1, FALSE, 15 ), - ) - ), - ); + ] + ], + ]; } } ?> diff --git a/plugins/config/class_mainPluginsConfig.inc b/plugins/config/class_mainPluginsConfig.inc index a00e598f0..dec365b7e 100644 --- a/plugins/config/class_mainPluginsConfig.inc +++ b/plugins/config/class_mainPluginsConfig.inc @@ -20,45 +20,45 @@ class mainPluginsConfig extends simplePlugin { - var $objectclasses = array("fusionDirectoryPluginsConf"); + var $objectclasses = ["fusionDirectoryPluginsConf"]; - static function plInfo() + static function plInfo () { - return array( + return [ "plShortName" => _("Plugins configuration"), "plDescription" => _("FusionDirectory plugins configuration"), "plSelfModify" => FALSE, - "plCategory" => array("configuration"), - "plObjectType" => array("smallConfig"), + "plCategory" => ["configuration"], + "plObjectType" => ["smallConfig"], "plProvidedAcls" => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () { - return array( - 'ogroups' => array( + return [ + 'ogroups' => [ 'name' => _('Object groups'), - 'attrs' => array( + 'attrs' => [ new StringAttribute ( _('Groups RDN'), _('Branch in which object groups will be stored'), 'fdOGroupRDN', TRUE, 'ou=groups' ), - ) - ), - 'sasl' => array( + ] + ], + 'sasl' => [ 'name' => _('SASL'), - 'attrs' => array( + 'attrs' => [ new BooleanAttribute ( _('Force to ask for password'), _('Useful if you add a hook using password value when SASL user passwords are edited'), 'fdForceSaslPasswordAsk', TRUE, FALSE ), - ) - ), - ); + ] + ], + ]; } } ?> diff --git a/plugins/config/class_pluginsConfigInLdap.inc b/plugins/config/class_pluginsConfigInLdap.inc index 676fa318d..daea9f313 100644 --- a/plugins/config/class_pluginsConfigInLdap.inc +++ b/plugins/config/class_pluginsConfigInLdap.inc @@ -22,16 +22,16 @@ class pluginsConfigInLdap extends multiPlugin { var $tabClass = 'SMALLCONFIGTABS'; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('Plugins'), 'plDescription' => _('Configuration for plugins'), 'plPriority' => 20, - 'plObjectType' => array('configuration'), + 'plObjectType' => ['configuration'], 'plSubTabs' => 'SMALLCONFIGTABS', - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } } diff --git a/plugins/config/class_recoveryConfig.inc b/plugins/config/class_recoveryConfig.inc index ff252c0de..799ea261a 100644 --- a/plugins/config/class_recoveryConfig.inc +++ b/plugins/config/class_recoveryConfig.inc @@ -20,27 +20,27 @@ class recoveryConfig extends simplePlugin { - var $objectclasses = array('fdPasswordRecoveryConf'); + var $objectclasses = ['fdPasswordRecoveryConf']; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('Password recovery'), 'plDescription' => _('Settings for the password recovery feature'), - 'plObjectType' => array('configuration'), + 'plObjectType' => ['configuration'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () { - return array ( - 'settings' => array ( + return [ + 'settings' => [ 'name' => _('Password recovery settings'), - 'class' => array ('alone'), + 'class' => ['alone'], 'template' => get_template_path('simpleplugin_section_alone.tpl'), - 'attrs' => array ( + 'attrs' => [ new BooleanAttribute ( _('Activate password recovery'), _('Whether to activate or not password recovery feature'), @@ -79,11 +79,11 @@ class recoveryConfig extends simplePlugin 'fdPasswordRecoveryLoginAttribute', TRUE, 'uid' ), - ) - ), - 'first_email' => array ( + ] + ], + 'first_email' => [ 'name' => _('First email'), - 'attrs' => array ( + 'attrs' => [ new StringAttribute ( _('Subject'), _('Subject of the first email'), @@ -98,11 +98,11 @@ class recoveryConfig extends simplePlugin TRUE, _("Hello,\n\nHere is your information: \n - Login : %s\n - Link : %s\n\nThis link is only valid for 10 minutes.") ) - ) - ), - 'second_email' => array ( + ] + ], + 'second_email' => [ 'name' => _('Second email'), - 'attrs' => array ( + 'attrs' => [ new StringAttribute ( _('Subject'), _('Subject of the second email'), @@ -117,9 +117,9 @@ class recoveryConfig extends simplePlugin TRUE, _("Hello,\n\nYour password has been changed.\nYour login is still %s.") ) - ) - ) - ); + ] + ] + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -128,7 +128,7 @@ class recoveryConfig extends simplePlugin // Check if token branch is here $ldap = $config->get_ldap_link(); $tokenBranch = get_ou('recoveryTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']; - $ldap->cat($tokenBranch, array('dn')); + $ldap->cat($tokenBranch, ['dn']); if (!$ldap->count()) { $ldap->cd($config->current['BASE']); $ldap->create_missing_trees($tokenBranch); @@ -145,15 +145,15 @@ class recoveryConfig extends simplePlugin parent::__construct($dn, $object, $parent, $mainTab); $this->attributesAccess['fdPasswordRecoveryActivated']->setManagedAttributes( - array( - 'disable' => array( - FALSE => array( + [ + 'disable' => [ + FALSE => [ 'fdPasswordRecoveryEmail','fdPasswordRecoveryValidity','fdPasswordRecoverySalt', 'fdPasswordRecoveryMailSubject','fdPasswordRecoveryMailBody', 'fdPasswordRecoveryMail2Subject','fdPasswordRecoveryMail2Body' - ) - ) - ) + ] + ] + ] ); } } diff --git a/plugins/generic/references/class_reference.inc b/plugins/generic/references/class_reference.inc index c67a5a8f2..b398f82cf 100644 --- a/plugins/generic/references/class_reference.inc +++ b/plugins/generic/references/class_reference.inc @@ -20,35 +20,35 @@ class reference extends simplePlugin { - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('References'), 'plDescription' => _('References'), - 'plCategory' => array('acl'), - 'plObjectType' => array( - 'special' => array( + 'plCategory' => ['acl'], + 'plObjectType' => [ + 'special' => [ 'name' => 'special' - ) - ), + ] + ], 'plPriority' => 10, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } static function getAttributesInfo () { - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('References'), - 'class' => array('fullwidth'), - 'attrs' => array( + 'class' => ['fullwidth'], + 'attrs' => [ new FakeAttribute('refs') - ), + ], 'template' => get_template_path('contents.tpl', TRUE, dirname(__FILE__)) - ), - ); + ], + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -58,7 +58,7 @@ class reference extends simplePlugin $this->refs = NULL; } - function execute() + function execute () { if ($this->refs === NULL) { $this->fillRefs(); @@ -68,7 +68,7 @@ class reference extends simplePlugin return parent::execute(); } - function fillRefs() + function fillRefs () { if (!isset($this->parent)) { $this->refs = NULL; @@ -77,18 +77,18 @@ class reference extends simplePlugin $this->refs = $this->browseForeignKeys('references'); } - function check() + function check () { } - function save() + function save () { - return array(); + return []; } - function remove($fulldelete = FALSE) + function remove ($fulldelete = FALSE) { - return array(); + return []; } } diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 7ce7c6681..1c7cdccff 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -29,8 +29,8 @@ class UserPasswordAttribute extends CompositeAttribute $temp = passwordMethod::get_available_methods(); /* Create password methods array */ - $pwd_methods = array(); - $this->needPassword = array(); + $pwd_methods = []; + $this->needPassword = []; foreach ($temp['name'] as $id => $name) { $this->needPassword[$name] = $temp[$id]['object']->need_password(); $pwd_methods[$name] = $name; @@ -41,7 +41,7 @@ class UserPasswordAttribute extends CompositeAttribute parent::__construct ( $description, $ldapName, - array( + [ new SelectAttribute( _('Password method'), _('Password hash method to use'), $ldapName.'_pwstorage', TRUE, @@ -62,13 +62,13 @@ class UserPasswordAttribute extends CompositeAttribute $ldapName.'_locked', FALSE, FALSE ) - ), + ], '', '', $acl, $label ); $this->attributes[0]->setSubmitForm(TRUE); } - public function setParent(&$plugin) + public function setParent (&$plugin) { global $config; parent::setParent($plugin); @@ -84,7 +84,7 @@ class UserPasswordAttribute extends CompositeAttribute } /* We need to handle method select disabling manually */ - function renderAttribute(&$attributes, $readOnly) + function renderAttribute (&$attributes, $readOnly) { global $config; if ($this->visible) { @@ -143,7 +143,7 @@ class UserPasswordAttribute extends CompositeAttribute $this->checkIfMethodNeedsPassword(); } - function checkIfMethodNeedsPassword() + function checkIfMethodNeedsPassword () { $method = $this->attributes[0]->getValue(); if ($method != $this->previousMethod) { @@ -160,7 +160,7 @@ class UserPasswordAttribute extends CompositeAttribute $this->previousMethod = $method; } - function readValues($value) + function readValues ($value) { global $config; $pw_storage = $config->get_cfg_value('passwordDefaultHash', 'ssha'); @@ -183,10 +183,10 @@ class UserPasswordAttribute extends CompositeAttribute $pw_storage = 'clear'; } } - return array($pw_storage, $password, $password, $value, $locked); + return [$pw_storage, $password, $password, $value, $locked]; } - function writeValues($values) + function writeValues ($values) { if ($this->needPassword[$values[0]] && ($values[1] == '')) { if ($this->plugin->is_template) { @@ -209,7 +209,7 @@ class UserPasswordAttribute extends CompositeAttribute } } - function check() + function check () { $method = $this->attributes[0]->getValue(); if (!$this->needPassword[$method]) { @@ -225,17 +225,17 @@ class UserPasswordAttribute extends CompositeAttribute } } - function getMethod() + function getMethod () { return $this->attributes[0]->getValue(); } - function getClear() + function getClear () { return $this->attributes[1]->getValue(); } - function isLocked() + function isLocked () { return $this->attributes[4]->getValue(); } @@ -246,8 +246,8 @@ class PostalAddressAttribute extends TextAreaAttribute function inputValue ($ldapValue) { return str_replace( - array('$', '\24','\5C'), - array("\n", '$', '\\'), + ['$', '\24','\5C'], + ["\n", '$', '\\'], $ldapValue ); } @@ -255,11 +255,11 @@ class PostalAddressAttribute extends TextAreaAttribute function computeLdapValue () { return str_replace( - array("\r\n", "\n", "\r"), + ["\r\n", "\n", "\r"], '$', str_replace( - array('\\', '$'), - array('\5C','\24'), + ['\\', '$'], + ['\5C','\24'], $this->getValue() ) ); @@ -268,19 +268,19 @@ class PostalAddressAttribute extends TextAreaAttribute class user extends simplePlugin { - var $objectclasses = array('inetOrgPerson','organizationalPerson','person'); + var $objectclasses = ['inetOrgPerson','organizationalPerson','person']; private $was_locked; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('User'), 'plDescription' => _('User account information'), 'plIcon' => 'geticon.php?context=applications&icon=user-info&size=48', 'plSmallIcon' => 'geticon.php?context=applications&icon=user-info&size=16', 'plSelfModify' => TRUE, - 'plObjectType' => array('user' => array( + 'plObjectType' => ['user' => [ 'name' => _('User'), 'description' => _('User account'), 'filter' => '(objectClass=inetOrgPerson)', @@ -288,16 +288,16 @@ class user extends simplePlugin 'nameAttr' => 'cn', 'icon' => 'geticon.php?context=types&icon=user&size=16', 'ou' => get_ou('userRDN'), - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], 'plProvidedAcls' => array_merge( parent::generatePlProvidedAcls(static::getAttributesInfo()), - array('userLock' => _('User lock status')) + ['userLock' => _('User lock status')] ) - ); + ]; } // The main function : information about attributes @@ -306,12 +306,12 @@ class user extends simplePlugin global $config; $languages = Language::getList(TRUE); asort($languages); - $languages = array_merge(array('' => ''), $languages); - $attributesInfo = array( - 'perso' => array( + $languages = array_merge(['' => ''], $languages); + $attributesInfo = [ + 'perso' => [ 'name' => _('Personal information'), 'icon' => 'geticon.php?context=types&icon=user&size=16', - 'attrs' => array( + 'attrs' => [ new HiddenAttribute('cn'), new StringAttribute ( _('Last name'), _('Last name of this user'), @@ -332,12 +332,12 @@ class user extends simplePlugin 'jpegPhoto', FALSE, 150, 200, 'jpeg' ), - ) - ), - 'contact' => array( + ] + ], + 'contact' => [ 'name' => _('Organizational contact information'), 'icon' => 'geticon.php?context=types&icon=contact&size=16', - 'attrs' => array( + 'attrs' => [ new StringAttribute ( _('Location'), _('Location'), 'l', FALSE @@ -378,12 +378,12 @@ class user extends simplePlugin _('Homepage'), _('Personal homepage'), 'labeledURI', FALSE ), - ) - ), - 'account' => array( + ] + ], + 'account' => [ 'name' => _('Account information'), 'icon' => 'geticon.php?context=applications&icon=ldap&size=16', - 'attrs' => array( + 'attrs' => [ new BaseSelectorAttribute (get_ou("userRDN")), new UidAttribute ( _('Login'), _('Login of this user'), @@ -398,12 +398,12 @@ class user extends simplePlugin _('Password'), _('Password of the user'), 'userPassword', FALSE ), - ) - ), - 'homecontact' => array( + ] + ], + 'homecontact' => [ 'name' => _('Personal contact information'), 'icon' => 'geticon.php?context=types&icon=contact&size=16', - 'attrs' => array( + 'attrs' => [ new StringAttribute ( _('Display name'), _('Name this user should appear as. Used by Exchange.'), 'displayName', FALSE @@ -416,12 +416,12 @@ class user extends simplePlugin _('Private phone'), _('Home phone number'), 'homePhone', FALSE ), - ) - ), - 'organization' => array( + ] + ], + 'organization' => [ 'name' => _('Organizational information'), 'icon' => 'geticon.php?context=places&icon=folder&size=16', - 'attrs' => array( + 'attrs' => [ new SetAttribute ( new StringAttribute ( _('Title'), _('Title of a person in their organizational context. Each title is one value of this multi-valued attribute'), @@ -452,12 +452,12 @@ class user extends simplePlugin _('Manager'), _('Manager'), 'manager', FALSE ), - ) - ), - ); + ] + ], + ]; if ($config->get_cfg_value('SplitPostalAddress') == 'TRUE') { $attributesInfo['contact']['attrs'][2]->setVisible(FALSE); - array_splice($attributesInfo['contact']['attrs'], 3, 0, array( + array_splice($attributesInfo['contact']['attrs'], 3, 0, [ new StringAttribute ( _('Street'), _('Street part of the address'), 'street', FALSE @@ -471,7 +471,7 @@ class user extends simplePlugin 'postalCode', FALSE, 0, FALSE ), - )); + ]); } return $attributesInfo; } @@ -491,13 +491,13 @@ class user extends simplePlugin $this->was_locked = $this->attributesAccess['userPassword']->isLocked(); } - function is_this_account($attrs) + function is_this_account ($attrs) { /* Only inetOrgPerson is needed, it has the two others as SUP classes */ return (isset($attrs['objectClass']) && in_array_ics('inetOrgPerson', $attrs['objectClass'])); } - function resetCopyInfos() + function resetCopyInfos () { parent::resetCopyInfos(); $this->attributesAccess['uid']->setDisabled($this->initially_was_account && !$this->is_template); @@ -513,7 +513,7 @@ class user extends simplePlugin private function applyPattern ($pattern) { $fields = templateHandling::listFields($pattern); - $attrs = array(); + $attrs = []; foreach ($fields as $field) { if (in_array($field, $this->attributes)) { $attrs[$field] = $this->$field; @@ -534,7 +534,7 @@ class user extends simplePlugin return templateHandling::parseString($pattern, $attrs); } - function compute_dn() + function compute_dn () { global $config; if ($this->is_template) { @@ -548,14 +548,14 @@ class user extends simplePlugin return $this->create_unique_dn($attribute, get_ou('userRDN').$this->base); } - function execute() + function execute () { $smarty = get_smarty(); $smarty->append('css_files', 'plugins/users/style/user_tab.css'); return parent::execute(); } - protected function shouldSave() + protected function shouldSave () { if ($this->attributesAccess['userPassword']->getClear() != '') { /* There may be hooks using this even if LDAP object is not modified */ @@ -577,7 +577,7 @@ class user extends simplePlugin return parent::prepare_save(); } - function ldap_save() + function ldap_save () { $errors = parent::ldap_save(); @@ -594,7 +594,7 @@ class user extends simplePlugin return $errors; } - function post_save() + function post_save () { global $ui; @@ -608,7 +608,7 @@ class user extends simplePlugin return parent::post_save(); } - function adapt_from_template($attrs, $skip = array()) + function adapt_from_template ($attrs, $skip = []) { if ($this->uid != '') { $skip[] = 'uid'; @@ -622,17 +622,17 @@ class user extends simplePlugin $hash = $tmp->generate_hash($password); } } - $this->userPassword = array( + $this->userPassword = [ '', $password, $password, $hash, $this->attributesAccess['userPassword']->isLocked() - ); + ]; } } - function callHook($cmd, array $addAttrs = array(), &$returnOutput = array(), &$returnCode = NULL) + function callHook ($cmd, array $addAttrs = [], &$returnOutput = [], &$returnCode = NULL) { $addAttrs['passwordMethod'] = $this->attributesAccess['userPassword']->getMethod(); $addAttrs['userLocked'] = $this->attributesAccess['userPassword']->isLocked(); @@ -656,7 +656,7 @@ class user extends simplePlugin $length = $config->get_cfg_value('passwordMinLength', 0); $ldap = $config->get_ldap_link(); - $ldap->cat($user, array('pwdPolicySubentry', 'pwdHistory', 'pwdChangedTime', 'userPassword')); + $ldap->cat($user, ['pwdPolicySubentry', 'pwdHistory', 'pwdChangedTime', 'userPassword']); $attrs = $ldap->fetch(); $ppolicydn = ''; if (isset($attrs['pwdPolicySubentry'][0])) { @@ -668,7 +668,7 @@ class user extends simplePlugin } } if (!empty($ppolicydn)) { - $ldap->cat($ppolicydn, array('pwdAllowUserChange', 'pwdMinLength', 'pwdMinAge', 'pwdSafeModify')); + $ldap->cat($ppolicydn, ['pwdAllowUserChange', 'pwdMinLength', 'pwdMinAge', 'pwdSafeModify']); $policy = $ldap->fetch(); if (!$policy) { return sprintf(_('Ppolicy "%s" could not be found in the LDAP!'), $ppolicydn); diff --git a/plugins/personal/roles/class_userRoles.inc b/plugins/personal/roles/class_userRoles.inc index 95be4ba93..db3078c9a 100644 --- a/plugins/personal/roles/class_userRoles.inc +++ b/plugins/personal/roles/class_userRoles.inc @@ -20,54 +20,54 @@ class userRoles extends simplePlugin { - var $objectclasses = array(); + var $objectclasses = []; - protected $savedGroupsMembership = array(); - protected $savedRolesMembership = array(); - protected $templateGroups = array(); - protected $templateRoles = array(); + protected $savedGroupsMembership = []; + protected $savedRolesMembership = []; + protected $templateGroups = []; + protected $templateRoles = []; - static function plInfo() + static function plInfo () { - return array( + return [ 'plShortName' => _('Groups and roles'), 'plDescription' => _('Edit user\'s groups and roles'), 'plIcon' => 'geticon.php?context=types&icon=role&size=48', 'plSmallIcon' => 'geticon.php?context=types&icon=role&size=16', 'plSelfModify' => FALSE, - 'plObjectType' => array('user'), + 'plObjectType' => ['user'], 'plPriority' => 5, 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo () { - return array( - 'groups' => array( + return [ + 'groups' => [ 'name' => _('Groups membership'), - 'attrs' => array( + 'attrs' => [ new SetAttribute( new SelectAttribute( '', _('Groups membership'), 'groupsMembership', FALSE ) ) - ) - ), - 'roles' => array( + ] + ], + 'roles' => [ 'name' => _('Roles membership'), - 'attrs' => array( + 'attrs' => [ new SetAttribute( new SelectAttribute( '', _('Roles membership'), 'rolesMembership', FALSE ) ) - ) - ), - ); + ] + ], + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -76,8 +76,8 @@ class userRoles extends simplePlugin $this->ignore_account = FALSE; /* Groups handling */ - $groups = array(); - $groupsattrs = objects::ls('ogroup', array('cn' => 1, 'description' => 1), NULL, '', TRUE); + $groups = []; + $groupsattrs = objects::ls('ogroup', ['cn' => 1, 'description' => 1], NULL, '', TRUE); foreach ($groupsattrs as $dn => $groupattr) { $groupDisplay = $groupattr['cn']; if (isset($groupattr['description'])) { @@ -94,7 +94,7 @@ class userRoles extends simplePlugin unset($this->attrs['userGroups']['count']); $myGroups = array_combine($this->attrs['userGroups'], $this->attrs['userGroups']); } else { - $myGroups = array(); + $myGroups = []; } } else { if (($this->dn != '') && ($this->dn != 'new')) { @@ -103,7 +103,7 @@ class userRoles extends simplePlugin '(member='.$this->dn.')' ); } else { - $myGroups = array(); + $myGroups = []; } $this->savedGroupsMembership = array_keys($myGroups); } @@ -113,8 +113,8 @@ class userRoles extends simplePlugin $this->attributesAccess['groupsMembership']->setValue(array_keys($myGroups)); /* Roles handling */ - $roles = array(); - $rolesattrs = objects::ls('role', array('cn' => 1, 'description' => 1), NULL, '', TRUE); + $roles = []; + $rolesattrs = objects::ls('role', ['cn' => 1, 'description' => 1], NULL, '', TRUE); foreach ($rolesattrs as $dn => $roleattr) { $roleDisplay = $roleattr['cn']; if (isset($roleattr['description'])) { @@ -131,7 +131,7 @@ class userRoles extends simplePlugin unset($this->attrs['userRoles']['count']); $myRoles = array_combine($this->attrs['userRoles'], $this->attrs['userRoles']); } else { - $myRoles = array(); + $myRoles = []; } } else { if (($this->dn != '') && ($this->dn != 'new')) { @@ -140,7 +140,7 @@ class userRoles extends simplePlugin '(roleOccupant='.$this->dn.')' ); } else { - $myRoles = array(); + $myRoles = []; } $this->savedRolesMembership = array_keys($myRoles); } @@ -153,7 +153,7 @@ class userRoles extends simplePlugin $this->initially_was_account = $this->is_account; } - function is_this_account($attrs) + function is_this_account ($attrs) { if (!isset($attrs['dn'])) { if (isset($attrs['userGroups'])) { /* Template groups field */ @@ -167,7 +167,7 @@ class userRoles extends simplePlugin return FALSE; } - protected function ldap_remove() + protected function ldap_remove () { if ($this->is_template) { return parent::ldap_remove(); @@ -191,16 +191,16 @@ class userRoles extends simplePlugin } } } - return array(); + return []; } - function save_object() + function save_object () { parent::save_object(); $this->is_account = ((count($this->rolesMembership) > 0) || (count($this->groupsMembership) > 0)); } - protected function shouldSave() + protected function shouldSave () { if (parent::shouldSave()) { return TRUE; @@ -214,7 +214,7 @@ class userRoles extends simplePlugin return FALSE; } - function prepare_save() + function prepare_save () { $errors = parent::prepare_save(); if ($this->is_template) { @@ -224,16 +224,16 @@ class userRoles extends simplePlugin return $errors; } - function prepare_remove() + function prepare_remove () { parent::prepare_remove(); if ($this->is_template) { - $this->attrs['userGroups'] = array(); - $this->attrs['userRoles'] = array(); + $this->attrs['userGroups'] = []; + $this->attrs['userRoles'] = []; } } - function ldap_save() + function ldap_save () { $errors = parent::ldap_save(); @@ -243,12 +243,12 @@ class userRoles extends simplePlugin if (!$this->is_template) { /* We need to give an array which looks like an ldap fetch and match user filter */ - $fake_attrs = array( - 'objectClass' => array('inetOrgPerson','organizationalPerson','person'), - 'cn' => array($this->dn), - 'uid' => array($this->dn), + $fake_attrs = [ + 'objectClass' => ['inetOrgPerson','organizationalPerson','person'], + 'cn' => [$this->dn], + 'uid' => [$this->dn], 'dn' => $this->dn - ); + ]; /* Take care about groupsMembership values: add to groups */ $groupsMembership = $this->attributesAccess['groupsMembership']->getValue(); @@ -344,7 +344,7 @@ class userRoles extends simplePlugin return $errors; } - function adapt_from_template($attrs, $skip = array()) + function adapt_from_template ($attrs, $skip = []) { parent::adapt_from_template($attrs, $skip); @@ -358,7 +358,7 @@ class userRoles extends simplePlugin $this->attributesAccess['groupsMembership']->setValue(array_keys($myGroups)); $this->templateGroups = array_keys($myGroups); } else { - $this->templateGroups = array(); + $this->templateGroups = []; } $this->savedRolesMembership = $this->rolesMembership; @@ -371,7 +371,7 @@ class userRoles extends simplePlugin $this->attributesAccess['rolesMembership']->setValue(array_keys($myRoles)); $this->templateRoles = array_keys($myRoles); } else { - $this->templateRoles = array(); + $this->templateRoles = []; } $this->is_account = ((count($this->rolesMembership) > 0) || (count($this->groupsMembership) > 0)); diff --git a/setup/class_setup.inc b/setup/class_setup.inc index 6d90d8a69..a1b881127 100644 --- a/setup/class_setup.inc +++ b/setup/class_setup.inc @@ -23,7 +23,7 @@ require_once("class_setupStep.inc"); class fake_userinfo extends userinfo { - function __construct() + function __construct () { $this->cn = 'fake_cn'; $this->dn = 'fake_dn'; @@ -50,12 +50,12 @@ class setup var $i_previous = 0; var $i_config = 4; - var $o_steps = array(); - var $captured_values = array(); + var $o_steps = []; + var $captured_values = []; - function __construct() + function __construct () { - $this->o_steps = array( + $this->o_steps = [ new setupStepWelcome($this), new setupStepLanguage($this), new setupStepChecks($this), @@ -63,7 +63,7 @@ class setup new setupStepConfig_before_init($this), new setupStepMigrate($this), new setupStepFinish($this), - ); + ]; $this->i_steps = count($this->o_steps); @@ -75,7 +75,7 @@ class setup } } - function execute() + function execute () { /* Display phpinfo() dialog when $_GET['info'] is set, * but only do this, if user is allowed to use the setup. @@ -96,7 +96,7 @@ class setup /* Save posted attributes */ - function save_object() + function save_object () { /* Call save_object for current setup step */ $this->o_steps[$this->i_current]->save_object(); @@ -167,7 +167,7 @@ class setup } - function disable_steps_from($start) + function disable_steps_from ($start) { for ($i = $start; $i < $this->i_steps; $i++) { $this->o_steps[$i]->set_enabled(FALSE); @@ -177,7 +177,7 @@ class setup /* Create navigation menu */ - function get_navigation_html() + function get_navigation_html () { $str = '<ul class="menu"><li><a>FusionDirectory Setup</a><ul>'; foreach ($this->o_steps as $key => $step) { @@ -219,7 +219,7 @@ class setup } - function get_bottom_html() + function get_bottom_html () { /* Skip adding forward/backward button, * if the currently opened step is a sub dialog @@ -241,20 +241,20 @@ class setup } /* Create header entry */ - function get_header_text() + function get_header_text () { return $this->o_steps[$this->i_current]->get_title(); } /* Create header entry */ - function get_header_image() + function get_header_image () { return $this->o_steps[$this->i_current]->header_image; } /* Check if the given step id is valid and selectable */ - function selectable_step($id) + function selectable_step ($id) { if (isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()) { return TRUE; @@ -262,7 +262,7 @@ class setup return FALSE; } - function step_name_to_id($name) + function step_name_to_id ($name) { foreach ($this->o_steps as $id => $class) { if (get_class($class) == $name) { @@ -273,7 +273,7 @@ class setup } /* Called when LDAP is configured */ - function read_ldap_config() + function read_ldap_config () { global $config; /* Get attributes from current ldap step */ diff --git a/setup/class_setupStep.inc b/setup/class_setupStep.inc index 2554fd386..1d9017b95 100644 --- a/setup/class_setupStep.inc +++ b/setup/class_setupStep.inc @@ -31,63 +31,63 @@ class setupStep extends simplePlugin var $header_image = ''; - static function getAttributesInfo() + static function getAttributesInfo () { - return array(); + return []; } - function __construct($parent) + function __construct ($parent) { parent::__construct(NULL, NULL, $parent); $this->update_strings(); } - function update_strings() + function update_strings () { die('abstract method'); } - function get_short_name() + function get_short_name () { return $this->s_short_name; } - function get_title() + function get_title () { return $this->s_title; } - function get_description() + function get_description () { return $this->s_description; } - function is_active() + function is_active () { return $this->is_active; } - function is_enabled() + function is_enabled () { return $this->is_enabled; } - function is_completed() + function is_completed () { return $this->is_completed; } - function set_active($value = TRUE) + function set_active ($value = TRUE) { $this->is_active = ($value == TRUE); } - function set_enabled($value = TRUE) + function set_enabled ($value = TRUE) { $this->is_enabled = ($value == TRUE); } - function set_completed($value = TRUE) + function set_completed ($value = TRUE) { $this->is_completed = ($value == TRUE); } @@ -95,7 +95,7 @@ class setupStep extends simplePlugin /* Return attributes handled by this setup step */ public function get_attributes () { - $tmp = array(); + $tmp = []; foreach (array_keys($this->attributesAccess) as $attr) { $tmp[$attr] = $this->$attr; } @@ -103,7 +103,7 @@ class setupStep extends simplePlugin } /* bypass LDAP loading */ - protected function loadAttributes() + protected function loadAttributes () { foreach ($this->attributesInfo as $sectionInfo) { foreach ($sectionInfo['attrs'] as $attr) { diff --git a/setup/class_setupStepChecks.inc b/setup/class_setupStepChecks.inc index 081645f53..f901d9e32 100644 --- a/setup/class_setupStepChecks.inc +++ b/setup/class_setupStepChecks.inc @@ -23,27 +23,27 @@ class setupStepChecks extends setupStep { var $header_image = 'geticon.php?context=categories&icon=checks&size=48'; - static function getAttributesInfo() + static function getAttributesInfo () { - return array( - 'modules' => array( + return [ + 'modules' => [ 'name' => _('PHP module and extension checks'), 'template' => get_template_path("setup_checks.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( + 'attrs' => [ new FakeAttribute('basic_checks') - ) - ), - 'setup' => array( + ] + ], + 'setup' => [ 'name' => _('PHP setup configuration'), 'template' => get_template_path("setup_checks.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( + 'attrs' => [ new FakeAttribute('config_checks') - ) - ) - ); + ] + ] + ]; } - function update_strings() + function update_strings () { $this->s_short_name = _('Installation check'); $this->s_title = _('Installation check'); @@ -51,17 +51,17 @@ class setupStepChecks extends setupStep } /* Execute and display template */ - function execute() + function execute () { $this->run_checks(); return parent::execute(); } /* Execute all checks */ - function run_checks() + function run_checks () { - $basic_checks = array(); - $config_checks = array(); + $basic_checks = []; + $config_checks = []; /* PHP version check */ $N = _('Checking PHP version'); @@ -69,7 +69,7 @@ class setupStepChecks extends setupStep $S = _('Please upgrade to a supported version.'); $R = version_compare(phpversion(), PHP_MIN_VERSION, '>='); $M = TRUE; - $basic_checks[] = array('NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ); + $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; /* Check for LDAP extension */ $N = msgPool::checkingFor("LDAP"); @@ -77,7 +77,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule("LDAP"); $R = is_callable("ldap_bind"); $M = TRUE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check for gettext support */ $N = msgPool::checkingFor("gettext"); @@ -85,7 +85,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule("gettext"); $R = is_callable("bindtextdomain"); $M = TRUE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check for curl support */ $N = msgPool::checkingFor('curl'); @@ -93,7 +93,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule('curl'); $R = is_callable('curl_init'); $M = TRUE; - $basic_checks[] = array('NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ); + $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; /* Pseudo-random check */ $N = _('Checking cryptographically secure pseudo-random integers'); @@ -101,7 +101,7 @@ class setupStepChecks extends setupStep $S = _('Please upgrade to PHP7 or activate openssl module.'); $R = (is_callable('random_int') || is_callable('openssl_random_pseudo_bytes')); $M = TRUE; - $basic_checks[] = array('NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ); + $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; /* Check for json support */ $N = msgPool::checkingFor('json'); @@ -109,7 +109,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule('json'); $R = is_callable('json_encode'); $M = TRUE; - $basic_checks[] = array('NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ); + $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; /* Check for filter support */ $N = msgPool::checkingFor('filter'); @@ -117,7 +117,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule('filter'); $R = is_callable('filter_var'); $M = TRUE; - $basic_checks[] = array('NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ); + $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; /* Check for iconv */ $N = msgPool::checkingFor("iconv"); @@ -125,7 +125,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule("iconv"); $R = is_callable("iconv"); $M = TRUE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check for installed mhash module */ $N = msgPool::checkingFor("hash method"); @@ -133,7 +133,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule("mhash/sha1"); $R = is_callable('mhash') || is_callable('sha1'); $M = FALSE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check if imap module is available */ $N = msgPool::checkingFor("IMAP"); @@ -141,7 +141,7 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule("IMAP"); $R = is_callable("imap_open"); $M = TRUE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check if mbstring module is available */ $N = msgPool::checkingFor(_("mbstring")); @@ -149,21 +149,21 @@ class setupStepChecks extends setupStep $S = msgPool::installPhpModule("mbstring"); $R = is_callable("mb_strlen"); $M = TRUE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; $N = msgPool::checkingFor(_('imagick')); $D = _('FusionDirectory requires this extension to handle images.'); $S = msgPool::installPhpModule('imagick'); $R = class_exists('Imagick', FALSE); $M = TRUE; - $basic_checks[] = array('NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ); + $basic_checks[] = ['NAME' => $N , 'DESC' => $D , 'RESULT' => $R , 'SOLUTION' => $S , 'MUST' => $M ]; $N = msgPool::checkingFor(_("compression module")); $D = _("FusionDirectory requires this extension to handle snapshots."); $S = msgPool::installPhpModule("compile with --with-zlib"); $R = is_callable("gzcompress"); $M = FALSE; - $basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $basic_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* PHP Configuration checks */ @@ -174,7 +174,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'session.gc_maxlifetime' in your php.ini and set it to 86400 or higher."); $R = ini_get("session.gc_maxlifetime") >= 86400; $M = FALSE; - $config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $config_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Session auto start must be turned off */ $session_auto_start = ini_get('session.auto_start'); @@ -183,7 +183,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'session.auto_start' in your php.ini and set it to 'Off'."); $R = !$session_auto_start; $M = TRUE; - $config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $config_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check if memory limit is set to 128 or > */ $N = "memory_limit >= <b>128</b>"; @@ -191,7 +191,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'memory_limit' in your php.ini and set it to '128M' or higher."); $R = ini_get('memory_limit') >= 128; $M = TRUE; - $config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $config_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Implicit Flush disabled can increase performance */ $N = "implicit_flush = <b>"._("Off")."</b>"; @@ -199,7 +199,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'implicit_flush' in your php.ini and set it to 'Off'."); $R = !ini_get('implicit_flush'); $M = FALSE; - $config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $config_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Check if execution time is set to 30 */ $N = "max_execution_time >= <b>30</b>"; @@ -207,7 +207,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher."); $R = ini_get("max_execution_time") >= 30; $M = TRUE; - $config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $config_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; /* Expose php should be set to off */ $N = "expose_php = <b>"._("Off")."</b>"; @@ -215,19 +215,19 @@ class setupStepChecks extends setupStep $S = _("Search for 'expose_php' in your php.ini and set if to 'Off'."); $R = !ini_get("expose_php"); $M = FALSE; - $config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + $config_checks[] = ["NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ]; $this->basic_checks = $basic_checks; $this->config_checks = $config_checks; } - function save_object() + function save_object () { parent::save_object(); /* If everything is fine, set this step to completed * and allow switching to next setup step */ $failed = FALSE; - foreach (array('basic_checks','config_checks') as $type) { + foreach (['basic_checks','config_checks'] as $type) { foreach ($this->$type as $obj) { if ($obj['MUST'] && !$obj['RESULT']) { $failed = TRUE; diff --git a/setup/class_setupStepConfig.inc b/setup/class_setupStepConfig.inc index a62e80c6e..d83c73764 100644 --- a/setup/class_setupStepConfig.inc +++ b/setup/class_setupStepConfig.inc @@ -21,7 +21,7 @@ class setupStepConfig_before_init extends setupStep { - function update_strings() + function update_strings () { global $config; if (!isset($config->current['BASE'])) { @@ -42,57 +42,57 @@ class setupStepConfig extends configInLdap var $is_completed = FALSE; var $header_image; - static function plInfo() + static function plInfo () { - return array(); + return []; } - function __construct($parent, $cv) + function __construct ($parent, $cv) { global $config; parent::__construct(CONFIGRDN.$config->current['BASE'], NULL, $parent, TRUE); - $this->attributesInfo['miscellaneous']['class'] = array('invisible'); - $this->attributesInfo['debug']['class'] = array('invisible'); + $this->attributesInfo['miscellaneous']['class'] = ['invisible']; + $this->attributesInfo['debug']['class'] = ['invisible']; $this->fdLanguage = $cv['lang_selected']; } - function update_strings() + function update_strings () { $infos = parent::plInfo(); $this->header_image = $infos['plIcon']; } - function get_short_name() + function get_short_name () { $infos = parent::plInfo(); return $infos['plTitle']; } - function get_title() + function get_title () { $infos = parent::plInfo(); return $infos['plDescription']; } - function get_description() + function get_description () { $infos = parent::plInfo(); return $infos['plDescription']; } /* Return attributes handled by this setup step */ - function get_attributes() + function get_attributes () { - $tmp = array(); + $tmp = []; foreach (array_keys($this->attributesAccess) as $attr) { $tmp[$attr] = $this->$attr; } return $tmp; } - function save_object() + function save_object () { global $config; parent::save_object(); @@ -126,58 +126,58 @@ class setupStepConfig extends configInLdap } } - function is_active() + function is_active () { return $this->is_active; } - function is_enabled() + function is_enabled () { return $this->is_enabled; } - function is_completed() + function is_completed () { return $this->is_completed; } - function set_active($value = TRUE) + function set_active ($value = TRUE) { $this->is_active = ($value == TRUE); } - function set_enabled($value = TRUE) + function set_enabled ($value = TRUE) { $this->is_enabled = ($value == TRUE); } - function set_completed($value = TRUE) + function set_completed ($value = TRUE) { $this->is_completed = ($value == TRUE); } /* bypass acl system as there is no user login */ - function acl_is_writeable($attribute, $skip_write = FALSE) + function acl_is_writeable ($attribute, $skip_write = FALSE) { return TRUE; } - function acl_is_readable($attribute) + function acl_is_readable ($attribute) { return TRUE; } - function acl_is_createable($base = "") + function acl_is_createable ($base = "") { return TRUE; } - function acl_is_removeable($base = "") + function acl_is_removeable ($base = "") { return TRUE; } - function acl_is_moveable($base = "") + function acl_is_moveable ($base = "") { return TRUE; } - function aclGetPermissions($attribute = '0', $base = NULL, $skipWrite = FALSE) + function aclGetPermissions ($attribute = '0', $base = NULL, $skipWrite = FALSE) { return 'cmdrw'; } diff --git a/setup/class_setupStepFinish.inc b/setup/class_setupStepFinish.inc index 0e2fe373b..ab93fab18 100644 --- a/setup/class_setupStepFinish.inc +++ b/setup/class_setupStepFinish.inc @@ -23,26 +23,26 @@ class setupStepFinish extends setupStep { var $header_image = 'geticon.php?context=devices&icon=server&size=48'; - static function getAttributesInfo() + static function getAttributesInfo () { - return array( - 'welcome' => array( + return [ + 'welcome' => [ 'name' => _('Welcome'), 'template' => get_template_path("setup_finish.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( - ) - ) - ); + 'attrs' => [ + ] + ] + ]; } - function update_strings() + function update_strings () { $this->s_short_name = _('Finish'); $this->s_title = _('Finish - write the configuration file'); $this->s_description = _('Write configuration file'); } - function get_conf_data() + function get_conf_data () { $smarty = get_smarty(); $cv = $this->parent->captured_values; @@ -52,7 +52,7 @@ class setupStepFinish extends setupStep return $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE); } - function insertConfigDefaults() + function insertConfigDefaults () { /* Insert default config values, even for installed plugin */ global $config, $ui, $plist, $BASE_DIR; @@ -79,7 +79,7 @@ class setupStepFinish extends setupStep $config->checkLdapConfig(TRUE); } - function execute() + function execute () { /* Check if there is currently an active fusiondirectory.conf */ $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); @@ -98,7 +98,7 @@ class setupStepFinish extends setupStep return parent::execute(); } - function save_object() + function save_object () { parent::save_object(); $exists = file_exists(CONFIG_DIR.'/'.CONFIG_FILE); @@ -121,7 +121,7 @@ class setupStepFinish extends setupStep } /* check if given file is world readable */ - function is_world_readable($file) + function is_world_readable ($file) { clearstatcache(); $p = fileperms($file); diff --git a/setup/class_setupStepLanguage.inc b/setup/class_setupStepLanguage.inc index 767f11930..de0fc6093 100644 --- a/setup/class_setupStepLanguage.inc +++ b/setup/class_setupStepLanguage.inc @@ -23,13 +23,13 @@ class setupStepLanguage extends setupStep { var $header_image = 'geticon.php?context=applications&icon=config-language&size=48'; - static function getAttributesInfo() + static function getAttributesInfo () { - return array( - 'lang' => array( + return [ + 'lang' => [ 'name' => _('Preferred language'), - 'class' => array('fullwidth', 'setup-language'), - 'attrs' => array( + 'class' => ['fullwidth', 'setup-language'], + 'attrs' => [ new DisplayAttribute( '', '', 'msg', FALSE @@ -42,19 +42,19 @@ class setupStepLanguage extends setupStep 'lang', FALSE, 'en_EN' ) - ) - ) - ); + ] + ] + ]; } - function __construct($parent) + function __construct ($parent) { parent::__construct($parent); $this->lang = Language::detect(); $this->attributesAccess['lang_selected']->setSize(20); } - function update_strings() + function update_strings () { $this->s_short_name = _('Language setup'); $this->s_title = _('Language setup'); @@ -62,16 +62,16 @@ class setupStepLanguage extends setupStep $this->msg = _('At this point, you can select the site wide default language. Choosing "automatic" will use the language requested by the browser. This setting can be overriden per user.'); } - function execute() + function execute () { $languages = Language::getList(TRUE); asort($languages); - $languages = array_merge(array("" => _("Automatic")), $languages); + $languages = array_merge(["" => _("Automatic")], $languages); $this->attributesAccess['lang_selected']->setChoices(array_keys($languages), array_values($languages)); return parent::execute(); } - function save_object() + function save_object () { parent::save_object(); $this->is_completed = TRUE; diff --git a/setup/class_setupStepLdap.inc b/setup/class_setupStepLdap.inc index f08c07acc..f931da121 100644 --- a/setup/class_setupStepLdap.inc +++ b/setup/class_setupStepLdap.inc @@ -31,10 +31,10 @@ class setupStepLdap extends setupStep static function getAttributesInfo () { - return array( - 'connection' => array( + return [ + 'connection' => [ 'name' => _('LDAP connection'), - 'attrs' => array( + 'attrs' => [ new StringAttribute( _('Location name'), _('Name of this connexion to show in the LDAP server list'), 'location', TRUE, @@ -53,15 +53,15 @@ class setupStepLdap extends setupStep _('Base'), _('The LDAP directory base'), 'base', TRUE ) - ) - ), - 'auth' => array( + ] + ], + 'auth' => [ 'name' => _('Authentication'), - 'attrs' => array( + 'attrs' => [ new CompositeAttribute( _('DN of the admin account to use for binding to the LDAP. Base is automatically appended.'), 'admin', - array( + [ new StringAttribute( '', '', 'admin_given', TRUE, @@ -70,7 +70,7 @@ class setupStepLdap extends setupStep new DisplayAttribute( '', '', 'base_append' ) - ), + ], '^(.+)(.*)$', '%s%s', '', @@ -80,21 +80,21 @@ class setupStepLdap extends setupStep _('Admin password'), _('Password for the admin account to use for binding to the LDAP'), 'password', TRUE ), - ) - ), - 'status' => array( + ] + ], + 'status' => [ 'name' => _('Status'), - 'attrs' => array( + 'attrs' => [ new DisplayAttribute( _('Current status'), _('Result of last attempt at checking LDAP binding and basic schemas'), 'status', FALSE ), - ) - ) - ); + ] + ] + ]; } - function __construct($parent) + function __construct ($parent) { parent::__construct($parent); $this->update_strings(); @@ -105,14 +105,14 @@ class setupStepLdap extends setupStep $this->status = $this->get_connection_status(); } - function update_strings() + function update_strings () { $this->s_short_name = _('LDAP setup'); $this->s_title = _('LDAP connection setup'); $this->s_description = _('This dialog performs the basic configuration of the LDAP connectivity for FusionDirectory.'); } - function update_base_choices() + function update_base_choices () { $attr = @LDAP::get_naming_contexts($this->connection); unset($attr['count']); @@ -135,7 +135,7 @@ class setupStepLdap extends setupStep $this->lastBase = $this->base; } - function save_object() + function save_object () { parent::save_object(); $this->connection = preg_replace('/\/$/', '', $this->connection); @@ -158,7 +158,7 @@ class setupStepLdap extends setupStep } } - function get_connection_status() + function get_connection_status () { $this->connect_id = FALSE; $this->bind_id = FALSE; @@ -199,7 +199,7 @@ class setupStepLdap extends setupStep } } - function check() + function check () { $error = parent::check(); if (!empty($error)) { @@ -207,7 +207,7 @@ class setupStepLdap extends setupStep return $error; } elseif ($this->is_completed) { $checked = check_schema($this->parent->captured_values); - $error = array(); + $error = []; foreach ($checked as $check) { if (!$check['STATUS']) { if ($check['IS_MUST_HAVE']) { diff --git a/setup/class_setupStepMigrate.inc b/setup/class_setupStepMigrate.inc index cfda33456..f99ada78c 100644 --- a/setup/class_setupStepMigrate.inc +++ b/setup/class_setupStepMigrate.inc @@ -48,13 +48,13 @@ class CheckFailedException extends FusionDirectoryException { private $error; - public function __construct($msg, $error) + public function __construct ($msg, $error) { parent::__construct($msg); $this->error = $error; } - public function getError() + public function getError () { return $this->error; } @@ -69,7 +69,7 @@ class StepMigrateDialog extends GenericDialog private $tplfile; private $check; - public function __construct(&$check, $tpl, $infos) + public function __construct (&$check, $tpl, $infos) { $this->attribute = NULL; $this->dialog = NULL; @@ -78,7 +78,7 @@ class StepMigrateDialog extends GenericDialog $this->check = $check; } - public function dialog_execute() + public function dialog_execute () { if ( isset($_POST['dialog_showchanges']) || @@ -121,7 +121,7 @@ class StepMigrateCheck public $fnc; private $step; - public function __construct($step, $name, $title) + public function __construct ($step, $name, $title) { $this->name = $name; $this->title = $title; @@ -129,7 +129,7 @@ class StepMigrateCheck $this->step = $step; } - public function run($fnc = NULL) + public function run ($fnc = NULL) { if ($fnc === NULL) { $fnc = $this->fnc; @@ -145,7 +145,7 @@ class StepMigrateCheck } } - public function save_object() + public function save_object () { if (isset($_POST[$this->name.'_create'])) { $fnc = $this->fnc.'_create'; @@ -164,7 +164,7 @@ class StepMigrateCheck return '<input type="submit" name="'.$this->name.'_'.$id.'" value="'.$value.'"/>'; } - public function migrate_confirm() + public function migrate_confirm () { $fnc = $this->fnc.'_migrate'.'_confirm'; $res = $this->step->$fnc($this); @@ -174,7 +174,7 @@ class StepMigrateCheck return $res; } - public function dialog_refresh() + public function dialog_refresh () { $fnc = $this->fnc.'_migrate'.'_refresh'; return $this->step->$fnc($this); @@ -186,80 +186,80 @@ class setupStepMigrate extends setupStep var $header_image = "geticon.php?context=applications&icon=utilities-system-monitor&size=48"; /* Root object classes */ - var $rootOC_details = array(); + var $rootOC_details = []; /* Entries needing migration */ - var $orgUnits_toMigrate = array(); - var $accounts_toMigrate = array(); - var $outsideUsers_toMigrate = array(); - var $outsideGroups_toMigrate = array(); + var $orgUnits_toMigrate = []; + var $accounts_toMigrate = []; + var $outsideUsers_toMigrate = []; + var $outsideGroups_toMigrate = []; /* check for multiple use of same uidNumber */ - var $check_uidNumbers = array(); + var $check_uidNumbers = []; /* check for multiple use of same gidNumber */ - var $check_gidNumbers = array(); + var $check_gidNumbers = []; /* Defaults ACL roles */ var $defaultRoles; - static function getAttributesInfo() + static function getAttributesInfo () { - return array( - 'checks' => array( - 'class' => array('fullwidth'), + return [ + 'checks' => [ + 'class' => ['fullwidth'], 'name' => _('PHP module and extension checks'), 'template' => get_template_path("setup_migrate.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( + 'attrs' => [ new FakeAttribute('checks') - ) - ), - ); + ] + ], + ]; } - function __construct($parent) + function __construct ($parent) { parent::__construct($parent); $this->fill_defaultRoles(); } - function update_strings() + function update_strings () { $this->s_short_name = _('LDAP inspection'); $this->s_title = _('LDAP inspection'); $this->s_description = _('Analyze your current LDAP for FusionDirectory compatibility'); } - function fill_defaultRoles() + function fill_defaultRoles () { - $this->defaultRoles = array( - array( + $this->defaultRoles = [ + [ 'cn' => 'manager', 'description' => _('Give all rights on users in the given branch'), - 'objectclass' => array('top', 'gosaRole'), + 'objectclass' => ['top', 'gosaRole'], 'gosaAclTemplate' => '0:user/user;cmdrw,user/posixAccount;cmdrw' - ), - array( + ], + [ 'cn' => 'editowninfos', 'description' => _('Allow users to edit their own information (main tab and posix use only on base)'), - 'objectclass' => array('top', 'gosaRole'), + 'objectclass' => ['top', 'gosaRole'], 'gosaAclTemplate' => '0:user/user;srw,user/posixAccount;srw' - ), - array( + ], + [ 'cn' => 'editownpwd', 'description' => _('Allow users to edit their own password (use only on base)'), - 'objectclass' => array('top', 'gosaRole'), + 'objectclass' => ['top', 'gosaRole'], 'gosaAclTemplate' => '0:user/user;s#userPassword;rw' - ), - ); + ], + ]; } - function initialize_checks() + function initialize_checks () { global $config; $config->get_departments(); - $checks = array( + $checks = [ 'baseOC' => new StepMigrateCheck($this, 'baseOC', _('Inspecting object classes in root object')), 'permissions' => new StepMigrateCheck($this, 'permissions', _('Checking permission for LDAP database')), 'accounts' => new StepMigrateCheck($this, 'accounts', _('Checking for invisible users')), @@ -270,13 +270,13 @@ class setupStepMigrate extends setupStep 'orgUnits' => new StepMigrateCheck($this, 'orgUnits', _('Checking for invisible departments')), 'uidNumber' => new StepMigrateCheck($this, 'uidNumber', _('Checking for duplicated UID numbers')), 'gidNumber' => new StepMigrateCheck($this, 'gidNumber', _('Checking for duplicated GID numbers')), - ); + ]; $this->checks = $checks; } /* Return ldif information for a given attribute array */ - function array_to_ldif($attrs) + function array_to_ldif ($attrs) { $ret = ''; unset($attrs['count']); @@ -297,7 +297,7 @@ class setupStepMigrate extends setupStep return preg_replace("/\n$/", '', $ret); } - function execute() + function execute () { if (empty($this->checks) || isset($_POST['reload'])) { $this->initialize_checks(); @@ -308,7 +308,7 @@ class setupStepMigrate extends setupStep return parent::execute(); } - function save_object() + function save_object () { $this->is_completed = TRUE; parent::save_object(); @@ -321,7 +321,7 @@ class setupStepMigrate extends setupStep * If the parameter just_check is TRUE, then just check for the OCs. * If the Parameter is FALSE, try to add the required object classes. */ - function check_baseOC(&$checkobj) + function check_baseOC (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -340,8 +340,8 @@ class setupStepMigrate extends setupStep /* Root object doesn't exists */ if (!in_array("gosaDepartment", $attrs['objectClass'])) { - $this->rootOC_details = array(); - $mods = array(); + $this->rootOC_details = []; + $mods = []; /* Get list of possible container objects, to be able to detect naming * attributes and missing attribute types. @@ -472,7 +472,7 @@ class setupStepMigrate extends setupStep * Create and remove a dummy object, * to ensure that we have the necessary permissions */ - function check_permissions(&$checkobj) + function check_permissions (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -480,7 +480,7 @@ class setupStepMigrate extends setupStep /* Create dummy entry */ $name = 'GOsa_setup_text_entry_'.session_id().random_int(0, 999999); $dn = 'ou='.$name.','.$config->current['BASE']; - $testEntry = array(); + $testEntry = []; $testEntry['objectClass'][] = 'top'; $testEntry['objectClass'][] = 'organizationalUnit'; @@ -498,11 +498,11 @@ class setupStepMigrate extends setupStep } /* Try to create dummy object */ - $ldap->cd ($dn); + $ldap->cd($dn); $res = $ldap->add($testEntry); $ldap->cat($dn); if (!$ldap->count()) { - logging::log('view', 'setup/'.get_class($this), $dn, array(), $ldap->get_error()); + logging::log('view', 'setup/'.get_class($this), $dn, [], $ldap->get_error()); throw new CheckFailedException( _('Failed'), sprintf(_('The specified user "%s" does not have full access to your LDAP database.'), $config->current['ADMINDN']) @@ -513,7 +513,7 @@ class setupStepMigrate extends setupStep $res = $ldap->rmDir($dn); $ldap->cat($dn); if ($ldap->count()) { - logging::log('view', 'setup/'.get_class($this), $dn, array(), $ldap->get_error()); + logging::log('view', 'setup/'.get_class($this), $dn, [], $ldap->get_error()); throw new CheckFailedException( _('Failed'), sprintf(_('The specified user "%s" does not have full access to your ldap database.'), $config->current['ADMINDN']) @@ -527,7 +527,7 @@ class setupStepMigrate extends setupStep /* Check if there are users which will * be invisible for FusionDirectory */ - function check_accounts(&$checkobj) + function check_accounts (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -536,7 +536,7 @@ class setupStepMigrate extends setupStep * the 'html checked' status for the checkboxes again */ $old = $this->accounts_toMigrate; - $this->accounts_toMigrate = array(); + $this->accounts_toMigrate = []; /* Get all invisible users */ $ldap->cd($config->current['BASE']); @@ -550,7 +550,7 @@ class setupStepMigrate extends setupStep '(!(objectClass=inetOrgPerson))'. '(uid=*)'. ')', - array('sn','givenName','cn','uid') + ['sn','givenName','cn','uid'] ); while ($attrs = $ldap->fetch()) { @@ -590,10 +590,10 @@ class setupStepMigrate extends setupStep { $this->check_multipleGeneric_migrate( $checkobj, - array( + [ 'title' => _('User migration'), 'outside' => FALSE, - ) + ] ); } @@ -601,19 +601,19 @@ class setupStepMigrate extends setupStep { return $this->check_multipleGeneric_migrate_refresh( $checkobj, - array( + [ 'title' => _('User migration'), 'outside' => FALSE, - ) + ] ); } - function check_accounts_migrate_confirm(&$checkobj, $only_ldif = FALSE) + function check_accounts_migrate_confirm (&$checkobj, $only_ldif = FALSE) { return $this->check_multipleGeneric_migrate_confirm( $checkobj, - array('inetOrgPerson','organizationalPerson','person'), - array(), + ['inetOrgPerson','organizationalPerson','person'], + [], $only_ldif ); } @@ -649,7 +649,7 @@ class setupStepMigrate extends setupStep return $infos; } - function check_multipleGeneric_migrate_confirm(&$checkobj, $oc, $mandatory, $only_ldif) + function check_multipleGeneric_migrate_confirm (&$checkobj, $oc, $mandatory, $only_ldif) { global $config; $ldap = $config->get_ldap_link(); @@ -660,11 +660,11 @@ class setupStepMigrate extends setupStep $entry['checked'] = isset($_POST['migrate_'.$key]); if ($entry['checked']) { /* Get old objectClasses */ - $ldap->cat($entry['dn'], array_merge(array('objectClass'), array_keys($mandatory))); + $ldap->cat($entry['dn'], array_merge(['objectClass'], array_keys($mandatory))); $attrs = $ldap->fetch(); /* Create new objectClass array */ - $new_attrs = array(); + $new_attrs = []; $new_attrs['objectClass'] = $oc; for ($i = 0; $i < $attrs['objectClass']['count']; $i++) { if (!in_array_ics($attrs['objectClass'][$i], $new_attrs['objectClass'])) { @@ -706,7 +706,7 @@ class setupStepMigrate extends setupStep } /* Check Acls if there is at least one object with acls defined */ - function check_adminAccount(&$checkobj) + function check_adminAccount (&$checkobj) { global $config; @@ -726,8 +726,8 @@ class setupStepMigrate extends setupStep $attrs = $ldap->fetch(); /* Collect a list of available FusionDirectory users and groups */ - $users = array(); - $ldap->search('(objectClass=inetOrgPerson)', array('uid','dn')); + $users = []; + $ldap->search('(objectClass=inetOrgPerson)', ['uid','dn']); while ($user_attrs = $ldap->fetch()) { if (isset($user_attrs['uid'][0])) { $users[$user_attrs['dn']] = $user_attrs['uid'][0]; @@ -736,13 +736,13 @@ class setupStepMigrate extends setupStep $users[$user_attrs['dn']] = $user_attrs['dn']; } } - $groups = array(); - $ldap->search('(objectClass=posixGroup)', array('cn','dn')); + $groups = []; + $ldap->search('(objectClass=posixGroup)', ['cn','dn']); while ($group_attrs = $ldap->fetch()) { $groups[$group_attrs['dn']] = $group_attrs['cn'][0]; } - $roles = array(); - $ldap->search('(objectClass=organizationalRole)', array('cn','dn')); + $roles = []; + $ldap->search('(objectClass=organizationalRole)', ['cn','dn']); while ($role_attrs = $ldap->fetch()) { $roles[$role_attrs['dn']] = $role_attrs['cn'][0]; } @@ -761,7 +761,7 @@ class setupStepMigrate extends setupStep if ($tmp[1] == 'subtree') { /* Check if acl owner is a valid FusionDirectory user account */ - $ldap->cat(base64_decode($tmp[2]), array('gosaAclTemplate'), '(gosaAclTemplate=*:all;cmdrw)'); + $ldap->cat(base64_decode($tmp[2]), ['gosaAclTemplate'], '(gosaAclTemplate=*:all;cmdrw)'); if ($ldap->count()) { $members = explode(',', $tmp[3]); foreach ($members as $member) { @@ -836,17 +836,17 @@ class setupStepMigrate extends setupStep return ''; } - function check_adminAccount_create(&$checkobj) + function check_adminAccount_create (&$checkobj) { - $infos = array( + $infos = [ 'uid' => 'fd-admin', 'password' => '', 'password2' => '', - ); + ]; $this->openDialog(new StepMigrateDialog($checkobj, 'setup_migrate_adminAccount.tpl', $infos)); } - function check_adminAccount_migrate_confirm(&$checkobj) + function check_adminAccount_migrate_confirm (&$checkobj) { global $config; session::set('CurrentMainBase', $config->current['BASE']); @@ -855,7 +855,7 @@ class setupStepMigrate extends setupStep $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - $ldap->search('(&(objectClass=gosaRole)(gosaAclTemplate=*:all;cmdrw))', array('dn')); + $ldap->search('(&(objectClass=gosaRole)(gosaAclTemplate=*:all;cmdrw))', ['dn']); if ($attrs = $ldap->fetch()) { $roledn = $attrs['dn']; } else { @@ -864,7 +864,7 @@ class setupStepMigrate extends setupStep $baseObject->cn = 'admin'; $baseObject->description = _('Gives all rights on all objects'); - $baseObject->gosaAclTemplate = array(array('all' => array('0' => 'cmdrw'))); + $baseObject->gosaAclTemplate = [['all' => ['0' => 'cmdrw']]]; $tabObject->save(); $roledn = $tabObject->dn; @@ -891,11 +891,11 @@ class setupStepMigrate extends setupStep $assignments = $baseObject->gosaAclEntry; array_unshift( $assignments, - array( + [ 'scope' => 'subtree', 'role' => $roledn, - 'members' => array($admindn), - ) + 'members' => [$admindn], + ] ); $baseObject->gosaAclEntry = $assignments; $tabObject->save(); @@ -903,17 +903,17 @@ class setupStepMigrate extends setupStep return TRUE; } - function check_adminAccount_migrate_refresh(&$checkobj) + function check_adminAccount_migrate_refresh (&$checkobj) { - return array( + return [ 'uid' => $_POST['uid'], 'password' => $_POST['userPassword_password'], 'password2' => $_POST['userPassword_password2'], - ); + ]; } /* Check if default roles and groupes have been inserted */ - function check_defaultACLs(&$checkobj) + function check_defaultACLs (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -930,7 +930,7 @@ class setupStepMigrate extends setupStep $existings = 0; foreach ($this->defaultRoles as $role) { $dn = 'cn='.$role['cn'].','.get_ou('aclRoleRDN').$config->current['BASE']; - $ldap->cat($dn, array('dn')); + $ldap->cat($dn, ['dn']); if ($ldap->count() > 0) { $existings++; } @@ -953,7 +953,7 @@ class setupStepMigrate extends setupStep } } - function check_defaultACLs_migrate(&$checkobj) + function check_defaultACLs_migrate (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -985,7 +985,7 @@ class setupStepMigrate extends setupStep } /* Search for users outside the people ou */ - function check_outsideUsers(&$checkobj) + function check_outsideUsers (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -995,7 +995,7 @@ class setupStepMigrate extends setupStep /*********** * Search for all users ***********/ - $res = $ldap->search('(&(objectClass=inetOrgPerson)(!(uid=*$)))', array('dn')); + $res = $ldap->search('(&(objectClass=inetOrgPerson)(!(uid=*$)))', ['dn']); if (!$res) { throw new CheckFailedException( _('LDAP query failed'), @@ -1006,7 +1006,7 @@ class setupStepMigrate extends setupStep /*********** * Check if returned users are within a valid department. (peopleou,gosaDepartment,base) ***********/ - $this->outsideUsers_toMigrate = array(); + $this->outsideUsers_toMigrate = []; $people_ou = trim(get_ou('userRDN')); while ($attrs = $ldap->fetch()) { @@ -1034,35 +1034,35 @@ class setupStepMigrate extends setupStep } } - function check_outsideUsers_migrate(&$checkobj) + function check_outsideUsers_migrate (&$checkobj) { global $config; $this->check_multipleGeneric_migrate( $checkobj, - array( + [ 'title' => _('Move users into configured user tree'), 'outside' => TRUE, 'ous' => $config->departments, 'destination' => (isset($_POST['destination']) ? $_POST['destination'] : ''), - ) + ] ); } - function check_outsideUsers_migrate_refresh(&$checkobj) + function check_outsideUsers_migrate_refresh (&$checkobj) { global $config; return $this->check_multipleGeneric_migrate_refresh( $checkobj, - array( + [ 'title' => _('Move users into configured user tree'), 'outside' => TRUE, 'ous' => $config->departments, 'destination' => (isset($_POST['destination']) ? $_POST['destination'] : ''), - ) + ] ); } - function check_outsideUsers_migrate_confirm(&$checkobj, $only_ldif = FALSE, $ou = 'userRDN') + function check_outsideUsers_migrate_confirm (&$checkobj, $only_ldif = FALSE, $ou = 'userRDN') { global $config; $ldap = $config->get_ldap_link(); @@ -1087,7 +1087,7 @@ class setupStepMigrate extends setupStep $entry['ldif'] = _('Entry will be moved from').":<br/>\t".($ldap->fix($dn)).'<br/>'._('to').":<br/>\t".($ldap->fix($d_dn)); /* Check if there are references to this object */ - $ldap->search('(&(member='.ldap_escape_f($dn).')(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))', array('dn')); + $ldap->search('(&(member='.ldap_escape_f($dn).')(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))', ['dn']); $refs = ''; while ($attrs = $ldap->fetch()) { $ref_dn = $attrs['dn']; @@ -1107,7 +1107,7 @@ class setupStepMigrate extends setupStep } /* Search for groups outside the group ou */ - function check_outsideGroups(&$checkobj) + function check_outsideGroups (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); @@ -1118,7 +1118,7 @@ class setupStepMigrate extends setupStep /*********** * Get all groups ***********/ - $res = $ldap->search('(objectClass=posixGroup)', array('dn')); + $res = $ldap->search('(objectClass=posixGroup)', ['dn']); if (!$res) { throw new CheckFailedException( _('LDAP query failed'), @@ -1126,7 +1126,7 @@ class setupStepMigrate extends setupStep ); } - $this->outsideGroups_toMigrate = array(); + $this->outsideGroups_toMigrate = []; while ($attrs = $ldap->fetch()) { $group_db_base = preg_replace('/^[^,]+,'.preg_quote($group_ou, '/').'/i', '', $attrs['dn']); @@ -1153,55 +1153,55 @@ class setupStepMigrate extends setupStep } } - function check_outsideGroups_migrate(&$checkobj) + function check_outsideGroups_migrate (&$checkobj) { global $config; $this->check_multipleGeneric_migrate( $checkobj, - array( + [ 'title' => _('Move groups into configured groups tree'), 'outside' => TRUE, 'ous' => $config->departments, 'destination' => (isset($_POST['destination']) ? $_POST['destination'] : ''), - ) + ] ); } - function check_outsideGroups_migrate_refresh(&$checkobj) + function check_outsideGroups_migrate_refresh (&$checkobj) { global $config; return $this->check_multipleGeneric_migrate_refresh( $checkobj, - array( + [ 'title' => _('Move groups into configured groups tree'), 'outside' => TRUE, 'ous' => $config->departments, 'destination' => (isset($_POST['destination']) ? $_POST['destination'] : ''), - ) + ] ); } - function check_outsideGroups_migrate_confirm(&$checkobj, $only_ldif = FALSE) + function check_outsideGroups_migrate_confirm (&$checkobj, $only_ldif = FALSE) { return $this->check_outsideUsers_migrate_confirm($checkobj, $only_ldif, 'groupRDN'); } /* Check if there are invisible organizational Units */ - function check_orgUnits(&$checkobj) + function check_orgUnits (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); $old = $this->orgUnits_toMigrate; - $this->orgUnits_toMigrate = array(); + $this->orgUnits_toMigrate = []; /* Skip FusionDirectory internal departments */ - $skip_dns = array( + $skip_dns = [ '/ou=fusiondirectory,'.preg_quote($config->current['BASE']).'$/', '/dc=addressbook,/', '/ou=systems,'.preg_quote($config->current['BASE']).'$/', '/ou=snapshots,/' - ); + ]; foreach (objects::types() as $type) { $infos = objects::infos($type); if (isset($infos['ou']) && ($infos['ou'] != '')) { @@ -1211,7 +1211,7 @@ class setupStepMigrate extends setupStep /* Get all invisible departments */ $ldap->cd($config->current['BASE']); - $res = $ldap->search('(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))', array('ou','description','dn')); + $res = $ldap->search('(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))', ['ou','description','dn']); if (!$res) { throw new CheckFailedException( _('LDAP query failed'), @@ -1262,46 +1262,46 @@ class setupStepMigrate extends setupStep } } - function check_orgUnits_migrate(&$checkobj) + function check_orgUnits_migrate (&$checkobj) { $this->check_multipleGeneric_migrate( $checkobj, - array( + [ 'title' => _('Department migration'), 'outside' => FALSE, - ) + ] ); } - function check_orgUnits_migrate_refresh(&$checkobj) + function check_orgUnits_migrate_refresh (&$checkobj) { return $this->check_multipleGeneric_migrate_refresh( $checkobj, - array( + [ 'title' => _('Department migration'), 'outside' => FALSE, - ) + ] ); } - function check_orgUnits_migrate_confirm(&$checkobj, $only_ldif) + function check_orgUnits_migrate_confirm (&$checkobj, $only_ldif) { return $this->check_multipleGeneric_migrate_confirm( $checkobj, - array('gosaDepartment'), - array('description' => 'FusionDirectory department'), + ['gosaDepartment'], + ['description' => 'FusionDirectory department'], $only_ldif ); } /* Check if there are uidNumbers which are used more than once */ - function check_uidNumber(&$checkobj) + function check_uidNumber (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - $res = $ldap->search("(&(objectClass=posixAccount)(uidNumber=*))", array("dn","uidNumber")); + $res = $ldap->search("(&(objectClass=posixAccount)(uidNumber=*))", ["dn","uidNumber"]); if (!$res) { throw new CheckFailedException( _('LDAP query failed'), @@ -1309,8 +1309,8 @@ class setupStepMigrate extends setupStep ); } - $this->check_uidNumbers = array(); - $tmp = array(); + $this->check_uidNumbers = []; + $tmp = []; while ($attrs = $ldap->fetch()) { $tmp[$attrs['uidNumber'][0]][] = $attrs; } @@ -1339,13 +1339,13 @@ class setupStepMigrate extends setupStep } /* Check if there are duplicated gidNumbers present in ldap */ - function check_gidNumber(&$checkobj) + function check_gidNumber (&$checkobj) { global $config; $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - $res = $ldap->search("(&(objectClass=posixGroup)(gidNumber=*))", array("dn","gidNumber")); + $res = $ldap->search("(&(objectClass=posixGroup)(gidNumber=*))", ["dn","gidNumber"]); if (!$res) { throw new CheckFailedException( _('LDAP query failed'), @@ -1353,8 +1353,8 @@ class setupStepMigrate extends setupStep ); } - $this->check_gidNumbers = array(); - $tmp = array(); + $this->check_gidNumbers = []; + $tmp = []; while ($attrs = $ldap->fetch()) { $tmp[$attrs['gidNumber'][0]][] = $attrs; } diff --git a/setup/class_setupStepWelcome.inc b/setup/class_setupStepWelcome.inc index d8f87295b..d73e23a46 100644 --- a/setup/class_setupStepWelcome.inc +++ b/setup/class_setupStepWelcome.inc @@ -23,19 +23,19 @@ class setupStepWelcome extends setupStep { var $header_image = 'geticon.php?context=applications&icon=config-welcome&size=48'; - static function getAttributesInfo() + static function getAttributesInfo () { - return array( - 'welcome' => array( + return [ + 'welcome' => [ 'name' => _('Welcome'), 'template' => get_template_path("setup_welcome.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( - ) - ) - ); + 'attrs' => [ + ] + ] + ]; } - function __construct($parent) + function __construct ($parent) { parent::__construct($parent); @@ -45,14 +45,14 @@ class setupStepWelcome extends setupStep } /* We need to init them with a method to be able to use _() */ - function update_strings() + function update_strings () { $this->s_short_name = _('Welcome'); $this->s_title = _('Welcome to FusionDirectory setup wizard'); $this->s_description = _('The welcome message'); } - function execute() + function execute () { $smarty = get_smarty(); $smarty->assign('auth_id', session_id()); @@ -61,7 +61,7 @@ class setupStepWelcome extends setupStep return parent::execute(); } - function save_object() + function save_object () { parent::save_object(); $id = ""; -- GitLab