示例#1
0
function schedule_controller()
{
    global $session, $route, $mysqli, $user;
    $result = false;
    require "Modules/schedule/schedule_model.php";
    $schedule = new Schedule($mysqli, $user->get_timezone($session['userid']));
    if ($route->format == 'html') {
        if ($route->action == "view" && $session['write']) {
            $result = view("Modules/schedule/Views/schedule_view.php", array());
        }
        if ($route->action == 'api') {
            $result = view("Modules/schedule/Views/schedule_api.php", array());
        }
    }
    if ($route->format == 'json') {
        if ($route->action == 'list') {
            if ($session['userid'] > 0 && $session['userid'] && $session['read']) {
                $result = $schedule->get_list($session['userid']);
            }
        } elseif ($route->action == "create") {
            if ($session['userid'] > 0 && $session['write']) {
                $result = $schedule->create($session['userid']);
            }
        } else {
            $scheduleid = (int) get('id');
            if ($schedule->exist($scheduleid)) {
                $scheduleget = $schedule->get($scheduleid);
                // if public or belongs to user
                if ($session['read'] && ($scheduleget['public'] || $session['userid'] > 0 && $scheduleget['userid'] == $session['userid'])) {
                    if ($route->action == "get") {
                        $result = $scheduleget;
                    }
                    if ($route->action == "expression") {
                        $result = $schedule->get_expression($scheduleid);
                    }
                    if ($route->action == "test") {
                        $result = $schedule->test_expression($scheduleid);
                    }
                }
                // if public
                if (isset($session['write']) && $session['write'] && $session['userid'] > 0 && $scheduleget['userid'] == $session['userid']) {
                    if ($route->action == "delete") {
                        $result = $schedule->delete($scheduleid);
                    }
                    if ($route->action == 'set') {
                        $result = $schedule->set_fields($scheduleid, get('fields'));
                    }
                }
            } else {
                $result = array('success' => false, 'message' => 'Schedule does not exist');
            }
        }
    }
    return array('content' => $result);
}
     case rectype_findone:
     case rectype_always:
     case rectype_daily:
     case rectype_weekly:
         break;
         // Everything else gets ignored
     // Everything else gets ignored
     default:
         $_POST['record'] = 0;
 }
 // Cancelling a schedule?
 if ($_POST['record'] == 0) {
     // Cancel this schedule
     if ($schedule && $schedule->recordid) {
         // Delete the schedule
         $schedule->delete();
         // Redirect back to the schedule list
         add_warning(t('The requested recording schedule has been deleted.'));
         save_session_errors();
         header('Location: ' . root_url . 'tv/schedules');
         exit;
     }
 } else {
     // Set things as the user requested
     $schedule->profile = $_POST['profile'];
     $schedule->recgroup = $_POST['recgroup'];
     $schedule->storagegroup = $_POST['storagegroup'];
     $schedule->playgroup = $_POST['playgroup'];
     $schedule->autoexpire = $_POST['autoexpire'] ? 1 : 0;
     $schedule->autocommflag = $_POST['autocommflag'] ? 1 : 0;
     $schedule->autouserjob1 = $_POST['autouserjob1'] ? 1 : 0;
示例#3
0
try {
    $tutors = TutorFetcher::retrieveActive();
    $currentTerms = TermFetcher::retrieveCurrTerm();
    $schedules = ScheduleFetcher::retrieveTutorsOnCurrentTerms();
    if (isUrlRequestingAllSchedules($user)) {
        $pageTitle = "All Schedules";
    } else {
        if (isBtnAddSchedulePrsd()) {
            $pageTitle = "Add schedule";
            $days = isset($_POST['day']) ? $_POST['day'] : null;
            Schedule::add($_POST['tutorId'], $_POST['termId'], $days, $_POST['startsAt'], $_POST['endsAt']);
            header('Location: ' . BASE_URL . 'staff/schedules/success');
            exit;
        } else {
            if (isBtnDeletePrsd()) {
                Schedule::delete($_POST['delScheduleIdModal']);
                header('Location: ' . BASE_URL . 'staff/schedules/success');
                exit;
            } else {
                if (isModificationSuccessful()) {
                    $pageTitle = "Schedule added - Success";
                } else {
                    header('Location: ' . BASE_URL . 'error-404');
                    exit;
                }
            }
        }
    }
} catch (Exception $e) {
    $errors[] = $e->getMessage();
}
示例#4
0
 function schedules_delete($id = '', $page = '')
 {
     $s = new Schedule();
     $s->get_by_id($id);
     $s->delete();
     Session::flash('msg', 'Schedule deleted!');
     return Redirect::to('attendance/schedules/' . $page, 'refresh');
 }