Esempio n. 1
0
function checkDeleteCourse($course)
{
    list($subject_name, $course_number) = explode(" ", $course);
    $subject_name = fixSubjectName($subject_name);
    $course_number = fixSubjectName($course_number);
    deleteCourse($subject_name, $course_number);
    return true;
}
        $dotw .= $days[$i];
    }
    $query = mysql_query("UPDATE `courses` SET `coursename`='{$_POST['title']}', `teacherid`='{$_POST['teacher']}', `semesterid`='{$_POST['semester']}', `sectionnum`='{$_POST['sectionnum']}', `roomnum`='{$_POST['roomnum']}', `periodnum`='{$_POST['periodnum']}', `dotw`='{$dotw}', `substituteid`='{$_POST['substitute']}' WHERE `courseid`='{$_POST['courseid']}' LIMIT 1") or die("ManageClasses.php: Unable to update the class information - " . mysql_error());
}
##############
#   DELETE   #
##############
// Delete the classess that the user has requested as well as the classes belonging to those classess //
if ($_POST["deleteclass"] == 1) {
    require_once "DeleteFunctions.php";
    $delete = $_POST["delete"];
    for ($i = 0; $i < sizeof($delete); $i++) {
        $query = mysql_query("SELECT secondcourseid FROM courses WHERE courseid = {$delete[$i]}");
        $secondclass = mysql_fetch_row($query);
        deleteCourse($delete[$i]);
        deleteCourse($secondclass[0]);
    }
}
print "<script language='JavaScript'>\n  // Function to make sure the user wants to delete the class(es) //\n  function validate()\n  {\n   if( document.classes.selectclass.value > 0 )\n   {\n\tvar confirmed = confirm(\"Deleteing a class will also delete the class bulletins, tardies, attendance, assignments, and registrations that occured during that class. \\n \\nAre you sure?\");\n\n\tif( confirmed == true )\n\t{\n\t document.classes.submit();\n\t}\n   }\n   else\n   {\n\talert('You must select a class to delete.');\n   }\n  }\n\n\n  // Function to make sure only one checkbox has been selected //\n  function checkboxes()\n  {\n   if( document.classes.selectclass.value == 1 )\n   {\n\tdocument.classes.submit();\n   }\n   else\n   {\n\tif( document.classes.selectclass.value > 1 )\n\t{\n\t alert('You can only edit one class at a time.');\n\t}\n\telse\n\t{\n\t alert(document.classes.selectclass.value);\n\t alert('You must select a class to edit.');\n\t}\n   }\n  }\n\n\n  // Function to keep track of how many checkboxes are checked //\n  function updateboxes(row)\n  {\n   row = row + 2;\n   if(document.classes.elements[row].checked)\n   {\n\tdocument.classes.selectclass.value = Math.round(document.classes.selectclass.value) - 1;\n   }\n   else\n   {\n\tdocument.classes.selectclass.value = Math.round(document.classes.selectclass.value) + 1;\n   }\n  }\n </script>\n\n <h1>Manage Classes</h1>\n <br>\n <form name='classes' action='./index.php' method='POST'>\n\n <table align='center' width='900' cellspacing='0' cellpadding='0' border='0'>\n <b>Semester: </b> <select name='semester' onChange='document.classes.submit();'>\n";
// Get a list of semesters //
$query = mysql_query("SELECT semesterid, title FROM semesters ORDER BY startdate DESC") or die("ViewCourses.php: Unable to get a list of semesters for drop-down - " . mysql_error());
if ($_POST['semester'] == NULL) {
    $q = mysql_query("SELECT semesterid FROM semesters WHERE startdate < CURDATE() < enddate ORDER BY startdate");
    $temp = mysql_fetch_row($q);
    $_POST['semester'] = $temp[0];
}
$count = 0;
$all = "";
while ($semester = mysql_fetch_row($query)) {
    if ($count == 0) {
        $all = " {$semester['0']}";
Esempio n. 3
0
 * 
 */
if (!isset($_REQUEST['cmd'])) {
    echo '{"result" : 0, "message" : "Command Not Set"}';
    exit;
}
$cmd = $_REQUEST['cmd'];
switch ($cmd) {
    case 1:
        addCourse();
        break;
    case 2:
        updateCourse();
        break;
    case 3:
        deleteCourse();
        break;
    case 4:
        viewAllCourses();
        break;
    default:
        echo '{"result" : 0, "message" : "Unknown Command"}';
        break;
}
/*
 * 
 */
function addCourse()
{
}
/*
Esempio n. 4
0
        }
    }
    return true;
}
//after selected:
//if CID in db is not in list: delete the record from db
//if CID in db is in list: delete the record from list
//if list is not null: insert all record to the db
$list = $_POST['courses'];
//if the list is empty, then create the array to compare
if ($list == NULL) {
    $list = array();
}
$deleteList = array_diff($lastSelectedCourses, $list);
foreach ($deleteList as $CID) {
    deleteCourse($CID);
}
$insertList = array_diff($list, $lastSelectedCourses);
//update track
updateTrack($MID);
$alladded = True;
foreach ($insertList as $CID) {
    //print "insert" . $CID;
    if (checkReg($CID)) {
        addCourse($CID);
    } else {
        $alladded = False;
    }
}
if ($alladded) {
    $errmsg_arr[] = 'Changes successfully made!!<br>
Esempio n. 5
0
File: rg2api.php Progetto: AtleH/rg2
function handlePostRequest($type, $eventid)
{
    $data = json_decode(file_get_contents('php://input'));
    $write = array();
    if (lockDatabase() !== FALSE) {
        if ($type != 'addroute') {
            $loggedIn = logIn($data);
        } else {
            // don't need to log in to add a route
            $loggedIn = TRUE;
        }
        if ($loggedIn) {
            //rg2log($type);
            switch ($type) {
                case 'addroute':
                    $write = addNewRoute($eventid, $data);
                    @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "stats.json");
                    break;
                case 'addmap':
                    $write = addNewMap($data);
                    break;
                case 'createevent':
                    $write = addNewEvent($data);
                    @unlink(CACHE_DIRECTORY . "events.json");
                    @unlink(CACHE_DIRECTORY . "stats.json");
                    break;
                case 'editevent':
                    $write = editEvent($eventid, $data);
                    @unlink(CACHE_DIRECTORY . "events.json");
                    @unlink(CACHE_DIRECTORY . "stats.json");
                    break;
                case 'deleteevent':
                    $write = deleteEvent($eventid);
                    @unlink(CACHE_DIRECTORY . "events.json");
                    @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "courses_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "stats.json");
                    break;
                case 'deleteroute':
                    $write = deleteRoute($eventid);
                    @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "stats.json");
                    break;
                case 'deletecourse':
                    $write = deleteCourse($eventid);
                    @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "courses_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json");
                    @unlink(CACHE_DIRECTORY . "stats.json");
                    break;
                case 'login':
                    // handled by default before we got here
                    $write["ok"] = TRUE;
                    $write["status_msg"] = "Login successful";
                    break;
                default:
                    rg2log("Post request not recognised: " . $type);
                    $write["status_msg"] = "Request not recognised: " . $type;
                    $write["ok"] = FALSE;
                    break;
            }
        } else {
            $write["ok"] = FALSE;
            $write["status_msg"] = "Incorrect user name or password";
        }
        unlockDatabase();
    } else {
        $write["status_msg"] = "File lock error";
        $write["ok"] = FALSE;
    }
    $keksi = generateNewKeksi();
    $write["keksi"] = $keksi;
    header("Content-type: application/json");
    $write["version"] = RG2VERSION;
    echo json_encode($write);
}