public static function add_progress($schedule_readings, $user_id) { global $wpdb; if (!$user_id) { return; } $values = array(); foreach ($schedule_readings as $schedule_id => $reading_ids) { $schedule = BfoxReadingSchedule::schedule($schedule_id); foreach ($reading_ids as $reading_id) { if ($reading_id < $schedule->reading_count) { $values[] = $wpdb->prepare("(%d, %d, %d)", $schedule_id, $user_id, $reading_id); } } } if (!empty($values)) { $wpdb->query("INSERT INTO " . self::$progress_table_name . " (schedule_id, user_id, reading_id) VALUES " . implode(',', $values)); } }
function bfox_bp_plans_list_by_date($schedule_ids, $start_date, $end_date = '', $args = array()) { if (empty($end_date)) { $end_date = $start_date; } $reading_ids = array(); foreach ($schedule_ids as $schedule_id) { $schedule = BfoxReadingSchedule::schedule($schedule_id); $_reading_ids = $schedule->readings_in_range($start_date, $end_date); if (!empty($_reading_ids)) { $reading_ids[$schedule->revision_id] = $_reading_ids; } } return bfox_bp_plans_list_readings($schedule_ids, BfoxReadingPlan::get_readings(array('reading_ids' => $reading_ids)), $args); }