From 02d58d450cb7c6d1a5c998f56fbfbe756c074d76 Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 13 Nov 2006 08:41:57 +0000 Subject: [PATCH] Updated role acl and enabled save button, if we're allowed to do *something* with the object git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5078 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_CopyPasteHandler.inc | 14 ++++-- plugins/admin/fai/class_faiHook.inc | 6 ++- plugins/admin/fai/class_faiManagement.inc | 2 +- plugins/admin/fai/class_faiPackage.inc | 2 + plugins/admin/fai/class_faiProfile.inc | 56 +++++++++++++++-------- plugins/admin/fai/class_faiScript.inc | 8 +++- plugins/admin/fai/class_faiTemplate.inc | 10 +++- 7 files changed, 70 insertions(+), 28 deletions(-) diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc index 35b1937ef..aba5e3208 100644 --- a/include/class_CopyPasteHandler.inc +++ b/include/class_CopyPasteHandler.inc @@ -124,10 +124,18 @@ class CopyPasteHandler { /* Cut & paste */ if($this->cutCurrent){ - $this->current->save(); - $this->dialogOpen =false; - $this->Clear(); + $msgs = $this->check(); + if(count ($msgs) ){ + foreach( $msgs as $msg){ + print_red($msg); + } + $this->dialogOpen =false; + }else{ + $this->current->save(); + $this->dialogOpen =false; + $this->Clear(); + } /* Copy & paste */ }else{ diff --git a/plugins/admin/fai/class_faiHook.inc b/plugins/admin/fai/class_faiHook.inc index 6fa2680a2..121d0ca5c 100644 --- a/plugins/admin/fai/class_faiHook.inc +++ b/plugins/admin/fai/class_faiHook.inc @@ -427,7 +427,11 @@ class faiHook extends plugin /* We do not need to save untouched objects */ foreach($this->SubObjects as $name => $obj){ if($obj['status'] == "FreshLoaded"){ - unset($this->SubObjects[$name]); + if($this->copy_paste_mode){ + $this->SubObjects[$name] = $this->get_object_attributes($obj,$this->sub_Load_Later); + }else{ + unset($this->SubObjects[$name]); + } } } diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index b68f90f3c..5d966c64e 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -629,7 +629,7 @@ class faiManagement extends plugin $this->CopyPasteHandler->SetVar("base", $this->DivListFai->selectedBase); $this->CopyPasteHandler->SetVar("copy_paste_mode", TRUE); - $release = $_SESSION['CurrentMainBase']; + $release = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; if($_SESSION['faifilter']['branch']!="main"){ $release = $_SESSION['faifilter']['branch']; } diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index e2e112dc9..7697beb74 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -64,6 +64,8 @@ class faiPackage extends plugin var $base = ""; var $release = ""; var $copy_paste_mode = false; + var $CopyPasteVars = array("FAIdebianRelease","FAIdebianSection","FAIinstallMethod","mirror","servers","releases","sections","list","mirrors","usedPackages"); + function faiPackage ($config, $dn= NULL) { diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc index 92969c285..1b11447e4 100644 --- a/plugins/admin/fai/class_faiProfile.inc +++ b/plugins/admin/fai/class_faiProfile.inc @@ -385,29 +385,45 @@ class faiProfile extends plugin /* Call common method to give check the hook */ $message= plugin::check(); - if(count($this->FAIclasses) == 0){ - $message[]=_("Please assign at least one class to this profile."); - } + if($this->copy_paste_mode){ - if(empty($this->cn)){ - $message[]=_("Please enter a valid name."); - } + /* If this is a new script, check if a script with this name already exists */ + if(!empty($this->release) && $this->copy_paste_mode){ - $ldap = $this->config->get_ldap_link(); - $release = "ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - if($_SESSION['faifilter']['branch']!="main"){ - $release = "ou=profiles,".$_SESSION['faifilter']['branch']; - } - $ldap->cd($release); - if ($this->old_cn == ""){ - $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn."))",array("*")); - } else { - $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*")); - } - if($ldap->count()){ - $message[]=_("There is already a profile with this class name defined."); + /* Check if current name is already used for fai scripts in selected release */ + $dn = 'cn='.$this->cn.",ou=profiles,".$this->release; + $ldap = $this->config->get_ldap_link(); + $ldap->cat($dn); + if($ldap->count()){ + + $r =convert_department_dn($this->release);; + $message[] = sprintf(_("Can't insert a script named '%s' in '%s' there is already a script with the given name."),$this->cn,$r); + } + } + }else{ + if(count($this->FAIclasses) == 0){ + $message[]=_("Please assign at least one class to this profile."); + } + + if(empty($this->cn)){ + $message[]=_("Please enter a valid name."); + } + + $ldap = $this->config->get_ldap_link(); + $release = "ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + if($_SESSION['faifilter']['branch']!="main"){ + $release = "ou=profiles,".$_SESSION['faifilter']['branch']; + } + $ldap->cd($release); + if ($this->old_cn == ""){ + $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn."))",array("*")); + } else { + $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*")); + } + if($ldap->count()){ + $message[]=_("There is already a profile with this class name defined."); + } } - return ($message); } diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc index 935b771b2..50a73992b 100644 --- a/plugins/admin/fai/class_faiScript.inc +++ b/plugins/admin/fai/class_faiScript.inc @@ -41,6 +41,8 @@ class faiScript extends plugin var $base =""; var $release =""; var $copy_paste_mode = false; + var $CopyPasteVars = array("SubObjects","FAIstate"); + function faiScript ($config, $dn= NULL) { @@ -397,7 +399,11 @@ class faiScript extends plugin /* We do not need to save untouched objects */ foreach($this->SubObjects as $name => $obj){ if($obj['status'] == "FreshLoaded"){ - unset($this->SubObjects[$name]); + if($this->copy_paste_mode){ + $this->SubObjects[$name] = $this->get_object_attributes($obj,$this->sub_Load_Later); + }else{ + unset($this->SubObjects[$name]); + } } } diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc index e34f5d4bb..1b2f78752 100644 --- a/plugins/admin/fai/class_faiTemplate.inc +++ b/plugins/admin/fai/class_faiTemplate.inc @@ -394,7 +394,11 @@ class faiTemplate extends plugin /* We do not need to save untouched objects */ foreach($this->SubObjects as $name => $obj){ if($obj['status'] == "FreshLoaded"){ - unset($this->SubObjects[$name]); + if($this->copy_paste_mode){ + $this->SubObjects[$name] = $this->get_object_attributes($obj,$this->sub_Load_Later); + }else{ + unset($this->SubObjects[$name]); + } } } @@ -420,8 +424,10 @@ class faiTemplate extends plugin foreach($attributes as $attrs){ if(empty($obj[$attrs])){ $obj[$attrs] = array(); + $tmp[$attrs] = $obj[$attrs]; + }else{ + $tmp[$attrs] = stripslashes ($obj[$attrs]); } - $tmp[$attrs] = stripslashes ($obj[$attrs]); } $tmp['objectClass'] = $this->subClasses; -- 2.30.2