diff -r 53cff4b4a802 -r bde1974c263b web/wp-content/plugins/event-calendar/admin.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/wp-content/plugins/event-calendar/admin.php Wed Feb 03 15:37:20 2010 +0000
@@ -0,0 +1,680 @@
+advanced=false;
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ get_results(
+ "SELECT
+ sched_id,
+ DATE_FORMAT(start,'%Y-%m-%d %H:%i') AS start,
+ DATE_FORMAT(end,'%Y-%m-%d %H:%i') AS end,
+ allday,
+ rpt
+ FROM $ec3->schedule WHERE post_id=$post_ID ORDER BY start");
+ else
+ $schedule = false;
+
+ if(function_exists('wp_create_nonce'))
+ {
+ echo '';
+ }
+ ?>
+
+
+
+
+
+ >
+
+
+ " value="" />
+
+ |
+
+ " value="" />
+
+ |
+
+ />
+ |
+
+
+
+
+
+ |
+
+ save_post_called) && $this->save_post_called[$post_ID])
+ return;
+ if(!isset($this->save_post_called))
+ $this->save_post_called=array();
+ $this->save_post_called[$post_ID]=true;
+
+ global $ec3,$wpdb;
+ // Use this to check the DB before DELETE/UPDATE. Should use
+ // ...IGNORE, but some people insist on using ancient version of MySQL.
+ $count_where="SELECT COUNT(0) FROM $ec3->schedule WHERE";
+
+ // If this post is no longer an event, then purge all schedule records.
+ if(isset($_POST['ec3_rows']) && '0'==$_POST['ec3_rows'])
+ {
+ if($wpdb->get_var("$count_where post_id=$post_ID"))
+ $wpdb->query("DELETE FROM $ec3->schedule WHERE post_id=$post_ID");
+ return;
+ }
+
+ // Find all of our parameters
+ $sched_entries=array();
+ $fields =array('start','end','allday','rpt');
+ foreach($_POST as $k => $v)
+ {
+ if(preg_match('/^ec3_(action|'.implode('|',$fields).')_(_?)([0-9]+)$/',$k,$match))
+ {
+ $sid=intval($match[3]);
+ if(!isset( $sched_entries[$sid] ))
+ $sched_entries[ $sid ]=array('allday' => 0);
+ $sched_entries[ $sid ][ $match[1] ] = $v;
+ }
+ }
+
+ foreach($sched_entries as $sid => $vals)
+ {
+ // Bail out if the input data looks suspect.
+ if(!array_key_exists('action',$vals) || count($vals)<3)
+ continue;
+ // Save the value of 'action' and remove it. Leave just the column vals.
+ $action=$vals['action'];
+ unset($vals['action']);
+ // Reformat the column values for SQL:
+ foreach($vals as $k => $v)
+ if('allday'==$k)
+ $vals[$k]=intval($v);
+ else
+ $vals[$k]="'".$wpdb->escape($v)."'";
+ $sid_ok=$wpdb->get_var("$count_where post_id=$post_ID AND sched_id=$sid");
+ // Execute the SQL.
+ if($action=='delete' && $sid>0 && $sid_ok):
+ $wpdb->query(
+ "DELETE FROM $ec3->schedule
+ WHERE post_id=$post_ID
+ AND sched_id=$sid"
+ );
+ elseif($action=='update' && $sid>0 && $sid_ok):
+ $wpdb->query(
+ "UPDATE $ec3->schedule
+ SET ".$this->implode_assoc(', ',$vals)."
+ WHERE post_id=$post_ID
+ AND sched_id=$sid"
+ );
+ elseif($action=='create'):
+ $wpdb->query(
+ "INSERT INTO $ec3->schedule
+ (post_id, ".implode(', ',array_keys($vals)).")
+ VALUES ($post_ID,".implode(', ',array_values($vals)).")"
+ );
+ endif;
+ }
+ // Force all end dates to be >= start dates.
+ $wpdb->query("UPDATE $ec3->schedule SET end=start WHERE end$value)
+ $result[]=$key."=".$value;
+ return implode($glue,$result);
+ }
+
+
+ //
+ // OPTIONS
+ //
+
+
+ /** Upgrade the installation, if necessary. */
+ function upgrade_database()
+ {
+ global $ec3,$wpdb;
+ // Check version - return if no upgrade required.
+ $installed_version=get_option('ec3_version');
+ if($installed_version==$ec3->version)
+ return;
+
+ $v0=$this->ec3_version($installed_version);
+ $v1=$this->ec3_version($ec3->version);
+ for($i=0; $i $v1[$i] )
+ return; // Installed version later than this one ?!?!
+ if( $v0[$i] < $v1[$i] )
+ break; // Installed version earlier than this one.
+ }
+
+ // Upgrade.
+ $tables=$wpdb->get_results('SHOW TABLES',ARRAY_N);
+ if(!$tables)
+ die(__('Error upgrading database for EventCalendar plugin.','ec3'));
+
+ $table_exists=false;
+ foreach($tables as $t)
+ if(preg_match("/$ec3->schedule/",$t[0]))
+ $table_exists=true;
+
+ if(!$table_exists)
+ {
+ $wpdb->query(
+ "CREATE TABLE $ec3->schedule (
+ sched_id BIGINT(20) AUTO_INCREMENT,
+ post_id BIGINT(20),
+ start DATETIME,
+ end DATETIME,
+ allday BOOL,
+ rpt VARCHAR(64),
+ PRIMARY KEY(sched_id)
+ )");
+ // Force the special upgrade page if we are coming from v3.0
+ if( $ec3->event_category &&
+ ( empty($v0) || $v0[0]<3 || ($v0[0]==3 && $v0[1]==0) ) )
+ {
+ update_option('ec3_upgrade_posts',1);
+ }
+ } // end if(!$table_exists)
+
+ // Record the new version number
+ update_option('ec3_version',$ec3->version);
+ echo ''
+ . sprintf(
+ __('Upgraded database to EventCalendar Version %s','ec3'),
+ $ec3->version
+ );
+ if($table_exists)
+ echo '
('.__('Table already existed','ec3').')';
+ echo ".
\n";
+ } // end function upgrade_database();
+
+ /** Utility function used by upgrade_database().
+ * Breaks apart a version string into an array of comparable parts. */
+ function ec3_version($str)
+ {
+ $s=preg_replace('/([a-z])([0-9])/','\1.\2',$str);
+ $v=explode('.',$s);
+ $result=array();
+ foreach($v as $i)
+ {
+ if(preg_match('/^[0-9]+$/',$i))
+ $result[]=intval($i);
+ elseif(empty($i))
+ $result[]=0;
+ else
+ $result[]=$i;
+ }
+ return $result;
+ }
+
+
+ function action_admin_menu()
+ {
+ global $ec3;
+ add_options_page(
+ __('Event Calendar Options','ec3'),
+ 'EventCalendar',
+ 6,
+ 'ec3_admin',
+ 'ec3_options_subpanel'
+ );
+
+ if(empty($ec3->event_category))
+ return; // Until EC is properly configured, only show the options page.
+
+ if(function_exists('add_meta_box'))
+ {
+ add_meta_box(
+ 'ec3_schedule_editor', // HTML id for container div
+ __('Event Editor','ec3'),
+ 'ec3_event_editor_box', // callback function
+ 'post', // page type
+ 'advanced', // context
+ 'high' // priority
+ );
+ }
+ else
+ {
+ // Old (pre WP2.5) functionality.
+ add_filter('simple_edit_form', array(&$ec3_admin,'filter_edit_form'));
+ if($ec3->wp_have_dbx)
+ add_filter('dbx_post_advanced', array(&$ec3_admin,'filter_edit_form'));
+ else
+ add_filter('edit_form_advanced',array(&$ec3_admin,'filter_edit_form'));
+ }
+ }
+
+
+ function options_subpanel()
+ {
+ global $ec3;
+
+ if(isset($_POST['info_update']))
+ {
+ echo '';
+ if(isset($_POST['ec3_event_category']))
+ $ec3->set_event_category( intval($_POST['ec3_event_category']) );
+ if(isset($_POST['ec3_num_months']))
+ $ec3->set_num_months( intval($_POST['ec3_num_months']) );
+ if(isset($_POST['ec3_show_only_events']))
+ $ec3->set_show_only_events( intval($_POST['ec3_show_only_events']) );
+ if(isset($_POST['ec3_day_length']))
+ $ec3->set_day_length( intval($_POST['ec3_day_length']) );
+ if(isset($_POST['ec3_hide_logo']))
+ $ec3->set_hide_logo( intval($_POST['ec3_hide_logo']) );
+ if(isset($_POST['ec3_hide_event_box']))
+ $ec3->set_hide_event_box( intval($_POST['ec3_hide_event_box']) );
+ if(isset($_POST['ec3_advanced']))
+ $ec3->set_advanced( intval($_POST['ec3_advanced']) );
+ if(isset($_POST['ec3_navigation']))
+ $ec3->set_navigation( intval($_POST['ec3_navigation']) );
+ if(isset($_POST['ec3_disable_popups']))
+ $ec3->set_disable_popups( intval($_POST['ec3_disable_popups']) );
+ if(isset($_POST['ec3_tz']))
+ $ec3->set_tz( $_POST['ec3_tz'] );
+ _e('Options saved.');
+ echo '
';
+ }
+ ?>
+
+ upgrade_database(); // May set option ec3_force_upgrade
+
+ if( intval(get_option('ec3_upgrade_posts')) ||
+ isset($_POST['ec3_upgrade_posts']) )
+ {
+ require_once(dirname(__FILE__).'/upgrade-posts.php');
+ ec3_upgrade_posts();
+ return;
+ }
+
+ // Normal options page...
+ $ec3_admin->options_subpanel();
+}
+
+function ec3_event_editor_box()
+{
+ global $ec3_admin;
+ $ec3_admin->event_editor_box();
+}
+
+
+//
+// Hook in...
+if($ec3->event_category)
+{
+ add_filter('admin_head',array(&$ec3_admin,'filter_admin_head'));
+ add_action('save_post', array(&$ec3_admin,'action_save_post'));
+ // TODO v3.2 - don't use the edit_post hook.
+ add_action('edit_post', array(&$ec3_admin,'action_save_post'));
+}
+
+// Always hook into the admin_menu - it's required to allow users to
+// set things up.
+add_action('admin_menu', array(&$ec3_admin,'action_admin_menu'));
+
+?>