PostVarName = $postvar; if(!session::is_set('glpi_user_filter')){ $tmp['users_regex'] = "*"; $tmp['base'] = $this->config->current['BASE']; session::set('glpi_user_filter',$tmp); } $this->ui = get_userinfo(); } function execute() { /* Call parent execute */ plugin::execute(); if(isset($_POST['depselect'])){ session::set('glpi_user_filter', array('base' => $_POST['depselect'])); } $filter = session::get('glpi_user_filter'); /* Filter settings, remove double* */ if(isset($_GET['search'])){ $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*"); }elseif(isset($_POST['regex'])){ $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']); } if(empty($filter['users_regex'])) { $filter = "*"; } $s_action=""; /* Test Posts */ foreach($_POST as $key => $val){ // Post for delete if(preg_match("/dep_back.*/i",$key)){ $s_action="back"; }elseif(preg_match("/user_new.*/",$key)){ $s_action="new"; }elseif(preg_match("/dep_home.*/i",$key)){ $s_action="home"; } } /* Homebutton is posted */ if($s_action=="home"){ $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn)); $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base'])); } if($s_action=="root"){ $filter['base']=($this->config->current['BASE']); } /* If Backbutton is Posted */ if($s_action=="back"){ $base_back = preg_replace("/^[^,]+,/","",$filter['base']); $base_back = convert_department_dn($base_back); if(isset($this->config->departments[trim($base_back)])){ $filter['base']= $this->config->departments[trim($base_back)]; }else{ $filter['base']= $this->config->departments["/"]; } } if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ $entry = base64_decode($_GET['dep_id']); $filter['base']= ($this->config->departments[$entry]); } session::set('glpi_user_filter',$filter); $this->reload(); /* Fill templating stuff */ $smarty= get_smarty(); $display= ""; $divlist = new divlist("glpi users"); $divlist->SetPluginMode(); $divlist->SetEntriesPerPage(0); $divlist->SetHeader(array( array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"), array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); $linkopen = "%s"; foreach($this->departments as $key=> $val){ if(!isset($this->config->departments[trim($key)])){ $this->config->departments[trim($key)]=""; } $non_empty=""; $keys= str_replace("/","\/",$key); foreach($this->config->departments as $keyd=>$vald ){ if(preg_match("/".$keys."\/.*/",$keyd)){ $non_empty="full"; } } $field1 = array("string" => "", "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3)); } $useruse = "PostVarName."&id=%s'>%s"; foreach($this->users as $key=>$user){ $field1 = array("string" => "", "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''"); $field3 = array("string" => sprintf($useruse,base64_encode($key),""), "attach" => "style='width:60px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3)); } /* Prepare departments, which are shown in the listbox on top of the listbox */ /* Get all departments within this subtree */ $glpi_user_filter = session::get('glpi_user_filter'); $this->base = $glpi_user_filter['base']; $options =""; $base = $this->config->current['BASE']; $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); /* Load possible departments */ $ui= get_userinfo(); $tdeps= $ui->get_module_departments("users"); $ids = $this->config->idepartments; foreach($deps as $dep){ if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){ $value = $ids[$dep['dn']]; if ($this->base == $dep['dn']){ $options.= ""; } else { $options.= ""; } } } $listhead = "