3 require_once('include/datetime.php');
4 require_once('include/event.php');
6 function events_post(&$a) {
11 $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
13 $start = strip_tags($_POST['start']);
14 $finish = strip_tags($_POST['finish']);
15 $desc = escape_tags($_POST['desc']);
16 $location = escape_tags($_POST['location']);
18 $adjust = intval($_POST['adjust']);
20 $str_group_allow = perms2str($_POST['group_allow']);
21 $str_contact_allow = perms2str($_POST['contact_allow']);
22 $str_group_deny = perms2str($_POST['group_deny']);
23 $str_contact_deny = perms2str($_POST['contact_deny']);
27 $r = q("UPDATE `event` SET
39 WHERE `id` = %d AND `uid` = %d LIMIT 1",
41 dbesc(datetime_convert()),
48 dbesc($str_contact_allow),
49 dbesc($str_group_allow),
50 dbesc($str_contact_deny),
51 dbesc($str_group_deny),
59 $uri = item_new_uri($a->get_hostname(),local_user());
61 $r = q("INSERT INTO `event` ( `uid`,`uri`,`created`,`edited`,`start`,`finish`,`desc`,`location`,`type`,
62 `adjust`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
63 VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' ) ",
66 dbesc(datetime_convert()),
67 dbesc(datetime_convert()),
74 dbesc($str_contact_allow),
75 dbesc($str_group_allow),
76 dbesc($str_contact_deny),
77 dbesc($str_group_deny)
86 function events_content(&$a) {
89 notice( t('Permission denied.') . EOL);
93 $o .= '<h2>' . t('Events') . '</h2>';
100 if($a->argc > 2 && $a->argv[1] == 'event') {
102 $event_id = intval($a->argv[2]);
104 if($a->argv[1] === 'new') {
108 if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
110 $y = intval($a->argv[1]);
111 $m = intval($a->argv[2]);
115 if($mode == 'view') {
116 $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
117 $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
119 $y = intval($thisyear);
121 $m = intval($thismonth);
124 $o .= cal($y,$m,false, ' eventcal');
126 $dim = get_dim($y,$m);
127 $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0);
128 $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59);
131 $r = q("SELECT * FROM `event` WHERE `start` >= '%s' AND `finish` <= '%s' AND `uid` = %d ",
139 $o .= format_event_html($rr);
144 if($mode === 'edit' || $mode === 'new') {
145 $tpl = get_markup_template('event_form.tpl');
147 $year = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
150 $o .= replace_macros($tpl,array(
151 '$post' => $a->get_baseurl() . '/events',
152 '$e_text' => t('Event details'),
153 '$s_text' => t('Starting date/time:'),
154 '$s_dsel' => datesel('start',$year+5,$year,false,$year,0,0),
155 '$s_tsel' => timesel('start',0,0),
156 '$f_text' => t('Finish date/time:'),
157 '$f_dsel' => datesel('start',$year+5,$year,false,$year,0,0),
158 '$f_tsel' => timesel('start',0,0),
159 '$d_text' => t('Description:'),
161 '$l_text' => t('Location:'),
163 '$submit' => t('Submit')