Ejemplo n.º 1
0
function bfox_bp_plans_reading_redirect(BfoxReadingSchedule $schedule, $reading_num, $action)
{
    global $bp;
    // If there is a reading num specified
    if ($reading_num && $reading_num <= $schedule->reading_count) {
        $reading_id = $reading_num - 1;
        // If we are marking the reading as read
        if ('read' == $action) {
            BfoxReadingSchedule::add_progress(array($schedule->id => array($reading_id)), $bp->loggedin_user->id);
            bp_core_add_message(sprintf(__('Reading #%d marked as read.', 'bfox'), $reading_num));
            bp_core_redirect($schedule->url());
        }
        // Redirect to the Bible Reader
        $readings = $schedule->readings();
        if (isset($readings[$reading_id]) && $readings[$reading_id]->is_valid()) {
            bp_core_redirect(bfox_ref_bible_url($readings[$reading_id]->get_string()));
        }
        bp_core_redirect($schedule->url());
    }
}