X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_faiTemplate.inc;h=6207b37aa8f867c1361f958ff4c6b57aeff7cc3f;hb=8cd748822ec15f04dd8a97616de7c6ee2c7826e1;hp=b25f018c044cd7b607d49b5a59c1a707c762ac23;hpb=da2f6a4c4a33cc97a7e85f2207c2c668614677d6;p=gosa.git diff --git a/gosa-plugins/fai/admin/fai/class_faiTemplate.inc b/gosa-plugins/fai/admin/fai/class_faiTemplate.inc index b25f018c0..6207b37aa 100644 --- a/gosa-plugins/fai/admin/fai/class_faiTemplate.inc +++ b/gosa-plugins/fai/admin/fai/class_faiTemplate.inc @@ -66,6 +66,17 @@ class faiTemplate extends plugin $this->is_new =TRUE; } $this->ui = get_userinfo(); + + // Prepare lists + $this->templateList = new sortableListing(); + $this->templateList->setDeleteable(true); + $this->templateList->setEditable(true); + $this->templateList->setWidth("100%"); + $this->templateList->setHeight("120px"); + $this->templateList->setColspecs(array('200px','*')); + $this->templateList->setHeader(array(_("Name"),_("Download"))); + $this->templateList->setDefaultSortColumn(1); + } @@ -115,56 +126,55 @@ class faiTemplate extends plugin /* New Listhandling */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^editscript_/",$name)&&($once)){ - $once = false; - $entry = preg_replace("/^editscript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); - $obj = $this->SubObjects[$entry]; - + $this->templateList->save_object(); + $action = $this->templateList->getAction(); + if($action['action'] == 'delete'){ + $id = $this->templateList->getKey($action['targets'][0]); + $obj = $this->SubObjects[$id]; $acl_dn = $this->acl_base_for_current_object($obj['dn']); $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); - if(preg_match("/r/",$acl)){ - if($obj['status'] == "FreshLoaded"){ - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - } - $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); - $this->dialog->set_acl_base($this->acl_base); - $this->dialog->FAIstate = $this->FAIstate; - $this->dialog->set_acl_category("fai"); - - session::set('objectinfo',$obj['dn']); - $this->dialog->parent = &$this; - $this->is_dialog=true; + if(preg_match("/d/",$acl)){ + $status = $this->SubObjects[$id]['status']; + if($status == "edited" || $status == "FreshLoaded"){ + $this->SubObjects[$id]['status']= "delete"; + }else{ + unset($this->SubObjects[$id]); + } } - } - if(preg_match("/^deletescript_/",$name)&&($once) && !preg_match("/freeze/",$this->FAIstate)){ - $once = false; - $entry = preg_replace("/^deletescript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); - $obj = $this->SubObjects[$entry]; - + } + if($action['action'] == 'edit'){ + $id = $this->templateList->getKey($action['targets'][0]); + $obj = $this->SubObjects[$id]; $acl_dn = $this->acl_base_for_current_object($obj['dn']); $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); - if(preg_match("/d/",$acl)){ - $status = $this->SubObjects[$entry]['status']; - if($status == "edited" || $status == "FreshLoaded"){ - $this->SubObjects[$entry]['status']= "delete"; - }else{ - unset($this->SubObjects[$entry]); - } + if(preg_match("/r/",$acl)){ + if($obj['status'] == "FreshLoaded"){ + $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); + } + $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); + $this->dialog->set_acl_base($this->acl_base); + $this->dialog->FAIstate = $this->FAIstate; + $this->dialog->set_acl_category("fai"); + + set_object_info($obj['dn']); + $this->dialog->parent = &$this; + $this->is_dialog=true; } - } } - /* File download requested */ - if(isset($_GET['getFAItemplate'])){ - if(isset($this->SubObjects[$_GET['getFAItemplate']])){ - $obj = $this->SubObjects[$_GET['getFAItemplate']]; + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^download_/",$name)&&($once) && !preg_match("/freeze/",$this->FAIstate)){ + $once = false; + $entry = postDecode(preg_replace("/^download_/","",$name)); + $obj = $this->SubObjects[$entry]; $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - send_binary_content($obj['FAItemplateFile'],$obj['cn'].".FAItemplate"); - } + if(!isset($obj['cn'])){ + trigger_error("Something wen't wrong here!"); + }else{ + send_binary_content($obj['FAItemplateFile'],$obj['cn'].".FAItemplate"); + } + } } /* Edit entries via GET */ @@ -178,7 +188,7 @@ class faiTemplate extends plugin $this->dialog->FAIstate = $this->FAIstate; $this->dialog->acl = $this->acl; $this->dialog->set_acl_category("fai"); - session::set('objectinfo',$obj['dn']); + set_object_info($obj['dn']); $this->dialog->parent = &$this; $this->is_dialog=true; } @@ -186,7 +196,7 @@ class faiTemplate extends plugin /* Add new sub object */ if(isset($_POST['AddSubObject']) && !preg_match("/freeze/",$this->FAIstate)){ - $acl_dn = "cn=dummy,".$this->acl_base_for_current_object($this->dn); + $acl_dn = $this->acl_base_for_current_object($this->dn); $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); if(preg_match("/c/",$acl)){ @@ -200,7 +210,7 @@ class faiTemplate extends plugin } if($this->dn != "new"){ - session::set('objectinfo',$this->dn); + set_object_info($this->dn); } /* Save Dialog */ @@ -265,56 +275,35 @@ class faiTemplate extends plugin } /* Divlist Containing FAItemplates */ - $divlist = new divSelectBox("FAItemplates"); - $divlist->setHeight(400); + $dn = $this->acl_base_for_current_object($this->dn); + $acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry") ; + $this->templateList->setAcl($acl,preg_match('/^freeze/', $this->FAIstate)); $tmp = $this->getList(true); - - /* Create div list with all sub entries listed */ foreach($this->SubObjects as $key => $name){ /* Skip removed entries */ if($name['status'] == "delete") continue; - /* Get permissions */ - $dn = $this->acl_base_for_current_object($name['dn']); - $acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry") ; $act = ""; - /* Hide delete icon if this object is freezed */ - if(preg_match("/freeze/",$this->FAIstate)){ - $act .= ""; - }else{ - $act .= ""; - if(preg_match("/d/",$acl)){ - $act .=""; - } - } - /* Check acls for download icon */ + $dn = $this->acl_base_for_current_object($name['dn']); $s_acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry","FAItemplateFile") ; - if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ + if(($this->SubObjects[$key]['status'] == "new") || + ($this->SubObjects[$key]['dn'] == "new") || + !preg_match("/r/",$s_acl)){ $down = ""; }else{ - $down = " - "._("Download")." - "; - } - - /* Check if we are allowed to view this object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry","cn") ; - if(preg_match("/r/",$s_acl)){ - - $edit_link = "".$tmp[$key].""; - $divlist->AddEntry(array( array("string"=> $edit_link), - array("string"=>$down , "attach" => "style='width:20px;'"), - array("string"=>str_replace("%s",base64_encode($key),$act), - "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); + $down = image('images/save.png','download_'.postEncode($key), _("Download")); } + $data[$key] = $key; + $lData[$key] = array('data' => array($name['cn'], $down)); } - $smarty->assign("Entry_divlist",$divlist->DrawList()); - /* Divlist creation complete - */ + + $this->templateList->setListData($data,$lData); + $this->templateList->update(); + $smarty->assign("Entry_listing",$this->templateList->render()); /* Magic quotes GPC, escapes every ' " \, to solve some security risks * If we post the escaped strings they will be escaped again