fixed some PHP notices and sorting

This commit is contained in:
Roland Gruber 2010-05-19 19:22:29 +00:00
parent 722daabb64
commit b6fda6b305
10 changed files with 56 additions and 31 deletions

View File

@ -1605,7 +1605,7 @@ class accountContainer {
// find new attributes
if (isset($attributes[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) {
if (is_array($orig[$name])) {
if (isset($orig[$name]) && is_array($orig[$name])) {
if (!in_array($value, $orig[$name]))
if ($value != '') {
$toadd[$name][] = $value;
@ -1615,7 +1615,7 @@ class accountContainer {
}
}
// find unchanged attributes
if (is_array($orig[$name]) && is_array($attributes[$name])) {
if (isset($orig[$name]) && is_array($orig[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) {
if (($value != '') && in_array($value, $orig[$name])) {
$notchanged[$name][] = $value;
@ -1913,9 +1913,15 @@ class accountContainer {
// create complete new dn
else {
$attr = array();
if (is_array($attributes[$this->finalDN]['add'])) $attr = array_merge_recursive($attr, $attributes[$this->finalDN]['add']);
if (is_array($attributes[$this->finalDN]['notchanged'])) $attr = array_merge_recursive($attr, $attributes[$this->finalDN]['notchanged']);
if (is_array($attributes[$this->finalDN]['modify'])) $attr = array_merge_recursive($attr, $attributes[$this->finalDN]['modify']);
if (isset($attributes[$this->finalDN]['add']) && is_array($attributes[$this->finalDN]['add'])) {
$attr = array_merge_recursive($attr, $attributes[$this->finalDN]['add']);
}
if (isset($attributes[$this->finalDN]['notchanged']) && is_array($attributes[$this->finalDN]['notchanged'])) {
$attr = array_merge_recursive($attr, $attributes[$this->finalDN]['notchanged']);
}
if (isset($attributes[$this->finalDN]['modify']) && is_array($attributes[$this->finalDN]['modify'])) {
$attr = array_merge_recursive($attr, $attributes[$this->finalDN]['modify']);
}
$success = ldap_add($_SESSION['ldap']->server(), $this->finalDN, $attr);
if (!$success) {
logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to create DN: ' . $this->finalDN . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').');

View File

@ -431,6 +431,9 @@ class eduPerson extends baseModule {
}
return array();
}
if (!in_array('eduPerson', $this->attributes['objectClass'])) {
return array();
}
$errors = array();
// primary affiliation
$this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation'];

View File

@ -422,7 +422,7 @@ class kolabUser extends baseModule {
$this->attributes['objectClass'][] = 'kolabInetOrgPerson';
}
else {
if ($_POST['form_subpage_kolabUser_deleteUser_open']) return array();
if (isset($_POST['form_subpage_kolabUser_deleteUser_open'])) return array();
$this->attributes['kolabInvitationPolicy'] = array();
// country
if (isset($_POST['country'])) {

View File

@ -90,13 +90,17 @@ class ldapPublicKey extends baseModule {
*/
function display_html_attributes() {
$return = array();
$keyCount = 0;
// list current keys
for ($i = 0; $i < sizeof($this->attributes['sshPublicKey']); $i++) {
$return[] = array(
array('kind' => 'text', 'text' => _('SSH public key')),
array('kind' => 'input', 'name' => 'sshPublicKey' . $i, 'type' => 'text', 'size' => '50', 'maxlength' => '2048', 'value' => $this->attributes['sshPublicKey'][$i]),
array('kind' => 'input', 'type' => 'submit', 'name' => 'delKey' . $i, 'value' => _("Remove")),
array('kind' => 'help', 'value' => 'key'));
if (isset($this->attributes['sshPublicKey'])) {
$keyCount = sizeof($this->attributes['sshPublicKey']);
for ($i = 0; $i < sizeof($this->attributes['sshPublicKey']); $i++) {
$return[] = array(
array('kind' => 'text', 'text' => _('SSH public key')),
array('kind' => 'input', 'name' => 'sshPublicKey' . $i, 'type' => 'text', 'size' => '50', 'maxlength' => '2048', 'value' => $this->attributes['sshPublicKey'][$i]),
array('kind' => 'input', 'type' => 'submit', 'name' => 'delKey' . $i, 'value' => _("Remove")),
array('kind' => 'help', 'value' => 'key'));
}
}
// input box for new key
$return[] = array(
@ -104,7 +108,7 @@ class ldapPublicKey extends baseModule {
array('kind' => 'input', 'name' => 'sshPublicKey', 'type' => 'text', 'size' => '50', 'maxlength' => '2048', 'value' => ''),
array('kind' => 'input', 'type' => 'submit', 'name' => 'addKey', 'value' => _("Add")),
array('kind' => 'help', 'value' => 'key'),
array('kind' => 'input', 'type' => 'hidden', 'value' => sizeof($this->attributes['sshPublicKey']), 'name' => 'key_number'));
array('kind' => 'input', 'type' => 'hidden', 'value' => $keyCount, 'name' => 'key_number'));
return $return;
}

View File

@ -178,9 +178,11 @@ class nisnetgroup extends baseModule {
array('kind' => 'text', 'text' => _("Group name").'*'),
array('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $groupName),
array('kind' => 'help', 'value' => 'cn'));
$description = '';
if (isset($this->attributes['description'][0])) $description = $this->attributes['description'][0];
$return[] = array(
array('kind' => 'text', 'text' => _('Description')),
array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $description),
array ('kind' => 'help', 'value' => 'description'));
$subgroups = array();
if (isset($this->attributes['memberNisNetgroup']) && is_array($this->attributes['memberNisNetgroup'])) {

View File

@ -536,7 +536,7 @@ class posixGroup extends baseModule implements passwordService {
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_removePassword'])) {
unset($this->attributes['userPassword']);
}
if ($_POST['changegids']) $this->changegids=true;
if (isset($_POST['changegids'])) $this->changegids=true;
else $this->changegids=false;
if (($this->attributes['gidNumber'][0] != $_POST['gidNumber']) || !isset($this->attributes['gidNumber'][0])) {
// Check if GID is valid. If none value was entered, the next useable value will be inserted

View File

@ -153,7 +153,7 @@ echo "<table style=\"border-color: grey\" cellpadding=\"10\" border=\"0\" cellsp
$counter = 0;
foreach ($sortedTypes as $type => $label) {
$style = 'style="display:none;"';
if ((!isset($_POST['type']) && ($counter == 0)) || ($_POST['type'] == $type)) {
if ((!isset($_POST['type']) && ($counter == 0)) || (isset($_POST['type']) && ($_POST['type'] == $type))) {
// show first account type or last selected one
$style = '';
}

View File

@ -117,8 +117,8 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
include 'main_header.php';
// display messages
if ($error || $message || $text) {
if ($text) echo $text;
elseif ($error) {
if (isset($text)) echo $text;
elseif (isset($error)) {
StatusMessage("ERROR", "", $error);
echo ("<br><a href=\"ou_edit.php\">" . _("Back to OU-Editor") . "</a>\n");
}
@ -138,17 +138,22 @@ display_main();
* Displays the main page of the OU editor
*/
function display_main() {
$types = $_SESSION['config']->get_ActiveTypes();
// display main page
include 'main_header.php';
echo "<h1>" . _("OU editor") . "</h1>";
echo ("<br>\n");
echo ("<form action=\"ou_edit.php\" method=\"post\">\n");
$types = array();
$typeList = $_SESSION['config']->get_ActiveTypes();
for ($i = 0; $i < sizeof($typeList); $i++) {
$types[$typeList[$i]] = getTypeAlias($typeList[$i]);
}
natcasesort($types);
$options = "";
for ($i = 0; $i < sizeof($types); $i++) {
$options .= "<optgroup label=\"" . getTypeAlias($types[$i]) . "\">\n";
$units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($types[$i]));
foreach ($types as $name => $title) {
$options .= "<optgroup label=\"" . $title . "\">\n";
$units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($name));
for ($u = 0; $u < sizeof($units); $u++) {
$options .= "<option>" . $units[$u] . "</option>\n";
}

View File

@ -47,13 +47,19 @@ setlanguage();
$types = $_SESSION['config']->get_ActiveTypes();
$profileClasses = array();
$profileClassesTemp = array();
for ($i = 0; $i < sizeof($types); $i++) {
$profileClasses[] = array(
$profileClassesTemp[getTypeAlias($types[$i])] = array(
'scope' => $types[$i],
'title' => getTypeAlias($types[$i]),
'profiles' => "");
}
$profileClassesKeys = array_keys($profileClassesTemp);
natcasesort($profileClassesKeys);
$profileClassesKeys = array_values($profileClassesKeys);
for ($i = 0; $i < sizeof($profileClassesKeys); $i++) {
$profileClasses[] = $profileClassesTemp[$profileClassesKeys[$i]];
}
// check if user is logged in, if not go to login
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {

View File

@ -107,12 +107,7 @@ if (isset($_POST['save'])) {
// print error messages if any
if (sizeof($errors) > 0) {
for ($i = 0; $i < sizeof($errors); $i++) {
if (sizeof($errors[$i]) > 3) { // messages with additional variables
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2], $errors[$i][3]);
}
else {
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
}
call_user_func_array('StatusMessage', $errors[$i]);
}
echo "<br>\n";
}
@ -246,7 +241,11 @@ for ($m = 0; $m < sizeof($modules); $m++) {
// profile name and submit/abort buttons
echo ("<b>" . _("Profile name") . ":</b> \n");
$tabindex++;
echo ("<input tabindex=\"$tabindex\" type=\"text\" name=\"profname\" value=\"" . $_GET['edit'] . "\">\n");
$profName = '';
if (isset($_GET['edit'])) {
$profName = $_GET['edit'];
}
echo ("<input tabindex=\"$tabindex\" type=\"text\" name=\"profname\" value=\"" . $profName . "\">\n");
printHelpLink(getHelp('', '360'), '360');
echo "<br><br>\n";
$tabindex++;