Code

Shrinked down aclRole class to half size.
[gosa.git] / plugins / gofax / faxaccount / main.inc
1 <?php
3 $display  ="";
4 $lock_msg = "";
6 if (!$remove_lock){
8         /* Reset requested? */
9         if (isset($_POST['edit_cancel']) ||
10                 (isset($_GET['reset']) && $_GET['reset'] == 1)){
12                 del_lock ($ui->dn);
13                 sess_del ('edit');
14                 sess_del ('gofaxAccount');
15         }
17         /* Create gofaxAccount object on demand */
18         if (!isset($_SESSION['gofaxAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
19                 $_SESSION['gofaxAccount']= new gofaxAccount ($config, $ui->dn);
20                 $_SESSION['gofaxAccount']->set_acl_base($ui->dn);
21                 $_SESSION['gofaxAccount']->set_acl_category("users");
23         }
24         $gofaxAccount= $_SESSION['gofaxAccount'];
26         /* save changes back to object */
27         if (isset ($_SESSION['edit'])){
28                 $gofaxAccount->save_object ();
29         }
31         /* Enter edit mode? */
32         if (isset($_POST['edit'])){
34                 /* Check locking */
35                 if (($username= get_lock($ui->dn)) != ""){
36                         $_SESSION['back_plugin']= $plug;
37                         $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
38                         $lock_msg =  gen_locked_message ($username, $ui->dn);
40                 }else{
42                         /* Lock the current entry */
43                         add_lock ($ui->dn, $ui->dn);
44                         $_SESSION['dn']= $ui->dn;
45                         $_SESSION['edit']= TRUE;
46                 }
47         }
49         /* save changes to LDAP and disable edit mode */
50         if (isset($_POST['edit_finish'])){
52                 /* Perform checks */
53                 $message= $gofaxAccount->check ();
55                 /* No errors, save object */
56                 if (count ($message) == 0){
57                         $gofaxAccount->save ();
58                         gosa_log ("User/fax object'".$ui->dn."' has been saved");
59                         del_lock ($ui->dn);
60                         sess_del ('edit');
62                 } else {
63                         /* Errors found, show message */
64                         show_errors ($message);
65                 }
66         }
68         /* Execute formular */
69         if($lock_msg){
70                 $display.= $lock_msg;
71         }else{
72                 $display.= $gofaxAccount->execute ();
73         }
75         $info= "";
77         /* Store changes  in session */
78         if (isset ($_SESSION['edit'])){
79                 $_SESSION['gofaxAccount']= $gofaxAccount;
80         }
82         /* Show page footer depending on the mode */
83         if (!$gofaxAccount->locals_dialog &&
84                 !$gofaxAccount->out_blocklist_dialog &&
85                 !$gofaxAccount->in_blocklist_dialog &&
86                 $gofaxAccount->is_account       && 
87                 empty($lock_msg)){
89                 $display.= "<p class=\"plugbottom\">\n";
91                 /* Are we in edit mode? */
92                 if (isset($_SESSION['edit'])){
93                         $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
94                         $display.= "&nbsp;\n";
95                         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
96                         $info= "<img alt='' align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn."&nbsp;";
97                 } else {
98                         $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn."&nbsp;";
100                         if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/gofaxAccount"))){
101                                 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\">"._("Click the 'Edit' button below to change informations in this dialog");
102                                 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">";
103                         }
104                         $display.= "<input type=\"hidden\" name=\"ignore\">\n";
105                 }
106                 $display.= "</p>";
107         }
108         
109         /* Page header*/
110         $display= print_header(get_template_path('images/fax.png'), _("FAX settings"), $info).$display;
113 ?>