* @package chamilo.admin.openbadges
*/
+use \ChamiloSession as Session;
+
$cidReset = true;
require_once '../inc/global.inc.php';
@@ -15,6 +17,12 @@ if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true')
$this_section = SECTION_PLATFORM_ADMIN;
+$errorMessage = null;
+
+if (Session::has('errorMessage')) {
+ $errorMessage = Session::read('errorMessage');
+}
+
$objSkill = new Skill();
$skills = $objSkill->get_all();
@@ -30,9 +38,12 @@ $interbreadcrumb = array(
);
$tpl = new Template(get_lang('Skills'));
+$tpl->assign('errorMessage', $errorMessage);
$tpl->assign('platformAdminEmail', get_setting('emailAdministrator'));
$tpl->assign('skills', $skills);
$contentTemplate = $tpl->get_template('skill/badge_list.tpl');
$tpl->display($contentTemplate);
+
+Session::erase('errorMessage');
diff --git a/main/admin/skills_wheel.php b/main/admin/skills_wheel.php
index 539a0b1dca..4965a9a751 100755
--- a/main/admin/skills_wheel.php
+++ b/main/admin/skills_wheel.php
@@ -46,6 +46,7 @@ $tpl->assign('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl->assign('url', $url);
+$tpl->assign('isAdministration', true);
$content = $tpl->fetch('default/skill/skill_wheel.tpl');
$tpl->assign('content', $content);
diff --git a/main/admin/special_exports.php b/main/admin/special_exports.php
index 54b2ebce83..5f6a754374 100755
--- a/main/admin/special_exports.php
+++ b/main/admin/special_exports.php
@@ -190,7 +190,7 @@ function create_zip(){
}
function rename_zip($FileZip) {
- event_download(($FileZip['PATH'] == '/')?'full_export_'.date('Ymd').'.zip (folder)': basename($FileZip['PATH']).'.zip (folder)');
+ Event::event_download(($FileZip['PATH'] == '/')?'full_export_'.date('Ymd').'.zip (folder)': basename($FileZip['PATH']).'.zip (folder)');
$name = ($FileZip['PATH']=='/')? 'full_export_'.date('Ymd').'.zip':basename($FileZip['PATH']).'.zip';
if(file_exists($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name)){ unlink($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name); }
if(file_exists($FileZip['TEMP_FILE_ZIP'])) {
diff --git a/main/admin/statistics/index.php b/main/admin/statistics/index.php
index 4624b1587f..d1d0652338 100755
--- a/main/admin/statistics/index.php
+++ b/main/admin/statistics/index.php
@@ -1,6 +1,6 @@
$name) {
$name = str_replace(get_lang('Department'), "", $name);
- $teachers[$name] = Statistics::count_users(1, $code, $_GET['count_invisible_courses']);
- $students[$name] = Statistics::count_users(5, $code, $_GET['count_invisible_courses']);
+ $teachers[$name] = Statistics::count_users(1, $code, $countInvisible);
+ $students[$name] = Statistics::count_users(5, $code, $countInvisible);
}
// docents for each course category
Statistics::print_stats(get_lang('Teachers'), $teachers);
diff --git a/main/admin/sub_language.php b/main/admin/sub_language.php
index e30bda04c1..8919cdba3d 100755
--- a/main/admin/sub_language.php
+++ b/main/admin/sub_language.php
@@ -10,7 +10,6 @@ $language_file = 'admin';
$cidReset = true;
$this_script = 'sub_language';
require_once '../inc/global.inc.php';
-require_once 'sub_language.class.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
diff --git a/main/admin/sub_language_add.php b/main/admin/sub_language_add.php
index 1a9431583d..9895c32a1d 100755
--- a/main/admin/sub_language_add.php
+++ b/main/admin/sub_language_add.php
@@ -10,7 +10,7 @@
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
-require_once 'sub_language.class.php';
+
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
diff --git a/main/admin/sub_language_ajax.inc.php b/main/admin/sub_language_ajax.inc.php
index c9cad48ef1..88f9e03056 100755
--- a/main/admin/sub_language_ajax.inc.php
+++ b/main/admin/sub_language_ajax.inc.php
@@ -4,13 +4,9 @@
* Sub language AJAX script to update variables
* @package chamilo.admin.sub_language
*/
-/**
- * Init
- */
$language_file = 'admin';
$this_script = 'sub_language';
require_once '../inc/global.inc.php';
-require_once 'sub_language.class.php';
api_protect_admin_script();
@@ -53,6 +49,6 @@ if (isset($new_language) && isset($language_variable) && isset($file_id)) {
echo $path_folder.' '.get_lang('IsNotWritable').'
'.api_ucwords(get_lang('ErrorsFound')).':
'.$variables_with_problems;
} else {
echo get_lang('Saved');
- }
+ }
}
diff --git a/main/admin/system_announcements.php b/main/admin/system_announcements.php
index 3ca48f2b59..a435755e2d 100755
--- a/main/admin/system_announcements.php
+++ b/main/admin/system_announcements.php
@@ -142,11 +142,7 @@ if ($action_todo) {
}
$form->addElement('select', 'lang',get_lang('Language'), $language_list_with_keys);
- if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
- $form->addElement('textarea', 'content', get_lang('Content'));
- } else {
- $form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300'));
- }
+ $form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300'));
$form->addDateRangePicker('range', get_lang('StartTimeWindow'), true, array('id' => 'date_range'));
$group = array();
@@ -182,13 +178,8 @@ if ($action_todo) {
$class='save';
$form->addElement('hidden', 'action', 'edit');
}
-
$form->addElement('checkbox', 'send_email_test', null, get_lang('SendOnlyAnEmailToMySelfToTest'));
-
$form->addElement('style_submit_button', 'submit', $text, 'class="'.$class.'"');
- if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
- $values['content'] = WCAG_Rendering::HTML_to_text($values['content']);
- }
$form->setDefaults($values);
if ($form->validate()) {
@@ -205,9 +196,6 @@ if ($action_todo) {
if ($values['lang'] == 'all') {
$values['lang'] = null;
}
- if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
- //$values['content'] = WCAG_Rendering::text_to_HTML($values['content']);
- }
$sendMail = isset($values['send_mail']) ? $values['send_mail'] : null;
@@ -262,13 +250,7 @@ if ($action_todo) {
}
$show_announcement_list = true;
} else {
- if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
- echo '';
- }
$form->display();
- if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
- echo '
';
- }
$show_announcement_list = false;
}
}
diff --git a/main/admin/teacher_time_report.php b/main/admin/teacher_time_report.php
index 4acfe5bac7..74d757d319 100644
--- a/main/admin/teacher_time_report.php
+++ b/main/admin/teacher_time_report.php
@@ -65,17 +65,14 @@ $timeReport = new TeacherTimeReport();
if (!empty($selectedCourse)) {
$withFilter = true;
-
$course = api_get_course_info($selectedCourse);
-
$reportTitle = sprintf(get_lang('TimeReportForCourseX'), $course['title']);
-
$teachers = CourseManager::get_teacher_list_from_course_code($selectedCourse);
foreach ($teachers as $teacher) {
$totalTime = UserManager::getExpendedTimeInCourses(
$teacher['user_id'],
- $selectedCourse,
+ $course['real_id'],
0,
$selectedFrom,
$selectedUntil
@@ -108,7 +105,7 @@ if (!empty($selectedCourse)) {
foreach ($coaches as $coach) {
$totalTime = UserManager::getExpendedTimeInCourses(
$coach['user_id'],
- $selectedCourse,
+ $course['real_id'],
$session['id'],
$selectedFrom,
$selectedUntil
@@ -163,7 +160,7 @@ if (!empty($selectedSession)) {
foreach ($coaches as $coach) {
$totalTime = UserManager::getExpendedTimeInCourses(
$coach['user_id'],
- $course['code'],
+ $course['id'],
$selectedSession,
$selectedFrom,
$selectedUntil
@@ -210,7 +207,7 @@ if (!empty($selectedTeacher)) {
$totalTime = UserManager::getExpendedTimeInCourses(
$selectedTeacher,
- $course['code'],
+ $course['real_id'],
0,
$selectedFrom,
$selectedUntil
@@ -242,7 +239,7 @@ if (!empty($selectedTeacher)) {
$totalTime = UserManager::getExpendedTimeInCourses(
$selectedTeacher,
- $course['course_code'],
+ $course['real_id'],
$session['id'],
$selectedFrom,
$selectedUntil
diff --git a/main/admin/user_add.php b/main/admin/user_add.php
index a27ab12c74..e7bf123c1d 100755
--- a/main/admin/user_add.php
+++ b/main/admin/user_add.php
@@ -235,7 +235,7 @@ $form->addGroup($group, 'mail', get_lang('SendMailToNewUser'), ' ');
$form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
$group = array ();
$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('On'), 1);
-$group[] = $form->createElement('datepicker', 'expiration_date', null, array('form_name' => $form->getAttribute('name'), 'onchange' => 'javascript: enable_expiration_date();'));
+$group[] = $form->createElement('DatePicker', 'expiration_date', null, array('form_name' => $form->getAttribute('name'), 'onchange' => 'javascript: enable_expiration_date();'));
$form->addGroup($group, 'max_member_group', null, '', false);
// Active account or inactive account
$form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1);
diff --git a/main/admin/user_edit.php b/main/admin/user_edit.php
index df7d89927f..820a153c2d 100755
--- a/main/admin/user_edit.php
+++ b/main/admin/user_edit.php
@@ -263,7 +263,7 @@ if (!$user_data['platform_admin']) {
$form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
$group = array ();
$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('On'), 1);
- $group[] = $form->createElement('datepicker', 'expiration_date', null, array('form_name' => $form->getAttribute('name'), 'onchange' => 'javascript: enable_expiration_date();'));
+ $group[] = $form->createElement('DatePickerDate', 'expiration_date', null, array('form_name' => $form->getAttribute('name'), 'onchange' => 'javascript: enable_expiration_date();'));
$form->addGroup($group, 'max_member_group', null, '', false);
// Active account or inactive account
diff --git a/main/admin/user_information.php b/main/admin/user_information.php
index ec8c7abb6e..cac91dbfd8 100755
--- a/main/admin/user_information.php
+++ b/main/admin/user_information.php
@@ -188,7 +188,7 @@ if (count($sessions) > 0) {
$timeSpent = api_time_to_hms(
Tracking :: get_time_spent_on_the_course(
$user['user_id'],
- $courseInfo['code'],
+ $courseInfo['real_id'],
$id_session
)
);
@@ -286,19 +286,21 @@ if (Database::num_rows($res) > 0) {
$data = array();
$courseToolInformationTotal = null;
while ($course = Database::fetch_object($res)) {
+ $courseInfo = api_get_course_info($course->code);
$courseToolInformation = null;
$tools = ''.Display::return_icon('synthese_view.gif', get_lang('Overview')).''.
''.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'' .
''.Display::return_icon('edit.gif', get_lang('Edit')).'';
if ($course->status == STUDENT) {
- $tools .= ''.Display::return_icon('delete.png', get_lang('Delete')).'';
+ $tools .= ''.
+ Display::return_icon('delete.png', get_lang('Delete')).'';
}
$timeSpent = api_time_to_hms(
Tracking :: get_time_spent_on_the_course(
$user['user_id'],
- $course->code,
+ $courseInfo['real_id'],
0
)
);
@@ -308,7 +310,7 @@ if (Database::num_rows($res) > 0) {
$course->id,
0
);
- $courseInfo = api_get_course_info($course->code);
+
$row = array(
Display::url($course->code, $courseInfo['course_public_url']),
$course->title,
diff --git a/main/admin/user_list.php b/main/admin/user_list.php
index 7775ce65f9..0d57dc0aa4 100755
--- a/main/admin/user_list.php
+++ b/main/admin/user_list.php
@@ -324,7 +324,7 @@ function login_user($user_id) {
$main_user_table = Database::get_main_table(TABLE_MAIN_USER);
$main_admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
- $track_e_login_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
+ $track_e_login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
unset($_user['user_id']); // uid not in session ? prevent any hacking
diff --git a/main/admin/user_move_stats.php b/main/admin/user_move_stats.php
index 3f106be35c..ce0604e1a9 100755
--- a/main/admin/user_move_stats.php
+++ b/main/admin/user_move_stats.php
@@ -116,10 +116,10 @@ if (isset($_REQUEST['load_ajax'])) {
$course_info = api_get_course_info($origin_course_code);
$course_id = $course_info['real_id'];
- $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $TBL_TRACK_E_COURSE_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
- $TBL_TRACK_E_LAST_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
+ $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+ $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+ $TBL_TRACK_E_COURSE_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
+ $TBL_TRACK_E_LAST_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
$TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK);
@@ -127,9 +127,9 @@ if (isset($_REQUEST['load_ajax'])) {
$TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
- $TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE);
- $TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST);
- $TBL_AGENDA = Database::get_course_table(TABLE_AGENDA);
+ $TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE);
+ $TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST);
+ $TBL_AGENDA = Database::get_course_table(TABLE_AGENDA);
//1. track_e_exercises
//ORIGINAL COURSE
@@ -161,7 +161,8 @@ if (isset($_REQUEST['load_ajax'])) {
if (!$update_database) {
- $sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE exe_cours_id = '$origin_course_code' AND session_id = $new_session_id AND exe_user_id = $user_id ";
+ $sql = "SELECT * FROM $TABLETRACK_EXERCICES
+ WHERE exe_cours_id = '$origin_course_code' AND session_id = $new_session_id AND exe_user_id = $user_id ";
$res = Database::query($sql);
$list = array();
while($row = Database::fetch_array($res,'ASSOC')) {
@@ -188,8 +189,8 @@ if (isset($_REQUEST['load_ajax'])) {
//Nothing to do because there are not relationship with a session
//3. track_e_course_access
-
- $sql = "SELECT * FROM $TBL_TRACK_E_COURSE_ACCESS WHERE course_code = '$origin_course_code' AND session_id = $origin_session_id AND user_id = $user_id ";
+ $sql = "SELECT * FROM $TBL_TRACK_E_COURSE_ACCESS
+ WHERE c_id = '$course_id' AND session_id = $origin_session_id AND user_id = $user_id ";
$res = Database::query($sql);
$list = array();
while($row = Database::fetch_array($res,'ASSOC')) {
@@ -204,14 +205,12 @@ if (isset($_REQUEST['load_ajax'])) {
$res = Database::query($sql);
if ($debug) var_dump($res);
$result_message[$TBL_TRACK_E_COURSE_ACCESS]++;
- } else {
- //$result_message[$TBL_TRACK_E_COURSE_ACCESS][$id] = $data;
}
}
-
//4. track_e_lastaccess
- $sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS WHERE access_cours_code = '$origin_course_code' AND access_session_id = $origin_session_id AND access_user_id = $user_id ";
+ $sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS
+ WHERE c_id = '$course_id' AND access_session_id = $origin_session_id AND access_user_id = $user_id ";
$res = Database::query($sql);
$list = array();
while($row = Database::fetch_array($res,'ASSOC')) {
@@ -231,7 +230,8 @@ if (isset($_REQUEST['load_ajax'])) {
//5. lp_item_view
//CHECK ORIGIN
- $sql = "SELECT * FROM $TBL_LP_VIEW WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id ";
+ $sql = "SELECT * FROM $TBL_LP_VIEW
+ WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id ";
$res = Database::query($sql);
//Getting the list of LPs in the new session
@@ -581,10 +581,11 @@ $htmlHeadXtra[] = '';
function get_courses_list_by_user_id_based_in_exercises($user_id) {
- $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+ $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$user_id = intval($user_id);
//$sql = "SELECT DISTINCT exe_user_id, exe_cours_id as code, session_id as id_session FROM $TABLETRACK_EXERCICES WHERE exe_user_id = $user_id GROUP BY exe_user_id, exe_cours_id ORDER by exe_user_id, exe_cours_id ASC";
- $sql = "SELECT DISTINCT exe_user_id, exe_cours_id as code, session_id as id_session FROM $TABLETRACK_EXERCICES WHERE exe_user_id = $user_id ORDER by exe_user_id, exe_cours_id ASC";
+ $sql = "SELECT DISTINCT exe_user_id, exe_cours_id as code, session_id as id_session
+ FROM $TABLETRACK_EXERCICES WHERE exe_user_id = $user_id ORDER by exe_user_id, exe_cours_id ASC";
$res = Database::query($sql);
$course_list = array();
diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php
index b3bfa45332..31166ba6dd 100755
--- a/main/announcements/announcements.php
+++ b/main/announcements/announcements.php
@@ -9,8 +9,6 @@
* Announcements tool and also add the resource linker here. The database also needed refactoring
* as there was no title field (the title was merged into the content field)
* @package chamilo.announcements
- * @todo make AWACS out of the configuration settings
- * @todo this file is 1300+ lines without any functions -> needs to be split into
* multiple functions
*/
@@ -24,22 +22,23 @@ $use_anonymous = true;
// setting the global file that gets the general configuration, the databases, the languages, ...
require_once '../inc/global.inc.php';
+
+/* Sessions */
+
+$ctok = $_SESSION['sec_token'];
+$stok = Security::get_token();
+
$current_course_tool = TOOL_ANNOUNCEMENT;
-$this_section=SECTION_COURSES;
+$this_section = SECTION_COURSES;
$nameTools = get_lang('ToolAnnouncement');
-//session
-if(isset($_GET['id_session'])) {
- $_SESSION['id_session'] = intval($_GET['id_session']);
-}
-
/* ACCESS RIGHTS */
api_protect_course_script(true);
// Configuration settings
-$display_announcement_list = true;
-$display_form = false;
-$display_title_list = true;
+$display_announcement_list = true;
+$display_form = false;
+$display_title_list = true;
// Maximum title messages to display
$maximum = '12';
@@ -48,164 +47,94 @@ $maximum = '12';
$length = '36';
// Database Table Definitions
-$tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
-$tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
-$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
-$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
-
-/* Libraries */
-
-$lib = api_get_path(LIBRARY_PATH); //avoid useless function calls
-require_once 'announcements.inc.php';
+$tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
+$tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
+$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
+$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
$_course = api_get_course_info();
/* Tracking */
-event_access_tool(TOOL_ANNOUNCEMENT);
-
-/* POST TO */
-$safe_emailTitle = isset($_POST['emailTitle']) ? $_POST['emailTitle'] : null;
-$safe_newContent = isset($_POST['newContent']) ? $_POST['newContent'] : null;
-
-$content_to_modify = $title_to_modify = '';
-
-if (!empty($_POST['To'])) {
- if (api_get_session_id()!=0 &&
- api_is_allowed_to_session_edit(false, true) == false
- ) {
- api_not_allowed(true);
- }
- $display_form = true;
-
- $form_elements = array(
- 'emailTitle' => $safe_emailTitle,
- 'newContent' => $safe_newContent,
- 'id' => $_POST['id'],
- 'emailoption' => $_POST['email_ann']
- );
- $_SESSION['formelements'] = $form_elements;
-
- $form_elements = $_SESSION['formelements'];
- $title_to_modify = $form_elements["emailTitle"];
- $content_to_modify = $form_elements["newContent"];
- $announcement_to_modify = $form_elements["id"];
-}
-
-/*
- Show/hide user/group form
-*/
-
-$setting_select_groupusers = true;
-if (empty($_POST['To']) and !isset($_SESSION['select_groupusers'])) {
- $_SESSION['select_groupusers'] = "hide";
-}
-$select_groupusers_status = isset($_SESSION['select_groupusers']) ? $_SESSION['select_groupusers']:null;
-if (!empty($_POST['To']) and ($select_groupusers_status=="hide")) {
- $_SESSION['select_groupusers'] = "show";
-}
-if (!empty($_POST['To']) and ($select_groupusers_status=="show")) {
- $_SESSION['select_groupusers'] = "hide";
-}
+Event::event_access_tool(TOOL_ANNOUNCEMENT);
+$announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null;
$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
+$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'list';
-/* Action handling */
-
-// display the form
-if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") ||
- (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To'])
-) {
- if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true) == false) {
- api_not_allowed(true);
- }
- $display_form = true;
-}
+$announcement_number = AnnouncementManager::getNumberAnnouncements();
-// clear all resources
-if ((empty($originalresource) || ($originalresource!=='no')) and (!empty($action) && $action=='add')) {
- $_SESSION['formelements']=null;
-}
-
-$htmlHeadXtra[] = AnnouncementManager::to_javascript();
-
-/* Filter user/group */
-
-if(!empty($_GET['toolgroup'])){
- if($_GET['toolgroup'] == strval(intval($_GET['toolgroup']))){
- //check is integer
- $toolgroup = intval($_GET['toolgroup']);
- $_SESSION['select_groupusers'] = 'hide';
- } else {
- $toolgroup = 0;
- }
- Session::write("toolgroup", $toolgroup);
-}
-
-/* Sessions */
-
-$ctok = $_SESSION['sec_token'];
-$stok = Security::get_token();
-$to = null;
-$email_ann = null;
-
-if (!empty($_SESSION['formelements']) and
- !empty($_GET['originalresource']) and
- $_GET['originalresource'] == 'no'
-) {
- $form_elements = $_SESSION['formelements'];
- $title_to_modify = $form_elements['emailTitle'];
- $content_to_modify = $form_elements['newContent'];
- $announcement_to_modify = $form_elements['id'];
- $to = $form_elements['to'];
- $email_ann = $form_elements['emailoption'];
-}
+$homeUrl = api_get_self().'?action=list&'.api_get_cidreq();
+$content = null;
-if (!empty($_GET['remind_inactive'])) {
- $to[] = 'USER:'.intval($_GET['remind_inactive']);
-}
-
-$group_id = api_get_group_id();
+switch ($action) {
+ case 'move':
+ /* Move announcement up/down */
+ if (isset($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
+ if (!empty($_GET['down'])) {
+ $thisAnnouncementId = intval($_GET['down']);
+ $sortDirection = "DESC";
+ }
-if (!empty($group_id)) {
- $group_properties = GroupManager :: get_group_properties($group_id);
- $interbreadcrumb[] = array("url" => "../group/group.php", "name" => get_lang('Groups'));
- $interbreadcrumb[] = array("url"=>"../group/group_space.php?gidReq=".$group_id, "name"=> get_lang('GroupSpace').' '.$group_properties['name']);
-}
+ if (!empty($_GET['up'])) {
+ $thisAnnouncementId = intval($_GET['up']);
+ $sortDirection = "ASC";
+ }
+ }
-$announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null;
-$message = null;
+ if (!empty($sortDirection)) {
+ if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) {
+ $sortDirection='ASC';
+ }
-if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
- //we are not in the learning path
- Display::display_header($nameTools,get_lang('Announcements'));
-}
+ $announcementInfo = AnnouncementManager::get_by_id($course_id, $thisAnnouncementId);
-if (api_is_allowed_to_edit(false,true) OR
- (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
-) {
- /*
- Change visibility of announcement
- */
- // $_GET['isStudentView']<>"false" is added to prevent that the visibility
- // is changed after you do the following:
- // change visibility -> studentview -> course manager view
- if (!isset($_GET['isStudentView']) || $_GET['isStudentView']!='false') {
- if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide") {
- if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
- api_not_allowed();
- }
- if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])) {
- if ($ctok == $_GET['sec_token']) {
- AnnouncementManager::change_visibility_announcement($_course, $_GET['id']);
- $message = get_lang('VisibilityChanged');
+ $sql = "SELECT DISTINCT announcement.id, announcement.display_order
+ FROM $tbl_announcement announcement,
+ $tbl_item_property itemproperty
+ WHERE
+ announcement.c_id = $course_id AND
+ itemproperty.c_id = $course_id AND
+ itemproperty.ref = announcement.id AND
+ itemproperty.tool = '".TOOL_ANNOUNCEMENT."' AND
+ itemproperty.visibility <> 2
+ ORDER BY display_order $sortDirection";
+ $result = Database::query($sql);
+ $thisAnnouncementOrderFound = false;
+ $thisAnnouncementOrder = null;
+
+ while (list($announcementId, $announcementOrder) = Database::fetch_row($result)) {
+ if ($thisAnnouncementOrderFound) {
+ $nextAnnouncementId = $announcementId;
+ $nextAnnouncementOrder = $announcementOrder;
+ $sql = "UPDATE $tbl_announcement SET display_order = '$nextAnnouncementOrder'
+ WHERE c_id = $course_id AND id = $thisAnnouncementId";
+ Database::query($sql);
+ $sql = "UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder'
+ WHERE c_id = $course_id AND id = $nextAnnouncementId";
+
+ Database::query($sql);
+ break;
+ }
+ // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
+ if ($announcementId == $thisAnnouncementId) {
+ $thisAnnouncementOrder = $announcementOrder;
+ $thisAnnouncementOrderFound = true;
}
}
+ Display::addFlash(Display::return_message(get_lang('AnnouncementMoved')));
+ header('Location: '.$homeUrl);
+ exit;
}
- }
-
- /* Delete announcement */
- if (!empty($_GET['action']) && $_GET['action']=='delete' && isset($_GET['id'])) {
+ break;
+ case 'view':
+ $content = AnnouncementManager::display_announcement($announcement_id);
+ break;
+ case 'list':
+ $content = AnnouncementManager::getAnnouncements($stok, $announcement_number);
+ break;
+ case 'delete':
+ /* Delete announcement */
$id = intval($_GET['id']);
if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false, true) == false) {
api_not_allowed();
@@ -215,361 +144,353 @@ if (api_is_allowed_to_edit(false,true) OR
// tooledit : visibility = 2 : only visible for platform administrator
if ($ctok == $_GET['sec_token']) {
AnnouncementManager::delete_announcement($_course, $id);
-
- $id = null;
- $emailTitle = null;
- $newContent = null;
- $message = get_lang('AnnouncementDeleted');
+ Display::addFlash(Display::return_message(get_lang('AnnouncementDeleted')));
}
}
- }
-
- //delete attachment file
- if (isset($_GET['action']) && $_GET['action'] == 'delete_attachment') {
+ header('Location: '.$homeUrl);
+ exit;
+ break;
+ case 'delete_all':
+ if (api_is_allowed_to_edit()) {
+ AnnouncementManager::delete_all_announcements($_course);
+ Display::addFlash(Display::return_message(get_lang('AnnouncementDeletedAll')));
+ header('Location: '.$homeUrl);
+ exit;
+ }
+ break;
+ case 'delete_attachment':
$id = $_GET['id_attach'];
if ($ctok == $_GET['sec_token']) {
if (api_is_allowed_to_edit()) {
AnnouncementManager::delete_announcement_attachment_file($id);
}
}
- }
+ header('Location: '.$homeUrl);
+ exit;
+ break;
+ case 'showhide':
+ if (!isset($_GET['isStudentView']) || $_GET['isStudentView'] != 'false') {
+ if (isset($_GET['id']) AND $_GET['id']) {
+ if (api_get_session_id() != 0 &&
+ api_is_allowed_to_session_edit(false, true) == false) {
+ api_not_allowed();
+ }
- /* Delete all announcements */
- if (!empty($_GET['action']) and $_GET['action']=='delete_all') {
- if (api_is_allowed_to_edit()) {
- AnnouncementManager::delete_all_announcements($_course);
- $id = null;
- $emailTitle = null;
- $newContent = null;
- $message = get_lang('AnnouncementDeletedAll');
+ if (!api_is_course_coach() ||
+ api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])
+ ) {
+ if ($ctok == $_GET['sec_token']) {
+ AnnouncementManager::change_visibility_announcement(
+ $_course,
+ $_GET['id']
+ );
+ Display::addFlash(Display::return_message(get_lang('VisibilityChanged')));
+ header('Location: '.$homeUrl);
+ exit;
+ }
+ }
+ }
}
- }
-
- /* Modify announcement */
- if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) {
- if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
- api_not_allowed();
+ break;
+ case 'add':
+ case 'modify':
+ if (api_get_session_id() != 0 &&
+ api_is_allowed_to_session_edit(false, true) == false
+ ) {
+ api_not_allowed(true);
}
- $display_form = true;
-
- // RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
- $id = intval($_GET['id']);
-
- if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
- $sql = "SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id = '$id'";
- $rs = Database::query($sql);
- $myrow = Database::fetch_array($rs);
- $last_id = $id;
- $userUpload = isset($_FILES['user_upload']) ? $_FILES['user_upload'] : null;
- $edit_attachment = AnnouncementManager::edit_announcement_attachment_file(
- $last_id,
- $userUpload,
- $file_comment
- );
+ // DISPLAY ADD ANNOUNCEMENT COMMAND
+ $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
+ $url = api_get_self().'?action='.$action.'&id=' . $id . '&' . api_get_cidreq();
- if ($myrow) {
- $announcement_to_modify = $myrow['id'];
- $content_to_modify = $myrow['content'];
- $title_to_modify = $myrow['title'];
+ $form = new FormValidator(
+ 'f1',
+ 'post',
+ $url,
+ null,
+ array('enctype' => 'multipart/form-data')
+ );
- if ($originalresource!=="no") {
- $to = AnnouncementManager::load_edit_users("announcement", $announcement_to_modify);
+ if (empty($id)) {
+ $form_name = get_lang('AddAnnouncement');
+ } else {
+ $form_name = get_lang('ModifyAnnouncement');
+ }
+ $form->addElement('header', $form_name);
+
+ if (empty($group_id)) {
+ if (isset($_GET['remind_inactive'])) {
+ $email_ann = '1';
+ $content_to_modify = sprintf(
+ get_lang('RemindInactiveLearnersMailContent'),
+ api_get_setting('siteName'),
+ 7
+ );
+ $title_to_modify = sprintf(
+ get_lang('RemindInactiveLearnersMailSubject'),
+ api_get_setting('siteName')
+ );
+ } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] == 'true') {
+ // we want to remind inactive users. The $_GET['since'] parameter
+ // determines which users have to be warned (i.e the users who have been inactive for x days or more
+ $since = isset($_GET['since']) ? intval($_GET['since']) : 6;
+ // getting the users who have to be reminded
+ $to = Tracking:: get_inactives_students_in_course(
+ api_get_course_int_id(),
+ $since,
+ api_get_session_id()
+ );
+ // setting the variables for the form elements: the users who need to receive the message
+ foreach ($to as &$user) {
+ $user = 'USER:' . $user;
+ }
+ // setting the variables for the form elements: the message has to be sent by email
+ $email_ann = '1';
+ // setting the variables for the form elements: the title of the email
+ $title_to_modify = sprintf(
+ get_lang('RemindInactiveLearnersMailSubject'),
+ api_get_setting('siteName')
+ );
+ // setting the variables for the form elements: the message of the email
+ $content_to_modify = sprintf(
+ get_lang('RemindInactiveLearnersMailContent'),
+ api_get_setting('siteName'),
+ $since
+ );
+ // when we want to remind the users who have never been active
+ // then we have a different subject and content for the announcement
+ if ($_GET['since'] == 'never') {
+ $title_to_modify = sprintf(
+ get_lang('RemindInactiveLearnersMailSubject'),
+ api_get_setting('siteName')
+ );
+ $content_to_modify = get_lang(
+ 'YourAccountIsActiveYouCanLoginAndCheckYourCourses'
+ );
}
- $display_announcement_list = false;
}
- if ($to=="everyone" OR !empty($group_id)) {
- $_SESSION['select_groupusers']="hide";
- } else {
- $_SESSION['select_groupusers']="show";
+ CourseManager::addUserGroupMultiSelect($form, array());
+ if (!isset($announcement_to_modify)) {
+ $announcement_to_modify = '';
}
+ $form->addElement(
+ 'checkbox',
+ 'email_ann',
+ null,
+ get_lang('EmailOption')
+ );
+ } else {
+ if (!isset($announcement_to_modify)) {
+ $announcement_to_modify = "";
+ }
+ CourseManager::addGroupMultiSelect($form, $group_id, array());
+ $form->addElement(
+ 'checkbox',
+ 'email_ann',
+ null,
+ get_lang('EmailOption')
+ );
}
- }
- /* Move announcement up/down */
- if (isset($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
- if (!empty($_GET['down'])) {
- $thisAnnouncementId = intval($_GET['down']);
- $sortDirection = "DESC";
- }
+ $announcementInfo = AnnouncementManager::get_by_id($course_id, $id);
- if (!empty($_GET['up'])) {
- $thisAnnouncementId = intval($_GET['up']);
- $sortDirection = "ASC";
- }
- }
+ if (isset($announcementInfo) && !empty($announcementInfo)) {
+ $to = AnnouncementManager::load_edit_users("announcement", $id);
- if (!empty($sortDirection)) {
- if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) {
- $sortDirection='ASC';
+ $defaults = array(
+ 'title' => $announcementInfo['title'],
+ 'content' => $announcementInfo['content'],
+ 'id' => $announcementInfo['id'],
+ 'users' => $to
+ );
+ } else {
+ $defaults = array();
}
- $sql = "SELECT announcement.id, announcement.display_order
- FROM $tbl_announcement announcement,
- $tbl_item_property itemproperty
- WHERE
- announcement.c_id = $course_id AND
- itemproperty.c_id = $course_id AND
- itemproperty.ref=announcement.id AND
- itemproperty.tool='".TOOL_ANNOUNCEMENT."' AND
- itemproperty.visibility<>2
- ORDER BY display_order $sortDirection";
- $result = Database::query($sql);
-
- while (list ($announcementId, $announcementOrder) = Database::fetch_row($result)) {
- // STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER.
- // COMMIT ORDER SWAP ON THE DB
- if ($thisAnnouncementOrderFound) {
- $nextAnnouncementId = $announcementId;
- $nextAnnouncementOrder = $announcementOrder;
- Database::query("UPDATE $tbl_announcement SET display_order = '$nextAnnouncementOrder' WHERE c_id = $course_id AND id = '$thisAnnouncementId'");
- Database::query("UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder' WHERE c_id = $course_id AND id = '$nextAnnouncementId.'");
- break;
- }
- // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
- if ($announcementId == $thisAnnouncementId) {
- $thisAnnouncementOrder = $announcementOrder;
- $thisAnnouncementOrderFound = true;
- }
+ $form->addElement('text', 'title', get_lang('EmailTitle'));
+ $form->addElement('hidden', 'id');
+ $form->add_html_editor(
+ 'content',
+ get_lang('Description'),
+ false,
+ false,
+ array('ToolbarSet' => 'Announcements')
+ );
+
+ $form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
+ $form->addElement('textarea', 'file_comment', get_lang('FileComment'));
+ $form->addElement('hidden', 'sec_token', $stok);
+
+ if (api_get_session_id() == 0) {
+ $form->addCheckBox('send_to_users_in_session', null, get_lang('SendToUsersInSessions'));
}
- // show message
- $message = get_lang('AnnouncementMoved');
- }
- /* Submit announcement */
+ $form->addButton('save', get_lang('ButtonPublishAnnouncement'));
+ $form->setDefaults($defaults);
- $emailTitle = (!empty($_POST['emailTitle'])?$safe_emailTitle:'');
- $newContent = (!empty($_POST['newContent'])?$safe_newContent:'');
- $submitAnnouncement = isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0;
+ $content = $form->return_form();
- $id = 0;
- if (!empty($_POST['id'])) {
- $id=intval($_POST['id']);
- }
+ if ($form->validate()) {
+ $data = $form->getSubmitValues();
- if ($submitAnnouncement && empty($emailTitle)) {
- $error_message = get_lang('TitleIsRequired');
- $content_to_modify = $newContent;
- } else if ($submitAnnouncement) {
- $sendToUsersInSession = isset($_POST['send_to_users_in_session']) ? true : false;
-
- if (isset($id) && $id) {
- // there is an Id => the announcement already exists => update mode
- if ($ctok == $_POST['sec_token']) {
- $file_comment = $_POST['file_comment'];
- $file = $_FILES['user_upload'];
- AnnouncementManager::edit_announcement(
- $id,
- $emailTitle,
- $newContent,
- $_POST['selectedform'],
- $file,
- $file_comment,
- $sendToUsersInSession
- );
+ $sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false;
- /* MAIL FUNCTION */
- if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) {
- AnnouncementManager::send_email($id, $sendToUsersInSession);
- }
- $message = get_lang('AnnouncementModified');
- }
- } else {
- //insert mode
- if ($ctok == $_POST['sec_token']) {
- $file = $_FILES['user_upload'];
- $file_comment = $_POST['file_comment'];
- if (!empty($group_id)) {
- $insert_id = AnnouncementManager::add_group_announcement(
- $safe_emailTitle,
- $safe_newContent,
- array('GROUP:' . $group_id),
- $_POST['selectedform'],
- $file,
- $file_comment,
- $sendToUsersInSession
- );
- } else {
- $insert_id = AnnouncementManager::add_announcement(
- $safe_emailTitle,
- $safe_newContent,
+ if (isset($id) && $id) {
+ // there is an Id => the announcement already exists => update mode
+ if ($ctok == $_POST['sec_token']) {
+ $file_comment = $_POST['file_comment'];
+ $file = $_FILES['user_upload'];
+
+ AnnouncementManager::edit_announcement(
+ $id,
+ $data['title'],
+ $data['content'],
$_POST['selectedform'],
$file,
$file_comment,
$sendToUsersInSession
);
- }
- //store_resources($_SESSION['source_type'],$insert_id);
- $_SESSION['select_groupusers']="hide";
- $message = get_lang('AnnouncementAdded');
- /* MAIL FUNCTION */
- if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) {
- AnnouncementManager::send_email($insert_id, $sendToUsersInSession);
+ /* MAIL FUNCTION */
+ if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) {
+ AnnouncementManager::send_email($id, $sendToUsersInSession);
+ }
+ Display::addFlash(Display::return_message(get_lang('AnnouncementModified'), 'success'));
+ header('Location: '.$homeUrl);
+ exit;
}
+ } else {
+ // Insert mode
+ if ($ctok == $_POST['sec_token']) {
+ $file = $_FILES['user_upload'];
+ $file_comment = $data['file_comment'];
+
+ if (empty($group_id)) {
+ $insert_id = AnnouncementManager::add_announcement(
+ $data['title'],
+ $data['content'],
+ $data['users'],
+ $file,
+ $file_comment,
+ $sendToUsersInSession
+ );
+ } else {
+ $insert_id = AnnouncementManager::add_group_announcement(
+ $data['title'],
+ $data['content'],
+ array('GROUP:' . $group_id),
+ $data['users'],
+ $file,
+ $file_comment,
+ $sendToUsersInSession
+ );
+ }
+ Display::addFlash(
+ Display::return_message(
+ get_lang('AnnouncementAdded'),
+ 'success'
+ )
+ );
- } // end condition token
- } // isset
-
- // UNSET VARIABLES
- unset($form_elements);
- $_SESSION['formelements']=null;
-
- $newContent = null;
- $emailTitle = null;
-
- unset($emailTitle);
- unset($newContent);
- unset($content_to_modify);
- unset($title_to_modify);
+ /* MAIL FUNCTION */
+ if (isset($data['email_ann']) && $data['email_ann']) {
+ AnnouncementManager::send_email($insert_id, $sendToUsersInSession);
+ }
+ header('Location: '.$homeUrl);
+ exit;
- } // if $submit Announcement
+ } // end condition token
+ }
+ }
+ break;
}
-/* Tool introduction */
-
-if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
- Display::display_introduction_section(TOOL_ANNOUNCEMENT);
+if (!empty($_GET['remind_inactive'])) {
+ $to[] = 'USER:'.intval($_GET['remind_inactive']);
}
+/*
+if (api_is_allowed_to_edit(false,true) OR
+ (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
+) {
-/* DISPLAY LEFT COLUMN */
-
-//condition for the session
-$session_id = api_get_session_id();
-$condition_session = api_get_session_condition($session_id, true, true);
-
-if (api_is_allowed_to_edit(false,true)) {
- // check teacher status
- if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
-
- if (api_get_group_id() == 0) {
- $group_condition = "";
- } else {
- $group_condition = " AND (ip.to_group_id='".api_get_group_id()."' OR ip.to_group_id = 0)";
+ //
+ if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) {
+ if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
+ api_not_allowed();
}
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref AND
- ip.tool = 'announcement' AND
- ip.visibility <> '2'
- $group_condition
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC
- LIMIT 0,$maximum";
- }
-} else {
- // students only get to see the visible announcements
- if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
- $group_memberships = GroupManager::get_group_ids($_course['real_id'], $_user['user_id']);
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
+ // RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
+ $id = intval($_GET['id']);
- if (api_get_group_id() == 0) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" .
- "OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
- } else {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."'
- OR ip.to_group_id IN (0, ".api_get_group_id()."))";
- }
- } else {
- if (api_get_group_id() == 0) {
- $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" .
- "OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
- } else {
- $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" .
- "OR ip.to_group_id IN (0, ".api_get_group_id().")) ";
- }
- }
+ if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
+ $sql = "SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id = '$id'";
+ $rs = Database::query($sql);
+ $myrow = Database::fetch_array($rs);
+ $last_id = $id;
+ $userUpload = isset($_FILES['user_upload']) ? $_FILES['user_upload'] : null;
+ $edit_attachment = AnnouncementManager::edit_announcement_attachment_file(
+ $last_id,
+ $userUpload,
+ $file_comment
+ );
- // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
- if (is_array($group_memberships) && count($group_memberships)>0) {
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
- announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref AND
- ip.tool='announcement'
- AND ip.visibility='1'
- $cond_user_id
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC
- LIMIT 0, $maximum";
- } else {
- // the user is not member of any group
- // this is an identified user => show the general announcements AND his personal announcements
- if ($_user['user_id']) {
-
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) ";
- } else {
- $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') ";
- }
- $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
- announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- AND ip.visibility='1'
- $cond_user_id
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC
- LIMIT 0, $maximum";
- } else {
+ if ($myrow) {
+ $announcement_to_modify = $myrow['id'];
+ $content_to_modify = $myrow['content'];
+ $title_to_modify = $myrow['title'];
- if (api_get_course_setting('allow_user_edit_announcement')) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0') ";
- } else {
- $cond_user_id = " AND ip.to_group_id='0' ";
+ if ($originalresource!=="no") {
+ $to = AnnouncementManager::load_edit_users("announcement", $announcement_to_modify);
}
-
- // the user is not identiefied => show only the general announcements
- $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
- announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- AND ip.visibility='1'
- AND ip.to_group_id='0'
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC
- LIMIT 0,$maximum";
+ $display_announcement_list = false;
}
}
}
+}*/
+
+$htmlHeadXtra[] = AnnouncementManager::to_javascript();
+
+$group_id = api_get_group_id();
+
+if (!empty($group_id)) {
+ $group_properties = GroupManager :: get_group_properties($group_id);
+ $interbreadcrumb[] = array("url" => "../group/group.php?".api_get_cidreq(), "name" => get_lang('Groups'));
+ $interbreadcrumb[] = array("url"=>"../group/group_space.php?".api_get_cidreq(), "name"=> get_lang('GroupSpace').' '.$group_properties['name']);
}
-$result = Database::query($sql);
-$announcement_number = Database::num_rows($result);
-/*
- ADD ANNOUNCEMENT / DELETE ALL
-*/
+if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
+ //we are not in the learning path
+ Display::display_header($nameTools,get_lang('Announcements'));
+}
+// Tool introduction
+if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
+ Display::display_introduction_section(TOOL_ANNOUNCEMENT);
+}
+
+// Actions
$show_actions = false;
-if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) {
+if ((api_is_allowed_to_edit(false,true) OR
+ (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and
+ (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
+) {
echo '';
if (isset($_GET['action']) && in_array($_GET['action'], array('add', 'modify','view'))) {
- echo "
".Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM)."";
+ echo "
".
+ Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM)."";
} else {
- echo "
".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM)."";
+ echo "
".
+ Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM)."";
}
$show_actions = true;
} else {
if (in_array($_GET['action'], array('view'))) {
echo '
';
}
}
@@ -582,509 +503,16 @@ if (api_is_allowed_to_edit() && $announcement_number > 1) {
echo "
".
Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM)."";
}
- } // if announcementNumber > 1
+ }
}
if ($show_actions)
echo '
';
+Display::showFlash();
-// ANNOUNCEMENTS LIST
-
-if ($message) {
- Display::display_confirmation_message($message);
- $display_announcement_list = true;
- $display_form = false;
-}
-if (!empty($error_message)) {
- Display::display_error_message($error_message);
- $display_announcement_list = false;
- $display_form = true;
-}
-
-/*
- DISPLAY FORM
-*/
-
-if ($display_form) {
-
- $content_to_modify = stripslashes($content_to_modify);
- $title_to_modify = stripslashes($title_to_modify);
-
- // DISPLAY ADD ANNOUNCEMENT COMMAND
- $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
- echo '
';
-
- if ((isset($_GET['action']) && isset($_GET['id']) && is_array($to))||isset($_GET['remindallinactives'])||isset($_GET['remind_inactive'])) {
- echo '';
- }
-
-} // end of displayform for announcement creation/edition
-
-/**
- * Announcements list display
- */
-$course_id = api_get_course_int_id();
-
-//if ($display_announcement_list && !$surveyid) {
-if ($display_announcement_list) {
- // by default we use the id of the current user. The course administrator can see the announcement of other users by using the user / group filter
- //$user_id=$_user['user_id'];
- if (isset($_SESSION['user'])) {
- //$user_id=$_SESSION['user'];
- }
- $user_id = api_get_user_id();
-
- if (isset($_SESSION['group'])) {
- //$group_id=$_SESSION['group'];
- }
- $group_id = api_get_group_id();
-
- $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
-
- //$is_group_member = GroupManager :: is_tutor(api_get_user_id());
-
- if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- // A.1. you are a course admin with a USER filter
- // => see only the messages of this specific user + the messages of the group (s)he is member of.
- if (!empty($_SESSION['user'])) {
-
- if (is_array($group_memberships) && count($group_memberships) > 0 ) {
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref AND
- ip.tool = 'announcement' AND
- (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )
- $condition_session
-
- ORDER BY display_order DESC";
-
- } else {
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref AND
- ip.tool ='announcement' AND
- (ip.to_user_id = $user_id OR ip.to_group_id='0') AND
- ip.visibility='1'
- $condition_session
- ORDER BY display_order DESC";
-
- }
- } elseif (api_get_group_id() != 0 ) {
- // A.2. you are a course admin with a GROUP filter
- // => see only the messages of this specific group
- $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- AND ip.visibility<>'2'
- AND (ip.to_group_id=$group_id OR ip.to_group_id='0')
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC";
- } else {
-
- // A.3 you are a course admin without any group or user filter
- // A.3.a you are a course admin without user or group filter but WITH studentview
- // => see all the messages of all the users and groups without editing possibilities
-
- if (isset($isStudentView) and $isStudentView=="true") {
- $sql="SELECT
- announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- AND ip.visibility='1'
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC";
- } else {
- // A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
- // => see all the messages of all the users and groups with editing possibilities
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- AND (ip.visibility='0' or ip.visibility='1')
- $condition_session
- GROUP BY ip.ref
- ORDER BY display_order DESC";
- }
- }
- } else {
- //STUDENT
-
- if (is_array($group_memberships) && count($group_memberships)>0) {
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- if (api_get_group_id() == 0) {
- //No group
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" .
- " OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
- } else {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."'
- OR ip.to_group_id IN (0, ".api_get_group_id()."))";
- }
- //$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )) ";
-
- } else {
- if (api_get_group_id() == 0) {
- $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
- } else {
- $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".api_get_group_id()."))";
- }
- }
-
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- $cond_user_id
- $condition_session
- AND ip.visibility='1'
- ORDER BY display_order DESC";
- } else {
- if ($_user['user_id']) {
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) ";
- } else {
- $cond_user_id = " AND (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') ";
- }
-
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
- announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref AND
- ip.tool='announcement'
- $cond_user_id
- $condition_session
- AND ip.visibility='1'
- AND announcement.session_id IN(0,".api_get_session_id().")
- ORDER BY display_order DESC";
- } else {
-
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' ) ";
- } else {
- $cond_user_id = " AND ip.to_group_id='0' ";
- }
-
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
- announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- $cond_user_id
- $condition_session
- AND ip.visibility='1'
- AND announcement.session_id IN(0,".api_get_session_id().")";
- }
- }
- }
-
- $result = Database::query($sql);
- $num_rows = Database::num_rows($result);
-
- // DISPLAY: NO ITEMS
-
- if (!isset($_GET['action']) || !in_array($_GET['action'], array('add', 'modify','view')))
- if ($num_rows == 0) {
- if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) {
- echo '';
- echo '
'.get_lang('Announcements').'
';
- echo Display::return_icon('valves.png', '', array(), 64);
- echo '
';
- echo Display::url(get_lang('AddAnnouncement'), api_get_self()."?".api_get_cidreq()."&action=add&origin=".$origin, array('class' => 'btn'));
- echo '
';
- echo '
';
- } else {
- //echo "".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM)."";
- Display::display_warning_message(get_lang('NoAnnouncements'));
- }
-
- } else {
- $iterator = 1;
- $bottomAnnouncement = $announcement_number;
-
- echo '';
- $ths = Display::tag('th', get_lang('Title'));
- $ths .= Display::tag('th', get_lang('By') );
- $ths .= Display::tag('th', get_lang('LastUpdateDate') );
- if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id']))
- OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- $ths .= Display::tag('th', get_lang('Modify'));
- }
-
- echo Display::tag('tr', $ths);
- $displayed = array();
-
- while ($myrow = Database::fetch_array($result, 'ASSOC')) {
- if (!in_array($myrow['id'], $displayed)) {
- $sent_to_icon = '';
- // the email icon
- if ($myrow['email_sent'] == '1') {
- $sent_to_icon = ' '.Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
- }
-
- $title = $myrow['title'].$sent_to_icon;
-
- /* DATE */
- $last_post_datetime = $myrow['end_date'];
-
- $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id);
- $myrow['visibility'] = $item_visibility;
-
- // the styles
- if ($myrow['visibility'] == '0') {
- $style='invisible';
- } else {
- $style = '';
- }
-
- echo '';
-
- // show attachment list
- $attachment_list = array();
- $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
-
- $attachment_icon = '';
- if (count($attachment_list)>0) {
- $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment'));
- }
-
- /* TITLE */
- $title = Display::url($title.$attachment_icon, api_get_self().'?'.api_get_cidreq().'&action=view&id='.$myrow['id']);
- echo Display::tag('td', Security::remove_XSS($title), array('class' => 'announcements-list-line-title '.$style));
-
- $user_info = api_get_user_info($myrow['insert_user_id']);
- $username = sprintf(get_lang("LoginX"), $user_info['username']);
- $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title'=>$username));
- echo Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user'));
- echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), array('class' => 'announcements-list-line-datetime'));
-
- // we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on
- $modify_icons = '';
- if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']))
- OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
-
- $modify_icons = "".Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."";
- if ($myrow['visibility']==1) {
- $image_visibility="visible";
- $alt_visibility=get_lang('Hide');
- } else {
- $image_visibility="invisible";
- $alt_visibility=get_lang('Visible');
- }
- $modify_icons .= "".
- Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."";
-
- // DISPLAY MOVE UP COMMAND only if it is not the top announcement
- if ($iterator != 1) {
- $modify_icons .= "".Display::return_icon('up.gif', get_lang('Up'))."";
- } else {
- $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up'));
- }
- if ($iterator < $bottomAnnouncement) {
- $modify_icons .= "".Display::return_icon('down.gif', get_lang('Down'))."";
- } else {
- $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
- }
- if (api_is_allowed_to_edit(false,true)) {
- $modify_icons .= "".
- Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).
- "";
- }
- $iterator ++;
- echo Display::tag('td', $modify_icons, array('class' => 'announcements-list-line-actions'));
- }
- echo "
";
- }
- $displayed[]=$myrow['id'];
- } // end while
- echo "
";
- }
-} // end: if ($displayAnnoucementList)
-
-
-if (isset($_GET['action']) && $_GET['action'] == 'view') {
- AnnouncementManager::display_announcement($announcement_id);
-}
/* FOOTER */
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
diff --git a/main/announcements/download.php b/main/announcements/download.php
index d68fe2811a..7f558c8285 100755
--- a/main/announcements/download.php
+++ b/main/announcements/download.php
@@ -53,7 +53,7 @@ if (is_dir($full_file_name)) {
$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
// launch event
-event_download($doc_url);
+Event::event_download($doc_url);
$course_id = api_get_course_int_id();
diff --git a/main/announcements/resources/js/main.js b/main/announcements/resources/js/main.js
index 3e056d61de..78ca6b89e3 100755
--- a/main/announcements/resources/js/main.js
+++ b/main/announcements/resources/js/main.js
@@ -34,8 +34,6 @@ $(function() {
}
}
});
-
-
});
});
diff --git a/main/attendance/attendance_controller.php b/main/attendance/attendance_controller.php
index 0e111238e7..777a7013cb 100755
--- a/main/attendance/attendance_controller.php
+++ b/main/attendance/attendance_controller.php
@@ -565,7 +565,7 @@ class AttendanceController
) . '&action=calendar_logins'
);
$form->addDateRangePicker('range', get_lang('Range'));
- $form->add_button('submit', get_lang('submit'));
+ $form->addButton('submit', get_lang('submit'));
if ($form->validate()) {
$values = $form->getSubmitValues();
diff --git a/main/attendance/attendance_sheet.php b/main/attendance/attendance_sheet.php
index d74b70ae5b..7678e0cc0e 100755
--- a/main/attendance/attendance_sheet.php
+++ b/main/attendance/attendance_sheet.php
@@ -345,7 +345,11 @@ if (api_is_allowed_to_edit(null, true) ||
echo '';
}
} else {
- echo '';
+ $calendarClass = null;
+ if (isset($calendar)) {
+ $calendarClass = "checkboxes_col_".$calendar['id'];
+ }
+ echo ' | ';
echo ' ';
echo '
diff --git a/main/attendance/layout.php b/main/attendance/layout.php
index dbc7537e24..ce84eb845f 100755
--- a/main/attendance/layout.php
+++ b/main/attendance/layout.php
@@ -18,7 +18,7 @@ Display :: display_header('');
Display::display_introduction_section($tool);
// Tracking
-event_access_tool($tool);
+Event::event_access_tool($tool);
// Display
echo $content;
diff --git a/main/auth/external_login/ldap.inc.php b/main/auth/external_login/ldap.inc.php
index d504a0a921..9b3f6e9f63 100755
--- a/main/auth/external_login/ldap.inc.php
+++ b/main/auth/external_login/ldap.inc.php
@@ -48,7 +48,7 @@ function extldap_connect()
$ds = ldap_connect($host);
}
if (!$ds) {
- $port = isset($extldap_config['port']) ? $ldap_config['port'] : 389;
+ $port = isset($extldap_config['port']) ? $extldap_config['port'] : 389;
error_log('EXTLDAP ERROR : cannot connect to '.$extldap_config['host'].':'.$port);
} else {
break;
diff --git a/main/auth/external_login/login.ldap.php b/main/auth/external_login/login.ldap.php
index d94c9eb392..e130db5efc 100755
--- a/main/auth/external_login/login.ldap.php
+++ b/main/auth/external_login/login.ldap.php
@@ -65,8 +65,7 @@ if ($ldap_user !== false) {
Session::write('_user', $_user);
$uidReset = true;
$logging_in = true;
- event_login();
- error_log("Calling event_login");
+ Event::event_login();
} else {
error_log('extldap_authenticate error');
$loginFailed = true;
diff --git a/main/auth/external_login/login.ws.php b/main/auth/external_login/login.ws.php
index a801c772f5..748c145159 100755
--- a/main/auth/external_login/login.ws.php
+++ b/main/auth/external_login/login.ws.php
@@ -27,8 +27,7 @@ if ($isValid === 1) {
Session::write('_user', $_user);
$uidReset = true;
$logging_in = true;
- event_login();
- //error_log('Calling event_login');
+ Event::event_login();
} else {
//error_log('WS authentication error - user not approved by external WS');
$loginFailed = true;
diff --git a/main/auth/external_login/newUser.ldap.php b/main/auth/external_login/newUser.ldap.php
index d59137805e..f422fbd366 100755
--- a/main/auth/external_login/newUser.ldap.php
+++ b/main/auth/external_login/newUser.ldap.php
@@ -2,38 +2,38 @@
// External login module : LDAP
/**
- * This file is included by main/inc/local.inc.php when extldap is activated, a user try to login
+ * This file is included by main/inc/local.inc.php when extldap is activated, a user try to login
* and chamilo does not find his user
- * Variables that can be used :
+ * Variables that can be used :
* - $login : string containing the username posted by the user
* - $password : string containing the password posted by the user
*
* Please configure the exldap module in main/auth/external_login/ldap.conf.php
- *
- * If login succeeds, we have to add the user in the chamilo database and then
- * we have 2 choices :
- * 1. - set $loginFailed to false,
- * - set $_SESSION['_user']['user_id'] with the dokeos user_id
+ *
+ * If login succeeds, we have to add the user in the chamilo database and then
+ * we have 2 choices :
+ * 1. - set $loginFailed to false,
+ * - set $_SESSION['_user']['user_id'] with the dokeos user_id
* - set $uidReset to true
* - let the script local.inc.php continue
*
- * 2. - set $_SESSION['_user']['user_id'] with the dokeos user_id
+ * 2. - set $_SESSION['_user']['user_id'] with the dokeos user_id
* - set $_SESSION['_user']['uidReset'] to true
* - upgrade user info in dokeos database if needeed
* - redirect to any page and let local.inc.php do the magic
- *
+ *
* If login fails we have also 2 choices :
- * 1. - unset $_user['user_id']
- * - set $loginFailed=true
+ * 1. - unset $_user['user_id']
+ * - set $loginFailed=true
* - set $uidReset = false
* User wil then have the user password incorrect message
*
- * 2. We redirect the user to index.php with appropriate message :
- * Possible messages are :
+ * 2. We redirect the user to index.php with appropriate message :
+ * Possible messages are :
* - index.php?loginFailed=1&error=access_url_inactive
* - index.php?loginFailed=1&error=account_expired
* - index.php?loginFailed=1&error=account_inactive
- * - index.php?loginFailed=1&error=user_password_incorrect
+ * - index.php?loginFailed=1&error=user_password_incorrect
* - index.php?loginFailed=1&error=unrecognize_sso_origin');
* */
@@ -55,13 +55,13 @@ if ($ldap_user !== false) {
$_user['uidReset'] = true;
Session::write('_user', $_user);
$uidReset = true;
- // Is user admin?
+ // Is user admin?
if ($chamilo_user['admin'] === true) {
$is_platformAdmin = true;
Database::query("INSERT INTO admin values ('$chamilo_uid')");
}
}
- event_login();
+ Event::event_login();
} else {
$loginFailed = true;
$uidReset = false;
diff --git a/main/auth/external_login/newUser.php b/main/auth/external_login/newUser.php
index cd4a825ca7..71a8ab8903 100755
--- a/main/auth/external_login/newUser.php
+++ b/main/auth/external_login/newUser.php
@@ -46,7 +46,7 @@ if ($user !== false && ($chamilo_uid = external_add_user($user)) !== false) {
// Can user create course
$is_allowedCreateCourse = (bool) (($user['status'] == COURSEMANAGER) or (api_get_setting('drhCourseManagerRights') and $user['status'] == SESSIONADMIN));
- event_login();
+ Event::event_login();
} else {
$loginFailed = true;
unset($_user['user_id']);
diff --git a/main/auth/inscription.php b/main/auth/inscription.php
index 937e95981b..787dda0abd 100755
--- a/main/auth/inscription.php
+++ b/main/auth/inscription.php
@@ -601,7 +601,7 @@ if ($form->validate()) {
Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
// Stats
- event_login();
+ Event::event_login();
// last user login date is now
$user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970
diff --git a/main/auth/ldap/authldap.php b/main/auth/ldap/authldap.php
index b8fd83c6d7..31d15a2224 100755
--- a/main/auth/ldap/authldap.php
+++ b/main/auth/ldap/authldap.php
@@ -62,6 +62,7 @@ use \ChamiloSession as Session;
/**
* Code
*/
+require_once api_get_path(SYS_CODE_PATH).'auth/external_login/ldap.inc.php';
require 'ldap_var.inc.php';
/**
* Check login and password with LDAP
@@ -325,7 +326,9 @@ function ldap_set_version(&$resource) {
*/
function ldap_handle_bind(&$ldap_handler,&$ldap_bind) {
//error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0);
- global $ldap_rdn,$ldap_pass;
+ global $ldap_rdn,$ldap_pass, $extldap_config;
+ $ldap_rdn = $extldap_config['admin_dn'];
+ $ldap_pass = $extldap_config['admin_password'];
if (!empty($ldap_rdn) and !empty($ldap_pass)) {
//error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0);
$ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass);
@@ -352,21 +355,23 @@ function ldap_handle_bind(&$ldap_handler,&$ldap_bind) {
*/
function ldap_get_users() {
- global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass;
+ global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance;
- $keyword_firstname = trim(Database::escape_string($_GET['keyword_firstname']));
- $keyword_lastname = trim(Database::escape_string($_GET['keyword_lastname']));
- $keyword_username = trim(Database::escape_string($_GET['keyword_username']));
- $keyword_type = Database::escape_string($_GET['keyword_type']);
+ $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): '';
+ $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : '';
+ $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : '';
+ $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : '';
$ldap_query=array();
if ($keyword_username != "") {
- $ldap_query[]="(uid=".$keyword_username."*)";
- } else if ($keyword_lastname!=""){
- $ldap_query[]="(sn=".$keyword_lastname."*)";
+ $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn);
+ } else {
+ if ($keyword_lastname!=""){
+ $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
+ }
if ($keyword_firstname!="") {
- $ldap_query[]="(givenName=".$keyword_firstname."*)";
+ $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
}
}
if ($keyword_type !="" && $keyword_type !="all") {
@@ -380,7 +385,7 @@ function ldap_get_users() {
}
$str_query.=" )";
} else {
- $str_query=$ldap_query[0];
+ $str_query= count($ldap_query) > 0 ? $ldap_query[0] : null;
}
$ds = ldap_connect($ldap_host, $ldap_port);
@@ -421,6 +426,9 @@ function ldap_get_number_of_users() {
* @author Mustapha Alouani
*/
function ldap_get_user_data($from, $number_of_items, $column, $direction) {
+
+ global $extldap_user_correspondance;
+
$users = array();
$is_western_name_order = api_is_western_name_order();
if (isset($_GET['submit'])) {
@@ -434,17 +442,17 @@ function ldap_get_user_data($from, $number_of_items, $column, $direction) {
//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
//$user[] = $dn_array[0]; // uid is first key
//$user[] = $dn_array[0]; // uid is first key
- $user[] = $info[$key]['uid'][0];
- $user[] = $info[$key]['uid'][0];
+ $user[] = $info[$key][$extldap_user_correspondance['username']][0];
+ $user[] = $info[$key][$extldap_user_correspondance['username']][0];
if ($is_western_name_order) {
- $user[] = api_convert_encoding($info[$key]['cn'][0], api_get_system_encoding(), 'UTF-8');
- $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8');
+ $user[] = api_convert_encoding($info[$key][$extldap_user_correspondance['firstname']][0], api_get_system_encoding(), 'UTF-8');
+ $user[] = api_convert_encoding($info[$key][$extldap_user_correspondance['lastname']][0], api_get_system_encoding(), 'UTF-8');
} else {
- $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8');
- $user[] = api_convert_encoding($info[$key]['cn'][0], api_get_system_encoding(), 'UTF-8');
+ $user[] = api_convert_encoding($info[$key][$extldap_user_correspondance['firstname']][0], api_get_system_encoding(), 'UTF-8');
+ $user[] = api_convert_encoding($info[$key][$extldap_user_correspondance['lastname']][0], api_get_system_encoding(), 'UTF-8');
}
$user[] = $info[$key]['mail'][0];
- $outab[] = $info[$key]['eduPersonPrimaryAffiliation'][0]; // Ici "student"
+ $user[] = $info[$key][$extldap_user_correspondance['username']][0];
$users[] = $user;
}
} else {
@@ -462,9 +470,12 @@ function ldap_get_user_data($from, $number_of_items, $column, $direction) {
* @author Mustapha Alouani
*/
function modify_filter($user_id,$url_params, $row) {
- $url_params_id="id[]=".$row[0];
+ $query_string="id[]=".$row[0];
+ if (!empty($_GET['id_session'])){
+ $query_string .= '&id_session='.Security::remove_XSS($_GET['id_session']);
+ }
//$url_params_id="id=".$row[0];
- $result .= ''.Display::return_icon('add_user.gif', get_lang('AddUsers')).'';
+ $result = ''.Display::return_icon('add_user.gif', get_lang('AddUsers')).'';
return $result;
}
@@ -474,26 +485,9 @@ function modify_filter($user_id,$url_params, $row) {
* @author Mustapha Alouani
*/
function ldap_add_user($login) {
- global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass;
- $ds = ldap_connect($ldap_host, $ldap_port);
- ldap_set_version($ds);
- $user_id = 0;
- if ($ds) {
- $str_query="(uid=".$login.")";
- $r = false;
- $res = ldap_handle_bind($ds, $r);
- $sr = ldap_search($ds, $ldap_basedn, $str_query);
- //echo "Number of results is : ".ldap_count_entries($ds,$sr)."";
- $info = ldap_get_entries($ds, $sr);
-
- for ($key = 0; $key < $info['count']; $key ++) {
- $user_id = ldap_add_user_by_array($info[$key]);
- }
-
- } else {
- Display :: display_error_message(get_lang('LDAPConnectionError'));
+ if ($ldap_user = extldap_authenticate($login, 'nopass', true)) {
+ return extldap_add_user_by_array($ldap_user);
}
- return $user_id;
}
function ldap_add_user_by_array($data, $update_if_exists = true) {
diff --git a/main/auth/ldap/ldap_var.inc.php b/main/auth/ldap/ldap_var.inc.php
index 5ff295e59f..60f39b637d 100755
--- a/main/auth/ldap/ldap_var.inc.php
+++ b/main/auth/ldap/ldap_var.inc.php
@@ -23,24 +23,24 @@
* Configuration settings
*/
// your ldap server
-$ldap_host = api_get_setting('ldap_main_server_address');
+$ldap_host = $extldap_config['host'][0];
// your ldap server's port number
-$ldap_port = api_get_setting('ldap_main_server_port');
+$ldap_port = @$extldap_config['port'] ?: null;
//domain
-$ldap_basedn = api_get_setting('ldap_domain');
+$ldap_basedn = $extldap_config['base_dn'];
//search term for students
-$ldap_search_dn = api_get_setting('ldap_search_string');
+$ldap_search_dn = $extldap_config['user_search'];
//additional server params for use of replica in case of problems
-$ldap_host2 = api_get_setting('ldap_replicate_server_address');
-$ldap_port2 = api_get_setting('ldap_replicate_server_port');
+$ldap_host2 = count($extldap_config['host']) > 1 ? $extldap_config['host'][1] : null;
+$ldap_port2 = $extldap_config['port'];
//protocol version - set to 3 for LDAP 3
-$ldap_version = api_get_setting('ldap_version');
+$ldap_version = $extldap_config['protocol_version'];
//non-anonymous LDAP mode
-$ldap_rdn = api_get_setting('ldap_authentication_login');
-$ldap_pass = api_get_setting('ldap_authentication_password');
+$ldap_rdn = $extldap_config['admin_dn'];
+$ldap_pass = $extldap_config['admin_password'];
$ldap_pass_placeholder = "PLACEHOLDER";
diff --git a/main/auth/ldap/login.php b/main/auth/ldap/login.php
index 5906a37243..5df705e0c9 100755
--- a/main/auth/ldap/login.php
+++ b/main/auth/ldap/login.php
@@ -34,7 +34,7 @@ if ($loginLdapSucces)
$_user['user_id'] = $uData['user_id'];
Session::write('_uid',$_uid);
// Jand: copied from event_login in events.lib.php to enable login statistics:
- event_login();
+ Event::event_login();
}
else
{
diff --git a/main/auth/my_progress.php b/main/auth/my_progress.php
index abfd81aa05..5963053df2 100755
--- a/main/auth/my_progress.php
+++ b/main/auth/my_progress.php
@@ -65,7 +65,7 @@ if (!empty($course_user_list)) {
if ($count == $last_item) {
$last = ''.get_lang('Last').'';
}
- $course_info = api_get_course_info($result['course_code']);
+ $course_info = api_get_course_info_by_id($result['c_id']);
$course_image = ' ';
$dates .= ' '.api_get_utc_datetime($login).'';
$issues .= '
diff --git a/main/auth/shibboleth/lib/shibboleth_session.class.php b/main/auth/shibboleth/lib/shibboleth_session.class.php
index 849da6a27e..4dcfdf35f8 100755
--- a/main/auth/shibboleth/lib/shibboleth_session.class.php
+++ b/main/auth/shibboleth/lib/shibboleth_session.class.php
@@ -80,14 +80,14 @@ class ShibbolethSession
$_SESSION['noredirection'] = true;
//must be called before 'init_local.inc.php'
- event_login();
+ Event::event_login();
//used in 'init_local.inc.php' this is BAD but and should be changed
$loginFailed = false;
$uidReset = true;
$gidReset = true;
- $cidReset = false; //FALSE !!
+ $cidReset = false; //FALSE !!
$mainDbName = Database :: get_main_database();
$includePath = api_get_path(INCLUDE_PATH);
@@ -98,4 +98,4 @@ class ShibbolethSession
return $_user;
}
-}
\ No newline at end of file
+}
diff --git a/main/auth/sso/sso.Drupal.class.php b/main/auth/sso/sso.Drupal.class.php
index d2214f0802..e5c8d51cf1 100755
--- a/main/auth/sso/sso.Drupal.class.php
+++ b/main/auth/sso/sso.Drupal.class.php
@@ -4,7 +4,7 @@ use \ChamiloSession as Session;
/* For licensing terms, see /license.txt */
/**
- * This file contains the necessary elements to implement a Single Sign On
+ * This file contains the necessary elements to implement a Single Sign On
* mechanism with an external Drupal application (on which the Chamilo module
* 7.x-1.0-alpha3 or above must be implemented)
*
@@ -16,7 +16,7 @@ use \ChamiloSession as Session;
*
* @package chamilo.auth.sso
*/
-
+
/**
* The SSO class allows for management of remote Single Sign On resources
*/
@@ -44,9 +44,9 @@ class ssoDrupal {
$this->master_url = $this->protocol.$this->domain.$this->auth_uri;
$this->target = api_get_path(WEB_PATH);
}
-
+
/**
- * Unlogs the user from the remote server
+ * Unlogs the user from the remote server
*/
public function logout() {
header('Location: '.$this->deauth_url);
@@ -69,7 +69,7 @@ class ssoDrupal {
header('Location: '.$this->master_url.$params);
exit;
}
-
+
/**
* Validates the received active connection data with the database
* @return bool Return the loginFailed variable value to local.inc.php
@@ -100,29 +100,29 @@ class ssoDrupal {
//Check the user's password
if ($uData['auth_source'] == PLATFORM_AUTH_SOURCE) {
- if ($sso['secret'] === sha1($uData['username'].$sso_challenge.api_get_security_key())
+ if ($sso['secret'] === sha1($uData['username'].$sso_challenge.api_get_security_key())
&& ($sso['username'] == $uData['username'])) {
//Check if the account is active (not locked)
if ($uData['active']=='1') {
// check if the expiration date has not been reached
- if ($uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
-
+ if ($uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
+
//If Multiple URL is enabled
if (api_get_multiple_access_url()) {
//Check the access_url configuration setting if the user is registered in the access_url_rel_user table
//Getting the current access_url_id of the platform
$current_access_url_id = api_get_current_access_url_id();
- // my user is subscribed in these
+ // my user is subscribed in these
//sites: $my_url_list
$my_url_list = api_get_access_url_from_user($uData['user_id']);
} else {
$current_access_url_id = 1;
$my_url_list = array(1);
}
-
+
$my_user_is_admin = UserManager::is_admin($uData['user_id']);
-
+
if ($my_user_is_admin === false) {
if (is_array($my_url_list) && count($my_url_list) > 0 ) {
if (in_array($current_access_url_id, $my_url_list)) {
@@ -130,7 +130,7 @@ class ssoDrupal {
$_user['user_id'] = $uData['user_id'];
$_user = api_get_user_info($_user['user_id']);
Session::write('_user', $_user);
- event_login();
+ Event::event_login();
// Redirect to homepage
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php';
header('Location: '. $sso_target);
@@ -143,7 +143,7 @@ class ssoDrupal {
exit;
}
} else {
- // there is no URL in the multiple
+ // there is no URL in the multiple
// urls list for this user
$loginFailed = true;
Session::erase('_uid');
@@ -153,23 +153,23 @@ class ssoDrupal {
} else {
//Only admins of the "main" (first) Chamilo
// portal can login wherever they want
- if (in_array(1, $my_url_list)) {
- //Check if this admin is admin on the
+ if (in_array(1, $my_url_list)) {
+ //Check if this admin is admin on the
// principal portal
$_user['user_id'] = $uData['user_id'];
$_user = api_get_user_info($_user['user_id']);
$is_platformAdmin = $uData['status'] == COURSEMANAGER;
Session::write('is_platformAdmin', $is_platformAdmin);
Session::write('_user', $_user);
- event_login();
+ Event::event_login();
} else {
- //Secondary URL admin wants to login
+ //Secondary URL admin wants to login
// so we check as a normal user
if (in_array($current_access_url_id, $my_url_list)) {
$_user['user_id'] = $uData['user_id'];
$_user = api_get_user_info($_user['user_id']);
Session::write('_user',$_user);
- event_login();
+ Event::event_login();
} else {
$loginFailed = true;
Session::erase('_uid');
@@ -177,7 +177,7 @@ class ssoDrupal {
exit;
}
}
- }
+ }
} else {
// user account expired
$loginFailed = true;
@@ -215,7 +215,7 @@ class ssoDrupal {
}
return $loginFailed;
}
-
+
/**
* Decode the cookie (this function may vary depending on the
* Single Sign On implementation
@@ -230,7 +230,7 @@ class ssoDrupal {
* Generate the URL for profile editing for a any user or the current user
* @param int $userId Optional. The user id
* @param boolean $asAdmin Optional. Whether get the URL for the platform admin
- * @return string If the URL is obtained return the drupal_user_id. Otherwise return false
+ * @return string If the URL is obtained return the drupal_user_id. Otherwise return false
*/
public function generateProfileEditingURL($userId = 0, $asAdmin = false)
{
@@ -243,18 +243,19 @@ class ssoDrupal {
$userExtraFieldValue = new ExtraFieldValue('user');
$drupalUserIdData = $userExtraFieldValue->get_values_by_handler_and_field_variable($userId, 'drupal_user_id');
+ // If this is an administrator, allow him to make some changes in
+ // the Chamilo profile
+ if ($asAdmin && api_is_platform_admin(true)) {
+ return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$userId";
+ }
+ // If the user doesn't match a Drupal user, give the normal profile
+ // link
if ($drupalUserIdData === false) {
- if ($asAdmin && api_is_platform_admin(true)) {
- return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$userId";
- }
-
return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
}
-
+ // In all other cases, generate a link to the Drupal profile edition
$drupalUserId = $drupalUserIdData['field_value'];
-
$url = "{$this->protocol}{$this->domain}/user/{$drupalUserId}/edit";
-
return $url;
}
diff --git a/main/auth/sso/sso.class.php b/main/auth/sso/sso.class.php
index ab827d00cd..f70e037e59 100755
--- a/main/auth/sso/sso.class.php
+++ b/main/auth/sso/sso.class.php
@@ -4,11 +4,11 @@ use \ChamiloSession as Session;
/* For licensing terms, see /license.txt */
/**
- * This file contains the necessary elements to implement a Single Sign On
- * mechanism with an arbitrary external web application (given some light
+ * This file contains the necessary elements to implement a Single Sign On
+ * mechanism with an arbitrary external web application (given some light
* development there) and is based on the Drupal-Chamilo module implementation.
* To develop a new authentication mechanism, please extend this class and
- * overwrite its method, then modify the corresponding calling code in
+ * overwrite its method, then modify the corresponding calling code in
* main/inc/local.inc.php
* @package chamilo.auth.sso
*/
@@ -40,16 +40,16 @@ class sso {
$this->master_url = $this->protocol.$this->domain.$this->auth_uri;
$this->target = api_get_path(WEB_PATH);
}
-
+
/**
- * Unlogs the user from the remote server
+ * Unlogs the user from the remote server
*/
public function logout()
{
header('Location: '.$this->deauth_url);
exit;
}
-
+
/**
* Sends the user to the master URL for a check of active connection
*/
@@ -68,7 +68,7 @@ class sso {
header('Location: '.$this->master_url.$params);
exit;
}
-
+
/**
* Validates the received active connection data with the database
* @return bool Return the loginFailed variable value to local.inc.php
@@ -79,10 +79,10 @@ class sso {
$loginFailed = false;
//change the way we recover the cookie depending on how it is formed
$sso = $this->decode_cookie($_GET['sso_cookie']);
-
+
//error_log('check_user');
//error_log('sso decode cookie: '.print_r($sso,1));
-
+
//lookup the user in the main database
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user_id, username, password, auth_source, active, expiration_date, status
@@ -97,7 +97,7 @@ class sso {
//This user's authentification is managed by Chamilo itself
// check the user's password
// password hash comes already parsed in sha1, md5 or none
-
+
/*
error_log($sso['secret']);
error_log($uData['password']);
@@ -125,7 +125,7 @@ class sso {
// check if the expiration date has not been reached
if ($uData['expiration_date'] > date('Y-m-d H:i:s')
or $uData['expiration_date']=='0000-00-00 00:00:00') {
-
+
//If Multiple URL is enabled
if (api_get_multiple_access_url()) {
//Check the access_url configuration setting if
@@ -139,9 +139,9 @@ class sso {
$current_access_url_id = 1;
$my_url_list = array(1);
}
-
+
$my_user_is_admin = UserManager::is_admin($uData['user_id']);
-
+
if ($my_user_is_admin === false) {
if (is_array($my_url_list) && count($my_url_list) > 0) {
if (in_array($current_access_url_id, $my_url_list)) {
@@ -149,7 +149,7 @@ class sso {
$_user['user_id'] = $uData['user_id'];
$_user = api_get_user_info($_user['user_id']);
Session::write('_user', $_user);
- event_login();
+ Event::event_login();
// Redirect to homepage
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php';
header('Location: '. $sso_target);
@@ -180,7 +180,7 @@ class sso {
$is_platformAdmin = $uData['status'] == COURSEMANAGER;
Session::write('is_platformAdmin', $is_platformAdmin);
Session::write('_user', $_user);
- event_login();
+ Event::event_login();
} else {
//Secondary URL admin wants to login
// so we check as a normal user
@@ -188,7 +188,7 @@ class sso {
$_user['user_id'] = $uData['user_id'];
$_user = api_get_user_info($_user['user_id']);
Session::write('_user', $_user);
- event_login();
+ Event::event_login();
} else {
$loginFailed = true;
Session::erase('_uid');
@@ -243,7 +243,7 @@ class sso {
}
return $loginFailed;
}
-
+
/**
* Decode the cookie (this function may vary depending on the
* Single Sign On implementation
@@ -259,7 +259,7 @@ class sso {
* Generate the URL for profile editing for a any user or the current user
* @param int $userId Optional. The user id
* @param boolean $asAdmin Optional. Whether get the URL for the platform admin
- * @return string The SSO URL
+ * @return string The SSO URL
*/
public function generateProfileEditingURL($userId = 0, $asAdmin = false)
{
diff --git a/main/blog/blog.php b/main/blog/blog.php
index 28da6c62ce..ff11b8ed26 100755
--- a/main/blog/blog.php
+++ b/main/blog/blog.php
@@ -6,9 +6,6 @@
* @package chamilo.blogs
*/
-/**
- * INIT
- */
// name of the language file that needs to be included
$language_file = "blog";
require_once '../inc/global.inc.php';
@@ -22,18 +19,11 @@ if (empty($blog_id)) {
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_BLOGS;
-
/* ACCESS RIGHTS */
// notice for unauthorized people.
api_protect_course_script(true);
-//session
-if(isset($_GET['id_session'])) {
- $_SESSION['id_session'] = intval($_GET['id_session']);
-}
-
$lib_path = api_get_path(LIBRARY_PATH);
-
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang('Blogs');
@@ -41,95 +31,146 @@ $DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
-$current_page = $_GET['action'];
+$action = isset($_GET['action']) ? $_GET['action'] : null;
/*
PROCESSING
*/
-$safe_post_title = Security::remove_XSS($_POST['post_title']);
-$safe_post_file_comment = Security::remove_XSS($_POST['post_file_comment']);
-$safe_post_full_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY);
-$safe_comment_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY);
-$safe_comment_title = Security::remove_XSS($_POST['comment_title']);
-$safe_task_name = Security::remove_XSS($_POST['task_name']);
-$safe_task_description = Security::remove_XSS($_POST['task_description']);
-
-if (!empty($_POST['new_post_submit']) AND !empty($_POST['post_title'])) {
- Blog :: create_post($safe_post_title, $safe_post_full_text, $safe_post_file_comment,$blog_id);
+$safe_post_file_comment = isset($_GET['post_file_comment']) ? Security::remove_XSS($_POST['post_file_comment']) : null;
+$safe_comment_text = isset($_GET['comment_text']) ? Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY) : null;
+$safe_comment_title = isset($_GET['comment_title']) ? Security::remove_XSS($_POST['comment_title']) : null;
+$safe_task_name = isset($_GET['task_name']) ? Security::remove_XSS($_POST['task_name']) : null;
+$safe_task_description = isset($_GET['task_description']) ? Security::remove_XSS($_POST['task_description']) : null;
+
+if (!empty($_POST['new_post_submit'])) {
+ Blog:: create_post(
+ $_POST['title'],
+ $_POST['full_text'],
+ $_POST['post_file_comment'],
+ $blog_id
+ );
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded'));
}
-if (!empty($_POST['edit_post_submit']))
-{
- $safe_post_title = Security::remove_XSS($_POST['post_title']);
- Blog :: edit_post($_POST['post_id'], $safe_post_title, $safe_post_full_text, $blog_id);
+if (!empty($_POST['edit_post_submit'])) {
+ Blog:: edit_post(
+ $_POST['post_id'],
+ $_POST['title'],
+ $_POST['full_text'],
+ $blog_id
+ );
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogEdited'));
}
-if (!empty($_POST['new_comment_submit']))
-{
- Blog :: create_comment($safe_comment_title, $safe_comment_text, $safe_post_file_comment,$blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id']);
+
+if (!empty($_POST['new_comment_submit'])) {
+ Blog:: create_comment(
+ $_POST['title'],
+ $_POST['comment'],
+ $_POST['post_file_comment'],
+ $blog_id,
+ $_GET['post_id'],
+ $_POST['comment_parent_id']
+ );
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentAdded'));
}
-if (!empty($_POST['new_task_submit']))
-{
- Blog :: create_task($blog_id, $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'], $_POST['chkCommentsDelete'], $_POST['task_color']);
+if (!empty($_POST['new_task_submit'])) {
+ Blog:: create_task(
+ $blog_id,
+ $safe_task_name,
+ $safe_task_description,
+ $_POST['chkArticleDelete'],
+ $_POST['chkArticleEdit'],
+ $_POST['chkCommentsDelete'],
+ $_POST['task_color']
+ );
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskCreated'));
}
-if (isset($_POST['edit_task_submit']))
-{
- Blog :: edit_task($_POST['blog_id'], $_POST['task_id'], $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'],$_POST['chkCommentsDelete'], $_POST['task_color']);
- $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskEdited'));
+if (isset($_POST['edit_task_submit'])) {
+ Blog:: edit_task(
+ $_POST['blog_id'],
+ $_POST['task_id'],
+ $safe_task_name,
+ $safe_task_description,
+ $_POST['chkArticleDelete'],
+ $_POST['chkArticleEdit'],
+ $_POST['chkCommentsDelete'],
+ $_POST['task_color']
+ );
+ $return_message = array(
+ 'type' => 'confirmation',
+ 'message' => get_lang('TaskEdited')
+ );
}
-if (!empty($_POST['assign_task_submit']))
-{
- Blog :: assign_task($blog_id, $_POST['task_user_id'], $_POST['task_task_id'], $_POST['task_year']."-".$_POST['task_month']."-".$_POST['task_day']);
- $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssigned'));
+
+if (!empty($_POST['assign_task_submit'])) {
+ Blog:: assign_task(
+ $blog_id,
+ $_POST['task_user_id'],
+ $_POST['task_task_id'],
+ $_POST['task_year'] . "-" . $_POST['task_month'] . "-" . $_POST['task_day']
+ );
+ $return_message = array(
+ 'type' => 'confirmation',
+ 'message' => get_lang('TaskAssigned')
+ );
}
-if (isset($_POST['assign_task_edit_submit']))
-{
- Blog :: edit_assigned_task($blog_id, $_POST['task_user_id'], $_POST['task_task_id'], $_POST['task_year']."-".$_POST['task_month']."-".$_POST['task_day'], $_POST['old_user_id'], $_POST['old_task_id'], $_POST['old_target_date']);
- $return_message = array('type' => 'confirmation', 'message' => get_lang('AssignedTaskEdited'));
+if (isset($_POST['assign_task_edit_submit'])) {
+ Blog:: edit_assigned_task(
+ $blog_id,
+ $_POST['task_user_id'],
+ $_POST['task_task_id'],
+ $_POST['task_year'] . "-" . $_POST['task_month'] . "-" . $_POST['task_day'],
+ $_POST['old_user_id'],
+ $_POST['old_task_id'],
+ $_POST['old_target_date']
+ );
+ $return_message = array(
+ 'type' => 'confirmation',
+ 'message' => get_lang('AssignedTaskEdited')
+ );
}
-if (!empty($_POST['new_task_execution_submit']))
-{
- Blog :: create_comment($safe_comment_title, $safe_comment_text, $blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id'], $_POST['task_id']);
- $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentCreated'));
+if (!empty($_POST['new_task_execution_submit'])) {
+ Blog:: create_comment(
+ $safe_comment_title,
+ $safe_comment_text,
+ $blog_id,
+ (int)$_GET['post_id'],
+ $_POST['comment_parent_id'],
+ $_POST['task_id']
+ );
+ $return_message = array(
+ 'type' => 'confirmation',
+ 'message' => get_lang('CommentCreated')
+ );
}
-if (!empty($_POST['register']))
-{
+if (!empty($_POST['register'])) {
if (is_array($_POST['user'])) {
- foreach ($_POST['user'] as $index => $user_id)
- {
+ foreach ($_POST['user'] as $index => $user_id) {
Blog :: set_user_subscribed((int)$_GET['blog_id'], $user_id);
}
}
}
-if (!empty($_POST['unregister']))
-{
+if (!empty($_POST['unregister'])) {
if (is_array($_POST['user'])) {
- foreach ($_POST['user'] as $index => $user_id)
- {
+ foreach ($_POST['user'] as $index => $user_id) {
Blog :: set_user_unsubscribed((int)$_GET['blog_id'], $user_id);
}
}
}
-if (!empty($_GET['register']))
-{
+if (!empty($_GET['register'])) {
Blog :: set_user_subscribed((int)$_GET['blog_id'], (int)$_GET['user_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('UserRegistered'));
$flag = 1;
}
-if (!empty($_GET['unregister']))
-{
+if (!empty($_GET['unregister'])) {
Blog :: set_user_unsubscribed((int)$_GET['blog_id'], (int)$_GET['user_id']);
}
if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') {
- if (isset($_GET['do']) && $_GET['do'] == 'delete')
- {
+ if (isset($_GET['do']) && $_GET['do'] == 'delete') {
Blog :: delete_task($blog_id, (int)$_GET['task_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskDeleted'));
}
@@ -138,54 +179,40 @@ if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') {
Blog :: delete_assigned_task($blog_id, intval($_GET['task_id']), intval($_GET['user_id']));
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssignmentDeleted'));
}
-
}
if (isset($_GET['action']) && $_GET['action'] == 'view_post') {
$task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0;
- if (isset($_GET['do']) && $_GET['do'] == 'delete_comment')
- {
- if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id))
- {
+ if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') {
+ if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) {
Blog :: delete_comment($blog_id, (int)$_GET['post_id'],(int)$_GET['comment_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentDeleted'));
- }
- else
- {
+ } else {
$error = true;
$message = get_lang('ActionNotAllowed');
}
}
- if (isset($_GET['do']) && $_GET['do'] == 'delete_article')
- {
- if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id))
- {
+ if (isset($_GET['do']) && $_GET['do'] == 'delete_article') {
+ if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) {
Blog :: delete_post($blog_id, (int)$_GET['article_id']);
- $current_page = ''; // Article is gone, go to blog home
+ $action = ''; // Article is gone, go to blog home
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogDeleted'));
- }
- else
- {
+ } else {
$error = true;
$message = get_lang('ActionNotAllowed');
}
}
- if (isset($_GET['do']) && $_GET['do'] == 'rate')
- {
- if (isset($_GET['type']) && $_GET['type'] == 'post')
- {
- if (api_is_allowed('BLOG_'.$blog_id, 'article_rate'))
- {
+ if (isset($_GET['do']) && $_GET['do'] == 'rate') {
+ if (isset($_GET['type']) && $_GET['type'] == 'post') {
+ if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) {
Blog :: add_rating('post', $blog_id, (int)$_GET['post_id'], (int)$_GET['rating']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded'));
}
}
- if (isset($_GET['type']) && $_GET['type'] == 'comment')
- {
- if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add'))
- {
+ if (isset($_GET['type']) && $_GET['type'] == 'comment') {
+ if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) {
Blog :: add_rating('comment', $blog_id, (int)$_GET['comment_id'], (int)$_GET['rating']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded'));
}
@@ -198,7 +225,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post') {
$htmlHeadXtra[] = '';
// Set bredcrumb
-switch ($current_page) {
+switch ($action) {
case 'new_post' :
$nameTools = get_lang('NewPost');
$interbreadcrumb[] = array ('url' => "blog.php?blog_id=$blog_id", "name" => Blog :: get_blog_title($blog_id));
@@ -244,7 +271,6 @@ if (!empty($return_message)) {
}
}
-
// actions
echo '';
?>
@@ -256,9 +282,8 @@ echo ' ';
echo ' ';
// Tool introduction
-Display::display_introduction_section(TOOL_BLOG);
+Display::display_introduction_section(TOOL_BLOGS);
-//Display::display_header($nameTools,'Blogs');
?>
@@ -309,7 +334,7 @@ if (isset($error)) {
}
if (isset($flag) && $flag == '1') {
- $current_page = "manage_tasks";
+ $action = "manage_tasks";
Blog :: display_assign_task_form($blog_id);
}
@@ -338,13 +363,13 @@ if (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) {
$user_task = true;
}
-switch ($current_page) {
- case 'new_post' :
+switch ($action) {
+ case 'new_post':
if (api_is_allowed('BLOG_'.$blog_id, 'article_add', $user_task ? $task_id : 0)) {
// we show the form if
// 1. no post data
// 2. there is post data and the required field is empty
- if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) {
+ if (!$_POST OR (!empty($_POST) AND empty($_POST['title']))) {
// if there is post data there is certainly an error in the form
if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
diff --git a/main/blog/blog_admin.php b/main/blog/blog_admin.php
index 5853833dcf..337d800c9e 100755
--- a/main/blog/blog_admin.php
+++ b/main/blog/blog_admin.php
@@ -1,13 +1,12 @@
'blog_admin.php?'.$my_url,
- 'name' => $current_section
- );
+ /*$interbreadcrumb[] = array(
+ 'url' => 'blog_admin.php?' . $my_url,
+ 'name' => $current_section
+ );*/
Display::display_header('');
- } else {
}
echo ' ';
- /*
- PROCESSING..
- */
- $get_blog_name = Security::remove_XSS($_POST['blog_name']);
- $get_blog_subtitle = Security::remove_XSS($_POST['blog_subtitle']);
- $get_blog_id = Security::remove_XSS($_POST['blog_id']);
-
if (!empty($_POST['new_blog_submit']) AND !empty($_POST['blog_name'])) {
- if (strlen(trim($_POST['blog_name']))>0) {
- Blog::create_blog($get_blog_name,$get_blog_subtitle);
+ if (isset($_POST['blog_name'])) {
+ Blog::create_blog($_POST['blog_name'], $_POST['blog_subtitle']);
Display::display_confirmation_message(get_lang('BlogStored'));
}
}
if (!empty($_POST['edit_blog_submit']) AND !empty($_POST['blog_name'])) {
if (strlen(trim($_POST['blog_name']))>0) {
- Blog::edit_blog($get_blog_id,$get_blog_name,$get_blog_subtitle);
+ Blog::edit_blog($_POST['blog_id'], $_POST['blog_name'], $_POST['blog_subtitle']);
Display::display_confirmation_message(get_lang('BlogEdited'));
}
}
@@ -96,11 +88,11 @@ if (api_is_allowed_to_edit()) {
/*if ($_POST){
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}*/
- if (strlen($_POST['blog_name'])==0) {
+ /*if (strlen($_POST['blog_name'])==0) {
if (count($_POST)>0) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}
- }
+ }*/
Blog::display_new_blog_form();
}
}
diff --git a/main/blog/download.php b/main/blog/download.php
index 722642f867..821fb68573 100755
--- a/main/blog/download.php
+++ b/main/blog/download.php
@@ -51,7 +51,7 @@ $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$course_id = api_get_course_int_id();
// launch event
-event_download($doc_url);
+Event::event_download($doc_url);
$sql = 'SELECT filename FROM '.$tbl_blogs_attachment.'
WHERE c_id = '.$course_id.' AND path LIKE BINARY "'.Database::escape_string($doc_url).'"';
diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php
index f7ea78924d..67f9750b8e 100755
--- a/main/calendar/agenda.php
+++ b/main/calendar/agenda.php
@@ -63,7 +63,7 @@ function plus_repeated_event() {
// setting the name of the tool
$nameTools = get_lang('Agenda');
-event_access_tool(TOOL_CALENDAR_EVENT);
+Event::event_access_tool(TOOL_CALENDAR_EVENT);
// permission stuff - also used by loading from global in agenda.inc.php
$is_allowed_to_edit = api_is_allowed_to_edit(false, true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous());
diff --git a/main/calendar/download.php b/main/calendar/download.php
index 459c573f04..b5722adc1e 100755
--- a/main/calendar/download.php
+++ b/main/calendar/download.php
@@ -67,7 +67,7 @@ if (is_dir($full_file_name)) {
$tbl_agenda_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
// launch event
-event_download($doc_url);
+Event::event_download($doc_url);
$sql='SELECT filename FROM '.$tbl_agenda_attachment.'
WHERE c_id = '.$course_id.' AND path LIKE BINARY "'.Database::escape_string($doc_url).'"';
diff --git a/main/chat/chat.php b/main/chat/chat.php
index 347d0d8f0a..b99a9135b1 100755
--- a/main/chat/chat.php
+++ b/main/chat/chat.php
@@ -6,7 +6,6 @@
* @package chamilo.chat
*/
-$language_file = array('chat');
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_CHAT;
$this_section = SECTION_COURSES;
@@ -26,7 +25,7 @@ if ($origin != 'whoisonline') {
/* TRACKING */
-event_access_tool(TOOL_CHAT);
+Event::event_access_tool(TOOL_CHAT);
header('Content-Type: text/html; charset='.api_get_system_encoding());
/*
diff --git a/main/chat/chat_chat.php b/main/chat/chat_chat.php
index d01589593d..4e46ed1f31 100755
--- a/main/chat/chat_chat.php
+++ b/main/chat/chat_chat.php
@@ -10,7 +10,6 @@
define('FRAME', 'chat');
-$language_file = array('chat');
require_once '../inc/global.inc.php';
$course = $_GET['cidReq'];
diff --git a/main/chat/chat_hidden.php b/main/chat/chat_hidden.php
index e0eb4ddaf4..28e9779970 100755
--- a/main/chat/chat_hidden.php
+++ b/main/chat/chat_hidden.php
@@ -10,8 +10,6 @@
define('FRAME', 'hidden');
-$language_file = array('chat');
-
require_once '../inc/global.inc.php';
require_once 'chat_functions.lib.php';
diff --git a/main/chat/chat_message.php b/main/chat/chat_message.php
index 1f0a1274e3..c78356aefc 100755
--- a/main/chat/chat_message.php
+++ b/main/chat/chat_message.php
@@ -10,7 +10,6 @@
*/
define('FRAME', 'message');
-$language_file = array('chat');
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'chat/chat_functions.lib.php';
diff --git a/main/chat/chat_whoisonline.php b/main/chat/chat_whoisonline.php
index 73f134c8d4..319f46847e 100755
--- a/main/chat/chat_whoisonline.php
+++ b/main/chat/chat_whoisonline.php
@@ -8,7 +8,6 @@
*/
define('FRAME', 'online');
-$language_file = array('chat');
require_once '../inc/global.inc.php';
diff --git a/main/course_description/add.php b/main/course_description/add.php
index 98b5b2c03f..12a7acb49d 100755
--- a/main/course_description/add.php
+++ b/main/course_description/add.php
@@ -54,12 +54,7 @@ $form->addElement('hidden', 'description_type',$description_type);
$form->addElement('hidden', 'sec_token',$token);
$form->add_textfield('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
$form->applyFilter('title','html_filter');
-
-if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
- WCAG_rendering::prepare_admin_form($description_content, $form);
-} else {
- $form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
-}
+$form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
// display default questions
@@ -68,10 +63,4 @@ if (isset ($question[$description_type])) {
$message .= $question[$description_type];
Display::display_normal_message($message, false);
}
-if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
- echo (WCAG_Rendering::editor_header());
-}
$form->display();
-if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
- echo (WCAG_Rendering::editor_footer());
-}
diff --git a/main/course_description/ajax_controller.class.php b/main/course_description/ajax_controller.class.php
index 38fb17e197..f64a9ffd4a 100755
--- a/main/course_description/ajax_controller.class.php
+++ b/main/course_description/ajax_controller.class.php
@@ -19,14 +19,14 @@ use Header;
/**
* Ajax controller. Dispatch request and perform required action.
- *
- * - delete category/link
- *
+ *
+ * - delete category/link
+ *
* Usage:
- *
+ *
* $controller = AjaxController::instance();
* $controller->run();
- *
+ *
* @author Laurent Opprecht for the Univesity of Genevas
* @license /license.txt
*/
@@ -38,7 +38,7 @@ class AjaxController extends \Controller
/**
* Return the instance of the controller.
- *
+ *
* @return \CourseDescription\AjaxController
*/
public static function instance()
@@ -52,15 +52,15 @@ class AjaxController extends \Controller
protected function __construct()
{
-
+
}
/**
- * Prepare the environment. Set up breadcrumps and raise tracking event.
+ * Prepare the environment. Set up breadcrumps and raise tracking event.
*/
protected function prolog()
{
- event_access_tool(TOOL_COURSE_DESCRIPTION);
+ Event::event_access_tool(TOOL_COURSE_DESCRIPTION);
}
public function is_allowed_to_edit()
@@ -79,7 +79,7 @@ class AjaxController extends \Controller
}
return true;
}
-
+
public function authorize()
{
$authorize = api_protect_course_script();
@@ -102,7 +102,7 @@ class AjaxController extends \Controller
}
/**
- *
+ *
*/
public function delete()
{
@@ -120,7 +120,7 @@ class AjaxController extends \Controller
$this->response($success);
}
/**
- *
+ *
*/
public function delete_by_course()
{
@@ -128,11 +128,11 @@ class AjaxController extends \Controller
$this->forbidden();
return;
}
-
+
$course = (object) array();
$course->c_id = Request::get_c_id();
$course->session_id = Request::get_session_id();
-
+
$success = CourseDescription::repository()->remove_by_course($course);
$this->response($success);
@@ -149,7 +149,7 @@ class AjaxController extends \Controller
}
/**
- * Action exists but implementation is missing.
+ * Action exists but implementation is missing.
*/
public function missing()
{
@@ -158,9 +158,9 @@ class AjaxController extends \Controller
/**
* Display a standard json responce.
- *
+ *
* @param bool $success
- * @param string $message
+ * @param string $message
* @param object $data
*/
public function response($success = false, $message = '', $data = null)
diff --git a/main/course_description/controller.class.php b/main/course_description/controller.class.php
index f646f34f6c..f25b71c621 100755
--- a/main/course_description/controller.class.php
+++ b/main/course_description/controller.class.php
@@ -13,18 +13,18 @@ use Javascript;
/**
* Controller for course description. Dispatch request and peform required action.
- *
+ *
* - list course description for course
* - add a new course description to a course/session
* - edit a course session
* - delete a course session
- *
+ *
* Usage:
- *
+ *
* $controller = CourseDescriptionController::instance();
* $controller->run();
- *
- * @package chamilo.course_description
+ *
+ * @package chamilo.course_description
* @author Christian Fasanando
* @author Laurent Opprecht for the Univesity of Genevas
* @license see /license.txt
@@ -42,8 +42,8 @@ class Controller extends \Controller
/**
* Return the instance of the controller.
- *
- * @return CourseDescriptionController
+ *
+ * @return CourseDescriptionController
*/
public static function instance()
{
@@ -56,13 +56,13 @@ class Controller extends \Controller
protected function __construct()
{
-
+
}
/**
- * Action to perform.
+ * Action to perform.
* Returns the request parameter.
- *
+ *
* @return string
*/
public function get_action()
@@ -95,8 +95,8 @@ class Controller extends \Controller
/**
* Whether the call is authorized or not.
- *
- * @return boolean
+ *
+ * @return boolean
*/
public function authorize()
{
@@ -114,7 +114,7 @@ class Controller extends \Controller
}
/**
- * Prepare the environment. Set up breadcrumps and raise tracking event.
+ * Prepare the environment. Set up breadcrumps and raise tracking event.
*/
protected function prolog()
{
@@ -135,12 +135,12 @@ class Controller extends \Controller
$current_course_tool = TOOL_COURSE_DESCRIPTION;
// Tracking
- event_access_tool(TOOL_COURSE_DESCRIPTION);
+ Event::event_access_tool(TOOL_COURSE_DESCRIPTION);
}
/**
* Javascript used by the controller
- *
+ *
* @return string
*/
public function javascript()
@@ -156,10 +156,10 @@ class Controller extends \Controller
/**
* Returns a url for an action that the controller can process
- *
+ *
* @param string $action
* @param array $params
- * @return string
+ * @return string
*/
public function url($action = '', $params = array())
{
@@ -185,8 +185,8 @@ class Controller extends \Controller
/**
* List course descriptions.
- *
- * @param array messages
+ *
+ * @param array messages
*/
public function listing()
{
@@ -203,7 +203,7 @@ class Controller extends \Controller
}
/**
- * Performs the edit action.
+ * Performs the edit action.
*/
public function edit()
{
@@ -211,7 +211,7 @@ class Controller extends \Controller
$this->forbidden();
return;
}
-
+
$id = Request::get_id();
$c_id = Request::get_c_id();
@@ -223,13 +223,13 @@ class Controller extends \Controller
if ($form->validate()) {
$success = $repo->save($description);
-
- $message = $success ? get_lang('DescriptionUpdated') : get_lang('Error');
+
+ $message = $success ? get_lang('CourseDescriptionUpdated') : get_lang('Error');
$home = $this->url(self::ACTION_DEFAULT);
Redirect::go($home);
}
-
+
$data = (object) array();
$data->form = $form;
$this->render('edit', $data);
@@ -285,7 +285,7 @@ class Controller extends \Controller
/**
* Performs the delete action.
- *
+ *
* @todo: could be worth to require a security token in the url and check it. Currently confirmation is done through javascript confirmation only.
*/
public function delete()
@@ -344,7 +344,7 @@ class Controller extends \Controller
$path = $file->tmp_name;
$reader = new CsvReader($path);
$descriptions = $reader->get_items();
-
+
$c_id = Request::get_c_id();
$session_id = Request::get_session_id();
$course = (object) array();
@@ -364,10 +364,10 @@ class Controller extends \Controller
/**
* Render a template using data. Adds a few common parameters to the data array.
- *
+ *
* @see /main/template/default/course_description/
* @param string $template
- * @param array $data
+ * @param array $data
*/
protected function render($template, $data)
{
diff --git a/main/course_description/course_description_controller.php b/main/course_description/course_description_controller.php
index e642204b15..323d6c87e8 100755
--- a/main/course_description/course_description_controller.php
+++ b/main/course_description/course_description_controller.php
@@ -45,7 +45,7 @@ class CourseDescriptionController
$data['descriptions'] = array($data['descriptions']);
}
foreach ($data['descriptions'] as $description) {
- if (strpos($description, ' |