Code

Removed unsed stuff
[gosa.git] / plugins / gofon / macro / class_gofonMacro.inc
index 2a809a9ec44ce09863d5459ead86d5e48b9eca03..d358ef900dcd9cd9c6a6ab1083c2e85cc0af77de 100755 (executable)
@@ -16,13 +16,15 @@ class macro extends plugin
   /*! CLI vars */
   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
 
-
   /*! Macro attributes,  */
   var $generate_error= "";
   
   /*! The name of the Macro in the openldap drirectory */
   var $cn               = ""; 
-  
+  /*! Display error once */
+  var $error_shown = false; 
+
   /*! This ist the variable that contains the description of the macro*/
   var $description      = "";
 
@@ -75,18 +77,24 @@ class macro extends plugin
       $this->orig_cn=$this->cn;
       $this->base= dn2base($this->dn);
     }
+    $ui= get_userinfo();
+    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
+    $this->acl= get_module_permission($acl, "goFonMacro", $ui->dn);
   }
 
   /*!  Execute this plugin */
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Variables */
     $vars      = "";
     $tmp       = array();
     $number = 0; 
 
     if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
-      print_red(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). \n  Your Settings can't be saved to asterisk Database. "));
+      print_red(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database."));
     }
 
     /* Do we represent a valid group? */
@@ -178,6 +186,14 @@ class macro extends plugin
       return(true);
     }
 
+    if(!is_callable("mysql_connect")){
+      if((!$this->error_shown)&&($save)){
+        print_red(_("There is no mysql extension available in your php setup, can't save any changes to asterisk db."));
+        $this->error_shown = true;
+      }
+      return(true);
+    }
+
     // Get Configuration for Mysql database Server  
     $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
 
@@ -221,6 +237,11 @@ class macro extends plugin
         // Remove  spaces 
         $s_linestr = trim ( $s_linestr);
 
+        // Skip empty lines
+        if ($s_linestr == ""){
+          continue;
+        }
+
         // If not empty or linebreak at [0]
         if((!empty($s_linestr))&&($s_linestr[0]!=";")&&(ord($s_linestr[0]) !=13)){
   
@@ -309,7 +330,11 @@ class macro extends plugin
   {
     if (isset($_POST['displayName'])){
       plugin::save_object();
-
+    }
+    foreach($this->attributes as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr= $_POST [$attr];
+      }
     }
   }
 
@@ -342,7 +367,7 @@ class macro extends plugin
     }
  
     foreach($this->attributes as $attr){
-      if(chkacl($this->acl,$attr)){
+      if(chkacl($this->acl,"edit")){
         $str =  sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro"),$attr) ;
         return(array($str));
         }
@@ -386,7 +411,9 @@ class macro extends plugin
     if($this->generate_mysql_entension_entries()){
       if (count($a)){
         $ldap->cd($this->dn);
-        $ldap->modify($this->attrs);
+        $this->cleanup();
+$ldap->modify ($this->attrs); 
+
         $this->handle_post_events("modify");
       } else {
         $ldap->cd($this->config->current['BASE']);