-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy patheventedit.php
120 lines (101 loc) · 4.02 KB
/
eventedit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2012 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
if(isset($_GET['action']) && $_GET['action'] == 'open')
{
$DB->Execute('UPDATE events SET closed = 0 WHERE id = ?',array($_GET['id']));
$SESSION->redirect('?'.$SESSION->get('backto'));
}
elseif(isset($_GET['action']) && $_GET['action'] == 'close')
{
$DB->Execute('UPDATE events SET closed = 1 WHERE id = ?',array($_GET['id']));
$SESSION->redirect('?'.$SESSION->get('backto'));
}
elseif(isset($_GET['action']) && $_GET['action'] == 'dropuser')
{
$DB->Execute('DELETE FROM eventassignments WHERE eventid = ? AND userid = ?',array($_GET['eid'], $_GET['aid']));
$SESSION->redirect('?'.$SESSION->get('backto'));
}
$event = $DB->GetRow('SELECT events.id AS id, title, description, note,
date, begintime, endtime, customerid, private, closed, '
.$DB->Concat('UPPER(customers.lastname)',"' '",'customers.name').' AS customername
FROM events LEFT JOIN customers ON (customers.id = customerid)
WHERE events.id = ?', array($_GET['id']));
$event['date'] = sprintf('%04d/%02d/%02d', date('Y',$event['date']),date('n',$event['date']),date('j',$event['date']));
$eventuserlist = $DB->GetAll('SELECT userid AS id, users.name
FROM users, eventassignments
WHERE users.id = userid
AND eventid = ?', array($event['id']));
if(isset($_POST['event']))
{
$event = $_POST['event'];
$event['id'] = $_GET['id'];
if($event['title'] == '')
$error['title'] = trans('Event title is required!');
if($event['date'] == '')
$error['date'] = trans('You have to specify event day!');
else
{
list($year,$month, $day) = explode('/',$event['date']);
if(!checkdate($month,$day,$year))
$error['date'] = trans('Incorrect date format! Enter date in YYYY/MM/DD format!');
}
if(!$error)
{
$date = mktime(0, 0, 0, $month, $day, $year);
$event['private'] = isset($event['private']) ? 1 : 0;
$DB->Execute('UPDATE events SET title=?, description=?, date=?, begintime=?, endtime=?, private=?, note=?, customerid=? WHERE id=?',
array($event['title'], $event['description'], $date, $event['begintime'], $event['endtime'], $event['private'], $event['note'], $event['customerid'], $event['id']));
if($event['user'])
{
if(!$DB->GetOne('SELECT 1 FROM eventassignments WHERE eventid = ? AND userid = ?',array($event['id'], $event['user'])))
{
$DB->Execute('INSERT INTO eventassignments (eventid, userid) VALUES(?,?)',array($event['id'], $event['user']));
}
}
$DB->Execute('UPDATE events SET moddate=?, moduserid=? WHERE id=?',
array(
mktime(),
$AUTH->id,
$event['id']
));
$SESSION->redirect('?m=eventlist');
}
}
$event['userlist'] = $eventuserlist;
$layout['pagetitle'] = trans('Event Edit');
$SESSION->save('backto', $_SERVER['QUERY_STRING']);
$userlist = $LMS->GetUserNames();
$SMARTY->assign('customerlist', $LMS->GetCustomerNames());
$SMARTY->assign('userlist', $userlist);
$SMARTY->assign('userlistsize', sizeof($userlist));
$SMARTY->assign('error', $error);
$SMARTY->assign('event', $event);
$SMARTY->assign('hours',
array(0,30,100,130,200,230,300,330,400,430,500,530,
600,630,700,730,800,830,900,930,1000,1030,1100,1130,
1200,1230,1300,1330,1400,1430,1500,1530,1600,1630,1700,1730,
1800,1830,1900,1930,2000,2030,2100,2130,2200,2230,2300,2330));
$SMARTY->display('eventedit.html');
?>