Code

Readed koabConnectivity Account Free Busy check
[gosa.git] / plugins / gofax / faxaccount / class_gofaxAccount.inc
index 24c94a4848a79e00b6c1fbf9d15665e4807cb219..5232ca844cf3e1bbf225a8dbc182abd4ba791583 100644 (file)
@@ -39,15 +39,21 @@ class gofaxAccount extends plugin
   var $current_blocklist= array();
 
   /* attribute list for save action */
-  var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled",
+  var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","goFaxRBlockgroups","facsimileAlternateTelephoneNumber",
       "goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail");
   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
@@ -60,7 +66,7 @@ class gofaxAccount extends plugin
       /* Get arrays */
       foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
             "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
-
+        $this->$val =array();
         if (isset($this->attrs["$val"]["count"])){
           for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
             array_push($this->$val, $this->attrs["$val"][$i]);
@@ -349,8 +355,8 @@ class gofaxAccount extends plugin
 
       $base= $faxfilter['depselect'];
       $acl= array($this->config->current['BASE'] => ":all");
-      print "(&(objectClass=goFaxAccount)$filter)";
-      $res= get_list($acl, "(&(objectClass=goFaxAccount)$filter)", TRUE, $base, array("sn", "givenName", "facsimileTelephoneNumber"), TRUE);
+      $res= get_list("(&(objectClass=goFaxAccount)$filter)", $acl, $base, 
+                     array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH);
 
       foreach ($res as $attrs){
         $list[$attrs['facsimileTelephoneNumber'][0]]=
@@ -411,8 +417,7 @@ class gofaxAccount extends plugin
 
       /* Create our divselect box */
       $divSel = new divSelectBox("divSelectPredefined");
-      $divSel->setHeight(150);
-      $divSel->setWidth(150);
+      $divSel->setHeight(296);
 
       /* NEW LIST MANAGMENT
        * We also need to search for the departments
@@ -499,8 +504,7 @@ class gofaxAccount extends plugin
 
       /*Create DivSel*/
       $divSel = new divSelectBox("divSelectPredefined");
-      $divSel->setHeight(300);
-      $divSel->setWidth(350);
+      $divSel->setHeight(296);
 
       /* NEW LIST MANAGMENT
        * We also need to search for the departments
@@ -614,25 +618,27 @@ class gofaxAccount extends plugin
     }
 
     /* Adapt mail settings if needed */
-    if ($this->parent->by_object['mailAccount']->is_account){
+    if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){
       unset($this->attrs['mail']);
     }
 
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error());
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    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));
   }
 
 
   /* Check formular input */
   function check()
   {
-    /* Reset message array */
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
 
     /* must: facsimileTelephoneNumber */
     if ($this->facsimileTelephoneNumber == ""){
@@ -708,7 +714,7 @@ class gofaxAccount extends plugin
 
       /* Check if mail account is active and correct the internal
          reference to represent the current status. */
-      if ($this->parent->by_object['mailAccount']->is_account){
+      if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
         $this->has_mailAccount= TRUE;
       }
     }
@@ -737,16 +743,18 @@ class gofaxAccount extends plugin
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error());
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), _("Saving FAX account failed"));
 
     /* 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));
     }
 
   }
@@ -785,6 +793,22 @@ class gofaxAccount extends plugin
         $this->facsimileAlternateTelephoneNumber);
   }
 
+  function getCopyDialog()
+  {
+    $str    = "";
+    $smarty = get_smarty();
+    $smarty->assign("facsimileTelephoneNumber", $this->facsimileTelephoneNumber);
+    $str['string']   = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
+    $str['status'] ="";
+    return($str);
+  }
+
+  function SaveCopyDialog()
+  {
+    if(isset($_POST['facsimileTelephoneNumber'])){
+      $this->facsimileTelephoneNumber = $_POST['facsimileTelephoneNumber'];
+    }
+  }
 
 }