function delete_tab($id_tab) { $info_fields_into_tab = find_all_field_by_tab($id_tab); if (isset($info_fields_into_tab) and $info_fields_into_tab != '') { $result = delete_field($info_fields_into_tab); } else { $result = true; } if ($result) { $id_tab = prepare_id($id_tab); if (is_array($id_tab)) { $sql_downloadwk_tab_values = "DELETE FROM downloadwk_tab_values WHERE ID in "; $downloadwk_tab_values = mysql2_prepare($sql_downloadwk_tab_values, array(), $id_tab); mysql2_query_secure($downloadwk_tab_values['SQL'], $_SESSION['OCS']["writeServer"], $downloadwk_tab_values['ARG']); addLog('DEL_WK_TELEDIFF', 'delete TAB (downloadwk_tab_values) => ' . mysql_affected_rows() . ' values'); } } }
} $fields = implode(',', $array_fields); if ($protectedPost['onglet'] == 1) { $tab_options['CACHE'] = 'RESET'; if (isset($protectedPost['del_check']) and $protectedPost['del_check'] != '') { $post_delete = $protectedPost['del_check']; } if (isset($protectedPost['SUP_PROF']) and $protectedPost['SUP_PROF'] != '') { $post_delete = $protectedPost['SUP_PROF']; } if (isset($post_delete)) { if ($table == "downloadwk_tab_values") { delete_tab($post_delete); } if ($table == "downloadwk_fields") { delete_field($post_delete); } if ($table == "downloadwk_conf_values") { delete_conf($post_delete); } } $queryDetails = "select ID," . $fields . " from " . $table . " where " . $field_search . "='%s' \n\t\t\t\t\tand (default_field is null or default_field=0) "; $argDetail = $protectedGet['value']; $resTypes = mysql2_query_secure($queryDetails, $_SESSION['OCS']["readServer"], $argDetail); $valTypes = mysql_fetch_array($resTypes); if (is_array($valTypes)) { $tab_options['ARG_SQL'] = $protectedGet['value']; if (!isset($protectedPost['SHOW'])) { $protectedPost['SHOW'] = 'NOSHOW'; } if (!isset($protectedPost["pcparpage"])) {
function reset_jawaban($tugas_id, $siswa_id) { # jika pengajar atau admin if (is_pengajar() or is_admin()) { $tugas_id = (int) $tugas_id; $tugas = $this->tugas_model->retrieve($tugas_id); if (empty($tugas)) { redirect('tugas'); } $siswa = $this->siswa_model->retrieve($siswa_id); if (empty($siswa)) { redirect('tugas'); } # hapus history $history_id = 'history-mengerjakan-' . $siswa['id'] . '-' . $tugas['id']; delete_field($history_id); # hapus nilai $retrieve_nilai = $this->tugas_model->retrieve_nilai(null, $tugas['id'], $siswa['id']); $this->tugas_model->delete_nilai($retrieve_nilai['id']); $this->session->set_flashdata('tugas', get_alert('success', 'Siswa berhasil dianggap belum mengerjakan.')); redirect('tugas/nilai/' . $tugas['id']); } else { $this->session->set_flashdata('tugas', get_alert('warning', 'Akses ditolak.')); redirect('tugas'); } }
if ($choice == "Add") { $error_msg = ""; if (empty($field_name)) { $error_msg .= "The field needs a name. <BR>"; } if ($error_msg != "") { include "add_field.php"; exit; } else { add_field($field_name); } } } else { if ($action == "delete") { $id = filter_input(INPUT_GET, "id"); delete_field($id); } else { if ($action == "edit") { $field = get_field(filter_input(INPUT_GET, "id")); include "edit_field.php"; exit; } else { if ($action == "edit_field") { $choice = filter_input(INPUT_POST, "choice"); $field_name = filter_input(INPUT_POST, "field_name"); $field_id = filter_input(INPUT_POST, "field_id"); if ($choice == "Make Changes") { $error_msg = ""; if (empty($field_name)) { $error_msg .= "A field name is required. <BR>"; }
function reset_jawaban($tugas_id, $siswa_id) { # jika pengajar atau admin if (is_pengajar() or is_admin()) { $tugas_id = (int) $tugas_id; $tugas = $this->tugas_model->retrieve($tugas_id); if (empty($tugas)) { redirect('tugas'); } $siswa = $this->siswa_model->retrieve($siswa_id); if (empty($siswa)) { redirect('tugas'); } # hapus history $history_id = 'history-mengerjakan-' . $siswa['id'] . '-' . $tugas['id']; $history = retrieve_field($history_id); $history_value = json_decode($history['value'], 1); delete_field($history_id); # hapus nilai $retrieve_nilai = $this->tugas_model->retrieve_nilai(null, $tugas['id'], $siswa['id']); $this->tugas_model->delete_nilai($retrieve_nilai['id']); $this->session->set_flashdata('tugas', get_alert('success', 'Siswa berhasil dianggap belum mengerjakan.')); if ($tugas['type_id'] == 3) { redirect('tugas/nilai/' . $tugas['id']); } else { # jika tugas upload, dihapus juga file uploadnya biar g menuh-menuhin space if ($tugas['type_id'] == 1 && is_file(get_path_file($history_value['file_name']))) { @unlink(get_path_file($history_value['file_name'])); } redirect('tugas/koreksi/' . $tugas['id']); } } else { $this->session->set_flashdata('tugas', get_alert('warning', 'Akses ditolak.')); redirect('tugas'); } }
$NEW_FIELD = "NO"; $_REQUEST['field_id'] = $id; } else { echo "<font color='#ff0000'><b>ERROR!</b></font><br>" . $error . ''; } } if ($_REQUEST['delete'] != '') { echo "Deleting..."; $sql = "SELECT * FROM form_fields WHERE form_id=1 and field_id='" . $_REQUEST['field_id'] . "'"; $result = mysql_query($sql); $row = mysql_fetch_array($result) or die(mysql_error()); if (is_reserved_template_tag($row['template_tag'])) { echo "<p><font color='red'><b>Cannot Delete:</b> This field contains a reserved 'Template Tag' and is needed by the system. Click on the 'R' icon next to the field for more information. Instead of deleting, please rename this field / change the type / move up or down. </font></p> "; } else { echo "Deleting..."; delete_field($_REQUEST['field_id']); echo "OK!"; $_REQUEST['field_id'] = ""; } } if (is_table_unsaved("ads")) { //echo "<br>Note: This form's database structure was not updated yet. <b>Please click 'Save Changes' button to update the database structure.</b>"; require 'build_ads_table.php'; } //$mode = "EDIT"; ?> <table> <tr> <td valign="top"> <?php
Database::get()->query('UPDATE annonces SET course_id = (SELECT course_id FROM cours WHERE code = annonces.code_cours) WHERE course_id = 0'); Database::get()->query('ALTER TABLE annonces DROP code_cours'); } } if (version_compare($oldversion, '2.3.1', '<')) { if (!DBHelper::fieldExists('prof_request', 'am')) { Database::get()->query('ALTER TABLE `prof_request` ADD `am` VARCHAR(20) NULL AFTER profcomm'); } } Database::get()->query("INSERT IGNORE INTO `auth` VALUES (7, 'cas', '', '', 0)"); DBHelper::fieldExists('user', 'email_public') or Database::get()->query("ALTER TABLE `user`\n ADD `email_public` TINYINT(1) NOT NULL DEFAULT 0,\n ADD `phone_public` TINYINT(1) NOT NULL DEFAULT 0,\n ADD `am_public` TINYINT(1) NOT NULL DEFAULT 0"); if (version_compare($oldversion, '2.4', '<')) { if (DBHelper::fieldExists('cours', 'faculte')) { delete_field('cours', 'faculte'); updateInfo(-1, $langDeleteField); } Database::get()->query("ALTER TABLE user CHANGE lang lang VARCHAR(16) NOT NULL DEFAULT 'el'"); DBHelper::fieldExists('annonces', 'visibility') or Database::get()->query("ALTER TABLE `annonces` ADD `visibility` CHAR(1) NOT NULL DEFAULT 'v'"); DBHelper::fieldExists('user', 'description') or Database::get()->query("ALTER TABLE `user` ADD description TEXT,\n ADD has_icon BOOL NOT NULL DEFAULT 0"); DBHelper::fieldExists('user', 'verified_mail') or Database::get()->query("ALTER TABLE `user` ADD verified_mail BOOL NOT NULL DEFAULT " . EMAIL_UNVERIFIED . ",\n ADD receive_mail BOOL NOT NULL DEFAULT 1"); DBHelper::fieldExists('course_user', 'receive_mail') or Database::get()->query("ALTER TABLE `course_user` ADD receive_mail BOOL NOT NULL DEFAULT 1"); Database::get()->query("CREATE TABLE IF NOT EXISTS `document` (\n `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `course_id` INT(11) NOT NULL,\n `subsystem` TINYINT(4) NOT NULL,\n `subsystem_id` INT(11) DEFAULT NULL,\n `path` VARCHAR(255) NOT NULL,\n `filename` VARCHAR(255) NOT NULL,\n `visibility` CHAR(1) NOT NULL DEFAULT 'v',\n `comment` TEXT,\n `category` TINYINT(4) NOT NULL DEFAULT 0,\n `title` TEXT,\n `creator` TEXT,\n `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n `date_modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n `subject` TEXT,\n `description` TEXT,\n `author` VARCHAR(255) NOT NULL DEFAULT '',\n `format` VARCHAR(32) NOT NULL DEFAULT '',\n `language` VARCHAR(16) NOT NULL DEFAULT '',\n `copyrighted` TINYINT(4) NOT NULL DEFAULT 0,\n FULLTEXT KEY `document`\n (`filename`, `comment`, `title`, `creator`,\n `subject`, `description`, `author`, `language`)) {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS `group_properties` (\n `course_id` INT(11) NOT NULL PRIMARY KEY ,\n `self_registration` TINYINT(4) NOT NULL DEFAULT 1,\n `multiple_registration` TINYINT(4) NOT NULL DEFAULT 0,\n `allow_unregister` TINYINT(4) NOT NULL DEFAULT 0,\n `forum` TINYINT(4) NOT NULL DEFAULT 1,\n `private_forum` TINYINT(4) NOT NULL DEFAULT 0,\n `documents` TINYINT(4) NOT NULL DEFAULT 1,\n `wiki` TINYINT(4) NOT NULL DEFAULT 0,\n `agenda` TINYINT(4) NOT NULL DEFAULT 0) {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS `group` (\n `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `course_id` INT(11) NOT NULL DEFAULT 0,\n `name` varchar(100) NOT NULL DEFAULT '',\n `description` TEXT,\n `forum_id` INT(11) NULL,\n `max_members` INT(11) NOT NULL DEFAULT 0,\n `secret_directory` varchar(30) NOT NULL DEFAULT '0') {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS `group_members` (\n `group_id` INT(11) NOT NULL,\n `user_id` INT(11) NOT NULL,\n `is_tutor` INT(11) NOT NULL DEFAULT 0,\n `description` TEXT,\n PRIMARY KEY (`group_id`, `user_id`)) {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS `glossary` (\n `id` MEDIUMINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `term` VARCHAR(255) NOT NULL,\n `definition` text NOT NULL,\n `url` text,\n `order` INT(11) NOT NULL DEFAULT 0,\n `datestamp` DATETIME NOT NULL,\n `course_id` INT(11) NOT NULL) {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS `link` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `course_id` INT(11) NOT NULL,\n `url` VARCHAR(255),\n `title` VARCHAR(255),\n `description` TEXT NOT NULL,\n `category` INT(6) DEFAULT 0 NOT NULL,\n `order` INT(6) DEFAULT 0 NOT NULL,\n `hits` INT(6) DEFAULT 0 NOT NULL,\n PRIMARY KEY (`id`, `course_id`)) {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS `link_category` (\n `id` INT(6) NOT NULL AUTO_INCREMENT,\n `course_id` INT(11) NOT NULL,\n `name` VARCHAR(255) NOT NULL,\n `description` TEXT,\n `order` INT(6) NOT NULL DEFAULT 0,\n PRIMARY KEY (`id`, `course_id`)) {$charset_spec}"); Database::get()->query("CREATE TABLE IF NOT EXISTS ebook (\n `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `course_id` INT(11) NOT NULL,\n `order` INT(11) NOT NULL,\n `title` TEXT) {$charset_spec}");
} if ($_GET['ID'] && 'move_down' == $_GET['action']) { $query_str = "SELECT * FROM `ProfilesDesc` ORDER BY `order` ASC"; $res = db_res($query_str); // Process moving if (!move_down($_GET['ID'], $res)) { echo "<p><span style=\"color:#ff6666;font-weight:bold\">Can't move down field.</span></p>\n"; } else { $modified = (int) $_GET['ID']; } } if ($_GET['ID'] && 'delete' == $_GET['action']) { $query_str = "SELECT * FROM `ProfilesDesc` ORDER BY `order` ASC"; $res = db_res($query_str); // Process deleting delete_field($_GET['ID'], $res); echo "<p><span style=\"color:#ff6666;font-weight:bold\">Field deleted.</span></p>\n"; } // Display add or edit form if ('add' == $_GET['action'] || 'edit' == $_GET['action']) { // Display if user just got into the page, or refreshed field type, // otherwise if the user pressed 'Add' button, add new field. if (!$_POST['add_button']) { display_controls(); } else { // Check input parameters. $errors = check_parameters($_POST['field_type']); if (count($errors) > 0) { // Display error messages and controls for entering. foreach ($errors as $value) { echo "<span style=\"color:#ff6666;font-weight:bold\">Error: {$value}</span><br />";
$exercises = Database::get()->queryArray("SELECT exercise.id AS id, exercise.course_id AS course_id, exercise_user_record.eurid AS eurid " . "FROM exercise_user_record, exercise " . "WHERE exercise_user_record.eid = exercise.id " . "AND exercise_user_record.total_weighting = 0 " . "AND exercise_user_record.attempt_status = 4"); foreach ($exercises as $exercise) { $totalweight = Database::get()->querySingle("SELECT SUM(exercise_question.weight) AS totalweight FROM exercise_question, exercise_with_questions WHERE exercise_question.course_id = ?d AND exercise_question.id = exercise_with_questions.question_id AND exercise_with_questions.exercise_id = ?d", $exercise->course_id, $exercise->id)->totalweight; Database::get()->query("UPDATE exercise_user_record SET total_weighting = ?f WHERE eurid = ?d", $totalweight, $exercise->eurid); } if (DBHelper::fieldExists('link', 'hits')) { // not needed delete_field('link', 'hits'); } Database::get()->query("CREATE TABLE IF NOT EXISTS `group_category` ( `id` INT(6) NOT NULL AUTO_INCREMENT, `course_id` INT(11) NOT NULL, `name` VARCHAR(255) NOT NULL, `description` TEXT, PRIMARY KEY (`id`, `course_id`)) $charset_spec"); if (!DBHelper::fieldExists('group', 'category_id')) { Database::get()->query("ALTER TABLE `group` ADD `category_id` INT(11) NULL"); } //Group Mapping due to group_id addition in group_properties table if (!DBHelper::fieldExists('group_properties', 'group_id')) { Database::get()->query("ALTER TABLE `group_properties` ADD `group_id` INT(11) NOT NULL DEFAULT 0");