From 1356231d8a92c58f21ce8be8a38ab56d4f98b843 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 5 Oct 2007 18:09:49 +0000 Subject: [PATCH] fixed some PHP notices --- lam/lib/baseModule.inc | 2 +- lam/lib/lists.inc | 5 ++--- lam/lib/modules.inc | 4 +++- lam/lib/modules/posixAccount.inc | 11 ++++++----- lam/lib/modules/sambaSamAccount.inc | 12 ++++++------ lam/lib/types/user.inc | 2 +- lam/templates/config/confmain.php | 18 +++++++++--------- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 37137c54..29e8c8fb 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -360,7 +360,7 @@ abstract class baseModule { $identifiers = array_keys($this->meta['config_checks'][$scopes[$s]]); for ($i = 0; $i < sizeof($identifiers); $i++) { // check if option is required - if ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) { + if (isset($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required']) && ($options[$identifiers[$i]][0] == '')) { $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required_message']; } switch ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']) { diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 4de091ba..4aa229ca 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -265,12 +265,11 @@ class lamList { function cmp_array(&$a, &$b) { // sort specifies the sort column $sort = $this->sortColumn; - $attr_array = $this->attrArray; // sort by first column if no attribute is given - if (!$sort) $sort = strtolower($attr_array[0]); + if (!$sort) $sort = strtolower($this->attrArray[0]); if ($sort != "dn") { // sort by first attribute with name $sort - return strnatcasecmp($a[$sort][0], $b[$sort][0]); + return @strnatcasecmp($a[$sort][0], $b[$sort][0]); } else { return strnatcasecmp($a[$sort], $b[$sort]); diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 85ae8218..98e1d145 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -322,7 +322,9 @@ function checkConfigOptions($scopes, $options) { for ($i = 0; $i < sizeof($modules); $i++) { $m = new $modules[$i]('none'); $errors = $m->check_configOptions($scopes[$modules[$i]], $options); - $return = array_merge($return, $errors); + if (isset($errors) && is_array($errors)) { + $return = array_merge($return, $errors); + } } return $return; } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 38de4b45..ff36c2f6 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -440,11 +440,11 @@ class posixAccount extends baseModule { * @return boolean true, if settings are complete */ function module_complete() { - if ($this->attributes['uid'][0] == '') return false; - if ($this->attributes['uidNumber'][0] == '') return false; - if ($this->attributes['gidNumber'][0] == '') return false; - if ($this->attributes['homeDirectory'][0] == '') return false; - if ($this->attributes['loginShell'][0] == '') return false; + if (!isset($this->attributes['uid'][0]) || ($this->attributes['uid'][0] == '')) return false; + if (!isset($this->attributes['uidNumber'][0]) || ($this->attributes['uidNumber'][0] == '')) return false; + if (!isset($this->attributes['gidNumber'][0]) || ($this->attributes['gidNumber'][0] == '')) return false; + if (!isset($this->attributes['homeDirectory'][0]) || ($this->attributes['homeDirectory'][0] == '')) return false; + if (!isset($this->attributes['loginShell'][0]) || ($this->attributes['loginShell'][0] == '')) return false; return true; } @@ -456,6 +456,7 @@ class posixAccount extends baseModule { function load_attributes($attr) { parent::load_attributes($attr); // get additional group memberships + if (!isset($attr['uid'][0])) return; $dn_groups = $_SESSION['cache']->get_cache(array('memberUid', 'cn'), 'posixGroup', 'group'); if (is_array($dn_groups)) { $DNs = array_keys($dn_groups); diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index b7aef2ea..b2740f85 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -503,7 +503,7 @@ class sambaSamAccount extends baseModule { */ function load_attributes($attr) { parent::load_attributes($attr); - if (is_string($this->attributes['sambaAcctFlags'][0])) { + if (isset($this->attributes['sambaAcctFlags'][0])) { if (strpos($this->attributes['sambaAcctFlags'][0], "D")) $this->deactivated = true; else $this->deactivated = false; if (strpos($this->attributes['sambaAcctFlags'][0], "N")) $this->nopwd = true; @@ -601,11 +601,11 @@ class sambaSamAccount extends baseModule { else { $this->nopwd = false; } - if ($_POST['sambaAcctFlagsS']) $flag .= "S"; - if ($_POST['sambaAcctFlagsH']) $flag .= "H"; - if ($_POST['sambaAcctFlagsW']) $flag .= "W"; - if ($_POST['sambaAcctFlagsU']) $flag .= "U"; - if ($_POST['sambaAcctFlagsL']) $flag .= "L"; + if (isset($_POST['sambaAcctFlagsS'])) $flag .= "S"; + if (isset($_POST['sambaAcctFlagsH'])) $flag .= "H"; + if (isset($_POST['sambaAcctFlagsW'])) $flag .= "W"; + if (isset($_POST['sambaAcctFlagsU'])) $flag .= "U"; + if (isset($_POST['sambaAcctFlagsL'])) $flag .= "L"; // Expand string to fixed length $flag = str_pad($flag, 12); // End character diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc index 44ea6bc8..eaaa4ec1 100644 --- a/lam/lib/types/user.inc +++ b/lam/lib/types/user.inc @@ -186,7 +186,7 @@ class lamUserList extends lamList { */ function listPrintTableCellContent(&$entry, &$attribute) { // check if there is something to display at all - if (!is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return; + if (!isset($entry[$attribute]) || !is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return; if (isset($entry[$attribute]['count'])) unset($entry[$attribute]['count']); // translate GID to group name if (($attribute == "gidnumber") && ($this->trans_primary == "on")) { diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 181113ae..b0aa1d0d 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -502,15 +502,15 @@ function saveSettings() { $chmodOwner = 0; $chmodGroup = 0; $chmodOther = 0; - if ($_POST['chmod_owr'] == 'on') $chmodOwner += 4; - if ($_POST['chmod_oww'] == 'on') $chmodOwner += 2; - if ($_POST['chmod_owe'] == 'on') $chmodOwner += 1; - if ($_POST['chmod_grr'] == 'on') $chmodGroup += 4; - if ($_POST['chmod_grw'] == 'on') $chmodGroup += 2; - if ($_POST['chmod_gre'] == 'on') $chmodGroup += 1; - if ($_POST['chmod_otr'] == 'on') $chmodOther += 4; - if ($_POST['chmod_otw'] == 'on') $chmodOther += 2; - if ($_POST['chmod_ote'] == 'on') $chmodOther += 1; + if (isset($_POST['chmod_owr']) && ($_POST['chmod_owr'] == 'on')) $chmodOwner += 4; + if (isset($_POST['chmod_oww']) && ($_POST['chmod_oww'] == 'on')) $chmodOwner += 2; + if (isset($_POST['chmod_owe']) && ($_POST['chmod_owe'] == 'on')) $chmodOwner += 1; + if (isset($_POST['chmod_grr']) && ($_POST['chmod_grr'] == 'on')) $chmodGroup += 4; + if (isset($_POST['chmod_grw']) && ($_POST['chmod_grw'] == 'on')) $chmodGroup += 2; + if (isset($_POST['chmod_gre']) && ($_POST['chmod_gre'] == 'on')) $chmodGroup += 1; + if (isset($_POST['chmod_otr']) && ($_POST['chmod_otr'] == 'on')) $chmodOther += 4; + if (isset($_POST['chmod_otw']) && ($_POST['chmod_otw'] == 'on')) $chmodOther += 2; + if (isset($_POST['chmod_ote']) && ($_POST['chmod_ote'] == 'on')) $chmodOther += 1; $chmod = $chmodOwner . $chmodGroup . $chmodOther; if (!$conf->set_scriptrights($chmod)) { $errors[] = array("ERROR", _("Script rights are invalid!"));