X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_faiProfile.inc;h=db587ac06f055f69019b88dab17e8760664771e2;hb=cb773874cb502bc0f01aeefc43849e0522e1a4d9;hp=212ea1dde18fa07d0c745a69efe648c10a26e30c;hpb=62749c66a77826037776fb0ee2f40602d264fd5d;p=gosa.git
diff --git a/gosa-plugins/fai/admin/fai/class_faiProfile.inc b/gosa-plugins/fai/admin/fai/class_faiProfile.inc
index 212ea1dde..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")){
@@ -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,18 +386,15 @@ class faiProfile extends plugin
$message[]=_("No class specified for this profile!");
}
- if(empty($this->cn)){
- $message[]= msgPool::invalid(_("Name"));
+ if($this->cn == ""){
+ $message[]= msgPool::required(_("Name"));
}
/* Ensure that we do not overwrite an allready existing entry
*/
if($this->dn == "new" || $this->cn != $this->old_cn){
- $new_dn= 'cn='.$this->cn.",".get_ou('faiprofileou').get_ou('faiou').session::get('CurrentMainBase');
- $faifilter = session::get('faifilter');
- if($faifilter['branch']!="main"){
- $new_dn ='cn='.$this->cn.",".get_ou('faiprofileou').$faifilter['branch'];
- }
+ $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"));
@@ -430,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){
@@ -445,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)){