From 8b684fa68190e74156b8b518ddf8bd4aaa2eb48a Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 2 Dec 2008 12:56:20 +0000 Subject: [PATCH] Updated FAI listing -We can't actually remove entries. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13111 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_divListFai.inc | 135 ++++++------------ .../fai/admin/fai/class_faiManagement.inc | 80 ++++------- 2 files changed, 74 insertions(+), 141 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_divListFai.inc b/gosa-plugins/fai/admin/fai/class_divListFai.inc index f171d9c06..458ba09ef 100644 --- a/gosa-plugins/fai/admin/fai/class_divListFai.inc +++ b/gosa-plugins/fai/admin/fai/class_divListFai.inc @@ -50,7 +50,6 @@ class divListFai extends MultiSelectWindow /* 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" => _("Class name"), "attach" => "style=''")); $this->AddHeader(array("string" => _("Class type"), "attach" => "style='width:200px;'")); $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); @@ -128,9 +127,6 @@ class divListFai extends MultiSelectWindow /* Add seperator */ $add_sep = false; - /* Get complete fai acls, to be able to check if we must show or hide the snapshot abilities */ - $acl_all = $ui->has_complete_category_acls($this->parent->acl_base,$this->module); - /* Add default header */ $listhead = MultiSelectWindow::get_default_header(false); @@ -229,103 +225,60 @@ class divListFai extends MultiSelectWindow /* Dynamic action col, depending on snapshot icons */ $action_col_size = 130; -# if($this->parent->snapshotEnabled()){ -# $action_col_size += 32; -# } /******************** Attach objects ********************/ + /* Initialize summary attributes + */ $cnts = array(); foreach($objects as $key => $data){ $cnts[$key] = 0; } - foreach($list as $key => $value){ - $info = ""; - $img = ""; - $type = $value['type']; - $abort =false; - - $cnts[$type] ++; - - if(isset($objects[$type])){ - $img = "".$objects[$type]["; - $info = $objects[$type]['NAME']; - $var = $objects[$type]['VAR']; - }else{ - $img = ""; - $info = ""; - $var = ""; - } - - if((isset($value['description']))&&(!empty($value['description']))){ - $desc= " [".$value['description']."]"; - }else{ - $desc= ""; - } - - /* Add copy & cut icons */ - $ui = get_userinfo(); - $action =""; - $acl_all = $ui->has_complete_category_acls($this->parent->acl_base,$this->module); - - if(preg_match("/^opsi_/",$type)){ - $editlink ="%NAME%"; - $action.= " "; - }else{ - - /* Add copy & cut functionality */ - $action.= $this->parent->get_copypaste_action($value['dn'],"fai",$value['class'],TRUE,FALSE); - - if(preg_match("/^freeze/", $value['FAIstate'])){ - $editlink ="%NAME%"; - $action.= ""; - $action.= "F"; - }else{ - $editlink ="%NAME%"; - $action.= ""; - if(preg_match("/d/",$value['acl'])){ - $action.= ""; - } - } - } - -# $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); - - /* Cutted objects should be displayed in light grey */ - $display = $value['cn'].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $value['dn']) { - $display = "".$display.""; - break; - } - } - } - $edi = $editlink; - $acti = $action; - - $display = "
".$display."
"; - - /* Some objects are non ldap objects which do not have a dn. - */ - if(!isset($value['dn'])) $value['dn'] = ""; - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/","/%TITLE%/"),array($key,$display,preg_replace('/ /', ' ', LDAP::fix($value['dn']))),$edi) , "attach" => "style=''"); - $field3 = array("string" => $info, "attach" => "style='width:200px;'"); - $field4 = array("string" => preg_replace("/%KEY%/",$key,$acti) , "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); - } + /* Walk through entries an build up a printable row for each object + */ + foreach($list as $key => $value){ + + /* Build up edit icons - depending on read acls for the current type + */ + $name = ""; + $name = ""; + $icon_list = ""; + foreach($objects as $type => $type_data){ + if(isset($value[$type])){ + $name = $value[$type]['cn']; + $icon_list .= "\n"; + $cnts[$type] ++; + }else{ + $icon_list .= " \n"; + } + } + + /* Create actions string + */ + $actions = ""; + + + /* Create list + */ + $field1 = array( + "string" => "" , + "attach" => "style='width:20px;'"); + $field2 = array( + "string" => $name, + "attach" => "style=''"); + $field3 = array( + "string" => $icon_list , + "attach" => "style='width:200px;'"); + $field4 = array( + "string" => $actions, + "attach" => "style='width:".$action_col_size."px;border-right: 0px;text-align:right;'"); + + $this->AddElement(array($field1,$field2,$field3,$field4)); + } /* Create summary string for list footer */ $num_deps=0; diff --git a/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/gosa-plugins/fai/admin/fai/class_faiManagement.inc index 1e4155283..8148eb65b 100644 --- a/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -151,16 +151,12 @@ class faiManagement extends plugin break; } } - if(preg_match("/^entry_edit_.*/",$name)){ - $s_entry = preg_replace("/^entry_edit_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_action = "edit"; - break; - }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){ - $s_entry = preg_replace("/^entry_freeze_edit_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); + if(preg_match("/^edit_[0-9]*_.*$/",$name)){ + + $i_entryID = preg_replace("/^edit_([0-9]*)_.*$/i","\\1",$name); + $s_entryType= preg_replace("/^edit_[0-9]*_([^_]*)_.*$/i","\\1",$name); $s_action = "edit"; - $no_save = TRUE; + break; }elseif(preg_match("/^entry_delete_.*/",$name)){ $s_entry = preg_replace("/^entry_delete_/","",$name); @@ -187,17 +183,6 @@ class faiManagement extends plugin $s_action = "opsi_edit"; } - if(isset($_GET['edit_entry'])){ - $s_entry = $_GET['edit_entry']; - $s_action = "edit"; - } - - if(isset($_GET['edit_freeze_entry'])){ - $s_entry = $_GET['edit_freeze_entry']; - $s_action = "edit"; - $no_save = TRUE; - } - if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){ $s_action = "freeze_branch"; } @@ -503,23 +488,25 @@ class faiManagement extends plugin ****************/ if(($s_action == "edit") && (!isset($this->dialog->config))){ - $entry = $this->objects[$s_entry]; - $a_setup = $this->get_type($entry); - $this->dn = $entry['dn']; + if(isset($this->objects[$i_entryID][$s_entryType])){ + $entry = $this->objects[$i_entryID][$s_entryType]; + $a_setup = $this->get_type($entry); + $this->dn = $entry['dn']; - /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn, TRUE)); - } - add_lock ($this->dn, $this->ui->dn); - - $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); - $this->dialog->parent = &$this; - $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate']; - $this->dialog->set_acl_base($this->dn); - $this->is_dialog = true; - session::set('objectinfo',$this->dn); - } + /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn, TRUE)); + } + add_lock ($this->dn, $this->ui->dn); + + $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); + $this->dialog->parent = &$this; + $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate']; + $this->dialog->set_acl_base($this->dn); + $this->is_dialog = true; + session::set('objectinfo',$this->dn); + } + } /* Branch handling @@ -1198,8 +1185,8 @@ class faiManagement extends plugin $obj['description'] = $object['description'][0]; $obj['objectClass'] = $object['objectClass']; - $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj; - $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; + $this->objects[$obj['cn']][$type] = $obj; + $this->objects[$obj['cn']][$type]['type']=$type; } } } @@ -1217,7 +1204,7 @@ class faiManagement extends plugin $entry = array("cn" => $name, "description" => $data['DESC'], "type" => "opsi_netboot"); - $this->objects[$name."_opsi_netboot"] = $entry; + $this->objects[$name]['opse_netboot'] = $entry; } } if(!$err && $this->DivListFai->ShowOpsiLocal){ @@ -1227,7 +1214,7 @@ class faiManagement extends plugin $entry = array("cn" => $name, "description" => $data['DESC'], "type" => "opsi_local"); - $this->objects[$name."_opsi_local"] = $entry; + $this->objects[$name]["opsi_local"] = $entry; } } if($err){ @@ -1235,17 +1222,10 @@ class faiManagement extends plugin } } } - - ksort($this->objects); + + uksort($this->objects, 'strnatcasecmp'); reset ($this->objects); - - /* use numeric index, thats a bit more secure */ - $tmp0 = array(); - foreach($this->objects as $obj){ - $tmp0[]= $obj; - } - $this->objects = array(); - $this->objects = $tmp0; + $this->objects = array_values($this->objects); } function remove_lock() -- 2.30.2