diff --git a/contrib/smarty/plugins/block.render.php b/contrib/smarty/plugins/block.render.php index 04d5b3c5ffcc109d9e7566a2086e5a6575333e37..5244ec90c2084139fdce62eba80a57cd80b9a144 100644 --- a/contrib/smarty/plugins/block.render.php +++ b/contrib/smarty/plugins/block.render.php @@ -61,17 +61,17 @@ function smarty_block_render ($params, $text) } /* Remove select options */ - $from = array( + $from = [ "#<option.*<\/option>#is", "/(<textarea.*>).*(<\/textarea>)/is", "/^(.*<input.*)checked(.*>.*)$/isD" - ); + ]; - $to = array( + $to = [ " ", "\\1\\2", "\\1 \\2" - ); + ]; return preg_replace($from, $to, $text); } diff --git a/contrib/smarty/plugins/function.msgPool.php b/contrib/smarty/plugins/function.msgPool.php index cb3e4ccacc6d7582e0ab12bb945b14b5b3218f33..3566d8bea47ea4cbae48eb3dfed600fdfb75292c 100644 --- a/contrib/smarty/plugins/function.msgPool.php +++ b/contrib/smarty/plugins/function.msgPool.php @@ -21,14 +21,14 @@ function smarty_function_msgPool ($params) { 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 86f4b9b3a48035559ec9394a6a0b119391a14d04..0ee0e8774b9c6dede3be5cd0822a02fedf611056 100644 --- a/html/autocomplete.php +++ b/html/autocomplete.php @@ -30,7 +30,7 @@ reset_errors(); /* Logged in? Simple security check */ if (!session::global_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/getbin.php b/html/getbin.php index edc9413b7e763b311cf975714aa9f442b16e106f..3fe6990d53ed9fa2d685fb0ba2268d27a84773b6 100644 --- a/html/getbin.php +++ b/html/getbin.php @@ -31,7 +31,7 @@ reset_errors(); /* Logged in? Simple security check */ if (!session::global_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 5807d6078498ef57d2b35d45fcdc04736fb152d2..beec687c99e550276b0c6b2d0535d8a2b53ac8f4 100644 --- a/html/geticon.php +++ b/html/geticon.php @@ -34,7 +34,7 @@ if (session::global_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 2fe92ef1a4c65d750d5f397c2b04af8e148c9d12..861af49be529b8b9a4af8c6e697ef886fcd93dcf 100644 --- a/html/index.php +++ b/html/index.php @@ -123,7 +123,7 @@ if ( ($config->get_cfg_value('casActivated') == 'TRUE') || ($config->get_cfg_value('httpAuthActivated') == 'TRUE') || ($config->get_cfg_value('httpHeaderAuthActivated') == 'TRUE') || - in_array($config->get_cfg_value('LoginMethod'), array('LoginCas', 'LoginHTTPAuth', 'LoginHTTPHeader'))) { + in_array($config->get_cfg_value('LoginMethod'), ['LoginCas', 'LoginHTTPAuth', 'LoginHTTPHeader'])) { session::global_set('DEBUGLEVEL', 0); } diff --git a/html/main.php b/html/main.php index 5a489b0c795f9432be49e4da5feadd8d48355bdc..8b467d5dba0d42c1c949497a384a48f67af4e6a2 100644 --- a/html/main.php +++ b/html/main.php @@ -46,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { /* Logged in? Simple security check */ if (!session::global_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; } @@ -78,7 +78,7 @@ if (session::global_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 ($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) { diff --git a/html/progress.php b/html/progress.php index 5c5ae04fd1ef94c9177e8e26038a5b3df653fc31..38e193e44e100c85028e1830744ea23d4c781a6b 100644 --- a/html/progress.php +++ b/html/progress.php @@ -57,7 +57,7 @@ if (!function_exists("imagecreate")) { } else { $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/include/accept-to-gettext.inc b/include/accept-to-gettext.inc index 4bfa810618724beafbc19d1a168a7b46e58a33d8..a0fffc4fe785dff119a16dd97410f950285db48f 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 fef0220eefee41e3cc738ed4112aa965a24ba6be..65027c70e8df4d852b58736a2f86495aa3834768 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 9aaf90b87c4c80e77bd377ea29eae63a61905f06..a7c529a20ef89a6e3aa8986d5bf214716b432c6d 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 */ protected $lastdn = ''; - protected $disallowed_objects = array(); - protected $objects_to_fix = array(); - protected $clean_objects = array(); + protected $disallowed_objects = []; + protected $objects_to_fix = []; + protected $clean_objects = []; protected $require_update = FALSE; /*! @@ -74,12 +74,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; @@ -109,8 +109,8 @@ class CopyPasteHandler { $this->current = FALSE; $this->require_update = TRUE; - $this->queue = array(); - $this->objectList = array(); + $this->queue = []; + $this->objectList = []; } /*! @@ -138,7 +138,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']); @@ -169,9 +169,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) { @@ -195,7 +195,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 e44ecbb3d617d3969d67f3614025806a58e3ffbc..84023218e5ecac10fbaacd191e76956bafd82ed1 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; @@ -197,7 +197,7 @@ 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. */ @@ -205,7 +205,7 @@ class IconTheme 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)) { @@ -244,160 +244,160 @@ 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 2d75417fbcad5139613b1652218d1e28c7567b34..987ca0d9535f856c1e0055de8bec652b75f1c7c7 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 4aae53235b2ad48c87c7ab64d1cda7d79d606d78..8c0e78268a2152ae891c9b239acbff1b771b43ff 100644 --- a/include/class_SnapshotDialogs.inc +++ b/include/class_SnapshotDialogs.inc @@ -28,17 +28,17 @@ class SnapshotCreateDialog extends simplePlugin static function plInfo (): array { - return array( + return [ 'plShortName' => 'SnapshotCreateDialog', - ); + ]; } static function getAttributesInfo (): array { - 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) @@ -116,7 +116,7 @@ class SnapshotCreateDialog extends simplePlugin function save (): array { $this->parent->createSnapshot($this->object_dn, $this->description); - return array(); + return []; } } @@ -125,7 +125,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; @@ -139,18 +139,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'), '' - )); + ]); } } } @@ -184,10 +184,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]); } @@ -200,16 +200,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) @@ -246,18 +246,18 @@ class SnapshotRestoreDialog extends simplePlugin static function plInfo (): array { - return array( + return [ 'plShortName' => 'SnapshotRestoreDialog', - ); + ]; } static function getAttributesInfo (): array { - 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 @@ -265,12 +265,12 @@ class SnapshotRestoreDialog extends simplePlugin new SnapshotsAttribute( _('Snapshots'), _('Existing snapshots for this object'), 'snapshots', FALSE, - array(), + [], 'SnapshotHandler' ), - ) - ), - ); + ] + ], + ]; } function __construct ($dn, $parent, $global, $aclCategory) @@ -300,28 +300,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 a6723a0a290834f1691b741c2ed1bf00c78b63e1..2e98d5a582b775b6b4c9de4bef6945e61470ffd2 100644 --- a/include/class_SnapshotHandler.inc +++ b/include/class_SnapshotHandler.inc @@ -34,17 +34,17 @@ class SnapshotHandler 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'), - ) - ); + ] + ]; } /*! @@ -115,10 +115,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; } @@ -145,7 +145,7 @@ class SnapshotHandler { global $config; if (!$this->enabled()) { - return array(); + return []; } $ldap = $config->get_ldap_link(); @@ -159,12 +159,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] = ""; @@ -176,7 +176,7 @@ class SnapshotHandler if ($raw) { return $objects; } else { - $tmp = array(); + $tmp = []; foreach ($objects as $entry) { $tmp[base64_encode($entry['dn'])] = $entry['description'][0]; } @@ -192,7 +192,7 @@ class SnapshotHandler * * \param array $description Snapshot description */ - function createSnapshot ($dn, $description = array()) + function createSnapshot ($dn, $description = []) { global $config; if (!$this->enabled()) { @@ -204,7 +204,7 @@ class SnapshotHandler $dns = $dn; $dn = $dns[0]; } else { - $dns = array($dn); + $dns = [$dn]; } $ldap = $config->get_ldap_link(); @@ -230,9 +230,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; @@ -285,7 +285,7 @@ class SnapshotHandler { global $config; if (!$this->enabled()) { - return array(); + return []; } $ldap = $config->get_ldap_link(); @@ -293,13 +293,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' ); @@ -323,7 +323,7 @@ class SnapshotHandler { global $config; if (!$this->enabled()) { - return array(); + return []; } $ldap = $config->get_ldap_link(); @@ -331,11 +331,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()) { @@ -372,23 +372,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 d3e63aebf74c6f4121e8c49e765144a86d2896bb..1fc26706dd7b0f1822eb7eb37616db80434f6c1c 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 63ceaa13e140421225e6f5727b6b311f33af59ca..a70ca5acd036ebf3310fc7fb851a45b50079f4c0 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 352aa207de0fbf2755e0ef6c200e075715fe42f8..fa553eb2b7ac30568c0f682433dc6c6f7ab3b58b 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -33,35 +33,35 @@ class config /* XML parser */ var $parser; var $config_found = FALSE; - var $tags = array(); + var $tags = []; var $level = 0; var $currentLocation = ''; /*! * \brief Store configuration for current location */ - var $current = array(); + var $current = []; /* Link to LDAP-server */ protected $ldapLink = 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; @@ -102,7 +102,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->currentLocation = ''; @@ -131,11 +131,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); @@ -217,7 +217,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; @@ -265,7 +265,7 @@ class config { if (isset($_SERVER['HTTP_FDKEY'])) { if (!session::global_is_set('HTTP_FDKEY_CACHE')) { - session::global_set('HTTP_FDKEY_CACHE', array()); + session::global_set('HTTP_FDKEY_CACHE', []); } $cache = session::global_get('HTTP_FDKEY_CACHE'); if (!isset($cache[$creds])) { @@ -322,7 +322,7 @@ class config /* Move referrals */ if (!isset($this->current['REFERRAL'])) { - $this->ldapLink->referrals = array(); + $this->ldapLink->referrals = []; } else { $this->ldapLink->referrals = $this->current['REFERRAL']; } @@ -358,7 +358,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']); } @@ -423,12 +423,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]; } @@ -440,10 +440,10 @@ class config /* If no samba servers are found, look for configured sid/ridbase */ if ((count($this->data['SERVERS']['SAMBA']) == 0) && 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') - ); + ]; } } } @@ -456,7 +456,7 @@ class config if (!$forceReload) { $ldap = $this->get_ldap_link(); - $ldap->cat($dn, array('fusionConfigMd5')); + $ldap->cat($dn, ['fusionConfigMd5']); if (($attrs = $ldap->fetch()) && isset($attrs['fusionConfigMd5'][0]) && ($attrs['fusionConfigMd5'][0] == md5_file(CACHE_DIR.'/'.CLASS_CACHE))) { return; @@ -484,10 +484,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; } @@ -512,9 +512,9 @@ class config { if (isset($this->current['MANAGEMENTCONFIG'])) { if (!is_array($this->current['MANAGEMENTCONFIG'])) { - $this->current['MANAGEMENTCONFIG'] = array($this->current['MANAGEMENTCONFIG']); + $this->current['MANAGEMENTCONFIG'] = [$this->current['MANAGEMENTCONFIG']]; } - $value = array(); + $value = []; foreach ($this->current['MANAGEMENTCONFIG'] as $config) { list($class, $json) = explode(':', $config, 2); $value[$class] = $json; @@ -529,32 +529,32 @@ class config public function updateManagementConfig ($managementClass, $managementConfig) { $managementConfig = json_encode($managementConfig); - $changes = array(); + $changes = []; if (isset($this->current['MANAGEMENTCONFIG'][$managementClass])) { /* If there already was a config for this class, remove it */ if ($this->current['MANAGEMENTCONFIG'][$managementClass] == $managementConfig) { /* Unless it's the same one and we've got nothing to do */ - return array(); + return []; } - $changes[] = array( + $changes[] = [ 'attrib' => 'fdManagementConfig', 'modtype' => LDAP_MODIFY_BATCH_REMOVE, - 'values' => array($managementClass.':'.$this->current['MANAGEMENTCONFIG'][$managementClass]), - ); + 'values' => [$managementClass.':'.$this->current['MANAGEMENTCONFIG'][$managementClass]], + ]; } /* Add the new one */ - $changes[] = array( + $changes[] = [ 'attrib' => 'fdManagementConfig', 'modtype' => LDAP_MODIFY_BATCH_ADD, - 'values' => array($managementClass.':'.$managementConfig), - ); + 'values' => [$managementClass.':'.$managementConfig], + ]; $ldap = $this->get_ldap_link(); $ldap->cd(CONFIGRDN.$this->current['BASE']); if (!$ldap->modify_batch($changes)) { - return array($ldap->get_error()); + return [$ldap->get_error()]; } $this->current['MANAGEMENTCONFIG'][$managementClass] = $managementConfig; - return array(); + return []; } /*! @@ -575,7 +575,7 @@ class config function get_departments () { /* Initialize result hash */ - $result = array(); + $result = []; $result['/'] = $this->current['BASE']; @@ -588,7 +588,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']; @@ -619,11 +619,11 @@ class config $dn = $attrs['dn']; $infos = objects::infos($oc); - $this->department_info[$dn] = array( + $this->department_info[$dn] = [ 'img' => $infos['icon'], 'description' => (isset($attrs['description'][0]) ? $attrs['description'][0] : ''), 'name' => $attrs[$infos['mainAttr']][0] - ); + ]; /* Only assign non-root departments */ if ($dn != $result['/']) { @@ -640,9 +640,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) { @@ -694,7 +694,7 @@ class config */ function generateDepartmentArray ($arr, $depth = -1, $max_size = 256) { - $ret = array(); + $ret = []; $depth++; /* Walk through array */ @@ -751,7 +751,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] : []); } /*! @@ -785,7 +785,7 @@ class config } if (is_array($default) && !is_array($res)) { - $res = array($res); + $res = [$res]; } return $res; @@ -854,14 +854,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']).'TABS'; } @@ -874,7 +874,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 { @@ -887,7 +887,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; } @@ -916,7 +916,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); } @@ -924,22 +924,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 => $infos) { $cat = (is_numeric($idx) ? $infos : $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; @@ -948,7 +948,7 @@ class config /* Non numeric index means -> base object containing more informations */ $this->data['CATEGORIES'][$cat]['description'] = $infos['description']; if (!is_array($infos['objectClass'])) { - $infos['objectClass'] = array($infos['objectClass']); + $infos['objectClass'] = [$infos['objectClass']]; } $this->data['CATEGORIES'][$cat]['objectClass'] = $infos['objectClass']; } @@ -957,18 +957,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']; @@ -979,11 +979,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'])) { @@ -1047,7 +1047,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); @@ -1066,9 +1066,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; } @@ -1081,7 +1081,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) { @@ -1097,15 +1097,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 affc4718a841d3ae37a14cfd9114029a39a7aaaf..ba6f5116de7c5e5aa03fad71cbcdce1173e5de2b 100644 --- a/include/class_divSelectBox.inc +++ b/include/class_divSelectBox.inc @@ -45,7 +45,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 6f5a776921a052fb66a5e2fad6554f54c124ed71..85b55e1d23b741f1359af349acd463eef7e505ea 100644 --- a/include/class_filter.inc +++ b/include/class_filter.inc @@ -30,17 +30,17 @@ class filter { var $xmlData; - var $elements = array(); - var $elementValues = array(); - var $autocompleter = array(); + var $elements = []; + var $elementValues = []; + var $autocompleter = []; var $category = ''; - var $objectStorage = array(); + var $objectStorage = []; var $base = ''; var $scope = ''; var $query; var $initial = FALSE; var $scopeMode = 'auto'; - var $converter = array(); + var $converter = []; var $pid; var $headpage; @@ -77,7 +77,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 @@ -99,7 +99,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 @@ -111,7 +111,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 @@ -258,9 +258,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]; } } } @@ -388,7 +388,7 @@ class filter function query () { global $class_mapping; - $result = array(); + $result = []; // Return empty list if initial is not set if (!$this->initial) { @@ -413,10 +413,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)) { @@ -433,8 +433,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']); @@ -467,7 +467,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, $branches)); } @@ -534,7 +534,7 @@ class filter function getCompletitionList ($cfg, $tag, $value = "*") { global $class_mapping; - $res = array(); + $res = []; // Is backend available? $backend = "filter".$cfg['backend']; @@ -546,7 +546,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. @@ -557,10 +557,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); } @@ -586,7 +586,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 4aeb0f4844b660557be7fbdff2b410655e121583..649729404ef3fbb87541cf5eb0e2c044c0881c42 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 7f6ff508ca666be5b50480fd389ddf6e33a18a80..48d58f9fff708e05d48db35966e43f7e1788a188 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) { @@ -295,7 +295,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); @@ -313,7 +313,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) { @@ -345,7 +345,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"]); return @ldap_count_entries($this->cid, $res); } else { $this->error = "Could not connect to LDAP server"; @@ -378,7 +378,7 @@ class LDAP */ function fetch ($srp) { - $att = array(); + $att = []; if ($this->hascon) { if ($this->hasres[$srp]) { if ($this->start[$srp] == 0) { @@ -386,7 +386,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]); @@ -397,7 +397,7 @@ class LDAP } $this->error = @ldap_error($this->cid); if (!isset($att)) { - $att = array(); + $att = []; } return $att; } else { @@ -618,11 +618,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']); } @@ -655,7 +655,7 @@ class LDAP && preg_match("/^objectClass: value #([0-9]*) invalid per syntax$/", $this->get_additional_error(), $m)) { $ocs = $attrs['objectClass']; if (!is_array($ocs)) { - $ocs = array($ocs); + $ocs = [$ocs]; } if (isset($ocs[$m[1]])) { $str .= " - <b>objectClass: ".$ocs[$m[1]]."</b>"; @@ -752,7 +752,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)); } @@ -788,9 +788,9 @@ class LDAP if (!count($attrs)) { $type = preg_replace('/^([^=]+)=.*$/', '\\1', $cdn); $param = preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn); - $param = preg_replace(array('/\\\\,/','/\\\\"/'), array(',','"'), $param); + $param = preg_replace(['/\\\\,/','/\\\\"/'], [',','"'], $param); - $na = array(); + $na = []; /* Automatic or traditional? */ if (count($classes)) { @@ -819,7 +819,7 @@ class LDAP } /* Assemble_entry */ - $na['objectClass'] = array($ocname); + $na['objectClass'] = [$ocname]; if (isset($classes[$ocname]['AUXILIARY'])) { $na['objectClass'][] = $classes[$ocname]['SUP']; } @@ -847,7 +847,7 @@ class LDAP $na['ou'] = $param; break; case 'dc': - $na['objectClass'] = array('dcObject', 'top', 'organization'); + $na['objectClass'] = ['dcObject', 'top', 'organization']; $na['dc'] = $param; $na['o'] = $param; break; @@ -946,7 +946,7 @@ class LDAP function get_credentials ($url, $referrals = NULL) { - $ret = array(); + $ret = []; $url = preg_replace('!\?\?.*$!', '', $url); $server = preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url); @@ -987,7 +987,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; } @@ -1003,11 +1003,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); @@ -1034,7 +1034,7 @@ class LDAP function dn_exists ($dn) { - return @ldap_read($this->cid, $dn, "(objectClass=*)", array("objectClass")); + return @ldap_read($this->cid, $dn, "(objectClass=*)", ["objectClass"]); } /*! @@ -1066,8 +1066,8 @@ class LDAP /* Joining lines */ $line = NULL; - $entry = array(); - $entries = array(); + $entry = []; + $entries = []; $entryStart = -1; foreach ($fileLines as $lineNumber => $fileLine) { if (preg_match('/^ /', $fileLine)) { @@ -1105,7 +1105,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; } @@ -1119,7 +1119,7 @@ class LDAP $entries[$entryStart] = $entry; } /* Start a new entry */ - $entry = array(); + $entry = []; $entryStart = -1; $line = NULL; } @@ -1201,11 +1201,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] = []; } } } @@ -1240,19 +1240,19 @@ class LDAP } // Get base to look for schema - $res = @ldap_read($this->cid, '', 'objectClass=*', array('subschemaSubentry')); + $res = @ldap_read($this->cid, '', 'objectClass=*', ['subschemaSubentry']); $attrs = @ldap_get_entries($this->cid, $res); if (!isset($attrs[0]['subschemasubentry'][0])) { - return array(); + return []; } /* Get list of objectclasses and fill array */ $nb = $attrs[0]['subschemasubentry'][0]; - $objectclasses = array(); - $res = ldap_read($this->cid, $nb, 'objectClass=*', array('objectclasses')); + $objectclasses = []; + $res = ldap_read($this->cid, $nb, 'objectClass=*', ['objectclasses']); $attrs = ldap_get_entries($this->cid, $res); if (!isset($attrs[0])) { - return array(); + return []; } foreach ($attrs[0]['objectclasses'] as $val) { if (preg_match('/^[0-9]+$/', $val)) { @@ -1261,7 +1261,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) { @@ -1273,8 +1273,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; } @@ -1292,8 +1292,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; } @@ -1380,7 +1380,7 @@ class LDAP ldap_bind($ds, $admin, $password); /* Get base to look for naming contexts */ - $res = @ldap_read($ds, '', 'objectClass=*', array('namingContexts')); + $res = @ldap_read($ds, '', 'objectClass=*', ['namingContexts']); $attrs = @ldap_get_entries($ds, $res); return $attrs[0]['namingcontexts']; diff --git a/include/class_ldapFilter.inc b/include/class_ldapFilter.inc index a76b27ce95592409f9ba6a6836a7702fbee71921..005a31e57700fa2e94ba8203f52ce275e4e890ee 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 2b3dd8ccc3e90604c59294232fb64c135c954eef..9bbae6a8bfe1c0fc461f037fce861acb91f7cfce 100644 --- a/include/class_ldapMultiplexer.inc +++ b/include/class_ldapMultiplexer.inc @@ -61,11 +61,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 fd1a034a393059a3ba0b319599287523a371e069..ce37f7dafab9c0dddfc3817188b894757764621d 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,23 +45,23 @@ 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 $exporters = array(); - var $exportColumns = array(); + var $exporters = []; + var $exportColumns = []; var $scrollPosition = 0; var $baseSelector; - protected $filterCache = array(); + protected $filterCache = []; protected $parent; /*! @@ -106,7 +106,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->exporters = array_merge($this->exporters, $info); } @@ -198,7 +198,7 @@ class listing $this->xmlData = xml::xml2array($contents, 1); } - $this->filterCache = array(); + $this->filterCache = []; if (!isset($this->xmlData['list'])) { return FALSE; @@ -207,7 +207,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; @@ -218,19 +218,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; @@ -250,7 +250,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 @@ -263,7 +263,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; @@ -272,8 +272,8 @@ class listing function renderHeader () { - $this->header = array(); - $this->plainHeader = array(); + $this->header = []; + $this->plainHeader = []; // Initialize sort? $sortInit = FALSE; @@ -284,7 +284,7 @@ class listing } else { $this->sortAttribute = ""; } - $this->sortDirection = array(); + $this->sortDirection = []; $sortInit = TRUE; } @@ -523,8 +523,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)) { @@ -547,12 +547,12 @@ class listing $exporter = $this->exporters[$_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']); } @@ -607,10 +607,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; } @@ -662,7 +662,7 @@ class listing */ function parseLayout ($layout) { - $result = array(); + $result = []; $layout = preg_replace("/^\|/", "", $layout); $layout = preg_replace("/\|$/", "", $layout); $cols = explode("|", $layout); @@ -756,7 +756,7 @@ class listing } else { preg_match_all('/%{filter:([^(]+)\((.*)\)}/', $data, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); - $filtersData = array(); + $filtersData = []; foreach ($matches as $match) { $cl = ''; $method = ''; @@ -771,7 +771,7 @@ class listing // Prepare params for function call preg_match_all('/"[^"]+"|[^,]+/', $match[2][0], $parts); - $filtersData[$match[0][0]] = array($cl, $method, $parts[0], $match[0][1]); + $filtersData[$match[0][0]] = [$cl, $method, $parts[0], $match[0][1]]; } $this->filterCache[$type.$index] = $filtersData; @@ -779,7 +779,7 @@ class listing foreach ($filtersData as $filterstring => $filter) { list ($cl, $method, $parts, $offset) = $filter; - $params = array(); + $params = []; foreach ($parts as $param) { switch ($param) { case 'row': @@ -821,10 +821,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)); } } @@ -874,7 +874,7 @@ class listing } $ocs = $objectType['objectClass']; if (!is_array($ocs)) { - $ocs = array($ocs); + $ocs = [$ocs]; } $found = TRUE; @@ -1088,7 +1088,7 @@ class listing */ function filterLink ($row, $dn, $mask, ...$vals) { - $params = array($mask); + $params = [$mask]; // Collect sprintf params foreach ($vals as $val) { @@ -1096,7 +1096,7 @@ class listing continue; } if (!is_array($val)) { - $val = array($val); + $val = [$val]; } $val = array_map( function ($v) @@ -1122,7 +1122,7 @@ class listing function renderNavigation () { - $result = array(); + $result = []; $enableBack = TRUE; $enableRoot = TRUE; $enableHome = TRUE; @@ -1190,7 +1190,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'])) { @@ -1265,7 +1265,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; } @@ -1304,7 +1304,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 @@ -1345,7 +1345,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; @@ -1371,7 +1371,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>"; @@ -1442,14 +1442,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) { @@ -1459,12 +1459,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]; @@ -1473,10 +1473,10 @@ class listing $modules = $module; if (!is_array($modules)) { - $modules = array($modules); + $modules = [$modules]; } - $aclInfos[] = array($aclList, $modules); + $aclInfos[] = [$aclList, $modules]; } $action['aclInfos'] = $aclInfos; } @@ -1525,7 +1525,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)) { @@ -1550,7 +1550,7 @@ class listing { $ui = get_userinfo(); - $this->departments = array(); + $this->departments = []; // Get list of supported department types $types = departmentManagement::getDepartmentTypes(); @@ -1563,12 +1563,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 6df3e766cfc4a5345855d657d3a59f4df5ab3dbc..5cb276a584ef1c98a55a60a0f41ad0521011b5ed 100644 --- a/include/class_logging.inc +++ b/include/class_logging.inc @@ -35,7 +35,7 @@ */ 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 @@ -50,7 +50,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; @@ -60,14 +60,14 @@ class logging } /* Create data object */ - $entry = array( + $entry = [ 'timestamp' => time(), 'action' => $action, 'objecttype' => $objecttype, 'object' => $object, 'changes' => $changes_array, 'result' => $result - ); + ]; if (isset($ui->dn) && !empty($ui->dn)) { $entry['user'] = $ui->dn; } else { @@ -84,7 +84,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); } } @@ -96,9 +96,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 6bc4a08106f1836c4d6f234471167333a8dc7587..09035082953fec0a12a12fa3c423c8654fe0633b 100644 --- a/include/class_msgPool.inc +++ b/include/class_msgPool.inc @@ -597,7 +597,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); @@ -642,9 +642,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")]; } /*! @@ -653,7 +653,7 @@ class msgPool */ public static function weekdays () { - return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")); + return [ _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")]; } /*! @@ -670,8 +670,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]); @@ -723,7 +723,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 fa1fc86d716466375b8f0b02197947307b55081b..091a83aaf48b7c7b6347a8a76cf05c1356e126eb 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 d9586b4fc7bae720532d0816ec1badbcb68d0fce..4ca155d8f45a2fc7b8a0ba1558fe1112cafcd077 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) { @@ -63,9 +63,9 @@ class objects $tplAcl = $infos['aclCategory'].'/template'; } - $attrsAcls = array(); + $attrsAcls = []; if ($attrs === NULL) { - $attrs = array(); + $attrs = []; foreach ($types as $type) { $infos = static::infos($type); if ($infos['mainAttr']) { @@ -76,13 +76,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); @@ -93,7 +93,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]; } } } @@ -105,15 +105,15 @@ class objects $search_attrs[] = 'cn'; } } else { - $search_attrs = array($attrs); + $search_attrs = [$attrs]; } try { $ldap = static::search($types, $search_attrs, $ou, $filter, $checkAcl, $scope, $templateSearch, $partialFilterAcls, $sizeLimit); } catch (NonExistingBranchException $e) { - return array(); + return []; } - $result = array(); + $result = []; while ($fetched_attrs = $ldap->fetch()) { $key = $fetched_attrs['dn']; if ($checkAcl) { @@ -127,7 +127,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]) && @@ -153,7 +153,7 @@ class objects ) { $result[$key]['cn'] = $fetched_attrs['cn'][0]; } - $result[$key]['fdTemplateField'] = array(); + $result[$key]['fdTemplateField'] = []; foreach ($fetched_attrs['fdTemplateField'] as $templateField) { $attr = explode(':', $templateField, 2)[0]; if (isset($attrs[$attr])) { @@ -195,7 +195,7 @@ class objects static function count ($types, $ou = NULL, $filter = '', $checkAcl = FALSE, $templateSearch = FALSE) { try { - $ldap = static::search($types, array('dn'), $ou, $filter, $checkAcl, 'subtree', $templateSearch, $partialFilterAcls); + $ldap = static::search($types, ['dn'], $ou, $filter, $checkAcl, 'subtree', $templateSearch, $partialFilterAcls); if (!empty($partialFilterAcls)) { throw new FusionDirectoryException('Not enough rights to use "'.$partialFilterAcls[0][1].'" in filter'); } @@ -207,21 +207,21 @@ class objects return $ldap->count(); } - private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, &$partialFilterAcls = array(), $sizeLimit = FALSE) + private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, &$partialFilterAcls = [], $sizeLimit = FALSE) { 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); @@ -263,7 +263,7 @@ class objects continue; } if (strpos($ui->get_permissions($ou, $category, $acl), 'r') === FALSE) { - $partialFilterAcls[] = array($category, $acl); + $partialFilterAcls[] = [$category, $acl]; } } } @@ -275,10 +275,10 @@ class objects if ($templateSearch) { $templateFilterObject = new ldapFilter( '&', - array( + [ new ldapFilterLeaf('objectClass', '=', 'fdTemplate'), fdTemplateFilter(ldapFilter::parse($filter)), - ) + ] ); $filter = "$templateFilterObject"; } @@ -335,7 +335,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]; @@ -383,7 +383,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].')'; @@ -426,7 +426,7 @@ class objects $infos =& static::infos($type); if (!isset($infos['searchAttributes'])) { - $searchAttrs = array(); + $searchAttrs = []; if (!empty($infos['mainAttr'])) { $searchAttrs[$infos['mainAttr']] = $infos['aclCategory'].'/'.$infos['mainTab']; } @@ -464,11 +464,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_passwordRecovery.inc b/include/class_passwordRecovery.inc index 4feb6489a0923ec83f3410306e6362a165fa55e1..527a4a44168fafb91842743bf497a31035097f8c 100644 --- a/include/class_passwordRecovery.inc +++ b/include/class_passwordRecovery.inc @@ -50,7 +50,7 @@ class passwordRecovery extends standAlonePage parent::init(); $this->step = 1; - $this->message = array(); + $this->message = []; if (isset($_GET['email_address']) && ($_GET['email_address'] != '')) { $this->email_address = validate($_GET['email_address']); @@ -164,7 +164,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']); @@ -177,15 +177,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); @@ -230,7 +230,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'; } @@ -239,7 +239,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')); @@ -274,7 +274,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) { @@ -300,7 +300,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); } @@ -367,7 +367,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'])) { @@ -384,13 +384,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/include/class_pluglist.inc b/include/class_pluglist.inc index e23764cff1db93f3ac4a64cd7c2c7007298c789e..33bc7de1046cc5922a3fa4c9a9b05ac5ff906e75 100644 --- a/include/class_pluglist.inc +++ b/include/class_pluglist.inc @@ -41,23 +41,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 @@ -72,13 +72,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; } @@ -86,7 +86,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; @@ -104,10 +104,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]; @@ -126,27 +126,27 @@ 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']; @@ -161,7 +161,7 @@ class pluglist if (isset($infos['plFilter'])) { $infos['plFilterObject'] = ldapFilter::parse($infos['plFilter']); } - $infos['plForeignRefs'] = array(); + $infos['plForeignRefs'] = []; $infos['INDEX'] = $index; $this->info[$cname] = $infos; $this->dirlist[$index++] = $cname; @@ -174,7 +174,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"); @@ -189,7 +189,7 @@ class pluglist $this->info[$conflict]['plConflicts'][] = $cname; } } else { - $this->info[$conflict]['plConflicts'] = array($cname); + $this->info[$conflict]['plConflicts'] = [$cname]; } } } @@ -201,9 +201,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; @@ -259,11 +259,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) { @@ -320,7 +320,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); @@ -340,7 +340,7 @@ class pluglist if (!$plIcon) { $plIcon = "icon.png"; } - return array($plHeadline,$plDescription,$href,$plIcon); + return [$plHeadline,$plDescription,$href,$plIcon]; } /*! @@ -560,7 +560,7 @@ class pluglist if (is_file("$plugin_dir/main.inc")) { $display = ''; require("$plugin_dir/main.inc"); - } elseif (is_callable(array($plugin, 'mainInc'))) { + } elseif (is_callable([$plugin, 'mainInc'])) { $plugin::mainInc(); } else { msg_dialog::display( diff --git a/include/class_standAlonePage.inc b/include/class_standAlonePage.inc index 42939609d6dd48d26c57120e11bfb92e5df9b565..42fcdea249efd6f624e80d84c02521c9129196d4 100644 --- a/include/class_standAlonePage.inc +++ b/include/class_standAlonePage.inc @@ -43,7 +43,7 @@ class standAlonePage session::global_set('config', $config); /* Generate server list */ - $this->directories = array(); + $this->directories = []; foreach ($config->data['LOCATIONS'] as $key => $ignored) { $this->directories[$key] = $key; } diff --git a/include/class_template.inc b/include/class_template.inc index 40085fd3b5d1c6b1d131a84acd82eb9c6c4a469a..bbe6875cf1cf9aceb915b7a7ce1ee19b64582ec9 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)) { @@ -189,12 +189,12 @@ class template */ function serialize () { - $ret = array(); + $ret = []; foreach ($this->tabObject->by_object as $class => $plugin) { if (!isset($this->attributes[$class])) { continue; } - $ret[$class] = array('name' => $this->tabObject->by_name[$class], 'attrs' => array()); + $ret[$class] = ['name' => $this->tabObject->by_name[$class], 'attrs' => []]; foreach ($this->attributes[$class] as $attr) { $plugin->attributesAccess[$attr]->serializeAttribute($ret[$class]['attrs'], FALSE); } @@ -223,9 +223,9 @@ class template */ function getValues () { - $ret = array(); + $ret = []; foreach ($this->tabObject->by_object as $class => $plugin) { - $ret[$class] = array(); + $ret[$class] = []; foreach ($plugin->attributesAccess as $name => $attr) { $ret[$class][$name] = $attr->getValue(); } @@ -263,8 +263,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])) { @@ -279,7 +279,7 @@ class template return $dialogResult; } } - $attributesRendered = array(); + $attributesRendered = []; 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 @@ -344,7 +344,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); @@ -353,7 +353,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 db1af78fc7e4fc6f0f15f63ebf9ed323ace61bee..df0c55ebbc29539d9e34d55287fd964bddc128f3 100644 --- a/include/class_templateHandling.inc +++ b/include/class_templateHandling.inc @@ -39,13 +39,13 @@ 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 */ public static function fieldsFromLDAP (array $template_attrs) { - $attrs = array(); + $attrs = []; if (isset($template_attrs['fdTemplateField'])) { unset($template_attrs['fdTemplateField']['count']); sort($template_attrs['fdTemplateField']); @@ -55,7 +55,7 @@ class templateHandling $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; } } @@ -121,27 +121,27 @@ 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 = $attrs[$mask]; if (is_array($result)) { unset($result['count']); } else { - $result = array($result); + $result = [$result]; } } elseif (($mask != '') && !preg_match('/c/', $modifiers)) { trigger_error("'$mask' was not found in attributes"); } $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 */ @@ -159,7 +159,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; @@ -221,10 +221,10 @@ class templateHandling } $offset = 0; - $vars = array(); + $vars = []; while (preg_match('/%([^%]+)%/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) { $replace = static::parseMask($m[1][0], $attrs); - $vars[] = array($m[0][1], strlen($m[0][0]), $replace); + $vars[] = [$m[0][1], strlen($m[0][0]), $replace]; $offset = $m[0][1] + strlen($m[0][0]); } @@ -238,7 +238,7 @@ class templateHandling /* Return the first found unique value */ foreach ($generator as $value) { $filter = '('.ldap_escape_f($unique).'='.ldap_escape_f($value).')'; - $ldap->search($filter, array('dn')); + $ldap->search($filter, ['dn']); if ( ($ldap->count() == 0) || (($target !== NULL) && ($ldap->count() == 1) && ($ldap->getDN() == $target)) @@ -286,7 +286,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]; @@ -310,15 +310,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); @@ -336,7 +336,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) @@ -348,13 +348,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])]; } } @@ -419,9 +419,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])]; } private static function modifierNumber (array $args) @@ -473,23 +473,23 @@ class templateHandling 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 @@ -515,22 +515,22 @@ class templateHandling 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 @@ -550,11 +550,11 @@ 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; case 'n': // number @@ -562,14 +562,14 @@ class templateHandling 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]; @@ -587,7 +587,7 @@ class templateHandling $key, $a ); - return array(); + return []; } $deps = static::flatDepends($cache, $errors, $depends, $a, $forbidden); if (($askmeKey = array_search('askme', $deps)) !== FALSE) { @@ -607,11 +607,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) { @@ -621,19 +621,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 239a1b9cc66bbf5df0fd2548d042d0a4d806e5ec..9313583d9bdbc41420bfc5cd1cd14551ca0e6c74 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; } @@ -285,7 +285,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']) && preg_match('/ou=([^,]+),$/', $infos['ou'], $m)) { $reservedNames[] = $m[1]; diff --git a/include/class_timezone.inc b/include/class_timezone.inc index 495151cdcc7a6bb40fff416247756d49fd5c39fb..0dccc3f7cddcbb4a8ddd4875d9639d43d52bfa88 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 549873179c1801886cc4f8ea6d2f10369097fb24..92982ea1e359384a03c4dbee0e16716d02f96507 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; @@ -76,7 +76,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]; @@ -110,7 +110,7 @@ class userinfo public function reset_acl_cache () { /* Initialize ACL_CACHE */ - session::global_set('ACL_CACHE', array()); + session::global_set('ACL_CACHE', []); } /*! @@ -119,42 +119,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])); } @@ -166,18 +166,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'] - ); + ]; } } } @@ -222,7 +222,7 @@ class userinfo if ($interresting) { if (!isset($this->ACL[$dn])) { - $this->ACL[$dn] = array(); + $this->ACL[$dn] = []; } $this->ACL[$dn][$idx] = $type; } @@ -243,7 +243,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 { @@ -406,11 +406,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) { @@ -460,7 +460,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; } @@ -490,7 +490,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; } @@ -499,7 +499,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); @@ -635,7 +635,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; } @@ -666,17 +666,17 @@ class userinfo $ACL_CACHE = &session::global_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) { @@ -738,7 +738,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"; @@ -902,8 +902,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); } @@ -992,7 +992,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) && (in_array($group, $this->groups) || in_array($group, $this->roles))) { @@ -1011,7 +1011,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 8a2c8acd0dfd270ed4f086acb17b1fdda6a56ddc..32351b7269ac915d290ceb2e6cf5d752c7195ac7 100644 --- a/include/class_xml.inc +++ b/include/class_xml.inc @@ -42,12 +42,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 @@ -63,12 +63,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 @@ -76,8 +76,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 @@ -146,7 +146,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_csvExporter.inc b/include/exporter/class_csvExporter.inc index 0389bbb32d94f2323afa0fe6790e4ac8f3eb0a5f..e45d70e983e31229edbf710b44dce9fcef375667 100644 --- a/include/exporter/class_csvExporter.inc +++ b/include/exporter/class_csvExporter.inc @@ -42,7 +42,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)) { @@ -115,6 +115,6 @@ 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 6fa8732951d80d6faea1e28c56b2a9365999f881..69f77d357110b9ee741258d456692cacf2bbc4b9 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')) { @@ -140,7 +140,7 @@ class pdfExporter */ function calcWidth ($header, $entries, $columns) { - $width = array(); + $width = []; // Locate longest value for each column foreach ($columns as $index) { @@ -181,7 +181,7 @@ class pdfExporter */ static function calcColumnsWidth ($result, $columns, $iterator) { - $width = array(); + $width = []; // Locate longest value for each column foreach ($columns as $index => $column) { @@ -304,7 +304,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 d06ba538decd1e89e33130e5e15be329f0ba5684..5fab66e54752c3a1d5ed754c970860d5b3e6c883 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" ]; /*! @@ -253,14 +253,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", @@ -268,7 +268,7 @@ function get_template_path ($filename = '', $plugin = FALSE, $path = '') "themes/default/$filename", "$BASE_DIR/ihtml/themes/default/$filename", $filename - ); + ]; } foreach ($paths as $path) { @@ -416,8 +416,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)) { @@ -426,7 +426,7 @@ function ldap_get_user ($username) } if (count($verify_attr) == 0) { - $verify_attr = array('uid'); + $verify_attr = ['uid']; } $tmp = $verify_attr; $tmp[] = 'uid'; @@ -501,7 +501,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'), @@ -536,7 +536,7 @@ function add_lock ($object, $user) don't need to remove any locks for them later. */ if (!session::global_is_set('LOCK_CACHE')) { - session::global_set('LOCK_CACHE', array('')); + session::global_set('LOCK_CACHE', ['']); } if (is_array($object)) { foreach ($object as $obj) { @@ -564,7 +564,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; @@ -572,16 +572,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); @@ -628,7 +628,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)); @@ -656,7 +656,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']); } @@ -729,7 +729,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).'))'; } @@ -737,20 +737,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)) { @@ -856,7 +856,7 @@ function get_ou ($name) { global $config; - $map = array( + $map = [ 'fusiondirectoryRDN' => 'ou=fusiondirectory,', 'lockRDN' => 'ou=locks,', 'recoveryTokenRDN' => 'ou=recovery,', @@ -906,7 +906,7 @@ function get_ou ($name) 'dsaRDN' => 'ou=dsa,', 'mimetypeRDN' => 'ou=mime,' - ); + ]; /* Preset ou... */ if ($config->get_cfg_value($name, '_not_set_') != '_not_set_') { @@ -1027,9 +1027,9 @@ function gen_locked_message (array $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) { @@ -1055,7 +1055,7 @@ function gen_locked_message (array $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); @@ -1338,7 +1338,7 @@ function to_byte ($value) */ function humanReadableSize ($bytes, $precision = 2) { - $format = array( + $format = [ _('%sB'), _('%sKiB'), _('%sMiB'), @@ -1348,7 +1348,7 @@ function humanReadableSize ($bytes, $precision = 2) _('%sEiB'), _('%sZiB'), _('%sYiB') - ); + ]; if ($bytes == 0) { return sprintf($format[0], '0'); } @@ -1433,7 +1433,7 @@ function scan_directory ($path, $sort_desc = FALSE) /* is this path a readable one */ if (is_dir($path) && is_readable($path)) { /* Get contents and write it into an array */ - $ret = array(); + $ret = []; $dir = opendir($path); @@ -1654,7 +1654,7 @@ function normalizeLdap ($input) */ function check_schema (array $cfg) { - $checks = array(); + $checks = []; /* Get objectclasses */ $ldapObj = new LDAP($cfg['admin'], $cfg['password'], $cfg['connection'], FALSE, $cfg['tls']); @@ -1668,14 +1668,14 @@ function check_schema (array $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 */ @@ -1683,7 +1683,7 @@ function check_schema (array $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'); @@ -1691,7 +1691,7 @@ function check_schema (array $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'); @@ -1699,7 +1699,7 @@ function check_schema (array $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.'); @@ -1707,7 +1707,7 @@ function check_schema (array $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.'); @@ -1716,7 +1716,7 @@ function check_schema (array $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.'); } @@ -1740,7 +1740,7 @@ function check_schema (array $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'] = ''; @@ -1819,13 +1819,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)) { @@ -1840,13 +1840,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)) { @@ -1872,7 +1872,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]); @@ -1906,7 +1906,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]; @@ -2087,7 +2087,7 @@ function mark ($needle, $haystack) function reset_errors () { - session::set('errorsAlreadyPosted', array()); + session::set('errorsAlreadyPosted', []); } function load_all_classes () @@ -2190,7 +2190,7 @@ function mail_utf8 ($to, $from_user, $from_email, $subject, $message, $replyto_u /* Calls fopen, gives errors as an array if any, file handle if successful */ function fopenWithErrorHandling (...$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 f88b121b3f5d0de0c6f356b7a785241faa922d00..b09700afc74e4280911b762f6e8b9e0006f7a819 100644 --- a/include/functions_debug.inc +++ b/include/functions_debug.inc @@ -169,8 +169,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 { @@ -319,17 +319,17 @@ function show_vars ($show_all_vars = FALSE, $show_object_vars = FALSE) DEBUG '.show_runtime().' '; - $vars_arr['script_globals'] = array('global script variables', '#7ACCC8'); + $vars_arr['script_globals'] = ['global script variables', '#7ACCC8']; - $vars_arr['_GET'] = array('$_GET', '#7DA7D9'); - $vars_arr['_POST'] = array('$_POST', '#F49AC1'); - $vars_arr['_FILES'] = array('$_POST FILES', '#82CA9C'); - $vars_arr['_SESSION'] = array('$_SESSION', '#FCDB26'); - $vars_arr['_COOKIE'] = array('$_COOKIE', '#A67C52'); + $vars_arr['_GET'] = ['$_GET', '#7DA7D9']; + $vars_arr['_POST'] = ['$_POST', '#F49AC1']; + $vars_arr['_FILES'] = ['$_POST FILES', '#82CA9C']; + $vars_arr['_SESSION'] = ['$_SESSION', '#FCDB26']; + $vars_arr['_COOKIE'] = ['$_COOKIE', '#A67C52']; if ($show_all_vars) { - $vars_arr['_SERVER'] = array('SERVER', '#A186BE'); - $vars_arr['_ENV'] = array('ENV', '#7ACCC8'); + $vars_arr['_SERVER'] = ['SERVER', '#A186BE']; + $vars_arr['_ENV'] = ['ENV', '#7ACCC8']; } foreach ($vars_arr as $vars_name => $vars_data) { diff --git a/include/login/class_LoginCAS.inc b/include/login/class_LoginCAS.inc index b06143bf9684e3caa227badcc6ee590ca3967329..3846c70f838f7c51ee4eb362106eb5e8bfee9f11 100644 --- a/include/login/class_LoginCAS.inc +++ b/include/login/class_LoginCAS.inc @@ -86,11 +86,11 @@ class LoginCAS extends LoginMethod $ui->loadACL(); - $success = static::runSteps(array( + $success = static::runSteps([ 'checkForLockingBranch', 'loginAndCheckExpired', 'runSchemaCheck', - )); + ]); if ($success) { /* Everything went well, redirect to main.php */ diff --git a/include/login/class_LoginHTTPAuth.inc b/include/login/class_LoginHTTPAuth.inc index 99829c487bf7d9e8e839a231430989b11a1f1593..31cdbaec98861397aec550836c68602be14a65cc 100644 --- a/include/login/class_LoginHTTPAuth.inc +++ b/include/login/class_LoginHTTPAuth.inc @@ -43,13 +43,13 @@ class LoginHTTPAuth extends LoginMethod 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 */ diff --git a/include/login/class_LoginHTTPHeader.inc b/include/login/class_LoginHTTPHeader.inc index 0eb6c1503b01cab0ea7902d8511e989e58dc847f..d7f6d64e974b31b5585a35af38bb0e196a7f7c80 100644 --- a/include/login/class_LoginHTTPHeader.inc +++ b/include/login/class_LoginHTTPHeader.inc @@ -82,11 +82,11 @@ class LoginHTTPHeader extends LoginMethod $ui->loadACL(); - $success = static::runSteps(array( + $success = static::runSteps([ 'checkForLockingBranch', 'loginAndCheckExpired', 'runSchemaCheck', - )); + ]); if ($success) { /* Everything went well, redirect to main.php */ diff --git a/include/login/class_LoginMethod.inc b/include/login/class_LoginMethod.inc index 81629aa82bd68e763f5ed97ebf61f634e6b27052..14f10965c81f3362501511928a4cc32ffe61ece6 100644 --- a/include/login/class_LoginMethod.inc +++ b/include/login/class_LoginMethod.inc @@ -42,7 +42,7 @@ class LoginMethod 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']; @@ -65,7 +65,7 @@ class LoginMethod { 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']); @@ -98,9 +98,9 @@ class LoginMethod $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'); @@ -136,7 +136,7 @@ class LoginMethod $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; @@ -150,7 +150,7 @@ class LoginMethod { 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::global_set('connected', 1); session::global_set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL')); header('Location: main.php'); @@ -200,13 +200,13 @@ class LoginMethod static function getMethods () { - $methods = array( + $methods = [ 'LoginPost', 'LoginCAS', 'LoginHTTPAuth', 'LoginHTTPHeader', - ); - $return = array(); + ]; + $return = []; foreach ($methods as $method) { $label = $method::getLabel(); if ($label) { diff --git a/include/login/class_LoginPost.inc b/include/login/class_LoginPost.inc index cb68c5ebad7a3f34dc1f4034e5d0aeaae6e4c76f..46261ad74b50457d346bf6023f184beb44216f2f 100644 --- a/include/login/class_LoginPost.inc +++ b/include/login/class_LoginPost.inc @@ -42,13 +42,13 @@ class LoginPost extends LoginMethod 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 */ @@ -103,7 +103,7 @@ class LoginPost extends LoginMethod } /* Generate server list */ - $servers = array(); + $servers = []; if (isset($_POST['server'])) { $selected = $_POST['server']; } else { diff --git a/include/management/actions/class_Action.inc b/include/management/actions/class_Action.inc index e1327ad1cafd36d94aeacf0554f9684bee2287e1..d0ddb08b43fde95ddceb4e317e4b11e9365559a7 100644 --- a/include/management/actions/class_Action.inc +++ b/include/management/actions/class_Action.inc @@ -49,7 +49,7 @@ class Action protected $parent; - function __construct (string $name, $label, $icon, string $targets, $callable, array $acls = array(), bool $inmenu = TRUE, bool $inline = TRUE, array $validTypes = array()) + function __construct (string $name, $label, $icon, string $targets, $callable, array $acls = [], bool $inmenu = TRUE, bool $inline = TRUE, array $validTypes = []) { if ($targets == '0') { $inline = FALSE; @@ -63,7 +63,7 @@ class Action $this->inmenu = $inmenu; $this->inline = $inline; $this->validTypes = array_map('strtoupper', $validTypes); - $this->acl = array(); + $this->acl = []; /* * acl may be of the form: * acl (ex: 'd') @@ -83,12 +83,12 @@ class Action if (strpos($acl, ':') !== FALSE) { list($attribute, $acl) = explode(':', $acl, 2); } - $this->acl[] = array( + $this->acl[] = [ 'category' => $category, 'class' => $class, 'attribute' => $attribute, 'acl' => str_split($acl), - ); + ]; } switch ($this->targets) { @@ -149,7 +149,7 @@ class Action function listActions (): array { - return array($this->name); + return [$this->name]; } function execute ($management, $action) @@ -165,7 +165,7 @@ class Action } $func = $this->callable; if (!is_array($func)) { - $func = array($management, $func); + $func = [$management, $func]; } return call_user_func($func, $action); } @@ -180,13 +180,13 @@ class Action return; } - $actions[] = array( + $actions[] = [ 'name' => $this->name, 'icon' => $this->icon, 'label' => $this->label, 'enabled' => $this->isEnabledFor(), 'separator' => $this->separator, - ); + ]; } function fillRowClasses (&$classes, ListingEntry $entry) @@ -233,7 +233,7 @@ class Action if ($type === NULL) { $types = $this->parent->objectTypes; } else { - $types = array($type); + $types = [$type]; } /* * if category is missing it’s deducted from type (all types are tested for menu actions) diff --git a/include/management/actions/class_HiddenAction.inc b/include/management/actions/class_HiddenAction.inc index 5b32d957be856e496387bb5bfdd56f69213fb241..08422db3783df35610a7851343c623905a8fe478 100644 --- a/include/management/actions/class_HiddenAction.inc +++ b/include/management/actions/class_HiddenAction.inc @@ -23,7 +23,7 @@ */ class HiddenAction extends Action { - function __construct (string $name, $callable, array $acl = array()) + function __construct (string $name, $callable, array $acl = []) { parent::__construct($name, '', '', '0', $callable, $acl, FALSE, FALSE); } diff --git a/include/management/actions/class_SubMenuAction.inc b/include/management/actions/class_SubMenuAction.inc index c43f2e26479dde0f217d29677d8521966683700e..9899b8517a15b6d391223ece9a89cd757a3dedfa 100644 --- a/include/management/actions/class_SubMenuAction.inc +++ b/include/management/actions/class_SubMenuAction.inc @@ -23,12 +23,12 @@ */ class SubMenuAction extends Action { - protected $actions = array(); - protected $handlers = array(); + protected $actions = []; + protected $handlers = []; function __construct (string $name, $label, $icon, array $actions, bool $inmenu = TRUE) { - parent::__construct($name, $label, $icon, '0', FALSE, array(), $inmenu, FALSE); + parent::__construct($name, $label, $icon, '0', FALSE, [], $inmenu, FALSE); $this->actions = $actions; foreach ($this->actions as $action) { $names = $action->listActions(); @@ -77,19 +77,19 @@ class SubMenuAction extends Action return; } - $subactions = array(); + $subactions = []; foreach ($this->actions as $action) { $action->fillMenuItems($subactions); } if (!empty($subactions)) { - $actions[] = array( + $actions[] = [ 'name' => $this->name, 'icon' => $this->icon, 'label' => $this->label, 'separator' => $this->separator, 'actions' => $subactions - ); + ]; } } diff --git a/include/management/class_DateFilterElement.inc b/include/management/class_DateFilterElement.inc index 16d6ae906ca57d52e1f65f84a996fe50b683842d..4f83da2129102e081bf6de6bfcb0d2eee6545e80 100644 --- a/include/management/class_DateFilterElement.inc +++ b/include/management/class_DateFilterElement.inc @@ -29,7 +29,7 @@ class DateFilterElement extends FilterElement protected $max; protected $types; - public function __construct (managementFilter $parent, $attribute, $label, $types = array()) + public function __construct (managementFilter $parent, $attribute, $label, $types = []) { global $config; diff --git a/include/management/class_ListingEntry.inc b/include/management/class_ListingEntry.inc index 2489e19a5a949c7d17576c1270e7dbbd4a87c84f..2a7348d05559a850a8d3d7b80d1c1b4808f6c75d 100644 --- a/include/management/class_ListingEntry.inc +++ b/include/management/class_ListingEntry.inc @@ -27,7 +27,7 @@ class ListingEntry implements ArrayAccess protected $listing; /* Cache where columns may store stuff */ - public $cache = array(); + public $cache = []; public function __construct (managementListing $listing, $type, $dn, array $attrs, $row = NULL) { diff --git a/include/management/class_ManagementConfigurationDialog.inc b/include/management/class_ManagementConfigurationDialog.inc index 88d6277979294b36c00ae69adad1c9c7bd4bb07c..4bca1f3f453240d9079e34e2171912ec250871f4 100644 --- a/include/management/class_ManagementConfigurationDialog.inc +++ b/include/management/class_ManagementConfigurationDialog.inc @@ -33,9 +33,9 @@ class ManagementConfigurationDialog extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => 'ManagementConfigurationDialog', - ); + ]; } static function getAttributesInfo (): array @@ -43,7 +43,7 @@ class ManagementConfigurationDialog extends simplePlugin global $class_mapping; // Load column types - $types = array(); + $types = []; foreach (array_keys($class_mapping) as $class) { if (preg_match('/Column$/', $class) && is_a($class, 'Column', TRUE)) { $types[] = $class; @@ -51,17 +51,17 @@ class ManagementConfigurationDialog extends simplePlugin } sort($types); - return array( - 'main' => array( - 'class' => array('fullwidth'), + return [ + 'main' => [ + 'class' => ['fullwidth'], 'name' => _('Management configuration'), - 'attrs' => array( + 'attrs' => [ new OrderedArrayAttribute( new ManagementColumnAttribute( _('Columns'), _('Columns displayed for this management list'), 'managementColumns', - array( + [ new SelectAttribute( _('Type'), _('Type of column'), 'columnType', TRUE, @@ -75,11 +75,11 @@ class ManagementConfigurationDialog extends simplePlugin _('Label'), _('Column title'), 'columnLabel', FALSE ), - ), + ], 'ManagementConfiguration' ), TRUE, // ordered - array(), + [], TRUE // edition ), new BooleanAttribute( @@ -88,9 +88,9 @@ class ManagementConfigurationDialog extends simplePlugin FALSE, 'fdManagementConfig' ), - ) - ), - ); + ] + ], + ]; } function __construct ($parent) @@ -104,7 +104,7 @@ class ManagementConfigurationDialog extends simplePlugin $this->attributesAccess['managementColumns']->setInLdap(FALSE); $this->attributesAccess['managementColumns']->setLinearRendering(FALSE); $columnInfos = $this->parent->getColumnConfiguration(); - $value = array(); + $value = []; foreach ($columnInfos as $column) { if (!isset($column[1]['attributes'])) { $column[1]['attributes'] = ''; @@ -114,7 +114,7 @@ class ManagementConfigurationDialog extends simplePlugin if (!isset($column[1]['label'])) { $column[1]['label'] = ''; } - $value[] = array($column[0], $column[1]['attributes'], $column[1]['label']); + $value[] = [$column[0], $column[1]['attributes'], $column[1]['label']]; } $this->attributesAccess['managementColumns']->setValue($value); } @@ -153,10 +153,10 @@ class ManagementConfigurationDialog extends simplePlugin function save (): array { global $config; - $columnInfos = array(); + $columnInfos = []; $values = $this->managementColumns; foreach ($values as $value) { - $column = array($value[0], array()); + $column = [$value[0], []]; if (!empty($value[1])) { $jsonDecoded = json_decode($value[1], TRUE); if ($jsonDecoded !== NULL) { diff --git a/include/management/class_TabFilterElement.inc b/include/management/class_TabFilterElement.inc index de6ca943328c3bc69663c9ead9d456c9088703c9..9352293ae90c85abae64f5e9503eb015c9c3e471 100644 --- a/include/management/class_TabFilterElement.inc +++ b/include/management/class_TabFilterElement.inc @@ -29,7 +29,7 @@ class TabFilterElement extends FilterElement parent::__construct($parent); - $this->tabs = array(); + $this->tabs = []; foreach ($this->parent->parent->objectTypes as $type) { $infos = objects::infos($type); foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) { @@ -43,11 +43,11 @@ class TabFilterElement extends FilterElement if (class_available($class)) { $classInfos = pluglist::pluginInfos($class); if (isset($classInfos['plFilterObject'])) { - $this->tabs[$class] = array( + $this->tabs[$class] = [ 'filter' => $classInfos['plFilterObject'], 'infos' => $classInfos, 'checked' => FALSE, - ); + ]; } } } @@ -67,14 +67,14 @@ class TabFilterElement extends FilterElement if (empty($this->tabs)) { return ''; } - $inputs = array(); + $inputs = []; foreach ($this->tabs as $class => $tab) { - $inputs['filter_tab_'.$class] = array( + $inputs['filter_tab_'.$class] = [ 'name' => $tab['infos']['plShortName'], 'desc' => $tab['infos']['plShortName'].' '.$tab['filter'], 'icon' => (isset($tab['infos']['plSmallIcon']) ? $tab['infos']['plSmallIcon'] : NULL), 'checked' => $tab['checked'], - ); + ]; } $smarty = get_smarty(); $smarty->assign('NAME', _('Tabs')); diff --git a/include/management/class_management.inc b/include/management/class_management.inc index 06890192d2d92d0636ce064b42c40b7a69612d5e..82a0cab8a4b70ed87c8b58a513caa9cdde050dfa 100644 --- a/include/management/class_management.inc +++ b/include/management/class_management.inc @@ -43,11 +43,11 @@ class management // The currently used object(s) (e.g. in edit, removal) protected $currentDn = ''; - protected $currentDns = array(); + protected $currentDns = []; // The last used object(s). protected $previousDn = ''; - protected $previousDns = array(); + protected $previousDns = []; // The opened object. protected $tabObject = NULL; @@ -61,22 +61,22 @@ class management public $title; public $icon; - protected $actions = array(); - protected $actionHandlers = array(); + protected $actions = []; + protected $actionHandlers = []; - protected $exporters = array(); + protected $exporters = []; - public $neededAttrs = array(); + public $neededAttrs = []; public static $skipTemplates = TRUE; /* Default columns */ - public static $columns = array( - array('ObjectTypeColumn', array()), - array('LinkColumn', array('attributes' => 'nameAttr', 'label' => 'Name')), - array('LinkColumn', array('attributes' => 'description', 'label' => 'Description')), - array('ActionsColumn', array('label' => 'Actions')), - ); + public static $columns = [ + ['ObjectTypeColumn', []], + ['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']], + ['LinkColumn', ['attributes' => 'description', 'label' => 'Description']], + ['ActionsColumn', ['label' => 'Actions']], + ]; // Whether to display a header or not. protected $skipHeader = FALSE; @@ -121,7 +121,7 @@ class management // 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->exporters = array_merge($this->exporters, $info); } @@ -155,11 +155,11 @@ class management global $config; // Register default actions - $createMenu = array(); + $createMenu = []; if (!static::$skipTemplates) { - $templateMenu = array(); - $fromTemplateMenu = array(); + $templateMenu = []; + $fromTemplateMenu = []; } foreach ($this->objectTypes as $type) { @@ -171,18 +171,18 @@ class management $createMenu[] = new Action( 'new_'.$type, $infos['name'], $img, '0', 'newEntry', - array($infos['aclCategory'].'/'.$infos['mainTab'].'/c') + [$infos['aclCategory'].'/'.$infos['mainTab'].'/c'] ); if (!static::$skipTemplates) { $templateMenu[] = new Action( 'new_template_'.$type, $infos['name'], $img, '0', 'newEntryTemplate', - array($infos['aclCategory'].'/template/c') + [$infos['aclCategory'].'/template/c'] ); $fromTemplateMenu[] = new Action( 'template_apply_'.$type, $infos['name'], $img, '0', 'newEntryFromTemplate', - array($infos['aclCategory'].'/template/r', $infos['aclCategory'].'/'.$infos['mainTab'].'/c') + [$infos['aclCategory'].'/template/r', $infos['aclCategory'].'/'.$infos['mainTab'].'/c'] ); } } @@ -190,7 +190,7 @@ class management if (!static::$skipTemplates) { $createMenu = array_merge( - array( + [ new SubMenuAction( 'template', _('Template'), 'geticon.php?context=devices&icon=template&size=16', $templateMenu @@ -199,7 +199,7 @@ class management 'fromtemplate', _('From template'), 'geticon.php?context=actions&icon=document-new&size=16', $fromTemplateMenu ), - ), + ], $createMenu ); } @@ -212,7 +212,7 @@ class management ); // Add export actions - $exportMenu = array(); + $exportMenu = []; foreach ($this->exporters as $action => $exporter) { $exportMenu[] = new Action( $action, $exporter['label'], $exporter['image'], @@ -239,24 +239,24 @@ class management new Action( 'cut', _('Cut'), 'geticon.php?context=actions&icon=edit-cut&size=16', '+', 'copyPasteHandler', - array('dr') + ['dr'] ) ); $this->registerAction( new Action( 'copy', _('Copy'), 'geticon.php?context=actions&icon=edit-copy&size=16', '+', 'copyPasteHandler', - array('r') + ['r'] ) ); $this->registerAction( new Action( 'paste', _('Paste'), 'geticon.php?context=actions&icon=edit-paste&size=16', '0', 'copyPasteHandler', - array('w') + ['w'] ) ); - $this->actions['paste']->setEnableFunction(array($this, 'enablePaste')); + $this->actions['paste']->setEnableFunction([$this, 'enablePaste']); } if (!static::$skipTemplates) { @@ -264,7 +264,7 @@ class management new Action( 'template_apply_to', _('Apply template'), 'geticon.php?context=actions&icon=tools-wizard&size=16', '+', 'applyTemplateToEntry', - array('/template/r', 'c'), + ['/template/r', 'c'], TRUE, FALSE ) @@ -275,7 +275,7 @@ class management new Action( 'remove', _('Remove'), 'geticon.php?context=actions&icon=edit-delete&size=16', '+', 'removeRequested', - array('d') + ['d'] ) ); @@ -284,18 +284,18 @@ class management new Action( 'snapshot', _('Create snapshot'), 'geticon.php?context=actions&icon=snapshot&size=16', '1', 'createSnapshotDialog', - array('/snapshot/c') + ['/snapshot/c'] ) ); $this->registerAction( new Action( 'restore', _('Restore snapshot'), 'geticon.php?context=actions&icon=document-restore&size=16', '*', 'restoreSnapshotDialog', - array('w', '/snapshot/r') + ['w', '/snapshot/r'] ) ); $this->actions['snapshot']->setSeparator(TRUE); - $this->actions['restore']->setEnableFunction(array($this, 'enableSnapshotRestore')); + $this->actions['restore']->setEnableFunction([$this, 'enableSnapshotRestore']); } if (!static::$skipTemplates) { @@ -303,10 +303,10 @@ class management new Action( 'template_apply', _('Create an object from this template'), 'geticon.php?context=actions&icon=document-new&size=16', '1', 'newEntryFromTemplate', - array('/template/r', 'c'), + ['/template/r', 'c'], FALSE, TRUE, - array('template') + ['template'] ) ); } @@ -365,7 +365,7 @@ class management if (!is_object($this->listing)) { throw new FusionDirectoryException('No valid listing object'); } - $action = array('targets' => array(), 'action' => '', 'subaction' => NULL); + $action = ['targets' => [], 'action' => '', 'subaction' => NULL]; if ($this->is_modal_dialog()) { if (isset($_POST['edit_cancel'])) { $action['action'] = 'cancel'; @@ -421,7 +421,7 @@ class management function execute (): string { // 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 */ @@ -505,7 +505,7 @@ class management protected function renderActionMenu (): string { - $menuActions = array(); + $menuActions = []; foreach ($this->actions as $action) { // Build ul/li list $action->fillMenuItems($menuActions); @@ -587,7 +587,7 @@ class management $this->previousDn = $this->currentDn; $this->currentDn = ''; $this->previousDns = $this->currentDns; - $this->currentDns = array(); + $this->currentDns = []; $this->last_tabObject = $this->tabObject; $this->tabObject = NULL; @@ -599,7 +599,7 @@ class management protected function listAclCategories (): array { - $cat = array(); + $cat = []; foreach ($this->objectTypes as $type) { $infos = objects::infos($type); $cat[] = $infos['aclCategory']; @@ -634,7 +634,7 @@ class management return; } if ($cancel) { - $msgs = array(); + $msgs = []; } else { $msgs = $this->tabObject->save(); } @@ -746,13 +746,13 @@ class management $entry = $this->listing->getEntry($dn); if ($entry === NULL) { trigger_error('Could not find '.$dn.', action canceled'); - $this->currentDns = array(); + $this->currentDns = []; return; } if ($entry->isTemplate()) { msg_dialog::display(_('Error'), _('Applying a template to a template is not possible'), ERROR_DIALOG); - $this->currentDns = array(); + $this->currentDns = []; return; } @@ -760,7 +760,7 @@ class management $type = $entry->type; } elseif ($entry->type != $type) { msg_dialog::display(_('Error'), _('All selected entries need to share the same type to be able to apply a template to them'), ERROR_DIALOG); - $this->currentDns = array(); + $this->currentDns = []; return; } } @@ -879,7 +879,7 @@ class management @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDns, 'Modifications applied'); $this->tabObject->re_init(); /* Avoid applying the POST a second time */ - $_POST = array(); + $_POST = []; } } } @@ -890,8 +890,8 @@ class management function removeRequested (array $action) { global $ui; - $disallowed = array(); - $this->currentDns = array(); + $disallowed = []; + $this->currentDns = []; @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $action['targets'], 'Entry deletion requested'); @@ -922,19 +922,19 @@ class management // Add locks add_lock($this->currentDns, $ui->dn); - $objects = array(); + $objects = []; foreach ($this->currentDns as $dn) { $entry = $this->listing->getEntry($dn); $infos = objects::infos($entry->getTemplatedType()); if ($entry->isTemplate()) { $infos['nameAttr'] = 'cn'; } - $objects[] = array( + $objects[] = [ 'name' => $entry[$infos['nameAttr']], 'dn' => $dn, 'icon' => $infos['icon'], 'type' => $infos['name'] - ); + ]; } return $this->removeConfirmationDialog($objects); @@ -974,7 +974,7 @@ class management del_lock($this->currentDn); } else { msg_dialog::display(_('Permission error'), msgPool::permDelete($dn), ERROR_DIALOG); - logging::log('security', 'management/'.get_class($this), $dn, array(), 'Tried to trick deletion.'); + logging::log('security', 'management/'.get_class($this), $dn, [], 'Tried to trick deletion.'); } } @@ -991,7 +991,7 @@ class management /*! \brief This method is used to queue and process copy&paste actions. * Allows to copy, cut and paste mutliple entries at once. */ - function copyPasteHandler (array $action = array('action' => '')) + function copyPasteHandler (array $action = ['action' => '']) { global $ui; @@ -1111,7 +1111,7 @@ class management function getSnapshotBases (): array { - $bases = array(); + $bases = []; foreach ($this->objectTypes as $type) { $infos = objects::infos($type); $bases[] = $infos['ou'].$this->listing->getBase(); @@ -1131,7 +1131,7 @@ class management function getAllDeletedSnapshots (): array { $bases = $this->getSnapshotBases(); - $tmp = array(); + $tmp = []; foreach ($bases as $base) { $tmp = array_merge($tmp, $this->snapHandler->getAllDeletedSnapshots($base)); } diff --git a/include/management/class_managementFilter.inc b/include/management/class_managementFilter.inc index d18490da4cb16bd2a09f6d1e349effffec747cf6..d53bf6b49d584d41557cbe4e9224c5d2a7f26bc5 100644 --- a/include/management/class_managementFilter.inc +++ b/include/management/class_managementFilter.inc @@ -25,13 +25,13 @@ class managementFilter { protected $types; - protected $searchAttributes = array(); + protected $searchAttributes = []; protected $scope = 'one'; protected $showTemplates = FALSE; protected $search = ''; - protected $filterElements = array(); + protected $filterElements = []; /* The management class */ public $parent; @@ -56,16 +56,16 @@ class managementFilter $this->pid = preg_replace('/[^0-9]/', '', microtime(TRUE)); foreach ($this->parent->objectTypes as $type) { - $this->types['filter_type_'.$type] = array( + $this->types['filter_type_'.$type] = [ 'show' => TRUE, - 'filters' => array(), + 'filters' => [], 'infos' => objects::infos($type), - ); + ]; } - $this->filterElements = array( + $this->filterElements = [ new TabFilterElement($this), - ); + ]; } function setScope ($scope) @@ -103,7 +103,7 @@ class managementFilter foreach ($this->parent->objectTypes as $type) { $attrs = objects::getSearchedAttributes($type); - $this->searchAttributes[$type] = array(); + $this->searchAttributes[$type] = []; $this->parent->listing->fillSearchedAttributes($type, $attrs); foreach ($attrs as $attr => $acl) { $rights = $ui->get_permissions($base, $acl); @@ -127,7 +127,7 @@ class managementFilter $smarty->assign('SEARCH', $this->search); $smarty->assign('TYPES', $this->types); - $searchAttrs = array(); + $searchAttrs = []; foreach ($this->searchAttributes as $type => $attrs) { foreach ($attrs as $attr) { $searchAttrs[] = strtolower($type).'/'.$attr; @@ -139,7 +139,7 @@ class managementFilter if (!$parentClass::$skipTemplates) { $smarty->assign('TEMPLATES', $this->showTemplates); } - $elements = array(); + $elements = []; foreach ($this->filterElements as $element) { $elements[] = $element->render(); } @@ -156,8 +156,8 @@ class managementFilter { global $ui; - $objectTypeCount = array(); - $entries = array(); + $objectTypeCount = []; + $entries = []; $row = 0; $ui->getSizeLimitHandler()->setLimitExceeded(FALSE); foreach ($this->parent->objectTypes as $type) { @@ -186,7 +186,7 @@ class managementFilter } } - $elementFilters = array(); + $elementFilters = []; if (!empty($this->search)) { if (preg_match('/^\(.+\)$/', $this->search)) { $elementFilters[] = $this->search; @@ -230,6 +230,6 @@ class managementFilter } } - return array($entries, $objectTypeCount); + return [$entries, $objectTypeCount]; } } diff --git a/include/management/class_managementListing.inc b/include/management/class_managementListing.inc index ddbecec6fc46ca24bef5329a042cf24894823d61..a3716428e927c734474c880f1af4fb316505cbac 100644 --- a/include/management/class_managementListing.inc +++ b/include/management/class_managementListing.inc @@ -31,8 +31,8 @@ class managementListing { public $pid; - protected $entries = array(); - protected $entriesIndex = array(); + protected $entries = []; + protected $entriesIndex = []; protected $base; protected $sortDirection = NULL; @@ -40,9 +40,9 @@ class managementListing protected $baseMode = TRUE; protected $multiSelect = TRUE; - protected $bases = array(); - protected $header = array(); - protected $objectTypeCount = array(); + protected $bases = []; + protected $header = []; + protected $objectTypeCount = []; protected $baseSelector; /* The management class */ @@ -94,12 +94,12 @@ class managementListing { $columnInfos = $this->parent->getColumnConfiguration(); - $this->columns = array(); + $this->columns = []; foreach ($columnInfos as $columnInfo) { $this->columns[] = Column::build($this, $columnInfo[0], $columnInfo[1]); } - $this->columns[1]->setTemplateAttributes(array('cn')); + $this->columns[1]->setTemplateAttributes(['cn']); } function getColumns () @@ -109,13 +109,13 @@ class managementListing function renderHeader () { - $this->header = array(); + $this->header = []; // Initialize sort? $sortInit = FALSE; if (!$this->sortDirection) { $this->sortColumn = 0; - $this->sortDirection = array(); + $this->sortDirection = []; $sortInit = TRUE; } @@ -125,11 +125,11 @@ class managementListing $this->sortDirection[$index] = FALSE; } - $this->header[$index] = array( + $this->header[$index] = [ 'props' => $column->getHtmlProps(), 'sortable' => $column->isSortable(), 'label' => $column->getLabel(), - ); + ]; if (($index == $this->sortColumn) && $column->isSortable()) { $this->header[$index]['sortdirection'] = $this->sortDirection[$index]; } @@ -162,17 +162,17 @@ class managementListing // Complete list by sorting entries and appending them to the output $entryIterator = $this->getIterator(); - $rows = array(); + $rows = []; foreach ($entryIterator as $entry) { - $row = array( - 'cells' => array(), - 'classes' => array(), - ); + $row = [ + 'cells' => [], + 'classes' => [], + ]; foreach ($this->columns as $column) { - $row['cells'][] = array( + $row['cells'][] = [ 'props' => $column->getHtmlCellProps(), 'render' => $column->renderCell($entry) - ); + ]; $column->fillRowClasses($row['classes'], $entry); } @@ -184,23 +184,23 @@ class managementListing // Add the footer if requested if ($this->showFooter) { - $types = array(); + $types = []; foreach ($this->parent->objectTypes as $type) { if (isset($this->objectTypeCount[$type])) { $infos = objects::infos($type); - $types[] = array( + $types[] = [ 'name' => $infos['name'], 'icon' => $infos['icon'], 'count' => $this->objectTypeCount[$type], - ); + ]; } if (isset($this->objectTypeCount['template_'.$type])) { $infos = objects::infos($type); - $types[] = array( + $types[] = [ 'name' => sprintf(_('%s template'), $infos['name']), 'icon' => 'geticon.php?context=devices&icon=template&size=16', 'count' => $this->objectTypeCount['template_'.$type], - ); + ]; } } $smarty->assign('objectCounts', $types); @@ -369,51 +369,51 @@ class managementListing } if ($this->baseMode) { - $actions = array( - array( + $actions = [ + [ 'id' => 'ROOT', 'desc' => _('Go to root department'), 'name' => _('Root'), 'icon' => 'geticon.php?context=actions&icon=go-first&size=16', 'enabled' => $enableRoot, 'class' => '', - ), - array( + ], + [ 'id' => 'BACK', 'desc' => _('Go up one department'), 'name' => _('Up'), 'icon' => 'geticon.php?context=actions&icon=go-up&size=16', 'enabled' => $enableBack, 'class' => '', - ), - array( + ], + [ 'id' => 'HOME', 'desc' => _('Go to user\'s department'), 'name' => _('Home'), 'icon' => 'geticon.php?context=actions&icon=go-home&size=16', 'enabled' => $enableHome, 'class' => '', - ), - ); + ], + ]; } else { - $actions = array(); + $actions = []; } - $actions[] = array( + $actions[] = [ 'id' => 'REFRESH', 'desc' => _('Reload list'), 'name' => _('Reload'), 'icon' => 'geticon.php?context=actions&icon=view-refresh&size=16', 'enabled' => TRUE, 'class' => 'optional', - ); - $actions[] = array( + ]; + $actions[] = [ 'id' => 'listing_configure', 'desc' => _('Configure this management list'), 'name' => _('Configure'), 'icon' => 'geticon.php?context=categories&icon=settings&size=16', 'enabled' => TRUE, 'class' => '', - ); + ]; return $actions; } @@ -425,7 +425,7 @@ class managementListing { global $config; - $result = array('targets' => array(), 'action' => '', 'subaction' => NULL); + $result = ['targets' => [], 'action' => '', 'subaction' => NULL]; // Do not do anything if this is not our PID, or there's even no PID available... if (!isset($_REQUEST['dn']) && (!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid)) { @@ -487,7 +487,7 @@ class managementListing $target = preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key); if (isset($this->entriesIndex[$target])) { $result['action'] = preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key); - $result['targets'] = array($this->entriesIndex[$target]); + $result['targets'] = [$this->entriesIndex[$target]]; } break; } @@ -520,9 +520,9 @@ class managementListing $ui = get_userinfo(); // Fill internal bases list - $this->bases = array(); + $this->bases = []; - $categories = array(); + $categories = []; foreach ($this->parent->objectTypes as $otype) { $i = objects::infos($otype); $categories[$i['aclCategory']] = $i['aclCategory']; @@ -569,7 +569,7 @@ class managementListing { global $ui; - $searchedAttributes = array(); + $searchedAttributes = []; foreach ($this->columns as $column) { $column->fillSearchedAttributes($searchedAttributes); } diff --git a/include/management/class_selectManagement.inc b/include/management/class_selectManagement.inc index caf831720e38f436c0629a40ecb8c1e6a365fdba..ce520cc0c4fd263d9f202788cb5e52940c77ee83 100644 --- a/include/management/class_selectManagement.inc +++ b/include/management/class_selectManagement.inc @@ -31,13 +31,13 @@ class selectManagement extends management protected $multiSelect = TRUE; /* Default columns */ - public static $columns = array( - array('ObjectTypeColumn', array()), - array('LinkColumn', array('attributes' => 'nameAttr', 'label' => 'Name')), - array('LinkColumn', array('attributes' => 'description', 'label' => 'Description')), - ); + public static $columns = [ + ['ObjectTypeColumn', []], + ['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']], + ['LinkColumn', ['attributes' => 'description', 'label' => 'Description']], + ]; - function __construct ($objectTypes = FALSE, $multiSelect = TRUE, $neededAttrs = array()) + function __construct ($objectTypes = FALSE, $multiSelect = TRUE, $neededAttrs = []) { $this->neededAttrs = $neededAttrs; $this->multiSelect = $multiSelect; diff --git a/include/management/columns/class_Column.inc b/include/management/columns/class_Column.inc index 5c8eea98ab12690e6ca41098676ce52b46a86c65..77f29ec81f20911bef9cb66b0605ed6348d96883 100644 --- a/include/management/columns/class_Column.inc +++ b/include/management/columns/class_Column.inc @@ -70,7 +70,7 @@ class Column protected function setAttributesVar (string $var, array $attributes = NULL) { if (is_array($attributes) && is_numeric(key($attributes))) { - $val = array(); + $val = []; foreach ($attributes as $attribute) { if ($attribute == 'dn') { $val[$attribute] = 'raw'; diff --git a/include/management/columns/class_PropertiesColumn.inc b/include/management/columns/class_PropertiesColumn.inc index f121560c5a1cc0f3e79b18236e9f2119d49d9fd3..e35be15785c6720abae07e3521013ec2336cf931 100644 --- a/include/management/columns/class_PropertiesColumn.inc +++ b/include/management/columns/class_PropertiesColumn.inc @@ -31,11 +31,11 @@ class PropertiesColumn extends Column parent::__construct($parent, NULL, $label); - $this->tabs = array(); + $this->tabs = []; foreach ($this->parent->parent->objectTypes as $type) { $infos = objects::infos($type); - $this->tabs[$type] = array(); + $this->tabs[$type] = []; foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) { if ($plug['CLASS'] == $infos['mainTab']) { continue; @@ -111,15 +111,15 @@ class PropertiesColumn extends Column } $infos = objects::infos($entry->getTemplatedType()); - $icons = array(); + $icons = []; /* Main tab is always there */ $pInfos = pluglist::pluginInfos($infos['mainTab']); - $icons[] = array( + $icons[] = [ 'icon' => (isset($pInfos['plSmallIcon']) ? $pInfos['plSmallIcon'] : $infos['icon']), 'title' => $pInfos['plShortName'], 'tab' => $infos['mainTab'], - ); + ]; if (!empty($entry)) { if ($entry->isTemplate()) { $attrs = $entry->getTemplatedFields(); @@ -131,18 +131,18 @@ class PropertiesColumn extends Column if ($status !== FALSE) { $pInfos = pluglist::pluginInfos($class); if (isset($pInfos['plSmallIcon'])) { - $icons[] = array( + $icons[] = [ 'icon' => $pInfos['plSmallIcon'], 'title' => $pInfos['plShortName'], 'tab' => $class, - ); + ]; } else { @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $pInfos['plShortName']." ($class)", 'No icon for'); } } else { - $icons[] = array( + $icons[] = [ 'tab' => $class, - ); + ]; } } } diff --git a/include/password-methods/class_password-methods-crypt.inc b/include/password-methods/class_password-methods-crypt.inc index 12ba6f6bd0293b946b57d08810d3b9f083abe958..39456bac6fe6a1b7fa90938ae0fd97d9976eefc9 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 dcae829c1d76ad51053176c3866ef3c92efd437c..7069578b91061991a100d7332c927d3a1f0ec236 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 e7b0917c0babce611f6ed918cf171f8d57b22917..f2aa2bd6e534b1cc784366434465d28160e7ad68 100644 --- a/include/password-methods/class_password-methods.inc +++ b/include/password-methods/class_password-methods.inc @@ -163,7 +163,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; @@ -192,7 +192,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); } @@ -220,7 +220,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 f8c0dbd288b009228cdb9104c2632f9871c05220..4256e1551976f4468550716435b751b95a56eeff 100644 --- a/include/php_setup.inc +++ b/include/php_setup.inc @@ -28,15 +28,15 @@ require_once("variables.inc"); 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); @@ -92,7 +92,7 @@ function html_trace ($errstr = "") if (isset($hideArgs[$func])) { $hideArgsIndexes = $hideArgs[$func]; } else { - $hideArgsIndexes = array(); + $hideArgsIndexes = []; } $f = function ($index, $arg) use (&$f, $hideArgsIndexes) { @@ -150,7 +150,7 @@ function html_trace ($errstr = "") $return_html .= "</table>"; $return_mailto .= rawurlencode("=== /Trace ==="); - return array($return_html, $return_mailto); + return [$return_html, $return_mailto]; } /*! @@ -194,7 +194,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); @@ -203,7 +203,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 */ @@ -345,8 +345,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 e2dbb0b180c828707461fc2e39d0cdd6e99cdff2..d2e719d66d5b78999673291ab9384762590f5d5e 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 fa94786eb7c5a06507240c70c079224c26d5efe6..1f8eac55ac1bbe0a9b93f7f8a9ae28fff96623f2 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/systemSelect/class_systemSelect.inc b/include/select/systemSelect/class_systemSelect.inc index c8d1a7faa8db0f28a1ec5bce4c7f04bad6af8116..9c95ec6987dcddac2169c891681509ef76708f19 100644 --- a/include/select/systemSelect/class_systemSelect.inc +++ b/include/select/systemSelect/class_systemSelect.inc @@ -23,8 +23,8 @@ */ 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/simpleplugin/attributes/class_BaseSelectorAttribute.inc b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc index ea27f0e5e9088f6dbdac91e3130f134adf3a5d8e..8926f320cbee2273c08ad902171746a9c6174e0e 100644 --- a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc +++ b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc @@ -154,9 +154,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 f355a9d9bc4980ba859c6f2f783683b24c73b7bb..9a63436d13962e4c5b8c4841be47930f574c712f 100644 --- a/include/simpleplugin/attributes/class_BooleanAttribute.inc +++ b/include/simpleplugin/attributes/class_BooleanAttribute.inc @@ -102,7 +102,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'); @@ -183,7 +183,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 5a0a8df3f2ec2c610b7161e54832d0d6617621b9..2eb940d811acccbd3f14cf5e795ba80eaa520b5c 100644 --- a/include/simpleplugin/attributes/class_CompositeAttribute.inc +++ b/include/simpleplugin/attributes/class_CompositeAttribute.inc @@ -104,7 +104,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]; @@ -258,7 +258,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); @@ -284,7 +284,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 bee7bfe0a28e217695f6b236fda89840facf09cc..bb84e807531d1ff5679e3a5c4aecaa0577e18426 100644 --- a/include/simpleplugin/attributes/class_DateAttribute.inc +++ b/include/simpleplugin/attributes/class_DateAttribute.inc @@ -145,10 +145,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"> @@ -205,7 +205,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, @@ -221,7 +221,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); } @@ -279,7 +279,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, @@ -290,7 +290,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); } @@ -303,7 +303,7 @@ class DateTimeAttribute extends CompositeAttribute { function __construct ($label, $description, $ldapName, $required, $acl = '') { - $attributes = array( + $attributes = [ new DateAttribute( _('Date'), '', $ldapName.'_date', $required, @@ -315,7 +315,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 9118adf6fd72905b0e25bf4b2107bb28195e11f4..ebc26a4d53be0eadfaaf0b4958426b4c071a6017 100644 --- a/include/simpleplugin/attributes/class_FileAttribute.inc +++ b/include/simpleplugin/attributes/class_FileAttribute.inc @@ -172,17 +172,17 @@ class FileDownloadAttribute extends FileAttribute $display = ''; if ($this->upload) { $display .= $this->renderInputField('file', $id); - $display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload'), 'formnovalidate' => 'formnovalidate')); + $display .= $this->renderInputField('submit', 'upload'.$id, ['value' => _('Upload'), 'formnovalidate' => 'formnovalidate']); } 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); @@ -191,7 +191,7 @@ class FileDownloadAttribute extends FileAttribute public function htmlIds () { $id = $this->getHtmlId(); - $ids = array(); + $ids = []; if ($this->download) { $ids[] = 'download'.$id; } @@ -260,7 +260,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 () @@ -388,22 +388,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 != '')) { @@ -418,7 +418,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 @@ -434,7 +434,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 4ee6404f2bbe1ac649663f86b27e12e8cd34e0ba..07cd4edaf3240135625a764fffa7b335884834df 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; } @@ -120,9 +120,9 @@ class IntAttribute extends Attribute function renderTemplateInput () { $id = $this->getHtmlId(); - $attributes = array( + $attributes = [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ); + ]; if ($this->isSubAttribute) { $attributes['class'] = 'subattribute'; } diff --git a/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc b/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc index 0445b13b66b6f76e25b96dbd28e0235dafabb240..fbed0db497587c097b248333d6aef247a816e9d9 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']; } /*! @@ -143,12 +143,12 @@ class PhoneNumberButtonAttribute extends PhoneNumberAttribute if ($this->type !== FALSE) { $display .= $this->renderAcl($this->renderInputField( 'image', $id.'_edit', - array( + [ 'class' => 'center dialog', '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 b60d2ebebe61087c1be654bd626e8194ea0defe4..1a78d7075ce89e0f8d3ad1300d5825d9f9e3a646 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 (array $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 3459b2c8915e310c66e8d775f45c141e8e82abec..52fa9661e03f2bf41b7cab5b6b0f7c9b633a4cf2 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(), @@ -67,7 +67,7 @@ class SetAttribute extends Attribute protected function loadAttrValue (array $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]; } @@ -237,24 +237,24 @@ 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()), 'subattribute' => $this->isSubAttribute, 'required' => $this->isRequired(), - ); + ]; $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()), 'subattribute' => TRUE, 'required' => FALSE, - ); + ]; } } } @@ -268,7 +268,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; @@ -289,8 +289,8 @@ class SetAttribute extends Attribute function renderButtons () { $id = $this->getHtmlId(); - $buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate')); - $buttons .= $this->renderInputField('submit', 'del'.$id, array('value' => '{msgPool type=delButton}', 'formnovalidate' => 'formnovalidate')); + $buttons = $this->renderInputField('submit', 'add'.$id, ['value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate']); + $buttons .= $this->renderInputField('submit', 'del'.$id, ['value' => '{msgPool type=delButton}', 'formnovalidate' => 'formnovalidate']); return $buttons; } @@ -302,7 +302,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 @@ -319,10 +319,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; } @@ -389,7 +389,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; @@ -421,7 +421,7 @@ class OrderedArrayAttribute extends SetAttribute function computeLdapValue () { - $ldapValue = array(); + $ldapValue = []; foreach ($this->value as $key => $value) { $ldapValue[] = $this->writeValue($key, $value); } @@ -431,7 +431,7 @@ class OrderedArrayAttribute extends SetAttribute protected function loadAttrValue (array $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)) { @@ -461,12 +461,12 @@ class OrderedArrayAttribute extends SetAttribute $div->setHeight($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)) { @@ -475,7 +475,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()); @@ -494,12 +494,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;"/>'; @@ -507,12 +507,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;"/>'; @@ -522,25 +522,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) @@ -645,7 +645,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()); } @@ -667,7 +667,7 @@ class OrderedArrayAttribute extends SetAttribute function renderButtons () { $id = $this->getHtmlId(); - $buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate')); + $buttons = $this->renderInputField('submit', 'add'.$id, ['value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate']); return $buttons; } } @@ -680,9 +680,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.'_'; @@ -699,7 +699,7 @@ class SubNodesAttribute extends OrderedArrayAttribute $this->objectClasses = $objectClass; } else { $this->objectClass = $objectClass; - $this->objectClasses = array($objectClass); + $this->objectClasses = [$objectClass]; } } @@ -710,8 +710,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) { @@ -733,8 +733,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']; } @@ -743,7 +743,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 bb8570447695678ec9efcd5ad64431a4c2487e4f..d58718ca254fec74191c18130ac9a51673b6b37d 100644 --- a/include/simpleplugin/attributes/class_StringAttribute.inc +++ b/include/simpleplugin/attributes/class_StringAttribute.inc @@ -69,9 +69,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'); @@ -94,9 +94,9 @@ class StringAttribute extends Attribute function renderTemplateInput () { $id = $this->getHtmlId(); - $attributes = array( + $attributes = [ 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}' - ); + ]; if ($this->autocomplete !== NULL) { $attributes['autocomplete'] = ($this->autocomplete ? 'on' : 'off'); } @@ -110,7 +110,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 () diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc index 6b2318fa6128c971c4720d17428206698722a991..de04bb06ec9a0b628f38ebffc782e6cfaa345bbe 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 = []; /* \bried If this is TRUE it means this attribute is not directly submitted with the form * but is part of a multivalue attribute. @@ -213,7 +213,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 () @@ -364,7 +364,7 @@ class Attribute $this->managedAttributesMultipleValues = $mAttributes['multiplevalues']; unset($mAttributes['multiplevalues']); } else { - $this->managedAttributesMultipleValues = array(); + $this->managedAttributesMultipleValues = []; } $this->managedAttributes = $mAttributes; $this->manageAttributes($this->getValue()); @@ -432,7 +432,7 @@ class Attribute if ($ldapValue !== '') { $attrs[$this->getLdapName()] = $ldapValue; } else { - $attrs[$this->getLdapName()] = array(); + $attrs[$this->getLdapName()] = []; } } } @@ -452,7 +452,7 @@ class Attribute continue; } foreach ($attributes as $attribute) { - $attrs[$attribute] = array(); + $attrs[$attribute] = []; } } } @@ -464,11 +464,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(); @@ -504,19 +504,19 @@ class Attribute array_keys($infos['plObjectType']), array_values($infos['plObjectType']) ); - $filters = array(); + $filters = []; if (!empty($objectTypeFilters)) { $filters[] = '(|'.implode($objectTypeFilters).')'; } - $pluginFilter = call_user_func(array(get_class($this->plugin), 'getLdapFilter')); + $pluginFilter = call_user_func([get_class($this->plugin), 'getLdapFilter']); if (!empty($pluginFilter)) { $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) @@ -604,14 +604,14 @@ 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, 'subattribute' => $this->isSubAttribute, 'required' => $this->isRequired(), - ); + ]; } } @@ -630,7 +630,7 @@ class Attribute } /* Avoid empty array */ $type[] = 'Attribute'; - $infos = array( + $infos = [ 'htmlid' => $this->getHtmlId(), 'label' => $this->getLabel(), 'required' => $this->isRequired(), @@ -639,7 +639,7 @@ class Attribute 'value' => $this->serializeValue(), 'default' => $this->serializeValue($this->defaultValue), 'type' => $type, - ); + ]; if (!$form) { $infos['inldap'] = $this->isInLdap(); $infos['visible'] = $this->visible; @@ -687,10 +687,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; @@ -710,7 +710,7 @@ class Attribute public function htmlIds () { - return array($this->getHtmlId()); + return [$this->getHtmlId()]; } protected function managedAttributesJS () @@ -759,7 +759,7 @@ class Attribute return ($this->getValue() == $value); } - protected function renderInputField ($type, $name, array $attributes = array()) + protected function renderInputField ($type, $name, array $attributes = []) { $input = '<input type="'.$type.'" '. 'name="'.$name.'" id="'.$name.'"'. @@ -804,7 +804,7 @@ class HiddenArrayAttribute extends HiddenAttribute protected function loadAttrValue (array $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]; } @@ -884,7 +884,7 @@ class DisplayLDAPArrayAttribute extends Attribute protected function loadAttrValue (array $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 789b0e8161d62835dff5062f48f84093926e4a13..32d609ad7b579f361a132a2942c0f1a795b79ac5 100644 --- a/include/simpleplugin/class_dialogAttributes.inc +++ b/include/simpleplugin/class_dialogAttributes.inc @@ -133,7 +133,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; @@ -174,7 +174,7 @@ class DialogAttribute extends SetAttribute function getFilterWhiteList () { - return array(); + return []; } function loadPostValue () @@ -202,31 +202,31 @@ 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}', 'formnovalidate' => 'formnovalidate' - ) + ] ); $dialogButtonValue = _('Add (dialog)'); } $buttons .= $this->renderInputField( 'submit', 'add'.$id.'_dialog', - array( + [ 'class' => 'dialog', 'value' => $dialogButtonValue, 'formnovalidate' => 'formnovalidate' - ) + ] ); $buttons .= $this->renderInputField( 'submit', 'del'.$id, - array( + [ 'value' => '{msgPool type=delButton}', 'formnovalidate' => 'formnovalidate' - ) + ] ); return $buttons; } @@ -234,7 +234,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; @@ -250,7 +250,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; @@ -264,7 +264,7 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute function getFilterWhiteList () { - return array(); + return []; } function loadPostValue () @@ -300,11 +300,11 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute $id = $this->getHtmlId(); return $this->renderInputField( 'submit', 'add'.$id.'_dialog', - array( + [ 'class' => 'dialog', 'value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate' - ) + ] ); } @@ -327,11 +327,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; @@ -340,7 +340,7 @@ class GenericDialogAttribute extends DialogAttribute function getFilterBlackList () { - return array($this->store_attr => $this->getValue()); + return [$this->store_attr => $this->getValue()]; } function addValue ($dn, $attrs) @@ -410,7 +410,7 @@ class GenericDialogAttribute extends DialogAttribute protected function ldapAttributesToGet () { - return array($this->display_attr); + return [$this->display_attr]; } protected function fillDisplayValueFrom ($i, $attrs) @@ -506,18 +506,18 @@ class ObjectsAttribute extends GenericDialogAttribute public $selectManagementParameters; - function __construct ($label, $description, $ldapName, $required, array $objectTypes, $defaultValue = array(), $store_attr = 'dn', $display_attr = 'cn', $acl = '') + function __construct ($label, $description, $ldapName, $required, array $objectTypes, $defaultValue = [], $store_attr = 'dn', $display_attr = 'cn', $acl = '') { parent::__construct($label, $description, $ldapName, $required, $defaultValue, $store_attr, $display_attr, $acl); - $this->selectManagementParameters = array( + $this->selectManagementParameters = [ $objectTypes, TRUE, - array( + [ 'objectClass' => '*', $store_attr => (($store_attr == 'dn') ? 'raw' : 1), $display_attr => (($display_attr == 'dn') ? 'raw' : 1), - ) - ); + ] + ]; } } @@ -529,9 +529,9 @@ class ObjectsAttribute extends GenericDialogAttribute */ class UsersAttribute extends ObjectsAttribute { - 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 = '') { - parent::__construct($label, $description, $ldapName, $required, array('user'), $defaultValue, $store_attr, $display_attr, $acl); + parent::__construct($label, $description, $ldapName, $required, ['user'], $defaultValue, $store_attr, $display_attr, $acl); } } @@ -542,9 +542,9 @@ class UsersAttribute extends ObjectsAttribute */ class UsersGroupsRolesAttribute extends ObjectsAttribute { - 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 = '') { - parent::__construct($label, $description, $ldapName, $required, array('user', 'group', 'role', 'ogroup'), $defaultValue, $store_attr, $display_attr, $acl); + parent::__construct($label, $description, $ldapName, $required, ['user', 'group', 'role', 'ogroup'], $defaultValue, $store_attr, $display_attr, $acl); $this->selectManagementParameters[2]['cn'] = 1; $this->selectManagementParameters[2]['uid'] = 1; $this->selectManagementParameters[2]['objectClass'] = '*'; @@ -552,7 +552,7 @@ class UsersGroupsRolesAttribute extends ObjectsAttribute protected function ldapAttributesToGet () { - return array_unique(array($store_attr, $display_attr, 'cn', 'uid', 'objectClass')); + return array_unique([$store_attr, $display_attr, 'cn', 'uid', 'objectClass']); } protected function fillDisplayValueFrom ($i, $attrs) @@ -602,7 +602,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); } @@ -639,14 +639,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) @@ -662,18 +662,18 @@ 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( + [ 'class' => 'dialog', 'value' => '{msgPool type=addButton} (from list)' - ) + ] ); $buttons .= $this->renderInputField( 'submit', 'del'.$id, - array('value' => '{msgPool type=delButton}') + ['value' => '{msgPool type=delButton}'] ); return $buttons; } @@ -681,7 +681,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]; } } @@ -702,7 +702,7 @@ class SystemsAttribute extends DialogAttribute function getFilterBlackList () { - return array('cn' => $this->getValue()); + return ['cn' => $this->getValue()]; } } @@ -729,7 +729,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); } @@ -773,12 +773,12 @@ class DialogButtonAttribute extends ButtonAttribute function getFilterBlackList () { - return array(); + return []; } function getFilterWhiteList () { - return array(); + return []; } } @@ -796,7 +796,7 @@ class ObjectAttribute extends DialogButtonAttribute { parent::__construct($label, $description, $ldapName, '', 'GenericSingleSelectManagementDialog', $defaultValue, $acl); $this->setRequired($required); - $this->selectManagementParameters = array(array($objectType), FALSE); + $this->selectManagementParameters = [[$objectType], FALSE]; $this->objectType = $objectType; } @@ -825,9 +825,9 @@ class ObjectAttribute 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="'.htmlentities($infos['icon'], ENT_COMPAT, 'UTF-8').'" alt="'.$infos['name'].'" class="center"/>'; @@ -841,22 +841,22 @@ class ObjectAttribute extends DialogButtonAttribute } $display .= $this->renderInputField( 'image', $id.'_dialog', - array( + [ 'class' => 'center dialog', '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); @@ -895,7 +895,7 @@ class ObjectAttribute extends DialogButtonAttribute $dn = $this->getValue(); if ($dn != '') { $ldap = $config->get_ldap_link(); - $ldap->cat($dn, array($this->displayAttr)); + $ldap->cat($dn, [$this->displayAttr]); if ($attrs = $ldap->fetch()) { $this->handleDialogResult($dn, $attrs); } else { @@ -908,7 +908,7 @@ class ObjectAttribute extends DialogButtonAttribute public function htmlIds () { $id = $this->getHtmlId(); - $ids = array($id.'_dialog'); + $ids = [$id.'_dialog']; if ($this->isTemplate()) { $ids[] = $id; } @@ -937,7 +937,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'); @@ -981,7 +981,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 d283642992f2309006fb35cb0948b43e4754d4ec..4beac9a4550a17cb8c7b51d076eab10ec8a0c847 100644 --- a/include/simpleplugin/class_helpersAttribute.inc +++ b/include/simpleplugin/class_helpersAttribute.inc @@ -175,9 +175,9 @@ class CommaListAttribute extends CompositeAttribute { parent::__construct( $attribute->getDescription(), $ldapName, - array( + [ $attribute - ), '', '' + ], '', '' ); $this->sep = $sep; } @@ -185,9 +185,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)]; } } @@ -206,10 +206,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); @@ -219,12 +219,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 ( @@ -232,7 +232,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 (array $values) @@ -257,13 +257,13 @@ class BytesSizeAttribute extends UnitIntAttribute { function __construct ($label, $description, $ldapName, $required, $min = FALSE, $max = FALSE, $defaultValue = "", $acl = "") { - $units = array( + $units = [ 1 => _('B'), 1024 ** 1 => _('KiB'), 1024 ** 2 => _('MiB'), 1024 ** 3 => _('GiB'), 1024 ** 4 => _('TiB'), - ); + ]; parent::__construct($label, $description, $ldapName, $required, $units, $min, $max, $defaultValue, $acl); } } @@ -275,12 +275,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 b501ec98d3dc96184a487c8726e652afa5391792..c3194d3a5d56a9aa20a243160275ba7a3cc2b3be 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 (): array { - return array(); + return []; } function __construct ($dn = NULL, $object = NULL, $parent = NULL) @@ -155,7 +155,7 @@ class multiPlugin extends simplePlugin /* Save to LDAP */ function save (): array { - $errors = array(); + $errors = []; /* Save objects */ foreach ($this->plugin as &$plug) { $plug->dn = $this->dn; @@ -174,7 +174,7 @@ class multiPlugin extends simplePlugin function remove (bool $fulldelete = FALSE): array { - $errors = array(); + $errors = []; /* Remove objects */ foreach ($this->plugin as &$plug) { $plug->dn = $this->dn; @@ -187,7 +187,7 @@ class multiPlugin extends simplePlugin return $errors; } - function adapt_from_template (array $attrs, array $skip = array()) + function adapt_from_template (array $attrs, array $skip = []) { /* Adapt objects */ foreach ($this->plugin as &$plug) { diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc index 0e61b1436f2f7b3a3f6698cdce349124f22a4981..2fb141b69b5e37a2b73d11b471984facea22b36b 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); @@ -287,22 +287,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(); @@ -316,17 +316,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', @@ -334,13 +334,13 @@ class simpleManagement 'filter' => new ldapFilter( '&', - array( + [ new ldapFilterLeaf('objectClass', '=', 'fdTemplate'), fdTemplateFilter($filterObject), - ) + ] ), 'nameAttr' => $i['nameAttr'], - ); + ]; } $this->headpage->categories[] = $i['aclCategory']; if ($this->autoActions) { @@ -354,30 +354,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]', - ); + ]; } } } @@ -427,13 +427,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']) { @@ -446,13 +446,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'; @@ -473,7 +473,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; @@ -520,18 +520,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(); @@ -546,7 +546,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 */ @@ -742,7 +742,7 @@ class simpleManagement return; } if ($cancel) { - $msgs = array(); + $msgs = []; } else { $msgs = $this->tabObject->save(); } @@ -893,7 +893,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'])) { @@ -924,7 +924,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); } @@ -960,7 +960,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; @@ -998,8 +998,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!"); @@ -1034,7 +1034,7 @@ class simpleManagement } // Add locks - $objects = array(); + $objects = []; foreach ($this->dns as $dn) { $type = $this->getType($dn); if (preg_match('/^template_/', $type) && !static::$skipTemplates) { @@ -1045,12 +1045,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); @@ -1088,7 +1088,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.'); } } @@ -1138,7 +1138,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(); } @@ -1177,7 +1177,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. @@ -1271,7 +1271,7 @@ class simpleManagement function getSnapshotBases () { - $bases = array(); + $bases = []; foreach ($this->storagePoints as $sp) { $bases[] = $sp.$this->headpage->getBase(); } @@ -1290,7 +1290,7 @@ class simpleManagement function getAllDeletedSnapshots () { $bases = $this->getSnapshotBases(); - $tmp = array(); + $tmp = []; foreach ($bases as $base) { $tmp = array_merge($tmp, $this->snapHandler->getAllDeletedSnapshots($base)); } diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index bfead1c099120ad4537a99974821367df0d51e67..bf6c21b90ee7e0f56d12033838ff704c7badf158 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -36,7 +36,7 @@ class simplePlugin * * associative array that stores attributeLdapName => reference on object */ - public $attributesAccess = array(); + public $attributesAccess = []; /*! \brief Mark plugin as account @@ -88,13 +88,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; @@ -113,14 +113,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; @@ -160,7 +160,7 @@ class simplePlugin $plInfo = pluglist::pluginInfos(get_class($this)); } catch (UnknownClassException $e) { /* May happen in special cases like setup */ - $plInfo = array(); + $plInfo = []; } if (empty($this->objectclasses) && isset($plInfo['plObjectClass'])) { @@ -175,9 +175,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])) { @@ -353,24 +353,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']; @@ -399,10 +399,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) { @@ -542,7 +542,7 @@ class simplePlugin function get_allowed_bases (): array { global $config; - $deps = array(); + $deps = []; /* Is this a new object ? Or just an edited existing object */ foreach ($config->idepartments as $dn => $name) { @@ -607,7 +607,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(); @@ -616,13 +616,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(); @@ -635,7 +635,7 @@ class simplePlugin function getRequiredAttributes (): array { - $tmp = array(); + $tmp = []; foreach ($this->attributesAccess as $attr) { if ($attr->isRequired()) { $tmp[] = $attr->getLdapName(); @@ -669,10 +669,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 = ""; @@ -731,7 +731,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]) && @@ -745,8 +745,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]) && @@ -770,7 +770,7 @@ class simplePlugin $buttonText = msgPool::addFeaturesButton($plInfo['plShortName']); $text = msgPool::featuresDisabled($plInfo['plShortName'], $depends, $conflicts); } - return array($disabled,$buttonText,$text); + return [$disabled,$buttonText,$text]; } /*! @@ -835,7 +835,7 @@ class simplePlugin } } - $sections = array(); + $sections = []; foreach ($this->attributesInfo as $section => $sectionInfo) { $legend = $sectionInfo['name']; if (isset($sectionInfo['icon'])) { @@ -851,7 +851,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 @@ -979,18 +979,18 @@ class simplePlugin function remove (bool $fulldelete = FALSE): array { 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(); @@ -1002,14 +1002,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 */ @@ -1018,7 +1018,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) { @@ -1039,7 +1039,7 @@ class simplePlugin /* Unset attributes from entry */ foreach ($this->attributes as $val) { - $this->attrs["$val"] = array(); + $this->attrs["$val"] = []; } } } @@ -1047,7 +1047,7 @@ class simplePlugin protected function pre_remove () { if ($this->initially_was_account) { - return $this->handle_pre_events('remove', array('modifiedLdapAttrs' => array_keys($this->attrs))); + return $this->handle_pre_events('remove', ['modifiedLdapAttrs' => array_keys($this->attrs)]); } } @@ -1065,9 +1065,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())]; } } @@ -1076,7 +1076,7 @@ class simplePlugin logging::log('remove', 'plugin/'.get_class($this), $this->dn, array_keys($this->attrs), $this->ldap_error); /* Optionally execute a command after we're done */ - $errors = $this->handle_post_events('remove', array('modifiedLdapAttrs' => array_keys($this->attrs))); + $errors = $this->handle_post_events('remove', ['modifiedLdapAttrs' => array_keys($this->attrs)]); if (!empty($errors)) { msg_dialog::displayChecks($errors); } @@ -1215,11 +1215,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(); @@ -1234,7 +1234,7 @@ class simplePlugin $this->prepareNextCleanup(); /* Post hooks and logging */ $this->post_save(); - return array(); + return []; } protected function shouldSave (): bool @@ -1260,13 +1260,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'])) { @@ -1298,15 +1298,15 @@ class simplePlugin } } - return array(); + return []; } protected function pre_save () { if ($this->initially_was_account) { - return $this->handle_pre_events('modify', array('modifiedLdapAttrs' => array_keys($this->attrs))); + return $this->handle_pre_events('modify', ['modifiedLdapAttrs' => array_keys($this->attrs)]); } else { - return $this->handle_pre_events('add', array('modifiedLdapAttrs' => array_keys($this->attrs))); + return $this->handle_pre_events('add', ['modifiedLdapAttrs' => array_keys($this->attrs)]); } } @@ -1317,17 +1317,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"; } @@ -1338,9 +1338,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 @@ -1351,10 +1351,10 @@ class simplePlugin { /* Propagate and log the event */ if ($this->initially_was_account) { - $errors = $this->handle_post_events('modify', array('modifiedLdapAttrs' => array_keys($this->attrs))); + $errors = $this->handle_post_events('modify', ['modifiedLdapAttrs' => array_keys($this->attrs)]); logging::log('modify', 'plugin/'.get_class($this), $this->dn, array_keys($this->attrs), $this->ldap_error); } else { - $errors = $this->handle_post_events('add', array('modifiedLdapAttrs' => array_keys($this->attrs))); + $errors = $this->handle_post_events('add', ['modifiedLdapAttrs' => array_keys($this->attrs)]); logging::log('create', 'plugin/'.get_class($this), $this->dn, array_keys($this->attrs), $this->ldap_error); } if (!empty($errors)) { @@ -1371,7 +1371,7 @@ class simplePlugin * * \param array $addAttrs */ - protected function handle_hooks (string $when, string $mode, array $addAttrs = array()) + protected function handle_hooks (string $when, string $mode, array $addAttrs = []) { switch ($mode) { case 'add': @@ -1392,7 +1392,7 @@ class simplePlugin /*! \brief Forward command execution requests * to the post hook execution method. */ - function handle_post_events (string $mode, array $addAttrs = array()) + function handle_post_events (string $mode, array $addAttrs = []) { /* Update foreign keys */ if ($mode == 'remove') { @@ -1407,7 +1407,7 @@ class simplePlugin * \brief Forward command execution requests * to the pre hook execution method. */ - function handle_pre_events (string $mode, array $addAttrs = array()) + function handle_pre_events (string $mode, array $addAttrs = []) { global $config; @@ -1416,7 +1416,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); @@ -1427,15 +1427,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): array + function callHook ($cmd, array $addAttrs = [], &$returnOutput = [], &$returnCode = NULL): array { 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. @@ -1498,7 +1498,7 @@ class simplePlugin function check (): array { @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, 'check'); - $messages = array(); + $messages = []; foreach ($this->attributesInfo as $sectionInfo) { foreach ($sectionInfo['attrs'] as $attr) { @@ -1513,7 +1513,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); } @@ -1556,14 +1556,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); } } @@ -1571,7 +1571,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 @@ -1590,11 +1590,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)) { @@ -1612,13 +1612,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.')'; } @@ -1648,11 +1648,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; @@ -1677,24 +1677,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.')'; @@ -1711,7 +1711,7 @@ class simplePlugin /* Back up POST content */ $SAVED_POST = $_POST; - $refs = array(); + $refs = []; // For each concerned objectType foreach ($foreignRefs as $objectType => $tabRefs) { // Compute filter @@ -1719,7 +1719,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) { @@ -1728,7 +1728,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)) { @@ -1745,12 +1745,12 @@ class simplePlugin $ofield, $field['oldvalue'], $field['newvalue'], - array( + [ 'CLASS' => $field['tab'], 'FIELD' => $field['field'], 'MODE' => preg_replace('/^handle_/', '', $mode), 'DN' => $this->dn, - ) + ] ); } } @@ -1771,17 +1771,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) { @@ -1790,10 +1790,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'])); @@ -1841,7 +1841,7 @@ class simplePlugin } /* Build DN with multiple attributes */ - $usableAttributes = array(); + $usableAttributes = []; foreach ($this->attributes as $attr) { if (($attr != $attribute) && is_string($this->$attr) && ($this->$attr != '')) { $usableAttributes[] = $attr; @@ -1867,7 +1867,7 @@ class simplePlugin /* * \brief Adapt from template */ - function adapt_from_template (array $attrs, array $skip = array()) + function adapt_from_template (array $attrs, array $skip = []) { $this->attrs = $attrs; @@ -1894,7 +1894,7 @@ class simplePlugin $this->dn = 'new'; $this->orig_dn = $this->dn; - $this->saved_attributes = array(); + $this->saved_attributes = []; $this->initially_was_account = FALSE; } @@ -2016,7 +2016,7 @@ class simplePlugin */ static function plInfo (): array { - return array(); + return []; } /*! \brief This function generate the needed ACLs for a given attribtues array @@ -2025,7 +2025,7 @@ class simplePlugin */ static function generatePlProvidedAcls (array $attributesInfo): array { - $plProvidedAcls = array(); + $plProvidedAcls = []; foreach ($attributesInfo as $sectionInfo) { foreach ($sectionInfo['attrs'] as $attr) { $aclInfo = $attr->getAclInfo(); @@ -2073,7 +2073,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]; @@ -2132,7 +2132,7 @@ class simplePlugin if ((isset($_POST['edit'])) && (!session::is_set('edit'))) { /* Check locking */ if ($locks = get_locks($entry_dn)) { - 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 0c4b98ffb3bd6b7719357d0e72eae5ae5e90d913..af78a0176ab3440c8cb85585a1204b42f7f301fd 100644 --- a/include/simpleplugin/class_simpleService.inc +++ b/include/simpleplugin/class_simpleService.inc @@ -28,7 +28,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 0f6692d8d529defae8e6687878b0bb60d7ed393f..419d98c12a035309a114a4c96f6c235e9b62328d 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) { @@ -248,7 +248,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" @@ -329,13 +329,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']); @@ -387,12 +387,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 ? */ @@ -462,7 +462,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 c7e94324c6e916218899f6164553ada7f31ae4bd..221bbb66b177153bfd9ed990bd6e4ee7d3bf9889 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 (): array { - 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 (): array { - 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 de27439d5e218466058bc9b934feb9695063fa0c..9bd943466a78c3c01285724448ae4e5cb20814f6 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 (): array { - return array( + return [ 'plShortName' => _('Passwords'), 'plDescription' => _('Statistics about passwords'), - 'plObjectType' => array('dashboard'), + 'plObjectType' => ['dashboard'], 'plPriority' => 12, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } static function getAttributesInfo (): array { - 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,14 +95,14 @@ 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 a6d8500a02caf411012d5059b19baadb4689affc..286573d4a0d1c862be8f9ae25189bd89d1de316e 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 (): array { - return array( + return [ 'plShortName' => _('Users'), 'plDescription' => _('Statistics about users'), - 'plObjectType' => array('dashboard'), + 'plObjectType' => ['dashboard'], 'plPriority' => 10, - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } static function getAttributesInfo (): array { - 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' => 'raw', 'cn' => 'raw', 'telephoneNumber' => 'raw', 'manager' => 'raw', 'shadowExpire' => 1, - ); + ]; 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'] <= $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 2c55fe3d78c1fd2bd1280e8195a9064a74ad61e2..dc197d56e51c635415f0588068118e782698a8e4 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 (): array { - 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 (): array { - 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,10 +248,10 @@ class ACLsAssignmentAttribute extends DialogOrderedArrayAttribute foreach ($this->value as $value) { if ( (($source['CLASS'] == 'aclRole') && ($value['role'] == $oldvalue)) || - (in_array($source['CLASS'], array('user','posixGroup','roleGeneric')) && in_array($oldvalue, $value['members'])) + (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']); } } @@ -263,53 +263,53 @@ class aclAssignment extends simplePlugin static function plInfo (): array { global $config; - $oc = array( - 'aclAssignment' => array( + $oc = [ + 'aclAssignment' => [ 'aclCategory' => 'acl', 'name' => _('ACL assignment'), 'ou' => '', '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'), - 'plObjectClass' => array('gosaAcl'), + 'plObjectClass' => ['gosaAcl'], '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 (): array { - 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 6898e9fadd0777331309f035fcd482f891f5c27b..79fc49db89785e594ad218af9c14921a91c2eddb 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 (): array { - 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 (): array { 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->management->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; @@ -129,25 +129,25 @@ class aclManagement extends management public static $skipTemplates = TRUE; /* We cannot show anything more than DN as there are no ACLs for other fields on aclAssignment object */ - public static $columns = array( - array('ObjectTypeColumn', array()), - array('LinkColumn', array('attributes' => 'dn', 'label' => 'DN')), - array('ActionsColumn', array('label' => 'Actions')), - ); + public static $columns = [ + ['ObjectTypeColumn', []], + ['LinkColumn', ['attributes' => 'dn', 'label' => 'DN']], + ['ActionsColumn', ['label' => 'Actions']], + ]; static function plInfo (): array { - 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' => [] + ]; } protected function setUpListing () diff --git a/plugins/admin/aclrole/class_aclEditionDialog.inc b/plugins/admin/aclrole/class_aclEditionDialog.inc index a724f1370e28f828e1ee04557d03c433b988383c..68a90d89ec38602cc93a9fde08b5f3250a46441b 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] != '') { @@ -192,17 +192,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; @@ -309,7 +309,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 995e5d6c80502f87159293e605ed85346b2eb048..64d9ecb51cd6ab7e57c20bfc0449a4ff6ae0fd1c 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) @@ -71,28 +71,28 @@ class aclRole extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => _('Role'), 'plDescription' => _('Access control roles'), - 'plObjectClass' => array('gosaRole'), - 'plObjectType' => array('aclRole' => array( + 'plObjectClass' => ['gosaRole'], + 'plObjectType' => ['aclRole' => [ 'aclCategory' => 'acl', 'name' => _('ACL role'), 'ou' => get_ou('aclRoleRDN'), 'icon' => 'geticon.php?context=categories&icon=acl&size=16', - )), - 'plSearchAttrs' => array('description'), + ]], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array { - return array( - 'properties' => array( + return [ + 'properties' => [ 'name' => _('Properties'), - 'attrs' => array( + 'attrs' => [ new BaseSelectorAttribute(get_ou('aclRoleRDN')), new HostNameAttribute( _('Name'), _('A name for this role'), @@ -102,18 +102,18 @@ 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 8f0efffbc2c5b004de568740257d309ddcb3b43b..b17c194bee2c50f882b2dc09f047b6d379e5a69f 100644 --- a/plugins/admin/aclrole/class_aclRoleManagement.inc +++ b/plugins/admin/aclrole/class_aclRoleManagement.inc @@ -22,17 +22,17 @@ class aclRoleManagement extends management { public static function plInfo (): array { - 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 73dd6fd632fb2d00f8db7f04189d3c97c8174ed1..a1baf7bac31945036be6229d812cc5084937b840 100644 --- a/plugins/admin/departments/class_country.inc +++ b/plugins/admin/departments/class_country.inc @@ -21,30 +21,30 @@ class country extends department { static protected $namingAttr = 'c'; - protected $structuralOC = array('country'); + protected $structuralOC = ['country']; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Country'), 'plDescription' => _('Country'), - 'plObjectClass' => array('gosaDepartment'), + 'plObjectClass' => ['gosaDepartment'], 'plFilter' => '(&(objectClass=country)(objectClass=gosaDepartment))', - 'plObjectType' => array('country' => array( + 'plObjectType' => ['country' => [ 'aclCategory' => 'department', 'name' => _('Country'), 'ou' => '', 'icon' => 'geticon.php?context=types&icon=country&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array diff --git a/plugins/admin/departments/class_dcObject.inc b/plugins/admin/departments/class_dcObject.inc index f3a3e56c9e31015c6d0903f316ba265606276a50..ee8284755d61b0d76567a9d6e58d5135d95c4fb0 100644 --- a/plugins/admin/departments/class_dcObject.inc +++ b/plugins/admin/departments/class_dcObject.inc @@ -21,29 +21,29 @@ class dcObject extends department { static protected $namingAttr = 'dc'; - protected $structuralOC = array('locality'); + protected $structuralOC = ['locality']; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Domain Component'), 'plDescription' => _('Domain Component'), - 'plObjectClass' => array('dcObject', 'gosaDepartment'), - 'plObjectType' => array('dcObject' => array( + 'plObjectClass' => ['dcObject', 'gosaDepartment'], + 'plObjectType' => ['dcObject' => [ 'aclCategory' => 'department', 'name' => _('Domain Component'), 'ou' => '', 'icon' => 'geticon.php?context=types&icon=dc&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc index 146633878d014d0d8dcf0e4a5138d012f5bdd83d..e20aaf853b2885a0108d50547dd9929d64332138 100644 --- a/plugins/admin/departments/class_department.inc +++ b/plugins/admin/departments/class_department.inc @@ -22,34 +22,33 @@ class department extends simplePlugin { static protected $namingAttr = 'ou'; - protected $structuralOC = array('organizationalUnit'); + protected $structuralOC = ['organizationalUnit']; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Department'), 'plDescription' => _('Departments'), /* Do not append the structural object classes here, they are added dynamically in the constructor */ - 'plObjectClass' => array('gosaDepartment'), + 'plObjectClass' => ['gosaDepartment'], 'plFilter' => '(&(objectClass=organizationalUnit)(objectClass=gosaDepartment))', - 'plCategory' => array('department' => array('objectClass' => 'gosaDepartment', 'description' => _('Departments'))), - 'plObjectType' => - array( - 'department' => array( - 'name' => _('Department'), - 'ou' => '', - 'icon' => 'geticon.php?context=places&icon=folder&size=16', - 'tabClass' => 'deptabs', - 'mainAttr' => static::$namingAttr, - ) - ), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + 'plCategory' => ['department' => ['objectClass' => 'gosaDepartment', 'description' => _('Departments')]], + 'plObjectType' => [ + 'department' => [ + 'name' => _('Department'), + 'ou' => '', + 'icon' => 'geticon.php?context=places&icon=folder&size=16', + 'tabClass' => 'deptabs', + 'mainAttr' => static::$namingAttr, + ] + ], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array @@ -58,10 +57,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 +83,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 +111,9 @@ class department extends simplePlugin _('Fax'), _('Facsimile telephone number'), 'facsimileTelephoneNumber', FALSE ), - ) - ), - ); + ] + ], + ]; if (static::$namingAttr != 'ou') { $attributesInfo['properties']['attrs'][] = new HiddenAttribute('ou'); } @@ -133,7 +132,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 +145,7 @@ class department extends simplePlugin } $this->objectclasses = array_unique($this->objectclasses); - $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 ffe59ae5b1a322b693de576708f7718a53a9ac7b..f0258116d9560b957a605b925f9ab0f20f29e281 100644 --- a/plugins/admin/departments/class_departmentManagement.inc +++ b/plugins/admin/departments/class_departmentManagement.inc @@ -25,17 +25,17 @@ class departmentManagement extends management public static function plInfo (): array { - 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' => [] + ]; } // Overriden save handler - We've to take care about the department tagging here. @@ -62,7 +62,7 @@ class departmentManagement extends management 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); } @@ -75,6 +75,6 @@ class departmentManagement extends management static function getDepartmentTypes (): array { - 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 589b4193244b3c3cc3164637980b209ee52d7399..85d7a2813a648ea79f0f755f86f9009fd8d4fe0c 100644 --- a/plugins/admin/departments/class_domain.inc +++ b/plugins/admin/departments/class_domain.inc @@ -21,29 +21,29 @@ class domain extends department { static protected $namingAttr = 'dc'; - protected $structuralOC = array('domain'); + protected $structuralOC = ['domain']; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Domain'), 'plDescription' => _('Domain'), - 'plObjectClass' => array('domain', 'gosaDepartment'), - 'plObjectType' => array('domain' => array( + 'plObjectClass' => ['domain', 'gosaDepartment'], + 'plObjectType' => ['domain' => [ 'aclCategory' => 'department', 'name' => _('Domain'), 'ou' => '', 'icon' => 'geticon.php?context=types&icon=domain&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array diff --git a/plugins/admin/departments/class_locality.inc b/plugins/admin/departments/class_locality.inc index 5c7ffcee6e233d5650196719a853f50e6e774e0f..b479f728a4711acb131199e3d1a063a6f3055748 100644 --- a/plugins/admin/departments/class_locality.inc +++ b/plugins/admin/departments/class_locality.inc @@ -21,30 +21,30 @@ class locality extends department { static protected $namingAttr = 'l'; - protected $structuralOC = array('locality'); + protected $structuralOC = ['locality']; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Locality'), 'plDescription' => _('Locality'), - 'plObjectClass' => array('gosaDepartment'), + 'plObjectClass' => ['gosaDepartment'], 'plFilter' => '(&(!(objectClass=dcObject))(objectClass=locality)(objectClass=gosaDepartment))', - 'plObjectType' => array('locality' => array( + 'plObjectType' => ['locality' => [ 'aclCategory' => 'department', 'name' => _('Locality'), 'ou' => '', 'icon' => 'geticon.php?context=types&icon=locality&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array diff --git a/plugins/admin/departments/class_organization.inc b/plugins/admin/departments/class_organization.inc index b6fd7641a5470d5174718db259b71fe0952d2f04..5b8cab3acf2f51053c58a27ba6e00a47caa6e12b 100644 --- a/plugins/admin/departments/class_organization.inc +++ b/plugins/admin/departments/class_organization.inc @@ -21,30 +21,30 @@ class organization extends department { static protected $namingAttr = 'o'; - protected $structuralOC = array('organization'); + protected $structuralOC = ['organization']; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Organization'), 'plDescription' => _('Organization'), - 'plObjectClass' => array('gosaDepartment'), + 'plObjectClass' => ['gosaDepartment'], 'plFilter' => '(&(objectClass=organization)(objectClass=gosaDepartment))', - 'plObjectType' => array('organization' => array( + 'plObjectType' => ['organization' => [ 'aclCategory' => 'department', 'name' => _('Organization'), 'ou' => '', 'icon' => 'geticon.php?context=types&icon=organization&size=16', 'tabClass' => 'deptabs', 'mainAttr' => static::$namingAttr, - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array diff --git a/plugins/admin/groups/class_GroupContentFilterElement.inc b/plugins/admin/groups/class_GroupContentFilterElement.inc index 0a8b062c0cbdd00b5eebd8165e0dad5f905ace44..9ff17422f541b816e67cbb2a69ca3331f8d5273f 100644 --- a/plugins/admin/groups/class_GroupContentFilterElement.inc +++ b/plugins/admin/groups/class_GroupContentFilterElement.inc @@ -31,15 +31,15 @@ class GroupContentFilterElement extends FilterElement parent::__construct($parent); - $this->types = array(); + $this->types = []; foreach (ogroup::$objectTypes as $key => $type) { try { $infos = objects::infos($type); - $this->types[$type] = array( + $this->types[$type] = [ 'filter' => '(gosaGroupObjects=*'.$key.'*)', 'infos' => $infos, 'checked' => FALSE, - ); + ]; } catch (NonExistingObjectTypeException $e) { continue; } @@ -56,14 +56,14 @@ class GroupContentFilterElement extends FilterElement public function render () { - $inputs = array(); + $inputs = []; foreach ($this->types as $type => $infos) { - $inputs['filter_member_'.$type] = array( + $inputs['filter_member_'.$type] = [ 'name' => $infos['infos']['name'], 'desc' => (isset($infos['infos']['description']) ? $infos['infos']['description'] : $infos['infos']['name']).' '.$infos['filter'], 'icon' => (isset($infos['infos']['icon']) ? $infos['infos']['icon'] : NULL), 'checked' => $infos['checked'], - ); + ]; } $smarty = get_smarty(); $smarty->assign('NAME', _('Members')); diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index f3ff7399de0275f9c2247e495b8c929446fe2980..846b102e157178efc7a06e832719affe49ea0006 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -23,30 +23,30 @@ class groupManagement extends management { public static $skipTemplates = FALSE; - public static $columns = array( - array('ObjectTypeColumn', array()), - array('LinkColumn', array('attributes' => 'cn', 'label' => 'Name')), - array('LinkColumn', array('attributes' => 'description', 'label' => 'Description')), - array('GroupContentColumn', array('attributes' => 'gosaGroupObjects', 'label' => 'Members')), - array('PropertiesColumn', array('label' => 'Properties')), - array('ActionsColumn', array('label' => 'Actions')), - ); + public static $columns = [ + ['ObjectTypeColumn', []], + ['LinkColumn', ['attributes' => 'cn', 'label' => 'Name']], + ['LinkColumn', ['attributes' => 'description', 'label' => 'Description']], + ['GroupContentColumn', ['attributes' => 'gosaGroupObjects', 'label' => 'Members']], + ['PropertiesColumn', ['label' => 'Properties']], + ['ActionsColumn', ['label' => 'Actions']], + ]; protected $siActive = FALSE; static function plInfo (): array { - 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 () @@ -68,8 +68,8 @@ class groupManagement extends management parent::configureActions(); if ($this->siActive) { - $triggerActions = array(); - $scheduleActions = array(); + $triggerActions = []; + $scheduleActions = []; $events = argonautEventTypes::get_event_types(); foreach ($events as $name => $infos) { $triggerActions[] = new Action( @@ -114,7 +114,7 @@ class groupManagement extends management $event = $action['subaction']; // Now send FAI/Argonaut events here. - $mac = array(); + $mac = []; // Collect target mac addresses $ldap = $config->get_ldap_link(); @@ -145,12 +145,12 @@ class groupManagement extends management /* 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.'); } } } diff --git a/plugins/admin/groups/class_ogroup.inc b/plugins/admin/groups/class_ogroup.inc index 1f6de1c0f8e3bd94334592b2fd00ba07b41cdbf6..40172884566e153d043fd2ca8546d5237879bfb5 100644 --- a/plugins/admin/groups/class_ogroup.inc +++ b/plugins/admin/groups/class_ogroup.inc @@ -21,18 +21,18 @@ class GroupMembersAttribute extends ObjectsAttribute { - protected $types = array(); + protected $types = []; - 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 = '') { parent::__construct($label, $description, $ldapName, $required, array_values(ogroup::$objectTypes), $defaultValue, $store_attr, $display_attr, $acl); } function getFilterBlackList () { - return array( - 'dn' => array_merge($this->getValue(), $this->plugin->used_workstations, array($this->plugin->dn)) - ); + return [ + 'dn' => array_merge($this->getValue(), $this->plugin->used_workstations, [$this->plugin->dn]) + ]; } protected function fillDisplayValueFrom ($i, $attrs) @@ -104,7 +104,7 @@ class GroupMembersAttribute extends ObjectsAttribute ($this->disabled ? ' disabled="disabled"' : ''). ' >'."\n"; foreach ($this->getDisplayValues() as $key => $value) { - $infos = array(); + $infos = []; try { if ($this->types[$key] !== 'I') { $infos = objects::infos(ogroup::$objectTypes[$this->types[$key]]); @@ -126,7 +126,7 @@ class GroupMembersAttribute extends ObjectsAttribute function ldapAttributesToGet () { - return array( + return [ 'objectClass', 'cn', 'sn', @@ -134,7 +134,7 @@ class GroupMembersAttribute extends ObjectsAttribute 'uid', 'givenName', 'description', - ); + ]; } function listObjectTypes () @@ -147,10 +147,10 @@ class GroupMembersAttribute extends ObjectsAttribute function getTypedValues () { $values = $this->getValue(); - $ret = array(); + $ret = []; foreach ($values as $i => $v) { if (!isset($ret[$this->types[$i]])) { - $ret[$this->types[$i]] = array(); + $ret[$this->types[$i]] = []; } $ret[$this->types[$i]][] = $v; } @@ -167,11 +167,11 @@ class GroupMembersAttribute extends ObjectsAttribute class ogroup extends simplePlugin { - var $used_workstations = array(); + var $used_workstations = []; protected $savedTypedMembers; - static $objectTypes = array( + static $objectTypes = [ 'U' => 'user', 'G' => 'ogroup', 'A' => 'application', @@ -181,51 +181,51 @@ class ogroup extends simplePlugin 'F' => 'phone', 'P' => 'printer', 'D' => 'simpleSecurityObject', - ); + ]; static function plInfo (): array { - return array( + return [ 'plShortName' => _('Object group'), 'plDescription' => _('Object group information'), 'plFilter' => '(objectClass=groupOfNames)', 'plPriority' => 1, - 'plObjectClass' => array('groupOfNames', 'gosaGroupOfNames'), + 'plObjectClass' => ['groupOfNames', 'gosaGroupOfNames'], 'plFilter' => '(objectClass=groupOfNames)', - 'plObjectType' => array('ogroup' => array( + 'plObjectType' => ['ogroup' => [ 'name' => _('Group'), 'description' => _('Group'), 'ou' => get_ou('ogroupRDN'), 'icon' => 'geticon.php?context=types&icon=resource-group&size=16', 'tabClass' => 'ogrouptabs', - )), - 'plForeignKeys' => array( - 'member' => array( - array('user', 'dn','member=%oldvalue%','*'), - array('ogroup', 'dn','member=%oldvalue%','*'), - array('application', 'dn','member=%oldvalue%','*'), - array('serverGeneric', 'dn','member=%oldvalue%','*'), - array('workstationGeneric', 'dn','member=%oldvalue%','*'), - array('terminalGeneric', 'dn','member=%oldvalue%','*'), - array('phoneGeneric', 'dn','member=%oldvalue%','*'), - array('printGeneric', 'dn','member=%oldvalue%','*'), - ), - 'owner' => array( - array('user','dn','owner=%oldvalue%','*') - ) - ), - 'plSearchAttrs' => array('description'), + ]], + 'plForeignKeys' => [ + 'member' => [ + ['user', 'dn','member=%oldvalue%','*'], + ['ogroup', 'dn','member=%oldvalue%','*'], + ['application', 'dn','member=%oldvalue%','*'], + ['serverGeneric', 'dn','member=%oldvalue%','*'], + ['workstationGeneric', 'dn','member=%oldvalue%','*'], + ['terminalGeneric', 'dn','member=%oldvalue%','*'], + ['phoneGeneric', 'dn','member=%oldvalue%','*'], + ['printGeneric', 'dn','member=%oldvalue%','*'], + ], + 'owner' => [ + ['user','dn','owner=%oldvalue%','*'] + ] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array { - return array( - 'main' => array( + return [ + 'main' => [ 'name' => _('Properties'), - 'attrs' => array( + 'attrs' => [ new BaseSelectorAttribute(get_ou('ogroupRDN')), new StringAttribute( _('Name'), _('Name of this group'), @@ -241,36 +241,36 @@ class ogroup extends simplePlugin _('Owner'), _('Owner'), 'owner', FALSE ), - ) - ), - 'members' => array( + ] + ], + 'members' => [ 'name' => _('Member objects'), - 'attrs' => array( + 'attrs' => [ new GroupMembersAttribute( '', _('Objects member of this group'), 'member', TRUE, - array(), 'dn' + [], 'dn' ) - ) - ), - 'system_trust' => array( + ] + ], + 'system_trust' => [ 'name' => _('System trust'), 'icon' => 'geticon.php?context=status&icon=locked&size=16', - 'attrs' => array( + 'attrs' => [ new SelectAttribute( _('Trust mode'), _('Type of authorization for those hosts'), 'trustMode', FALSE, - array('', 'fullaccess', 'byhost'), + ['', 'fullaccess', 'byhost'], '', - array(_('disabled'), _('full access'), _('allow access to these hosts')) + [_('disabled'), _('full access'), _('allow access to these hosts')] ), new SystemsAttribute( '', _('Only allow this group to connect to this list of hosts'), 'host', FALSE ) - ) - ) - ); + ] + ] + ]; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -279,12 +279,12 @@ class ogroup extends simplePlugin $this->attributesAccess['trustMode']->setInLdap(FALSE); $this->attributesAccess['trustMode']->setManagedAttributes( - array( - 'multiplevalues' => array('notbyhost' => array('','fullaccess')), - 'erase' => array( - 'notbyhost' => array('host') - ) - ) + [ + 'multiplevalues' => ['notbyhost' => ['','fullaccess']], + 'erase' => [ + 'notbyhost' => ['host'] + ] + ] ); if ((count($this->host) == 1) && ($this->host[0] == '*')) { $this->trustMode = 'fullaccess'; @@ -295,14 +295,14 @@ class ogroup extends simplePlugin /* Detect all workstations, which are already assigned to an object group - Those objects will be hidden in the add object dialog. - Check() will complain if such a system is assigned to this object group.*/ - $this->used_workstations = array(); + $this->used_workstations = []; try { - $ws_dns = array_keys(objects::ls(array('workstation','terminal'))); - $res = objects::ls('ogroup', array('member' => '*'), NULL, '(&(member=*)(|(gosaGroupObjects=[W])(gosaGroupObjects=[T])))'); + $ws_dns = array_keys(objects::ls(['workstation','terminal'])); + $res = objects::ls('ogroup', ['member' => '*'], NULL, '(&(member=*)(|(gosaGroupObjects=[W])(gosaGroupObjects=[T])))'); } catch (NonExistingObjectTypeException $e) { /* If workstation/terminal objectType is not existing, systems plugin is missing so there are no systems */ - $ws_dns = array(); - $res = array(); + $ws_dns = []; + $res = []; } foreach ($res as $odn => $og) { if ($odn == $this->dn) { @@ -321,7 +321,7 @@ class ogroup extends simplePlugin $errors = parent::prepare_save(); if ($this->trustMode == 'fullaccess') { - $this->attrs['host'] = array('*'); + $this->attrs['host'] = ['*']; } /* Trust accounts */ @@ -354,11 +354,11 @@ class ogroup extends simplePlugin { global $ui; - $errors = array(); + $errors = []; if (isset($this->attrs['member'])) { - $userMembers = array(); - $savedMembers = array(); + $userMembers = []; + $savedMembers = []; $members = $this->attributesAccess['member']->getTypedValues(); if (isset($members['U'])) { $userMembers = $members['U']; diff --git a/plugins/admin/groups/class_roleGeneric.inc b/plugins/admin/groups/class_roleGeneric.inc index 1e7f835ef0e468715185a386ed4af93ae3929e4c..e9eed2965612a472ae9166d814e9e1ff98d95df3 100644 --- a/plugins/admin/groups/class_roleGeneric.inc +++ b/plugins/admin/groups/class_roleGeneric.inc @@ -28,19 +28,19 @@ 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 = array_merge_recursive(...array_values($groups))['member']; } } - return array( - 'branches' => array($this->plugin->base), + return [ + 'branches' => [$this->plugin->base], 'dn' => $this->whitelistDns, - ); + ]; } else { - return array(); + return []; } } } @@ -49,27 +49,27 @@ class roleGeneric extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => _('Role'), 'plDescription' => _('Role information'), - 'plObjectClass' => array('organizationalRole'), + 'plObjectClass' => ['organizationalRole'], 'plFilter' => '(&(objectClass=organizationalRole)(!(objectClass=simpleSecurityObject)))', - 'plObjectType' => array('role' => - array( + 'plObjectType' => ['role' => + [ 'name' => _('Role'), 'description' => _('Organizational role'), 'ou' => get_ou('roleRDN'), 'icon' => 'geticon.php?context=types&icon=role&size=16', 'mainAttr' => 'cn', - ) - ), - 'plForeignKeys' => array( - 'roleOccupant' => array('user','dn','roleOccupant=%oldvalue%','*') - ), - 'plSearchAttrs' => array('description'), + ] + ], + 'plForeignKeys' => [ + 'roleOccupant' => ['user','dn','roleOccupant=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['description'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } /*! @@ -77,10 +77,10 @@ class roleGeneric extends simplePlugin */ static function getAttributesInfo (): array { - 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 (): array { 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 ba30d7ed553fd5b43e38632756fe3cc9269f6f4c..ca4ccd73d217ea38daa8667194da92329ad8e708 100644 --- a/plugins/admin/groups/tabs_ogroups.inc +++ b/plugins/admin/groups/tabs_ogroups.inc @@ -22,7 +22,7 @@ class ogrouptabs extends simpleTabs_noSpecial { protected $groupObjects = NULL; - protected $removed_tabs = array(); + protected $removed_tabs = []; function __construct ($type, $dn, $copied_object = NULL) { @@ -40,21 +40,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, diff --git a/plugins/admin/users/class_LockAction.inc b/plugins/admin/users/class_LockAction.inc index 2fcdf9c096627a17d27c649009b65f5e65a83e9c..7e7c28d45de8d251a7902e35b8c71a35aae537a0 100644 --- a/plugins/admin/users/class_LockAction.inc +++ b/plugins/admin/users/class_LockAction.inc @@ -20,15 +20,15 @@ class LockAction extends Action { - function __construct (string $name, string $targets, $callable, array $acl = array(), $inmenu = TRUE, $inline = TRUE) + function __construct (string $name, string $targets, $callable, array $acl = [], $inmenu = TRUE, $inline = TRUE) { parent::__construct( $name, - array('lock' => _('Lock users'), 'unlock' => _('Unlock users')), - array( + ['lock' => _('Lock users'), 'unlock' => _('Unlock users')], + [ 'lock' => 'geticon.php?context=status&icon=object-locked&size=16', 'unlock' => 'geticon.php?context=status&icon=object-unlocked&size=16', - ), + ], $targets, $callable, $acl, $inmenu, $inline); } @@ -53,21 +53,21 @@ class LockAction extends Action return; } - $actions[] = array( + $actions[] = [ 'name' => $this->name.'_lock', 'icon' => $this->icon['lock'], 'label' => $this->label['lock'], 'enabled' => $this->isEnabledFor(), 'separator' => $this->separator, - ); + ]; - $actions[] = array( + $actions[] = [ 'name' => $this->name.'_unlock', 'icon' => $this->icon['unlock'], 'label' => $this->label['unlock'], 'enabled' => $this->isEnabledFor(), 'separator' => FALSE, - ); + ]; } function fillRowClasses (&$classes, ListingEntry $entry) diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 0e99934c5cc4d516c877cfcbf494a67962d686aa..3f5f476914d4f414bf3f49301f3dfe237257f24c 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -21,32 +21,32 @@ class userManagement extends management { - public $neededAttrs = array('userPassword' => '1'); + public $neededAttrs = ['userPassword' => '1']; public static $skipTemplates = FALSE; - public static $columns = array( - array('ObjectTypeColumn', array()), - array('LinkColumn', array('attributes' => 'sn', 'label' => 'Last name')), - array('LinkColumn', array('attributes' => 'givenName', 'label' => 'First name')), - array('Column', array('attributes' => 'uid', 'label' => 'Login')), - array('PropertiesColumn', array('label' => 'Properties')), - array('ActionsColumn', array('label' => 'Actions')), - ); + public static $columns = [ + ['ObjectTypeColumn', []], + ['LinkColumn', ['attributes' => 'sn', 'label' => 'Last name']], + ['LinkColumn', ['attributes' => 'givenName', 'label' => 'First name']], + ['Column', ['attributes' => 'uid', 'label' => 'Login']], + ['PropertiesColumn', ['label' => 'Properties']], + ['ActionsColumn', ['label' => 'Actions']], + ]; static function plInfo (): array { - 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' => [] + ]; } @@ -58,7 +58,7 @@ class userManagement extends management new LockAction( 'lockUsers', '+', 'lockUsers', - array('userPassword:rw'), TRUE, TRUE + ['userPassword:rw'], TRUE, TRUE ) ); $this->actions['lockUsers']->setSeparator(TRUE); @@ -72,8 +72,8 @@ class userManagement extends management @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $action, 'Lock'); // Filter out entries we are not allowed to modify - $disallowed = array(); - $allowed = array(); + $disallowed = []; + $allowed = []; foreach ($action['targets'] as $dn) { if (strpos($ui->get_permissions($dn, 'user/user', 'userLock'), 'w') === FALSE) { $disallowed[] = $dn; diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc index f5f0faa3ef148e9ac8ae7d21bab9ebb7bd1c4aec..25b35d9c345dfd9a421453814d6ff0d9d8adbe34 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; @@ -50,46 +50,46 @@ class configInLdap extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => _('Configuration'), 'plTitle' => _('FusionDirectory configuration'), 'plDescription' => _('Configuration screen of FusionDirectory'), 'plIcon' => 'geticon.php?context=categories&icon=settings&size=48', - 'plObjectClass' => array('fusionDirectoryConf'), - 'plObjectType' => array( - 'configuration' => array( + 'plObjectClass' => ['fusionDirectoryConf'], + '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 (): array { global $config; - $plugins = array(); + $plugins = []; if (session::global_is_set('plist')) { $plugins = array_keys(session::global_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'), @@ -100,14 +100,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, @@ -117,7 +117,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'), @@ -146,15 +146,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'), @@ -183,17 +183,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'), @@ -221,11 +221,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, @@ -241,11 +241,11 @@ class configInLdap extends simplePlugin 'fdSslCaCertPath', FALSE, '/etc/ssl/certs/ca.cert' ), - ) - ), - 'cas' => array( + ] + ], + 'cas' => [ 'name' => _('CAS'), - 'attrs' => array( + 'attrs' => [ new TrimmedStringAttribute( _('CA certificate path'), _('Path to the CA certificate of the CAS server'), 'fdCasServerCaCertPath', FALSE, @@ -266,16 +266,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'), @@ -310,11 +310,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.'), @@ -335,18 +335,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.'), @@ -363,44 +363,44 @@ 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() + [] ), // Needed here for ACLs new HiddenAttribute('fdManagementConfig'), - ) - ), - '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, @@ -409,22 +409,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( @@ -432,9 +432,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) @@ -444,7 +444,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()); @@ -479,7 +479,7 @@ class configInLdap extends simplePlugin array_keys($groupsAndRoles), array_values($groupsAndRoles) ); - $menuPlugins = array(); + $menuPlugins = []; $plist = session::global_get('plist'); foreach ($config->data['SECTIONS'] as $section => $section_infos) { foreach ($config->data['MENU'][$section] as $info) { @@ -505,61 +505,61 @@ class configInLdap extends simplePlugin $this->fusionConfigMd5 = md5_file(CACHE_DIR."/".CLASS_CACHE); $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['fdSplitPostalAddress']->setManagedAttributes( - array( - 'disable' => array ( - FALSE => array ( + [ + 'disable' => [ + FALSE => [ 'fdPostalAddressPattern', - ) - ) - ) + ] + ] + ] ); $this->attributesAccess['fdLoginMethod']->setManagedAttributes( - array( - 'multiplevalues' => array( - 'noncas' => array( + [ + 'multiplevalues' => [ + 'noncas' => [ 'LoginPost', 'LoginHTTPAuth', 'LoginHTTPHeader', - ), - 'nonheader' => array( + ], + 'nonheader' => [ 'LoginPost', 'LoginCAS', 'LoginHTTPAuth' - ), - ), - 'disable' => array( - 'noncas' => array ( + ], + ], + 'disable' => [ + 'noncas' => [ 'fdCasServerCaCertPath', 'fdCasHost', 'fdCasPort', 'fdCasContext', - ), - 'nonheader' => array ( + ], + 'nonheader' => [ 'fdHttpHeaderAuthHeaderName', - ) - ) - ) + ] + ] + ] ); if (empty($this->attrs['fdLoginMethod'][0])) { // Reading OBSOLETE attributes from FD<1.4 to ease migration diff --git a/plugins/config/class_dashBoardConfig.inc b/plugins/config/class_dashBoardConfig.inc index d724bec69f305ff469c14ca869ff70061d104cd7..ccd332a4a2eeefed6c4f5bda0913ddcc5ee19021 100644 --- a/plugins/config/class_dashBoardConfig.inc +++ b/plugins/config/class_dashBoardConfig.inc @@ -22,23 +22,23 @@ class dashboardConfig extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => _('Dashboard configuration'), 'plDescription' => _('FusionDirectory dashboard plugin configuration'), - 'plCategory' => array('configuration'), - 'plObjectClass' => array('fdDashboardPluginConf'), - 'plObjectType' => array('smallConfig'), + 'plCategory' => ['configuration'], + 'plObjectClass' => ['fdDashboardPluginConf'], + 'plObjectType' => ['smallConfig'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array { - 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, @@ -49,20 +49,20 @@ 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 8619cb1accb27c740d92ecbd7e2ab67c6393f2d8..fe6f8328dc4c9dcfcb20c284262ab12b99743bf4 100644 --- a/plugins/config/class_mainPluginsConfig.inc +++ b/plugins/config/class_mainPluginsConfig.inc @@ -22,40 +22,40 @@ class mainPluginsConfig extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => _('Plugins configuration'), 'plDescription' => _('FusionDirectory plugins configuration'), - 'plCategory' => array('configuration'), - 'plObjectClass' => array('fusionDirectoryPluginsConf'), - 'plObjectType' => array('smallConfig'), + 'plCategory' => ['configuration'], + 'plObjectClass' => ['fusionDirectoryPluginsConf'], + 'plObjectType' => ['smallConfig'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array { - 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 b2034fd13622e6b96eb4dd519f59a0ec1e7806fe..072cf312f5a7320af6368b95a60f81b0ce92b74e 100644 --- a/plugins/config/class_pluginsConfigInLdap.inc +++ b/plugins/config/class_pluginsConfigInLdap.inc @@ -24,14 +24,14 @@ class pluginsConfigInLdap extends multiPlugin static function plInfo (): array { - return array( + return [ 'plShortName' => _('Plugins'), 'plDescription' => _('Configuration for plugins'), 'plPriority' => 20, - 'plObjectType' => array('configuration'), + 'plObjectType' => ['configuration'], 'plSubTabs' => 'smallConfig', - 'plProvidedAcls' => array() - ); + 'plProvidedAcls' => [] + ]; } } diff --git a/plugins/config/class_recoveryConfig.inc b/plugins/config/class_recoveryConfig.inc index c7e3bde5e8b43f1c513082b8102eed4b26877b75..1764e522ac0138cba8a4503a91277c4ee3478e2b 100644 --- a/plugins/config/class_recoveryConfig.inc +++ b/plugins/config/class_recoveryConfig.inc @@ -22,24 +22,24 @@ class recoveryConfig extends simplePlugin { static function plInfo (): array { - return array( + return [ 'plShortName' => _('Password recovery'), 'plDescription' => _('Settings for the password recovery feature'), - 'plObjectClass' => array('fdPasswordRecoveryConf'), - 'plObjectType' => array('configuration'), + 'plObjectClass' => ['fdPasswordRecoveryConf'], + 'plObjectType' => ['configuration'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) - ); + ]; } static function getAttributesInfo (): array { - 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'), @@ -78,11 +78,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'), @@ -97,11 +97,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'), @@ -116,9 +116,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) @@ -127,7 +127,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); @@ -144,15 +144,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 b3e57904550b6696036218cca702e22ed9519e5a..dc8c7f499a0afa1362d7f2741f5512f4fe7f5236 100644 --- a/plugins/generic/references/class_reference.inc +++ b/plugins/generic/references/class_reference.inc @@ -23,33 +23,33 @@ class reference extends simplePlugin { static function plInfo (): array { - 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 (): array { - 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) @@ -80,16 +80,16 @@ class reference extends simplePlugin function check (): array { - return array(); + return []; } function save (): array { - return array(); + return []; } function remove (bool $fulldelete = FALSE): array { - return array(); + return []; } } diff --git a/plugins/personal/generic/class_UserPasswordAttribute.inc b/plugins/personal/generic/class_UserPasswordAttribute.inc index a4d781859b7793c750557fa97ac3a2cd9db0668c..3095b63d8262ae97fd5163bb048f09022a3187d7 100644 --- a/plugins/personal/generic/class_UserPasswordAttribute.inc +++ b/plugins/personal/generic/class_UserPasswordAttribute.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, @@ -64,7 +64,7 @@ class UserPasswordAttribute extends CompositeAttribute $ldapName.'_locked', FALSE, FALSE ) - ), + ], '', '', $acl, $label ); $this->attributes[0]->setSubmitForm(TRUE); @@ -184,7 +184,7 @@ class UserPasswordAttribute extends CompositeAttribute $password = ''; if ($istemplate && !empty($value)) { if ($value == '%askme%') { - return array('%askme%', '', '', $value, $locked); + return ['%askme%', '', '', $value, $locked]; } list($value, $password) = explode('|', $value, 2); } @@ -200,7 +200,7 @@ class UserPasswordAttribute extends CompositeAttribute $pw_storage = 'empty'; } $locked = ($locked ? 'TRUE' : 'FALSE'); - return array($pw_storage, $password, $password, $value, $locked); + return [$pw_storage, $password, $password, $value, $locked]; } function writeValues (array $values) diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index eab0ac7d446130f4060a04c01b54d0e8cfeae54d..4e20f2bcf603604a359d0387e9d27bfe5be4e5a3 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -23,8 +23,8 @@ class PostalAddressAttribute extends TextAreaAttribute function inputValue ($ldapValue) { return str_replace( - array('$', '\24','\5C'), - array("\n", '$', '\\'), + ['$', '\24','\5C'], + ["\n", '$', '\\'], $ldapValue ); } @@ -32,11 +32,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() ) ); @@ -49,32 +49,32 @@ class user extends simplePlugin static function plInfo (): array { - 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, - 'plObjectClass' => array('inetOrgPerson','organizationalPerson','person'), + 'plObjectClass' => ['inetOrgPerson','organizationalPerson','person'], 'plFilter' => '(objectClass=inetOrgPerson)', - 'plObjectType' => array('user' => array( + 'plObjectType' => ['user' => [ 'name' => _('User'), 'description' => _('User account'), 'mainAttr' => 'uid', 'nameAttr' => 'cn', 'icon' => 'geticon.php?context=types&icon=user&size=16', 'ou' => get_ou('userRDN'), - )), - 'plForeignKeys' => array( - 'manager' => array('user','dn','manager=%oldvalue%','*') - ), - 'plSearchAttrs' => array('uid','description'), + ]], + 'plForeignKeys' => [ + 'manager' => ['user','dn','manager=%oldvalue%','*'] + ], + 'plSearchAttrs' => ['uid','description'], 'plProvidedAcls' => array_merge( parent::generatePlProvidedAcls(static::getAttributesInfo()), - array('userLock' => _('User lock status')) + ['userLock' => _('User lock status')] ) - ); + ]; } static function getAttributesInfo (): array @@ -82,12 +82,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'), @@ -108,12 +108,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 @@ -154,12 +154,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'), @@ -174,12 +174,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 @@ -192,12 +192,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'), @@ -228,12 +228,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 @@ -247,7 +247,7 @@ class user extends simplePlugin 'postalCode', FALSE, 0, FALSE ), - )); + ]); } return $attributesInfo; } @@ -283,7 +283,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; @@ -378,18 +378,18 @@ class user extends simplePlugin return parent::post_save(); } - function adapt_from_template (array $attrs, array $skip = array()) + function adapt_from_template (array $attrs, array $skip = []) { if ($this->uid != '') { $skip[] = 'uid'; } - parent::adapt_from_template($attrs, array_merge($skip, array('userPassword'))); + parent::adapt_from_template($attrs, array_merge($skip, ['userPassword'])); if (isset($this->attrs['userPassword']) && !in_array('userPassword', $skip)) { $this->userPassword = $this->attributesAccess['userPassword']->readUserPasswordValues($this->attrs['userPassword'][0], TRUE); } } - function callHook ($cmd, array $addAttrs = array(), &$returnOutput = array(), &$returnCode = NULL): array + function callHook ($cmd, array $addAttrs = [], &$returnOutput = [], &$returnCode = NULL): array { $addAttrs['passwordMethod'] = $this->attributesAccess['userPassword']->getMethod(); $addAttrs['userLocked'] = (int)($this->attributesAccess['userPassword']->isLocked()); @@ -413,7 +413,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])) { @@ -425,7 +425,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 4b9348a0912f2bf8aa377160285b07769ca82c78..1b19094c0c1628920ed20d9952879212a14c3477 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 (): array { - 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 (): array { - 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); } @@ -191,7 +191,7 @@ class userRoles extends simplePlugin } } } - return array(); + return []; } function save_object () @@ -228,8 +228,8 @@ class userRoles extends simplePlugin { parent::prepare_remove(); if ($this->is_template) { - $this->attrs['userGroups'] = array(); - $this->attrs['userRoles'] = array(); + $this->attrs['userGroups'] = []; + $this->attrs['userRoles'] = []; } } @@ -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 (array $attrs, array $skip = array()) + function adapt_from_template (array $attrs, array $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 69041d34f2d79f37f031b12e9a6d5beab7447fe3..142141c28597105462d2c9141edec2577544ce6a 100644 --- a/setup/class_setup.inc +++ b/setup/class_setup.inc @@ -33,12 +33,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 () { - $this->o_steps = array( + $this->o_steps = [ new setupStepWelcome($this), new setupStepLanguage($this), new setupStepChecks($this), @@ -46,7 +46,7 @@ class setup new setupStepConfig_before_init($this), new setupStepMigrate($this), new setupStepFinish($this), - ); + ]; $this->i_steps = count($this->o_steps); diff --git a/setup/class_setupStep.inc b/setup/class_setupStep.inc index 7f0ebea2d2ada9232989e5c0a6c4b8995ec198bd..6e0907924534e79ca63588ff76b86a660cd015c5 100644 --- a/setup/class_setupStep.inc +++ b/setup/class_setupStep.inc @@ -33,7 +33,7 @@ class setupStep extends simplePlugin static function getAttributesInfo (): array { - return array(); + return []; } function __construct ($parent) @@ -95,7 +95,7 @@ class setupStep extends simplePlugin /* Return attributes handled by this setup step */ function get_attributes () { - $tmp = array(); + $tmp = []; foreach (array_keys($this->attributesAccess) as $attr) { $tmp[$attr] = $this->$attr; } diff --git a/setup/class_setupStepChecks.inc b/setup/class_setupStepChecks.inc index 84cc9cdfc5b2b69a15fd1606641eccd588f803c8..6d9ecd4b6bfa70d8aaab288e8b3c1720f9522d57 100644 --- a/setup/class_setupStepChecks.inc +++ b/setup/class_setupStepChecks.inc @@ -25,22 +25,22 @@ class setupStepChecks extends setupStep static function getAttributesInfo (): array { - 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 (<a href="?info" target="_blank">show information</a>)'), 'template' => get_template_path("setup_checks.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( + 'attrs' => [ new FakeAttribute('config_checks') - ) - ) - ); + ] + ] + ]; } function update_strings () @@ -60,8 +60,8 @@ class setupStepChecks extends setupStep /* Execute all 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 */ @@ -173,7 +173,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'register_globals' in your php.ini and switch it to 'Off'."); $R = ini_get("register_globals") == 0; $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 lifetime set to >=86400 seconds ? */ $N = "session.gc_maxlifetime >= <b>86400</b>"; @@ -182,7 +182,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'); @@ -191,7 +191,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>"; @@ -199,7 +199,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>"; @@ -207,7 +207,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>"; @@ -215,7 +215,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>"; @@ -223,7 +223,7 @@ 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 ]; /* Emulating old stuff? */ $N = "zend.ze1_compatibility_mode = <b>"._("Off")."</b>"; @@ -231,7 +231,7 @@ class setupStepChecks extends setupStep $S = _("Search for 'zend.ze1_compatibility_mode' in your php.ini and set it to 'Off'."); $R = !ini_get('zend.ze1_compatibility_mode'); $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; @@ -243,7 +243,7 @@ class setupStepChecks extends setupStep /* 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 11e34ea16bc69ead7e77e4fdeebb2b7ca700e4fb..b9db000c2fabb5568c319b0a765a5e0a02a67d1a 100644 --- a/setup/class_setupStepConfig.inc +++ b/setup/class_setupStepConfig.inc @@ -43,11 +43,11 @@ class setupStepConfig extends configInLdap var $is_completed = FALSE; var $header_image; - protected $objectclasses = array('fusionDirectoryConf'); + protected $objectclasses = ['fusionDirectoryConf']; static function plInfo (): array { - return array(); + return []; } function __construct ($parent, $cv) @@ -55,8 +55,8 @@ class setupStepConfig extends configInLdap 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']; } @@ -87,7 +87,7 @@ class setupStepConfig extends configInLdap /* Return attributes handled by this setup step */ function get_attributes () { - $tmp = array(); + $tmp = []; foreach (array_keys($this->attributesAccess) as $attr) { $tmp[$attr] = $this->$attr; } diff --git a/setup/class_setupStepFinish.inc b/setup/class_setupStepFinish.inc index 2c5ba31e89a63ddc6cba2e287c35c3f697dfc6de..e8dd618a72d37d600fe06e7b375c59be406c4c1a 100644 --- a/setup/class_setupStepFinish.inc +++ b/setup/class_setupStepFinish.inc @@ -25,14 +25,14 @@ class setupStepFinish extends setupStep static function getAttributesInfo (): array { - return array( - 'welcome' => array( + return [ + 'welcome' => [ 'name' => _('Welcome'), 'template' => get_template_path("setup_finish.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( - ) - ) - ); + 'attrs' => [ + ] + ] + ]; } function update_strings () diff --git a/setup/class_setupStepLanguage.inc b/setup/class_setupStepLanguage.inc index 4c0307a461a8080f9478150e7d62f4d94de1cc17..90121d9943949512f6fb9b15500efe571052bed3 100644 --- a/setup/class_setupStepLanguage.inc +++ b/setup/class_setupStepLanguage.inc @@ -25,11 +25,11 @@ class setupStepLanguage extends setupStep static function getAttributesInfo (): array { - 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,9 +42,9 @@ class setupStepLanguage extends setupStep 'lang', FALSE, 'en_EN' ) - ) - ) - ); + ] + ] + ]; } function __construct ($parent) @@ -66,7 +66,7 @@ class setupStepLanguage extends setupStep { $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(); } diff --git a/setup/class_setupStepLdap.inc b/setup/class_setupStepLdap.inc index 33dd780160ee20686c29e49a7ec6f822035a141f..922b2b3cfe280985bc9ab93c7c32b6be48960214 100644 --- a/setup/class_setupStepLdap.inc +++ b/setup/class_setupStepLdap.inc @@ -28,10 +28,10 @@ class setupStepLdap extends setupStep static function getAttributesInfo (): array { - 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, @@ -50,15 +50,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, @@ -67,7 +67,7 @@ class setupStepLdap extends setupStep new DisplayAttribute( '', '', 'base_append' ) - ), + ], '^(.+)(.*)$', '%s%s', '', @@ -77,18 +77,18 @@ 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) @@ -204,7 +204,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 00d47979386d3cb639552ae6d8630eb630c7aee7..6c491496e79a965f6bf1040f0b3f0e98f059ac17 100644 --- a/setup/class_setupStepMigrate.inc +++ b/setup/class_setupStepMigrate.inc @@ -181,35 +181,35 @@ 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 (): array { - 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) @@ -227,26 +227,26 @@ class setupStepMigrate extends setupStep 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 () @@ -254,7 +254,7 @@ class setupStepMigrate extends setupStep 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')), @@ -265,7 +265,7 @@ 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; } @@ -335,8 +335,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. @@ -473,7 +473,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'; @@ -495,7 +495,7 @@ class setupStepMigrate extends setupStep $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']) @@ -506,7 +506,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']) @@ -529,7 +529,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']); @@ -543,7 +543,7 @@ class setupStepMigrate extends setupStep '(!(objectClass=inetOrgPerson))'. '(uid=*)'. ')', - array('sn','givenName','cn','uid') + ['sn','givenName','cn','uid'] ); while ($attrs = $ldap->fetch()) { @@ -583,10 +583,10 @@ class setupStepMigrate extends setupStep { $this->check_multipleGeneric_migrate( $checkobj, - array( + [ 'title' => _('User migration'), 'outside' => FALSE, - ) + ] ); } @@ -594,10 +594,10 @@ class setupStepMigrate extends setupStep { return $this->check_multipleGeneric_migrate_refresh( $checkobj, - array( + [ 'title' => _('User migration'), 'outside' => FALSE, - ) + ] ); } @@ -605,8 +605,8 @@ class setupStepMigrate extends setupStep { return $this->check_multipleGeneric_migrate_confirm( $checkobj, - array('inetOrgPerson','organizationalPerson','person'), - array(), + ['inetOrgPerson','organizationalPerson','person'], + [], $only_ldif ); } @@ -653,11 +653,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'])) { @@ -719,8 +719,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]; @@ -729,13 +729,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]; } @@ -754,7 +754,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) { @@ -831,11 +831,11 @@ class setupStepMigrate extends setupStep function check_adminAccount_create (&$checkobj) { - $infos = array( + $infos = [ 'uid' => 'fd-admin', 'password' => '', 'password2' => '', - ); + ]; $this->openDialog(new StepMigrateDialog($checkobj, 'setup_migrate_adminAccount.tpl', $infos)); } @@ -849,7 +849,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 { @@ -858,7 +858,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; @@ -885,11 +885,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(); @@ -899,11 +899,11 @@ class setupStepMigrate extends setupStep 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 */ @@ -924,7 +924,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++; } @@ -989,7 +989,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'), @@ -1000,7 +1000,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()) { @@ -1033,12 +1033,12 @@ class setupStepMigrate extends setupStep 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'] : ''), - ) + ] ); } @@ -1047,12 +1047,12 @@ class setupStepMigrate extends setupStep 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'] : ''), - ) + ] ); } @@ -1081,7 +1081,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']; @@ -1112,7 +1112,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'), @@ -1120,7 +1120,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']); @@ -1152,12 +1152,12 @@ class setupStepMigrate extends setupStep 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'] : ''), - ) + ] ); } @@ -1166,12 +1166,12 @@ class setupStepMigrate extends setupStep 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'] : ''), - ) + ] ); } @@ -1187,15 +1187,15 @@ class setupStepMigrate extends setupStep $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'] != '')) { @@ -1205,7 +1205,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'), @@ -1260,10 +1260,10 @@ class setupStepMigrate extends setupStep { $this->check_multipleGeneric_migrate( $checkobj, - array( + [ 'title' => _('Department migration'), 'outside' => FALSE, - ) + ] ); } @@ -1271,10 +1271,10 @@ class setupStepMigrate extends setupStep { return $this->check_multipleGeneric_migrate_refresh( $checkobj, - array( + [ 'title' => _('Department migration'), 'outside' => FALSE, - ) + ] ); } @@ -1282,8 +1282,8 @@ class setupStepMigrate extends setupStep { return $this->check_multipleGeneric_migrate_confirm( $checkobj, - array('gosaDepartment'), - array('description' => 'FusionDirectory department'), + ['gosaDepartment'], + ['description' => 'FusionDirectory department'], $only_ldif ); } @@ -1295,7 +1295,7 @@ class setupStepMigrate extends setupStep $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'), @@ -1303,8 +1303,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,7 +1339,7 @@ class setupStepMigrate extends setupStep $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'), @@ -1347,8 +1347,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 178309c2eaffc577bd9bc6d4ed784e364c37c751..4e4f9776915c0ddd3371915dcff7496e4d2311aa 100644 --- a/setup/class_setupStepWelcome.inc +++ b/setup/class_setupStepWelcome.inc @@ -25,14 +25,14 @@ class setupStepWelcome extends setupStep static function getAttributesInfo (): array { - return array( - 'welcome' => array( + return [ + 'welcome' => [ 'name' => _('Welcome'), 'template' => get_template_path("setup_welcome.tpl", TRUE, dirname(__FILE__)), - 'attrs' => array( - ) - ) - ); + 'attrs' => [ + ] + ] + ]; } function __construct ($parent)