*/ $require_current_course = true; $require_course_admin = true; $require_help = true; $helpTopic = 'User'; require_once '../../include/baseTheme.php'; require_once 'include/sendMail.inc.php'; require_once 'include/log.php'; $toolName = $langUsers; $pageName = $langAddUser; $navigation[] = array('url' => "index.php?course=$course_code", 'name' => $langUsers); if (isset($_GET['add'])) { $uid_to_add = intval(getDirectReference($_GET['add'])); $result = Database::get()->query("INSERT IGNORE INTO course_user (user_id, course_id, status, reg_date, document_timestamp) VALUES (?d, ?d, " . USER_STUDENT . ", " . DBHelper::timeAfter() . ", " . DBHelper::timeAfter(). ")", $uid_to_add, $course_id); Log::record($course_id, MODULE_ID_USERS, LOG_INSERT, array('uid' => $uid_to_add, 'right' => '+5')); if ($result) { Session::Messages( $langTheU . $langAdded, "alert alert-success"); //$tool_content .= "<div class='alert alert-success'>$langTheU $langAdded</div>"; // notify user via email $email = uid_to_email($uid_to_add); if (!empty($email) and email_seems_valid($email)) { $emailsubject = "$langYourReg " . course_id_to_title($course_id); $emailbody = "$langNotifyRegUser1 '" . course_id_to_title($course_id) . "' $langNotifyRegUser2 $langFormula \n$gunet"; send_mail('', '', '', $email, $emailsubject, $emailbody, $charset); }
/** * @brief Enter the modified info submitted from the category form into the database * @global type $course_id * @global type $langCategoryAdded * @global type $langCategoryModded * @global type $categoryname * @global type $description */ function submit_category() { global $course_id, $langCategoryAdded, $langCategoryModded, $categoryname, $description; register_posted_variables(array('categoryname' => true, 'description' => true), 'all', 'trim'); $set_sql = "SET name = ?s, description = ?s"; $terms = array($categoryname, purify($description)); if (isset($_POST['id'])) { $id = getDirectReference($_POST['id']); Database::get()->query("UPDATE `link_category` $set_sql WHERE course_id = ?d AND id = ?d", $terms, $course_id, $id); $log_type = LOG_MODIFY; } else { $order = Database::get()->querySingle("SELECT MAX(`order`) as maxorder FROM `link_category` WHERE course_id = ?d", $course_id)->maxorder; $order++; $id = Database::get()->query("INSERT INTO `link_category` $set_sql, course_id = ?d, `order` = ?d", $terms, $course_id, $order)->lastInsertID; $log_type = LOG_INSERT; } $txt_description = ellipsize(canonicalize_whitespace(strip_tags($description)), 50, '+'); Log::record($course_id, MODULE_ID_LINKS, $log_type, array('id' => $id, 'category' => $categoryname, 'description' => $txt_description)); }
/** * @brief insert grades for activity * @global string $tool_content * @global type $langGradebookEdit * @param type $gradebook_id * @param type $actID */ function insert_grades($gradebook_id, $actID) { global $tool_content, $langGradebookEdit, $gradebook, $langTheField, $course_code, $langFormErrors, $m; $errors = []; $v = new Valitron\Validator($_POST['usersgrade']); $v->addRule('emptyOrNumeric', function($field, $value, array $params) { if(is_numeric($value) || empty($value)) return true; }); foreach ($_POST['usersgrade'] as $userID => $userInp) { $v->rule('emptyOrNumeric', array("$userID")); $v->rule('min', array("$userID"), 0); $v->rule('max', array("$userID"), $gradebook->range); $v->labels(array( "$userID" => "$langTheField $m[grade]" )); } if($v->validate()) { foreach ($_POST['usersgrade'] as $userID => $userInp) { if ($userInp == '') { Database::get()->query("DELETE FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $actID, getDirectReference($userID)); } else { // //check if there is record for the user for this activity $checkForBook = Database::get()->querySingle("SELECT COUNT(id) AS count, id FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $actID, getDirectReference($userID)); if ($checkForBook->count) { // update Database::get()->query("UPDATE gradebook_book SET grade = ?f WHERE id = ?d", $userInp/$gradebook->range, $checkForBook->id); } else { // insert Database::get()->query("INSERT INTO gradebook_book SET uid = ?d, gradebook_activity_id = ?d, grade = ?f, comments = ?s", getDirectReference($userID), $actID, $userInp/$gradebook->range, ''); } } } } else { Session::flashPost()->Messages($langFormErrors)->Errors($v->errors()); redirect_to_home_page("modules/gradebook/index.php?course=$course_code&gradebook_id=".getIndirectReference($gradebook->id)."&ins=".getIndirectReference($actID)); } $message = "<div class='alert alert-success'>$langGradebookEdit</div>"; $tool_content .= $message . "<br/>"; }
} elseif (isset($_GET['editUsers'])) { // edit attendance users user_attendance_settings($attendance_id); $display = FALSE; } elseif (isset($_GET['editSettings'])) { // attendance settings attendance_settings($attendance_id); $display = FALSE; } elseif (isset($_GET['addActivityAs'])) { //display available assignments attendance_display_available_assignments($attendance_id); $display = FALSE; } elseif (isset($_GET['addActivityEx'])) { // display available exercises attendance_display_available_exercises($attendance_id); $display = FALSE; } //DISPLAY - EDIT DB: insert grades for each activity elseif (isset($_GET['ins'])) { $actID = intval(getDirectReference($_GET['ins'])); $error = false; if (isset($_POST['bookUsersToAct'])) { insert_presence($attendance_id, $actID); } // if (isset($_POST['updateUsersToAct'])) { // update_presence($attendance_id, $actID); // } register_user_presences($attendance_id, $actID); $display = FALSE; } } if (isset($display) and $display == TRUE) { // display attendance
if (isset($_POST['toolStatActive'])) { foreach ($_POST['toolStatActive'] as $mid_ref) { $mids[] = getDirectReference($mid_ref); } $placeholders = join(', ', array_fill(0, count($mids), '?d')); Database::get()->query("UPDATE course_module SET visible = 1 WHERE course_id = ?d AND module_id IN ($placeholders)", $course_id, $mids); } Log::record($course_id, MODULE_ID_TOOLADMIN, LOG_MODIFY, array()); Session::Messages($langRegDone, 'alert-success'); redirect_to_home_page($page_url); } if (isset($_GET['delete'])) { $delete = getDirectReference($_GET['delete']); $r = Database::get()->querySingle("SELECT url, title, category FROM link WHERE id = ?d", $delete); Database::get()->query("DELETE FROM link WHERE id = ?d", $delete); Log::record($course_id, MODULE_ID_TOOLADMIN, LOG_DELETE, array('id' => $delete, 'link' => $r->url, 'name_link' => $r->title)); Session::Messages($langLinkDeleted, 'alert-success'); redirect_to_home_page($page_url); } /** * Add external link */ if (isset($_POST['submit'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); $link = isset($_POST['link']) ? $_POST['link'] : '';
function processActions() { global $tool_content, $langResourceCourseUnitDeleted, $course_id, $course_code; if (isset($_REQUEST['del'])) { // delete resource from course unit $res_id = intval(getDirectReference($_REQUEST['del'])); Database::get()->query("DELETE FROM course_description WHERE id = ?d AND course_id = ?d", $res_id, $course_id); CourseXMLElement::refreshCourse($course_id, $course_code); Session::Messages($langResourceCourseUnitDeleted, "alert-success"); redirect_to_home_page("modules/course_description/index.php?course=$course_code"); } elseif (isset($_REQUEST['vis'])) { // modify visibility in text resources only $res_id = intval(getDirectReference($_REQUEST['vis'])); $vis = Database::get()->querySingle("SELECT `visible` FROM course_description WHERE id = ?d AND course_id = ?d", $res_id, $course_id); $newvis = (intval($vis->visible) === 1) ? 0 : 1; Database::get()->query("UPDATE course_description SET `visible` = ?d, update_dt = NOW() WHERE id = ?d AND course_id = ?d", $newvis, $res_id, $course_id); CourseXMLElement::refreshCourse($course_id, $course_code); redirect_to_home_page("modules/course_description/index.php?course=$course_code"); } elseif (isset($_REQUEST['down'])) { // change order down $res_id = intval(getDirectReference($_REQUEST['down'])); move_order('course_description', 'id', $res_id, 'order', 'down', "course_id = $course_id"); redirect_to_home_page("modules/course_description/index.php?course=$course_code"); } elseif (isset($_REQUEST['up'])) { // change order up $res_id = intval(getDirectReference($_REQUEST['up'])); move_order('course_description', 'id', $res_id, 'order', 'up', "course_id = $course_id"); redirect_to_home_page("modules/course_description/index.php?course=$course_code"); } }
} } } elseif (isset($_REQUEST['up'])) { // change order up $id = intval(getDirectReference($_REQUEST['up'])); if ($course_info->view_type == 'units' or $course_info->view_type == 'simple') { move_order('course_units', 'id', $id, 'order', 'up', "course_id=$course_id"); } else { $res_id = intval(getDirectReference($_REQUEST['up'])); if (($id = check_admin_unit_resource($res_id))) { move_order('course_weekly_view_activities', 'id', $res_id, 'order', 'up', "course_weekly_view_id=$id"); } } } 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>' : '';
category_id = ?d", $course_id, $cat_id); Session::Messages($langCategoryDeletedGlossary, 'alert-success'); redirect_to_home_page("modules/glossary/categories.php?course=$course_code"); } } // display form for adding or editing a category if (isset($_GET['add']) or isset($_GET['edit'])) { $html_id = ''; if (isset($_GET['add'])) { $pageName = $langCategoryAdd; $submit_value = $langSubmit; } else { $pageName = $langCategoryMod; $cat_id = intval(getDirectReference($_GET['edit'])); $data = Database::get()->querySingle("SELECT name, description FROM glossary_category WHERE id = ?d", $cat_id); if ($data) { $html_id = "<input type = 'hidden' name='category_id' value='" . getIndirectReference($cat_id) . "'>"; } $submit_value = $langModify; } $name = Session::has('name') ? Session::get('name') : ( isset($_GET['add']) ? "" : q($data->name) ); $description = Session::has('description') ? Session::get('description') : ( isset($_GET['add']) ? "" : q($data->description) ); $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' action='$cat_url' method='post'> $html_id <div class='form-group".(Session::getError('name') ? " has-error" : "")."'> <label for='name' class='col-sm-2 control-label'>$langCategoryName: </label> <div class='col-sm-10'> <input type='text' class='form-control' id='term' name='name' placeholder='$langCategoryName' value='$name'>
/** * @brief add other attendance activity * @global type $tool_content * @global type $course_code * @global type $langTitle * @global type $langAttendanceInsAut * @global type $langAdd * @global type $langAdd * @global type $langSave * @global type $langAttendanceActivityDate * @param type $attendance_id */ function add_attendance_other_activity($attendance_id) { global $tool_content, $course_code, $langDescription, $langTitle, $langAttendanceInsAut, $langAdd, $langAdd, $langSave, $langAttendanceActivityDate; $date_error = Session::getError('date'); $tool_content .= "<div class='row'> <div class='col-sm-12'> <div class='form-wrapper'> <form class='form-horizontal' role='form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&attendance_id=$attendance_id'> <fieldset>"; if (isset($_GET['modify'])) { // modify an existing attendance activity $id = filter_var(getDirectReference($_GET['modify']), FILTER_VALIDATE_INT); //All activity data (check if it's in this attendance) $modifyActivity = Database::get()->querySingle("SELECT * FROM attendance_activities WHERE id = ?d AND attendance_id = ?d", $id, $attendance_id); //if ($modifyActivity) { $titleToModify = Session::has('actTitle') ? Session::get('actTitle') : $modifyActivity->title; $contentToModify = Session::has('actDesc') ? Session::get('actDesc') : $modifyActivity->description; $attendanceActivityToModify = $id; $date = Session::has('date') ? Session::get('date') : $modifyActivity->date; $module_auto_id = $modifyActivity->module_auto_id; $auto = $modifyActivity->auto; } else { //new activity $attendanceActivityToModify = ""; $titleToModify = Session::has('actTitle') ? Session::get('actTitle') : ''; $contentToModify = Session::has('actDesc') ? Session::get('actDesc') : ''; $date = Session::has('date') ? Session::get('date') : ''; } if (!isset($contentToModify)) $contentToModify = ""; @$tool_content .= " <div class='form-group'> <label for='actTitle' class='col-sm-2 control-label'>$langTitle:</label> <div class='col-sm-10'> <input type='text' class='form-control' name='actTitle' value='$titleToModify'/> </div> </div> <div class='form-group".($date_error ? " has-error" : "")."'> <label for='date' class='col-sm-2 control-label'>$langAttendanceActivityDate:</label> <div class='col-sm-10'> <input type='text' class='form-control' name='date' id='startdatepicker' value='" . datetime_remove_seconds($date) . "'/> <span class='help-block'>$date_error</span> </div> </div> <div class='form-group'> <label for='actDesc' class='col-sm-2 control-label'>$langDescription:</label> <div class='col-sm-10'> " . rich_text_editor('actDesc', 4, 20, $contentToModify) . " </div> </div>"; if (isset($module_auto_id) && $module_auto_id != 0) { //accept the auto attendance mechanism $tool_content .= "<div class='form-group'> <label for='weight' class='col-sm-2 control-label'>$langAttendanceInsAut:</label> <div class='col-sm-10'><input type='checkbox' value='1' name='auto' "; if ($auto) { $tool_content .= " checked"; } $tool_content .= "/></div>"; } $tool_content .= "<div class='form-group'> <div class='col-sm-10 col-sm-offset-2'>".form_buttons(array( array( 'text' => $langSave, 'name' => 'submitAttendanceActivity', 'value'=> $langAdd ), array( 'href' => "$_SERVER[SCRIPT_NAME]?course=$course_code" ) ))."</div></div>"; if (isset($_GET['modify'])) { $tool_content .= "<input type='hidden' name='id' value='" . $attendanceActivityToModify . "'>"; } else { $tool_content .= " <input type='hidden' name='id' value=''>"; } $tool_content .= "</fieldset> </form> </div> </div> </div>"; }
$sendSep = true; } else { $charset = 'UTF-8'; $sendSep = false; } $crlf = "\r\n"; header("Content-Type: text/csv; charset=$charset"); header("Content-Disposition: attachment; filename=list_gradebook_users.csv"); if ($sendSep) { echo 'sep=;', $crlf; } $sql = Database::get()->queryArray("SELECT id, title FROM gradebook_activities WHERE gradebook_id = ?d", getDirectReference($_GET['gradebook_id'])); foreach ($sql as $act) { $title = !empty($act->title) ? $act->title : $langGradebookNoTitle; echo csv_escape($title). "$crlf"; echo join(';', array_map("csv_escape", array($langSurname, $langName, $langAm, $langUsername, $langEmail, $langGradebookGrade))); echo $crlf; $sql2 = Database::get()->queryArray("SELECT uid, grade FROM gradebook_book WHERE gradebook_activity_id = ?d", $act->id); foreach ($sql2 as $u) { $userdata = Database::get()->querySingle("SELECT surname, givenname, username, am, email FROM user WHERE id = ?d", $u->uid); echo join(';', array_map("csv_escape", array($userdata->surname, $userdata->givenname, $userdata->am, $userdata->username, $userdata->email, $u->grade))); echo "$crlf"; } echo "$crlf"; echo "$crlf"; }
WHERE user_id = ?d", $privilege, $user_id)->affectedRows; } else { $affected = Database::get()->query("INSERT INTO admin VALUES(?d,?d)", $user_id, $privilege)->affectedRows; } if ($affected > 0) { $tool_content .= "<div class='alert alert-success'> $langTheUser " . q($username) . " $langWith id=" . q($user_id) . " $langDone</div>"; } } else { $tool_content .= "<div class='alert alert-danger'>$langError</div>"; } } else { $tool_content .= "<div class='alert alert-danger'>$langTheUser " . q($username) . " $langNotFound.</div>"; } } else if (isset($_GET['delete'])) { // delete admin users $aid = intval(getDirectReference($_GET['aid'])); if ($aid != 1) { // admin user (with id = 1) cannot be deleted if (Database::get()->query("DELETE FROM admin WHERE admin.user_id = ?d", $aid)->affectedRows > 0) { $tool_content .= "<div class='alert alert-success'>$langNotAdmin</div>"; } else { $tool_content .= "<div class='alert alert-danger'>$langDeleteAdmin" . q($aid) . " $langNotFeasible</p>"; } } else { $tool_content .= "<div class='alert alert-danger'>$langCannotDeleteAdmin</div>"; } } $tool_content .= printform($langUsername); $tool_content .= "<table class='table-default'> <tr>
} else { $tool_content .= "<div class='alert alert-danger'>$langFileNotFound</div>"; } } elseif (isset($_POST['create_restored_course'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); register_posted_variables(array('restoreThis' => true, 'course_code' => true, 'course_lang' => true, 'course_title' => true, 'course_desc' => true, 'course_vis' => true, 'course_prof' => true), 'all'); create_restored_course($tool_content, getDirectReference($restoreThis) , $course_code, $course_lang, $course_title, $course_desc, $course_vis, $course_prof); } elseif (isset($_POST['do_restore'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); $base = getDirectReference($_POST['restoreThis']); if (!file_exists($base . '/config_vars')) { $tool_content .= "<div class='alert alert-warning'>$langInvalidArchive</div>"; draw($tool_content, 3); exit; } if (($data = get_serialized_file('course'))) { // 3.0-style backup $data = $data[0]; if (isset($data['fake_code'])) { $data['public_code'] = $data['fake_code']; } $hierarchy = get_serialized_file('hierarchy'); $course_units = get_serialized_file('course_units'); $unit_resources = get_serialized_file('unit_resources'); if (isset($data['description'])) {
$c = Database::get()->querySingle("SELECT sessionUsers FROM bbb_session where meeting_id=?s",$_GET['meeting_id']); $sess = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id']); $serv = Database::get()->querySingle("SELECT * FROM bbb_servers WHERE id=?d", $sess->running_at); if( ($c->sessionUsers > 0) && ($c->sessionUsers < get_meeting_users($serv->server_key,$serv->api_url,$_GET['meeting_id'],$sess->mod_pw))) { $tool_content .= "<div class='alert alert-warning'>$langBBBMaxUsersJoinError</div>"; break; } else { header('Location: ' . bbb_join_user($_GET['meeting_id'],$_GET['att_pw'],$_SESSION['surname'],$_SESSION['givenname'])); } } break; case 'import_video': publish_video_recordings($course_code,getDirectReference($_GET['id'])); break; } } elseif(isset($_POST['new_bbb_session'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); $startDate_obj = DateTime::createFromFormat('d-m-Y H:i', $_POST['start_session']); $start = $startDate_obj->format('Y-m-d H:i:s'); //add_bbb_session($course_id,$_POST['title'], $_POST['desc'], $start, $_POST['type'] ,$_POST['status'],(isset($_POST['notifyUsers']) ? '1' : '0'),$_POST['minutes_before'],$_POST['external_users'], $_POST['record'], $_POST['sessionUsers']); add_bbb_session($course_id,$_POST['title'], $_POST['desc'], $start, '0' ,$_POST['status'],(isset($_POST['notifyUsers']) ? '1' : '0'),$_POST['minutes_before'],$_POST['external_users'], $_POST['record'], $_POST['sessionUsers']); Session::Messages($langBBBAddSuccessful, 'alert-success'); redirect_to_home_page("modules/bbb/index.php?course=$course_code"); } else { bbb_session_details(); }
$tool_content .="<input type='hidden' name='id' value='" . getIndirectReference($noteToModify)."' />"; } $tool_content .="</fieldset> </form></div>"; } elseif (isset($_GET['nid'])) { $tool_content .= action_bar(array( array( 'title' => $langBack, 'level' => 'primary-label', 'icon' => 'fa-reply', 'url' => $_SERVER['SCRIPT_NAME'] ) )); $note = Notes::get_note(intval(getDirectReference($_GET['nid']))); $navigation[] = array("url" => "$_SERVER[SCRIPT_NAME]", "name" => $langNotes); $pageName = q($note->title); $tool_content .= " <div class='panel panel-action-btn-default'> <div class='panel-heading'> <div class='pull-right'>". action_button(array( array('title' => $langEditChange, 'url' => "$_SERVER[SCRIPT_NAME]?modify=".getIndirectReference($note->id), 'icon' => 'fa-edit'), array('title' => $langDelete, 'url' => "$_SERVER[SCRIPT_NAME]?delete=".getIndirectReference($note->id), 'confirm' => $langSureToDelNote, 'class' => 'delete', 'icon' => 'fa-times')
include '../../include/baseTheme.php'; load_js('tools.js'); $toolName = $langMyProfile; $pageName = $langEmailUnsubscribe; $navigation[] = array('url' => 'display_profile.php', 'name' => $langMyProfile); check_uid(); if (isset($_POST['submit'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); if (isset($_POST['unsub'])) { Database::get()->query("UPDATE user SET receive_mail = 1 WHERE id = ?d", $uid); } if (isset($_POST['cid'])) { // change email subscription for one course $cid = intval(getDirectReference($_POST['cid'])); if (isset($_POST['c_unsub'])) { Database::get()->query("UPDATE course_user SET receive_mail = 1 WHERE user_id = ?d AND course_id = ?d", $uid, $cid); } else { Database::get()->query("UPDATE course_user SET receive_mail = 0 WHERE user_id = ?d AND course_id = ?d", $uid, $cid); } $course_title = course_id_to_title($cid); $message = q(sprintf($course_title, $langEmailUnsubSuccess)); Session::Messages($message, "alert-success"); } else { // change email subscription for all courses foreach ($_SESSION['courses'] as $course_code => $c_value) { if (@array_key_exists($course_code, $_POST['c_unsub'])) { Database::get()->query("UPDATE course_user SET receive_mail = 1 WHERE user_id = ?d AND course_id = " . course_code_to_id($course_code), $uid);
$require_usermanage_user = true; include '../../include/baseTheme.php'; $toolName = $langUnregUser; $navigation[] = array('url' => 'index.php', 'name' => $langAdmin); $pageName = $langConfirmDelete; $tool_content .= action_bar(array( array('title' => $langBackAdmin, 'url' => "index.php", 'icon' => 'fa-reply', 'level' => 'primary-label'))); // get the incoming values and initialize them if (isset($_GET['u'])) { $user = getDirectReference($_GET['u']); $iuid = $_GET['u']; } else { forbidden(); } if ($user) { $u_account = q(uid_to_name($user, 'username')); $u_realname = q(uid_to_name($user)); $u_desc = "<em>$u_realname ($u_account)</em>"; } if (!isset($_POST['doit'])) { if ($user) { if (get_admin_rights($user) > 0) { $tool_content .= "<div class='alert alert-warning'>" .
/** * Indirect reference to direct reference, Delete any relevant record * * @param string * @return object reference */ function getAndUnsetDirectReference($indirectReference) { $direct = getDirectReference($indirectReference); getIndirectReferencesMap()->offsetUnset($indirectReference); getDirectReferencesMap()->offsetUnset(directHash($direct)); return $direct; }
} Session::Messages($langAutoEnrollAdded, 'alert-success'); if (isset($_POST['apply'])) { apply_autoenroll($rule); Session::Messages($langRuleApplied, 'alert-info'); } redirect_to_home_page('modules/admin/autoenroll.php'); } elseif (isset($_GET['add']) or isset($_GET['edit'])) { load_js('jstree3'); load_js('select2'); $pageName = isset($_GET['add'])? $langAutoEnrollNew: $langEditChange; $navigation[] = array('url' => 'autoenroll.php', 'name' => $langAutoEnroll); if (isset($_GET['edit'])) { if (!($rule = getDirectReference($_GET['edit']))) { forbidden(); } $q = Database::get()->querySingle('SELECT * FROM autoenroll_rule WHERE id = ?d', $rule); $type = $q->status; $department = array_map(function ($item) { return $item->department; }, Database::get()->queryArray( 'SELECT department FROM autoenroll_rule_department WHERE rule = ?d', $rule)); $courses = implode(',', array_map(function ($course) { return "{id: {$course->course_id}, text: '" . js_escape($course->title . ' (' . $course->public_code . ')') . "'}";
if (isset($_POST['submit'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); if (empty($_POST['title'])) { $tool_content .= "<div class='alert alert-danger'>$langNoCourseTitle</div> <p>« <a href='$_SERVER[SCRIPT_NAME]?course=$course_code'>$langAgain</a></p>"; } else { // update course settings if (isset($_POST['formvisible']) and ( $_POST['formvisible'] == '1' or $_POST['formvisible'] == '2')) { $password = $_POST['password']; } else { $password = ""; } // if it is opencourses certified keeep the current course_license if (isset($_POST['course_license'])) { $course_license = getDirectReference($_POST['course_license']); } // update course_license if (isset($_POST['l_radio'])) { $l = $_POST['l_radio']; switch ($l) { case 'cc': if (isset($_POST['cc_use'])) { $course_license = intval($_POST['cc_use']); } break; case '10': $course_license = 10; break; default: $course_license = 0;
</form> </div>"; } } } } } if (isset($_GET['down'])) { move_order('link', 'id', intval(getDirectReference($_GET['down'])), 'order', 'down', "course_id = $course_id"); } elseif (isset($_GET['up'])) { move_order('link', 'id', intval(getDirectReference($_GET['up'])), 'order', 'up', "course_id = $course_id"); } elseif (isset($_GET['cdown'])) { move_order('link_category', 'id', intval(getDirectReference($_GET['cdown'])), 'order', 'down', "course_id = $course_id"); } elseif (isset($_GET['cup'])) { move_order('link_category', 'id', intval(getDirectReference($_GET['cup'])), 'order', 'up', "course_id = $course_id"); } $display_tools = $is_editor && !$is_in_tinymce; if (!in_array($action, array('addlink', 'editlink', 'addcategory', 'editcategory', 'settings'))) { if ($social_bookmarks_enabled == 1) { $countlinks = Database::get()->querySingle("SELECT COUNT(*) AS cnt FROM `link` WHERE course_id = ?d AND category <> ?d", $course_id, -1)->cnt; } else { $countlinks = Database::get()->querySingle("SELECT COUNT(*) AS cnt FROM `link` WHERE course_id = ?d AND category <> ?d AND category <> ?d", $course_id, -1, -2)->cnt; } if ($countlinks > 0) { $numberofzerocategory = count(Database::get()->queryArray("SELECT * FROM `link` WHERE course_id = ?d AND (category = 0 OR category IS NULL)", $course_id)); // making the show none / show all links. Show none means urlview=0000 (number of zeros depending on the // number of categories). Show all means urlview=1111 (number of 1 depending on teh number of categories). $resultcategories = Database::get()->queryArray("SELECT * FROM `link_category` WHERE course_id = ?d ORDER BY `order`", $course_id); $aantalcategories = count($resultcategories);
AND course_id = ?d", $removed_tutor_gid, $course_id); } elseif (isset($_GET['removeEditor'])) { $removed_editor_gid = intval(getDirectReference($_GET['removeEditor'])); Database::get()->query("UPDATE course_user SET editor = 0 WHERE user_id = ?d AND course_id = ?d", $removed_editor_gid, $course_id); } if (get_config('opencourses_enable')) { if (isset($_GET['giveReviewer'])) { $new_reviewr_gid = intval(getDirectReference($_GET['giveReviewer'])); Database::get()->query("UPDATE course_user SET status = " . USER_TEACHER . ", reviewer = 1 WHERE user_id = ?d AND course_id = ?d", $new_reviewr_gid, $course_id); } elseif (isset($_GET['removeReviewer'])) { $removed_reviewer_gid = intval(getDirectReference($_GET['removeReviewer'])); Database::get()->query("UPDATE course_user SET status = " . USER_STUDENT . ", reviewer = 0 WHERE user_id <> ?d AND user_id = ?d AND course_id = ?d", $uid, $removed_reviewer_gid, $course_id); } } // show help link and link to Add new user, search new user and management page of groups $tool_content .= action_bar(array( array('title' => $langOneUser, 'url' => "adduser.php?course=$course_code", 'icon' => 'fa-plus-circle', 'button-class' => 'btn-success', 'level' => 'primary-label'),
$require_current_course = TRUE; $require_help = TRUE; $helpTopic = 'Coursedescription'; $require_login = true; $require_editor = true; require_once '../../include/baseTheme.php'; require_once 'include/lib/textLib.inc.php'; require_once 'include/log.php'; $toolName = $langCourseDescription; $pageName = $langEditCourseProgram; $navigation[] = array('url' => 'index.php?course=' . $course_code, 'name' => $langCourseProgram); if (isset($_REQUEST['id'])) { $editId = intval(getDirectReference($_REQUEST['id'])); $q = Database::get()->querySingle("SELECT title, comments, type FROM course_description WHERE course_id = ?d AND id = ?d", $course_id, $editId); $cdtitle = Session::has('editTitle') ? Session::get('editTitle') : $q->title; $comments = Session::has('editComments') ? Session::get('editComments') : $q->comments; $defaultType = Session::has('editType') ? Session::get('editType') : $q->type; } else { $editId = false; $cdtitle = Session::has('editTitle') ? Session::get('editTitle') : ""; $comments = Session::has('editComments') ? Session::get('editComments') : ""; $defaultType = Session::has('editType') ? Session::get('editType') : ""; } $q = Database::get()->queryArray("SELECT id, title FROM course_description_type ORDER BY `order`"); $types = array(); $types[''] = ''; foreach ($q as $type) {
/* * *********************************************** // display glossary * *********************************************** */ $where = ''; $terms = array(); if (isset($_GET['edit'])) { $where = "AND id = ?d"; $terms[] = intval($id); } elseif (isset($_GET['id'])) { $navigation[] = array('url' => $base_url, 'name' => $langGlossary); $where = "AND id = ?d"; $terms[] = intval(getDirectReference($_GET['id'])); } elseif (isset($_GET['prefix'])) { $where = "AND term LIKE ?s"; $terms[] = $_GET['prefix'] . '%'; } elseif ($glossary_index and ! $cat_id and count($prefixes) > 1) { $where = "AND term LIKE ?s"; $terms[] = $prefixes[0] . '%'; } if(!isset($_GET['add']) && !isset($_GET['edit']) && !isset($_GET['config'])) { if ($glossary_index and count($prefixes) > 1) { $tool_content .= "<div class='alphabetic_index'>"; $begin = true; foreach ($prefixes as $letter) { $active = (!isset($_GET['prefix']) && !$cat_id && $begin) || (isset($_GET['prefix']) and $_GET['prefix'] == $letter);
function submit_category() { global $course_id, $langCategoryAdded, $langCategoryModded, $categoryname, $description, $langFormErrors, $course_code; register_posted_variables(array('categoryname' => true, 'description' => true), 'all', 'trim'); $set_sql = "SET name = ?s, description = ?s"; $terms = array($categoryname, purify($description)); $v = new Valitron\Validator($_POST); $v->rule('required', array('categoryname')); if($v->validate()) { if (isset($_POST['id'])) { $id = getDirectReference($_POST['id']); Database::get()->query("UPDATE `group_category` $set_sql WHERE course_id = ?d AND id = ?d", $terms, $course_id, $id); $log_type = LOG_MODIFY; } else { $id = Database::get()->query("INSERT INTO `group_category` $set_sql, course_id = ?d", $terms, $course_id)->lastInsertID; $log_type = LOG_INSERT; } $txt_description = ellipsize(canonicalize_whitespace(strip_tags($description)), 50, '+'); Log::record($course_id, MODULE_ID_LINKS, $log_type, array('id' => $id, 'category' => $categoryname, 'description' => $txt_description)); } else { Session::flashPost()->Messages($langFormErrors)->Errors($v->errors()); redirect_to_home_page("modules/group/group_category.php?course=$course_code&addcategory=1"); } }