示例#1
0
文件: crosslist.php 项目: rrusso/EARS
function findResetables($user, $courses, $semestersid)
{
    global $CFG, $USER;
    $semester = get_record('block_courseprefs_semesters', 'id', $semestersid);
    $semester_name = "{$semester->year}{$semester->name}{$user->getUsername()}cl";
    $numbers = $user->findClNumbers($semestersid, $courses);
    foreach ($numbers as $number) {
        $crosslists = CoursePrefsCrosslist::findByNumber($semester_name . $number);
        if (empty($crosslists)) {
            continue;
        }
        reset_prefs($crosslists);
    }
}
示例#2
0
            $errors[] = get_string('err_invalid_section', 'block_courseprefs', $a);
            continue;
        }
        $section = $sections[$sectionsid];
        $suggested_idnumber = "{$section->year}{$section->name}{$user->getUsername()}cl{$i}";
        if (array_key_exists($sectionsid, $crosslisted)) {
            $cr = $crosslisted[$sectionsid];
            if ($suggested_idnumber == $cr->getIdnumber()) {
                $cr->setShellName($data->{'bucket_' . $i . '_name'});
                $cr->setStatus('todo');
            } else {
                reset_prefs(array($cr));
            }
            insert_into_array($section, $changed_cr, $cr->getShellName());
        } else {
            $cr = new CoursePrefsCrosslist($user->getId(), $sectionsid, 'todo', $data->{'bucket_' . $i . '_name'}, $suggested_idnumber);
            insert_into_array($section, $new_cr, $cr->getShellName());
        }
        try {
            $cr->save();
        } catch (Exception $e) {
            $errors[] = 'Could not save a cross list entry!';
        }
    }
}
$params = array($changed_cr, $new_cr, $errors);
build_form('finished_content', $params, 'Next', '', 'GET', 'crosslist.php');
print_footer();
function insert_into_array($object, &$array, $key = null)
{
    if ($key) {