Code

Some fixes for gofax account
[gosa.git] / plugins / gofax / faxaccount / main.inc
1 <?php
2 if (!$remove_lock){
4         /* Reset requested? */
5         if (isset($_POST['edit_cancel']) ||
6                 (isset($_GET['reset']) && $_GET['reset'] == 1)){
8                 del_lock ($ui->dn);
9                 sess_del ('edit');
10                 sess_del ('gofaxAccount');
11         }
13         /* Create gofaxAccount object on demand */
14         if (!isset($_SESSION['gofaxAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
15                 $_SESSION['gofaxAccount']= new gofaxAccount ($config, $ui->dn);
16                 $_SESSION['gofaxAccount']->set_acl_base($ui->dn);
17                 $_SESSION['gofaxAccount']->set_acl_category("users");
19         }
20         $gofaxAccount= $_SESSION['gofaxAccount'];
22         /* save changes back to object */
23         if (isset ($_SESSION['edit'])){
24                 $gofaxAccount->save_object ();
25         }
27         /* Enter edit mode? */
28         if (isset($_POST['edit'])){
30                 /* Check locking */
31                 if (($username= get_lock($ui->dn)) != ""){
32                         $_SESSION['back_plugin']= $plug;
33                         gen_locked_message ($username, $ui->dn);
34                         exit ();
35                 }
37                 /* Lock the current entry */
38                 add_lock ($ui->dn, $ui->dn);
39                 $_SESSION['dn']= $ui->dn;
40                 $_SESSION['edit']= TRUE;
41         }
43         /* save changes to LDAP and disable edit mode */
44         if (isset($_POST['edit_finish'])){
46                 /* Perform checks */
47                 $message= $gofaxAccount->check ();
49                 /* No errors, save object */
50                 if (count ($message) == 0){
51                         $gofaxAccount->save ();
52                         gosa_log ("User/fax object'".$ui->dn."' has been saved");
53                         del_lock ($ui->dn);
54                         sess_del ('edit');
56                 } else {
57                         /* Errors found, show message */
58                         show_errors ($message);
59                 }
60         }
62         /* Execute formular */
63         $display= $gofaxAccount->execute ();
64         $info= "";
66         /* Store changes  in session */
67         if (isset ($_SESSION['edit'])){
68                 $_SESSION['gofaxAccount']= $gofaxAccount;
69         }
71         /* Show page footer depending on the mode */
72         if (!$gofaxAccount->locals_dialog &&
73                 !$gofaxAccount->out_blocklist_dialog &&
74                 !$gofaxAccount->in_blocklist_dialog &&
75                 $gofaxAccount->is_account){
77                 $display.= "<p class=\"plugbottom\">\n";
79                 /* Are we in edit mode? */
80                 if (isset($_SESSION['edit'])){
81                         $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
82                         $display.= "&nbsp;\n";
83                         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
84                         $info= "<img alt='' align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn."&nbsp;";
85                 } else {
86                         $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn."&nbsp;";
88                         if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/gofaxAccount"))){
89                                 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\">"._("Click the 'Edit' button below to change informations in this dialog");
90                                 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">";
91                         }
92                         $display.= "<input type=\"hidden\" name=\"ignore\">\n";
93                 }
94                 $display.= "</p>";
95         }
96         
97         /* Page header*/
98         $display= print_header(get_template_path('images/fax.png'), _("FAX settings"), $info).$display;
101 ?>