diff --git a/html/index.php b/html/index.php index 075d948beff43988b32cad8b44f729090ccecfa9..bcd6e5fb7356c127fa59fabddf058cce933ca493 100644 --- a/html/index.php +++ b/html/index.php @@ -486,7 +486,7 @@ class Index { ); exit(); } - $ui = new userinfo($config, $attrs['dn']); + $ui = new userinfo($attrs['dn']); $ui->loadACL(); $success = static::runSteps(array( @@ -558,7 +558,7 @@ class Index { ); exit(); } - $ui = new userinfo($config, $attrs['dn']); + $ui = new userinfo($attrs['dn']); $ui->loadACL(); $success = static::runSteps(array( diff --git a/include/class_ldap.inc b/include/class_ldap.inc index bf21f732b0a69b089f9c1f41766dea823282285d..2c0cc24b0a56b9491672e99e9670bad176b257a2 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -578,25 +578,31 @@ class LDAP function rm($attrs = "", $dn = "") { if ($this->hascon) { - if ($this->reconnect) $this->connect(); - if ($dn == "") + if ($this->reconnect) { + $this->connect(); + } + if ($dn == '') { $dn = $this->basedn; + } $r = ldap_mod_del($this->cid, LDAP::fix($dn), $attrs); $this->error = @ldap_error($this->cid); return $r; } else { - $this->error = "Could not connect to LDAP server"; - return ""; + $this->error = 'Could not connect to LDAP server'; + return ''; } } function mod_add($attrs = "", $dn = "") { if ($this->hascon) { - if ($this->reconnect) $this->connect(); - if ($dn == "") + if ($this->reconnect) { + $this->connect(); + } + if ($dn == "") { $dn = $this->basedn; + } $r = @ldap_mod_add($this->cid, LDAP::fix($dn), $attrs); $this->error = @ldap_error($this->cid); @@ -615,7 +621,9 @@ class LDAP function rmdir($deletedn) { if ($this->hascon) { - if ($this->reconnect) $this->connect(); + if ($this->reconnect) { + $this->connect(); + } $r = @ldap_delete($this->cid, LDAP::fix($deletedn)); $this->error = @ldap_error($this->cid); return ($r ? $r : 0); @@ -660,7 +668,9 @@ class LDAP $dest_rdn = preg_replace("/,.*$/", "", $dest); if ($this->hascon) { - if ($this->reconnect) $this->connect(); + if ($this->reconnect) { + $this->connect(); + } $r = ldap_rename($this->cid, @LDAP::fix($source), @LDAP::fix($dest_rdn), @LDAP::fix($parent), FALSE); $this->error = ldap_error($this->cid); @@ -689,7 +699,9 @@ class LDAP function rmdir_recursive($srp, $deletedn) { if ($this->hascon) { - if ($this->reconnect) $this->connect(); + if ($this->reconnect) { + $this->connect(); + } $delarray = array(); /* Get sorted list of dn's to delete */ @@ -749,7 +761,9 @@ class LDAP return 0; } if ($this->hascon) { - if ($this->reconnect) $this->connect(); + if ($this->reconnect) { + $this->connect(); + } $r = @ldap_modify($this->cid, LDAP::fix($this->basedn), $attrs); $this->error = @ldap_error($this->cid); if (!$this->success()) { @@ -770,7 +784,9 @@ class LDAP function add($attrs) { if ($this->hascon) { - if ($this->reconnect) $this->connect(); + if ($this->reconnect) { + $this->connect(); + } $r = @ldap_add($this->cid, LDAP::fix($this->basedn), $attrs); $this->error = @ldap_error($this->cid); if (!$this->success()) { @@ -875,7 +891,9 @@ class LDAP // Fill in MUST values - but do not overwrite existing ones. if (is_array($classes[$ocname]['MUST'])) { foreach ($classes[$ocname]['MUST'] as $attr) { - if (isset($na[$attr]) && !empty($na[$attr])) continue; + if (isset($na[$attr]) && !empty($na[$attr])) { + continue; + } $na[$attr] = 'filled'; } } diff --git a/include/class_listing.inc b/include/class_listing.inc index 53a4edf48ca45ceebeeb120fb838001875458d69..5c8df9860c242f924487d8933b0d4eca147cdc55 100644 --- a/include/class_listing.inc +++ b/include/class_listing.inc @@ -1050,7 +1050,7 @@ class listing { $cut = !isset($action['cut']) || $action['cut'] == "true"; $result .= $this->renderCopyPasteActions($row, $this->entries[$row]['dn'], $category, $class, $copy, $cut); } else { - $result .= $this->renderSnapshotActions($row, $this->entries[$row]['dn'], $category, $class); + $result .= $this->renderSnapshotActions($row, $this->entries[$row]['dn'], $category); } } } @@ -1639,7 +1639,7 @@ class listing { // Render copy entries if ($copy) { - if ($ui->is_copyable($dn, $category, $class)) { + if ($ui->is_copyable($dn, $category)) { $result .= '<input class="center" type="image"'. ' src="geticon.php?context=actions&icon=edit-copy&size=16"'. ' alt="'._('Copy').'" name="listing_copy_'.$row.'" title="'._('Copy this entry').'"'. @@ -1705,44 +1705,43 @@ class listing { } - function renderSnapshotActions($row, $dn, $category, $class, $copy = TRUE, $cut = TRUE) + function renderSnapshotActions($row, $dn, $category) { - // We can only provide information if we've got a snapshot handler - // instance - if (!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))) { - return ""; + /* We can only provide information if we've got a snapshot handler instance */ + if (!isset($this->snapshotHandler) || !is_object($this->snapshotHandler) || !$this->snapshotHandler->enabled()) { + return ''; } // Presets - $result = ""; + $result = ''; $ui = get_userinfo(); - // Only act if enabled here - if ($this->snapshotHandler->enabled()) { - - // Draw restore button - if ($ui->allow_snapshot_restore($dn, $category)) { - - // Do we have snapshots for this dn? - if ($this->snapshotHandler->hasSnapshots($dn)) { - $result .= "<input class='center' type='image' src='geticon.php?context=actions&icon=document-restore&size=16' ". - "alt='"._("Restore snapshot")."' name='listing_restore_$row' title='". - _("Restore snapshot")."' style='padding:1px'>"; - } else { - $result .= "<img src='geticon.php?context=actions&icon=document-restore&size=16&disabled=1' alt='restore' class='center' style='padding:1px'>"; - } - } + if ($ui->allow_snapshot_restore($dn, $category)) { + /* Draw restore button */ - // Draw snapshot button - if ($ui->allow_snapshot_create($dn, $category)) { - $result .= "<input class='center' type='image' src='geticon.php?context=actions&icon=snapshot&size=16' ". - "alt='"._("Create snapshot")."' name='listing_snapshot_$row' title='". - _("Create a new snapshot from this object")."' style='padding:1px'>"; + if ($this->snapshotHandler->hasSnapshots($dn)) { + /* We have snapshots for this dn */ + $result .= '<input class="center" type="image"'. + ' src="geticon.php?context=actions&icon=document-restore&size=16"'. + ' alt="'._('Restore snapshot').'" name="listing_restore_'.$row.'"'. + ' title="'._('Restore snapshot').'" style="padding:1px"/>'; } else { - $result .= "<img src='images/empty.png' alt=' ' class='center optional' style='padding:1px'>"; + $result .= '<img class="center"'. + ' src="geticon.php?context=actions&icon=document-restore&size=16&disabled=1"'. + ' alt="restore" style="padding:1px"/>'; } } + if ($ui->allow_snapshot_create($dn, $category)) { + /* Draw snapshot button */ + $result .= '<input class="center" type="image"'. + ' src="geticon.php?context=actions&icon=snapshot&size=16"'. + ' alt="'._('Create snapshot').'" name="listing_snapshot_'.$row.'"'. + ' title="'._('Create a new snapshot from this object').'" style="padding:1px"/>'; + } else { + $result .= '<img src="images/empty.png" alt=" " class="center optional" style="padding:1px"/>'; + } + return $result; } diff --git a/include/class_management.inc b/include/class_management.inc index fc662e5911fe966e4d28bf8d7145c5a45e2ea96e..021eba736cd3fd79a9f7e116331803aa334bf079 100644 --- a/include/class_management.inc +++ b/include/class_management.inc @@ -190,7 +190,9 @@ class management } // No bases specified? Try base - if (!count($bases)) $bases[] = $this->headpage->getBase(); + if (!count($bases)) { + $bases[] = $this->headpage->getBase(); + } $this->snapHandler->setSnapshotBases($bases); } @@ -284,9 +286,13 @@ class management return array(); } $action = $this->headpage->getAction(); - if (isset($_POST['edit_apply'])) $action['action'] = 'apply'; - if (isset($_POST['edit_finish'])) $action['action'] = 'save'; - if (isset($_POST['edit_cancel'])) $action['action'] = 'cancel'; + if (isset($_POST['edit_cancel'])) { + $action['action'] = 'cancel'; + } elseif (isset($_POST['edit_finish'])) { + $action['action'] = 'save'; + } elseif (isset($_POST['edit_apply'])) { + $action['action'] = 'apply'; + } if (!$this->is_modal_dialog()) { if (isset($_POST['delete_confirmed'])) { $action['action'] = 'removeConfirmed'; diff --git a/include/class_msgPool.inc b/include/class_msgPool.inc index f3b449c473758eb6de9e9803c91e860d4a53d33a..ea72f92e561715aa8d1327d999f5e3a83ad770a8 100644 --- a/include/class_msgPool.inc +++ b/include/class_msgPool.inc @@ -522,17 +522,17 @@ class msgPool { * * \param string $what Text for the button */ - public static function editButton($what = "") + public static function editButton($what = '') { - return ($what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what)); + return (($what == '') ? sprintf(_('Edit...')) : sprintf(_('Edit %s...'), $what)); } /*! * \brief Text for a back button */ - public static function backButton($what = "") + public static function backButton() { - return _("Back"); + return _('Back'); } /*! @@ -668,20 +668,6 @@ class msgPool { return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")); } - /*! - * \brief Display error about database - * - * \param string $error Error to display - * - * \param string $plugin - */ - public static function dbError($error, $plugin = "") - { - /* Assign headline depending on type */ - $headline = _("Database operation failed!"); - return $headline."<br><br><i>"._("Error").":</i> ".$error; - } - /*! * \brief Display LDAP error * @@ -693,24 +679,24 @@ class msgPool { * * \param string $plugin */ - public static function ldaperror($error, $dn = "", $type = 0, $plugin = "") + 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 = array(1 => _('read operation'), _('add operation'), _('modify operation'), + _('delete operation'), _('search operation'), _('authentication')); if (isset($typemap[$type])) { - $headline = sprintf(_("LDAP %s failed!"), $typemap[$type]); + $headline = sprintf(_('LDAP %s failed!'), $typemap[$type]); } else { - $headline = _("LDAP operation failed!"); + $headline = _('LDAP operation failed!'); } /* Fill DN information */ - if ($dn != "") { - $dn_info = "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn); + if ($dn != '') { + $dn_info = '<br/><br/><i>'._('Object').':</i> '.LDAP::fix($dn); } - return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error; + return $headline.$dn_info.'<br/><br/><i>'._('Error').':</i> '.$error; } /*! diff --git a/include/class_plugin.inc b/include/class_plugin.inc index ef025c26b8503d2958c800462a181a41e4ed4bf4..a534bf682acc23e22b95bb993b9433e30b2664e6 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -1165,10 +1165,8 @@ class plugin * \param string $old_dn specifies the actually used dn * * \param string $new_dn specifies the destiantion dn - * - * \param boolean $output_changes FALSE */ - function update_acls($old_dn, $new_dn, $output_changes = FALSE) + function update_acls($old_dn, $new_dn) { /* Check if old_dn is empty. This should never happen */ if (empty($old_dn) || empty($new_dn)) { diff --git a/include/class_pluglist.inc b/include/class_pluglist.inc index 5ec8cbfebe43ebea63515ed6746f6fdabf1f129a..d24a656f744b321be809beaf9001608f5df13a2e 100644 --- a/include/class_pluglist.inc +++ b/include/class_pluglist.inc @@ -225,7 +225,7 @@ class pluglist { return TRUE; } } else { - if ($ui->get_category_permissions($ui->dn, $acl_to_check, "") != "") { + if ($ui->get_category_permissions($ui->dn, $acl_to_check) != '') { $this->silly_cache[$aclname] = TRUE; return TRUE; } diff --git a/include/class_tests.inc b/include/class_tests.inc index bba1ba5e9ce2feced30ccb3fea04902266101de1..a968bd4b0c76a6208e1ed6f9c8b8518a8e5d39b3 100644 --- a/include/class_tests.inc +++ b/include/class_tests.inc @@ -265,10 +265,8 @@ class tests { * \brief Check if the given argument is an email * * \param string $address The email address - * - * \param boolean $template FALSE */ - public static function is_email($address, $deprecated = FALSE) + public static function is_email($address) { if ($address == "") { return TRUE; diff --git a/include/class_userinfo.inc b/include/class_userinfo.inc index e5ffcea9f3c92bd6e54c344a2ff96408c37358ee..7d647e6e0e7f1cb895004f49890056d938f70664 100644 --- a/include/class_userinfo.inc +++ b/include/class_userinfo.inc @@ -52,7 +52,7 @@ class userinfo /* get acl's an put them into the userinfo object attr subtreeACL (userdn:components, userdn:component1#sub1#sub2,component2,...) */ - function __construct($unused, $userdn) + function __construct($userdn) { global $config; $ldap = $config->get_ldap_link(); @@ -284,13 +284,11 @@ class userinfo * * \param string $category Category for which we want the acl eg: server * - * \param bool $any_acl FALSE - * * \return all the permissions for the dn and category */ - function get_category_permissions($dn, $category, $any_acl = FALSE) + function get_category_permissions($dn, $category) { - return @$this->get_permissions($dn, $category.'/0', ""); + return @$this->get_permissions($dn, $category.'/0', ''); } @@ -301,13 +299,11 @@ class userinfo * * \param string $object The acl category (e.g. user) * - * \param string $class The acl class (e.g. user) - * * \return boolean TRUE if the given object is copyable else FALSE */ - function is_copyable($dn, $object, $class) + function is_copyable($dn, $object) { - return preg_match("/r/", $this->get_complete_category_acls($dn, $object)); + return preg_match('/r/', $this->get_complete_category_acls($dn, $object)); } @@ -666,12 +662,14 @@ class userinfo /* For all gosaDepartments */ foreach ($config->departments as $dn) { - if (isset($deps[$dn])) continue; - $acl = ""; + if (isset($deps[$dn])) { + continue; + } + $acl = ''; if (strpos($mod, '/')) { $acl .= $this->get_permissions($dn, $mod); } else { - $acl .= $this->get_category_permissions($dn, $mod, TRUE); + $acl .= $this->get_category_permissions($dn, $mod); } if (!empty($acl)) { $deps[$dn] = $dn; @@ -792,8 +790,10 @@ class userinfo if (!isset($this->result_cache['get_complete_category_acls'][$dn][$category])) { if (isset($config->data['CATEGORIES'][$category])) { foreach ($config->data['CATEGORIES'][$category]['classes'] as $oc) { - /* Skip objectClass '0' (e.g. user/0) get_permissions will ever return '' ?? */ - if ($oc == "0") continue; + if ($oc == '0') { + /* Skip objectClass '0' (e.g. user/0) get_permissions will ever return '' ?? */ + continue; + } $tmp = $this->get_permissions($dn, $category."/".$oc); for ($i = 0, $l = strlen($types); $i < $l; $i++) { if (!preg_match("/".$types[$i]."/", $tmp)) { diff --git a/include/functions.inc b/include/functions.inc index bac72c0e4ebf93e1e567656a7eba2ef150b395dd..38ce088f24c007d2339f4317e3042d7a9d25c167 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -576,7 +576,7 @@ function ldap_login_user ($username, $password) } /* got user dn, fill acl's */ - $ui = new userinfo($config, $ldap->getDN()); + $ui = new userinfo($ldap->getDN()); /* password check, bind as user with supplied password */ $ldap->disconnect(); diff --git a/include/functions_debug.inc b/include/functions_debug.inc index 9c577a1394a8f29211ca626b3d6ecb98f5ed6a15..a1a0d62958343a68c8e8cc2191bebf0a6e65079a 100644 --- a/include/functions_debug.inc +++ b/include/functions_debug.inc @@ -333,7 +333,9 @@ function show_vars($show_all_vars = FALSE, $show_object_vars = FALSE) } foreach ($vars_arr as $vars_name => $vars_data) { - if ($vars_name != 'script_globals') global $$vars_name; + if ($vars_name != 'script_globals') { + global $$vars_name; + } if ($$vars_name) { print '<div class="vars-container" style="background-color:'.$vars_data[1].';"><span class="varsname">'.$vars_data[0].'</span><br />'; print_a($$vars_name, FALSE, $show_object_vars, FALSE ); diff --git a/include/simpleplugin/class_helpersAttribute.inc b/include/simpleplugin/class_helpersAttribute.inc index c6fe058b3cf4f4e26071a868d7a727a7ef138444..9795345dd386135dd511a52347f658c42f8d2d28 100644 --- a/include/simpleplugin/class_helpersAttribute.inc +++ b/include/simpleplugin/class_helpersAttribute.inc @@ -18,31 +18,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ - /*! \brief This class allow to handle easily a String LDAP attribute that contains a mail address * */ class MailAttribute extends StringAttribute { - private $template; - /*! \brief The constructor of MailAttribute - * - * \param string $label The label to show for this attribute - * \param string $description A more detailed description for the attribute - * \param string $ldapName The name of the attribute in the LDAP (If it's not in the ldap, still provide a unique name) - * \param boolean $required Is this attribute mandatory or not - * \param mixed $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) - * \param boolean $template Should this email field accept template character '%' ? - */ - function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = "", $acl = "", $template = FALSE) - { - parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl); - $this->template = $template; - } function validate () { - if (!tests::is_email($this->value, $this->template)) { + if (!tests::is_email($this->value)) { return msgPool::invalid($this->getLabel(), $this->value); } } diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc index bb48976a6446d3a5ea90d525afd19264fcdbb905..d1f13dc0501f703aa48ec9c55114fe09edc0172c 100644 --- a/include/simpleplugin/class_simpleManagement.inc +++ b/include/simpleplugin/class_simpleManagement.inc @@ -854,7 +854,7 @@ class simpleManagement extends management } $infos = objects::infos($type); - if ($action == "copy" && $ui->is_copyable($dn, $infos['aclCategory'], $infos['mainTab'])) { + if ($action == "copy" && $ui->is_copyable($dn, $infos['aclCategory'])) { $this->cpHandler->add_to_queue($dn, "copy", $type); @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry copied!"); } diff --git a/setup/class_setupStep_Finish.inc b/setup/class_setupStep_Finish.inc index ebc4bc6455838117d6f331e299ecc695e4d6b27b..e2b939e439c15c84514135ad1894c6a3f15410ef 100644 --- a/setup/class_setupStep_Finish.inc +++ b/setup/class_setupStep_Finish.inc @@ -66,7 +66,7 @@ class Step_Finish extends setupStep /* Create ui object */ /* got user dn, fill acl's */ - $ui = new userinfo($config, $cv['valid_admin']); + $ui = new userinfo($cv['valid_admin']); /* Username is set, load subtreeACL's now */ $ui->loadACL();