diff --git a/include/management/actions/class_Action.inc b/include/management/actions/class_Action.inc index 6622b654f6f7b5c6141e2af098d0ab37269d4c83..706b3215148248249563731da88ca5262cfee750 100755 --- a/include/management/actions/class_Action.inc +++ b/include/management/actions/class_Action.inc @@ -77,17 +77,17 @@ class Action $category = NULL; $class = NULL; $attribute = '0'; - if (str_contains((string) $acl, '/')) { - list($category, $class, $acl) = explode('/', (string) $acl, 3); + if (strpos($acl, '/') !== FALSE) { + list($category, $class, $acl) = explode('/', $acl, 3); } - if (str_contains((string) $acl, ':')) { - list($attribute, $acl) = explode(':', (string) $acl, 2); + if (strpos($acl, ':') !== FALSE) { + list($attribute, $acl) = explode(':', $acl, 2); } $this->acl[] = [ 'category' => $category, 'class' => $class, 'attribute' => $attribute, - 'acl' => str_split((string) $acl), + 'acl' => str_split($acl), ]; } @@ -275,7 +275,7 @@ class Action // Check rights foreach ($acl['acl'] as $part) { - if (!str_contains((string) $checkAcl, (string) $part)) { + if (strpos($checkAcl, $part) === FALSE) { return FALSE; } } diff --git a/include/management/class_ListingEntry.inc b/include/management/class_ListingEntry.inc index c8802cb344d0f6ea7ed2b0a1c6b6b40848797586..759c6acb95f1d05330456f476ee3830e76973dde 100755 --- a/include/management/class_ListingEntry.inc +++ b/include/management/class_ListingEntry.inc @@ -84,12 +84,12 @@ class ListingEntry implements ArrayAccess public function isTemplate (): bool { - return preg_match('/^template_/', (string) $this->type); + return preg_match('/^template_/', $this->type); } public function getTemplatedType (): string { - return preg_replace('/^template_/', '', (string) $this->type); + return preg_replace('/^template_/', '', $this->type); } public function getTemplatedFields (): array @@ -104,7 +104,7 @@ class ListingEntry implements ArrayAccess $infos = objects::infos($this->getTemplatedType()); $rights = $ui->get_permissions($this->aclBase, $infos['aclCategory'].'/'.($this->isTemplate() ? 'template' : $infos['mainTab'])); foreach (str_split($acls) as $acl) { - if (!str_contains((string) $rights, $acl)) { + if (strpos($rights, $acl) === FALSE) { return FALSE; } } diff --git a/include/management/class_ManagementConfigurationDialog.inc b/include/management/class_ManagementConfigurationDialog.inc index 72736c1bd5e48eaa31dd6ebbf09d8f02cd996347..d0dfa4d89a3a8231e14c07234d16a9199c654a92 100755 --- a/include/management/class_ManagementConfigurationDialog.inc +++ b/include/management/class_ManagementConfigurationDialog.inc @@ -128,10 +128,10 @@ class ManagementConfigurationDialog extends ManagementDialog $this->attributesAccess['resetInLdap']->setVisible(FALSE); } - if (!$config->hasManagementConfig($this->parent::class, TRUE)) { + if (!$config->hasManagementConfig(get_class($this->parent), TRUE)) { $this->attributesAccess['resetInLdapUser']->setVisible(FALSE); } - if (!$config->hasManagementConfig($this->parent::class, FALSE)) { + if (!$config->hasManagementConfig(get_class($this->parent), FALSE)) { $this->attributesAccess['resetInLdap']->setVisible(FALSE); } @@ -169,7 +169,7 @@ class ManagementConfigurationDialog extends ManagementDialog return TRUE; } elseif ((is_object($attr) && in_array($attr->getLdapName(), $configAttrs)) || in_array($attr, $configAttrs)) { $acl = $ui->get_permissions(CONFIGRDN.$config->current['BASE'], 'configuration/configInLdap', 'fdManagementConfig', $this->readOnly()); - return (str_contains((string) $acl, 'w')); + return (strpos($acl, 'w') !== FALSE); } else { return parent::attrIsWriteable($attr); } @@ -178,7 +178,7 @@ class ManagementConfigurationDialog extends ManagementDialog function handle_resetInLdapUser () { global $config; - $errors = $config->updateManagementConfig($this->parent::class, NULL, TRUE); + $errors = $config->updateManagementConfig(get_class($this->parent), NULL, TRUE); msg_dialog::displayChecks($errors); if (empty($errors)) { $this->attributesAccess['resetInLdapUser']->setVisible(FALSE); @@ -188,7 +188,7 @@ class ManagementConfigurationDialog extends ManagementDialog function handle_resetInLdap () { global $config; - $errors = $config->updateManagementConfig($this->parent::class, NULL, FALSE); + $errors = $config->updateManagementConfig(get_class($this->parent), NULL, FALSE); msg_dialog::displayChecks($errors); if (empty($errors)) { $this->attributesAccess['resetInLdap']->setVisible(FALSE); @@ -213,7 +213,7 @@ class ManagementConfigurationDialog extends ManagementDialog foreach ($values as $value) { $column = [$value[0], []]; if (!empty($value[1])) { - $jsonDecoded = json_decode((string) $value[1], TRUE); + $jsonDecoded = json_decode($value[1], TRUE); if ($jsonDecoded !== NULL) { $column[1]['attributes'] = $jsonDecoded; } else { @@ -228,11 +228,11 @@ class ManagementConfigurationDialog extends ManagementDialog $this->parent->setColumnConfiguration($columnInfos); if ($this->saveInLdapUser) { - return $config->updateManagementConfig($this->parent::class, $columnInfos, TRUE); + return $config->updateManagementConfig(get_class($this->parent), $columnInfos, TRUE); } if ($this->saveInLdap) { - return $config->updateManagementConfig($this->parent::class, $columnInfos); + return $config->updateManagementConfig(get_class($this->parent), $columnInfos); } return []; diff --git a/include/management/class_management.inc b/include/management/class_management.inc index f1b903074f0ad9afe09e4cefb27a2bbd995787f1..d613a0c2c65c3b9a34112baec3d8a4b2de645a6b 100755 --- a/include/management/class_management.inc +++ b/include/management/class_management.inc @@ -99,11 +99,11 @@ class management implements FusionDirectoryDialog global $config, $class_mapping; if ($objectTypes === FALSE) { - $plInfos = pluglist::pluginInfos(static::class); + $plInfos = pluglist::pluginInfos(get_class($this)); $objectTypes = $plInfos['plManages']; } - if (!preg_match('/^geticon/', (string) $this->icon)) { + if (!preg_match('/^geticon/', $this->icon)) { $this->icon = get_template_path($this->icon); } @@ -111,8 +111,8 @@ class management implements FusionDirectoryDialog foreach ($objectTypes as $key => $type) { try { objects::infos($type); - $objectTypes[$key] = strtoupper((string) $type); - } catch (NonExistingObjectTypeException) { + $objectTypes[$key] = strtoupper($type); + } catch (NonExistingObjectTypeException $e) { unset($objectTypes[$key]); } } @@ -156,7 +156,7 @@ class management implements FusionDirectoryDialog protected function setUpHeadline () { - $plInfos = pluglist::pluginInfos(static::class); + $plInfos = pluglist::pluginInfos(get_class($this)); $this->headline = $plInfos['plShortName']; $this->title = $plInfos['plTitle']; @@ -269,7 +269,7 @@ class management implements FusionDirectoryDialog ['w'] ) ); - $this->actions['paste']->setEnableFunction($this->enablePaste(...)); + $this->actions['paste']->setEnableFunction([$this, 'enablePaste']); } if (!static::$skipTemplates) { @@ -317,7 +317,7 @@ class management implements FusionDirectoryDialog ) ); $this->actions['snapshot']->setSeparator(TRUE); - $this->actions['restore']->setEnableFunction($this->enableSnapshotRestore(...)); + $this->actions['restore']->setEnableFunction([$this, 'enableSnapshotRestore']); } if (!static::$skipTemplates) { @@ -362,7 +362,7 @@ class management implements FusionDirectoryDialog if (!isset($this->columnConfiguration)) { // LDAP configuration - $this->columnConfiguration = $config->getManagementConfig(static::class); + $this->columnConfiguration = $config->getManagementConfig(get_class($this)); } if (!isset($this->columnConfiguration)) { @@ -430,8 +430,8 @@ class management implements FusionDirectoryDialog protected function handleSubAction (array $action): bool { - if (preg_match('/^tab_/', (string) $action['subaction'])) { - $tab = preg_replace('/^tab_/', '', (string) $action['subaction']); + if (preg_match('/^tab_/', $action['subaction'])) { + $tab = preg_replace('/^tab_/', '', $action['subaction']); if (isset($this->tabObject->by_object[$tab])) { $this->tabObject->current = $tab; } else { @@ -768,7 +768,7 @@ class management implements FusionDirectoryDialog if (static::$skipTemplates) { return; } - $type = preg_replace('/^template_/', '', (string) $action['subaction']); + $type = preg_replace('/^template_/', '', $action['subaction']); $this->currentDn = 'new'; @@ -793,7 +793,7 @@ class management implements FusionDirectoryDialog } $type = $this->listing->getEntry($dn)->getTemplatedType(); } else { - $type = preg_replace('/^apply_/', '', (string) $action['subaction']); + $type = preg_replace('/^apply_/', '', $action['subaction']); } $this->dialogObject = new templateDialog($this, $type, $dn); } @@ -1124,7 +1124,7 @@ class management implements FusionDirectoryDialog } else { $error = new FusionDirectoryPermissionError(msgPool::permDelete($dn)); $error->display(); - logging::log('security', 'management/' . static::class, $dn, [], 'Tried to trick deletion.'); + logging::log('security', 'management/' . get_class($this), $dn, [], 'Tried to trick deletion.'); } } diff --git a/include/management/class_managementFilter.inc b/include/management/class_managementFilter.inc index 7cdfb3342f05de86fb5ef61e42cfdde6e69f9c85..aa58142c3658af696abb09ecc911e9ea4d2660d9 100755 --- a/include/management/class_managementFilter.inc +++ b/include/management/class_managementFilter.inc @@ -120,7 +120,7 @@ class managementFilter $this->parent->listing->fillSearchedAttributes($type, $attrs); foreach ($attrs as $attr => $acl) { $rights = $ui->get_permissions($base, $acl, $attr); - if (str_contains((string) $rights, 'r')) { + if (strpos($rights, 'r') !== FALSE) { $this->searchAttributes[$type][] = $attr; } } @@ -143,12 +143,12 @@ class managementFilter $searchAttrs = []; foreach ($this->searchAttributes as $type => $attrs) { foreach ($attrs as $attr) { - $searchAttrs[] = strtolower((string) $type).'/'.$attr; + $searchAttrs[] = strtolower($type).'/'.$attr; } } $smarty->assign('SEARCHDESC', sprintf(_('Searches in %s'), implode(', ', $searchAttrs))); - $parentClass = $this->parent::class; + $parentClass = get_class($this->parent); if (!$parentClass::$skipTemplates) { $smarty->assign('TEMPLATES', $this->showTemplates); } @@ -201,7 +201,7 @@ class managementFilter $elementFilters = []; if (!empty($this->search)) { - if (preg_match('/^\(.+\)$/', (string) $this->search)) { + if (preg_match('/^\(.+\)$/', $this->search)) { $elementFilters[] = $this->search; } else { $searchAttributesTmp = $this->searchAttributes[$type]; @@ -224,7 +224,7 @@ class managementFilter $filter = '(&'.implode('', $typeElementFilters).')'; } - $parentClass = $this->parent::class; + $parentClass = get_class($this->parent); if (!$parentClass::$skipTemplates && $this->showTemplates) { try { $ldapEntries = objects::ls($type, $attrsAsked, (($this->scope == 'one') ? 'ou=templates,'.$searchBase : $searchBase), $filter, TRUE, $this->scope, TRUE); @@ -290,7 +290,7 @@ class managementFilter continue; } foreach ($this->parent->whiteList['branches'] as $branch) { - if (preg_match('/'.preg_quote((string) $branch, '/').'$/', $dn)) { + if (preg_match('/'.preg_quote($branch, '/').'$/', $dn)) { continue 2; } } diff --git a/include/management/class_managementListing.inc b/include/management/class_managementListing.inc index c9ed3b689376d4e0e451b369461e74d79a9b5aa8..a80f5f6028b519513da134b3b543c2b3e7f40b64 100755 --- a/include/management/class_managementListing.inc +++ b/include/management/class_managementListing.inc @@ -293,7 +293,7 @@ class managementListing if ($action == 'ROOT') { $this->setBase(key($this->bases)); } elseif ($action == 'BACK') { - $parentBase = preg_replace('/^[^,]+,/', '', (string) $this->base); + $parentBase = preg_replace('/^[^,]+,/', '', $this->base); $this->tryAndSetBase($parentBase); } elseif ($action == 'HOME') { $ui = get_userinfo(); @@ -472,7 +472,7 @@ class managementListing } } elseif (isset($_REQUEST['dn']) && preg_match('/^listing_([[:alnum:]_\.]+)$/', $key, $m)) { /* Pre-render list to init things if a dn is gonna be opened on first load */ - $dn = urldecode((string) $_REQUEST['dn']); + $dn = urldecode($_REQUEST['dn']); $this->focusDn($dn); $this->render(); @@ -516,8 +516,8 @@ class managementListing } } - if (str_contains((string) $result['action'], '_')) { - list($result['action'], $result['subaction']) = explode('_', (string) $result['action'], 2); + if (strpos($result['action'], '_') !== FALSE) { + list($result['action'], $result['subaction']) = explode('_', $result['action'], 2); } return $result; } diff --git a/include/management/columns/class_Column.inc b/include/management/columns/class_Column.inc index fe8158d03d2d050037234881780d2d9a6465f037..f40ce0b4fb1a1b667dd5d6c8eda47709d8d1066c 100755 --- a/include/management/columns/class_Column.inc +++ b/include/management/columns/class_Column.inc @@ -50,7 +50,7 @@ class Column if (isset($data['attributes'])) { $attributes = $data['attributes']; if (!is_array($attributes)) { - $attributes = array_map('trim', explode(',', (string) $attributes)); + $attributes = array_map('trim', explode(',', $attributes)); } } if (isset($data['label'])) { @@ -216,9 +216,9 @@ class Column if ($b == '') { $b = '31.12.0000'; } - list($d, $m, $y) = explode('.', (string) $a); + list($d, $m, $y) = explode('.', $a); $a = (int)sprintf('%04d%02d%02d', $y, $m, $d); - list($d, $m, $y) = explode('.', (string) $b); + list($d, $m, $y) = explode('.', $b); $b = (int)sprintf('%04d%02d%02d', $y, $m, $d); return $b - $a; diff --git a/include/management/snapshot/class_SnapshotAttribute.inc b/include/management/snapshot/class_SnapshotAttribute.inc index d09e493237b2b5a623734d25e83b00dc1ac1b04d..895e2e677e4819632053b2149fb7aba3d6cd4c85 100755 --- a/include/management/snapshot/class_SnapshotAttribute.inc +++ b/include/management/snapshot/class_SnapshotAttribute.inc @@ -87,7 +87,7 @@ class SnapshotsAttribute extends OrderedArrayAttribute protected function getAttributeArrayValue ($key, $value) { $values = [ - date(_('Y-m-d, H:i:s'), preg_replace('/\-.*$/', '', (string) $value['gosaSnapshotTimestamp'][0])), + date(_('Y-m-d, H:i:s'), preg_replace('/\-.*$/', '', $value['gosaSnapshotTimestamp'][0])), $value['description'][0] ]; if ($this->plugin->global) { @@ -120,8 +120,8 @@ class SnapshotsAttribute extends OrderedArrayAttribute if (parent::handlePostValueActions($id, $postValue)) { return TRUE; } - if (preg_match('/^'.$id.'_restore_/', (string) $postValue)) { - $key = preg_replace('/^'.$id.'_restore_/', '', (string) $postValue); + if (preg_match('/^'.$id.'_restore_/', $postValue)) { + $key = preg_replace('/^'.$id.'_restore_/', '', $postValue); $key = preg_replace('/_[xy]$/', '', $key); $this->plugin->triggerRestore($this->value[$key]['dn']); diff --git a/include/management/snapshot/class_SnapshotHandler.inc b/include/management/snapshot/class_SnapshotHandler.inc index 15f4e224aed7f7628bad61a40357f71d5bd5143d..c95078c5a82d78595771f81549b56f5897ab1082 100755 --- a/include/management/snapshot/class_SnapshotHandler.inc +++ b/include/management/snapshot/class_SnapshotHandler.inc @@ -85,7 +85,7 @@ class SnapshotHandler protected function snapshot_dn ($dn) { global $config; - return preg_replace("/".preg_quote((string) $config->current['BASE'], '/')."$/", "", (string) $dn) + return preg_replace("/".preg_quote($config->current['BASE'], '/')."$/", "", $dn) .$this->snapshotRDN; } @@ -154,7 +154,7 @@ class SnapshotHandler $ldap = $config->get_ldap_link(); - $objectBase = preg_replace("/^[^,]*./", "", (string) $dn); + $objectBase = preg_replace("/^[^,]*./", "", $dn); // Initialize base $base = $this->snapshot_dn($objectBase); @@ -182,7 +182,7 @@ class SnapshotHandler } else { $tmp = []; foreach ($objects as $entry) { - $tmp[base64_encode((string) $entry['dn'])] = $entry['description'][0]; + $tmp[base64_encode($entry['dn'])] = $entry['description'][0]; } } return $tmp; @@ -227,7 +227,7 @@ class SnapshotHandler list($usec, $sec) = explode(" ", microtime()); /* Collect some infos */ - $base_of_object = preg_replace('/^[^,]+,/i', '', (string) $dn); + $base_of_object = preg_replace('/^[^,]+,/i', '', $dn); $new_base = $this->snapshot_dn($base_of_object); /* Create object */ $data = ''; @@ -318,7 +318,7 @@ class SnapshotHandler foreach ($dnSnapshotsList as $snap) { $snapCount += 1; // let's keep seconds instead of nanosecs - $snapEpoch = preg_split('/-/', (string) $snap['gosaSnapshotTimestamp'][0]); + $snapEpoch = preg_split('/-/', $snap['gosaSnapshotTimestamp'][0]); if ($snapEpoch[0] < $snapDateToDelete) { $snapToDelete[] = $snap['dn']; } @@ -373,7 +373,7 @@ class SnapshotHandler $ldap = $config->get_ldap_link(); /* Prepare bases and some other infos */ - $base_of_object = preg_replace('/^[^,]+,/i', '', (string) $dn); + $base_of_object = preg_replace('/^[^,]+,/i', '', $dn); $new_base = $this->snapshot_dn($base_of_object); $tmp = [];