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(); /* 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", msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), 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(); /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); $listhead .= " "._("Base")." ". "  "; /* Create Layers menu */ $s = ".|"._("Actions")."|\n"; /* Append create options */ $s .= "..|". " "._("Create")."|\n"; /* Add all createable department types */ $types = $this->parent->get_support_departments(); foreach($types as $type){ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/".$type['ACL']))){ $s.= "...|". " ".$type['TITLE']." (".$type['ATTR'].")|dep_new_".$type['ATTR']."|\n"; } } /* Add remove action */ $s.= "..|---|\n"; $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); } function execute() { $this->ClearElementsList(); $this->GenHeader(); } function setEntries($list) { $linkopen = "%s"; $types = $this->parent->get_support_departments(); $this->departments = $list; $ui = get_userinfo(); foreach($list as $key => $val) { $actions= ""; /* Detect department type */ $dep_data = array(); foreach($types as $type => $data){ if(in_array($type,$val['objectClass'])){ $dep_data = $data; break; } } /* Warn if there was an unknown department type found */ if(!count($dep_data)) { trigger_error("Unknown department type given. Skipped '".$val['dn']."'."); continue; } /* Get permissions */ $acl = $ui->get_permissions($val['dn'],"department/".$dep_data['ACL']); $acl_all = $ui->has_complete_category_acls($val['dn'],"department"); /* Create actions */ $actions.= ""; if(preg_match("/d/",$acl)){ $actions.= ""; } /* Check if this department contains sub-departments Display different image in this case */ $sub_folders= FALSE; foreach($this->config->departments as $keyd){ if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){ $sub_folders = TRUE; } } /* Create entry name */ $name = $val[$dep_data['ATTR']][0]; if(isset($val['description'])){ $name .= " - [".$val["description"][0]."]"; } /* Create title */ $title = preg_replace('/ /', ' ', @LDAP::fix($val['dn'])); /* Create checkboxes infront of the entry */ if($name == "."){ $field01 = array("string" => " ", "attach" => "style='width:20px;'"); }else{ $field01 = array("string" => "" , "attach" => "style='width:20px;'"); } /* Create image */ if($sub_folders){ $img = "".$dep_data["; }else{ $img = "".$dep_data["; } /* Append data to the listing */ $field0 = array("string" => $img, "attach" => "style='text-align:center;width:20px;'"); $field1 = array("string" => sprintf($linkopen,$key,$name), "attach" => "style='' title='".$title."'"); $field2 = array("string" => preg_replace("/%KEY%/", $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); $num_dep_str = _("Number of listed departments"); $str = "".$num_dep_str." ".$num_deps."    "; $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: ?>