示例#1
0
     print "<tr><td class=\"title\">Add a New Parent</td></tr>\n";
     print "<tr><td>First name:</td><td><input type=\"text\" name=\"firstname\" /></td></tr>\n";
     print "<tr><td>Last name:</td><td><input type=\"text\" name=\"surname\" /></td></tr>\n";
     print "<tr><td>Gender:</td><td><select name=\"gender\"><option value=\"f\" class=\"tdcolour0\">female<option value=\"m\" class=\"tdcolour1\">male</select></td></tr>\n";
     print "<tr><td>E-mail address (optional):</td><td><input type=\"text\" name=\"emailaddress\" /></td></tr>\n";
     print "<tr><td colspan=\"2\" class=\"small\"><em>Note:  Leave the following fields blank to make the system automatically generate them.</em></td></tr>\n";
     print "<tr><td>Username:</td><td><input type=\"text\" name=\"username\" /></td></tr>\n";
     print "<tr><td>Password:</td><td><input type=\"password\" name=\"pass1\" /></td></tr>\n";
     print "<tr><td>Confirm password:</td><td><input type=\"password\" name=\"pass2\" /></td></tr>\n";
     print "<tr><td><input type=\"hidden\" name=\"studentid\" value=\"{$user}\" /><input type=\"submit\" name=\"addnewparent\" value=\"add the parent\" /></td></tr>\n";
     print "</form></table>\n";
 } else {
     print "<table><form action=\"options.php\" method=\"post\">";
     print "<tr><td><p class=\"title\">Classes</p></td></tr>";
     // get the classes he or she is in, and allow the admin to change them
     $classes = parse_class_list($user);
     //remove the last comma
     $classes = substr($classes, 0, -1);
     // split it up into an array
     $classes = split(",", $classes);
     // for every grading period
     for ($i = 1; $i <= number_of_semesters; $i++) {
         print "<tr><td class=\"title\" align=\"center\">Grading Period {$i}</td></tr>\n";
         // for every day
         for ($j = 1; $j <= 5; $j++) {
             print "<tr><td><em>";
             switch ($j) {
                 case 1:
                     print "Monday";
                     break;
                 case 2:
示例#2
0
    print "Your post has been added.  Back to the <a href=\"forum.php?id={$class_id}\" title=\"class forum\">forum</a>?";
} elseif (isset($_GET['id'])) {
    if ($_GET['id'] != "" && is_numeric($_GET['id']) == TRUE) {
        $class_id = escape_string($_GET['id']);
    } else {
        cust_die("Invalid class ID.");
    }
    // perhaps $class_id = 0 can be reserved for a teachers'/admins' forum...
    // see if the requested ID is an actual class.
    $is_class = @query("SELECT 1 FROM `classes` WHERE `ID`='{$class_id}'") or die("Error checking the database.");
    if (num_rows($is_class) == 0) {
        cust_die("Invalid class ID.");
    }
    // if it is, see if the user may access it.  teachers and admins may access all forums
    if (user_type() == "user") {
        $classes = parse_class_list($_SESSION['id']);
        if (strpos($classes, $class_id . ",") === FALSE && strpost($classes, "," . $class_id) === FALSE) {
            cust_die("You may not access this forum>");
        }
    }
    // if he or she may...
    // allow the class's teacher (or an administrator) to delete posts or topics
    if (isset($_GET['delete'])) {
        // if the user is an administrator or the class's teacher, allow him or her to delete the post/topic
        if (user_type() == "admin" || user_type() == "teacher") {
            $good = 1;
            if (user_type() == "teacher") {
                // see if they teach the class
                $class_data = get_class_data($class_id);
                $class_data = explode("::", $class_data);
                $teacher_id = $class_data[1];
示例#3
0
/**
 * uses parse_class_list() and returns classes user $user has for semester $semester
 *
 * returned string is a list of classes separated with commas
 */
function classes_by_semester($user, $semester)
{
    $class_list = parse_class_list($user);
    $classes = explode(",", $class_list);
    $classes_per_semester = number_of_periods * 5;
    $up_until = $classes_per_semester * $semester - 1;
    $from = $classes_per_semester * ($semester - 1);
    $classes_displayed = "";
    $return = "";
    for ($i = $from; $i <= $up_until; $i++) {
        // get the class
        $class_id = $classes[$i];
        // display the class only if it already hasn't been displayed
        if (strpos($classes_displayed, $class_id . ",") === FALSE) {
            //add it to the string (so it's not displayed again)
            $classes_displayed .= "{$class_id},";
            // add it to the string we'll return
            $return .= "{$class_id},";
        }
    }
    return $return;
}