fixed maxlistentries setting

This commit is contained in:
Roland Gruber 2003-05-07 14:29:44 +00:00
parent 5b11f1d847
commit a6dabef929
3 changed files with 22 additions and 3 deletions

View File

@ -8,7 +8,6 @@ serverURL: ldap://localhost:389
# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org # e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org
admins: cn=Manager,dc=my-domain,dc=com admins: cn=Manager,dc=my-domain,dc=com
# password to change these preferences via webfrontend # password to change these preferences via webfrontend
passwd: lam passwd: lam
@ -59,3 +58,6 @@ grouplistAttributes: #cn;#gidNumber;#memberUID;#description
# or individual ones (e.g. 'cn:Host Name') # or individual ones (e.g. 'cn:Host Name')
# values have to be seperated by semicolons # values have to be seperated by semicolons
hostlistAttributes: #cn;#rid;#description;gidNumber:GID hostlistAttributes: #cn;#rid;#description;gidNumber:GID
# maximum number of rows to show in user/group/host lists
maxlistentries: 30

View File

@ -73,6 +73,8 @@ class Config {
var $userlistAttributes; var $userlistAttributes;
var $grouplistAttributes; var $grouplistAttributes;
var $hostlistAttributes; var $hostlistAttributes;
// maximum number of rows shown in user/group/host list
var $maxlistentries; var $maxlistentries;
// constructor, loads preferences from ../config/lam.conf // constructor, loads preferences from ../config/lam.conf
@ -151,6 +153,10 @@ class Config {
$this->hostlistAttributes = chop(substr($line, 20, strlen($line)-20)); $this->hostlistAttributes = chop(substr($line, 20, strlen($line)-20));
continue; continue;
} }
if (substr($line, 0, 16) == "maxlistentries: ") {
$this->maxlistentries = chop(substr($line, 16, strlen($line)-16));
continue;
}
} }
fclose($file); fclose($file);
} }
@ -173,7 +179,7 @@ class Config {
// booleans to check if value was already saved // booleans to check if value was already saved
$save_serverURL = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst = $save_serverURL = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst =
$save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach = $save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach =
$save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = False; $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = $maxlstent = False;
$file = fopen($conffile, "r"); $file = fopen($conffile, "r");
$file_array = array(); $file_array = array();
while (!feof($file)) { while (!feof($file)) {
@ -258,6 +264,11 @@ class Config {
$save_hstlstattr = True; $save_hstlstattr = True;
continue; continue;
} }
if (substr($file_array[$i], 0, 16) == "maxlistentries: ") {
$file_array[$i] = "maxlistentries: " . $this->maxlistentries . "\n";
$save_maxlstent = True;
continue;
}
} }
// check if we have to add new entries (e.g. if user upgraded LAM and has an old lam.conf) // check if we have to add new entries (e.g. if user upgraded LAM and has an old lam.conf)
if (!$save_serverURL == True) array_push($file_array, "\n\n# server address (e.g. ldap://localhost:389 or ldaps://localhost:636)\n" . "serverURL: " . $this->ServerURL); if (!$save_serverURL == True) array_push($file_array, "\n\n# server address (e.g. ldap://localhost:389 or ldaps://localhost:636)\n" . "serverURL: " . $this->ServerURL);
@ -283,6 +294,7 @@ class Config {
"\n# or individual ones (e.g. 'cn:Group Name')\n# values have to be seperated by semicolons\n" . "grouplistAttributes: " . $this->grouplistAttributes); "\n# or individual ones (e.g. 'cn:Group Name')\n# values have to be seperated by semicolons\n" . "grouplistAttributes: " . $this->grouplistAttributes);
if (!$save_hstlstattr == True) array_push($file_array, "\n\n# list of attributes to show in host list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" . if (!$save_hstlstattr == True) array_push($file_array, "\n\n# list of attributes to show in host list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" .
"\n# or individual ones (e.g. 'cn:Host Name')\n# values have to be seperated by semicolons\n" . "hostlistAttributes: " . $this->hostlistAttributes); "\n# or individual ones (e.g. 'cn:Host Name')\n# values have to be seperated by semicolons\n" . "hostlistAttributes: " . $this->hostlistAttributes);
if (!$save_maxlstent == True) array_push($file_array, "\n\n# maximum number of rows to show in user/group/host lists\n" . "maxlistentries: " . $this->maxlistentries);
$file = fopen($conffile, "w"); $file = fopen($conffile, "w");
if ($file) { if ($file) {
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);
@ -310,7 +322,8 @@ class Config {
echo _("<b>maxMachine: </b>") . $this->MaxMachine . "<br>"; echo _("<b>maxMachine: </b>") . $this->MaxMachine . "<br>";
echo _("<b>userlistAttributes: </b>") . $this->userlistAttributes . "<br>"; echo _("<b>userlistAttributes: </b>") . $this->userlistAttributes . "<br>";
echo _("<b>grouplistAttributes: </b>") . $this->grouplistAttributes . "<br>"; echo _("<b>grouplistAttributes: </b>") . $this->grouplistAttributes . "<br>";
echo _("<b>hostlistAttributes: </b>") . $this->hostlistAttributes; echo _("<b>hostlistAttributes: </b>") . $this->hostlistAttributes . "<br>";
echo _("<b>maxlistentries: </b>") . $this->maxlistentries;
} }
// functions to read/write preferences // functions to read/write preferences

