📄 event.php3
字号:
$start_date = mktime( 0,0,0, date( "m", $this->start_time ), date( "j", $this->start_time ), date( "Y", $this->start_time ) ); if( !$this->end_time ) {// If there's no end_time, the event is one day only $timestamps[0] = $start_date; return $timestamps; } else {// also one day only if the end date is the same as the start date $end_date = mktime( 0,0,0, date( "m", $this->end_time ), date( "j", $this->end_time ), date( "Y", $this->end_time ) ); if( $end_date == $start_date ) { $timestamps[0] = $start_date; return $timestamps; } }// Otherwise, let's get ready to run through the entire date range $current_stamp = $start_date; $j = 0;// create an easy way to check the weekday, since in_array is a PHP4 feature for( $i=0; $i<count($this->weekday_id); $i++ ) $weekdays[$this->weekday_id[$i]] = 1; while( $current_stamp <= $end_date ) { if( $weekdays[ date( "w", $current_stamp ) ] ) $timestamps[$j++] = $current_stamp; $current_stamp = mktime( 0,0,0, date( "m", $current_stamp ), date( "j", $current_stamp ) + 1, date( "Y", $current_stamp ) ); } return $timestamps; } function getStringsForIDs() { $db_conn = connectROToCalendar();// will fetch the name column from a bunch of tables.// in those cases where there are multiple IDs, the strings will// be catted into a comma separated list $query = "SELECT name AS location FROM srcLocation " . "WHERE location_id = " . $this->location_id; $result_id = @pg_exec( $db_conn, $query ); $stuff = pg_fetch_array( $result_id, 0 ); $this->location = $stuff["location"]; $query = "SELECT name AS audience FROM srcAudience " . "WHERE audience_id IN ( "; for( $i=0; $i<count( $this->audience_id ); $i++ ) { $query .= ( $i ? "," : "" ) . $this->audience_id[$i]; } $query .= " )"; $result_id = pg_exec( $db_conn, $query ); $num_rows = pg_numrows( $result_id ); for( $i = 0; $i < $num_rows ; $i++ ) { $stuff = pg_fetch_array( $result_id, $i ); ( $i ? $this->audience .= ", " . $stuff["audience"] : $this->audience = $stuff["audience"] ); } $query = "SELECT name AS category FROM srcCategory " . "WHERE category_id IN ( "; for( $i=0; $i<count( $this->category_id ); $i++ ) { $query .= ( $i ? "," : "" ) . $this->category_id[$i]; } $query .= " )"; $result_id = pg_exec( $db_conn, $query ); $num_rows = pg_numrows( $result_id ); for( $i = 0; $i < $num_rows ; $i++ ) { $stuff = pg_fetch_array( $result_id, $i ); ( $i ? $this->category .= ", " . $stuff["category"] : $this->category = $stuff["category"] ); } // grab some information about the modified event if( $this->modify_id ) { $query = "SELECT title, submitter_id, submitted_time " . "FROM srcEvent WHERE event_id = " . $this->modify_id; $result_id = pg_exec( $db_conn, $query ); $stuff = pg_fetch_array( $result_id, 0 ); $this->modified_title = $stuff["title"]; $this->modified_submit_time = $stuff["submitted_time"]; exec( $GLOBALS["config_getuidinfo"] . " " . $stuff["submitter_id"], $dummy, $err_num ); $stuff = $dummy[0]; unset( $dummy ); if( !$err_num ) { $array = split( ":", $stuff ); $gecos = split( ",", $array[4] ); $this->modified_submitter = $gecos[0]; } }// the usernames aren't stored in the database (unless there's an active session) exec( $GLOBALS["config_getuidinfo"] . " " . $this->submitter_id, $dummy, $err_num ); $stuff = $dummy[0]; unset( $dummy ); if( !$err_num ) { $array = split( ":", $stuff ); $gecos = split( ",", $array[4] ); $this->submitter = $gecos[0]; } if( $this->approver_id ) { exec( $GLOBALS["config_getuidinfo"] . " " . $this->approver_id, $dummy, $err_num ); $stuff = $dummy[0]; unset( $dummy ); if( !$err_num ) { $array = split( ":", $stuff ); $gecos = split( ",", $array[4] ); $this->approver = $gecos[0]; } } unset( $this->weekday ); if( $this->weekday_id[0] != -1 ) { $query = "SELECT name AS weekday FROM srcWeekday " . "WHERE day IN ( "; for( $i=0; $i<count( $this->weekday_id ); $i++ ) { $query .= ( $i ? "," : "" ) . $this->weekday_id[$i]; } $query .= " )"; $result_id = pg_exec( $db_conn, $query ); $num_rows = pg_numrows( $result_id ); for( $i = 0; $i < $num_rows ; $i++ ) { $stuff = pg_fetch_array( $result_id, $i ); ( $i ? $this->weekday .= ", " . $stuff["weekday"] : $this->weekday = $stuff["weekday"] ); } } }// This function returns a string containing the details of an event,// suitable for including in e-mail messages function returnEventText() { $message = "\n\nTitle: $this->title\n" . "Description: $this->description\n" . "Location: $this->location\n" . "Audience: $this->audience\n" . "Category: $this->category\n" . "Submitted: " . date( "F j, h:i A", $this->submitted_time ) . "\n" . "Submitted by: " . $this->submitter . "\n" . "Starting: " . date( "F j, h:i A", $this->start_time ) . "\n"; if( $this->end_time ) { $message .= "Ending: " . date( "F j, h:i A", $this->end_time ) . "\n"; } if( $this->weekday ) { $message .= "On: $this->weekday\n"; } if( $this->info_url ) { $message .= "Info URL: $this->info_url\n"; } if( $this->info_email ) { $message .= "Info email: $this->info_email\n"; } if( $this->hide_oc ) { $message .= "*Hidden from off-campus browsers*\n"; } if( $this->modify_id ) { $message .= "This is a proposed modification to " . "the event titled \"" . $this->modified_title . "\" submitted by " . $this->modified_submitter . " on " . date( "F j, h:i A", $this->modified_submit_time ) . "\n"; } return $message; } function outputDetailView( $prev_link = 1 ) {// we want the names of things like location and audience, not just IDs echo( "<BIG>" . stripSlashes( $this->title ) . "</BIG><BR>\n" . "<B>Location:</B> $this->location <BR>\n" . "<B>When:</B> " . date( "F j, Y", $this->start_time ) . ( ($temp = date( ", h:i A", $this->start_time )) == ", 12:00 AM" ? "" : $temp ) ); if ( $this->end_time ) { echo( " - " ); if ( date( "F j, Y", $this->start_time ) != ($temp = date( "F j, Y", $this->end_time )) ) { echo( $temp ); if( ($temp = date( ", h:i A", $this->end_time)) != ", 12:00 AM") echo( $temp ); } else { echo( date( "h:i A", $this->end_time ) ); } } echo( "<BR>\n" ); if( $this->weekday ) { echo( "$this->weekday<BR>\n" ); } echo( "<P>" . stripSlashes( $this->description ) . "</P>\n" ); if( $this->info_email ) { echo( "<B>Contact E-Mail:</B>\n" . "<A HREF=\"mailto:" . $this->info_email . "\">" . $this->info_email . "</A><BR>\n" ); } if( $this->info_url ) { echo( "<B>Info URL:</B>\n" . "<A HREF=\"" . $this->info_url . "\">" . $this->info_url . "</A><BR>\n" ); } echo( "<B>Category:</B> " . $this->category . "<BR>\n" ); echo( "<B>Audience:</B> " . $this->audience . "<BR>\n" ); echo( "<B>Submitted:</B> " . date( "F j, Y, h:i A", $this->submitted_time ) . "<BR>\n"); echo( "<B>Submitted by:</B> " . $this->submitter . "<BR>\n" ); echo( "<B>Approved by:</B> " . ($this->approver ? $this->approver : "<STRONG>Not Yet Approved</STRONG>" ) . "<BR>\n" ); if( $this->hide_oc ) { echo( "<STRONG>Hidden from off-campus browsers</STRONG><BR>\n" ); } if( $this->modify_id ) {// FIXME - this is dependant on stuff outside the class echo( "This is a proposed modification to " . "the event titled "" . "<A HREF=\"?action=calendar&cal_view=detail" . "&event_id=" . $this->modify_id . "\">" . $this->modified_title . "</A>" submitted by " . $this->modified_submitter . " on " . date( "F j, h:i A", $this->modified_submit_time ) . "<BR>\n" ); } if( $prev_link ) {// FIXME - this is dependant on stuff outside the class// we're outputting links that load the appropriate boxes, provided the // current session has the ability to delete/approve/modify the event if( $this->verifyAction( "Delete" ) ) {echo( "<A HREF=\"?action=delete&form_action=delete_event&num_events=1" . "&delete_0=delete&event_0_id=" . $this->event_id . ( isSet( $GLOBALS["timestamp"] ) ? "&timestamp=" . $GLOBALS["timestamp"] : "" ) . "\">Delete</A><BR>" ); } if( !$this->approver_id && ( ( !$this->modify_id && $this->verifyAction( "Approve" ) ) || ( $this->modify_id && $this->verifyAction( "Modify" ) ) ) ) { echo( "<A HREF=\"?action=approve&form_action=approve_event&num_events=1" . "&approve_0=approve&event_0_id=" . $this->event_id . ( isSet( $GLOBALS["timestamp"] ) ? "&timestamp=" . $GLOBALS["timestamp"] : "" ) . "\">Approve</A><BR>" ); }// if( $this->verifyAction( "Modify" ) ) {echo( "<A HREF=\"?action=modify&form_action=output_form&" . "event_id=" . $this->event_id . ( isSet( $GLOBALS["timestamp"] ) ? "&timestamp=" . $GLOBALS["timestamp"] : "" ) . "\">Modify</A><BR>" );// }// a link to the referring page, so we don't lose search results $string = getEnv( "HTTP_REFERER" ); $string = ereg_replace( "&", "&", $string ); echo( "<A HREF=\"" . $string . "\">Previous page</A>" ); } }// this could possibly use some alternate layouts, but I just slapped this in here function outputTextOnly() { $temp_description = eregi_replace( "<.*>", "", $this->description ); echo( "<P><B>$this->title:</B> $temp_description - <I>$this->location" ); if( ($temp = date( "h:i A", $this->start_time )) != "12:00 AM" ) echo( ", $temp" ); if( $this->end_time ) { if( ($temp = date( "h:i A", $this->end_time )) != "12:00 AM" ) echo( " - $temp" ); } echo( "</I></P>\n" ); } function outputEditableEvent() {// here we output some form elements with the appropriate values// the actual form tags will be handled by the various components that call this if( !$my_conn = @connectROToCalendar() ) { $this->error = $php_errormsg; return; } if( $this->event_id ) { echo( "<INPUT TYPE=hidden NAME=\"event_id\" VALUE=\"" . $this->event_id . "\">\n" ); } ?> <B>Event Title:</B> <INPUT TYPE=text NAME="title"<?php if( $this->title ) echo " VALUE=\"" . ereg_replace( "\"", """, stripSlashes($this->title)) . "\""; ?>><BR> <B>Starting time:</B> <INPUT TYPE=text SIZE=2 MAXLENGTH=2 NAME="start_month" VALUE="<?php $temp_stamp = ( $this->start_time ? $this->start_time : mktime() ); echo( date( "m", $temp_stamp ) ); ?>"> / <INPUT TYPE=text SIZE=2 MAXLENGTH=2 NAME="start_date" VALUE="<?php echo( date( "j", $temp_stamp ) ); ?>"> / <INPUT TYPE=text SIZE=4 MAXLENGTH=4 NAME="start_year" VALUE="<?php echo( date( "Y", $temp_stamp ) ); ?>"> at <INPUT TYPE=text SIZE=2 MAXLENGTH=2 NAME="start_hour"<? if( $this->start_time ) { echo( "VALUE=\"" . date( "h", $this->start_time ) . "\"" ); } ?>> : <INPUT TYPE=text SIZE=2 MAXLENGTH=2 NAME="start_minute"<? if( $this->start_time ) { echo( "VALUE=\"" . date( "i", $this->start_time ) . "\"" ); } ?>> <INPUT TYPE=checkbox NAME="start_pm" VALUE="yup"<? if( $this->start_time && (date( "H", $this->start_time ) > 11) ) { echo( " CHECKED" ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -