/wp-content/plugins/calendar/calendar.php
PHP | 1268 lines | 1102 code | 70 blank | 96 comment | 212 complexity | 97eab6853c6f6da6caa8372e2f84d7bf MD5 | raw file
- <?php
- /*
- Plugin Name: Calendar
- Plugin URI: http://www.kieranoshea.com
- Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
- Author: Kieran O'Shea
- Author URI: http://www.kieranoshea.com
- Version: 1.2.2
- */
- /* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- // Enable internationalisation
- $plugin_dir = basename(dirname(__FILE__));
- load_plugin_textdomain( 'calendar','wp-content/plugins/'.$plugin_dir, $plugin_dir);
- // Define the tables used in Calendar
- define('WP_CALENDAR_TABLE', $table_prefix . 'calendar');
- define('WP_CALENDAR_CONFIG_TABLE', $table_prefix . 'calendar_config');
- define('WP_CALENDAR_CATEGORIES_TABLE', $table_prefix . 'calendar_categories');
- // Check ensure calendar is installed and install it if not - required for
- // the successful operation of most functions called from this point on
- check_calendar();
- // Create a master category for Calendar and its sub-pages
- add_action('admin_menu', 'calendar_menu');
- // Enable the ability for the calendar to be loaded from pages
- add_filter('the_content','calendar_insert');
- // Enable the ability for the lists to be loaded from pages
- add_filter('the_content','upcoming_insert');
- add_filter('the_content','todays_insert');
- // Add the function that puts style information in the header
- add_action('wp_head', 'calendar_wp_head');
- // Add the function that deals with deleted users
- add_action('delete_user', 'deal_with_deleted_user');
- // Add the widgets if we are using version 2.8
- add_action('widgets_init', 'widget_init_calendar_today');
- add_action('widgets_init', 'widget_init_calendar_upcoming');
- // Before we get on with the functions, we need to define the initial style used for Calendar
- // Function to deal with events posted by a user when that user is deleted
- function deal_with_deleted_user($id)
- {
- global $wpdb;
- // Do the query
- $wpdb->get_results("UPDATE ".WP_CALENDAR_TABLE." SET event_author=".$wpdb->get_var("SELECT MIN(ID) FROM ".$wpdb->prefix."users",0,0)." WHERE event_author=".$id);
- }
- // Function to provide time with WordPress offset, localy replaces time()
- function ctwo()
- {
- return (time()+(3600*(get_option('gmt_offset'))));
- }
- // Function to add the calendar style into the header
- function calendar_wp_head()
- {
- global $wpdb;
- $styles = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='calendar_style'");
- if (!empty($styles))
- {
- foreach ($styles as $style)
- {
- echo '<style type="text/css">
- ';
- echo $style->config_value.'
- ';
- echo '</style>
- ';
- }
- }
- }
- // Function to deal with adding the calendar menus
- function calendar_menu()
- {
- global $wpdb;
- // Set admin as the only one who can use Calendar for security
- $allowed_group = 'manage_options';
- // Use the database to *potentially* override the above if allowed
- $configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='can_manage_events'");
- if (!empty($configs))
- {
- foreach ($configs as $config)
- {
- $allowed_group = $config->config_value;
- }
- }
- // Add the admin panel pages for Calendar. Use permissions pulled from above
- if (function_exists('add_menu_page'))
- {
- add_menu_page(__('Calendar','calendar'), __('Calendar','calendar'), $allowed_group, 'calendar', 'edit_calendar');
- }
- if (function_exists('add_submenu_page'))
- {
- add_submenu_page('calendar', __('Manage Calendar','calendar'), __('Manage Calendar','calendar'), $allowed_group, 'calendar', 'edit_calendar');
- add_action( "admin_head", 'calendar_add_javascript' );
- // Note only admin can change calendar options
- add_submenu_page('calendar', __('Manage Categories','calendar'), __('Manage Categories','calendar'), 'manage_options', 'calendar-categories', 'manage_categories');
- add_submenu_page('calendar', __('Calendar Config','calendar'), __('Calendar Options','calendar'), 'manage_options', 'calendar-config', 'edit_calendar_config');
- }
- }
- // Function to add the javascript to the admin header
- function calendar_add_javascript()
- {
- echo '<script type="text/javascript" src="';
- bloginfo('wpurl');
- echo '/wp-content/plugins/calendar/javascript.js"></script>
- <script type="text/javascript">document.write(getCalendarStyles());</script>
- ';
- }
- // Function to deal with loading the calendar into pages
- function calendar_insert($content)
- {
- if (preg_match('{CALENDAR}',$content))
- {
- $cal_output = calendar();
- $content = str_replace('{CALENDAR}',$cal_output,$content);
- }
- return $content;
- }
- // Functions to allow the widgets to be inserted into posts and pages
- function upcoming_insert($content)
- {
- if (preg_match('{UPCOMING_EVENTS}',$content))
- {
- $cal_output = '<span class="page-upcoming-events">'.upcoming_events().'</span>';
- $content = str_replace('{UPCOMING_EVENTS}',$cal_output,$content);
- }
- return $content;
- }
- function todays_insert($content)
- {
- if (preg_match('{TODAYS_EVENTS}',$content))
- {
- $cal_output = '<span class="page-todays-events">'.todays_events().'</span>';
- $content = str_replace('{TODAYS_EVENTS}',$cal_output,$content);
- }
- return $content;
- }
- // Function to check what version of Calendar is installed and install if needed
- function check_calendar()
- {
- // Checks to make sure Calendar is installed, if not it adds the default
- // database tables and populates them with test data. If it is, then the
- // version is checked through various means and if it is not up to date
- // then it is upgraded.
- // Lets see if this is first run and create us a table if it is!
- global $wpdb, $initial_style;
- // All this style info will go into the database on a new install
- // This looks nice in the Kubrick theme
- $initial_style = " .calnk a:hover {
- background-position:0 0;
- text-decoration:none;
- color:#000000;
- border-bottom:1px dotted #000000;
- }
- .calnk a:visited {
- text-decoration:none;
- color:#000000;
- border-bottom:1px dotted #000000;
- }
- .calnk a {
- text-decoration:none;
- color:#000000;
- border-bottom:1px dotted #000000;
- }
- .calnk a span {
- display:none;
- }
- .calnk a:hover span {
- color:#333333;
- background:#F6F79B;
- display:block;
- position:absolute;
- margin-top:1px;
- padding:5px;
- width:150px;
- z-index:100;
- line-height:1.2em;
- }
- .calendar-table {
- border:none;
- width:100%;
- }
- .calendar-heading {
- height:25px;
- text-align:center;
- border:1px solid #D6DED5;
- background-color:#E4EBE3;
- }
- .calendar-next {
- width:25%;
- text-align:center;
- }
- .calendar-prev {
- width:25%;
- text-align:center;
- }
- .calendar-month {
- width:50%;
- text-align:center;
- font-weight:bold;
- }
- .normal-day-heading {
- text-align:center;
- width:25px;
- height:25px;
- font-size:0.8em;
- border:1px solid #DFE6DE;
- background-color:#EBF2EA;
- }
- .weekend-heading {
- text-align:center;
- width:25px;
- height:25px;
- font-size:0.8em;
- border:1px solid #DFE6DE;
- background-color:#EBF2EA;
- color:#FF0000;
- }
- .day-with-date {
- vertical-align:text-top;
- text-align:left;
- width:60px;
- height:60px;
- border:1px solid #DFE6DE;
- }
- .no-events {
- }
- .day-without-date {
- width:60px;
- height:60px;
- border:1px solid #E9F0E8;
- }
- span.weekend {
- color:#FF0000;
- }
- .current-day {
- vertical-align:text-top;
- text-align:left;
- width:60px;
- height:60px;
- border:1px solid #BFBFBF;
- background-color:#E4EBE3;
- }
- span.event {
- font-size:0.75em;
- }
- .kjo-link {
- font-size:0.75em;
- text-align:center;
- }
- .calendar-date-switcher {
- height:25px;
- text-align:center;
- border:1px solid #D6DED5;
- background-color:#E4EBE3;
- }
- .calendar-date-switcher form {
- margin:0;
- padding:0;
- }
- .calendar-date-switcher input {
- border:1px #D6DED5 solid;
- }
- .calendar-date-switcher select {
- border:1px #D6DED5 solid;
- }
- .cat-key {
- width:100%;
- margin-top:10px;
- padding:5px;
- border:1px solid #D6DED5;
- }
- .calnk a:hover span span.event-title {
- padding:0;
- text-align:center;
- font-weight:bold;
- font-size:1.2em;
- }
- .calnk a:hover span span.event-title-break {
- width:96%;
- text-align:center;
- height:1px;
- margin-top:5px;
- margin-right:2%;
- padding:0;
- background-color:#000000;
- }
- .calnk a:hover span span.event-content-break {
- width:96%;
- text-align:center;
- height:1px;
- margin-top:5px;
- margin-right:2%;
- padding:0;
- background-color:#000000;
- }
- .page-upcoming-events {
- font-size:80%;
- }
- .page-todays-events {
- font-size:80%;
- }";
-
- // Assume this is not a new install until we prove otherwise
- $new_install = false;
- $vone_point_one_upgrade = false;
- $vone_point_two_beta_upgrade = false;
- $wp_calendar_exists = false;
- $wp_calendar_config_exists = false;
- $wp_calendar_config_version_number_exists = false;
- // Determine the calendar version
- $tables = $wpdb->get_results("show tables");
- foreach ( $tables as $table )
- {
- foreach ( $table as $value )
- {
- if ( $value == WP_CALENDAR_TABLE )
- {
- $wp_calendar_exists = true;
- }
- if ( $value == WP_CALENDAR_CONFIG_TABLE )
- {
- $wp_calendar_config_exists = true;
-
- // We now try and find the calendar version number
- // This will be a lot easier than finding other stuff
- // in the future.
- $version_number = $wpdb->get_var("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='calendar_version'");
- if ($version_number == "1.2")
- {
- $wp_calendar_config_version_number_exists = true;
- }
- }
- }
- }
- if ($wp_calendar_exists == false && $wp_calendar_config_exists == false)
- {
- $new_install = true;
- }
- else if ($wp_calendar_exists == true && $wp_calendar_config_exists == false)
- {
- $vone_point_one_upgrade = true;
- }
- else if ($wp_calendar_exists == true && $wp_calendar_config_exists == true && $wp_calendar_config_version_number_exists == false)
- {
- $vone_point_two_beta_upgrade = true;
- }
- // Now we've determined what the current install is or isn't
- // we perform operations according to the findings
- if ( $new_install == true )
- {
- $sql = "CREATE TABLE " . WP_CALENDAR_TABLE . " (
- event_id INT(11) NOT NULL AUTO_INCREMENT ,
- event_begin DATE NOT NULL ,
- event_end DATE NOT NULL ,
- event_title VARCHAR(30) NOT NULL ,
- event_desc TEXT NOT NULL ,
- event_time TIME ,
- event_recur CHAR(1) ,
- event_repeats INT(3) ,
- event_author BIGINT(20) UNSIGNED,
- PRIMARY KEY (event_id)
- )";
- $wpdb->get_results($sql);
- $sql = "CREATE TABLE " . WP_CALENDAR_CONFIG_TABLE . " (
- config_item VARCHAR(30) NOT NULL ,
- config_value TEXT NOT NULL ,
- PRIMARY KEY (config_item)
- )";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='can_manage_events', config_value='edit_posts'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_style', config_value='".$initial_style."'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_author', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_jump', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_todays', config_value='true'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming', config_value='true'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming_days', config_value=7";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT DEFAULT ''";
- $wpdb->get_results($sql);
- $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
- category_id INT(11) NOT NULL AUTO_INCREMENT,
- category_name VARCHAR(30) NOT NULL ,
- category_colour VARCHAR(30) NOT NULL ,
- PRIMARY KEY (category_id)
- )";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_id=1, category_name='General', category_colour='#F6F79B'";
- $wpdb->get_results($sql);
- }
- else if ($vone_point_one_upgrade == true)
- {
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_author BIGINT(20) UNSIGNED";
- $wpdb->get_results($sql);
- $sql = "UPDATE ".WP_CALENDAR_TABLE." SET event_author=".$wpdb->get_var("SELECT MIN(ID) FROM ".$wpdb->prefix."users",0,0);
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." MODIFY event_desc TEXT NOT NULL";
- $wpdb->get_results($sql);
- $sql = "CREATE TABLE " . WP_CALENDAR_CONFIG_TABLE . " (
- config_item VARCHAR(30) NOT NULL ,
- config_value TEXT NOT NULL ,
- PRIMARY KEY (config_item)
- )";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='can_manage_events', config_value='edit_posts'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_style', config_value='".$initial_style."'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_author', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_jump', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_todays', config_value='true'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming', config_value='true'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming_days', config_value=7";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT DEFAULT ''";
- $wpdb->get_results($sql);
- $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
- category_id INT(11) NOT NULL AUTO_INCREMENT,
- category_name VARCHAR(30) NOT NULL ,
- category_colour VARCHAR(30) NOT NULL ,
- PRIMARY KEY (category_id)
- )";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_id=1, category_name='General', category_colour='#F6F79B'";
- $wpdb->get_results($sql);
- }
- else if ($vone_point_two_beta_upgrade == true)
- {
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
- $wpdb->get_results($sql);
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT DEFAULT ''";
- $wpdb->get_results($sql);
- $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
- category_id INT(11) NOT NULL AUTO_INCREMENT,
- category_name VARCHAR(30) NOT NULL ,
- category_colour VARCHAR(30) NOT NULL ,
- PRIMARY KEY (category_id)
- )";
- $wpdb->get_results($sql);
- $sql = "INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_id=1, category_name='General', category_colour='#F6F79B'";
- $wpdb->get_results($sql);
- $sql = "UPDATE " . WP_CALENDAR_CONFIG_TABLE . " SET config_value='".$initial_style."' WHERE config_item='calendar_style'";
- $wpdb->get_results($sql);
- }
- }
- // Used on the manage events admin page to display a list of events
- function wp_events_display_list()
- {
- global $wpdb;
-
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " ORDER BY event_begin DESC");
-
- if ( !empty($events) )
- {
- ?>
- <table class="widefat page fixed" width="100%" cellpadding="3" cellspacing="3">
- <thead>
- <tr>
- <th class="manage-column" scope="col"><?php _e('ID','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Title','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Start Date','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('End Date','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Time','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Recurs','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Repeats','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Author','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Category','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Edit','calendar') ?></th>
- <th class="manage-column" scope="col"><?php _e('Delete','calendar') ?></th>
- </tr>
- </thead>
- <?php
- $class = '';
- foreach ( $events as $event )
- {
- $class = ($class == 'alternate') ? '' : 'alternate';
- ?>
- <tr class="<?php echo $class; ?>">
- <th scope="row"><?php echo $event->event_id; ?></th>
- <td><?php echo $event->event_title; ?></td>
- <td><?php echo $event->event_begin; ?></td>
- <td><?php echo $event->event_end; ?></td>
- <td><?php if ($event->event_time == '00:00:00') { echo __('N/A','calendar'); } else { echo $event->event_time; } ?></td>
- <td>
- <?php
- // Interpret the DB values into something human readable
- if ($event->event_recur == 'S') { echo __('Never','calendar'); }
- else if ($event->event_recur == 'W') { echo __('Weekly','calendar'); }
- else if ($event->event_recur == 'M') { echo __('Monthly','calendar'); }
- else if ($event->event_recur == 'Y') { echo __('Yearly','calendar'); }
- ?>
- </td>
- <td>
- <?php
- // Interpret the DB values into something human readable
- if ($event->event_recur == 'S') { echo __('N/A','calendar'); }
- else if ($event->event_repeats == 0) { echo __('Forever','calendar'); }
- else if ($event->event_repeats > 0) { echo $event->event_repeats.' '.__('Times','calendar'); }
- ?>
- </td>
- <td><?php $e = get_userdata($event->event_author); echo $e->display_name; ?></td>
- <?php
- $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
- $this_cat = $wpdb->get_row($sql);
- ?>
- <td style="background-color:<?php echo $this_cat->category_colour;?>;"><?php echo $this_cat->category_name; ?></td>
- <?php unset($this_cat); ?>
- <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar&action=edit&event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
- <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar&action=delete&event_id=<?php echo $event->event_id;?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this event?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
- </tr>
- <?php
- }
- ?>
- </table>
- <?php
- }
- else
- {
- ?>
- <p><?php _e("There are no events in the database!",'calendar') ?></p>
- <?php
- }
- }
- // The event edit form for the manage events admin page
- function wp_events_edit_form($mode='add', $event_id=false)
- {
- global $wpdb,$users_entries;
- $data = false;
-
- if ( $event_id !== false )
- {
- if ( intval($event_id) != $event_id )
- {
- echo "<div class=\"error\"><p>".__('Bad Monkey! No banana!','calendar')."</p></div>";
- return;
- }
- else
- {
- $data = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_id='" . mysql_escape_string($event_id) . "' LIMIT 1");
- if ( empty($data) )
- {
- echo "<div class=\"error\"><p>".__("An event with that ID couldn't be found",'calendar')."</p></div>";
- return;
- }
- $data = $data[0];
- }
- // Recover users entries if they exist; in other words if editing an event went wrong
- if (!empty($users_entries))
- {
- $data = $users_entries;
- }
- }
- // Deal with possibility that form was submitted but not saved due to error - recover user's entries here
- else
- {
- $data = $users_entries;
- }
-
- ?>
- <div id="pop_up_cal" style="position:absolute;margin-left:150px;visibility:hidden;background-color:white;layer-background-color:white;z-index:1;"></div>
- <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar">
- <input type="hidden" name="action" value="<?php echo $mode; ?>">
- <input type="hidden" name="event_id" value="<?php echo $event_id; ?>">
-
- <div id="linkadvanceddiv" class="postbox">
- <div style="float: left; width: 98%; clear: both;" class="inside">
- <table cellpadding="5" cellspacing="5">
- <tr>
- <td><legend><?php _e('Event Title','calendar'); ?></legend></td>
- <td><input type="text" name="event_title" class="input" size="40" maxlength="30"
- value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_title); ?>" /></td>
- </tr>
- <tr>
- <td style="vertical-align:top;"><legend><?php _e('Event Description','calendar'); ?></legend></td>
- <td><textarea name="event_desc" class="input" rows="5" cols="50"><?php if ( !empty($data) ) echo htmlspecialchars($data->event_desc); ?></textarea></td>
- </tr>
- <tr>
- <td><legend><?php _e('Event Category','calendar'); ?></legend></td>
- <td> <select name="event_category">
- <?php
- // Grab all the categories and list them
- $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE;
- $cats = $wpdb->get_results($sql);
- foreach($cats as $cat)
- {
- echo '<option value="'.$cat->category_id.'"';
- if (!empty($data))
- {
- if ($data->event_category == $cat->category_id)
- {
- echo 'selected="selected"';
- }
- }
- echo '>'.$cat->category_name.'</option>
- ';
- }
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td><legend><?php _e('Event Link (Optional)','calendar'); ?></legend></td>
- <td><input type="text" name="event_link" class="input" size="40" value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_link); ?>" /></td>
- </tr>
- <tr>
- <td><legend><?php _e('Start Date','calendar'); ?></legend></td>
- <td> <script type="text/javascript">
- var cal_begin = new CalendarPopup('pop_up_cal');
- cal_begin.setWeekStartDay(<?php echo get_option('start_of_week'); ?>);
- function unifydates() {
- document.forms['quoteform'].event_end.value = document.forms['quoteform'].event_begin.value;
- }
- </script>
- <input type="text" name="event_begin" class="input" size="12"
- value="<?php
- if ( !empty($data) )
- {
- echo htmlspecialchars($data->event_begin);
- }
- else
- {
- echo date("Y-m-d",ctwo());
- }
- ?>" /> <a href="#" onClick="cal_begin.select(document.forms['quoteform'].event_begin,'event_begin_anchor','yyyy-MM-dd'); return false;" name="event_begin_anchor" id="event_begin_anchor"><?php _e('Select Date','calendar'); ?></a>
- </td>
- </tr>
- <tr>
- <td><legend><?php _e('End Date','calendar'); ?></legend></td>
- <td> <script type="text/javascript">
- function check_and_print() {
- unifydates();
- var cal_end = new CalendarPopup('pop_up_cal');
- cal_end.setWeekStartDay(<?php echo get_option('start_of_week'); ?>);
- var newDate = new Date();
- newDate.setFullYear(document.forms['quoteform'].event_begin.value.split('-')[0],document.forms['quoteform'].event_begin.value.split('-')[1]-1,document.forms['quoteform'].event_begin.value.split('-')[2]);
- newDate.setDate(newDate.getDate()-1);
- cal_end.addDisabledDates(null, formatDate(newDate, "yyyy-MM-dd"));
- cal_end.select(document.forms['quoteform'].event_end,'event_end_anchor','yyyy-MM-dd');
- }
- </script>
- <input type="text" name="event_end" class="input" size="12"
- value="<?php
- if ( !empty($data) )
- {
- echo htmlspecialchars($data->event_end);
- }
- else
- {
- echo date("Y-m-d",ctwo());
- }
- ?>" /> <a href="#" onClick="check_and_print(); return false;" name="event_end_anchor" id="event_end_anchor"><?php _e('Select Date','calendar'); ?></a>
- </td>
- </tr>
- <tr>
- <td><legend><?php _e('Time (hh:mm)','calendar'); ?></legend></td>
- <td> <input type="text" name="event_time" class="input" size=12
- value="<?php
- if ( !empty($data) )
- {
- if ($data->event_time == "00:00:00")
- {
- echo '';
- }
- else
- {
- echo date("H:i",strtotime(htmlspecialchars($data->event_time)));
- }
- }
- else
- {
- echo date("H:i",ctwo());
- }
- ?>" /> <?php _e('Optional, set blank if not required.','calendar'); ?> <?php _e('Current time difference from GMT is ','calendar'); echo get_option('gmt_offset'); _e(' hour(s)','calendar'); ?>
- </td>
- </tr>
- <tr>
- <td><legend><?php _e('Recurring Events','calendar'); ?></legend></td>
- <td> <?php
- if ($data->event_repeats != NULL)
- {
- $repeats = $data->event_repeats;
- }
- else
- {
- $repeats = 0;
- }
- if ($data->event_recur == "S")
- {
- $selected_s = 'selected="selected"';
- }
- else if ($data->event_recur == "W")
- {
- $selected_w = 'selected="selected"';
- }
- else if ($data->event_recur == "M")
- {
- $selected_m = 'selected="selected"';
- }
- else if ($data->event_recur == "Y")
- {
- $selected_y = 'selected="selected"';
- }
- ?>
- <?php _e('Repeats for','calendar'); ?>
- <input type="text" name="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
- <select name="event_recur" class="input">
- <option class="input" <?php echo $selected_s; ?> value="S">None</option>
- <option class="input" <?php echo $selected_w; ?> value="W">Weeks</option>
- <option class="input" <?php echo $selected_m; ?> value="M">Months</option>
- <option class="input" <?php echo $selected_y; ?> value="Y">Years</option>
- </select><br />
- <?php _e('Entering 0 means forever. Where the recurrance interval is left at none, the event will not reoccur.','calendar'); ?>
- </td>
- </tr>
- </table>
- </div>
- <div style="clear:both; height:1px;"> </div>
- </div>
- <input type="submit" name="save" class="button bold" value="<?php _e('Save','calendar'); ?> »" />
- </form>
- <?php
- }
- // The actual function called to render the manage events page and
- // to deal with posts
- function edit_calendar()
- {
- global $current_user, $wpdb, $users_entries;
- ?>
- <style type="text/css">
- <!--
- .error {
- background: lightcoral;
- border: 1px solid #e64f69;
- margin: 1em 5% 10px;
- padding: 0 1em 0 1em;
- }
- .center {
- text-align: center;
- }
- .right { text-align: right;
- }
- .left {
- text-align: left;
- }
- .top {
- vertical-align: top;
- }
- .bold {
- font-weight: bold;
- }
- .private {
- color: #e64f69;
- }
- //-->
- </style>
- <?php
- // First some quick cleaning up
- $edit = $create = $save = $delete = false;
- // Make sure we are collecting the variables we need to select years and months
- $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
- $event_id = !empty($_REQUEST['event_id']) ? $_REQUEST['event_id'] : '';
- // Deal with adding an event to the database
- if ( $action == 'add' )
- {
- $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
- $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
- $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
- $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
- $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
- $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
- $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
- $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
- $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
- // Deal with the fools who have left magic quotes turned on
- if ( ini_get('magic_quotes_gpc') )
- {
- $title = stripslashes($title);
- $desc = stripslashes($desc);
- $begin = stripslashes($begin);
- $end = stripslashes($end);
- $time = stripslashes($time);
- $recur = stripslashes($recur);
- $repeats = stripslashes($repeats);
- $category = stripslashes($category);
- $linky = stripslashes($linky);
- }
- // Perform some validation on the submitted dates - this checks for valid years and months
- $date_format_one = '/^([0-9]{4})-([0][1-9])-([0-3][0-9])$/';
- $date_format_two = '/^([0-9]{4})-([1][0-2])-([0-3][0-9])$/';
- if ((preg_match($date_format_one,$begin) || preg_match($date_format_two,$begin)) && (preg_match($date_format_one,$end) || preg_match($date_format_two,$end)))
- {
- // We know we have a valid year and month and valid integers for days so now we do a final check on the date
- $begin_split = split('-',$begin);
- $begin_y = $begin_split[0];
- $begin_m = $begin_split[1];
- $begin_d = $begin_split[2];
- $end_split = split('-',$end);
- $end_y = $end_split[0];
- $end_m = $end_split[1];
- $end_d = $end_split[2];
- if (checkdate($begin_m,$begin_d,$begin_y) && checkdate($end_m,$end_d,$end_y))
- {
- // Ok, now we know we have valid dates, we want to make sure that they are either equal or that the end date is later than the start date
- if (strtotime($end) >= strtotime($begin))
- {
- $start_date_ok = 1;
- $end_date_ok = 1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Your event end date must be either after or the same as your event begin date','calendar'); ?></p></div>
- <?php
- }
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Your date formatting is correct but one or more of your dates is invalid. Check for number of days in month and leap year related errors.','calendar'); ?></p></div>
- <?php
- }
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Both start and end dates must be entered and be in the format YYYY-MM-DD','calendar'); ?></p></div>
- <?php
- }
- // We check for a valid time, or an empty one
- $time_format_one = '/^([0-1][0-9]):([0-5][0-9])$/';
- $time_format_two = '/^([2][0-3]):([0-5][0-9])$/';
- if (preg_match($time_format_one,$time) || preg_match($time_format_two,$time) || $time == '')
- {
- $time_ok = 1;
- if ($time == '')
- {
- $time_to_use = '00:00:00';
- }
- else if ($time == '00:00')
- {
- $time_to_use = '00:00:01';
- }
- else
- {
- $time_to_use = $time;
- }
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The time field must either be blank or be entered in the format hh:mm','calendar'); ?></p></div>
- <?php
- }
- // We check to make sure the URL is alright
- if (preg_match('/^(http)(s?)(:)\/\//',$linky) || $linky == '')
- {
- $url_ok = 1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','calendar'); ?></p></div>
- <?php
- }
- // The title must be at least one character in length and no more than 30
- if (preg_match('/^.{1,30}$/',$title))
- {
- $title_ok =1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 30 characters in length','calendar'); ?></p></div>
- <?php
- }
- // We run some checks on recurrance
- $repeats = (int)$repeats;
- if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y')))
- {
- $recurring_ok = 1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
- <?php
- }
- if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok == 1 && $recurring_ok == 1)
- {
- $sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
- . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
- . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time_to_use) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "', event_author=".$current_user->ID.", event_category=".mysql_escape_string($category).", event_link='".mysql_escape_string($linky)."'";
-
- $wpdb->get_results($sql);
-
- $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
- . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' AND event_recur='" . mysql_escape_string($recur) . "' AND event_repeats='" . mysql_escape_string($repeats) . "' LIMIT 1";
- $result = $wpdb->get_results($sql);
-
- if ( empty($result) || empty($result[0]->event_id) )
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('An event with the details you submitted could not be found in the database. This may indicate a problem with your database or the way in which it is configured.','calendar'); ?></p></div>
- <?php
- }
- else
- {
- ?>
- <div class="updated"><p><?php _e('Event added. It will now show in your calendar.','calendar'); ?></p></div>
- <?php
- }
- }
- else
- {
- // The form is going to be rejected due to field validation issues, so we preserve the users entries here
- $users_entries->event_title = $title;
- $users_entries->event_desc = $desc;
- $users_entries->event_begin = $begin;
- $users_entries->event_end = $end;
- $users_entries->event_time = $time;
- $users_entries->event_recur = $recur;
- $users_entries->event_repeats = $repeats;
- $users_entries->event_category = $category;
- $users_entries->event_link = $linky;
- }
- }
- // Permit saving of events that have been edited
- elseif ( $action == 'edit_save' )
- {
- $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
- $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
- $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
- $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
- $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
- $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
- $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
- $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
- $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
- // Deal with the fools who have left magic quotes turned on
- if ( ini_get('magic_quotes_gpc') )
- {
- $title = stripslashes($title);
- $desc = stripslashes($desc);
- $begin = stripslashes($begin);
- $end = stripslashes($end);
- $time = stripslashes($time);
- $recur = stripslashes($recur);
- $repeats = stripslashes($repeats);
- $category = stripslashes($category);
- $linky = stripslashes($linky);
- }
-
- if ( empty($event_id) )
- {
- ?>
- <div class="error"><p><strong><?php _e('Failure','calendar'); ?>:</strong> <?php _e("You can't update an event if you haven't submitted an event id",'calendar'); ?></p></div>
- <?php
- }
- else
- {
- // Perform some validation on the submitted dates - this checks for valid years and months
- $date_format_one = '/^([0-9]{4})-([0][1-9])-([0-3][0-9])$/';
- $date_format_two = '/^([0-9]{4})-([1][0-2])-([0-3][0-9])$/';
- if ((preg_match($date_format_one,$begin) || preg_match($date_format_two,$begin)) && (preg_match($date_format_one,$end) || preg_match($date_format_two,$end)))
- {
- // We know we have a valid year and month and valid integers for days so now we do a final check on the date
- $begin_split = split('-',$begin);
- $begin_y = $begin_split[0];
- $begin_m = $begin_split[1];
- $begin_d = $begin_split[2];
- $end_split = split('-',$end);
- $end_y = $end_split[0];
- $end_m = $end_split[1];
- $end_d = $end_split[2];
- if (checkdate($begin_m,$begin_d,$begin_y) && checkdate($end_m,$end_d,$end_y))
- {
- // Ok, now we know we have valid dates, we want to make sure that they are either equal or that the end date is later than the start date
- if (strtotime($end) >= strtotime($begin))
- {
- $start_date_ok = 1;
- $end_date_ok = 1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Your event end date must be either after or the same as your event begin date','calendar'); ?></p></div>
- <?php
- }
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Your date formatting is correct but one or more of your dates is invalid. Check for number of days in month and leap year related errors.','calendar'); ?></p></div>
- <?php
- }
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Both start and end dates must be entered and be in the format YYYY-MM-DD','calendar'); ?></p></div>
- <?php
- }
- // We check for a valid time, or an empty one
- $time_format_one = '/^([0-1][0-9]):([0-5][0-9])$/';
- $time_format_two = '/^([2][0-3]):([0-5][0-9])$/';
- if (preg_match($time_format_one,$time) || preg_match($time_format_two,$time) || $time == '')
- {
- $time_ok = 1;
- if ($time == '')
- {
- $time_to_use = '00:00:00';
- }
- else if ($time == '00:00')
- {
- $time_to_use = '00:00:01';
- }
- else
- {
- $time_to_use = $time;
- }
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The time field must either be blank or be entered in the format hh:mm','calendar'); ?></p></div>
- <?php
- }
- // We check to make sure the URL is alright
- if (preg_match('/^(http)(s?)(:)\/\//',$linky) || $linky == '')
- {
- $url_ok = 1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','calendar'); ?></p></div>
- <?php
- }
- // The title must be at least one character in length and no more than 30
- if (preg_match('/^.{1,30}$/',$title))
- {
- $title_ok =1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 30 characters in length','calendar'); ?></p></div>
- <?php
- }
- // We run some checks on recurrance
- $repeats = (int)$repeats;
- if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y')))
- {
- $recurring_ok = 1;
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
- <?php
- }
- if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok == 1 && $recurring_ok == 1)
- {
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
- . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
- . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time_to_use) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "', event_author=".$current_user->ID . ", event_category=".mysql_escape_string($category).", event_link='".mysql_escape_string($linky)."' WHERE event_id='" . mysql_escape_string($event_id) . "'";
-
- $wpdb->get_results($sql);
-
- $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
- . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' AND event_recur='" . mysql_escape_string($recur) . "' AND event_repeats='" . mysql_escape_string($repeats) . "' LIMIT 1";
- $result = $wpdb->get_results($sql);
-
- if ( empty($result) || empty($result[0]->event_id) )
- {
- ?>
- <div class="error"><p><strong><?php _e('Failure','calendar'); ?>:</strong> <?php _e('The database failed to return data to indicate the event has been updated sucessfully. This may indicate a problem with your database or the way in which it is configured.','calendar'); ?></p></div>
- <?php
- }
- else
- {
- ?>
- <div class="updated"><p><?php _e('Event updated successfully','calendar'); ?></p></div>
- <?php
- }
- }
- else
- {
- // The form is going to be rejected due to field validation issues, so we preserve the users entries here
- $users_entries->event_title = $title;
- $users_entries->event_desc = $desc;
- $users_entries->event_begin = $begin;
- $users_entries->event_end = $end;
- $users_entries->event_time = $time;
- $users_entries->event_recur = $recur;
- $users_entries->event_repeats = $repeats;
- $users_entries->event_category = $category;
- $users_entries->event_link = $linky;
- $error_with_saving = 1;
- }
- }
- }
- // Deal with deleting an event from the database
- elseif ( $action == 'delete' )
- {
- if ( empty($event_id) )
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e("You can't delete an event if you haven't submitted an event id",'calendar'); ?></p></div>
- <?php
- }
- else
- {
- $sql = "DELETE FROM " . WP_CALENDAR_TABLE . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
- $wpdb->get_results($sql);
-
- $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
- $result = $wpdb->get_results($sql);
-
- if ( empty($result) || empty($result[0]->event_id) )
- {
- ?>
- <div class="updated"><p><?php _e('Event deleted successfully','calendar'); ?></p></div>
- <?php
- }
- else
- {
- ?>
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('Despite issuing a request to delete, the event still remains in the database. Please investigate.','calendar'); ?></p></div>
- <?php
- }
- }
- }
- // Now follows a little bit of code that pulls in the main
- // components of this page; the edit form and the list of events
- ?>
- <div class="wrap">
- <?php
- if ( $action == 'edit' || ($action == 'edit_save' && $error_with_saving == 1))
- {
- ?>
- <h2><?php _e('Edit Event','calendar'); ?></h2>
- <?php
- if ( empty($event_id) )
- {
- echo "<div class=\"error\"><p>".__("You must provide an event id in order to edit it",'calendar')."</p></div>";
- }
- else
- {
- wp_events_edit_form('edit_save', $event_id);
- }
- }
- else
- {
- ?>
- <h2><?php _e('Add Event','calendar'); ?></h2>
- <?php wp_events_edit_form(); ?>
-
- <h2><?php _e('Manage Events','calendar'); ?></h2>
- <?php
- wp_events_display_list();
- }
- ?>
- </div>
- <?php
-
- }
- // Display the admin configuration page
- function edit_calendar_config()
- {
- global $wpdb, $initial_style;
- if (isset($_POST['permissions']) && isset($_POST['style']))
- {
- if ($_POST['permissions'] == 'subscriber') { $new_perms = 'read'; }
- else if ($_POST['permissions'] == 'contributor') { $new_perms = 'edit_posts'; }
- else if ($_POST['permissions'] == 'author') { $new_perms = 'publish_posts'; }
- else if ($_POST['permissions'] == 'editor') { $new_perms = 'moderate_comments'; }
- else if ($_POST['permissions'] == 'admin') { $new_perms = 'manage_options'; }
- else { $new_perms = 'manage_options'; }
- $calendar_style = mysql_escape_string($_POST