View File

@ -46,6 +46,7 @@ $MaxMachine = $conf->get_maxMachine();
$userlistAttributes = $conf->get_userlistAttributes(); $userlistAttributes = $conf->get_userlistAttributes();
$grouplistAttributes = $conf->get_grouplistAttributes(); $grouplistAttributes = $conf->get_grouplistAttributes();
$hostlistAttributes = $conf->get_hostlistAttributes(); $hostlistAttributes = $conf->get_hostlistAttributes();
$maxlistentries = $conf->get_maxlistentries();
echo ("done<br>"); echo ("done<br>");
// next we modify them and save lam.conf // next we modify them and save lam.conf
echo ("Changing preferences..."); echo ("Changing preferences...");
@ -65,6 +66,7 @@ $conf->set_maxMachine("47");
$conf->set_userlistAttributes("#uid;#cn"); $conf->set_userlistAttributes("#uid;#cn");
$conf->set_grouplistAttributes("#gidNumber;#cn;#memberUID"); $conf->set_grouplistAttributes("#gidNumber;#cn;#memberUID");
$conf->set_hostlistAttributes("#cn;#uid;#description"); $conf->set_hostlistAttributes("#cn;#uid;#description");
$conf->set_maxlistentries("54");
$conf->save(); $conf->save();
echo ("done<br>"); echo ("done<br>");
// at last all preferences are read from lam.conf and compared // at last all preferences are read from lam.conf and compared
@ -88,6 +90,7 @@ if ($conf->get_maxMachine() != "47") echo ("<br><font color=\"#FF0000\">Saving m
if ($conf->get_userlistAttributes() != "#uid;#cn") echo ("<br><font color=\"#FF0000\">Saving userlistAttributes failed!</font><br>"); if ($conf->get_userlistAttributes() != "#uid;#cn") echo ("<br><font color=\"#FF0000\">Saving userlistAttributes failed!</font><br>");
if ($conf->get_grouplistAttributes() != "#gidNumber;#cn;#memberUID") echo ("<br><font color=\"#FF0000\">Saving grouplistAttributes failed!</font><br>"); if ($conf->get_grouplistAttributes() != "#gidNumber;#cn;#memberUID") echo ("<br><font color=\"#FF0000\">Saving grouplistAttributes failed!</font><br>");
if ($conf->get_hostlistAttributes() != "#cn;#uid;#description") echo ("<br><font color=\"#FF0000\">Saving hostlistAttributes failed!</font><br>"); if ($conf->get_hostlistAttributes() != "#cn;#uid;#description") echo ("<br><font color=\"#FF0000\">Saving hostlistAttributes failed!</font><br>");
if ($conf->get_maxlistentries() != "54") echo ("<br><font color=\"#FF0000\">Saving maxlistentries failed!</font><br>");
echo ("done<br>"); echo ("done<br>");
// restore old values // restore old values
echo ("Restoring old preferences..."); echo ("Restoring old preferences...");
@ -107,6 +110,7 @@ $conf->set_maxMachine($MaxMachine);
$conf->set_userlistAttributes($userlistAttributes); $conf->set_userlistAttributes($userlistAttributes);
$conf->set_grouplistAttributes($grouplistAttributes); $conf->set_grouplistAttributes($grouplistAttributes);
$conf->set_hostlistAttributes($hostlistAttributes); $conf->set_hostlistAttributes($hostlistAttributes);
$conf->set_maxlistentries($maxlistentries);
$conf->save(); $conf->save();
echo ("done<br>"); echo ("done<br>");
// finished // finished