コード例 #1
0
ファイル: printlib.php プロジェクト: kfr2/phpmygrades
/**
 * displays the content for a user, depending upon what type of user he
 * or she is
 */
function display_content()
{
    if (user_type() == "user") {
        // print his or her latest grades, etc
        print "<div class=\"grades\"><p class=\"big\">Latest Grades&nbsp;<a href=\"classes.php?xml&amp;u={$_SESSION['id']}&p=" . gen_rss_pass($_SESSION['id']) . "\" title=\"latest grades feed\"><img src=\"images/xml.gif\" alt=\"latest grades via rss\" /></a></p>";
        // get their (5) latest grades
        display_latest_grades($_SESSION['id'], 5, "all");
        print "<p class=\"big\">Latest News&nbsp;<a href=\"news.php?xml&amp;u={$_SESSION['id']}&p=" . gen_rss_pass($_SESSION['id']) . "\" title=\"latest news feed\"><img src=\"images/xml.gif\" alt=\"latest news via rss\" /></a></p>";
        // get the user's class's latest news post
        display_latest_news($_SESSION['id'], 1);
        print "</div>";
        print "<p class=\"big\">Classes</p>";
        print_students_classes($_SESSION['id']);
    } elseif (user_type() == "teacher") {
        // eventually figure out what should go here.  suggestions?
        print "Use the menu above.";
    } elseif (user_type() == "admin") {
        // eventually figure out what should go here.  suggestions?
        print "Use the menu above to administer as you will.";
    } elseif (user_type() == "parent") {
        connect_sql();
        $parentID = $_SESSION['id'];
        // see which students the parent is a parent of, and print info about their grades.
        // the following will eventually be turned into a function
        $students = @query("SELECT `students` FROM `parents` WHERE `parent_ID`='{$parentID}'") or die("Error checking the database.");
        while ($row = result($students)) {
            $student = explode(",", $row->students);
            $i = 0;
            foreach ($student as $the_student) {
                // get his or her name
                $student_name = @query("SELECT `firstname`, `surname` FROM `users` WHERE `ID`='{$the_student}' LIMIT 1") or die("Error checking the database.");
                while ($row2 = result($student_name)) {
                    $students_name = stripslashes($row2->firstname) . " " . stripslashes($row2->surname);
                }
                print "<p class=\"title\">{$students_name}</p>";
                // print his or her latest grades, etc
                print "<div class=\"grades\"><p class=\"big\">Latest Grades&nbsp;<a href=\"classes.php?xml&amp;u={$the_student}&p=" . gen_rss_pass($the_student) . "\" title=\"latest grades feed\"><img src=\"images/xml.gif\" alt=\"latest grades via rss\" /></a></p>";
                // get their (5) latest grades
                display_latest_grades($the_student, 5, "all");
                print "<p class=\"big\">Latest News&nbsp;<a href=\"news.php?xml&amp;u={$the_student}&p=" . gen_rss_pass($the_student) . "\" title=\"latest news feed\"><img src=\"images/xml.gif\" alt=\"latest news via rss\" /></a></p>";
                // get the user's class's latest news post
                display_latest_news($the_student, 1);
                print "</div>";
                print "<p class=\"big\">Classes</p>";
                print_students_classes($the_student);
                $i++;
                // if we have more users to print, print a line
                if (isset($student[$i])) {
                    print "<hr />";
                }
            }
        }
        disconnect_sql();
    }
}
コード例 #2
0
ファイル: classes.php プロジェクト: kfr2/phpmygrades
        print "Apparently there is nothing for you here.";
    }
} else {
    any_errors();
    if (user_type() == "admin") {
        print "A list of all the classes, plus administration options for them, will (eventually) be displayed here.";
    } elseif (user_type() == "teacher") {
        print "<table style=\"width: 100%;\">\n<tr><th>Grading Period(s)</th><th>Period</th><th>Class Name</th></tr>";
        $id = $_SESSION['id'];
        connect_sql();
        $classes = @query("SELECT * FROM `classes` WHERE `teacher`='{$id}' ORDER BY `period`") or die("Error getting your list of classes.");
        while ($row = result($classes)) {
            $name = stripslashes($row->name);
            $period = $row->period;
            $class_id = $row->ID;
            $semesters = $row->semester;
            print "<tr><td>{$semesters}</td><td>{$period}</td><td>{$name}</td><td style=\"border-right: 1px dotted #000000;\"><a href=\"assignment.php?add&amp;id={$class_id}\" title=\"add an assignment\">add</a>:<a href=\"assignment.php?edit&amp;id={$class_id}\" title=\"edit an assignment\">edit</a>:<a href=\"assignment.php?view&amp;id={$class_id}\" title=\"view assignments\">view</a> an assignment</a></td>";
            if (enable_forums == 1) {
                print "<td style=\"border-right: 1px dotted #000000;\"><a href=\"forum.php?id={$class_id}\" title=\"class forum\">forum</a></td>";
            }
            print "<td style=\"border-right: 1px dotted #000000;\"><a href=\"classes.php?studentlist&amp;id={$class_id}\" title=\"student list\" target=\"_blank\" onClick=\"window.open('classes.php?studentlist&amp;id={$class_id}','class list','width=650,height=400'); return false;\">student list</a></td><td><a href=\"category.php?teacherid={$_SESSION['id']}&classid={$class_id}\" title=\"categories\">categories</a></td></tr>";
        }
        disconnect_sql();
        print "</table>";
    } elseif (user_type() == "user") {
        print_students_classes($_SESSION['id'], current_semester);
    }
}
print "</div>";
display_copyright();
display_footer();