Code

Updated translation, fixed some typo/errors
[gosa.git] / plugins / gofax / faxaccount / class_gofaxAccount.inc
index 9455b4249f98034d101b23334e250be5349b72ed..42ab729cecd4b5f0765cdff8aa5efdd74e300ad2 100644 (file)
@@ -6,17 +6,11 @@ class gofaxAccount extends plugin
   var $plHeadline= "FAX";
   var $plDescription= "This does something";
 
-  /* CLI vars */
-  var $cli_summary= "Manage users fax account";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
-
   /* Department list shown in the divSelectList*/
   var $departments;
 
   /* Fax attributes */
-  var $goFaxDeliveryMode= "";
+  var $goFaxDeliveryMode= "0";
   var $facsimileTelephoneNumber= "";
   var $goFaxIsEnabled= 1;
   var $goFaxPrinter= "";
@@ -38,16 +32,24 @@ class gofaxAccount extends plugin
   var $out_blocklist_dialog= FALSE;
   var $current_blocklist= array();
 
+  /* Copy & paste variables */
+  var $CopyPasteVars=array("facsimileTelephoneNumber");//,"goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups");
+
   /* attribute list for save action */
-  var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","goFaxRBlockgroups","facsimileAlternateTelephoneNumber",
-      "goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail");
+  var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","facsimileAlternateTelephoneNumber","goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups","goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail","facsimileTelephoneNumber");
   var $objectclasses= array("goFaxAccount");
 
-  function gofaxAccount ($config, $dn= NULL)
+  var $uid= "";
+
+  function gofaxAccount ($config, $dn= NULL, $parent)
   {
     /* General initialization */
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
 
+    /* Get user id */
+    if(isset($this->attrs['uid'])){
+      $this->uid = $this->attrs['uid'][0];
+    }
 
     /* Hickert : 11.11.05
      * Added to be able to handle department selection in divSelelect
@@ -92,12 +94,19 @@ class gofaxAccount extends plugin
           "regex"           => "");
       register_global("faxfilter", $faxfilter);
     }
+    $this->ui = get_userinfo();
   }
 
   function execute()
   {
     /* Call parent execute */
     plugin::execute();
+
+
+    $acl= get_permissions ($this->ui->dn, $this->ui->subtreeACL);
+    $editacl= get_module_permission($acl, "gofax", $this->dn);
+    $this->acl = $editacl;
+
     /* Hickert : 11.11.05
      * Added to be able to handle department selection in divSelelect
      */
@@ -128,7 +137,13 @@ class gofaxAccount extends plugin
 
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
+
+      /* Onyl change account state if allowed */
+      if($this->is_account && $this->acl == "#all#"){
+        $this->is_account= !$this->is_account;
+      }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){
+        $this->is_account= !$this->is_account;
+      }
     }
 
     /* Do we represent a valid account? */
@@ -349,7 +364,6 @@ class gofaxAccount extends plugin
 
       $base= $faxfilter['depselect'];
       $acl= array($this->config->current['BASE'] => ":all");
-      print "(&(objectClass=goFaxAccount)$filter)";
       $res= get_list("(&(objectClass=goFaxAccount)$filter)", $acl, $base, 
                      array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH);
 
@@ -558,7 +572,8 @@ class gofaxAccount extends plugin
 
 
     /* Show main page */
-    $smarty->assign("languages", $this->config->data['MAIN']['LANGUAGES']);
+    $smarty->assign("languages", get_languages(TRUE));
+
     $smarty->assign("formats", $this->config->data['MAIN']['FAXFORMATS']);
     $smarty->assign("printers", $this->printerList);
 
@@ -605,13 +620,6 @@ class gofaxAccount extends plugin
 
     plugin::remove_from_parent();
 
-    /* Zero out arrays */
-    foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
-          "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
-
-      $this->attrs[$val]= array();
-    }
-
     /* Adapt mail settings if needed */
     if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){
       unset($this->attrs['mail']);
@@ -625,7 +633,7 @@ class gofaxAccount extends plugin
     show_ldap_error($ldap->get_error(), _("Removing FAX account failed"));
 
     /* Optionally execute a command after we're done */
-    $this->handle_post_events('remove');
+    $this->handle_post_events('remove',array("uid"=> $this->uid));
   }
 
 
@@ -647,7 +655,7 @@ class gofaxAccount extends plugin
     /* IF mail is specified (which is only the case if there's no mail account
        present), check if it's valid..  */
     if (@isset($this->parent->by_object['mailAccount']) &&
-        $this->goFaxDeliveryMode && 32){
+        $this->goFaxDeliveryMode & 32){
       if ($this->mail == ""){
         $message[]= _("Mail delivery is checked, but no address has been specified.");
       } elseif (!is_email($this->mail)){
@@ -729,10 +737,9 @@ class gofaxAccount extends plugin
       $this->attrs[$val]= $this->$val;
     }
 
-    /* Adapt mail settings if needed */
-    unset($this->attrs['mail']);
-    if (!$this->has_mailAccount && $this->goFaxDeliveryMode && 32){
-      $this->attrs['mail']= $this->mail;
+    /* Do not save mail address ... it was possibly changed by mail plugin*/
+    if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){
+      unset($this->attrs['mail']);
     }
 
     /* Write back to ldap */
@@ -746,10 +753,10 @@ class gofaxAccount extends plugin
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
       if ($this->is_modified){
-        $this->handle_post_events("mofify");
+        $this->handle_post_events("modify",array("uid" => $this->uid));
       }
     } else {
-      $this->handle_post_events("add");
+      $this->handle_post_events("add",array("uid" => $this->uid));
     }
 
   }