]>
git.datanom.net - webcal.git/blob - events/edit_event.php
4 require_once 'calendar.class.php' ;
5 require_once 'user_validate.php' ;
6 require_once 'helper.php' ;
10 include_once 'config.inc.php' ;
11 include_once 'eventgui.class.php' ;
13 if (! defined ( $_SESSION [ '__ROOT__' ]) && empty ( $_SESSION [ '__ROOT__' ])) {
15 header ( 'Location: ' . WEB_ROOT
. 'error.html' );
19 if ( isset ( $_SESSION [ 'authenticate' ]) && $_SESSION [ 'authenticate' ]-> validUser ()) {
20 $view_style = ( $_SESSION [ 'user_settings' ]-> getViewStyle ()) ?
21 $_SESSION [ 'user_settings' ]-> getViewStyle () : VIEW_STYLE
;
22 // $timeout = ($_SESSION['user_settings']->getTimeout()) ?
23 // (int) $_SESSION['user_settings']->getTimeout() : TIMEOUT;
24 $week_start_sunday = ( $_SESSION [ 'user_settings' ]-> getStartWeek () !== NULL ) ?
25 $_SESSION [ 'user_settings' ]-> getStartWeek () : WEEK_START_SUNDAY
;
26 $start_hour = ( $_SESSION [ 'user_settings' ]-> getStartHour ()) ?
27 ( int ) $_SESSION [ 'user_settings' ]-> getStartHour () : START_HOUR
;
28 $end_hour = ( $_SESSION [ 'user_settings' ]-> getEndHour ()) ?
29 ( int ) $_SESSION [ 'user_settings' ]-> getEndHour () : END_HOUR
;
33 if ( $pwd [ strlen ( $pwd )- 1 ] == '/' )
34 $pwd = substr ( $pwd , 0 , - 1 );
36 if ( isset ( $_POST ) && count ( $_POST ) > 0 ) {
37 $exclude = array ( 'tzid' , 'range' , 'times' , 'untildate' );
38 $start = array ( 'date' => NULL , 'time' => NULL );
39 $end = array ( 'date' => NULL , 'time' => NULL );
40 $referer = $_POST [ 'referer' ];
43 foreach ( $_POST as $key => $value ) {
44 //echo "$key => $value<br/>";
45 if ( strcmp ( $key , 'referer' ) == 0 )
47 if ( in_array ( $key , $exclude ))
49 if ( strcasecmp ( $key , 'startdate' ) == 0 ) {
50 $start [ 'date' ] = join ( '' , explode ( '-' , $value ));
53 if ( strcasecmp ( $key , 'starttime' ) == 0 ) {
54 $start [ 'time' ] = $value ;
55 if ( strlen ( $start [ 'time' ]) < 5 )
56 $start [ 'time' ] .= '00' ;
59 if ( strcasecmp ( $key , 'enddate' ) == 0 ) {
60 $end [ 'date' ] = join ( '' , explode ( '-' , $value ));
63 if ( strcasecmp ( $key , 'endtime' ) == 0 ) {
64 $end [ 'time' ] = $value ;
65 if ( strlen ( $end [ 'time' ]) < 5 )
69 if ( strcasecmp ( "allDay" , $key ) == 0 ) {
73 if ( strcasecmp ( "recurrence" , $key ) == 0 ) {
74 $value = "FREQ= $value" ;
77 //echo " $key => $value < br
/> ";
78 $_SESSION ['current_event']->setProperty( $key , $value );
80 //echo 'DTSTART: '. $start ['date'].'T'. $start ['time'];
81 //echo '<br/>DTEND: '. $end ['date'].'T'. $end ['time'];
84 $_SESSION ['current_event']->setProperty(
85 'DTSTART;VALUE=DATE', $start ['date']);
86 $_SESSION ['current_event']->setProperty(
87 'DTEND;VALUE=DATE', $end ['date']);
88 //echo " < br
/> ". $start ['date']." < br
/> ";
89 //echo $end ['date']." < br
/> ";
92 $start = strtotime( $start ['date'].'T'. $start ['time']);
93 $end = strtotime( $end ['date'].'T'. $end ['time']);
94 //echo " < br
/> ".Calendar::timestamp2ICal( $start , FALSE)." < br
/> ";
95 //echo Calendar::timestamp2ICal( $end , FALSE)." < br
/> ";
97 $_SESSION ['current_event']->setProperty('DTSTART',
98 Calendar::timestamp2ICal( $start , FALSE));
99 $_SESSION ['current_event']->setProperty('DTEND',
100 Calendar::timestamp2ICal( $end , FALSE));
103 if (isset( $_SESSION ['calendar'])) {
104 $res = $_SESSION ['calendar']->update(
105 $_SESSION ['current_event']->getUrl(),
106 $_SESSION ['current_event']->getEtag());
109 unset( $_SESSION ['current_event']);
110 unset( $_SESSION ['calendar']);
111 unset( $_SESSION ['EVENT_ACTION']);
112 if (count( $res ) == 0) {
113 header('Location: ' . $referer );
117 foreach ( $res as $elem ) {
119 $msg .= " $k : " . $elem [ $k ];
123 throw new Exception(" Error updating event
");
125 $msg = join(" ", explode(" \n
", $msg ));
129 <?xml version=" 1.0 " encoding=" utf
- 8 "?>
130 <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Strict//EN"
131 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
132 < html xmlns
= "http://www.w3.org/1999/xhtml" xml
: lang
= "en" lang
= "en" >
134 < title
> $title </ title
>
135 < meta http
- equiv
= "content-type" content
= "application/xhtml+xml; charset=UTF-8" />
136 < meta http
- equiv
= "content-style-type" content
= "text/css" />
137 < link rel
= "stylesheet" type
= "text/css" href
= " $pwd /css/top_level.css" />
138 < link rel
= "shortcut icon" href
= " $pwd /pixmaps/favicon.ico" />
139 < script type
= "text/javascript" src
= " $pwd /js/helper.js" ></ script
>
141 < body onload
= "error(' $msg' )" >
142 < table style
= "width: 100%;" >
144 < td style
= "width: 33%" >< img src
= " $pwd /pixmaps/calendar.png" alt
= "calendar.png" /></ td
>
145 < td style
= "width: 33%; text-align: center;" >< a href
= " $pwd /logout.php" >< img style
= "border: 0" src
= " $pwd /pixmaps/exit.png" width
= "32" height
= "32" alt
= "Logout" />< br
/> Logout
</ a
></ td
>
146 < td style
= "text-align: right" >< span style
= "font-size: 1.6em" > DAViCal Web Calendar
</ span
>< br
/> - A Web
Interface for < a href
= "javascript: newwin('http://www.davical.org/');" > DAViCal
</ a
></ td
>
151 include TOP_FOLDER.'/include/menu.inc.php';
152 print " < div id
=\" ui\"
></ div
> ";
153 include TOP_FOLDER.'/include/footer.inc.php';
157 $query = construct_URL( $_SERVER ['QUERY_STRING'],
158 array('etag', 'referer', 'cal'));
159 //print_r( $_SESSION ['all_events'][ $query ['cal']]);
161 if (isset( $query ['cal']) && ! empty( $query ['cal'])) {
162 $_SESSION ['calendar'] = $_SESSION ['all_events'][ $query ['cal']];
163 if (! is_object( $_SESSION ['calendar']))
164 throw new Exception(" Missing calendar
object ");
166 if ( $_SESSION ['EVENT_ACTION'] == 'NEW') {
167 $event = $_SESSION ['calendar']->newComponent('VEVENT');
168 $_SESSION ['current_event'] = $event ;
171 foreach ( $_SESSION ['calendar'] as $vevent ) {
172 if ( $vevent- >getEtag() == $query ['etag']) {
177 $_SESSION ['current_event'] = $event ;
179 //print $query ['referer'];
181 $gui = new EventGUI( $event , $query ['referer'], $query ['cal']);
182 //unset( $_GET ['referer']);
183 $calendar = $gui- >getView();
186 $text = '<h3 style=" text
- align
: center
">Choose an event from one of the listed calendars</h3>';
188 $text .= '<form id=" cals
" style=" text
- align
: center
" action=" '.
189 $_SERVER [' PHP_SELF
'].' " method=" get
">';
190 $text .= '<input type=" hidden
" name=" referer
" value=" '.urldecode( $query [' referer
']).' " />';
191 $text .= '<input type=" hidden
" id=" cal
" name=" cal
" value=" " />';
193 foreach ( $_SESSION ['all_events'] as $name => $cal ) {
194 // $calendar .= " $name < br
/> ".var_export( $cal , true)." < br
/> ";
195 $text .= $name .': <select name=" etag
"
196 onchange=" setCalendar (\' cals\'
, \' cal\'
, '."' $name'" . ')">' ;
197 $text .= '<option selected="selected"></option>' ;
198 foreach ( $cal as $vevent ) {
199 $calendar .= $vevent- > getEtag (). "<br/>" ;
200 $text .= '<option value="' . $vevent- > getEtag (). '">' .
201 $vevent- > getDetails (). '</option>' ;
203 $text .= '</select><br/><br/>' ;
205 $text .= '<input type="submit" value="Continue" />' ;
206 $text .= '</form></p>' ;
207 //print "{$_GET['referer']}";
209 print popup_window ( $text , $query [ 'referer' ]);
213 include TOP_FOLDER
. '/include/header.inc.php' ;
214 include TOP_FOLDER
. '/include/menu.inc.php' ;
216 print "<div id= \" ui \" > $calendar </div>" ;
217 include TOP_FOLDER
. '/include/footer.inc.php' ;
This page took 0.85141 seconds and 6 git commands to generate.