Code

Removed base64_encoding, from all classes
[gosa.git] / plugins / admin / fai / class_faiProfile.inc
index 02d25dc00e61e860a851a9260f2b00d67f73a4d6..d5680e49d26d354f1a80e32976f01fd80cef6a61 100644 (file)
@@ -91,6 +91,11 @@ class faiProfile extends plugin
         $s_entry  = preg_replace("/_.*$/","",$s_entry);
       }elseif(preg_match("/Add_class/i",$name)){
         $s_action  = "add";
+      }elseif(preg_match("/DelClass/i",$name)){
+        $s_action  = "delete";
+        $s_entry = $_POST['FAIclass'];
+      }elseif(preg_match("/AddClass/i",$name)){
+        $s_action  = "add";
       }
     }
 
@@ -166,15 +171,23 @@ class faiProfile extends plugin
       $field3 = array("string"=> preg_replace("/%KEY%/",$usedClass,$actions),"attach"=>"style='border-right:none;'");
       $divlist->AddEntry(array($field1,$field2,$field3));
     }
-
+    
+    $smarty->assign("FAIclasses"  ,$this->FAIclasses);
     $smarty->assign("divlisthead" ,$listhead);
     $smarty->assign("divlist"     ,$divlist->DrawList());
 
-    /* Assign variables */
+     /* Magic quotes GPC, escapes every ' " \, to solve some security risks
+     * If we post the escaped strings they will be escaped again
+     */
     foreach($this->attributes as $attrs){
-      $smarty->assign($attrs,$this->$attrs);
+      if(get_magic_quotes_gpc()){
+        $smarty->assign($attrs,stripslashes($this->$attrs));
+      }else{
+        $smarty->assign($attrs,($this->$attrs));
+      }
     }
 
+
     $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE));
     return($display);
   }
@@ -204,23 +217,15 @@ class faiProfile extends plugin
   function check()
   {
     $message= array();
-    $str = utf8_encode("üöä");
-    if((empty($this->description))){
-      $message[] =_("Please specify a description for this profile.");
-    }
-
-    if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){
-      $message[]=_("Please enter a valid description.");
-    }
     
-    if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){
-      $message[]=_("Please enter a valid name. Only 0-9 a-Z are allowed here.");
-    }
-
     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();
     $ldap->cd($_SESSION['faifilter']['base']);
     $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*"));
@@ -254,7 +259,7 @@ class faiProfile extends plugin
       $ldap->modify($this->attrs);
     }else{
       /* Write FAIscript to ldap*/
-      $ldap->cd(preg_replace('/^[^,]+,[^,]+,/', '', $this->dn));
+      $ldap->cd($this->config->current['BASE']);
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);