예제 #1
0
function List_Courses_Permission($account_id, $bd)
{
    $courses = array();
    // Includes the permissions related to the user
    $result_user = $bd->Query("SELECT * FROM relationships WHERE master_id = '{$account_id}' AND\n\t\trel_type = 'course'");
    for ($i = 0; $i < $bd->NumberOfRows($result_user); $i++) {
        $course_id = $bd->FetchResult($result_user, $i, 'slave_id');
        $course = List_Courses($course_id, '', '', '', '', '', '', $bd);
        $courses[] = $course[0];
    }
    // Include the permissions related to the groups which the user is member of
    $query_groups = "SELECT * FROM group_members WHERE account_id = '{$account_id}'";
    $result_groups = $bd->Query($query_groups);
    for ($i = 0; $i < $bd->NumberOfRows($result_groups); $i++) {
        $group_id = $bd->FetchResult($result_groups, $i, 'group_id');
        $query_perm_group = "SELECT * FROM relationships WHERE master_group = '{$group_id}' AND\n\t\t\trel_type = 'course'";
        $result_group = $bd->Query($query_perm_group);
        for ($j = 0; $j < $bd->NumberOfRows($result_group); $j++) {
            $course_id = $bd->FetchResult($result_group, $j, 'slave_id');
            $course = List_Courses($course_id, '', '', '', '', '', '', $bd);
            $course[] = $course[0];
        }
    }
    // Include the permissions related to the user's category
    $query_cat = "SELECT * FROM people WHERE account_id = '{$account_id}'";
    $result_cat = $bd->Query($query_cat);
    $cat_id = $bd->FetchResult($result_cat, 0, 'category');
    $query_perm_cat = "SELECT * FROM relationships WHERE master_category = '{$cat_id}' AND\n\t\t\trel_type = 'course'";
    $result_category = $bd->Query($query_perm_cat);
    for ($j = 0; $j < $bd->NumberOfRows($result_category); $j++) {
        $course_id = $bd->FetchResult($result_category, $j, 'slave_id');
        $course = List_Courses($course_id, '', '', '', '', '', '', $bd);
        $course[] = $course[0];
    }
    return $courses;
}
            case 0:
                $error[$num_errors++] = "The semester must be filled";
                break;
            case -2:
                $error[$num_errors++] = "There are invalid characteres at the semester";
                break;
        }
        switch (User_Validate_Simple_Field($courses[0][7], 32)) {
            case 0:
                $error[$num_errors++] = "A Lecturer must be chosen";
                break;
            case -2:
                $error[$num_errors++] = "There are invalid characteres at the Lecturer";
                break;
        }
        $current = List_Courses('', '', $courses[0][3], $courses[0][4], '', $courses[5], $courses[0][6], $bd);
        if ($current) {
            $error[$num_errors++] = 'This course already exists';
        }
        if (empty($error)) {
            Insert_Course($courses[0][0], $courses[0][1], $courses[0][2], $courses[0][3], $courses[0][4], $courses[0][6], $courses[0][5], $courses[0][7], $bd);
            $alert[$num_alerts++] = "New Course Inserted Successfully";
            include "adm_acc_courses.php";
            exit;
        }
    }
    $result_xsl = "xsl/" . $default_xsl . "/adm_acc_courses_new.xsl";
    $category = List_Categories('', $cfg['professor_category'], $bd);
    $people = List_People('', '', '', '', $category[0][0], $bd);
} else {
    $error[$num_errors++] = "Invalid Session ID";
        include "logout.php";
        exit;
    }
    if (!empty($_POST['submit_conf_yes']) || !empty($_POST['submit_conf_no'])) {
        if (!empty($_POST['submit_conf_yes'])) {
            if (Delete_Course($_POST['account_id'], $bd) == 1) {
                $alert[$num_alerts++] = 'Course deleted successfully';
            }
        } else {
            $alert[$num_alerts++] = 'Course deletion cancelled';
        }
        include "adm_acc_courses.php";
        exit;
    } else {
        if (!empty($_GET['account_id'])) {
            $courses = List_Courses($_GET['account_id'], '', '', '', '', '', '', $bd);
        }
    }
    $result_xsl = "xsl/" . $default_xsl . "/adm_acc_courses_remove.xsl";
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpCourses", $courses);
$smarty->assign("nrpPeople", $people);
$result_xml = $smarty->fetch("xml/adm_acc_courses.xml");
            }
        } else {
            $error[$num_errors++] = "One (and only one) option of master must be chosen";
        }
        if (empty($error)) {
            Insert_Permission($permissions[0][1], $permissions[0][3], $permissions[0][5], $permissions[0][7], 'course', $bd);
            $alert[$num_alerts++] = "New Permision to Course Inserted Successfully";
            include "adm_permissions.php";
            exit;
        }
    }
    $result_xsl = "xsl/" . $default_xsl . "/adm_permissions_course_new.xsl";
    $categories = List_Categories('', '', $bd);
    $people = List_People('', '', '', '', '', $bd);
    $groups = List_Groups('', '', '', '', '', $bd);
    $courses = List_Courses('', '', '', '', '', '', '', $bd);
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpUserId", $account_id);
$smarty->assign("nrpCourses", $courses);
$smarty->assign("nrpPeople", $people);
$smarty->assign("nrpCategories", $categories);
$smarty->assign("nrpGroups", $groups);
$smarty->assign("nrpPermissions", $permissions);