From: hickert Date: Thu, 17 Jul 2008 06:31:44 +0000 (+0000) Subject: Updated baseSelectDialog && MultiSelectWindow. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a09a60e76b41769b9575e2d966023179b7442a98;p=gosa.git Updated baseSelectDialog && MultiSelectWindow. -Fixed department selection. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11688 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_MultiSelectWindow.inc b/gosa-core/include/class_MultiSelectWindow.inc index 325b7e047..0b15a765d 100644 --- a/gosa-core/include/class_MultiSelectWindow.inc +++ b/gosa-core/include/class_MultiSelectWindow.inc @@ -666,17 +666,22 @@ class MultiSelectWindow{ /* Create an array with all visible (in the list) departments */ $types = departmentManagement::get_support_departments(); - $departments = array(); - foreach($deps as $value){ - $name = $value['ou'][0]." -".$value['dn']; - foreach($types as $type){ - if(in_array($type['OC'],$value['objectClass'])){ - $value['type'] = $type; - break; - } - } - $this->departments[$name]= $value; - } + + /* Create search filter + */ + $this->departments = array(); + foreach($types as $name => $data){ + $filter = "(&(objectClass=gosaDepartment)(objectClass=".$data['OC'].") + (".$data['ATTR']."=".$this->base_selection_regex."))"; + $tmp = get_list($filter,"department/".$data['ACL'],$this->selectedBase,array($data['ATTR'],"description"),GL_NONE); + foreach($tmp as $attrs){ + $attrs['NAME'] = $attrs[$data['ATTR']][0]; + $attrs['TYPE'] = $data; + $name = $attrs['NAME']." -".$attrs['dn']; + $this->departments[$name] = $attrs; + } + } + uksort($this->departments, 'strnatcasecmp'); $ui = get_userinfo(); @@ -691,10 +696,10 @@ class MultiSelectWindow{ /* Check if this department contains sub-departments Display different image in this case */ - $img = $val['type']['IMG']; + $img = $val['TYPE']['IMG']; foreach($this->config->departments as $keyd){ if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){ - $img = $val['type']['IMG_FULL']; + $img = $val['TYPE']['IMG_FULL']; } } @@ -711,7 +716,7 @@ class MultiSelectWindow{ /* Create entry name */ - $name = $val['ou'][0]; + $name = $val['NAME']; if(isset($val['description'])){ $name .= " - [".$val["description"][0]."]"; } diff --git a/gosa-core/include/class_baseSelectDialog.inc b/gosa-core/include/class_baseSelectDialog.inc index 494409270..d43da2ee6 100644 --- a/gosa-core/include/class_baseSelectDialog.inc +++ b/gosa-core/include/class_baseSelectDialog.inc @@ -32,7 +32,7 @@ class baseSelectDialog extends MultiSelectWindow function baseSelectDialog (&$config,$parent,$onlyAllowThisBases = array()) { - $module= "all"; + $module= "department"; MultiSelectWindow::MultiSelectWindow($config, "BASEselectWindow", $module); $this->parent = $parent; @@ -63,10 +63,6 @@ class baseSelectDialog extends MultiSelectWindow $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); $this->AddHeader(array("string"=>_("Base"))); - $this->AddHeader(array("string"=>_("Action"),"attach"=>"style='width:50px;border-right:0px;'")); - - /* Text ,Value ,Name ,Is selected */ -// $this->AddCheckBox("Doesnothing","servers","Doesnothing",true); /* Name ,Text ,Default , Connect with alphabet */ $this->AddRegex ("base_selection_regex",_("Filter entries with this syntax"),"*" , true); @@ -74,69 +70,14 @@ class baseSelectDialog extends MultiSelectWindow function execute() { - $this->setEntries(); + $this->ClearElementsList(); + $this->AddDepartments($this->selectedBase,2); return($this->Draw()); } function setEntries() { - $this->ClearElementsList(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->selectedBase); - $ldap->ls("(&(objectClass=gosaDepartment) - (|(ou=".$this->base_selection_regex.") - (cn=".$this->base_selection_regex.") - (description=".$this->base_selection_regex.")))", - $this->selectedBase,array("ou","description","cn")); - - $link = "%s"; - - $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase); - $base_back = convert_department_dn($base_back); - - /* Add departments, to be able to switch into them - */ - while($attrs = $ldap->fetch()){ - - $key = $attrs['dn'] ; - $val = $attrs['ou'][0]; - - if(count($this->allowedBases) != 0){ - if(!isset($this->allowedBases[$key])){ - continue; - break; - } - } - - /* Append description */ - if(isset($attrs['description'][0])){ - $val.=" [".$attrs['description'][0]."]"; - } - - /* Add missing entries ... */ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - /* check if this department contains sub-departments - Display different image in this case - */ - $non_empty=""; - $keys= str_replace("/","\/",$key); - foreach($this->config->departments as $keyd ){ - if(preg_match("/,".$keys."/",$keyd)){ - $non_empty="-full"; - } - } - - /* Add to divlist */ - $field1 = array("string" => "department", - "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($link,base64_encode($key),$val), "attach" => "style=''"); - $field3 = array("string" => sprintf(" ",base64_encode($key)), - "attach" => "style='width:50px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field1,$field2,$field3)); - } + // Do nothing here } function Save() @@ -154,64 +95,6 @@ class baseSelectDialog extends MultiSelectWindow { $this->selectedBase = $base; } - - function save_object() - { - /* Save current base */ - $old_base = $this->selectedBase; - - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - - if(isset($_GET['open_dep'])){ - $this->selectedBase = base64_decode($_GET['open_dep']); - } - - $s_action =""; - foreach($_POST as $key => $value){ - if(preg_match("/^dep_back.*/i",$key)){ - $s_action="back"; - }elseif(preg_match("/^dep_root.*/",$key)){ - $s_action="root"; - }elseif(preg_match("/^dep_home.*/i",$key)){ - $s_action="home"; - }elseif(preg_match("/^usebase_/",$key)){ - $tmp = preg_replace("/^usebase_/","",$key); - $tmp = preg_replace("/_.*$/","",$tmp); - $tmp = base64_decode($tmp); - $this->BaseToUse = $tmp; - } - } - - $ui= get_userinfo(); - /* Homebutton is posted */ - if($s_action=="home"){ - $this->selectedBase=(preg_replace("/^[^,]+,/","",$ui->dn)); - $this->selectedBase=(preg_replace("/^[^,]+,/","",$this->selectedBase)); - } - - /* back to the roots ^^ */ - if($s_action=="root"){ - $this->selectedBase=($this->config->current['BASE']); - } - - /* If Backbutton is Posted */ - if($s_action=="back"){ - $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase); - $base_back = convert_department_dn($base_back); - - if(isset($this->config->departments[trim($base_back)])){ - $this->selectedBase= $this->config->departments[trim($base_back)]; - }else{ - $this->selectedBase= $this->config->departments["/"]; - } - } - - /* Restore old base, if selected base is not allowed */ - if(count($this->allowedBases) && !isset($this->allowedBases[$this->selectedBase])){ - $this->selectedBase = $old_base; - } - } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>