source: trunk/calendar/inc/class.uialarm.inc.php @ 2

Revision 2, 7.6 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Calendar                                                    *
4  * http://www.egroupware.org                                                *
5  * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net>               *
6  *          http://www.radix.net/~cknudsen                                  *
7  * Modified by Mark Peters <skeeter@phpgroupware.org>                       *
8  * --------------------------------------------                             *
9  *  This program is free software; you can redistribute it and/or modify it *
10  *  under the terms of the GNU General Public License as published by the   *
11  *  Free Software Foundation; either version 2 of the License, or (at your  *
12  *  option) any later version.                                              *
13  \**************************************************************************/
14
15
16        class uialarm
17        {
18                var $template;
19                var $template_dir;
20
21                var $bo;
22                var $event;
23
24                var $debug = False;
25//              var $debug = True;
26
27                var $tz_offset;
28                var $theme;
29
30                var $public_functions = array(
31                        'manager' => True
32                );
33
34                function uialarm()
35                {
36                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
37                        $GLOBALS['phpgw']->browser    = CreateObject('phpgwapi.browser');
38                       
39                        $this->theme = $GLOBALS['phpgw_info']['theme'];
40
41                        $this->bo = CreateObject('calendar.boalarm');
42
43                        if($this->debug)
44                        {
45                                echo "BO Owner : ".$this->bo->owner."<br>\n";
46                        }
47                        $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar');
48
49                        if (!is_object($GLOBALS['phpgw']->html))
50                        {
51                                $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
52                        }
53                        $this->html = &$GLOBALS['phpgw']->html;
54                }
55
56                function prep_page()
57                {
58                        if ($this->bo->cal_id <= 0 ||
59                                !$this->event = $this->bo->read_entry($this->bo->cal_id))
60                        {
61                                $GLOBALS['phpgw']->redirect_link('/index.php',Array(
62                                        'menuaction'    => 'calendar.uicalendar.index'
63                                ));
64                        }
65
66                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
67                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
68                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Alarm Management');
69                        $GLOBALS['phpgw']->common->phpgw_header();
70
71                        $this->template = CreateObject('phpgwapi.Template',$this->template_dir);
72
73                        $this->template->set_unknowns('remove');
74                        $this->template->set_file(
75                                Array(
76                                        'alarm' => 'alarm.tpl'
77                                )
78                        );
79                        $this->template->set_block('alarm','alarm_management','alarm_management');
80                        $this->template->set_block('alarm','alarm_headers','alarm_headers');
81                        $this->template->set_block('alarm','list','list');
82                        $this->template->set_block('alarm','hr','hr');
83                        $this->template->set_block('alarm','buttons','buttons');
84                }
85
86                function output_template_array($row,$list,$var)
87                {
88                        if (!isset($var['tr_color']))
89                        {
90                                $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color();
91                        }
92                        $this->template->set_var($var);
93                        $this->template->parse($row,$list,True);
94                }
95
96                /* Public functions */
97
98                function manager()
99                {
100                        if ($_POST['cancel'])
101                        {
102                                $GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.($_POST['return_to'] ? $_POST['return_to'] : 'calendar.uicalendar.index'));
103                        }
104                        if ($_POST['delete'] && count($_POST['alarm']))
105                        {
106                                if ($this->bo->delete($_POST['alarm']) < 0)
107                                {
108                                        echo '<center>'.lang('You do not have permission to delete this alarm !!!').'</center>';
109                                        $GLOBALS['phpgw']->common->phpgw_exit(True);
110                                }
111                        }
112                        if (($_POST['enable'] || $_POST['disable']) && count($_POST['alarm']))
113                        {
114                                if ($this->bo->enable($_POST['alarm'],$_POST['enable']) < 0)
115                                {
116                                        echo '<center>'.lang('You do not have permission to enable/disable this alarm !!!').'</center>';
117                                        $GLOBALS['phpgw']->common->phpgw_exit(True);
118                                }
119                        }
120                        $this->prep_page();
121
122                        if ($_POST['add'])
123                        {
124                                $time = (int)($_POST['time']['days'])*24*3600 +
125                                        (int)($_POST['time']['hours'])*3600 +
126                                        (int)($_POST['time']['mins'])*60;
127
128                                if ($time > 0 && !$this->bo->add($this->event,$time,$_POST['owner']))
129                                {
130                                        echo '<center>'.lang('You do not have permission to add alarms to this event !!!').'</center>';
131                                        $GLOBALS['phpgw']->common->phpgw_exit(True);
132                                }
133                        }
134                        if (!ExecMethod('calendar.uicalendar.view_event',$this->event))
135                        {
136                                echo '<center>'.lang('You do not have permission to read this record!').'</center>';
137                                $GLOBALS['phpgw']->common->phpgw_exit(True);
138                        }
139                        echo "<br>\n";
140                        $GLOBALS['phpgw']->template->set_var('th_bg',$this->theme['th_bg']);
141                        $GLOBALS['phpgw']->template->set_var('hr_text',lang('Alarms').':');
142                        $GLOBALS['phpgw']->template->fp('row','hr',True);
143                        $GLOBALS['phpgw']->template->pfp('phpgw_body','view_event');
144
145                        $var = Array(
146                                'tr_color'              => $this->theme['th_bg'],
147                                'lang_select'   => lang('Select'),
148                                'lang_time'             => lang('Time'),
149                                'lang_text'             => lang('Text'),
150                                'lang_owner'    => lang('Owner'),
151                                'lang_enabled'  => lang('enabled'),
152                                'lang_disabled' => lang('disabled'),
153                        );
154                        if($this->event['alarm'])
155                        {
156                                $this->output_template_array('rows','alarm_headers',$var);
157
158                                foreach($this->event['alarm'] as $key => $alarm)
159                                {
160                                        if (!$this->bo->check_perms(PHPGW_ACL_READALARM,$alarm['owner']))
161                                        {
162                                                continue;
163                                        }
164                                        $var = Array(
165                                                'field'    => $GLOBALS['phpgw']->common->show_date($alarm['time']),
166                                                //'data'   => $alarm['text'],
167                                                'data'     => lang('Email Notification'),
168                                                'owner'    => $GLOBALS['phpgw']->common->grab_owner_name($alarm['owner']),
169                                                'enabled'  => $this->html->image('calendar',$alarm['enabled']?'enabled':'disabled',$alarm['enabled']?'enabled':'disabled','width="13" height="13"'),
170                                                'select'   => $this->html->checkbox("alarm[$alarm[id]]")
171                                        );
172                                        if ($this->bo->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
173                                        {
174                                                ++$to_delete;
175                                        }
176                                        $this->output_template_array('rows','list',$var);
177                                }
178                                $this->template->set_var('enable_button',$this->html->submit_button('enable','Enable'));
179                                $this->template->set_var('disable_button',$this->html->submit_button('disable','Disable'));
180                                if ($to_delete)
181                                {
182                                        $this->template->set_var('delete_button',$this->html->submit_button('delete','Delete',"return confirm('".lang("Are you sure\\nyou want to\\ndelete these alarms?")."')"));
183                                }
184                                $this->template->parse('rows','buttons',True);
185                        }
186                        if (isset($this->event['participants'][(int)$GLOBALS['phpgw_info']['user']['account_id']]))
187                        {
188                                $this->template->set_var(Array(
189                                        'input_days'    => $this->html->select('time[days]',$_POST['time']['days'],range(0,31),True).' '.lang('days'),
190                                        'input_hours'   => $this->html->select('time[hours]',$_POST['time']['hours'],range(0,24),True).' '.lang('hours'),
191                                        'input_minutes' => $this->html->select('time[mins]',$_POST['time']['mins'],range(0,60),True).' '.lang('minutes').' '.lang('before the event'),
192                                        'input_owner'   => $this->html->select('owner',$GLOBALS['phpgw_info']['user']['account_id'],$this->bo->participants($this->event,True),True),
193                                        'input_add'     => $this->html->submit_button('add','Add Alarm'),
194                                ));
195                        }
196                        $this->template->set_var(Array(
197                                'action_url'    => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')),
198                                'hidden_vars'   => $this->html->input_hidden(array(
199                                        'cal_id' => $this->bo->cal_id,
200                                        'return_to' => $_POST['return_to']
201                                )),
202                                'lang_enable'   => lang('Enable'),
203                                'lang_disable'  => lang('Disable'),
204                                'input_cancel'  => $this->html->submit_button('cancel','Cancel')
205                        ));
206//echo "<p>alarm_management='".htmlspecialchars($this->template->get_var('alarm_management'))."'</p>\n";
207                        $this->template->pfp('out','alarm_management');
208                }
209        }
210?>
Note: See TracBrowser for help on using the repository browser.