Beispiel #1
0
 }
 /** The Update and Edit Term have been depreciated, handled by INSERT/ADD now to preserve error checking **/
 if (isset($_POST['really_delete_year'])) {
     /** 
     			Deleting a term is complicated.  Must remove all references to classes that are in this term.
     			This means we need to remove the assignments/categories/grades/homework/classes/reports 
     		**/
     /** get the list of classes belonging to this term **/
     $sql = "SELECT * from classes where term_id=" . $_POST['term_id'];
     $result = $db->query($sql);
     $errorFlag = false;
     $err = "";
     /** Now call remove_class for each class belonging to term_id **/
     if ($result->num_rows) {
         while ($row = $result->fetch_assoc()) {
             $ret = remove_class($row['class_id']);
             if ($ret['num'] != 0) {
                 /** add to array of errors **/
                 $errorFlag = true;
                 $err .= $ret['txt'];
             }
         }
     }
     /** now remove the term... **/
     $sql = "DELETE from ";
     $result = $db->query($sql);
     $t = "Message...";
     $bc = "red";
     $b = "The year has been deleted.<br />";
     if ($errorFlag) {
         $b .= "However, there were some errors.  A message was sent to the system administrator.<br />";
Beispiel #2
0
/**
 * This will remove a course from the db and filesystem
 *
 * @param int $cid  course id
 */
function remove_course($cid)
{
    global $_CONF;
    global $db;
    $cname = '';
    $result = get_course_info($cid);
    $row = $result->fetch_assoc();
    $cname = $row['course_name'];
    $errBox = "";
    $sql = "SELECT courses.course_name, classes.term_id, terms.term_name, classes.class_id\r\n        \t\tFROM classes, courses, terms\r\n\t\t\t\tWHERE courses.course_id=" . $cid . "\r\n\t\t\t\t\tAND classes.course_id=courses.course_id\r\n\t\t\t\t\tAND terms.term_id = classes.term_id";
    $result = $db->query($sql);
    if ($result) {
        while ($row = $result->fetch_assoc()) {
            $b .= "Removing " . $row['course_name'] . " from " . $row['term_name'] . "<br>";
            $results = remove_class($row['class_id']);
            if ($results['num']) {
                $bc = "red";
                $b .= "<br />However, the database reported some errors...<br />";
                $b .= $results['txt'] . "<br />";
                $errBox .= "<br />" . make_box("Deleting", $b, $bc);
            }
        }
        /** remove the teacher backups folder for this course **/
        $path = $_CONF['configPath'] . "teacher_backups/" . $_SESSION[$_CONF['sess_name'] . "_myCenters"][$_SESSION[$_CONF['sess_name'] . "_myCenter"]]['short_name'] . "/" . $_SESSION[$_CONF['sess_name'] . "_myUname"] . "/";
        deltree($path . $cname);
        $sql = "DELETE from courses where course_id = " . $cid;
        $result = $db->query($sql);
        $b .= "Removing " . $cname . "... Done.";
    }
    $ret['num'] = $results['num'];
    $ret['txt'] = $errBox;
    //return $ret;
}
Beispiel #3
0
 }
 $remove_terms = array();
 $remove_terms = array_diff($current_terms, $future_terms);
 /** 
 		Removing terms/classes is a bit more difficult 
 		Need to remove the grades and the assignments and categories also
 		**/
 /** WORKING HERE--- Check out remove_class... remember dealing with a single term, not an entire course **/
 foreach ($remove_terms as $tid) {
     $sql = "SELECT class_id, courses.course_name\n\t\t\tFROM classes, courses \n\t\t\tWHERE classes.course_id =" . $_POST['course_id'] . " \n\t\t\tAND classes.term_id=" . $tid;
     $result = $db->query($sql);
     $row = $result->fetch_assoc();
     $cid = $row['class_id'];
     $cname = $row['course_name'];
     $b .= "<br />Removing " . $cname . " from " . $terms[$tid]['term_name'];
     $results = remove_class($cid);
     if ($results['num']) {
         $bc = "red";
         $b .= "<br />However, the database reported some errors...<br />";
         $b .= $results['txt'] . "<br />";
     }
 }
 $b .= "<br />Done.<br />";
 $msg .= $b;
 /** now update the course name **/
 if (isset($_POST['coreClass'])) {
     $active = 'Y';
 } else {
     $active = 'N';
 }
 $minutes = $_POST['minutes'];