X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Fplugins%2Fadmin%2Fdepartments%2Fclass_divListDepartment.inc;h=469b0163bc93a34d4c6c0f1d270874bcc1686db4;hb=8dc7cd7fa1e01bcfab1d824fcc2d47c63b51000e;hp=d33e817d36060a30537fe36b49a21c46487f709c;hpb=cb72d09b8cefe3438d2e4bec8d03ac3caa1d39c8;p=gosa.git diff --git a/gosa-core/plugins/admin/departments/class_divListDepartment.inc b/gosa-core/plugins/admin/departments/class_divListDepartment.inc index d33e817d3..469b0163b 100644 --- a/gosa-core/plugins/admin/departments/class_divListDepartment.inc +++ b/gosa-core/plugins/admin/departments/class_divListDepartment.inc @@ -58,7 +58,7 @@ class divListDepartment extends MultiSelectWindow /* Toggle all selected / deselected */ - $chk = ""; /* set Page header */ @@ -135,26 +135,53 @@ class divListDepartment extends MultiSelectWindow /* Generate list head */ $ui = get_userinfo(); - $acl = $ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department"); /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); $listhead .= " "._("Base")." ". - "  "; /* Create Layers menu */ $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Department")."|dep_new|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department"))) { + $s.= "...|". + " "._("Department")." (ou)|dep_new_ou|\n"; + } + + if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/organization"))) { + $s.= "...|". + " "._("Organization")." (o)|dep_new_o|\n"; + } + + if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/country"))) { + $s.= "...|". + " "._("Country")." (c)"."|dep_new_c|\n"; + } + + if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/locality"))) { + $s.= "...|". + " "._("Locality")." (l)|dep_new_l|\n"; + } + + if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/alias"))) { + $s.= "...|". + " "._("Alias")."|dep_new_alias|\n"; + } + + if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/referal"))) { + $s.= "...|". + " "._("Referal")."|dep_new_referal|\n"; + } + $s.= "..|---|\n"; $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; @@ -174,52 +201,114 @@ class divListDepartment extends MultiSelectWindow { $linkopen = "%s"; + + /* Possible department types + */ + $types['country'] = array("ACL" => "country", "ATTR" => "c", + "TITLE" => _("Department"), + "IMG_FULL" => "plugins/departments/images/country.png", + "IMG" => "plugins/departments/images/country.png", "ABBR" => "c"); + $types['locality'] = array("ACL" => "locality", "ATTR" => "l", + "TITLE" => _("Department"), + "IMG" => "plugins/departments/images/locality.png", "ABBR" => "l"); + $types['organizationalUnit'] = array("ACL" => "department", "ATTR" => "ou", + "TITLE" => _("Department"), + "IMG_FULL" => "images/lists/folder-full.png", + "IMG" => "images/lists/folder.png", "ABBR" => "ou"); + $types['organization'] = array("ACL" => "organization", "ATTR" => "o", + "TITLE" => _("Department"), + "IMG" => "plugins/departments/images/organization.png", "ABBR" => "o"); + $types['Alias??'] = array("ACL" => "alias" , "ATTR" => "alias?", + "TITLE" => _("Department"), + "IMG" => "plugins/departments/images/department_alias.png", "ABBR" => "alias"); + $types['Referal??'] = array("ACL" => "referal", "ATTR" => "referal?", + "TITLE" => _("Department"), + "IMG" => "plugins/departments/images/department_referal.png", "ABBR" => "referal"); + + $this->departments = $list; + $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.= ""; + /* 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; } - if(preg_match("/c/",$acl)){ + /* 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.= ""; } - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - /* check if this department contains sub-departments + /* Check if this department contains sub-departments Display different image in this case */ - $non_empty=""; - $nkey= normalizePreg($key); - foreach($this->config->departments as $keyd=>$vald ){ - if(preg_match('/$nkey\/.*/',$keyd)){ - $non_empty="full"; + $sub_folders= FALSE; + foreach($this->config->departments as $keyd){ + if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){ + $sub_folders = TRUE; } } - $title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key])); + /* 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'])); - if($val == "."){ + /* Create checkboxes infront of the entry + */ + if($name == "."){ $field01 = array("string" => " ", "attach" => "style='width:20px;'"); }else{ - $field01 = array("string" => "" , + $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;'"); + /* Create image + */ + if($sub_folders){ + $img = ""; + }else{ + $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)); } @@ -227,7 +316,7 @@ class divListDepartment extends MultiSelectWindow /* 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);