Code

Readed koabConnectivity Account Free Busy check
[gosa.git] / plugins / gofax / faxaccount / class_gofaxAccount.inc
index a8658b2ed137f02b386157d6c180be8df2cd0642..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]]=
@@ -612,27 +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);
     $this->cleanup();
-$ldap->modify ($this->attrs); 
+    $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    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 @@ $ldap->modify ($this->attrs);
 
       /* Check if mail account is active and correct the internal
          reference to represent the current status. */
-      if (isset($this->parent)&&($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;
       }
     }
@@ -738,17 +744,17 @@ $ldap->modify ($this->attrs);
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $this->cleanup();
-$ldap->modify ($this->attrs); 
+    $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    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));
     }
 
   }
@@ -787,6 +793,22 @@ $ldap->modify ($this->attrs);
         $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'];
+    }
+  }
 
 }