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()
{
/* Get all departments within this subtree */
$ui= get_userinfo();
$base = $this->config->current['BASE'];
$options = $this->create_department_list($this->module);
$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($this->selectedBase ,"department/".$type['ACL']))){
$s.= "...|".
" ".$type['TITLE']." (".$type['OC'].")|dep_new_".$type['OC']."|\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 = "post_id."&act=dep_open&dep_id=%s'>%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']);
/* Create actions
*/
$actions.= "";
if(preg_match("/d/",$acl)){
$actions.= "";
}
/* Create entry name
*/
$name = $val[$dep_data['ATTR']][0];
if(isset($val['description'])){
$name .= " - [".$val["description"][0]."]";
}
/* Create title
*/
$title = 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;'");
}
$img = "
";
/* 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_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:
?>