diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc
index 5fad0db19c56ea3baa40c6a638992a8dfd763704..139f6973243639c74cbd635eb52d7024147f6492 100644 (file)
<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
/*!
\brief posixAccount plugin
\author Cajus Pollmeier <pollmeier@gonicus.de>
{
/* Definitions */
var $plHeadline= "UNIX";
- var $plDescription= "This does something";
-
- /* CLI vars */
- var $cli_summary= "Manage users posix account";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+ var $plDescription= "Edit users POSIX settings";
/* Plugin specific values */
var $homeDirectory= "";
var $savedGroupMembership= array();
var $savedUidNumber= "";
var $savedGidNumber= "";
- var $use_shadowMin= "0";
- var $use_shadowMax= "0";
- var $use_shadowWarning= "0";
- var $use_shadowInactive= "0";
- var $use_shadowExpire= "0";
+ var $activate_shadowMin= "0";
+ var $activate_shadowMax= "0";
+ var $activate_shadowWarning= "0";
+ var $activate_shadowInactive= "0";
+ var $activate_shadowExpire= "0";
var $mustchangepassword= "0";
var $force_ids= 0;
var $group_dialog= FALSE;
/* attribute list for save action */
var $CopyPasteVars =
- array("grouplist","groupMembership","use_shadowMin",
- "use_shadowMax","use_shadowWarning","use_shadowInactive","use_shadowExpire",
+ array("grouplist","groupMembership","activate_shadowMin",
+ "activate_shadowMax","activate_shadowWarning","activate_shadowInactive","activate_shadowExpire",
"must_change_password","printerList","grouplist","savedGidNumber","savedUidNumber");
var $attributes = array("homeDirectory", "loginShell", "uidNumber", "gidNumber", "gecos",
$this->status.= ", "._("grace time active");
}
} elseif (($this->shadowLastChange + $this->shadowMin) >= $current){
- $this->status= _("active, password not changable");
+ $this->status= _("active").", "._("password not changeable");
} elseif (($this->shadowLastChange + $this->shadowMax) >= $current){
- $this->status= _("active, password expired");
+ $this->status= _("active").", "._("password expired");
} else {
$this->status= _("active");
}
$ldap->cd($this->config->current['BASE']);
$ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("cn", "description"));
- while ($this->attrs= $ldap->fetch()){
- if (!isset($this->attrs["description"][0])){
- $entry= $this->attrs["cn"][0];
+ while ($attrs= $ldap->fetch()){
+ if (!isset($attrs["description"][0])){
+ $entry= $attrs["cn"][0];
} else {
- $dsc= preg_replace ('/^Group of user/', _("Group of user"), $this->attrs["description"][0]);
- $entry= $this->attrs["cn"][0]." [$dsc]";
+ $entry= $attrs["cn"][0]." [".$attrs["description"][0]."]";
}
$this->groupMembership[$ldap->getDN()]= $entry;
}
"shadowExpire") as $val){
if ($this->$val != 0){
- $oval= "use_".$val;
+ $oval= "activate_".$val;
$this->$oval= "1";
}
}
asort ($this->secondaryGroups);
/* Get global filter config */
- if (!is_global("sysfilter")){
+ if (!session::is_set("sysfilter")){
$ui= get_userinfo();
$base= get_base_from_people($ui->dn);
$sysfilter= array( "depselect" => $base,
"regex" => "*");
- register_global("sysfilter", $sysfilter);
+ session::set("sysfilter", $sysfilter);
}
$this->ui = get_userinfo();
}
/* Department has changed? */
if(isset($_POST['depselect'])){
- $_SESSION['CurrentMainBase']= validate($_POST['depselect']);
+ session::set('CurrentMainBase',validate($_POST['depselect']));
}
if($this->multiple_support_active){
/* Do we represent a valid posixAccount? */
if (!$this->is_account && $this->parent === NULL ){
- $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
- _("This account has no unix extensions.")."</b>";
+ $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
+ msgPool::noValidExtension(_("POSIX"))."</b>";
$display.= back_to_main();
return ($display);
}
in the moment, because I need to rely on unique
uidNumbers. There'll be a better solution later
on. */
- $display= $this->show_disable_header(_("Remove posix account"),
- _("This account has unix features enabled. To disable them, you'll need to remove the samba / environment account first."), TRUE);
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("POSIX")), msgPool::featuresEnabled(_("POSIX"), array(_("Samba"), _("Environment"))), TRUE);
} else {
- $display= $this->show_disable_header(_("Remove posix account"),
- _("This account has posix features enabled. You can disable them by clicking below."));
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("POSIX")), msgPool::featuresEnabled(_("POSIX")));
}
} else {
- $display= $this->show_enable_header(_("Create posix account"),
- _("This account has posix features disabled. You can enable them by clicking below."));
+ $display= $this->show_enable_header(msgPool::addFeaturesButton(_("POSIX")), msgPool::featuresDisabled(_("POSIX")));
return($display);
}
}
/* Show ws dialog */
if ($this->show_ws_dialog){
/* Save data */
- $sysfilter= get_global("sysfilter");
+ $sysfilter= session::get("sysfilter");
foreach( array("depselect", "regex") as $type){
if (isset($_POST[$type])){
$sysfilter[$type]= $_POST[$type];
}
$sysfilter['regex']= $s;
}
- register_global("sysfilter", $sysfilter);
+ session::set("sysfilter", $sysfilter);
/* Get workstation list */
$exclude= "";
$exclude= "(!(|$exclude))";
}
$regex= $sysfilter['regex'];
+
+ $acls = array();
+ if(class_available("servgeneric")) $acls[] = "server";
+ if(class_available("workgeneric")) $acls[] = "worstation";
+ if(class_available("termgeneric")) $acls[] = "terminal";
+
$filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
- $res= get_list($filter, "groups", $sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT);
+
+ $deps_a = array(get_ou("serverou"),
+ get_ou("terminalou"),
+ get_ou("workstationou"));
+
+ $res= get_sub_list($filter, $acls, $deps_a, get_ou("systemsou").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT);
$wslist= array();
foreach ($res as $attrs){
$wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]);
}
asort($wslist);
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+ $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
+ $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
$smarty->assign("deplist", $this->config->idepartments);
$smarty->assign("alphabet", generate_alphabet());
foreach( array("depselect", "regex") as $type){
$smarty->assign("regex",$this->GroupRegex);
$smarty->assign("guser",$this->GroupUserRegex);
$smarty->assign("groups", $glist);
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+ $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
+ $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
$smarty->assign("deplist", $this->config->idepartments);
$smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("depselect",$_SESSION['CurrentMainBase']);
+ $smarty->assign("depselect", session::get('CurrentMainBase'));
$smarty->assign("hint", print_sizelimit_warning());
$smarty->assign("apply", apply_filter());
$smarty= get_smarty();
/* In 'MyAccount' mode, we must remove write acls if we are not in editing mode. */
- $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
+ $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
/* Depending on pwmode, currently hardcoded because there are no other methods */
if ( 1 == 1 ){
"<input name=\"shadowMax\" size=3 maxlength=4 value=\"".$this->shadowMax."\">"));
$shadowInactiveACL= $this->getacl("shadowInactive",$SkipWrite);
- $smarty->assign("shadowinactives", sprintf(_("Disable account after %s days of inactivity after password expiery"),
+ $smarty->assign("shadowinactives", sprintf(_("Disable account after %s days of inactivity after password expiry"),
"<input name=\"shadowInactive\" size=3 maxlength=4 value=\"".$this->shadowInactive."\">"));
$shadowWarningACL = $this->getacl("shadowWarning",$SkipWrite);
- $smarty->assign("shadowwarnings", sprintf(_("Warn user %s days before password expiery"),
+ $smarty->assign("shadowwarnings", sprintf(_("Warn user %s days before password expiry"),
"<input name=\"shadowWarning\" size=3 maxlength=4 value=\"".$this->shadowWarning."\">"));
- foreach( array("use_shadowMin", "use_shadowMax",
- "use_shadowExpire", "use_shadowInactive","use_shadowWarning") as $val){
+ foreach( array("activate_shadowMin", "activate_shadowMax",
+ "activate_shadowExpire", "activate_shadowInactive","activate_shadowWarning") as $val){
if ($this->$val == 1){
$smarty->assign("$val", "checked");
} else {
$smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite));
}
- if($this->mustchangepassword){
- $smarty->assign("mustchangepassword", "checked");
- } else {
- $smarty->assign("mustchangepassword", "");
- }
$smarty->assign("mustchangepasswordACL", $this->getacl("mustchangepassword",$SkipWrite));
}
for($y= $date['year']-10; $y<$date['year']+10; $y++){
$years[]= $y;
}
- $months= array(_("January"), _("February"), _("March"), _("April"),
- _("May"), _("June"), _("July"), _("August"), _("September"),
- _("October"), _("November"), _("December"));
+ $months= msgPool::months();
$smarty->assign("day", $date["mday"]);
$smarty->assign("days", $days);
$smarty->assign("months", $months);
/* Checkboxes */
if ($this->force_ids == 1){
$smarty->assign("force_ids", "checked");
- if ($_SESSION['js']){
+ if (session::get('js')){
$smarty->assign("forceMode", "");
}
} else {
- if ($_SESSION['js']){
+ if (session::get('js')){
$smarty->assign("forceMode", "disabled");
}
$smarty->assign("force_ids", "");
}
-
+ /* Create onClick="" action string for the "Force UID/GID" option
+ */
+ $onClickIDS ="";
+ if(preg_match("/w/",$this->getacl("uidNumber",$SkipWrite))){
+ $onClickIDS .= "changeState('uidNumber');";
+ }
+ if(preg_match("/w/",$this->getacl("gidNumber",$SkipWrite))){
+ $onClickIDS .= "changeState('gidNumber');";
+ }
+ $smarty->assign("onClickIDS", $onClickIDS);
$smarty->assign("force_idsACL", $this->getacl("uidNumber",$SkipWrite).$this->getacl("gidNumber",$SkipWrite));
- foreach(array("primaryGroup","trustmode") as $val){
+ foreach(array("primaryGroup","trustmode","activate_shadowWarning","activate_shadowInactive","activate_shadowMin","activate_shadowMax","activate_shadowExpire","mustchangepassword") as $val){
if(in_array($val,$this->multi_boxes)){
$smarty->assign("use_".$val,TRUE);
}else{
$smarty->assign("use_".$val,FALSE);
}
- if(($_SESSION["js"])&&(($val=="uidNumber")||($val=="gidNumber")))
+ if((session::get("js"))&&(($val=="uidNumber")||($val=="gidNumber")))
{
$smarty->assign("$val"."ACL",$this->getacl($val,$SkipWrite));
$smarty->assign("$val", $this->$val);
else
$smarty->assign("emptyArrAccess",false);
-
+ if($this->mustchangepassword){
+ $smarty->assign("mustchangepassword", " checked ");
+ } else {
+ $smarty->assign("mustchangepassword", "");
+ }
$smarty->assign("workstations", $this->accessTo);
return;
}
- /* include global link_info */
- $ldap= $this->config->get_ldap_link();
/* Remove and write to LDAP */
plugin::remove_from_parent();
unset($this->attrs['trustModel']);
@DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
- $this->attributes, "Save");
+ /* include global link_info */
+ $this->attributes, "Save");
+ $ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/posix account with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+ }
/* Delete group only if cn is uid and there are no other
members inside */
$this->primaryGroup= $_POST['primaryGroup'];
}
- foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning","mustchangepassword") as $var) {
+ /* Get seelcted shadow checkboxes */
+ foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning") as $var) {
if($this->acl_is_writeable($var)){
- $use_var = "use_".$var;
- if(isset($_POST['use_'.$var])){
- $this->$use_var = true;
+ $activate_var = "activate_".$var;
+ if(isset($_POST['activate_'.$var])){
+ $this->$activate_var = true;
$this->$var = $_POST[$var];
}else{
- $this->$use_var = false;
+ $this->$activate_var = false;
$this->$var = 0;
}
}
}
+ /* Force change password ? */
+ if(isset($_POST['mustchangepassword'])){
+ $this->mustchangepassword = TRUE;
+ }else{
+ $this->mustchangepassword = FALSE;
+ }
+
/* Trust mode - special handling */
if($this->acl_is_writeable("trustModel")){
if (isset($_POST['trustmode'])){
function save()
{
- /* include global link_info */
- $ldap= $this->config->get_ldap_link();
-
/* Adapt shadow values */
- if (!$this->use_shadowExpire){
+ if (!$this->activate_shadowExpire){
$this->shadowExpire= "0";
} else {
/* Transform seconds to days here */
$this->shadowExpire= (int)($this->shadowExpire / (60 * 60 * 24)) ;
}
- if (!$this->use_shadowMax){
+ if (!$this->activate_shadowMax){
$this->shadowMax= "0";
}
if ($this->mustchangepassword){
} else {
$this->shadowLastChange= (int)(date("U") / 86400);
}
- if (!$this->use_shadowWarning){
+ if (!$this->activate_shadowWarning){
$this->shadowWarning= "0";
}
/* Oups - timed out */
if ($wait-- == 0){
- print_red (_("Failed: overriding lock"));
+ msg_dialog::display(_("Warning"), _("Timeout while waiting for lock. Ignoring lock!"), WARNING_DIALOG);
break;
}
}
}
}
- if ($this->use_shadowMin != "1" ) {
+ if ($this->activate_shadowMin != "1" ) {
$this->shadowMin = "";
}
- if (($this->use_shadowMax != "1") && ($this->mustchangepassword != "1")) {
+ if (($this->activate_shadowMax != "1") && ($this->mustchangepassword != "1")) {
$this->shadowMax = "";
}
- if ($this->use_shadowWarning != "1" ) {
+ if ($this->activate_shadowWarning != "1" ) {
$this->shadowWarning = "";
}
- if ($this->use_shadowInactive != "1" ) {
+ if ($this->activate_shadowInactive != "1" ) {
$this->shadowInactive = "";
}
- if ($this->use_shadowExpire != "1" ) {
+ if ($this->activate_shadowExpire != "1" ) {
$this->shadowExpire = "";
}
}
- /* Save data to LDAP */
- $ldap->cd($this->dn);
+ /* include global link_info */
$this->cleanup();
+
+ /* This is just a test, we have had duplicated ids
+ in the past when copy & paste was used.
+ Normaly this should not happen.
+ */
+ if(isset($this->attrs['uidNumber']) && !$this->force_ids){
+ $used = $this->get_used_uid_numbers();
+ if(isset($used[$this->attrs['uidNumber']]) && $used[$this->attrs['uidNumber']] != $this->dn){
+ msg_dialog::display(_("Warning"),_("A duplicated UID number was written for this user. If this was not intended please verify all used uidNumbers!"), WARNING_DIALOG);
+ }
+ }
+
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd($this->dn);
unset($this->attrs['uid']);
$ldap->modify ($this->attrs);
new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/posix account with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+ }
/* Remove lock needed for unique id generation */
del_lock ("uidnumber");
/* Create group if it doesn't exist */
if ($ldap->count() == 0){
- $groupdn= preg_replace ('/^'.$this->config->current['DNMODE'].'=[^,]+,'.get_people_ou().'/i', 'cn='.$this->uid.','.get_groups_ou(), $this->dn);
+ $groupdn= preg_replace ('/^'.$this->config->get_cfg_value("dnmode").'=[^,]+,'.get_people_ou().'/i', 'cn='.$this->uid.','.get_groups_ou(), $this->dn);
$g= new group($this->config, $groupdn);
$g->cn= $this->uid;
$g->force_gid= 1;
$g->gidNumber= $this->gidNumber;
- $g->description= "Group of user ".$this->givenName." ".$this->sn;
+ $g->description= _("Group of user")." ".$this->givenName." ".$this->sn;
$g->save ();
}
}
/* must: homeDirectory */
if ($this->homeDirectory == ""){
- $message[]= _("The required field 'Home directory' is not set.");
+ $message[]= msgPool::required(_("Home directory"));
}
- if (!is_path($this->homeDirectory)){
- $message[]= _("Please enter a valid path in 'Home directory' field.");
+ if (!tests::is_path($this->homeDirectory)){
+ $message[]= msgPool::invalid(_("Home directory"), "", "", "/home/yourname" );
}
/* Check ID's if they are forced by user */
if ($this->force_ids == "1"){
/* Valid uid/gid? */
- if (!is_id($this->uidNumber)){
- $message[]= _("Value specified as 'UID' is not valid.");
+ if (!tests::is_id($this->uidNumber)){
+ $message[]= msgPool::invalid(_("UID"), $this->uidNumber, "/[0-9]/");
} else {
- if ($this->uidNumber < $this->config->current['MINID']){
- $message[]= _("Value specified as 'UID' is too small.");
+ if ($this->uidNumber < $this->config->get_cfg_value("minid")){
+ $message[]= msgPool::toosmall(_("UID"), $this->config->get_cfg_value("minid"));
}
}
- if (!is_id($this->gidNumber)){
- $message[]= _("Value specified as 'GID' is not valid.");
+ if (!tests::is_id($this->gidNumber)){
+ $message[]= msgPool::invalid(_("GID"), $this->gidNumber, "/[0-9]/");
} else {
- if ($this->gidNumber < $this->config->current['MINID']){
- $message[]= _("Value specified as 'GID' is too small.");
+ if ($this->gidNumber < $this->config->get_cfg_value("minid")){
+ $message[]= msgPool::toosmall(_("GID"), $this->config->get_cfg_value("minid"));
}
}
}
/* Check shadow settings, well I like spaghetties... */
- if ($this->use_shadowMin){
- if (!is_id($this->shadowMin)){
- $message[]= _("Value specified as 'shadowMin' is not valid.");
+ if ($this->activate_shadowMin){
+ if (!tests::is_id($this->shadowMin)){
+ $message[]= msgPool::invalid(_("shadowMin"), $this->shadowMin, "/[0-9]/");
}
}
- if ($this->use_shadowMax){
- if (!is_id($this->shadowMax)){
- $message[]= _("Value specified as 'shadowMax' is not valid.");
+ if ($this->activate_shadowMax){
+ if (!tests::is_id($this->shadowMax)){
+ $message[]= msgPool::invalid(_("shadowMax"), $this->shadowMax, "/[0-9]/");
}
}
- if ($this->use_shadowWarning){
- if (!is_id($this->shadowWarning)){
- $message[]= _("Value specified as 'shadowWarning' is not valid.");
+ if ($this->activate_shadowWarning){
+ if (!tests::is_id($this->shadowWarning)){
+ $message[]= msgPool::invalid(_("shadowWarning"), $this->shadowWarning, "/[0-9]/");
}
- if (!$this->use_shadowMax){
- $message[]= _("'shadowWarning' without 'shadowMax' makes no sense.");
+ if (!$this->activate_shadowMax){
+ $message[]= msgPool::depends("shadowWarning", "shadowMax");
}
if ($this->shadowWarning > $this->shadowMax){
- $message[]= _("Value specified as 'shadowWarning' should be smaller than 'shadowMax'.");
+ $message[]= msgPool::toobig("shadowWarning", "shadowMax");
}
- if ($this->use_shadowMin && $this->shadowWarning < $this->shadowMin){
- $message[]= _("Value specified as 'shadowWarning' should be greater than 'shadowMin'.");
+ if ($this->activate_shadowMin && $this->shadowWarning < $this->shadowMin){
+ $message[]= msgPool::toosmall("shadowWarning", "shadowMin");
}
}
- if ($this->use_shadowInactive){
- if (!is_id($this->shadowInactive)){
- $message[]= _("Value specified as 'shadowInactive' is not valid.");
+ if ($this->activate_shadowInactive){
+ if (!tests::is_id($this->shadowInactive)){
+ $message[]= msgPool::invalid(_("shadowInactive"), $this->shadowInactive, "/[0-9]/");
}
- if (!$this->use_shadowMax){
- $message[]= _("'shadowInactive' without 'shadowMax' makes no sense.");
+ if (!$this->activate_shadowMax){
+ $message[]= msgPool::depends("shadowInactive", "shadowMax");
}
}
- if ($this->use_shadowMin && $this->use_shadowMax){
+ if ($this->activate_shadowMin && $this->activate_shadowMax){
if ($this->shadowMin > $this->shadowMax){
- $message[]= _("Value specified as 'shadowMin' should be smaller than 'shadowMax'.");
+ $message[]= msgPool::toobig("shadowMin", "shadowMax");
}
}
- // if(empty($this->gosaDefaultPrinter)){
- // $message[]= _("You need to specify a valid default printer.");
- // }
-
return ($message);
}
+
+ function multiple_check()
+ {
+ $message = plugin::multiple_check();
+ if ($this->homeDirectory == "" && in_array("homeDirectory",$this->multi_boxes)){
+ $message[]= msgPool::required(_("Home directory"));
+ }
+ if (!tests::is_path($this->homeDirectory) && in_array("homeDirectory",$this->multi_boxes)){
+ $message[]= msgPool::invalid(_("Home directory"), "", "", "/home/yourname" );
+ }
+
+ /* Check shadow settings, well I like spaghetties... */
+ if ($this->activate_shadowMin && in_array("activate_shadowMin",$this->multi_boxes)){
+ if (!tests::is_id($this->shadowMin)){
+ $message[]= msgPool::invalid(_("shadowMin"), $this->shadowMin, "/[0-9]/");
+ }
+ }
+ if ($this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){
+ if (!tests::is_id($this->shadowMax)){
+ $message[]= msgPool::invalid(_("shadowMax"), $this->shadowMax, "/[0-9]/");
+ }
+ }
+ if ($this->activate_shadowWarning && in_array("activate_shadowWarning",$this->multi_boxes)){
+ if (!tests::is_id($this->shadowWarning)){
+ $message[]= msgPool::invalid(_("shadowWarning"), $this->shadowWarning, "/[0-9]/");
+ }
+ if (!$this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){
+ $message[]= msgPool::depends("shadowWarning", "shadowMax");
+ }
+ if ($this->shadowWarning > $this->shadowMax && in_array("activate_shadowWarning",$this->multi_boxes)){
+ $message[]= msgPool::toobig("shadowWarning", "shadowMax");
+ }
+ if ($this->activate_shadowMin && $this->shadowWarning < $this->shadowMin && in_array("activate_shadowMin",$this->multi_boxes)){
+ $message[]= msgPool::tosmall("shadowWarning", "shadowMin");
+ }
+ }
+ if ($this->activate_shadowInactive && in_array("activate_shadowInactive",$this->multi_boxes)){
+ if (!tests::is_id($this->shadowInactive)){
+ $message[]= msgPool::invalid(_("shadowInactive"), $this->shadowInactive, "/[0-9]/");
+ }
+ if (!$this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){
+ $message[]= msgPool::depends("shadowInactive", "shadowMax");
+ }
+ }
+ if ($this->activate_shadowMin && $this->activate_shadowMax && in_array("activate_shadowMin",$this->multi_boxes)){
+ if ($this->shadowMin > $this->shadowMax){
+ $message[]= msgPool::toobig("shadowMin", "shadowMax");
+ }
+ }
+
+ return($message);
+ }
+
+
function addGroup ($groups)
{
/* include global link_info */
/* Adapt from template, using 'dn' */
- function adapt_from_template($dn)
+ function adapt_from_template($dn, $skip= array())
{
/* Include global link_info */
$ldap= $this->config->get_ldap_link();
- plugin::adapt_from_template($dn);
+ plugin::adapt_from_template($dn, $skip);
$template= $this->attrs['uid'][0];
/* Adapt group membership */
/* Adjust shadow checkboxes */
foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive") as $val){
if ($this->$val != 0){
- $oval= "use_".$val;
+ $oval= "activate_".$val;
$this->$oval= "1";
}
}
/* Only enable checkbox, if shadowExpire is in the future */
if($this->shadowExpire > time()) {
- $this->use_shadowExpire= "1";
+ $this->activate_shadowExpire= "1";
}
}
}
+ function get_used_uid_numbers()
+ {
+ $ids= array();
+ $ldap= $this->config->get_ldap_link();
+
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(objectClass=posixAccount)(uidNumber=*))", array("uidNumber"));
+
+ /* Get list of ids */
+ while ($attrs= $ldap->fetch()){
+ $ids[$attrs['uidNumber'][0]] = $attrs['dn'];
+ }
+ return($ids);
+ }
+
+
function get_next_id($attrib, $dn)
{
$ids= array();
/* get the ranges */
$tmp = array('0'=> 1000);
- if (preg_match('/posixAccount/', $oc) && isset($this->config->current['UIDBASE'])) {
- $tmp= split('-',$this->config->current['UIDBASE']);
- } elseif(isset($this->config->current['GIDBASE'])){
- $tmp= split('-',$this->config->current['GIDBASE']);
+ if (preg_match('/posixAccount/', $oc) && $this->config->get_cfg_value("uidbase") != ""){
+ $tmp= split('-',$this->config->get_cfg_value("uidbase"));
+ } elseif($this->config->get_cfg_value("gidbase") != ""){
+ $tmp= split('-',$this->config->get_cfg_value("gidbase"));
}
/* Set hwm to max if not set - for backward compatibility */
}
/* Find out next free id near to UID_BASE */
- if (!isset($this->config->current['BASE_HOOK'])){
+ if ($this->config->get_cfg_value("base_hook") == ""){
$base= $lwm;
} else {
/* Call base hook */
/* Should not happen */
if ($id == $hwm){
- print_red(_("Too many users, can't allocate a free ID!"));
+ msg_dialog::display(_("Error"), _("Cannot allocate a free ID!"), ERROR_DIALOG);
exit;
}
function reload()
{
/* Set base for all searches */
- $base = $_SESSION['CurrentMainBase'];
+ $base = session::get('CurrentMainBase');
$base = $base;
$ldap = $this->config->get_ldap_link();
$attrs = array("cn", "description", "gidNumber");
$res= get_list($filter, "groups", $base,$attrs, $Flags);
/* check sizelimit */
- if (preg_match("/size limit/i", $ldap->error)){
- $_SESSION['limit_exceeded']= TRUE;
+ if (preg_match("/size limit/i", $ldap->get_error())){
+ session::set('limit_exceeded',TRUE);
}
/* Create a list of users */
if(!$this->is_account) return("");
if ($this->force_ids == 1){
$force_ids = "checked";
- if ($_SESSION['js']){
+ if (session::get('js')){
$forceMode = "";
}
} else {
- if ($_SESSION['js']){
+ if (session::get('js')){
if($this->acl != "#none#")
$forceMode ="disabled";
}
plugin::PrepareForCopyPaste($source);
/* Avoid using the same gid/uid number as source user */
- $this->savedUidNumber = $this->get_next_id("gidNumber", $this->dn);
- $this->savedGidNumber = $this->get_next_id("uidNumber", $this->dn);
+ $this->savedUidNumber = $this->get_next_id("uidNumber", $this->dn);
+ $this->savedGidNumber = $this->get_next_id("gidNumber", $this->dn);
}
);
}
+
+ /* Return selected values for multiple edit */
function get_multi_edit_values()
{
$ret = plugin::get_multi_edit_values();
$ret['trustModel'] = $this->trustModel;
$ret['accessTo'] = $this->accessTo;
}
+ foreach(array("shadowWarning","shadowInactive","shadowMin","shadowMax", "shadowExpire") as $entry){
+ $active = "activate_".$entry;
+ if(in_array($active,$this->multi_boxes)){
+ $ret[$entry] = $this->$entry;
+ $ret[$active] = $this->$active;
+ }
+ }
+ if(in_array("mustchangepassword",$this->multi_boxes)){
+ $ret['mustchangepassword'] = $this->mustchangepassword;
+ }
return($ret);
}
+ /* Save posts for multiple edit
+ */
function multiple_save_object()
{
if(isset($_POST['posix_mulitple_edit'])){
+
+ /* Backup expire value */
+ $expire_tmp = $this->shadowExpire;
+
+ /* Update all values */
plugin::multiple_save_object();
- foreach(array("primaryGroup","trustmode") as $val){
+
+ /* Get selected checkboxes */
+ foreach(array("primaryGroup","trustmode","mustchangepassword","activate_shadowWarning","activate_shadowInactive","activate_shadowMin", "activate_shadowMax","activate_shadowExpire") as $val){
if(isset($_POST["use_".$val])){
$this->multi_boxes[] = $val;
}
}
+ /* Update special values, checkboxes for posixShadow */
+ foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning") as $var) {
+ if($this->acl_is_writeable($var)){
+ $activate_var = "activate_".$var;
+ if(in_array($activate_var, $this->multi_boxes)){
+ if(isset($_POST['activate_'.$var])){
+ $this->$activate_var = true;
+ $this->$var = $_POST[$var];
+ }else{
+ $this->$activate_var = false;
+ $this->$var = 0;
+ }
+ }
+ }
+ }
+
+ /* Restore shadow value, if the shadow attribute isn't used */
+ if(!in_array("activate_shadowExpire",$this->multi_boxes)){
+ $this->shadowExpire = $expire_tmp;
+ }
+
+ /* Force change password ? */
+ if(isset($_POST['mustchangepassword'])){
+ $this->mustchangepassword = TRUE;
+ }else{
+ $this->mustchangepassword = FALSE;
+ }
+
/* Trust mode - special handling */
if($this->acl_is_writeable("trustModel")){
if (isset($_POST['trustmode'])){
}
}
-
/* Save primary group settings */
if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){
$data= $_POST['primaryGroup'];
}
}
+
+ /* Initialize plugin with given atribute arrays
+ */
function init_multiple_support($attrs,$all)
{
plugin::init_multiple_support($attrs,$all);
- restore_error_handler();
-
+ /* Some dummy values */
$groups_some = array();
$groups_all = array();
$groups_uid = array();
- $uids = array();
- $first = TRUE;
+ $uids = array();
+ $first = TRUE;
+ /* Get all groups used by currently edited users */
$uid_filter="";
for($i =0; $i < $this->multi_attrs_all['uid']['count'] ; $i ++){
$uid = $this->multi_attrs_all['uid'][$i];
}
}
+ /* Create an array, containing all used groups */
$groups_all = $groups_some;
foreach($groups_all as $id => $group){
foreach($uids as $uid){
}
}
+ /* Assign group array */
$this->groupMembership = $groups_all;
+
+ /* Create an array of all grouops used by all users */
foreach( $groups_all as $dn => $cn){
if(isset($groups_some[$dn])){
unset($groups_some[$dn]);
$this->trustModel= "";
}
+ /* Create access informations */
$this->accessTo = array();
if (isset($this->multi_attrs['accessTo'])){
for ($i= 0; $i<$this->multi_attrs['accessTo']['count']; $i++){
$this->accessTo[$tmp]= $tmp;
}
}
+
+ /* Adjust shadow checkboxes */
+ foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive",
+ "shadowExpire") as $val){
+ if ($this->$val != 0){
+ $oval= "activate_".$val;
+ $this->$oval= "1";
+ }
+ }
+
+ /* Convert to seconds */
+ if(isset($this->multi_attrs['shadowExpire'])){
+ $this->shadowExpire = $this->convertToSeconds($this->multi_attrs['shadowExpire'][0]);
+ }else{
+ $this->activate_shadowExpire = FALSE;
+ }
}