コード例 #1
0
ファイル: manage.php プロジェクト: anilch/Personel
$id = required_param('id', PARAM_INT);
$from = optional_param('from', null, PARAM_ALPHANUMEXT);
$pageparams->view = optional_param('view', null, PARAM_INT);
$pageparams->curdate = optional_param('curdate', null, PARAM_INT);
$pageparams->perpage = 10; //get_config('local_attendance', 'resultsperpage');

$att = $DB->get_record('local_attendance', array('id' => $id), '*', MUST_EXIST);
$classinfo = $DB->get_record('local_clclasses', array('id' => $att->classid));
$PAGE->set_context(context_system::instance());


$pageparams->init($classinfo);

$att = new local_attendance($att, $classinfo, $PAGE->context, $pageparams);
if (!$att->perm->can_manage() && !$att->perm->can_take() && !$att->perm->can_change()) {
    redirect($att->url_view());
}

// If teacher is coming from block, then check for a session exists for today.
if ($from === 'block') {
    $sessions = $att->get_today_sessions();
    $size = count($sessions);
    if ($size == 1) {
        $sess = reset($sessions);
        $nottaken = !$sess->lasttaken && has_capability('mod/attendance:takeattendances', $PAGE->context);
        $canchange = $sess->lasttaken && has_capability('mod/attendance:changeattendances', $PAGE->context);
        if ($nottaken || $canchange) {
            redirect($att->url_take(array('sessionid' => $sess->id, 'grouptype' => $sess->groupid)));
        }
    } else if ($size > 1) {
        $att->curdate = $today;