Code

Added another set of error messages
[gosa.git] / plugins / gofax / faxaccount / class_gofaxAccount.inc
1 <?php
3 class gofaxAccount extends plugin
4 {
5   /* Definitions */
6   var $plHeadline= "FAX";
7   var $plDescription= "This does something";
9   /* CLI vars */
10   var $cli_summary= "Manage users fax account";
11   var $cli_description= "Some longer text\nfor help";
12   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
15   /* Department list shown in the divSelectList*/
16   var $departments;
18   /* Fax attributes */
19   var $goFaxDeliveryMode= "";
20   var $facsimileTelephoneNumber= "";
21   var $goFaxIsEnabled= 1;
22   var $goFaxPrinter= "";
23   var $goFaxDivertNumber= "";
24   var $goFaxLanguage= "";
25   var $goFaxFormat= "";
26   var $goFaxRBlocklist = array();
27   var $goFaxRBlockgroups= array();
28   var $goFaxSBlocklist= array();
29   var $goFaxSBlockgroups= array();
30   var $mail= "";
31   var $facsimileAlternateTelephoneNumber= array();
33   /* Internal variables */
34   var $printerList= array();
35   var $has_mailAccount= FALSE;
36   var $locals_dialog= FALSE;
37   var $in_blocklist_dialog= FALSE;
38   var $out_blocklist_dialog= FALSE;
39   var $current_blocklist= array();
41   /* attribute list for save action */
42   var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","goFaxRBlockgroups","facsimileAlternateTelephoneNumber",
43       "goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail");
44   var $objectclasses= array("goFaxAccount");
46   function gofaxAccount ($config, $dn= NULL)
47   {
48     /* General initialization */
49     plugin::plugin ($config, $dn);
52     /* Hickert : 11.11.05
53      * Added to be able to handle department selection in divSelelect
54      */
55     if(!isset($_SESSION["Fax_Filter"])){
56       $_SESSION['Fax_Filter']['depselect'] = $this->config->current['BASE'];
57     }
59     if ($dn != "new"){
60       /* Get arrays */
61       foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
62             "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
63         $this->$val =array();
64         if (isset($this->attrs["$val"]["count"])){
65           for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
66             array_push($this->$val, $this->attrs["$val"][$i]);
67           }
68         }
69       }
71       /* Set up has_mailAccount */
72       if (in_array("gosaMailAccount", $this->attrs['objectClass'])){
73         $this->has_mailAccount= TRUE;
74       }
75       if (isset($this->attrs["facsimileTelephoneNumber"][0])){
76         $this->facsimileTelephoneNumber= $this->attrs["facsimileTelephoneNumber"][0];
77       }
78     }
80     /* Load printer list */
81     if (isset($this->config->data['SERVERS']['CUPS'])){
82       $this->printerList= get_printer_list ($this->config->data['SERVERS']['CUPS']);
83       asort ($this->printerList);
84     }
86     /* Get global filter config */
87     if (!is_global("faxfilter")){
88       $ui= get_userinfo();
89       $base= get_base_from_people($ui->dn);
90       $faxfilter= array( "depselect"       => $base,
91           "fuser"            => "*",
92           "regex"           => "");
93       register_global("faxfilter", $faxfilter);
94     }
95   }
97   function execute()
98   {
99     /* Call parent execute */
100     plugin::execute();
101     /* Hickert : 11.11.05
102      * Added to be able to handle department selection in divSelelect
103      */
104     if((isset($_GET['act']))&&($_GET['act']=="dep_open")){
106       if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){
107         $_SESSION['Fax_Filter']['depselect']= base64_decode($_GET['dep_id']);
108       }else{
109         $_SESSION['Fax_Filter']['depselect']= $this->config->current['BASE'];
110       }
111     }
113     /* Load smarty stuff */
114     $smarty= get_smarty();
116     /* Check if mail account is active. We'll display an additional
117        mail address field if this is not the case. Some people may
118        want goFax, but have a mailserver which is not managed with
119        GOsa */
120     if (!@isset($this->parent->by_object['mailAccount'])) {
121       $smarty->assign("has_mailaccount", $this->has_mailAccount?"true":"false");
122     } elseif ( !$this->parent->by_object['mailAccount']->is_account){
123       $smarty->assign("has_mailaccount", "false");
124       $this->has_mailAccount= false;
125     } else {
126       $smarty->assign("has_mailaccount", "true");
127     }
129     /* Do we need to flip is_account state? */
130     if (isset($_POST['modify_state'])){
131       $this->is_account= !$this->is_account;
132     }
134     /* Do we represent a valid account? */
135     if (!$this->is_account && $this->parent == NULL){
136       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
137         _("This account has no fax extensions.")."</b>";
138       $display.= back_to_main();
139       return ($display);
140     }
142     /* Show tab dialog headers */
143     $display= "";
144     if ($this->parent != NULL){
145       if ($this->is_account){
146         $display= $this->show_header(_("Remove fax account"),
147             _("This account has fax features enabled. You can disable them by clicking below."));
148       } else {
149         $display= $this->show_header(_("Create fax account"),
150             _("This account has fax features disabled. You can enable them by clicking below."));
151         return ($display);
152       }
153     }
155     /* Trigger Add local fax alternatives dialog */
156     if (isset($_POST['add_local_alternate'])){
157       $this->locals_dialog= TRUE;       
158       $this->dialog= TRUE;      
159     }
161     /* Add alternatives from dialog */
162     if (isset($_POST['add_locals_finish'])){
163       if (isset($_POST['local_list']) &&
164           chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
166         foreach ($_POST['local_list'] as $val){
167           $this->addAlternate($val);
168           $this->is_modified= TRUE;
169         }
170       }
171     }
173     /* Add alternatives */
174     if (isset($_POST['add_alternate'])){
175       if ($_POST['forward_address'] != "" &&
176           is_phone_nr($_POST['forward_address']) &&
177           chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
179         $this->addAlternate($_POST['forward_address']);
180       }
181     }
183     /* Delete alternate fax number */
184     if (isset($_POST['delete_alternate'])){
185       if (isset($_POST['alternate_list']) && count($_POST['alternate_list']) &&
186           chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
188         $this->delAlternate ($_POST['alternate_list']);
189       }
190     }
193     /* Edit incoming blocklists */
194     if (isset($_POST['edit_incoming'])){
195       $this->current_blocklist= array_merge($this->goFaxRBlocklist,
196           $this->goFaxRBlockgroups);
197       sort($this->current_blocklist);
198       reset($this->current_blocklist);
200       $this->in_blocklist_dialog= TRUE;
201       $this->dialog= TRUE;
202     }
204     /* Edit outgoing blocklists */
205     if (isset($_POST['edit_outgoing'])){
206       $this->current_blocklist= array_merge($this->goFaxSBlocklist,
207           $this->goFaxSBlockgroups);
208       sort($this->current_blocklist);
209       reset($this->current_blocklist);
211       $this->out_blocklist_dialog= TRUE;
212       $this->dialog= TRUE;
213     }
215     /* Add number to blocklist (dialog) */
216     if (isset($_POST['add_blocklist_number']) && $_POST['block_number'] != ""){
217       if (!is_phone_nr($_POST['block_number'])){
218         print_red (_("You're trying to add an invalid phone number."));
219       } else {
220         array_push($this->current_blocklist, $_POST['block_number']);
221         $this->current_blocklist= array_unique($this->current_blocklist);
222         sort($this->current_blocklist);
223         reset($this->current_blocklist);
224       }
225     }
227     /* Hickert : 11.11.05
228      * Add selection from divSelelect to our Blocklist 
229      */
230     /* Add list to blocklist */
231     if (isset($_POST['add_blocklist'])){
232       foreach($_POST as $name => $value){
233         if(preg_match("/ADDLIST_/i",$name)){
234           $this->current_blocklist= array_merge($this->current_blocklist, array(base64_decode($value)));
236         }
237       } 
238       $this->current_blocklist= array_unique($this->current_blocklist);
239       sort($this->current_blocklist);
240       reset($this->current_blocklist);
241     }
243     /* Add list to blocklist */
244     if (isset($_GET['add'])){
245       if(!is_array($this->current_blocklist)) $this->current_blocklist=array();
246       $this->current_blocklist= array_merge($this->current_blocklist, array( base64_decode($_GET['add'])));
247       $this->current_blocklist= array_unique($this->current_blocklist);
248       sort($this->current_blocklist);
249       reset($this->current_blocklist);
250     }
252     /* Delete from blocklist */
253     if (isset($_POST['delete_blocklist_number']) && isset($_POST['block_list'])){
254       $tmp= array();
255       foreach($this->current_blocklist as $val){
256         if (!in_array($val, $_POST['block_list'])){
257           $tmp[]= $val;
258         }
259       }
260       $this->current_blocklist= $tmp;
261     }
264     /* Blocklist edit finished */
265     if (isset($_POST['edit_blocklists_finish'])){
267       /* Incoming or outgoing? */
268       if ($this->in_blocklist_dialog){
269         $this->goFaxRBlocklist = array();
270         $this->goFaxRBlockgroups = array();
272         foreach ($this->current_blocklist as $val){
273           if (is_phone_nr($val)){
274             $this->goFaxRBlocklist[]=$val;
275           } else {
276             $this->goFaxRBlockgroups[]= $val;
277           }
278         }
279       } else {
280         $this->goFaxSBlocklist = array();
281         $this->goFaxSBlockgroups = array();
283         /* Transfer values to ourself */
284         foreach ($this->current_blocklist as $val){
285           if (is_phone_nr($val)){
286             $this->goFaxSBlocklist[]=$val;
287           } else {
288             $this->goFaxSBlockgroups[]= $val;
289           }
290         }
291       }
292       $this->is_modified= TRUE;
293     }
296     /* Set departments */
297     if ($this->locals_dialog ||
298         $this->in_blocklist_dialog ||
299         $this->out_blocklist_dialog){
301       $list= array ();
302       $ldap= $this->config->get_ldap_link();
303       if (isset ($_POST['department'])){
304         $ldap->cd ($_POST['department']);
305       } else {
306         $ldap->cd ($this->config->current['BASE']);
307       }
308     }
310     /* Cancel  dialogs */
311     if (isset($_POST['add_locals_cancel']) || isset($_POST['edit_blocklists_finish']) ||
312         isset($_POST['edit_blocklists_cancel']) || isset($_POST['add_locals_finish'])){
314       $this->locals_dialog= FALSE;
315       $this->in_blocklist_dialog= FALSE;
316       $this->out_blocklist_dialog= FALSE;
317       $this->dialog= FALSE;
318     }
320     /* Manage locals dialog */
321     if ($this->locals_dialog){
323       /* Save data */
324       $faxfilter= get_global("faxfilter");
325       foreach( array("depselect", "fuser", "regex") as $type){
326         if (isset($_POST[$type])){
327           $faxfilter[$type]= $_POST[$type];
328         }
329       }
330       if (isset($_GET['search'])){
331         $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
332         if ($s == "**"){
333           $s= "*";
334         }
335         $faxfilter['fuser']= $s;
336       }
337       register_global("faxfilter", $faxfilter);
339       if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){
340         $regex= $faxfilter['regex'];
341         $filter= "(facimileTelephoneNumber=$regex)";
342       } else {
343         $filter= "";
344       }
345       if ($faxfilter['fuser'] != ""){
346         $user= $faxfilter['fuser'];
347         $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
348       }
350       $base= $faxfilter['depselect'];
351       $acl= array($this->config->current['BASE'] => ":all");
352       print "(&(objectClass=goFaxAccount)$filter)";
353       $res= get_list("(&(objectClass=goFaxAccount)$filter)", $acl, $base, 
354                      array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH);
356       foreach ($res as $attrs){
357         $list[$attrs['facsimileTelephoneNumber'][0]]=
358           $attrs['sn'][0].", ".
359           $attrs['givenName'][0]." [".
360           $attrs['facsimileTelephoneNumber'][0]."]";
361       }
363       /* Show dialog */
364       $smarty->assign("search_image", get_template_path('images/search.png'));
365       $smarty->assign("usearch_image", get_template_path('images/search_user.png'));
366       $smarty->assign("tree_image", get_template_path('images/tree.png'));
367       $smarty->assign("infoimage", get_template_path('images/info.png'));
368       $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
369       $smarty->assign("departments", $this->config->idepartments);
370       $smarty->assign("list", $list);
371       if (isset($_POST['depselect'])){
372         $smarty->assign("depselect", $_POST['depselect']);
373       }
374       $smarty->assign("deplist", $this->config->idepartments);
375       $smarty->assign("apply", apply_filter());
376       $smarty->assign("alphabet", generate_alphabet());
377       $smarty->assign("hint", print_sizelimit_warning());
378       foreach( array("depselect", "fuser", "regex") as $type){
379         $smarty->assign("$type", $faxfilter[$type]);
380       }
381       $smarty->assign("hint", print_sizelimit_warning());
383       $display.= $smarty->fetch (get_template_path('locals.tpl', TRUE, dirname(__FILE__)));
384       return ($display);
385     }
388     /* Manage incoming blocklists */
389     if ($this->in_blocklist_dialog){
391       /* This handles the divSelectBox */
393       /* The base specifies the current position in the ldap tree 
394        * The current base was specified by $_GET['dep_id'] before. Or contains the default value.
395        */
396       $base = $_SESSION['Fax_Filter']['depselect'];
397       $ldap->cd($base);
399       /* Ge all Blocklists */
400       $ldap->search ("(objectClass=goFaxRBlock)",array("cn","description"));
401       while ($attrs= $ldap->fetch()){
403         /* Generate list depending on description */
404         if(isset($attrs['description'][0])){
405           $list[$attrs['cn'][0]]=
406             $attrs['description'][0].
407             " [".$attrs['cn'][0]."]";
408         }else{
409           $list[$attrs['cn'][0]]= $attrs['cn'][0];
410         }
411       }
413       /* Create our divselect box */
414       $divSel = new divSelectBox("divSelectPredefined");
415       $divSel->setHeight(296);
417       /* NEW LIST MANAGMENT
418        * We also need to search for the departments
419        * So we are able to navigate like in konquerer
420        */
421       $this->departments= array();
422    
423       /* Get all departments within the current department */ 
424       $base = $_SESSION['Fax_Filter']['depselect'];
425       $ldap->ls("(objectClass=gosaDepartment)",$base);
427       /* Base back is used to go one department up in our ldap tree */
428       $base_back = preg_replace("/^[^,]+,/","",$base);
430       /* Only show base_back if it is needed */
431       if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){
432         $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; 
433       }
435       /* Fetch all returned departments an add them to our divlist */
436       while($value = $ldap->fetch()){
437         if($value["description"][0]!=".."){
438           $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
439         }else{
440           $this->departments[$value['dn']]=$value["description"][0];
441         }
442       }
443       /* END NEW LIST MANAGMENT
444        */
446       // This links specifies the department open link 
447       $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
449       /* Insert departments in divsel */
450       foreach($this->departments as $key=> $val){
451         if(!isset($this->config->departments[trim($key)])){
452           $this->config->departments[trim($key)]="";
453         }
454         $field1 = array("string" => "<img src='images/folder.png' alt='department'>","attach"=>"style='width:16px;text-align:center;'");
455         $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'");
456         $divSel->AddEntry(array($field1,$field2));
457       }
459       /* Append predefined Blocklists */
460       foreach($list as $entry => $value){
461         $divSel->AddEntry(array(
462               array("string"=>"<input type='checkbox' value='".base64_encode($entry)."' name='ADDLIST_".base64_encode($entry)."'>"),
463               array("string"=>$value,"attach"=>"style='border:0px;'")
464               ));
465       }
467       /* Show dialog */
468       $smarty->assign("cblocklist", $this->current_blocklist);
469       $smarty->assign("goFaxBlockListACL", chkacl($this->acl, "goFaxBlockList"));
470       $smarty->assign("departments", $this->config->idepartments);
471       $smarty->assign("divSelectPredefined", $divSel->DrawList());
472       $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__)));
473       return ($display);
474     }
476     /* Manage outgoing blocklists */
478     if ($this->out_blocklist_dialog){
480       /* This handles the divSelectBox */
482       /* The base specifies the current position in the ldap tree
483        * The current base was specified by $_GET['dep_id'] before. Or contains the default value.
484        */
485       $base = $_SESSION['Fax_Filter']['depselect'];
486       $ldap->cd($base);
488       /* Ge all Blocklists */ 
489       $ldap->search ("(objectClass=goFaxSBlock)",array("cn","description"));
490       while ($attrs= $ldap->fetch()){
491         if(isset($attrs['description'][0])){
492           $list[$attrs['cn'][0]]=
493             $attrs['description'][0].
494             " [".$attrs['cn'][0]."]";
495         }else{
496           $list[$attrs['cn'][0]]= $attrs['cn'][0];
497         }
498       }
500       /*Create DivSel*/
501       $divSel = new divSelectBox("divSelectPredefined");
502       $divSel->setHeight(296);
504       /* NEW LIST MANAGMENT
505        * We also need to search for the departments
506        * So we are able to navigate like in konquerer
507        */
508       $this->departments= array();
509       $ldap->ls("(objectClass=gosaDepartment)",$base);
511       /* Generate Back url, and append if it is needed */
512       $base_back = preg_replace("/^[^,]+,/","",$base);
513       if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){
514         $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]";
515       }
517       /* Get all departments */
518       while($value = $ldap->fetch()){
519         if(isset($value["description"][0])){
520           $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
521         }else{
522           $this->departments[$value['dn']]=$value["description"][0];
523         }
524       }
525       /* END NEW LIST MANAGMENT
526        */
528       // Defining Links
529       $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
531       /* Insert departments in divlist*/
532       foreach($this->departments as $key=> $val){
533         if(!isset($this->config->departments[trim($key)])){
534           $this->config->departments[trim($key)]="";
535         }
537         $field1 = array("string" => "<img src='images/folder.png' alt='department'>","attach"=>"style='width:16px;text-align:center;'");
538         $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'");
539         $divSel->AddEntry(array($field1,$field2));
540       }
542       /* Append Blocklits */
543       foreach($list as $entry => $value){
544         $divSel->AddEntry(array(
545               array("string"=>"<input type='checkbox' value='".base64_encode($entry)."' name='ADDLIST_".base64_encode($entry)."'>"),
546               array("string"=>$value,"attach"=>"style='border:0px;'")
547               ));
548       }
550       /* Show dialog */
551       $smarty->assign("cblocklist", $this->current_blocklist);
552       $smarty->assign("goFaxBlockListACL", chkacl($this->acl, "goFaxBlockList"));
553       $smarty->assign("departments", $this->config->idepartments);
554       $smarty->assign("divSelectPredefined", $divSel->DrawList());
555       $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__)));
556       return ($display);
557     }
560     /* Show main page */
561     $smarty->assign("languages", $this->config->data['MAIN']['LANGUAGES']);
562     $smarty->assign("formats", $this->config->data['MAIN']['FAXFORMATS']);
563     $smarty->assign("printers", $this->printerList);
565     /* Load attributes */
566     foreach(array("goFaxIsEnabled", "goFaxDeliveryMode", "facsimileTelephoneNumber",
567           "goFaxPrinter", "goFaxLanguage", "goFaxFormat", 
568           "facsimileAlternateTelephoneNumber", "mail") as $val){
570       $smarty->assign("$val", $this->$val);
571       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
572     }
573     $smarty->assign("goFaxRBlockgroupsACL", chkacl($this->acl, "goFaxRBlockgroups"));
574     $smarty->assign("goFaxSBlockgroupsACL", chkacl($this->acl, "goFaxSBlockgroups"));
576     /* Load checkboxes */
577     if ($this->goFaxIsEnabled == "1"){
578       $smarty->assign("goFaxIsEnabled", "");
579     } else {
580       $smarty->assign("goFaxIsEnabled", "checked");
581     }
582     /* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */
583     if ($this->goFaxDeliveryMode & 32) {
584       $smarty->assign("fax_to_mail", "checked");
585     } else {
586       $smarty->assign("fax_to_mail", "");
587     }
588     if ($this->goFaxDeliveryMode & 64) {
589       $smarty->assign("fax_to_printer", "checked");
590     } else {
591       $smarty->assign("fax_to_printer", "");
592     }
595     $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
596     return ($display);
597   }
599   function remove_from_parent()
600   {
601     /* Cancel if there's nothing to do here */
602     if (!$this->initially_was_account){
603       return;
604     }
606     plugin::remove_from_parent();
608     /* Zero out arrays */
609     foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
610           "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
612       $this->attrs[$val]= array();
613     }
615     /* Adapt mail settings if needed */
616     if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){
617       unset($this->attrs['mail']);
618     }
620     $ldap= $this->config->get_ldap_link();
621     $ldap->cd($this->dn);
622     $this->cleanup();
623     $ldap->modify ($this->attrs); 
625     show_ldap_error($ldap->get_error(), _("Removing FAX account failed"));
627     /* Optionally execute a command after we're done */
628     $this->handle_post_events('remove');
629   }
632   /* Check formular input */
633   function check()
634   {
635     /* Call common method to give check the hook */
636     $message= plugin::check();
638     /* must: facsimileTelephoneNumber */
639     if ($this->facsimileTelephoneNumber == ""){
640       $message[]= _("The required field 'Fax' is not set.");
641     }
643     if (!is_phone_nr($this->facsimileTelephoneNumber)){
644       $message[]= _("Please enter a valid telephone number in the 'Fax' field.");
645     }
647     /* IF mail is specified (which is only the case if there's no mail account
648        present), check if it's valid..  */
649     if (@isset($this->parent->by_object['mailAccount']) &&
650         $this->goFaxDeliveryMode && 32){
651       if ($this->mail == ""){
652         $message[]= _("Mail delivery is checked, but no address has been specified.");
653       } elseif (!is_email($this->mail)){
654         $message[]= _("The mail address you've entered is invalid.");
655       }
656     }
658     // IE Fix, IE lets you choose disabled option, stupid browser ... 
659     if((empty($this->goFaxPrinter))&&($this->goFaxDeliveryMode & 64)){
660       $message[]= _("Deliver fax to printer, is only possible if valid printer is given. Please correct your choice.");
661     }
663     return ($message);
664   }
666   /* Save data to object */
667   function save_object()
668   {
669     if (isset($_POST['faxTab'])){
670       plugin::save_object();
672       /* Adapt combobox values */
673       $tmp= 0;
674       if (isset($_POST["fax_to_mail"]) && $_POST["fax_to_mail"] == 1){
675         $tmp+= 32;
676       }
677       if (isset($_POST["fax_to_printer"]) && $_POST["fax_to_printer"] == 1){
678         $tmp+= 64;
679       }
680       if (chkacl ($this->acl, "goFaxIsEnabled") == ""){
681         if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){
682           $this->goFaxIsEnabled= "0";
683         } else {
684           $this->goFaxIsEnabled= "1";
685         }
686       }
688       if (isset($_POST['facsimileTelephoneNumber'])){
689         if ($_POST['facsimileTelephoneNumber'] != $this->facsimileTelephoneNumber){
690           $this->is_modified= TRUE;
691         }
692         $this->facsimileTelephoneNumber= $_POST['facsimileTelephoneNumber'];
693       }
695       if (isset($_POST['mail'])){
696         if ($this->mail != $_POST['mail']){
697           $this->is_modified= TRUE;
698         }
699         $this->mail= $_POST['mail'];
700       }
702       /* Write to object */
703       if (chkacl ($this->acl, "goFaxDeliveryMode") == ""){
704         if ($tmp != $this->goFaxDeliveryMode){
705           $this->is_modified= TRUE;
706         }
707         $this->goFaxDeliveryMode= "$tmp";
708       }
710       /* Check if mail account is active and correct the internal
711          reference to represent the current status. */
712       if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
713         $this->has_mailAccount= TRUE;
714       }
715     }
717   }
720   /* Save to LDAP */
721   function save()
722   {
723     plugin::save();
725     /* Save arrays */
726     foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
727           "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
729       $this->attrs[$val]= $this->$val;
730     }
732     /* Adapt mail settings if needed */
733     unset($this->attrs['mail']);
734     if (!$this->has_mailAccount && $this->goFaxDeliveryMode && 32){
735       $this->attrs['mail']= $this->mail;
736     }
738     /* Write back to ldap */
739     $ldap= $this->config->get_ldap_link();
740     $ldap->cd($this->dn);
741     $this->cleanup();
742     $ldap->modify ($this->attrs); 
744     show_ldap_error($ldap->get_error(), _("Saving FAX account failed"));
746     /* Optionally execute a command after we're done */
747     if ($this->initially_was_account == $this->is_account){
748       if ($this->is_modified){
749         $this->handle_post_events("mofify");
750       }
751     } else {
752       $this->handle_post_events("add");
753     }
755   }
758   /* Adapt from template, using 'dn' */
759   function adapt_from_template($dn)
760   {
761     plugin::adapt_from_template($dn);
763     foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
764           "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
766       if (isset($this->attrs[$val])){
767         $this->$val= $this->attrs[$val];
768       }
769     }
770   }
774   /* Add alternate fax recipient */
775   function addAlternate($number)
776   {
777     $this->facsimileAlternateTelephoneNumber[]= "$number";
778     $this->facsimileAlternateTelephoneNumber=
779       array_unique ($this->facsimileAlternateTelephoneNumber);
781     sort ($this->facsimileAlternateTelephoneNumber);
782     reset ($this->facsimileAlternateTelephoneNumber);
783   }
785   function delAlternate($numbers)
786   {
787     $this->facsimileAlternateTelephoneNumber= array_remove_entries ($numbers,
788         $this->facsimileAlternateTelephoneNumber);
789   }
791   function getCopyDialog()
792   {
793     $str    = "";
794     $smarty = get_smarty();
795     $smarty->assign("facsimileTelephoneNumber", $this->facsimileTelephoneNumber);
796     $str['string']   = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
797     $str['status'] ="";
798     return($str);
799   }
801   function SaveCopyDialog()
802   {
803     if(isset($_POST['facsimileTelephoneNumber'])){
804       $this->facsimileTelephoneNumber = $_POST['facsimileTelephoneNumber'];
805     }
806   }
810 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
811 ?>