Ejemplo n.º 1
0
function bfox_bp_plans_list_month_year_readings($month, $year)
{
    global $bp;
    $start_date = date('Y-m-d', strtotime("{$year}-{$month}-01"));
    $end_date = date('Y-m-d', strtotime('+1 month -1 day', strtotime($start_date)));
    $schedule_ids = BfoxReadingSchedule::get(BfoxReadingSchedule::add_current_owner_to_args(array('date' => array($start_date, $end_date))));
    if ($bp->groups->current_group->id) {
        $show_checks = groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id);
    } else {
        $show_checks = $bp->loggedin_user->id == $bp->displayed_user->id;
    }
    ?>
		<h4 class="plans-calendar"><?php 
    printf(__('Readings for %s', 'bfox'), date('F, Y', strtotime($start_date)));
    ?>
</h4>
		<form action="" method="post">
		<?php 
    $checked_ids = bfox_bp_plans_list_by_date($schedule_ids, $start_date, $end_date, array('date_format' => 'F j (D)', 'is_item_list' => true, 'show_checks' => $show_checks));
    ?>
		<br/>
	<?php 
    if ($show_checks && !empty($schedule_ids)) {
        ?>
		<p>
		<input type="hidden" name="bible_reading_plan_old_checks" value="<?php 
        echo implode(',', $checked_ids);
        ?>
" />
		<input type="submit" name="bible_reading_save_checks" value="<?php 
        _e('Save Progress', 'bfox');
        ?>
" />
		</p>
	<?php 
    }
    ?>
	<?php 
    if ($show_checks) {
        ?>
		<p>
		<a href="<?php 
        echo bfox_bp_plan_url();
        ?>
"><?php 
        _e('Schedule a reading plan', 'bfox');
        ?>
</a>
		</p>
	<?php 
    }
    ?>
		</form>
	<?php 
}
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
 public static function delete_plan(BfoxReadingPlan $plan)
 {
     global $wpdb;
     BfoxReadingSchedule::delete_plan($plan);
     $plan->is_deleted = true;
     $plan->save();
 }