Code

3b55b3285f79d3298e734621b612f93be08df7ff
[gosa.git] / gosa-plugins / goto / personal / environment / main.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 $lock_msg = "";
21 if (!$remove_lock){
23   /* Reset requested? */
24   if (isset($_POST['edit_cancel']) || 
25       (isset($_GET['reset']) && $_GET['reset'] == 1)){
27     /* Only remove lock if object was opened 
28      */
29     if(session::is_set('environment') && session::is_set('edit')){
30       del_lock ($ui->dn);
31     }
32     session::un_set ('edit');
33     session::un_set ('environment');
34   }
36   /* Create mail object on demand */
37   if (!session::is_set('environment') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
38     $environment= new environment ($config, $ui->dn);
39     $environment->enable_CSN_check();
40     $environment->set_acl_category('users');
41     $environment->set_acl_base($ui->dn);
42     session::set('environment',$environment);
43   }
44   $environment = session::get('environment');
46   /* save changes back to object */
47   if (session::is_set('edit')){
48     $environment->save_object ();
49   }
51   /* Enter edit mode? */
52   if (isset($_POST['edit']) || isset($_POST['delete_lock'])){
53   
54    /* Check locking */
55     if (($username= get_lock($ui->dn)) != ""){
56       session::set('back_plugin',$plug);
57       session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
58       $lock_msg =  gen_locked_message ($username, $ui->dn);
60     }else{
62       /* Lock the current entry */
63       add_lock ($ui->dn, $ui->dn);
64       session::set('dn',$ui->dn);
65       session::set('edit',TRUE);
66     }
67   }
69   /* save changes to LDAP and disable edit mode */
70   if (isset($_POST['edit_finish'])){
72     /* Perform checks */
73     $message= $environment->check ();
75     /* No errors, save object */
76     if (count ($message) == 0){
77       $environment->save ();
78       del_lock ($ui->dn);
79       session::un_set ('edit');
81       /* Remove object */
82       session::un_set ('environment');
83     } else {
84       /* Errors found, show message */
85       msg_dialog::displayChecks($message);
86     }
87   }
89   /* Execute formular */
90   if($lock_msg){
91     $display = $lock_msg;
92   }else{
93     $display = $environment->execute();
94   }
96   /* Store changes  in session */
97   if (session::is_set('edit')){
98     session::set('environment',$environment);
99   }
101   $info= "";
102   /* Show page footer depending on the mode */
103   if (!$environment->in_dialog && !$environment->dialog && $environment->is_account  && empty($lock_msg)){
104     $display.= "<p class=\"plugbottom\">";
106     /* Are we in edit mode? */
107     if (session::is_set('edit')){
108       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
109       $display.= "&nbsp;";
110       $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
111       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
112              "\"> ".$ui->dn."&nbsp;";
113     } else {
114       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
115         "\"> ".$ui->dn."&nbsp;";
116       if(preg_match("/r/",$ui->get_permissions($ui->dn,"users/environment"))){
117         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png').
118           "\"> ".msgPool::clickEditToChange();
119         $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
120       }
121       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
122     }
123     $display.= "</p>\n";
124   }
126   /* Page header*/
127   $display= print_header(get_template_path('plugins/goto/images/plugin.png'), _("User environment settings"), $info).$display;
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>