From f861fe9cc9dd8256d00141a60980456616176f50 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 27 Feb 2006 07:43:06 +0000 Subject: [PATCH] Added base selection dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2741 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_baseSelectDialog.inc | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 plugins/admin/systems/class_baseSelectDialog.inc diff --git a/plugins/admin/systems/class_baseSelectDialog.inc b/plugins/admin/systems/class_baseSelectDialog.inc new file mode 100644 index 000000000..a0d9f340a --- /dev/null +++ b/plugins/admin/systems/class_baseSelectDialog.inc @@ -0,0 +1,172 @@ +selected_base = $config->current['BASE']; + + $this->SetTitle("Base"); + $this->SetSummary(_("Please choose your prefered base")); + $this->SetListHeader("
". + "  ". + "  ". + "  ". + "
"); + + $this->SetInformation(_("Step in the prefered tree and click save to use the subtree as base for the currently edited user. Or click the image on the end of each entry.")); + + $this->EnableAplhabet (true); + $this->EnableCloseButton(true); + $this->EnableSaveButton (true); + + $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>"Base")); + $this->AddHeader(array("string"=>"Option","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); + } + + function execute() + { + $this->setEntries(); + return($this->Draw()); + } + + function setEntries() + { + $this->ClearElementsList(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->selected_base); + $ldap->ls("(&(objectClass=gosaDepartment) + (|(ou=".$this->base_selection_regex.") + (cn=".$this->base_selection_regex.") + (description=".$this->base_selection_regex.")))", + $this->selected_base,array("ou","description","cn")); + + $link = "%s"; + + $base_back = preg_replace("/^[^,]+,/","",$this->selected_base); + $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]; + + /* 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)); + } + } + + function Save() + { + MultiSelectWindow :: Save(); + $this->selectedBase = $this->selected_base; + } + + function isSelected() + { + return($this->selectedBase); + } + + function setCurrentBase($base) + { + $this->selected_base = $base; + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + + if(isset($_GET['open_dep'])){ + $this->selected_base = 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->selectedBase = $tmp; + } + } + + $ui= get_userinfo(); + /* Homebutton is posted */ + if($s_action=="home"){ + $this->selected_base=(preg_replace("/^[^,]+,/","",$ui->dn)); + $this->selected_base=(preg_replace("/^[^,]+,/","",$this->selected_base)); + } + + /* back to the roots ^^ */ + if($s_action=="root"){ + $this->selected_base=($this->config->current['BASE']); + } + + /* If Backbutton is Posted */ + if($s_action=="back"){ + $base_back = preg_replace("/^[^,]+,/","",$this->selected_base); + $base_back = convert_department_dn($base_back); + + if(isset($this->config->departments[trim($base_back)])){ + $this->selected_base= $this->config->departments[trim($base_back)]; + }else{ + $this->selected_base= $this->config->departments["/"]; + } + } + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> -- 2.30.2