summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e79b3cd)
raw | patch | inline | side by side (parent: e79b3cd)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 13 Jun 2008 08:59:36 +0000 (08:59 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 13 Jun 2008 08:59:36 +0000 (08:59 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11318 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-core/plugins/admin/departments/class_departmentManagement.inc b/gosa-core/plugins/admin/departments/class_departmentManagement.inc
index 26ed101aa8c1b4bdf7b2536dfd0a2faa8d6b1b86..2d84632ef94ea9034797092cf825e800cae6aca0 100644 (file)
$config = session::get('config');
$tmp = $config->idepartments;
- // In case of a valid back button create entry
- if(isset($tmp[$base_back])){
- $tmp2 ['dn'] = convert_department_dn($base_back);
-
- // If empty always go to top
- if(empty($tmp2['dn'])){
- $tmp2['dn']="/";
- }
- $tmp2 ['description'][0] = ".. ".msgPool::backButton();
- $result[$tmp[$base_back]]=$tmp2;
- }
-
-
-
+ /* Possible department types
+ */
+ $types['country'] = array("ACL" => "country", "ATTR" => "c",
+ "CLS" => "(objectClass=country)",
+ "IMG" => "plugins/departments/images/country.png", "ABBR" => "c");
+ $types['locality'] = array("ACL" => "locality", "ATTR" => "l",
+ "CLS" => "(objectClass=locality)",
+ "IMG" => "plugins/departments/images/country.png", "ABBR" => "l");
+ $types['organizationalUnit'] = array("ACL" => "department", "ATTR" => "ou",
+ "CLS" => "(&(objectClass=gosaDepartment)(objectClass=organizationalUnit))",
+ "IMG" => "plugins/departments/images/country.png", "ABBR" => "ou");
+ $types['organization'] = array("ACL" => "organization", "ATTR" => "o",
+ "CLS" => "(objectClass=organization)",
+ "IMG" => "plugins/departments/images/country.png", "ABBR" => "o");
+ $types['Alias??'] = array("ACL" => "alias" , "ATTR" => "alias?",
+ "CLS" => "(objectClass=alias??)",
+ "IMG" => "plugins/departments/images/country.png", "ABBR" => "alias");
+ $types['Referal??'] = array("ACL" => "referal", "ATTR" => "referal?",
+ "CLS" => "(objectClass=referal??)",
+ "IMG" => "plugins/departments/images/country.png", "ABBR" => "referal");
+
+ /* Create search filter for each department type
+ */
+ $res = array();
if($this->DivListDepartment->SubSearch){
- $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
- "department", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+ foreach($types as $oc => $data){
+ $res= array_merge($res,get_list("(&(|(".$data['ATTR']."=$Regex)(description=$Regex))".$data['CLS'].")",
+ "department", $base, array($data['ATTR'],"objectClass", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+ }
}else{
- $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
- "department", $base, array("ou", "description"), GL_SIZELIMIT );
- }
-
-
- /**/
- $non_ou = get_list("(&(|(c=$Regex)(description=$Regex))(objectClass=country))",
- "department", $base, array("c", "description"), GL_SIZELIMIT );
- $non_ou = array_merge($non_ou,get_list("(&(|(l=$Regex)(description=$Regex))(objectClass=locality))",
- "department", $base, array("l", "description"), GL_SIZELIMIT ));
- $non_ou = array_merge($non_ou,get_list("(&(|(o=$Regex)(description=$Regex))(objectClass=organization))",
- "department", $base, array("o", "description"), GL_SIZELIMIT ));
-
- $this->departments= array();
- foreach($non_ou as $obj){
- $this->departments[] = $obj['dn'];
- }
-
-
- /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */
- if(preg_match("/^ou=/",$base)){
- $this->departments [ convert_department_dn($base) ] = ".";
+ foreach($types as $oc => $data){
+ $res= array_merge($res,get_list("(&(|(".$data['ATTR']."=$Regex)(description=$Regex))".$data['CLS'].")",
+ "department", $base, array($data['ATTR'], "objectClass","description"), GL_SIZELIMIT ));
+ }
}
- foreach ($res as $key => $value){
+ /* Prepare list (sortable index)
+ */
+ $deps = array();
+ $this->departments = array();
+ foreach($res as $attr){
/* Don't display base as entry on subsearch */
- if(($value['dn'] == $base) && ($this->DivListDepartment->SubSearch)){
+ if(($attr['dn'] == $base) && ($this->DivListDepartment->SubSearch)){
continue;
}
- $cdn= convert_department_dn($value['dn']);
-
- /* Append to dep list */
- if(isset($value["description"][0])){
- $this->departments[$cdn]= get_sub_department($cdn)." - [".$value["description"][0]."]";
- }else{
- $this->departments[$cdn]= get_sub_department($cdn);//$value["description"][0];
+ /* Detect type and create sortable index
+ */
+ $found =FALSE;
+ foreach($types as $oc => $data){
+ if(in_array($oc,$attr['objectClass'])){
+ $name = $attr[$data['ATTR']][0]."-".$attr['dn'];
+ $deps[$name] = $attr;
+ $found =TRUE;
+ break;
+ }
}
+ if(!$found ) trigger_error("Not found!");
+ }
+ uksort($deps, 'strnatcasecmp');
+
+ /* In case of a valid back button create entry
+ */
+ if(isset($tmp[$base_back])){
+ $tmp = array();
+ $tmp['dn'] = $base_back;
+ $tmp['ou'][0] = "..";
+ $tmp['objectClass'] = array("organizationalUnit","gosaDepartment");
+ $tmp['description'][0] = msgPool::backButton();
+ $deps= array_merge(array($tmp),$deps);
}
- natcasesort ($this->departments);
- reset ($this->departments);
+ $this->departments = array_values($deps);
}
function remove_from_parent()
diff --git a/gosa-core/plugins/admin/departments/class_divListDepartment.inc b/gosa-core/plugins/admin/departments/class_divListDepartment.inc
index 6fa3f8d0779effceb6245756b67e89aa9812652f..469b0163bc93a34d4c6c0f1d270874bcc1686db4 100644 (file)
/* Generate list head */
$ui = get_userinfo();
- $acl = $ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department");
/* Add default header */
$listhead = MultiSelectWindow::get_default_header();
$s = ".|"._("Actions")."|\n";
/* Append create options */
- if(preg_match("/c/",$acl)) {
- $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
- " "._("Create")."|\n";
+ $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
+ " "._("Create")."|\n";
+
+ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department"))) {
$s.= "...|<input class='center' type='image' src='plugins/departments/images/department.png' alt=''>".
" "._("Department")." (ou)|dep_new_ou|\n";
- $s.= "...|<input class='center' type='image' src='plugins/departments/images/department.png' alt=''>".
+ }
+
+ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/organization"))) {
+ $s.= "...|<input class='center' type='image' src='plugins/departments/images/organization.png' alt=''>".
" "._("Organization")." (o)|dep_new_o|\n";
+ }
- $s.= "...|<input class='center' type='image' src='plugins/departments/images/department.png' alt=''>".
+ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/country"))) {
+ $s.= "...|<input class='center' type='image' src='plugins/departments/images/country.png' alt=''>".
" "._("Country")." (c)"."|dep_new_c|\n";
+ }
- $s.= "...|<input class='center' type='image' src='plugins/departments/images/department.png' alt=''>".
+ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/locality"))) {
+ $s.= "...|<input class='center' type='image' src='plugins/departments/images/locality.png' alt=''>".
" "._("Locality")." (l)|dep_new_l|\n";
+ }
- $s.= "...|<input class='center' type='image' src='plugins/departments/images/department.png' alt=''>".
+ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/alias"))) {
+ $s.= "...|<input class='center' type='image' src='plugins/departments/images/department_alias.png' alt=''>".
" "._("Alias")."|dep_new_alias|\n";
+ }
- $s.= "...|<input class='center' type='image' src='plugins/departments/images/department.png' alt=''>".
+ if(preg_match("/c/",$ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/referal"))) {
+ $s.= "...|<input class='center' type='image' src='plugins/departments/images/department_referal.png' alt=''>".
" "._("Referal")."|dep_new_referal|\n";
-
- $s.= "..|---|\n";
}
+
+ $s.= "..|---|\n";
$s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
" "._("Remove")."|"."remove_multiple|\n";
{
$linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
+
+ /* 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= "";
- if(!isset($this->config->departments[$key])){
-
- $field01 = array("string" => " ", "attach" => "style='width:20px;'");
- $field0 = array("string" => "<img src='images/".$non_empty."lists/folder.png'
- title='"._("department")."' alt='department'>",
- "attach" => "style='text-align:center;width:20px;'");
- $field1 = array("string" => $val, "attach" => "style='' title='".$val."'");
- $field2 = array("string" => "", "attach" => "style='border-right: 0px;'");
-
- }else{
- $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department");
- $acl_all = $ui->has_complete_category_acls($this->config->departments[$key] ,"department");
-
- $actions.= "<input class='center' type='image' src='images/lists/edit.png'
- alt='"._("edit")."' name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
-
- if(preg_match("/d/",$acl)){
- $actions.= "<input class='center' type='image' src='images/lists/trash.png'
- alt='"._("delete")."' name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
+ /* 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(!isset($this->config->departments[trim($key)])){
- $this->config->departments[trim($key)]="";
- }
+ /* 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.= "<input class='center' type='image' src='images/lists/edit.png'
+ alt='"._("edit")."' name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
+ if(preg_match("/d/",$acl)){
+ $actions.= "<input class='center' type='image' src='images/lists/trash.png'
+ alt='"._("delete")."' name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
+ }
- /* 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";
- }
+ /* 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;
}
+ }
- $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]."]";
+ }
- if($val == "."){
- $field01 = array("string" => " ",
- "attach" => "style='width:20px;'");
- }else{
- $field01 = array("string" => "<input type='checkbox' id='item_selected_".base64_encode($key)."'
- name='item_selected_".base64_encode($key)."'>" ,
- "attach" => "style='width:20px;'");
- }
+ /* Create title
+ */
+ $title = preg_replace('/ /', ' ', @LDAP::fix($val['dn']));
- $field0 = array("string" => "<img src='images/".$non_empty."lists/folder.png' title='"._("department")."' alt='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 checkboxes infront of the entry
+ */
+ if($name == "."){
+ $field01 = array("string" => " ",
+ "attach" => "style='width:20px;'");
+ }else{
+ $field01 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+ "attach" => "style='width:20px;'");
+ }
+ /* Create image
+ */
+ if($sub_folders){
+ $img = "<img src='".$dep_data['IMG_FULL']."' class='center' title='".$dep_data['TITLE']."'>";
+ }else{
+ $img = "<img src='".$dep_data['IMG']."' class='center' title='".$dep_data['TITLE']."'>";
}
+
+ /* 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));
}
diff --git a/gosa-core/plugins/admin/departments/tabs_department.inc b/gosa-core/plugins/admin/departments/tabs_department.inc
index e8a7842487da9107811ff9967961f148265c2145..86f0acd65053e2613b59e6bfb7b7b2541b94a665 100644 (file)
/* Detect the base class (The classs which extends from department)
*/
- $class = "department";
foreach($this->by_object as $name => $object){
if($object instanceOf department){
$this->base_name = get_class($object);