X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fusers%2Fclass_userManagement.inc;h=88936bd503a44fca137274790f3a877074bdd5c7;hb=c3a786a7af7dcec35d946e2e7f551ab29f05ad1c;hp=6c3c8cebf8f9d51da5cec7299d94e7bbfe92a3d2;hpb=6a79b10e21f085430ba627a1ae8a1be22dd30d24;p=gosa.git diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 6c3c8cebf..88936bd50 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -59,6 +59,9 @@ class userManagement extends plugin function execute() { + /* Call parent execute */ + plugin::execute(); + $smarty = get_smarty(); // Smarty instance $userfilter = get_global("userfilter"); // contains Filter Settings $s_action = ""; // Contains the action to proceed @@ -347,7 +350,7 @@ class userManagement extends plugin /* Lock the current entry, so nobody will edit it during deletion */ add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the user %s."), $this->dn)); + $smarty->assign("info", sprintf(_("You're about to delete the user %s."), LDAP::fix($this->dn))); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } else { @@ -457,15 +460,26 @@ class userManagement extends plugin /* Generate template list */ if (($s_action=="new")||($s_action=="create_user_from_tpl")){ + $this->templates= array(); + $ldap= $this->config->get_ldap_link(); + + /* Create list of tempaltes */ foreach ($this->config->departments as $key => $value){ + + /* Get acls from different ou's */ $acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL); $acl= get_module_permission($acl, "user", get_people_ou().$value); + + /* If creation of a new user is allowed, append this template */ if (chkacl($acl, "create") == ""){ + + /* Search all templates from the current dn */ $ldap->cd (get_people_ou().$value); $ldap->search ("(objectClass=gosaUserTemplate)", array("uid")); + /* Append */ if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ $this->templates[$ldap->getDN()]= @@ -475,6 +489,8 @@ class userManagement extends plugin } } } + + /* Sort templates */ natcasesort ($this->templates); reset ($this->templates); } @@ -494,6 +510,7 @@ class userManagement extends plugin $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $this->dn); $this->usertab->set_acl(array(':all')); + $this->usertab->by_object['user']->base= $userfilter['depselect']; /* Take care about templates */ if ($s_action=="new_tpl"){ @@ -504,14 +521,15 @@ class userManagement extends plugin } /* Use template if there are any of them */ - if ((count($this->templates) && !isset($_POST['new_template']))||($s_action=="create_user_from_tpl")){ + + if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){ foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){ $smarty->assign("$attr", $this->$attr); } if ($s_action=="create_user_from_tpl"){ $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']); } else { - $smarty->assign("template", ""); + $smarty->assign("template", "none"); } $smarty->assign("edit_uid", ""); return($smarty->fetch(get_template_path('template.tpl', TRUE))); @@ -649,33 +667,33 @@ class userManagement extends plugin /* NEW LIST MANAGMENT */ $listhead = "
". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - _("Current base")." ". - "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + _("Base")." ". + "  ". "
"; - $action= ""; - $action.= ""; - $action.= ""; + $action= ""; + $action.= ""; + $action.= ""; $divlist = new divlist("userstab"); $divlist->SetHeader(array( - array("string" => " "), - array("string" => _("Username")." / "._("Department")), - array("string" => _("Properties")), - array("string" => _("Actions"), "attach" => "style='border:none'" ))); + array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => _("Username")." / "._("Department"), "attach" => "style=''"), + array("string" => _("Properties"), "attach" => "style='width:152px;'"), + array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'"))); $divlist->SetSummary(_("This table displays all users, in the selected tree.")); - $divlist->SetEntriesPerPage(20); + $divlist->SetEntriesPerPage(0); // Defining Links $linkopen = "%s"; @@ -695,39 +713,39 @@ class userManagement extends plugin } } - $field1 = array("string" => "department"); - $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val)); - $field3 = array("string" => " "); - $field4 = array("string" => " ", "attach" => "style='border:none'"); + $field1 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); + $field3 = array("string" => " ", "attach" => "style='width:152px;'"); + $field4 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3,$field4)); } /* Pictures for Extensions */ - $usrimg =""; - $posiximg = ""; - $eviroimg = ""; - $mailimg = ""; - $fonimg = ""; - $faximg = ""; - $sambaimg = ""; - $tplcreateuserimg = ""; - $empty = ""; + $empty = ""; // User and Template Images - $userimg = "User"; - $tplimg = "Template"; + $userimg = "User"; + $tplimg = "Template"; $editlink = "%s"; // Defines Arrays to save User and Templates @@ -751,10 +769,14 @@ class userManagement extends plugin /* If you want to disable the status pictures, just comment out the next line */ - $r_con= @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); - // Check if we are connected correctly - if($r_con){ - $r_db = @mysql_select_db($a_SETUP['DB'],$r_con); + $r_con = false; + $r_db = false; + if(is_callable("mysql_pconnect")){ + $r_con= @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); + // Check if we are connected correctly + if($r_con){ + $r_db = @mysql_select_db($a_SETUP['DB'],$r_con); + } } } @@ -770,7 +792,7 @@ class userManagement extends plugin $fonac = preg_replace("/%title%/", "", $fonac); /* Database connection is ok ?*/ - if($r_db){ + if(($r_db)&&(is_callable("mysql_query"))){ $res= @mysql_query("SELECT regseconds,name,port,ipaddr FROM ".$a_SETUP['SIP_TABLE']." WHERE (name='".$val['uid'][0]."')"); $mysql_entry = @mysql_fetch_row($res); if(is_array($mysql_entry)){ @@ -793,6 +815,8 @@ class userManagement extends plugin $fonac=$empty; } + + // Specify Pics for Extensions if(in_array("posixAccount" ,$val['objectClass'])){ $posix = preg_replace("/%KEY%/", "$key", $posiximg); @@ -842,10 +866,10 @@ class userManagement extends plugin } /* Create each field */ - $field1 = array("string" => sprintf($tpl,$val['dn']),"attach"=>"style='width:20px;align:middle;'"); - $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port,"attach"=>"title='".$val['dn']."'"); - $field3 = array("string" => $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$s_img_create_from_template, "attach" => "style='width:150px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:48px'"); + $field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='".$val['dn']."'"); + $field3 = array("string" => $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$s_img_create_from_template, "attach" => "style='width:152px;'"); + $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='width:60px;border-right:0px;text-align:right;'"); $add = array($field1,$field2,$field3,$field4); @@ -894,6 +918,9 @@ class userManagement extends plugin $smarty->assign("alphabet", generate_alphabet()); $smarty->assign("hint", print_sizelimit_warning()); + if((is_callable("mysql_close"))&&($r_con)){ + @mysql_close($r_con); + } return ($smarty->fetch(get_template_path('headpage.tpl', TRUE))); } @@ -962,23 +989,37 @@ class userManagement extends plugin * We also need to search for the departments * So we are able to navigate like in konquerer */ - $base2 = preg_replace("/ou=people,/i","",$base); + /* Create base to search in */ + + $peopleOU = get_people_ou(); + if(empty($peopleOU)) { + $base2 = $base; + }else{ + $base2 = preg_replace("/".$peopleOU."/i","",$base); + } + + /* Get all departments within this subtree */ $res3 = get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", TRUE, $base2, array("ou", "description"), TRUE); $this->departments= array(); + /* Create array with results */ $tmp = array(); foreach ($res3 as $value){ $tmp[strtolower($value['dn']).$value['dn']]=$value; } + + /* Sort array */ ksort($tmp); + + /* Create result array */ foreach($tmp as $value){ - if($value["description"][0]!=".."){ + if(isset($value['description'][0])){ $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]"; }else{ - $this->departments[$value['dn']]=$value["description"][0]; + $this->departments[$value['dn']]=convert_department_dn2($value['dn']); } } /* END NEW LIST MANAGMENT