calendar.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,905 行 · 第 1/5 页
PHP
1,905 行
$quicktime = trim( $this->ipsclass->input['qt'] ); $md5check = trim( $this->ipsclass->input['md5check'] ); list( $month, $day, $year ) = explode( "-", $quicktime ); //----------------------------------------- // Get permissions //----------------------------------------- $this->build_permissions( $cal_id ); //----------------------------------------- // Check //----------------------------------------- if ( ! $this->can_moderate ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } //----------------------------------------- // Check MD5 //----------------------------------------- if ( $md5check != $this->ipsclass->md5_check ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } //----------------------------------------- // Check Dates //----------------------------------------- if ( ! $day OR ! $month OR ! $year ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } //----------------------------------------- // Get Event //----------------------------------------- $event = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_calendar_id={$cal_id} and event_id={$event_id}" ) ); if ( ! $event['event_id'] ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } //----------------------------------------- // Update event... //----------------------------------------- $this->ipsclass->DB->do_update( 'cal_events', array( 'event_approved' => $event['event_approved'] ? 0 : 1 ), 'event_id='.$event_id ); //----------------------------------------- // Recache... //----------------------------------------- $this->_call_recache(); //----------------------------------------- // Boink... //----------------------------------------- $this->ipsclass->boink_it( $this->ipsclass->base_url."act=calendar&cal_id={$cal_id}&modfilter={$modfilter}&code=showday&y={$year}&m={$month}&d={$day}"); } /*-------------------------------------------------------------------------*/ // Build Permissions /*-------------------------------------------------------------------------*/ function build_permissions( $cal_id=0 ) { $this->can_read = 0; $this->can_post = 0; $this->can_avoid_queue = 0; $this->can_moderate = 0; //----------------------------------------- // Got an idea? //----------------------------------------- if ( ! $cal_id ) { $cal_id = $this->calendar_id; } $calendar = $this->calendar_cache[ $cal_id ]; //----------------------------------------- // Read //----------------------------------------- if ( $this->ipsclass->check_perms( $calendar['perm_read'] ) == TRUE ) { $this->can_read = 1; } //----------------------------------------- // Post //----------------------------------------- if ( $this->ipsclass->check_perms( $calendar['perm_post'] ) == TRUE ) { $this->can_post = 1; } //----------------------------------------- // Mod Queue //----------------------------------------- if ( $this->ipsclass->check_perms( $calendar['perm_nomod'] ) == TRUE ) { $this->can_avoid_queue = 1; } //----------------------------------------- // Moderate //----------------------------------------- if ( $this->ipsclass->member['g_is_supmod'] ) { $this->can_moderate = 1; } } /*-------------------------------------------------------------------------*/ // Find /*-------------------------------------------------------------------------*/ function find_date() { if ( $this->ipsclass->input['what'] ) { if ( $this->ipsclass->input['what'] == 'thismonth' ) { $this->ipsclass->boink_it( $this->ipsclass->base_url."act=calendar&cal_id={$this->calendar_id}&m={$this->now_date['mon']}&y={$this->now_date['year']}" ); } else { $time = time() + $this->ipsclass->get_time_offset(); $this->ipsclass->boink_it( $this->ipsclass->base_url."act=calendar&cal_id={$this->calendar_id}&code=showweek&week={$time}" ); } } else { $this->show_month(); } } /*-------------------------------------------------------------------------*/ // Show WEEK /*-------------------------------------------------------------------------*/ function show_week() { $in_week = intval($this->ipsclass->input['week']); //----------------------------------------- // Get start of week //----------------------------------------- $startweek = $this->ipsclass->date_getgmdate( $in_week ); //----------------------------------------- // Not Sunday? Go back.. //----------------------------------------- $startweek['wday'] = intval($startweek['wday']); if ( $startweek['wday'] > 0 ) { while ( $startweek['wday'] != 0 ) { $startweek['wday']--; $in_week -= 86400; } $startweek = $this->ipsclass->date_getgmdate( $in_week ); } //----------------------------------------- // Get end of week //----------------------------------------- $endweek = $this->ipsclass->date_getgmdate( $in_week + 604800 ); $our_datestamp = gmmktime( 0,0,0, $startweek['mon'], $startweek['mday'], $startweek['year']); $our_timestamp = $in_week; $seen_days = array(); // Holds yday $seen_ids = array(); //----------------------------------------- // Figure out the next / previous links //----------------------------------------- $prev_month = $this->get_prev_month($this->chosen_month, $this->chosen_year); $next_month = $this->get_next_month($this->chosen_month, $this->chosen_year); $prev_week = $this->ipsclass->date_getgmdate( $in_week - 604800 ); $next_week = $this->ipsclass->date_getgmdate( $in_week + 604800 ); $this->output .= $this->ipsclass->compiled_templates['skin_calendar']->cal_week_content( $startweek['mday'], $this->month_words[$startweek['mon'] - 1], $startweek['year'], $prev_week, $next_week); $last_month_id = -1; //----------------------------------------- // Get the events //----------------------------------------- $this->get_events_sql($startweek['mon'], $startweek['year']); //----------------------------------------- // Print each effing day :D //----------------------------------------- for ( $i = 0 ; $i <= 6 ; $i++ ) { $year = gmdate('Y', $our_datestamp); $month = gmdate('n', $our_datestamp); $day = gmdate('j', $our_datestamp); $today = $this->ipsclass->date_getgmdate($our_datestamp); if ( $last_month_id != $today['mon'] ) { $last_month_id = $today['mon']; $cal_output .= $this->ipsclass->compiled_templates['skin_calendar']->cal_week_monthbar( $this->month_words[$today['mon'] - 1], $today['year'] ); //----------------------------------------- // Get the birthdays from the database //----------------------------------------- if ( $this->ipsclass->vars['show_bday_calendar'] ) { $birthdays = array(); $this->get_birthday_sql($today['mon']); $birthdays = $this->query_bday_cache[ $today['mon'] ]; } //----------------------------------------- // Get the events //----------------------------------------- $this->get_events_sql($month, $year); } $events = $this->get_day_events( $month, $day, $year ); $queued_event = 0; if ( is_array( $events ) AND count( $events ) ) { foreach( $events as $idx => $event ) { if ( ! $this->shown_events[ $month.'-'.$day.'-'.$year ][ $event['event_id'] ] ) { //----------------------------------------- // Recurring //----------------------------------------- if ( $event['recurring'] ) { $this_day_events .= $this->ipsclass->compiled_templates['skin_calendar']->cal_events_wrap_recurring( $event ); } else if ( $event['single'] ) { $this_day_events .= $this->ipsclass->compiled_templates['skin_calendar']->cal_events_wrap( $event ); } else { $this_day_events .= $this->ipsclass->compiled_templates['skin_calendar']->cal_events_wrap_range( $event ); } $this->shown_events[ $month.'-'.$day.'-'.$year ][ $event['event_id'] ] = 1; } //----------------------------------------- // Queued events? //----------------------------------------- if ( ! $event['event_approved'] AND $this->can_moderate ) { $queued_event = 1; } } } //----------------------------------------- // Birthdays //----------------------------------------- if ( $this->calendar['cal_bday_limit'] ) { if ( isset($birthdays[ $today['mday'] ]) and count( $birthdays[ $today['mday'] ] ) > 0 ) { $no_bdays = count($birthdays[ $today['mday'] ]); if ( $this->calendar['cal_bday_limit'] and $no_bdays <= $this->calendar['cal_bday_limit'] ) { foreach( $birthdays[ $today['mday'] ] as $idx => $user ) { $this_day_events .= $this->ipsclass->compiled_templates['skin_calendar']->cal_week_events_wrap( "code=birthdays&y=".$today['year']."&m=".$today['mon']."&d=".$today['mday'], $user['members_display_name'].$this->ipsclass->lang['bd_birthday'] ); } } else { $this_day_events .= $this->ipsclass->compiled_templates['skin_calendar']->cal_week_events_wrap( "code=birthdays&y=".$today['year']."&m=".$today['mon']."&d=".$today['mday'], sprintf( $this->ipsclass->lang['entry_birthdays'], count($birthdays[ $today['mday'] ]) ) ); } } } if ($this_day_events == "") { $this_day_events = ' '; } $cal_output .= $this->ipsclass->compiled_templates['skin_calendar']->cal_week_dayentry( $this->day_words[ $today['wday'] ], $today['mday'], $this->month_words[$today['mon'] - 1], $today['mon'], $today['year'], $this_day_events, $queued_event ); $our_datestamp += 86400; unset($this_day_events); } //----------------------------------------- // Switch the HTML tags... //----------------------------------------- $this->output = str_replace( "<!--IBF.DAYS_CONTENT-->" , $cal_output, $this->output ); $this->output = str_replace( "<!--IBF.MONTH_BOX-->" , $this->get_month_dropdown(), $this->output ); $this->output = str_replace( "<!--IBF.YEAR_BOX-->" , $this->get_year_dropdown() , $this->output ); //----------------------------------------- // Get prev / this / next calendars //----------------------------------------- $this->output = str_replace( "<!--PREV.MONTH-->", $this->get_mini_calendar( $prev_month['month_id'], $prev_month['year_id'] ), $this->output ); $this->output = str_replace( "<!--THIS.MONTH-->", $this->get_mini_calendar( $this->chosen_month , $this->chosen_year ), $this->output ); $this->output = str_replace( "<!--NEXT.MONTH-->", $this->get_mini_calendar( $next_month['month_id'], $next_month['year_id'] ), $this->output ); $this->nav[] = "<a href='{$this->ipsclass->base_url}act=calendar'>{$this->ipsclass->lang['page_title']}</a>"; $this->nav[] = $this->month_words[$this->chosen_month - 1]." ".$this->chosen_year; } /*-------------------------------------------------------------------------*/ // SHOW MONTH /*-------------------------------------------------------------------------*/ function show_month() { //----------------------------------------- // Figure out the next / previous links //----------------------------------------- $prev_month = $this->get_prev_month($this->chosen_month, $this->chosen_year); $next_month = $this->get_next_month($this->chosen_month, $this->chosen_year); $this->output .= $this->ipsclass->compiled_templates['skin_calendar']->cal_main_content($this->month_words[$this->chosen_month - 1], $this->chosen_year, $prev_month, $next_month, $this->calendar_jump, $this->calendar_id); //----------------------------------------- // Print the days table top row //----------------------------------------- $day_output = ""; $cal_output = ""; foreach ($this->day_words as $day) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?