X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_faiProfile.inc;h=db587ac06f055f69019b88dab17e8760664771e2;hb=cb773874cb502bc0f01aeefc43849e0522e1a4d9;hp=9fb9ae0f7272e50e21d773c686c5f078333de1a3;hpb=0e18d29f78a782f1328668d201313e335ce42c2e;p=gosa.git
diff --git a/gosa-plugins/fai/admin/fai/class_faiProfile.inc b/gosa-plugins/fai/admin/fai/class_faiProfile.inc
index 9fb9ae0f7..db587ac06 100644
--- a/gosa-plugins/fai/admin/fai/class_faiProfile.inc
+++ b/gosa-plugins/fai/admin/fai/class_faiProfile.inc
@@ -23,6 +23,8 @@ class faiProfile extends plugin
var $FAIstate = "";
var $view_logged = FALSE;
+ var $classSelect;
+
function faiProfile(&$config, $dn= NULL)
{
/* Load Attributes */
@@ -32,7 +34,7 @@ class faiProfile extends plugin
$this->ui = get_userinfo();
/* Parse ldap attribute to get all assigned classes */
- $tmp = split(" ",$this->FAIclass);
+ $tmp = explode(" ",$this->FAIclass);
$tmp2 = array();
foreach($tmp as $class){
if(!empty($class)){
@@ -40,10 +42,6 @@ class faiProfile extends plugin
}
}
- if(isset($this->attrs['FAIstate'][0])){
- $this->FAIstate = $this->attrs['FAIstate'][0];
- }
-
/* Sort assigned classes */
if(is_array($tmp2)){
foreach($tmp2 as $class){
@@ -122,9 +120,9 @@ class faiProfile extends plugin
function acl_base_for_current_object($dn)
{
- if($dn == "new"){
+ if($dn == "new" || $dn == ""){
if($this->dn == "new"){
- $dn = session::get('CurrentMainBase');
+ $dn= $this->parent->parent->acl_base;
}else{
$dn = $this->dn;
}
@@ -214,96 +212,91 @@ class faiProfile extends plugin
/* Remove class name From list */
$sort_once = false;
- foreach($_POST as $name => $post){
- if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){
- $s_action = "delete";
- $s_entry = preg_replace("/DEL_/","",$name);
- $s_entry = base64_decode(preg_replace("/_.*$/","",$s_entry));
- }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){
- $s_action = "add";
- }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){
- $s_action = "delete";
- $s_entry = $_POST['FAIclass'];
- }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){
- $s_action = "add";
- }
+ if(!preg_match("/freeze/",$this->FAIstate)){
+ foreach($_POST as $name => $post){
+ if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){
+ $s_action = "delete";
+ $s_entry = preg_replace("/DEL_/","",$name);
+ $s_entry = base64_decode(preg_replace("/_.*$/","",$s_entry));
+ }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){
+ $s_action = "add";
+ }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){
+ $s_action = "delete";
+ $s_entry = $_POST['FAIclass'];
+ }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){
+ $s_action = "add";
+ }
- /* Check if a list element should be pushed one position up */
- if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
- $sort_once = true;
- $val = preg_replace("/sortup_/","",$name);
- $val = preg_replace("/_.*$/","",$val);
- $val = base64_decode($val);
- $this->catUp($val);
- }
-
- /* Check if a list element should be pushed one position down */
- if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
- $sort_once = true;
- $val = preg_replace("/sortdown_/","",$name);
- $val = preg_replace("/_.*$/","",$val);
- $val = base64_decode($val);
- $this->catDown($val);
- }
+ /* Check if a list element should be pushed one position up */
+ if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
+ $sort_once = true;
+ $val = preg_replace("/sortup_/","",$name);
+ $val = preg_replace("/_.*$/","",$val);
+ $val = base64_decode($val);
+ $this->catUp($val);
+ }
- }
+ /* Check if a list element should be pushed one position down */
+ if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
+ $sort_once = true;
+ $val = preg_replace("/sortdown_/","",$name);
+ $val = preg_replace("/_.*$/","",$val);
+ $val = base64_decode($val);
+ $this->catDown($val);
+ }
- if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){
- unset($this->FAIclasses[$s_entry]);
- }
+ }
- if($s_action == "add" && $this->acl_is_writeable("FAIclass")){
- $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses);
- $this->is_dialog =true;
- }
+ if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){
+ unset($this->FAIclasses[$s_entry]);
+ }
- /* Save Dialog */
- if(isset($_POST['SaveSubObject'])){
- $this->dialog->save_object();
- $msgs= $this->dialog->check();
- if(count($msgs)){
- msg_dialog::display(_("Error"), $msgs, ERROR_DIALOG);
- }else{
- $ret = $this->dialog->save();
- foreach($ret as $class){
+ if($s_action == "add" && $this->acl_is_writeable("FAIclass")){
+ $this->classSelect = new classSelect($this->config, get_userinfo());
+ $this->dialog =true;
+ }
+
+ /* Save Dialog */
+ if(isset($_POST['classSelect_save']) && $this->classSelect instanceOf classSelect){
+ $list = $this->classSelect->save();
+ foreach($list as $entry){
+ $class = $entry['cn'][0];
$this->FAIclasses[$class] =$class;
}
- $this->is_dialog=false;
- unset($this->dialog);
- $this->dialog=FALSE;
- //ksort($this->FAIclasses);
+ $this->dialog=false;
+ $this->classSelect=FALSE;
}
}
/* Cancel Dialog */
- if(isset($_POST['CancelSubObject'])){
- $this->is_dialog=false;
- unset($this->dialog);
- $this->dialog=FALSE;
+ if(isset($_POST['classSelect_cancel']) && $this->classSelect instanceOf classSelect){
+ $this->dialog=false;
+ $this->classSelect=FALSE;
}
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- return($this->dialog->execute());
+ if($this->classSelect instanceOf classSelect){
+ session::set('filterFAIClass_base',$this->parent->parent->fai_release);
+ session::set('filterBlacklist', array('cn' => array_values($this->FAIclasses)));
+ return($this->classSelect->execute());
}
$divlist =new divSelectBox("Profile");
$divlist->SetSummary(_("This list displays all assigned class names for this profile."));
/* item images */
- $objTypes['FAIhook'] = "";
- $objTypes['FAItemplate'] = "";
- $objTypes['FAIscript'] = "";
- $objTypes['FAIvariable'] = "";
- $objTypes['FAIpackageList'] = "";
- $objTypes['FAIpartitionTable'] = "";
+ $objTypes['FAIhook'] = "";
+ $objTypes['FAItemplate'] = "";
+ $objTypes['FAIscript'] = "";
+ $objTypes['FAIvariable'] = "";
+ $objTypes['FAIpackageList'] = "";
+ $objTypes['FAIpartitionTable'] = "";
/* Delete button */
- $actions = "";
+ $actions = "";
/* Up down buttons */
- $linkupdown = " ";
- $linkupdown.= "";
+ $linkupdown = " ";
+ $linkupdown.= "";
/* Append fai classes to divlist */
if($this->acl_is_readable("FAIclass")){
@@ -319,7 +312,7 @@ class faiProfile extends plugin
$field1 = array("string"=> $usedClass,"attach"=>"");
$field2 = array("string"=> $str,"attach"=>"");
- if(($this->FAIstate != "freeze") && $this->acl_is_writeable("FAIclass")){
+ if(!preg_match("/freeze/", $this->FAIstate) && $this->acl_is_writeable("FAIclass")){
$field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions).
preg_replace("/%s/",base64_encode($usedClass),$linkupdown),
"attach"=>"style='border-right:none;'");
@@ -330,6 +323,8 @@ class faiProfile extends plugin
}
}
+ $smarty->assign("freeze", preg_match("/freeze/i",$this->FAIstate));
+
$smarty->assign("FAIclasses" ,$this->FAIclasses);
$smarty->assign("divlist" ,$divlist->DrawList());
@@ -352,7 +347,7 @@ class faiProfile extends plugin
$tmp = $this->plInfo();
foreach($tmp['plProvidedAcls'] as $name => $translated){
- $smarty->assign($name."ACL",$this->getacl($name));
+ $smarty->assign($name."ACL",$this->getacl($name, preg_match("/freeze/",$this->FAIstate)));
}
$display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE));
@@ -363,13 +358,8 @@ class faiProfile extends plugin
{
$ldap = $this->config->get_ldap_link();
$ldap->cd ($this->dn);
-
- $faifilter = session::get('faifilter');
- $use_dn = preg_replace("/".normalizePreg(FAI::get_release_dn($this->dn))."/i", $faifilter['branch'], $this->dn);
- if($faifilter['branch'] == "main"){
- $use_dn = $this->dn;
- }
-
+ $release = $this->parent->parent->fai_release;
+ $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $this->dn);
new log("remove","fai/".get_class($this),$use_dn,$this->attributes);
FAI::prepare_to_save_FAI_object($use_dn,array(),true);
$this->handle_post_events("remove");
@@ -380,7 +370,9 @@ class faiProfile extends plugin
*/
function save_object()
{
- plugin::save_object();
+ if(!preg_match("/freeze/",$this->FAIstate)){
+ plugin::save_object();
+ }
}
@@ -394,27 +386,19 @@ class faiProfile extends plugin
$message[]=_("No class specified for this profile!");
}
- if(empty($this->cn)){
- $message[]= msgPool::invalid(_("Name"));
- }
-
- $ldap = $this->config->get_ldap_link();
- $faifilter = session::get('faifilter');
- $base = $faifilter['branch'];
- if($base == "main"){
- $base = session::get('CurrentMainBase');
- }
- $base = get_ou('faiprofileou').$base;
-
- $ldap->cd($base);
- if ($this->old_cn == ""){
- $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn."))",$base,array("*"));
- } else {
- $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",$base,array("*"));
+ if($this->cn == ""){
+ $message[]= msgPool::required(_("Name"));
}
- if($ldap->count() || isset($this->FAIAllclasses[$this->cn])){
- $message[]= msgPool::duplicated(_("Name"));
+ /* Ensure that we do not overwrite an allready existing entry
+ */
+ if($this->dn == "new" || $this->cn != $this->old_cn){
+ $release = $this->parent->parent->fai_release;
+ $new_dn= 'cn='.$this->cn.",".get_ou('faiProfileRDN').get_ou('faiBaseRDN').$release;
+ $res = faiManagement::check_class_name("FAIprofile",$this->cn,$new_dn);
+ if(isset($res[$this->cn])){
+ $message[] = msgPool::duplicated(_("Name"));
+ }
}
return ($message);
@@ -435,6 +419,13 @@ class faiProfile extends plugin
$this->attrs['FAIclass']=trim($this->FAIclass);
+ /* Remove the old FAI profile, if the dn has changed.
+ */
+ if($this->cn != $this->old_cn && $this->old_cn != ""){
+
+ $old_dn = preg_replace("/^cn=[^,]+,/","cn=".$this->old_cn.",",$this->dn);
+ FAI::prepare_to_save_FAI_object($old_dn,array(),TRUE);
+ }
FAI::prepare_to_save_FAI_object($this->dn,$this->attrs);
if($this->initially_was_account){
@@ -450,7 +441,7 @@ class faiProfile extends plugin
plugin::PrepareForCopyPaste($source);
/* Parse ldap attribute to get all assigned classes */
- $tmp = split(" ",$this->FAIclass);
+ $tmp = explode(" ",$this->FAIclass);
$tmp2 = array();
foreach($tmp as $class){
if(!empty($class)){
@@ -484,6 +475,34 @@ class faiProfile extends plugin
"FAIclass" => _("FAI classes"))
));
}
+
+
+ /*! \brief Used for copy & paste.
+ Returns a HTML input mask, which allows to change the cn of this entry.
+ @param Array Array containing current status && a HTML template.
+ */
+ function getCopyDialog()
+ {
+ $vars = array("cn");
+ $smarty = get_smarty();
+ $smarty->assign("cn", htmlentities($this->cn));
+ $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+ $ret = array();
+ $ret['string'] = $str;
+ $ret['status'] = "";
+ return($ret);
+ }
+
+
+ /*! \brief Used for copy & paste.
+ Some entries must be renamed to avaoid duplicate entries.
+ */
+ function saveCopyDialog()
+ {
+ if(isset($_POST['cn'])){
+ $this->cn = get_post('cn');
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: