| [ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/calendar_menu/ecal_class.php,v $ 14 | $Revision: 1.2 $ 15 | $Date: 2006/11/16 10:24:14 $ 16 | $Author: e107coders $ 17 | 18 | Event calendar class for gradual enhancement 19 | (Some bits may be usefully transferred to common code later) 20 | 21 | 11.11.06 - Add date formatting options 22 | - Add notify 23 | 24 +----------------------------------------------------------------------------+ 25 */ 26 27 /* 28 Preferences used: 29 eventpost_caltime 1 = server, 2 = site, 3 = user 30 eventpost_timedisplay 1 = 24 hour, 2 = 12 hour default, 3 = custom 31 eventpost_timecustom String for custom time display 32 33 date() returns formatted date/time string 34 */ 35 class ecal_class 36 { 37 // Useful time/date variables - set up on creation, and available externally 38 // (All the times and dates are consistent, being derived from $time_now, which is the time the constructor was 39 // called - probably doesn't matter, but may help someone. 40 var $time_now; // Current time/date stamp 41 var $site_timedate; // Site time/date stamp - adjusted for time zone 42 var $user_timedate; // Time/date based on user's time zone 43 var $cal_timedate; // Time/date stamp used by event calendar (user set) 44 var $now_date; // Time/date array from $time_now 45 var $site_date; // Time/date array from $site_timedate 46 var $cal_date ; // Time/date array from $cal_timedate 47 48 var $cal_super; // True if current user is a calendar supervisor 49 var $extra_query; // Extra bit of mysql query used for non-supervisor (read) queries 50 51 var $time_format_string; // String to format times on the site 52 var $cal_format_string; // String to format the displayed date on event entry ("Y-m-d" or "d-m-Y") 53 var $dcal_format_string; // Format string to pass to DHTML calendar 54 var $java_format_code; // Code to pass to Javascript re date format 55 56 var $event_date_format_string; // String to format the date in the event calendar 57 var $next_date_format_string; // String to format the date in the 'forthcoming event' menu 58 59 var $max_cache_time; // Oldest permissible age of any cached pages relating to event calendar 60 var $max_recent_show; // Time in seconds for showing 'recent events' 61 62 function ecal_class() 63 { // Constructor 64 global $pref; 65 66 $this->time_now = time(); 67 $this->site_timedate = $this->time_now + ($pref['time_offset'] * 3600); // Check sign of offset 68 $this->user_timedate = $this->time_now + TIMEOFFSET; 69 switch ($pref['eventpost_caltime']) 70 { 71 case 1 : 72 $this->cal_timedate = $this->site_timedate; // Site time 73 break; 74 case 2 : 75 $this->cal_timedate = $this->user_timedate; // User 76 break; 77 default : 78 $this->cal_timedate = $this->time_now; // Server time - default 79 } 80 $this->now_date = getdate($this->time_now); 81 $this->site_date = getdate($this->site_timedate); // Array with h,m,s, day, month year etc 82 $this->cal_date = getdate($this->cal_timedate); 83 84 $this->max_cache_time = $this->site_date['minutes'] + 60*$this->site_date['hours']; 85 86 $this->cal_super = check_class($pref['eventpost_super']); 87 if ($this->cal_super) $this->extra_query = ""; else $this->extra_query = " AND find_in_set(event_cat_class,'".USERCLASS_LIST."')"; 88 89 if (isset($pref['eventpost_recentshow']) && ($pref['eventpost_recentshow'] != 0)) 90 { 91 $this->max_recent_show = 3600 * $pref['eventpost_recentshow']; 92 } 93 else 94 { 95 $this->max_recent_show = 0; 96 } 97 switch ($pref['eventpost_timedisplay']) 98 { 99 case 2 : 100 $this->time_format_string = "%I:%M %p"; // 12-hour display 101 break; 102 case 3 : 103 $this->time_format_string = $pref['eventpost_timecustom']; // custom display 104 if (isset($this->time_format_string)) break; 105 default : 106 $this->time_format_string = "%H%M"; // default to 24-hour display 107 } 108 109 switch ($pref['eventpost_datedisplay']) 110 { // Event entry calendar 111 case 2 : 112 $this->cal_format_string = "d-m-Y"; 113 $this->dcal_format_string = "%d-%m-%Y"; 114 $this->java_format_code = 2; 115 break; 116 case 3 : 117 $this->cal_format_string = "m-d-Y"; 118 $this->dcal_format_string = "%m-%d-%Y"; 119 $this->java_format_code = 3; 120 break; 121 default : // 'original' defaults 122 $this->cal_format_string = "Y-m-d"; 123 $this->dcal_format_string = "%Y-%m-%d"; 124 $this->java_format_code = 1; 125 } 126 127 switch ($pref['eventpost_dateevent']) 128 { // Event list date display 129 case 0 : 130 $this->event_date_format_string = $pref['eventpost_eventdatecustom']; 131 break; 132 case 2 : 133 $this->event_date_format_string = "%a %d %b %Y"; 134 break; 135 case 3 : 136 $this->event_date_format_string = "%a %d-%m-%y"; 137 break; 138 default : 139 $this->event_date_format_string = "%A %d %B %Y"; 140 } 141 142 switch ($pref['eventpost_datenext']) 143 { // Forthcoming event date display 144 case 0 : 145 $this->next_date_format_string = $pref['eventpost_nextdatecustom']; 146 break; 147 case 2 : 148 $this->next_date_format_string = "%d %b"; 149 break; 150 case 3 : 151 $this->next_date_format_string = "%B %d"; 152 break; 153 case 4 : 154 $this->next_date_format_string = "%b %d"; 155 break; 156 default : 157 $this->next_date_format_string = "%d %B"; 158 } 159 } 160 161 function time_string($convtime) 162 { // Returns a time string from a time stamp, formatted as 24-hour, 12-hour or custom as set in prefs 163 return strftime($this->time_format_string, $convtime); 164 } 165 166 function event_date_string($convdate) 167 { // Returns a date string from a date stamp, formatted for display in event list 168 return strftime($this->event_date_format_string,$convdate); 169 } 170 171 172 function next_date_string($convdate) 173 { // Returns a date string from a date stamp, formatted for display in forthcoming event menu 174 return strftime($this->next_date_format_string,$convdate); 175 } 176 177 178 function full_date($convdate) 179 { // Returns a date as dd-mm-yyyy or yyyy-mm-dd according to prefs (for event entry) 180 return date($this->cal_format_string, $convdate); 181 } 182 183 function make_date($new_hour, $new_minute, $date_string) 184 { // Turns a date as entered in the calendar into a time stamp (for event entry) 185 global $pref; 186 $tmp = explode("-", $date_string); 187 switch ($pref['eventpost_datedisplay']) 188 { 189 case 2 : 190 return mktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy 191 case 3 : 192 return mktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy 193 default : 194 return mktime($new_hour, $new_minute, 0, $tmp[1], $tmp[2], $tmp[0]); // yyyy-mm-dd 195 } 196 } 197 198 function cal_log($event_type, $event_title = '', $event_string='', $event_start=0) 199 { // All calendar-related logging intentionally passed through a single point to maintain control 200 // (so we could also add other info if we wanted) 201 // Event types: 202 // 1 - add event 203 // 2 - edit event 204 // 3 - delete event 205 // 4 - Bulk delete 206 global $pref, $admin_log, $e_event; 207 208 $log_titles = array( '1' => 'Event Calendar - add event', 209 '2' => 'Event Calendar - edit event', 210 '3' => 'Event Calendar - delete event', 211 '4' => 'Event Calendar - Bulk Delete' 212 ); 213 // Do the notifies first 214 $cmessage = $log_titles[$event_type]."<br />"; 215 if ($event_start > 0) 216 $cmessage .= "Event Start: ".strftime("%d-%B-%Y",$event_start)."<br />"; 217 else 218 $cmessage .= "Event Start unknown<br />"; 219 $edata_ec = array("cmessage" => $cmessage, "ip" => getip()); 220 switch ($event_type) 221 { 222 case 1 : $e_event -> trigger("ecalnew", $edata_ec); 223 break; 224 case 2 : 225 case 3 : 226 case 4 : $e_event -> trigger("ecaledit", $edata_ec); 227 break; 228 } 229 230 switch ($pref['eventpost_adminlog']) 231 { 232 case 1 : if ($event_type == '1') return; 233 case 2 : break; // Continue 234 default : return; // Invalid or undefined option 235 } 236 $log_titles = array( '1' => 'Event Calendar - add event', 237 '2' => 'Event Calendar - edit event', 238 '3' => 'Event Calendar - delete event', 239 '4' => 'Event Calendar - Bulk Delete' 240 ); 241 $admin_log->log_event($log_titles[$event_type],$event_title." \n".$event_string,4); 242 } 243 } 244 245 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |