Changeset 677215
- Timestamp:
- 03/06/2013 11:03:15 PM (13 years ago)
- File:
-
- 1 edited
-
riotschedule/trunk/riotschedule.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
riotschedule/trunk/riotschedule.php
r666051 r677215 4 4 * Plugin URI: http://www.mattyribbo.co.uk/riotschedule 5 5 * Description: Plugin to display weekly schedule for TV/Radio 6 * Version: 1. 0b36 * Version: 1.1b1 7 7 * Author: Matt Ribbins 8 8 * Author URI: http://www.mattyribbo.co.uk … … 28 28 */ 29 29 30 $version = "1. 0b3";30 $version = "1.1b1"; 31 31 32 32 … … 120 120 $genoptions['includestylescript'] = ""; 121 121 $genoptions['frontpagestylescript'] = false; 122 $genoptions['version'] = "1. 0";122 $genoptions['version'] = "1.1"; 123 123 return $genoptions; 124 124 } … … 301 301 <table> 302 302 <tr> 303 <td>Show Type</td> 304 <td> 305 <select style='width: 150px' name="type"> 306 <option value='1' <?php selected( 1, $itemexist->type );?>>Scheduled Item</option> 307 <option value='2' <?php selected( 2, $itemexist->type );?>>Unscheduled Item</option> 308 </select> 309 </td> 310 </tr> 311 <?php if ( $itemexist->type == 2 ) { ?> 312 <tr> 313 <td>Enable Unscheduled Item</td> 314 <td><input type="checkbox" <?php checked ( $itemexist->enabled ); ?> name="enabled" value="enabled" /></td> 315 </tr> 316 <?php } ?> 317 <tr> 303 318 <td>Short Description (One line)</td> 304 <td><textarea name="description" style='width: 150px;' rows=" 2"><?php if ($itemexist) { echo htmlspecialchars(stripslashes($itemexist->description)); }?></textarea>319 <td><textarea name="description" style='width: 150px;' rows="5"><?php if ($itemexist) { echo htmlspecialchars(stripslashes($itemexist->description)); }?></textarea> 305 320 </td> 306 321 </tr> … … 435 450 'scheduleid' => $_POST['schedule'], 436 451 'pid' => $schedule_id, 437 'enabled' => '1' 452 'enabled' => 0, 453 'type' => $_POST['type'] 438 454 ); 439 455 // Force enable. Scheduled items are always enabled. Unscheduled items are disabled by default 456 if($newitem['type'] == '1') { 457 $newitem['enabled'] = '1'; 458 } 459 if( $newitem['type'] == '2' ) { 460 461 if ( isset ( $_POST['enabled'] ) ) { 462 $newitem['enabled'] = '1' ; 463 } else { 464 $newitem['enabled'] = '0'; 465 } 466 } 467 440 468 // Search for matching PID in our database 441 469 $endtime = $newitem['starttime'] + $newitem['duration']; … … 450 478 if ( $update ) { 451 479 // We're updating a current record. 452 //$item_row = $wpdb->get_row("SELECT * from " . $wpdb->prefix . "rs_items where pid = " . $schedule_id);453 480 $wpdb->update( $wpdb->prefix . 'rs_items', $newitem, array( 'pid' => $schedule_id )); 454 481 //echo '<div id="message" class="updated fade"><p><strong>Updated Scheduled Item</strong></div>'; … … 464 491 465 492 } else { 466 // Seems we're just re-enabling this scheduled item 467 $wpdb->update( $wpdb->prefix . 'rs_items', array( 'enabled' => true ), array( 'pid' => $schedule_id )); 493 // Seems we're just re-enabling this scheduled item or updating the item 494 if ( $newitem['type'] == '1' ) { 495 $wpdb->update( $wpdb->prefix . 'rs_items', array( 'enabled' => true ), array( 'pid' => $schedule_id )); 496 } 468 497 } 469 498 } … … 526 555 echo $before_title . $title . $after_title; 527 556 528 // fetch results557 // Fetch results 529 558 global $wpdb; 530 559 531 $schedule_query = 'SELECT * from ' . $wpdb->prefix . 'rs_items WHERE day = ' . $today . ' AND scheduleid = ' . $schedule_id . ' ORDER by starttime ASC LIMIT 0, ' . $max_items;560 $schedule_query = 'SELECT * from ' . $wpdb->prefix . 'rs_items WHERE day = ' . $today . ' AND scheduleid = ' . $schedule_id . ' AND type = 1 AND enabled = 1 ORDER by starttime ASC LIMIT 0, ' . $max_items; 532 561 533 562 $schedule_items = $wpdb->get_results( $schedule_query ); … … 695 724 'offset' => '0', 696 725 'display' => 'name', 697 'default_message' => 'Non-stop Music 24/7' 726 'default_message' => 'Non-stop Music 24/7', 727 'schedule' => '1' 698 728 ), $atts ) ); 699 729 … … 713 743 if($mode == 'now') { 714 744 // Find the most recent show 715 $sqlitems = "SELECT * FROM " .$wpdb->prefix."rs_items WHERE day = '".$wsc_day."' AND starttime <= '".$wsc_hour."' ORDER BY starttime DESC LIMIT 0,1";745 $sqlitems = "SELECT * FROM " . $wpdb->prefix . "rs_items WHERE day = '" . $wsc_day . "' AND starttime <= '" . $wsc_hour . "' AND enabled = 1 AND scheduleid = " . $schedule . " ORDER BY starttime DESC, type DESC LIMIT 0,1"; 716 746 $items = $wpdb->get_row($sqlitems,ARRAY_A); 717 747 // Check that there is a show that has happened or is happening … … 725 755 // Look at yesterday, could be an overlapping show 726 756 } 757 727 758 } 728 759 … … 730 761 if($mode == 'next') { 731 762 // Find the next item after the current hour 732 $sqlitems = "SELECT * FROM ".$wpdb->prefix."rs_items WHERE day = '".$wsc_day."' AND starttime > '".$wsc_hour."' ORDER BY starttime ASC LIMIT 0,1";763 $sqlitems = "SELECT * FROM ".$wpdb->prefix."rs_items WHERE day = '".$wsc_day."' AND starttime > '".$wsc_hour."' AND enabled = 1 AND AND scheduleid = " . $schedule . " ORDER BY starttime ASC, type DESC LIMIT 0,1"; 733 764 $items = $wpdb->get_row($sqlitems,ARRAY_A); 734 765 // If items found, that is the next show. If no items found, check next day up until 1pm! … … 802 833 $show_next['time'] = rs_now_next_func(array("mode" => "next", "display" => "time")); 803 834 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"0.92\">\n"; 804 echo "<channel>\n<title> Hub Now and Next</title>\n<description>Shows the Now and Next shows on Hub Radio in a RSS format</description>\n";835 echo "<channel>\n<title>" . get_bloginfo("name") . " Now and Next</title>\n<description>Shows the Now and Next shows on " . get_bloginfo("name") . "</description>\n"; 805 836 echo "<link>http://www.hubradio.co.uk</link>\n"; 806 837 echo "<item><guid>http://www.hubradio.co.uk/?now</guid><title>".strip_tags($show_now['name'])." - ".strip_tags($show_now['time'])."</title><description>".strip_tags($show_now['name'])."</description></item\n>"; … … 830 861 'thumb_height' => 100, 831 862 'thumb_width' => 100, 832 'block_name_desc' => 0 863 'block_name_desc' => 0, 864 'type' => 1 833 865 ), $atts)); 834 866 … … 843 875 ' AND starttime >= ' . $period_start . 844 876 ' AND starttime < ' . $period_end . 845 ' ORDER by starttime ASC LIMIT 0, ' . $max_items; 877 ' AND type = ' . $type . 878 ' ORDER by starttime ASC, type DESC LIMIT 0, ' . $max_items; 846 879 847 880 $schedule_items = $wpdb->get_results( $schedule_query ); … … 930 963 'rs_items WHERE pid = ' . $pid . 931 964 ' AND enabled = 1' . 932 ' ORDER by starttime ASC LIMIT 0, 1';965 ' ORDER by starttime ASC, type DESC LIMIT 0, 1'; 933 966 934 967 $schedule_items = $wpdb->get_results( $schedule_query ); … … 1008 1041 'thumbnail' => 0, 1009 1042 'thumb_height' => 100, 1010 'thumb_width' => 100 1043 'thumb_width' => 100, 1044 'type' => 1 1011 1045 ), $atts)); 1012 1046 … … 1023 1057 1024 1058 foreach ( $postslist as $post ) : setup_postdata( $post ); 1025 //Fetch the RiotSchedule specific results1059 //Fetch the RiotSchedule specific results 1026 1060 $schedule_query = 'SELECT * from ' . $wpdb->prefix . 1027 'rs_items WHERE pid = ' . $post->ID . 1061 'rs_items WHERE pid = ' . $post->ID . 1062 ' AND type = ' . $type . 1028 1063 ' LIMIT 0, 1'; 1029 1064 $schedule_item = $wpdb->get_row( $schedule_query ); 1030 1031 1032 $output .= '<li class="riotschedule-fulllist-item">';1033 1034 $output .= '<a href=' . get_permalink() . '>';1035 1036 $output .= '<div class="riotschedule-fulllist-thumb">';1037 $output .= get_the_post_thumbnail();1038 $output .= '</div>';1039 1040 $output .= '<div class="riotschedule-fulllist-title">';1041 $output .= get_the_title();1042 $output .= '</div>';1043 1044 $output .= '<div class="riotschedule-fulllist-time">';1045 $output .= rs_get_day_string( $schedule_item->day ) . ' ' . rs_get_time_string( $schedule_item->starttime );1046 $output .= '</div>';1047 1048 $output .= '<div class="riotschedule-fulllist-desc">';1049 $output .= $schedule_item->description;1050 $output .= '</div>';1051 1052 $output .= '</a>';1053 1054 $output .= '</li>';1065 if($schedule_item) { 1066 $output .= '<li class="riotschedule-fulllist-item">'; 1067 1068 $output .= '<a href=' . get_permalink() . '>'; 1069 1070 $output .= '<div class="riotschedule-fulllist-thumb">'; 1071 $output .= get_the_post_thumbnail(); 1072 $output .= '</div>'; 1073 1074 $output .= '<div class="riotschedule-fulllist-title">'; 1075 $output .= get_the_title(); 1076 $output .= '</div>'; 1077 1078 $output .= '<div class="riotschedule-fulllist-time">'; 1079 $output .= rs_get_day_string( $schedule_item->day ) . ' ' . rs_get_time_string( $schedule_item->starttime ); 1080 $output .= '</div>'; 1081 1082 $output .= '<div class="riotschedule-fulllist-desc">'; 1083 $output .= $schedule_item->description; 1084 $output .= '</div>'; 1085 1086 $output .= '</a>'; 1087 1088 $output .= '</li>'; 1089 } 1055 1090 endforeach; 1056 1091 … … 1223 1258 } 1224 1259 1225 $sqldays = "SELECT * from " . $wpdb->prefix . "rs_days wherescheduleid = " . $scheduleid;1260 $sqldays = "SELECT * from " . $wpdb->prefix . "rs_days WHERE scheduleid = " . $scheduleid . "AND enabled = 1 AND scheduleid = " . $scheduleid; 1226 1261 1227 1262 if ($daylist != "") … … 1259 1294 $output .= "</tr>\n"; 1260 1295 1261 $sqlitems = "SELECT *, i.name as itemname, c.name as categoryname, c.id as catid FROM " . $wpdb->prefix . "rs_items i, " . $wpdb->prefix . "rs_categories c WHERE day = " . $day->id . " AND i.scheduleid = " . $scheduleid . " AND i.category = c.id AND i.starttime >= " . $starttime . " AND i.starttime < " . $endtime . " ORDER by starttime";1296 $sqlitems = "SELECT *, i.name as itemname, c.name as categoryname, c.id as catid FROM " . $wpdb->prefix . "rs_items i, " . $wpdb->prefix . "rs_categories c WHERE day = " . $day->id . " AND i.scheduleid = " . $scheduleid . " AND i.category = c.id AND i.starttime >= " . $starttime . " AND i.starttime < " . $endtime . " AND i.enabled = 1 AND i.scheduleid = '" . $scheduleid . "' ORDER by starttime"; 1262 1297 1263 1298 $items = $wpdb->get_results($sqlitems); … … 2518 2553 $genoptions = get_option("RiotScheduleGeneral"); 2519 2554 2520 if ( $genoptions == false) {2555 if ( $genoptions == false ) { 2521 2556 $genoptions = rs_return_default_genoptions($genoptions); 2522 2557 update_option( 'RiotScheduleGeneral', $genoptions ); 2523 2558 } 2559 if ( $genoptions['version'] === "2.7" ) { 2560 // Port from Weekly Schedule may have put this false version number in. Revert back to 1.0 2561 $genoptions['version'] = "1.0"; 2562 update_option( 'RiotScheduleGeneral', $genoptions ); 2563 } 2564 2565 if ( $genoptions['version'] === "1.0" ) { 2566 // Add type to scheduled item (introduced 1.1) 2567 $result = $wpdb->query("ALTER TABLE `$wpdb->rs_items` ADD COLUMN `type` INT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `enabled`;"); 2568 2569 $genoptions['version'] = "1.1"; 2570 update_option( 'RiotScheduleGeneral', $genoptions ); 2571 } 2524 2572 } 2525 2573
Note: See TracChangeset
for help on using the changeset viewer.