parent = $parent; $this->ui = get_userinfo(); /* Set list strings */ $this->SetTitle(_("List of departments")); $this->SetSummary(_("List of departments")); $this->EnableAplhabet (true); /* Result page will look like a headpage */ $this->SetHeadpageMode(); $this->SetInformation(_("This menu allows you to create, delete and edit selected departments. Having a large number of departments, you might prefer the range selectors on top of the department list.")); /* Disable buttonsm */ $this->EnableCloseButton(false); $this->EnableSaveButton (false); /* Toggle all selected / deselected */ $chk = ""; /* set Page header */ $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); $this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''")); $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")); /* Add SubSearch checkbox */ $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); /* Name ,Text ,Default , Connect with alphabet */ $this->AddRegex ("Regex", _("Regular expression for matching department names"), "*" , true); } function GenHeader() { /* Prepare departments, which are shown in the listbox on top of the listbox */ $options= ""; /* Get all departments within this subtree */ $ui= get_userinfo(); $first = ""; $found = FALSE; $base = $this->config->current['BASE']; /* Add base */ $tmp = array(); $tmp[] = array("dn"=>$this->config->current['BASE']); $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); $deps = array(); foreach($tmp as $tm){ $deps[$tm['dn']] = $tm['dn']; } /* Load possible departments */ $ui= get_userinfo(); $tdeps= $ui->get_module_departments("department"); $ids = $this->config->idepartments; $first = ""; $found = FALSE; foreach($ids as $dep => $name){ if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ /* Keep first base dn in mind, we could need this * info if no valid base was found */ if(empty($first)) { $first = $dep['dn']; } $value = $ids[$dep]; if ($this->selectedBase == $dep){ $found = TRUE; $options.= ""; } else { $options.= ""; } } } /* The currently used base is not visible with your acl setup. * Set base to first useable base. */ if(!$found){ $this->selectedBase = $first; } /* Generate list head */ $ui = get_userinfo(); $acl = $ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department"); /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); if(preg_match("/c/",$acl)){ $listhead .= "  ". "   "; } $listhead .= "  ". " "._("Base")." ". "  "; /* Multiple options */ $listhead .= "  "; $listhead .="";; $this->SetListHeader($listhead); } function execute() { $this->ClearElementsList(); $this->GenHeader(); } function setEntries($list) { $linkopen = "%s"; $ui = get_userinfo(); foreach($list as $key => $val) { $actions= ""; $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department"); if(preg_match("/r/",$acl)){ $actions.= ""; } if(preg_match("/c/",$acl)){ $actions.= ""; } 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"; } } $title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key])); if($val == "."){ $field01 = array("string" => " ", "attach" => "style='width:20px;'"); }else{ $field01 = array("string" => "" , "attach" => "style='width:20px;'"); } $field0 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'"); $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align: right;'"); $this->AddElement( array($field01,$field0,$field1,$field2)); } /* Create summary string for list footer */ $num_deps=count($list); $str = $num_deps." "; $num_deps != 1 ? $str.=_("Departments") : $str .= _("Department"); $this->set_List_Bottom_Info($str); } function Save() { MultiSelectWindow::Save(); } function save_object() { /* Save automatic created POSTs like regex, checkboxes */ MultiSelectWindow::save_object(); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>