} else { $stat = Database::get()->querySingle("SELECT status FROM course_user\n WHERE user_id = ?d AND\n course_id = ?d", $uid, $course_id); if ($stat) { $status = $stat->status; } else { // the department manager has rights to the courses of his department(s) if ($is_departmentmanage_user && $is_usermanage_user && !$is_power_user && !$is_admin && isset($course_code)) { require_once 'include/lib/hierarchy.class.php'; require_once 'include/lib/course.class.php'; require_once 'include/lib/user.class.php'; $treeObj = new Hierarchy(); $courseObj = new Course(); $userObj = new User(); $atleastone = false; $subtrees = $treeObj->buildSubtrees($userObj->getDepartmentIds($uid)); $depIds = $courseObj->getDepartmentIds($course_id); foreach ($depIds as $depId) { if (in_array($depId, $subtrees)) { $atleastone = true; break; } } if ($atleastone) { $status = 1; $is_course_admin = true; $_SESSION['courses'][$course_code] = USER_DEPARTMENTMANAGER; } } } } if ($visible != COURSE_OPEN) {
} if (isset($_REQUEST['visW'])) { // modify visibility of the Week $id = intval(getDirectReference($_REQUEST['visW'])); $vis = Database::get()->querySingle("SELECT `visible` FROM course_weekly_view WHERE id = ?d", $id)->visible; $newvis = ($vis == 1) ? 0 : 1; Database::get()->query("UPDATE course_weekly_view SET visible = ?d WHERE id = ?d AND course_id = ?d", $newvis, $id, $course_id); } } //style='color:#999999; font-size:13px;' $bar_content .= "<b>" . $langCode . ":</b> " . q($public_code) . "" . "<br><b>" . $langFaculty . ":</b> "; $departments = $course->getDepartmentIds($course_id); $i = 1; foreach ($departments as $dep) { $br = ($i < count($departments)) ? '<br>' : ''; $bar_content .= $tree->getFullPath($dep) . $br; $i++; } $numUsers = Database::get()->querySingle("SELECT COUNT(user_id) AS numUsers FROM course_user WHERE course_id = ?d", $course_id)->numUsers; //set the lang var for lessons visibility status switch ($visible) { case COURSE_CLOSED: { $lessonStatus = "<span title='$langClosedCourseShort'>$langPrivateShort</span>";
validateCourseNodes($cId, isDepartmentAdmin()); load_js('jstree'); $toolName = $langCourseInfo; $navigation[] = array('url' => 'index.php', 'name' => $langAdmin); $navigation[] = array('url' => 'editcours.php?c=' . q($_GET['c']), 'name' => $langCourseEdit); if (isset($_GET['c'])) { $tool_content .= action_bar(array(array('title' => $langBack, 'url' => "editcours.php?c={$_GET['c']}", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } else { $tool_content .= action_bar(array(array('title' => $langBackAdmin, 'url' => "index.php", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } // Update course basic information if (isset($_POST['submit'])) { $departments = isset($_POST['department']) ? $_POST['department'] : array(); // if depadmin then diff new/old deps and if new or deleted deps are out of juristinction, then error if (isDepartmentAdmin()) { $olddeps = $course->getDepartmentIds($cId); foreach ($departments as $depId) { if (!in_array($depId, $olddeps)) { validateNode(intval($depId), true); } } foreach ($olddeps as $depId) { if (!in_array($depId, $departments)) { validateNode($depId, true); } } } // Update query Database::get()->query("UPDATE course SET title = ?s,\n prof_names = ?s\n WHERE code = ?s", $_POST['title'], $_POST['titulary'], $_GET['c']); $course->refresh($cId, $departments); $tool_content .= "<div class='alert alert-success'>{$langModifDone}</div>";
// update the counter $cnt++; } // check if left from the previous weeks and they are out of the new period // if so delete them if (--$cnt < $countPreviousWeeks) { $week2delete = $countPreviousWeeks - $cnt; for ($i = 0; $i < $week2delete; $i++) { Database::get()->query("DELETE FROM course_weekly_view WHERE id = ?d", $previousWeeksArray[$cntOld]); $cntOld++; } } } } $old_deps = $course->getDepartmentIds($course_id); $deps_changed = count(array_diff($old_deps, $departments)) + count(array_diff($departments, $old_deps)); //======================================================= // Check if the teacher is allowed to create in the departments he chose if ($deps_changed and !$deps_valid) { Session::Messages($langCreateCourseNotAllowedNode, 'alert-danger'); redirect_to_home_page("modules/course_info/?course=$course_code"); } else { Database::get()->query("UPDATE course SET title = ?s, public_code = ?s, keywords = ?s, visible = ?d, course_license = ?d,
$title = $langClosedCourse; break; case COURSE_REGISTRATION: $icon = 'lock_registration'; $title = $langRegCourse; break; case COURSE_OPEN: $icon = 'lock_open'; $title = $langOpenCourse; break; case COURSE_INACTIVE: $icon = 'lock_inactive'; $title = $langInactiveCourse; break; } $departments = $course->getDepartmentIds($logs->id); $i = 1; $dep = ''; foreach ($departments as $department) { $br = $i < count($departments) ? '<br/>' : ''; $dep .= $tree->getFullPath($department) . $br; $i++; } // Add links to course users, delete course and course edit $icon_content = icon('fa-user', $langUsers, "listusers.php?c={$logs->id}") . " "; if (!isDepartmentAdmin()) { $icon_content .= icon('fa-list', $langUsersLog, "../usage/displaylog.php?c={$logs->id}&from_admin=TRUE") . " "; } $icon_content .= icon('fa-edit', $langEdit, "editcours.php?c={$logs->code}") . " "; $icon_content .= icon('fa-times', $langDelete, "delcours.php?c={$logs->id}"); $data['aaData'][] = array('0' => $course_title, '1' => icon_old_style($icon, $title), '2' => $dep, '3' => $icon_content);
$radio_dis = ''; $rating_dis_label = ''; } if (setting_get(SETTING_COURSE_ANONYMOUS_RATING_ENABLE, $course_id) == 1) { $checkDis = ''; $checkEn = 'checked '; } else { $checkDis = 'checked '; $checkEn = ''; } // USER COMMENTS if (setting_get(SETTING_COURSE_COMMENT_ENABLE, $course_id) == 1) { $checkDis = ""; $checkEn = "checked "; } else { $checkDis = "checked "; $checkEn = ""; } $tool_content .= "<div class='form-wrapper'>\n\t<form class='form-horizontal' role='form' method='post' action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' onsubmit='return validateNodePickerForm();'>\n\t<fieldset>\n\t<div class='form-group'>\n <label for='fcode' class='col-sm-2 control-label'>{$langCode}</label>\n <div class='col-sm-10'>\n <input type='text' class='form-control' name='fcode' id='fcode' value='{$public_code}'>\n </div>\n </div>\n <div class='form-group'>\t \n <label for='title' class='col-sm-2 control-label'>{$langCourseTitle}:</label>\n <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='title' id='title' value='" . q($title) . "'>\n\t </div>\n </div>\n <div class='form-group'>\n <label for='titulary' class='col-sm-2 control-label'>{$langTeachers}:</label>\n <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='titulary' id='titulary' value='{$titulary}'>\n\t </div>\n </div>\n <div class='form-group'>\n\t <label for='Faculty' class='col-sm-2 control-label'>{$langFaculty}:</label>\n <div class='col-sm-10'>"; $allow_only_defaults = get_config('restrict_teacher_owndep') && !$is_admin ? true : false; list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $course->getDepartmentIds($c->id), 'allow_only_defaults' => $allow_only_defaults)); $head_content .= $js; $tool_content .= $html; @($tool_content .= "</div></div>\n\t <div class='form-group'>\n\t\t<label for='course_keywords' class='col-sm-2 control-label'>{$langCourseKeywords}</label>\n\t\t<div class='col-sm-10'>\n <input type='text' class='form-control' name='course_keywords' id='course_keywords' value='{$course_keywords}'>\n </div>\n\t </div> \n\t <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langCourseFormat}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input type='radio' name='view_type' value='simple' id='simple'" . ($c->view_type == "simple" ? " checked" : "") . ">\n {$langCourseSimpleFormat}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' name='view_type' value='units' id='units'" . ($c->view_type == "units" ? " checked" : "") . ">\n {$langWithCourseUnits}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' name='view_type' value='weekly' id='weekly'" . ($c->view_type == "weekly" ? " checked" : "") . ">\n {$langCourseWeeklyFormat}\n </label>\n </div> \n </div> \n </div>\n <div class='form-group'>\n <div class='col-sm-10 col-sm-offset-2' id='weeklyDates'>\n {$langStartDate} \n <input class='dateInForm form-control' type='text' name='start_date' value='" . ($c->start_date != "0000-00-00" ? $c->start_date : "") . "' readonly> \n {$langEndDate}\n <input class='dateInForm form-control' type='text' name='finish_date' value='" . ($c->finish_date != "0000-00-00" ? $c->finish_date : "") . "' readonly>\n </div>\n </div>"); if ($isOpenCourseCertified) { $tool_content .= "<input type='hidden' name='course_license' value='{$course_license}'>"; } $language = $c->lang; $tool_content .= " \n <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langOpenCoursesLicense}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input type='radio' name='l_radio' value='0'{$license_checked['0']}{$disabledVisibility}>\n {$license[0]['title']}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' name='l_radio' value='10'{$license_checked['10']}{$disabledVisibility}>\n {$license[10]['title']}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input id='cc_license' type='radio' name='l_radio' value='cc'{$cc_checked}{$disabledVisibility}>\n {$langCMeta['course_license']}\n </label>\n </div> \n </div> \n </div>\n <div class='form-group'>\n <div class='col-sm-10 col-sm-offset-2' id='cc'> \n " . selection($cc_license, 'cc_use', $course_license, 'class="form-control"' . $disabledVisibility) . "\n </div>\n </div>\n <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langConfidentiality}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input id='courseopen' type='radio' name='formvisible' value='2' {$visibleChecked['2']}>\n <img src='{$themeimg}/lock_open.png' alt='{$langOpenCourse}' title='{$langOpenCourse}' width='16'> {$langOpenCourse}\n <span class='help-block'><small>{$langPublic}</small></span>\n </label>\n </div>\n <div class='radio'>\n <label>\n <input id='coursewithregistration' type='radio' name='formvisible' value='1' {$visibleChecked['1']}>\n <img src='{$themeimg}/lock_registration.png' alt='{$m['legrestricted']}' title='{$m['legrestricted']}' width='16'> {$m['legrestricted']}\n <span class='help-block'><small>{$langPrivOpen}</small></span>\n </label>\n </div>\n <div class='radio'>\n <label>\n <input id='courseclose' type='radio' name='formvisible' value='0' {$visibleChecked['0']} {$disabledVisibility}>\n <img src='{$themeimg}/lock_closed.png' alt='{$langClosedCourse}' title='{$langClosedCourse}' width='16'> {$langClosedCourse}\n <span class='help-block'><small>{$langClosedCourseShort}</small></span>\n </label>\n </div>\n <div class='radio'>\n <label>\n <input id='courseinactive' type='radio' name='formvisible' value='3' {$visibleChecked['3']} {$disabledVisibility}>\n <img src='{$themeimg}/lock_inactive.png' alt='{$langInactiveCourse}' title='{$langInactiveCourse}' width='16'> {$langInactiveCourse}\n <span class='help-block'><small>{$langCourseInactiveShort}</small></span>\n </label>\n </div> \n </div> \n </div>\n <div class='form-group'>\n <label for='coursepassword' class='col-sm-2 control-label'>{$langOptPassword}:</label>\n <div class='col-sm-10'>\n <input class='form-control' id='coursepassword' type='text' name='password' value='" . @q($password) . "' class='FormData_InputText' autocomplete='off'>\n </div>\n </div> \n\t <div class='form-group'>\n <label for='Options' class='col-sm-2 control-label'>{$langLanguage}:</label>\n <div class='col-sm-10'>" . lang_select_options('localize', 'class="form-control"') . "</div>\t \n\t </div>\n <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langSharing}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input type='radio' value='1' name='s_radio' {$checkSharingEn} {$radio_dis}> {$langSharingEn}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' value='0' name='s_radio' {$checkSharingDis} {$radio_dis}> {$langSharingDis}\n <span class='help-block'><small>{$sharing_dis_label}</small></span> \n </label>\n </div> \n </div> \n </div>\n <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langRating}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input type='radio' value='1' name='r_radio' {$checkRatingEn}> {$langRatingEn}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' value='0' name='r_radio' {$checkRatingDis}> {$langRatingDis} \n </label>\n </div> \n </div>\n </div>\n <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langAnonymousRating}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input type='radio' value='1' name='ran_radio' {$checkEn} {$radio_dis}> {$langRatingAnonEn}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' value='0' name='ran_radio' {$checkDis} {$radio_dis}> {$langRatingAnonDis}\n <span class='help-block'><small>{$rating_dis_label}</small></span> \n </label>\n </div> \n </div> \n </div>\n <div class='form-group'>\n <label class='col-sm-2 control-label'>{$langCommenting}:</label>\n <div class='col-sm-10'>\n <div class='radio'>\n <label>\n <input type='radio' value='1' name='c_radio' {$checkEn}> {$langCommentsEn}\n </label>\n </div>\n <div class='radio'>\n <label>\n <input type='radio' value='0' name='c_radio' {$checkDis}> {$langCommentsDis} \n </label>\n </div> \n </div> \n </div>\n <div class='form-group'>\n <div class='col-sm-10 col-sm-offset-2'>\n <input class='btn btn-primary' type='submit' name='submit' value='{$langSubmit}'>\n </div>\n </div>\n </fieldset>\n </form>\n</div>"; } draw($tool_content, 2, null, $head_content);