diff --git a/documentation/changelog.html b/documentation/changelog.html index 1fb05be244..9867d3d152 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -200,11 +200,10 @@ This version of Chamilo only includes new features:

Known issues

Third-Party Libraries additions/updates

@@ -684,7 +683,7 @@ This version of Chamilo only includes a few minor new features:
  • If you used split users directories before v1.8.8 in combination with the "My files" feature (if it existed at all at that point), you will probably have a problem now, as the code in the previous version was wrong and was saving the personal portfolio file in another directory than the user's. Sorry about that. If you need professional assistance, see the http://www.chamilo.org/ website under support -> professional support for official providers who could help you. And don't forget to keep a backup. If you don't understand a thing about what I'm talking about, you are probable not concerned by this bug, so don't worry too much.
  • For some reason, we have been reported unsuccessful migrations from 1.8.7 to 1.8.7.1 whereby the course_rel_user table was not integrally copied. We recommend keeping your database backup until you're sure every student/course relationship was copied (comparing the lines in the table before and after migration might help you)
  • Document tool: when moving an HTML file using the "move" funcionality, images, videos and any incrusted file in that HTML will not be moved automatically see #1278
  • -
  • Hotpotatoes: When taking a Hotpotato exam added to Chamilo there is a javascript error, this bug can be only reproduced using Google Chrome see #3332
  • +
  • Hotpotatoes: When taking a Hotpotato exam added to Chamilo there is a javascript error, this bug can be only reproduced using Google Chrome see #3332
  • Deprecated features

    diff --git a/main/admin/configure_inscription.php b/main/admin/configure_inscription.php index 420a136394..3e0077e19b 100644 --- a/main/admin/configure_inscription.php +++ b/main/admin/configure_inscription.php @@ -301,10 +301,6 @@ if (get_setting('allow_terms_conditions') == 'true') { $form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']); $form->addElement('hidden', 'legal_info', $term_preview['legal_id'].':'.$term_preview['language_id']); - /*if (isset($_SESSION['term_and_condition']['user_id']) && isset($_SESSION['term_and_condition']['password'])) { - $form->addElement('hidden', 'login', $_SESSION['term_and_condition']['user_id']); - $form->addElement('hidden', 'password', $_SESSION['term_and_condition']['password']); - }*/ if ($term_preview['type'] == 1) { $form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').' '.get_lang('TermsAndConditions').''); $form->addRule('extra_legal_accept', get_lang('ThisFieldIsRequired'), 'required'); diff --git a/main/admin/index.php b/main/admin/index.php index 933e1a0ae7..bf153e5962 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -175,65 +175,37 @@ if (api_is_platform_admin()) { } /* Sessions */ +$blocks['sessions']['icon'] = Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL, false); +$blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions')); + +$search_form = ' '; +$blocks['sessions']['search_form'] = $search_form; +$items = array(); +$items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession')); +$items[] = array('url'=>'session_add.php', 'label' => get_lang('AddSession')); +$items[] = array('url'=>'session_category_list.php', 'label' => get_lang('ListSessionCategory')); +$items[] = array('url'=>'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV')); +if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { + $items[] = array('url'=>'ldap_import_students_to_session.php', 'label' => get_lang('ImportLDAPUsersIntoSession')); +} +$items[] = array('url'=>'session_export.php', 'label' => get_lang('ExportSessionListXMLCSV')); +$items[] = array('url'=>'../coursecopy/copy_course_session.php', 'label' => get_lang('CopyFromCourseInSessionToAnotherSession')); -//if (api_get_setting('use_session_mode') == 'true') { -if (true) { - - $blocks['sessions']['icon'] = Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL, false); - $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions')); - - $search_form = ' '; - $blocks['sessions']['search_form'] = $search_form; - $items = array(); - $items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession')); - $items[] = array('url'=>'session_add.php', 'label' => get_lang('AddSession')); - $items[] = array('url'=>'session_category_list.php', 'label' => get_lang('ListSessionCategory')); - $items[] = array('url'=>'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV')); - if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { - $items[] = array('url'=>'ldap_import_students_to_session.php', 'label' => get_lang('ImportLDAPUsersIntoSession')); - } - $items[] = array('url'=>'session_export.php', 'label' => get_lang('ExportSessionListXMLCSV')); - $items[] = array('url'=>'../coursecopy/copy_course_session.php', 'label' => get_lang('CopyFromCourseInSessionToAnotherSession')); - - if (api_is_platform_admin()) { - if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required - $items[] = array('url'=>'user_move_stats.php', 'label' => get_lang('MoveUserStats')); - } - $items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions')); - } - - $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes')); - - $blocks['sessions']['items'] = $items; - $blocks['sessions']['extra'] = null; +if (api_is_platform_admin()) { + if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required + $items[] = array('url'=>'user_move_stats.php', 'label' => get_lang('MoveUserStats')); + } + $items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions')); +} -} elseif (api_is_platform_admin()) { +$items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes')); + +$blocks['sessions']['items'] = $items; +$blocks['sessions']['extra'] = null; - /*$blocks['classes']['items'] = $items; - $blocks['classes']['icon'] = Display::return_icon('group.gif', get_lang('AdminClasses'), array(), ICON_SIZE_SMALL, false); - $blocks['classes']['label'] = api_ucfirst(get_lang('AdminClasses')); - - $search_form = ' '; - $blocks['classes']['search_form'] = $search_form; - $items = array(); - $items[] = array('url'=>'class_list.php', 'label' => get_lang('ClassList')); - $items[] = array('url'=>'class_add.php', 'label' => get_lang('AddClasses')); - $items[] = array('url'=>'class_import.php', 'label' => get_lang('ImportClassListCSV')); - $items[] = array('url'=>'class_user_import.php', 'label' => get_lang('AddUsersToAClass')); - $items[] = array('url'=>'subscribe_class2course.php', 'label' => get_lang('AddClassesToACourse')); - - $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes')); - - $blocks['classes']['items'] = $items; - $blocks['classes']['extra'] = null;*/ - -} /* Settings */ if (api_is_platform_admin()) { @@ -407,6 +379,7 @@ function check_system_version() { // The number of users $number_of_users = statistics::count_users(); + $number_of_active_users = statistics::count_users(null,null,null,true); $data = array( 'url' => api_get_path(WEB_PATH), @@ -415,6 +388,7 @@ function check_system_version() { 'version' => $system_version, 'numberofcourses' => $number_of_courses, 'numberofusers' => $number_of_users, + 'numberofactiveusers' => $number_of_active_users, //The donotlistcampus setting recovery should be improved to make // it true by default - this does not affect numbers counting 'donotlistcampus' => api_get_setting('donotlistcampus'), diff --git a/main/admin/session_add.php b/main/admin/session_add.php index 332c7dfbb2..9b3466b99b 100644 --- a/main/admin/session_add.php +++ b/main/admin/session_add.php @@ -155,7 +155,7 @@ echo '';
    - +
    diff --git a/main/admin/session_edit.php b/main/admin/session_edit.php index e7fbaabc3a..d9388b9a78 100644 --- a/main/admin/session_edit.php +++ b/main/admin/session_edit.php @@ -115,7 +115,7 @@ if (!empty($return)) {
    - +
    diff --git a/main/admin/settings.php b/main/admin/settings.php index 1f98c58477..5c5187c808 100644 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -40,6 +40,7 @@ api_protect_admin_script(); // Settings to avoid $settings_to_avoid = array( + 'use_session_mode' => 'true', 'gradebook_enable' => 'false', 'example_material_course_creation' => 'true' // ON by default - now we have this option when we create a course ); diff --git a/main/admin/statistics/statistics.lib.php b/main/admin/statistics/statistics.lib.php index 95c0865d12..7f3484843f 100644 --- a/main/admin/statistics/statistics.lib.php +++ b/main/admin/statistics/statistics.lib.php @@ -48,10 +48,11 @@ class Statistics { * Count users * @param int optional, user status (COURSEMANAGER or STUDENT), if it's not setted it'll count all users. * @param string optional, code of a course category. Default: count only users without filtering category - * @todo count invisible courses + * @param bool count invisible courses (todo) + * @param bool count only active users (false to only return currently active users) * @return int Number of users counted */ - function count_users($status = null, $category_code = null, $count_invisible_courses = true) { + function count_users($status = null, $category_code = null, $count_invisible_courses = true, $only_active = false) { global $_configuration; // Database table definitions @@ -60,19 +61,19 @@ class Statistics { $user_table = Database :: get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); + $active_filter = $only_active?' AND active=1':''; + $status_filter = isset($status)?' AND status = '.intval($status):''; if ($_configuration['multiple_access_urls']) { - $status_filter = isset($status)?' AND status = '.intval($status):''; - $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number FROM $user_table as u, $access_url_rel_user_table as url WHERE u.user_id=url.user_id AND access_url_id='".$current_url_id."' $status_filter "; + $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number FROM $user_table as u, $access_url_rel_user_table as url WHERE u.user_id=url.user_id AND access_url_id='".$current_url_id."' $status_filter $active_filter"; if (isset ($category_code)) { - $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c, $access_url_rel_user_table as url WHERE c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."' AND cu.user_id=url.user_id AND access_url_id='".$current_url_id."' $status_filter "; + $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c, $access_url_rel_user_table as url WHERE c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."' AND cu.user_id=url.user_id AND access_url_id='".$current_url_id."' $status_filter $active_filter"; } } else { - $status_filter = isset($status)?' WHERE status = '.intval($status):''; - $sql = "SELECT COUNT(DISTINCT(user_id)) AS number FROM $user_table $status_filter "; + $sql = "SELECT COUNT(DISTINCT(user_id)) AS number FROM $user_table WHERE 1=1 $status_filter $active_filter"; if (isset ($category_code)) { $status_filter = isset($status)?' AND status = '.intval($status):''; - $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c WHERE c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."' $status_filter "; + $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c WHERE c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."' $status_filter $active_filter"; } } diff --git a/main/auth/conditional_login/complete_phone_number.php b/main/auth/conditional_login/complete_phone_number.php index 0a06b0dee3..01fff2f0de 100644 --- a/main/auth/conditional_login/complete_phone_number.php +++ b/main/auth/conditional_login/complete_phone_number.php @@ -1,7 +1,7 @@ 'check_platform_legal_conditions', +// 'url' => api_get_path(WEB_CODE_PATH).'auth/inscription.php' +)); + + //array_push($dc_conditions, array( // 'conditional_function' => 'dc_check_phone_number', // 'url' => api_get_path(WEB_PATH).'main/auth/conditional_login/complete_phone_number.php' @@ -19,7 +31,7 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; */ function dc_check_phone_number($user){ $uInfo = UserManager::get_user_info_by_id($user['user_id']); - if ( empty($uInfo['phone'])) { + if (empty($uInfo['phone'])) { return true; } return false; @@ -27,5 +39,28 @@ function dc_check_phone_number($user){ function dc_check_first_login($user){ $uInfo = UserManager::get_user_info_by_id($user['user_id']); - return(($uInfo['extra']['already_logged_in'] === 'false')); -} \ No newline at end of file + return $uInfo['extra']['already_logged_in'] === 'false'; +} + +function check_platform_legal_conditions($user) { + if (api_get_setting('allow_terms_conditions') == 'true') { + $term_and_condition_status = api_check_term_condition($user['user_id']); + // @todo not sure why we need the login password and update_term_status + if ($term_and_condition_status === false) { + $_SESSION['term_and_condition'] = array('user_id' => $user['user_id'], + //'login' => $user['username'], + //'password' => $user['password'], + //'update_term_status' => true, + ); + return true; + /*header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php'); + exit;*/ + } else { + unset($_SESSION['term_and_condition']); + return false; + } + } else { + //No validation + return true; + } +} diff --git a/main/auth/lostPassword.php b/main/auth/lostPassword.php index 5842d083d2..7dd2e6327d 100644 --- a/main/auth/lostPassword.php +++ b/main/auth/lostPassword.php @@ -109,36 +109,12 @@ if (isset($_GET['reset']) && isset($_GET['id'])) { if ($form->validate()) { $values = $form->exportValues(); + + $users_related_to_username = Login::get_user_accounts_by_username($values['user']); - if(strpos($values['user'],'@')){ - $user = strtolower($values['user']); - $email = TRUE; - } else { - $user = strtolower($values['user']); - $email = FALSE; - } - - $condition = ''; - if ($email) { - $condition = "LOWER(email) = '".Database::escape_string($user)."' "; - } else { - $condition = "LOWER(username) = '".Database::escape_string($user)."'"; - } - - $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); - $query = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, ". - "username AS loginName, password, email, status AS status, ". - "official_code, phone, picture_uri, creator_id ". - "FROM ".$tbl_user." ". - "WHERE ( $condition ) "; - - $result = Database::query($query); - $num_rows = Database::num_rows($result); - - if ($result && $num_rows > 0) { - $by_username = true; - $users = Database::store_result($result); - foreach ($users as $user ) { + if ($users_related_to_username) { + $by_username = true; + foreach ($users_related_to_username as $user) { if ($_configuration['password_encryption'] != 'none') { Login::handle_encrypted_password($user, $by_username); } else { diff --git a/main/css/base.css b/main/css/base.css index a7eb8d44d3..ef092ab68d 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -2548,7 +2548,8 @@ div.admin_section h4 { } .topics_grid_item { - /* margin-left:20px; */ + border-bottom: 1px solid #CCCCCC; + margin-bottom: 20px; } #div_content_table { diff --git a/main/document/showinframes.php b/main/document/showinframes.php index 625e3a7710..a58dd94212 100644 --- a/main/document/showinframes.php +++ b/main/document/showinframes.php @@ -173,34 +173,6 @@ if (api_get_setting('show_glossary_in_documents') == 'ismanual') { // });'; } -if (!$jplayer_supported) { - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ''; - - $htmlHeadXtra[] = ''; -} $web_odf_supported_files = DocumentManager::get_web_odf_extension_list(); if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) { @@ -220,6 +192,8 @@ if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) { '; } +$execute_iframe = true; + if ($jplayer_supported) { $extension = api_strtolower($pathinfo['extension']); @@ -251,11 +225,46 @@ if ($jplayer_supported) { '.$jquery.' }); '; + $execute_iframe = false; +} +if ($show_web_odf) { + $execute_iframe = false; +} + +$is_nanogong_available = $pathinfo['extension']=='wav' && preg_match('/_chnano_.wav/i', $file_url_web) && api_get_setting('enable_nanogong') == 'true'; +if ($is_nanogong_available){ + $execute_iframe = false; +} + +if (!$jplayer_supported && $execute_iframe) { + + $htmlHeadXtra[] = ''; + $htmlHeadXtra[] = ''; + $htmlHeadXtra[] = ''; } + Display::display_header(''); -$execute_iframe = true; echo '
    '; $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq(); @@ -268,19 +277,17 @@ if (in_array(strtolower($pathinfo['extension']) , array('html', "htm"))) { if ($show_web_odf) { //echo Display::url(get_lang('Show'), api_get_path(WEB_CODE_PATH).'document/edit_odf.php?id='.$document_data['id'], array('class' => 'btn')); - echo '
    '; - $execute_iframe = false; + echo '
    '; } echo '
    '; -if ($jplayer_supported) { +if ($jplayer_supported) { echo '
    '; echo DocumentManager::generate_video_preview($document_data); - echo '
    '; - $execute_iframe = false; + echo '
    '; } -if ($pathinfo['extension']=='wav' && preg_match('/_chnano_.wav/i', $file_url_web) && api_get_setting('enable_nanogong') == 'true'){ +if ($is_nanogong_available){ echo '
    '; echo '
    '; echo ''; @@ -289,8 +296,7 @@ if ($pathinfo['extension']=='wav' && preg_match('/_chnano_.wav/i', $file_url_web echo ''; echo ''; echo ''; - echo '
    '; - $execute_iframe = false; + echo ''; } if ($execute_iframe) { diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php index 30ffafb864..584ad789a2 100644 --- a/main/exercice/exercise_submit.php +++ b/main/exercice/exercise_submit.php @@ -740,8 +740,7 @@ if (!empty($error)) { $number_of_hotspot_questions = 0; $onsubmit = ''; $i = 0; - //i have a doubt in this line cvargas - //var_dump($questionList); + if (!strcmp($questionList[0], '') === 0) { foreach ($questionList as $questionId) { $i++; @@ -782,6 +781,8 @@ if (!empty($error)) { //$(this).find(".exercise_save_now_button").hide(); $(this).removeClass("question_highlight"); }); + + $(".no_remind_highlight").hide(); }); @@ -973,6 +974,12 @@ if (!empty($error)) { $user_choice = $attempt_list[$questionId]; $remind_highlight = ''; + + //Hides questions when reviewing a ALL_ON_ONE_PAGE exercise see #4542 no_remind_highlight class hide with jquery + if ($objExercise->type == ALL_ON_ONE_PAGE && isset($_GET['reminder']) && $_GET['reminder'] == 2) { + $remind_highlight = 'no_remind_highlight'; + } + $exercise_actions = ''; $is_remind_on = false; diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index a435af85c5..6f76f6b162 100644 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -288,10 +288,6 @@ echo ''; $session_list = SessionManager::get_sessions_by_coach(api_get_user_id()); $tabAttrParam = array('class'=>'chzn-select', 'onchange'=>'submit_form(this)'); // when sessions are used $labelFormRow = get_lang('Session'); -if (api_get_setting('use_session_mode') == 'false') { - $tabAttrParam = array('style'=>'visibility:hidden', 'onchange'=>'submit_form(this)'); - $labelFormRow = ""; -} $session_select_list = array(); foreach($session_list as $item) { $session_select_list[$item['id']] = $item['name']; diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index b924afce33..e6c5336b35 100644 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -25,22 +25,17 @@ function get_tabs() { $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage'); // My Courses - if (api_get_setting('use_session_mode')=='true') { - if(api_is_allowed_to_create_course()) { - // Link to my courses for teachers - $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true'; - $navigation['mycourses']['title'] = get_lang('MyCourses'); - } else { - // Link to my courses for students - $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php'; - $navigation['mycourses']['title'] = get_lang('MyCourses'); - } - } else { - // Link to my courses - $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php'; - $navigation['mycourses']['title'] = get_lang('MyCourses'); - } - + + if(api_is_allowed_to_create_course()) { + // Link to my courses for teachers + $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true'; + $navigation['mycourses']['title'] = get_lang('MyCourses'); + } else { + // Link to my courses for students + $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php'; + $navigation['mycourses']['title'] = get_lang('MyCourses'); + } + // My Profile $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); $navigation['myprofile']['title'] = get_lang('ModifyProfile'); @@ -197,7 +192,7 @@ function return_notification_menu() { } // Display the who's online for the session - if (api_get_setting('use_session_mode') == 'true' && isset($user_id) && api_get_session_id() != 0) { + if (isset($user_id) && api_get_session_id() != 0) { $html .= '
  • '. Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY).'
  • '; } @@ -490,7 +485,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; break; default: - if (api_get_setting('use_session_mode') == 'true' && api_get_session_id() != -1 ) { + if (api_get_session_id() != -1 ) { $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; } else { $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name']).' '.$course_title; diff --git a/main/inc/lib/conditional_login.class.php b/main/inc/lib/conditional_login.class.php index 1ede1715f9..ebcd4eb122 100644 --- a/main/inc/lib/conditional_login.class.php +++ b/main/inc/lib/conditional_login.class.php @@ -1,14 +1,17 @@ +/* For licensing terms, see /license.txt */ +/* + * Conditional login + * Used to implement the loading of custom pages + * 2011, Noel Dieschburg + */ class ConditionalLogin { public static function check_conditions($user) { if (file_exists(api_get_path(SYS_PATH).'main/auth/conditional_login/conditional_login.php')) { include_once api_get_path(SYS_PATH).'main/auth/conditional_login/conditional_login.php'; - if (isset($dc_conditions)){ + if (isset($dc_conditions)) { foreach ($dc_conditions as $dc_condition) { if (isset($dc_condition['conditional_function']) && $dc_condition['conditional_function']($user)) { $_SESSION['conditional_login']['uid'] = $user['user_id']; diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 9ade12cc17..3b7bb2aef6 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1323,7 +1323,7 @@ class CourseManager { // students subscribed to the course through a session - if (api_get_setting('use_session_mode') == 'true' && $with_session) { + if ($with_session) { $sql_query = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." WHERE course_code = '$course_code' AND status<>2"; if ($session_id != 0) { $sql_query .= ' AND id_session = '.$session_id; @@ -2782,9 +2782,7 @@ class CourseManager { $html .= '
    '; $html .= '
    '; $html .= '
    '; - $html .= '
    '; - if (!empty($params['link'])) { $html .= ''; $html .= $params['icon']; @@ -2853,14 +2851,12 @@ class CourseManager { $rs_special_course = Database::query($sql); $number_of_courses = Database::num_rows($rs_special_course); $key = 0; - $status_icon = ''; - + $html = ''; if ($number_of_courses > 0) { while ($course = Database::fetch_array($rs_special_course)) { $course_info = api_get_course_info($course['code']); - $params = array(); // Get notifications. //$course['id_session'] = null; @@ -2876,7 +2872,7 @@ class CourseManager { $params['icon'] = Display::return_icon('blackboard.png', $course_info['title'], array(), ICON_SIZE_LARGE); - $params['right_actions'] = ''; + $params['right_actions'] = ''; if (api_is_platform_admin()) { if ($load_dirs) { $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; @@ -2889,9 +2885,11 @@ class CourseManager { //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;')); } } else { - if ($load_dirs) { - $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; - $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course['real_id'].'_0', 'class'=>'document_preview_container')); + if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { + if ($load_dirs) { + $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; + $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course['real_id'].'_0', 'class'=>'document_preview_container')); + } } } @@ -2912,7 +2910,11 @@ class CourseManager { $params['title'] = $course_title; $params['link'] = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0&autoreg=1'; - $params['notifications'] = $show_notification; + + if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { + $params['notifications'] = $show_notification; + } + $html .= self::course_item_html($params, false); $key++; } @@ -2993,7 +2995,6 @@ class CourseManager { $result = Database::query($sql_select_courses); $key = 0; $status_icon = ''; - $html = ''; // Browse through all courses. @@ -3026,12 +3027,14 @@ class CourseManager { //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;')); } } else { - if ($load_dirs) { - $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; - $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class'=>'document_preview_container')); - } else { - if ($course_info['status'] == COURSEMANAGER) { - $params['right_actions'].= ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; + if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { + if ($load_dirs) { + $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; + $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class'=>'document_preview_container')); + } else { + if ($course_info['status'] == COURSEMANAGER) { + $params['right_actions'].= ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; + } } } } @@ -3057,7 +3060,10 @@ class CourseManager { $params['icon'] = $status_icon; $params['title'] = $course_title; $params['teachers'] = $teachers; - $params['notifications'] = $show_notification; + + if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { + $params['notifications'] = $show_notification; + } $is_subcontent = true; if (empty($user_category_id)) { @@ -3138,7 +3144,7 @@ class CourseManager { $course_info['id_session'] = $session_id; - if (api_get_setting('use_session_mode') == 'true' && !$nosession) { + if (!$nosession) { global $now, $date_start, $date_end; } @@ -3152,30 +3158,6 @@ class CourseManager { $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_info['code']); - - // Function logic - act on the data. - /* - $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($course_info['code']); - if ($is_virtual_course) { - // If the current user is also subscribed in the real course to which this - // virtual course is linked, we don't need to display the virtual course entry in - // the course list - it is combined with the real course entry. - $target_course_code = CourseManager :: get_target_of_linked_course($course_info['code']); - $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code); - if ($is_subscribed_in_target_course) { - return; //do not display this course entry - } - } - $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_info['code'], api_get_user_id()); - if ($has_virtual_courses) { - $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info); - $course_display_title = $return_result['name']; - $course_display_code = $return_result['code']; - } else { - $course_display_title = $course_info['name']; - $course_display_code = $course_info['official_code']; - }*/ - $is_coach = api_is_coach($course_info['id_session'], $course['code']); // Display course entry. @@ -3185,7 +3167,7 @@ class CourseManager { if ($session_accessible) { if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) { - if (api_get_setting('use_session_mode') == 'true' && !$nosession) { + if (!$nosession) { if (empty($course_info['id_session'])) { $course_info['id_session'] = 0; } @@ -3210,9 +3192,12 @@ class CourseManager { $params['title'] = $session_title; $params['right_actions'] = ''; - if ($load_dirs) { - $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; - $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_'.$course_info['id_session'], 'class'=>'document_preview_container')); + + if ($course_visibility != COURSE_VISIBILITY_CLOSED) { + if ($load_dirs) { + $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).''; + $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_'.$course_info['id_session'], 'class'=>'document_preview_container')); + } } if (api_get_setting('display_coursecode_in_courselist') == 'true') { @@ -3220,7 +3205,7 @@ class CourseManager { } if (api_get_setting('display_teacher_in_courselist') == 'true') { - if (api_get_setting('use_session_mode') == 'true' && !$nosession) { + if (!$nosession) { $teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code'], self::USER_SEPARATOR, true); $course_coachs = CourseManager::get_coachs_from_course_to_string($course_info['id_session'], $course['code'], self::USER_SEPARATOR, true); @@ -3228,7 +3213,7 @@ class CourseManager { $params['teachers'] = $teacher_list; } if (($course_info['status'] == STUDENT && !empty($course_info['id_session'])) || ($is_coach && $course_info['status'] != COURSEMANAGER)) { - $params['coaches'] = $course_coachs; + $params['coaches'] = $course_coachs; } } else { $params['teachers'] = $teacher_list; @@ -3238,7 +3223,9 @@ class CourseManager { $session_title .= isset($course['special_course']) ? ' '.Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : ''; // Display the "what's new" icons - $session_title .= Display :: show_notification($course_info); + if ($course_visibility != COURSE_VISIBILITY_CLOSED) { + $session_title .= Display :: show_notification($course_info); + } $params['title'] = $session_title; $params['extra'] = ''; @@ -3246,7 +3233,7 @@ class CourseManager { $html = self::course_item_html($params, true); $session_category_id = null; - if (api_get_setting('use_session_mode') == 'true' && !$nosession) { + if (!$nosession) { $session = ''; $active = false; if (!empty($course_info['session_name'])) { @@ -3678,7 +3665,8 @@ class CourseManager { } } - $table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); + $table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); + $table_course = Database::get_main_table(TABLE_MAIN_COURSE); //@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC /* @@ -3691,8 +3679,11 @@ class CourseManager { //$table_course_access table uses the now() and interval ... - $sql = "SELECT COUNT(course_access_id) course_count, course_code FROM $table_course_access - WHERE login_course_date <= now() AND login_course_date > DATE_SUB(now(), INTERVAL $days DAY) + $sql = "SELECT COUNT(course_access_id) course_count, a.course_code, visibility FROM $table_course c INNER JOIN $table_course_access a + ON (c.code = a.course_code) + WHERE login_course_date <= now() AND + login_course_date > DATE_SUB(now(), INTERVAL $days DAY) AND + visibility <> '".COURSE_VISIBILITY_CLOSED."' GROUP BY course_code ORDER BY course_count DESC LIMIT $limit"; @@ -3704,25 +3695,25 @@ class CourseManager { $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; foreach ($courses as &$my_course) { - $course_info = api_get_course_info($my_course['course_code']); + $course_info = api_get_course_info($my_course['course_code']); $my_course['extra_info'] = $course_info; $my_course['extra_info']['go_to_course_button'] = ''; //Course visibility if (api_is_platform_admin() || ( $course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || - ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && api_user_is_login()) || in_array($course_info['real_id'], $my_course_code_list) && $course_info['visibility'] != COURSE_VISIBILITY_CLOSED ) + ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && api_user_is_login()) || in_array($course_info['real_id'], $my_course_code_list)) ) { - $my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$my_course['extra_info']['path'].'/index.php', array('class' => 'btn btn-primary')); + $my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary')); } //Description $my_course['extra_info']['description_button'] = ''; if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list) ) { - $my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$my_course['course_code'], array('class' => 'ajax btn')); + $my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn')); } - $my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($my_course['course_code']); + $my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']); $point_info = self::get_course_ranking($course_info['real_id'], 0); $my_course['extra_info']['rating_html'] = Display::return_rating_system('star_'.$course_info['real_id'], $ajax_url.'&course_id='.$course_info['real_id'], $point_info); } diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 77be3c31bc..1f25c123a2 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -1005,37 +1005,6 @@ class Display { return $table->toHtml(); } - /** - * Display dashboard link - * - */ - /*function display_dashboard_link() { - echo '
  • '.get_lang('Dashboard').'
  • '; - }*/ - - /** - * Display edit course list links - * - */ - /*function display_edit_course_list_links() { - echo '
  • '.get_lang('CourseManagement').'
  • '; - }*/ - - /** - * Show history sessions - * - */ - /* - function display_history_course_session() { - if (api_get_setting('use_session_mode') == 'true') { - if (isset($_GET['history']) && intval($_GET['history']) == 1) { - echo '
  • '.get_lang('DisplayTrainingList').'
  • '; - } else { - echo '
  • '.get_lang('HistoryTrainingSessions').'
  • '; - } - } - }*/ - /** * Returns the "what's new" icon notifications * @@ -1251,12 +1220,12 @@ class Display { function get_session_title_box($session_id) { global $nosession; - if (api_get_setting('use_session_mode') == 'true' && !$nosession) { + if (!$nosession) { global $now, $date_start, $date_end; } $output = array(); - if (api_get_setting('use_session_mode') == 'true' && !$nosession) { + if (!$nosession) { $main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $tbl_session_category = Database :: get_main_table(TABLE_MAIN_SESSION_CATEGORY); diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index d5a830b108..bbc67c5544 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -797,11 +797,11 @@ class DocumentManager { } if (!empty($document_id)) { - $sql= 'SELECT a.insert_user_id, b.readonly FROM '.$TABLE_PROPERTY.' a,'.$TABLE_DOCUMENT.' b + $sql= "SELECT a.insert_user_id, b.readonly FROM $TABLE_PROPERTY a, $TABLE_DOCUMENT b WHERE a.c_id = $course_id AND b.c_id = $course_id AND - a.ref = b.id and a.ref='.$document_id.' LIMIT 1'; + a.ref = b.id and a.ref= $document_id LIMIT 1"; $resultans = Database::query($sql); $doc_details = Database ::fetch_array($resultans, 'ASSOC'); @@ -1306,7 +1306,7 @@ class DocumentManager { } $sql='UPDATE '.$tbl_category.' SET document_id="'.Database::escape_string($document_id).'" WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session; - $rs=Database::query($sql); + Database::query($sql); } /** @@ -1461,7 +1461,7 @@ class DocumentManager { $default_certificate=self::get_default_certificate_id($course_id); if ((int)$default_certificate==(int)$default_certificate_id) { $tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $session_id=api_get_session_id(); + $session_id = api_get_session_id(); if ($session_id==0 || is_null($session_id)) { $sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) '; } elseif ($session_id>0) { @@ -1471,8 +1471,8 @@ class DocumentManager { } $sql='UPDATE '.$tbl_category.' SET document_id=null - WHERE course_code="'.Database::escape_string($course_id).'" AND document_id="'.$default_certificate_id.'" '.$sql_session; - $rs=Database::query($sql); + WHERE course_code="'.Database::escape_string($course_id).'" AND document_id="'.$default_certificate_id.'" '.$sql_session; + Database::query($sql); } } diff --git a/main/inc/lib/fckeditor/editor/_source/internals/fck.js b/main/inc/lib/fckeditor/editor/_source/internals/fck.js old mode 100755 new mode 100644 index f3553d091e..b5a4a9a912 --- a/main/inc/lib/fckeditor/editor/_source/internals/fck.js +++ b/main/inc/lib/fckeditor/editor/_source/internals/fck.js @@ -381,10 +381,10 @@ var FCK = var oRegex ; if ( sTags.length > 0 ) { - oRegex = new RegExp( '<(' + sTags + ')(?!\w|:)', 'gi' ) ; + oRegex = new RegExp( '<(' + sTags + ')(?!\w|:)', 'gi' ) ; html = html.replace( oRegex, '', 'gi' ) ; + oRegex = new RegExp( '<\/(' + sTags + ')>', 'gi' ) ; html = html.replace( oRegex, '<\/FCK:$1>' ) ; } @@ -398,8 +398,10 @@ var FCK = sTags = 'META' ; if ( FCKBrowserInfo.IsIE ) sTags += '|HR' ; - - oRegex = new RegExp( '<((' + sTags + ')(?=\\s|>|/)[\\s\\S]*?)/?>', 'gi' ) ; + + //Fixes bug when editing meta tags see BT#4370 + //oRegex = new RegExp( '<((' + sTags + ')(?=\\s|>|/)[\\s\\S]*?)/?>', 'gi' ) ; + oRegex = new RegExp( '<((' + sTags + ')(?=\s|>)[\s\S]*?)/?>', 'gi' ) ; html = html.replace( oRegex, '' ) ; return html ; diff --git a/main/inc/lib/fckeditor/editor/fckeditor.original.html b/main/inc/lib/fckeditor/editor/fckeditor.original.html old mode 100755 new mode 100644 index 07272aee09..4271a59cfb --- a/main/inc/lib/fckeditor/editor/fckeditor.original.html +++ b/main/inc/lib/fckeditor/editor/fckeditor.original.html @@ -1,4 +1,4 @@ - + /g,//gi,//gi];FCKConfig.ProtectedSource.Add=function(A){this.RegexEntries.push(A);};FCKConfig.ProtectedSource.Protect=function(A){var B=this._CodeTag;function _Replace(protectedSource){var C=FCKTempBin.AddElement(protectedSource);return '';};for (var i=0;i|>)","g");return A.replace(D,_Replace);};FCKConfig.GetBodyAttributes=function(){var A='';if (this.BodyId&&this.BodyId.length>0) A+=' id="'+this.BodyId+'"';if (this.BodyClass&&this.BodyClass.length>0) A+=' class="'+this.BodyClass+'"';return A;};FCKConfig.ApplyBodyAttributes=function(A){if (this.BodyId&&this.BodyId.length>0) A.id=FCKConfig.BodyId;if (this.BodyClass&&this.BodyClass.length>0) A.className+=' '+FCKConfig.BodyClass;}; var FCKDebug={Output:function(){},OutputObject:function(){}}; diff --git a/main/inc/lib/fckeditor/editor/js/fckeditorcode_ie.js b/main/inc/lib/fckeditor/editor/js/fckeditorcode_ie.js old mode 100755 new mode 100644 index 42e410cd06..472d3d686c --- a/main/inc/lib/fckeditor/editor/js/fckeditorcode_ie.js +++ b/main/inc/lib/fckeditor/editor/js/fckeditorcode_ie.js @@ -29,7 +29,7 @@ var s=navigator.userAgent.toLowerCase();var FCKBrowserInfo={IsIE:/*@cc_on!@*/fal var FCKURLParams={};(function(){var A=document.location.search.substr(1).split('&');for (var i=0;i';if (!FCKRegexLib.HtmlOpener.test(A)) A=''+A+'';if (!FCKRegexLib.HeadOpener.test(A)) A=A.replace(FCKRegexLib.HtmlOpener,'$&');return A;}else{var B=FCKConfig.DocType+'0&&!FCKRegexLib.Html4DocType.test(FCKConfig.DocType)) B+=' style="overflow-y: scroll"';B+='>'+A+'';return B;}},ConvertToDataFormat:function(A,B,C,D){var E=FCKXHtml.GetXHTML(A,!B,D);if (C&&FCKRegexLib.EmptyOutParagraph.test(E)) return '';return E;},FixHtml:function(A){return A;}}; -var FCK={Name:FCKURLParams['InstanceName'],Status:0,EditMode:0,Toolbar:null,HasFocus:false,DataProcessor:new FCKDataProcessor(),GetInstanceObject:(function(){var w=window;return function(name){return w[name];}})(),AttachToOnSelectionChange:function(A){this.Events.AttachEvent('OnSelectionChange',A);},GetLinkedFieldValue:function(){return this.LinkedField.value;},GetParentForm:function(){return this.LinkedField.form;},StartupValue:'',IsDirty:function(){if (this.EditMode==1) return (this.StartupValue!=this.EditingArea.Textarea.value);else{if (!this.EditorDocument) return false;return (this.StartupValue!=this.EditorDocument.body.innerHTML);}},ResetIsDirty:function(){if (this.EditMode==1) this.StartupValue=this.EditingArea.Textarea.value;else if (this.EditorDocument.body) this.StartupValue=this.EditorDocument.body.innerHTML;},StartEditor:function(){this.TempBaseTag=FCKConfig.BaseHref.length>0?'':'';var A=FCK.KeystrokeHandler=new FCKKeystrokeHandler();A.OnKeystroke=_FCK_KeystrokeHandler_OnKeystroke;A.SetKeystrokes(FCKConfig.Keystrokes);if (FCKBrowserInfo.IsIE7){if ((CTRL+86) in A.Keystrokes) A.SetKeystrokes([CTRL+86,true]);if ((SHIFT+45) in A.Keystrokes) A.SetKeystrokes([SHIFT+45,true]);};A.SetKeystrokes([CTRL+8,true]);this.EditingArea=new FCKEditingArea(document.getElementById('xEditingArea'));this.EditingArea.FFSpellChecker=FCKConfig.FirefoxSpellChecker;this.SetData(this.GetLinkedFieldValue(),true);FCKTools.AddEventListener(document,"keydown",this._TabKeyHandler);this.AttachToOnSelectionChange(_FCK_PaddingNodeListener);if (FCKBrowserInfo.IsGecko) this.AttachToOnSelectionChange(this._ExecCheckEmptyBlock);},Focus:function(){FCK.EditingArea.Focus();},SetStatus:function(A){this.Status=A;if (A==1){FCKFocusManager.AddWindow(window,true);if (FCKBrowserInfo.IsIE) FCKFocusManager.AddWindow(window.frameElement,true);if (FCKConfig.StartupFocus) FCK.Focus();};this.Events.FireEvent('OnStatusChange',A);},FixBody:function(){var A=FCKConfig.EnterMode;if (A!='p'&&A!='div') return;var B=this.EditorDocument;if (!B) return;var C=B.body;if (!C) return;FCKDomTools.TrimNode(C);var D=C.firstChild;var E;while (D){var F=false;switch (D.nodeType){case 1:var G=D.nodeName.toLowerCase();if (!FCKListsLib.BlockElements[G]&&G!='li'&&!D.getAttribute('_fckfakelement')&&D.getAttribute('_moz_dirty')==null) F=true;break;case 3:if (E||D.nodeValue.Trim().length>0) F=true;break;case 8:if (E) F=true;break;};if (F){var H=D.parentNode;if (!E) E=H.insertBefore(B.createElement(A),D);E.appendChild(H.removeChild(D));D=E.nextSibling;}else{if (E){FCKDomTools.TrimNode(E);E=null;};D=D.nextSibling;}};if (E) FCKDomTools.TrimNode(E);},GetData:function(A){FCK.Events.FireEvent("OnBeforeGetData");if (FCK.EditMode==1) return FCK.EditingArea.Textarea.value;this.FixBody();var B=FCK.EditorDocument;if (!B) return null;var C=FCKConfig.FullPage;var D=FCK.DataProcessor.ConvertToDataFormat(C?B.documentElement:B.body,!C,FCKConfig.IgnoreEmptyParagraphValue,A);D=FCK.ProtectEventsRestore(D);if (FCKBrowserInfo.IsIE) D=D.replace(FCKRegexLib.ToReplace,'$1');if (C){if (FCK.DocTypeDeclaration&&FCK.DocTypeDeclaration.length>0) D=FCK.DocTypeDeclaration+'\n'+D;if (FCK.XmlDeclaration&&FCK.XmlDeclaration.length>0) D=FCK.XmlDeclaration+'\n'+D;};D=FCKConfig.ProtectedSource.Revert(D);setTimeout(function() { FCK.Events.FireEvent("OnAfterGetData");},0);return D;},UpdateLinkedField:function(){var A=FCK.GetXHTML(FCKConfig.FormatOutput);if (FCKConfig.HtmlEncodeOutput) A=FCKTools.HTMLEncode(A);FCK.LinkedField.value=A;FCK.Events.FireEvent('OnAfterLinkedFieldUpdate');},RegisteredDoubleClickHandlers:{},OnDoubleClick:function(A){var B=FCK.RegisteredDoubleClickHandlers[A.tagName.toUpperCase()];if (B){for (var i=0;i0?'|ABBR|XML|EMBED|OBJECT':'ABBR|XML|EMBED|OBJECT';var C;if (B.length>0){C=new RegExp('<('+B+')(?!\w|:)','gi');A=A.replace(C,'','gi');A=A.replace(C,'<\/FCK:$1>');};B='META';if (FCKBrowserInfo.IsIE) B+='|HR';C=new RegExp('<(('+B+')(?=\\s|>|/)[\\s\\S]*?)/?>','gi');A=A.replace(C,'');return A;},SetData:function(A,B){this.EditingArea.Mode=FCK.EditMode;if (FCKBrowserInfo.IsIE&&FCK.EditorDocument){FCK.EditorDocument.detachEvent("onselectionchange",Doc_OnSelectionChange);};FCKTempBin.Reset();FCK.Selection.Release();if (FCK.EditMode==0){this._ForceResetIsDirty=(B===true);A=FCKConfig.ProtectedSource.Protect(A);A=FCK.DataProcessor.ConvertToHtml(A);A=A.replace(FCKRegexLib.InvalidSelfCloseTags,'$1>');A=FCK.ProtectEvents(A);A=FCK.ProtectUrls(A);A=FCK.ProtectTags(A);if (FCK.TempBaseTag.length>0&&!FCKRegexLib.HasBaseTag.test(A)) A=A.replace(FCKRegexLib.HeadOpener,'$&'+FCK.TempBaseTag);var C='';if (!FCKConfig.FullPage) C+=_FCK_GetEditorAreaStyleTags();if (FCKBrowserInfo.IsIE) C+=FCK._GetBehaviorsStyle();else if (FCKConfig.ShowBorders) C+=FCKTools.GetStyleHtml(FCK_ShowTableBordersCSS,true);C+=FCKTools.GetStyleHtml(FCK_InternalCSS,true);A=A.replace(FCKRegexLib.HeadCloser,C+'$&');this.EditingArea.OnLoad=_FCK_EditingArea_OnLoad;this.EditingArea.Start(A);}else{FCK.EditorWindow=null;FCK.EditorDocument=null;FCKDomTools.PaddingNode=null;this.EditingArea.OnLoad=null;this.EditingArea.Start(A);this.EditingArea.Textarea._FCKShowContextMenu=true;FCK.EnterKeyHandler=null;if (B) this.ResetIsDirty();FCK.KeystrokeHandler.AttachToElement(this.EditingArea.Textarea);this.EditingArea.Textarea.focus();FCK.Events.FireEvent('OnAfterSetHTML');};if (window.onresize) window.onresize();},RedirectNamedCommands:{},ExecuteNamedCommand:function(A,B,C,D){if (!D) FCKUndo.SaveUndoStep();if (!C&&FCK.RedirectNamedCommands[A]!=null) FCK.ExecuteRedirectedNamedCommand(A,B);else{FCK.Focus();FCK.EditorDocument.execCommand(A,false,B);FCK.Events.FireEvent('OnSelectionChange');};if (!D) FCKUndo.SaveUndoStep();},GetNamedCommandState:function(A){try{if (FCKBrowserInfo.IsSafari&&FCK.EditorWindow&&A.IEquals('Paste')) return 0;if (!FCK.EditorDocument.queryCommandEnabled(A)) return -1;else{return FCK.EditorDocument.queryCommandState(A)?1:0;}}catch (e){return 0;}},GetNamedCommandValue:function(A){var B='';var C=FCK.GetNamedCommandState(A);if (C==-1) return null;try{B=this.EditorDocument.queryCommandValue(A);}catch(e) {};return B?B:'';},Paste:function(A){if (FCK.Status!=2||!FCK.Events.FireEvent('OnPaste')) return false;return A||FCK._ExecPaste();},PasteFromWord:function(){FCKDialog.OpenDialog('FCKDialog_Paste',FCKLang.PasteFromWord,'dialog/fck_paste.html',400,330,'Word');},Preview:function(){var A;if (FCKConfig.FullPage){if (FCK.TempBaseTag.length>0) A=FCK.TempBaseTag+FCK.GetXHTML();else A=FCK.GetXHTML();}else{A=FCKConfig.DocType+''+FCK.TempBaseTag+''+FCKLang.Preview+''+_FCK_GetEditorAreaStyleTags()+''+FCK.GetXHTML()+'';};var B=FCKConfig.ScreenWidth*0.8;var C=FCKConfig.ScreenHeight*0.7;var D=(FCKConfig.ScreenWidth-B)/2;var E='';if (FCK_IS_CUSTOM_DOMAIN&&FCKBrowserInfo.IsIE){window._FCKHtmlToLoad=A;E='javascript:void( (function(){document.open() ;document.domain="'+document.domain+'" ;document.write( window.opener._FCKHtmlToLoad );document.close() ;window.opener._FCKHtmlToLoad = null ;})() )';};var F=window.open(E,null,'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+B+',height='+C+',left='+D);if (!FCK_IS_CUSTOM_DOMAIN||!FCKBrowserInfo.IsIE){F.document.write(A);F.document.close();}},SwitchEditMode:function(A){var B=(FCK.EditMode==0);var C=FCK.IsDirty();var D;if (B){FCKCommands.GetCommand('ShowBlocks').SaveState();if (!A&&FCKBrowserInfo.IsIE) FCKUndo.SaveUndoStep();D=FCK.GetXHTML(FCKConfig.FormatSource);if (FCKBrowserInfo.IsIE) FCKTempBin.ToHtml();if (D==null) return false;}else D=this.EditingArea.Textarea.value;FCK.EditMode=B?1:0;FCK.SetData(D,!C);FCK.Focus();FCKTools.RunFunction(FCK.ToolbarSet.RefreshModeState,FCK.ToolbarSet);return true;},InsertElement:function(A){if (typeof A=='string') A=this.EditorDocument.createElement(A);var B=A.nodeName.toLowerCase();FCKSelection.Restore();var C=new FCKDomRange(this.EditorWindow);C.MoveToSelection();C.DeleteContents();if (FCKListsLib.BlockElements[B]!=null){if (C.StartBlock){if (C.CheckStartOfBlock()) C.MoveToPosition(C.StartBlock,3);else if (C.CheckEndOfBlock()) C.MoveToPosition(C.StartBlock,4);else C.SplitBlock();};C.InsertNode(A);var D=FCKDomTools.GetNextSourceElement(A,false,null,['hr','br','param','img','area','input'],true);if (!D&&FCKConfig.EnterMode!='br'){D=this.EditorDocument.body.appendChild(this.EditorDocument.createElement(FCKConfig.EnterMode));if (FCKBrowserInfo.IsGeckoLike) FCKTools.AppendBogusBr(D);};if (FCKListsLib.EmptyElements[B]==null) C.MoveToElementEditStart(A);else if (D) C.MoveToElementEditStart(D);else C.MoveToPosition(A,4);if (FCKBrowserInfo.IsGeckoLike){if (D) FCKDomTools.ScrollIntoView(D,false);FCKDomTools.ScrollIntoView(A,false);}}else{C.InsertNode(A);C.SetStart(A,4);C.SetEnd(A,4);};C.Select();C.Release();this.Focus();return A;},_InsertBlockElement:function(A){},_IsFunctionKey:function(A){if (A>=16&&A<=20) return true;if (A==27||(A>=33&&A<=40)) return true;if (A==45) return true;return false;},_KeyDownListener:function(A){if (!A) A=FCK.EditorWindow.event;if (FCK.EditorWindow){if (!FCK._IsFunctionKey(A.keyCode)&&!(A.ctrlKey||A.metaKey)&&!(A.keyCode==46)) FCK._KeyDownUndo();};return true;},_KeyDownUndo:function(){if (!FCKUndo.Typing){FCKUndo.SaveUndoStep();FCKUndo.Typing=true;FCK.Events.FireEvent("OnSelectionChange");};FCKUndo.TypesCount++;FCKUndo.Changed=1;if (FCKUndo.TypesCount>FCKUndo.MaxTypes){FCKUndo.TypesCount=0;FCKUndo.SaveUndoStep();}},_TabKeyHandler:function(A){if (!A) A=window.event;var B=A.keyCode;if (B==9&&FCK.EditMode!=0){if (FCKBrowserInfo.IsIE){var C=document.selection.createRange();if (C.parentElement()!=FCK.EditingArea.Textarea) return true;C.text='\t';C.select();}else{var a=[];var D=FCK.EditingArea.Textarea;var E=D.selectionStart;var F=D.selectionEnd;a.push(D.value.substr(0,E));a.push('\t');a.push(D.value.substr(F));D.value=a.join('');D.setSelectionRange(E+1,E+1);};if (A.preventDefault) return A.preventDefault();return A.returnValue=false;};return true;}};FCK.Events=new FCKEvents(FCK);FCK.GetHTML=FCK.GetXHTML=FCK.GetData;FCK.SetHTML=FCK.SetData;FCK.InsertElementAndGetIt=FCK.CreateElement=FCK.InsertElement;function _FCK_ProtectEvents_ReplaceTags(A){return A.replace(FCKRegexLib.EventAttributes,_FCK_ProtectEvents_ReplaceEvents);};function _FCK_ProtectEvents_ReplaceEvents(A,B){return ' '+B+'_fckprotectedatt="'+encodeURIComponent(A)+'"';};function _FCK_ProtectEvents_RestoreEvents(A,B){return decodeURIComponent(B);};function _FCK_MouseEventsListener(A){if (!A) A=window.event;if (A.type=='mousedown') FCK.MouseDownFlag=true;else if (A.type=='mouseup') FCK.MouseDownFlag=false;else if (A.type=='mousemove') FCK.Events.FireEvent('OnMouseMove',A);};function _FCK_PaddingNodeListener(){if (FCKConfig.EnterMode.IEquals('br')) return;FCKDomTools.EnforcePaddingNode(FCK.EditorDocument,FCKConfig.EnterMode);if (!FCKBrowserInfo.IsIE&&FCKDomTools.PaddingNode){var A=FCKSelection.GetSelection();if (A&&A.rangeCount==1){var B=A.getRangeAt(0);if (B.collapsed&&B.startContainer==FCK.EditorDocument.body&&B.startOffset==0){B.selectNodeContents(FCKDomTools.PaddingNode);B.collapse(true);A.removeAllRanges();A.addRange(B);}}}else if (FCKDomTools.PaddingNode){var C=FCKSelection.GetParentElement();var D=FCKDomTools.PaddingNode;if (C&&C.nodeName.IEquals('body')){if (FCK.EditorDocument.body.childNodes.length==1&&FCK.EditorDocument.body.firstChild==D){if (FCKSelection._GetSelectionDocument(FCK.EditorDocument.selection)!=FCK.EditorDocument) return;var B=FCK.EditorDocument.body.createTextRange();var F=false;if (!D.childNodes.firstChild){D.appendChild(FCKTools.GetElementDocument(D).createTextNode('\ufeff'));F=true;};B.moveToElementText(D);B.select();if (F) B.pasteHTML('');}}}};function _FCK_EditingArea_OnLoad(){FCK.EditorWindow=FCK.EditingArea.Window;FCK.EditorDocument=FCK.EditingArea.Document;if (FCKBrowserInfo.IsIE) FCKTempBin.ToElements();FCK.InitializeBehaviors();FCK.MouseDownFlag=false;FCKTools.AddEventListener(FCK.EditorDocument,'mousemove',_FCK_MouseEventsListener);FCKTools.AddEventListener(FCK.EditorDocument,'mousedown',_FCK_MouseEventsListener);FCKTools.AddEventListener(FCK.EditorDocument,'mouseup',_FCK_MouseEventsListener);if (FCKBrowserInfo.IsSafari){FCKTools.AddEventListener(FCK.EditorDocument,'paste',function(evt){var A=new FCKDomRange(FCK.EditorWindow);var B=FCK.EditorDocument.createTextNode('\ufeff');var C=FCK.EditorDocument.createElement('a');C.id='fck_paste_padding';C.innerHTML='';A.MoveToSelection();A.DeleteContents();A.InsertNode(B);A.Collapse();A.InsertNode(C);A.MoveToPosition(C,3);A.Select();setTimeout(function(){B.parentNode.removeChild(B);C=FCK.EditorDocument.getElementById('fck_paste_padding');C.parentNode.removeChild(C);},0);});};if (FCKBrowserInfo.IsSafari){var D=function(evt){if (!(evt.ctrlKey||evt.metaKey)) return;if (FCK.EditMode!=0) return;switch (evt.keyCode){case 89:FCKUndo.Redo();break;case 90:FCKUndo.Undo();break;}};FCKTools.AddEventListener(FCK.EditorDocument,'keyup',D);};FCK.EnterKeyHandler=new FCKEnterKey(FCK.EditorWindow,FCKConfig.EnterMode,FCKConfig.ShiftEnterMode,FCKConfig.TabSpaces);FCK.KeystrokeHandler.AttachToElement(FCK.EditorDocument);if (FCK._ForceResetIsDirty) FCK.ResetIsDirty();if (FCKBrowserInfo.IsIE&&FCK.HasFocus) FCK.EditorDocument.body.setActive();FCK.OnAfterSetHTML();FCKCommands.GetCommand('ShowBlocks').RestoreState();if (FCK.Status!=0) return;FCK.SetStatus(1);};function _FCK_GetEditorAreaStyleTags(){return FCKTools.GetStyleHtml(FCKConfig.EditorAreaCSS)+FCKTools.GetStyleHtml(FCKConfig.EditorAreaStyles);};function _FCK_KeystrokeHandler_OnKeystroke(A,B){if (FCK.Status!=2) return false;if (FCK.EditMode==0){switch (B){case 'Paste':return!FCK.Paste();case 'Cut':FCKUndo.SaveUndoStep();return false;}}else{if (B.Equals('Paste','Undo','Redo','SelectAll','Cut')) return false;};var C=FCK.Commands.GetCommand(B);if (C.GetState()==-1) return false;return (C.Execute.apply(C,FCKTools.ArgumentsToArray(arguments,2))!==false);};(function(){var A=window.parent.document;var B=A.getElementById(FCK.Name);var i=0;while (B||i==0){if (B&&B.tagName.toLowerCase().Equals('input','textarea')){FCK.LinkedField=B;break;};B=A.getElementsByName(FCK.Name)[i++];}})();var FCKTempBin={Elements:[],AddElement:function(A){var B=this.Elements.length;this.Elements[B]=A;return B;},RemoveElement:function(A){var e=this.Elements[A];this.Elements[A]=null;return e;},Reset:function(){var i=0;while (i '+this.Elements[i].outerHTML+'
    ';this.Elements[i].isHtml=true;}},ToElements:function(){var A=FCK.EditorDocument.createElement('div');for (var i=0;i0?'':'';var A=FCK.KeystrokeHandler=new FCKKeystrokeHandler();A.OnKeystroke=_FCK_KeystrokeHandler_OnKeystroke;A.SetKeystrokes(FCKConfig.Keystrokes);if (FCKBrowserInfo.IsIE7){if ((CTRL+86) in A.Keystrokes) A.SetKeystrokes([CTRL+86,true]);if ((SHIFT+45) in A.Keystrokes) A.SetKeystrokes([SHIFT+45,true]);};A.SetKeystrokes([CTRL+8,true]);this.EditingArea=new FCKEditingArea(document.getElementById('xEditingArea'));this.EditingArea.FFSpellChecker=FCKConfig.FirefoxSpellChecker;this.SetData(this.GetLinkedFieldValue(),true);FCKTools.AddEventListener(document,"keydown",this._TabKeyHandler);this.AttachToOnSelectionChange(_FCK_PaddingNodeListener);if (FCKBrowserInfo.IsGecko) this.AttachToOnSelectionChange(this._ExecCheckEmptyBlock);},Focus:function(){FCK.EditingArea.Focus();},SetStatus:function(A){this.Status=A;if (A==1){FCKFocusManager.AddWindow(window,true);if (FCKBrowserInfo.IsIE) FCKFocusManager.AddWindow(window.frameElement,true);if (FCKConfig.StartupFocus) FCK.Focus();};this.Events.FireEvent('OnStatusChange',A);},FixBody:function(){var A=FCKConfig.EnterMode;if (A!='p'&&A!='div') return;var B=this.EditorDocument;if (!B) return;var C=B.body;if (!C) return;FCKDomTools.TrimNode(C);var D=C.firstChild;var E;while (D){var F=false;switch (D.nodeType){case 1:var G=D.nodeName.toLowerCase();if (!FCKListsLib.BlockElements[G]&&G!='li'&&!D.getAttribute('_fckfakelement')&&D.getAttribute('_moz_dirty')==null) F=true;break;case 3:if (E||D.nodeValue.Trim().length>0) F=true;break;case 8:if (E) F=true;break;};if (F){var H=D.parentNode;if (!E) E=H.insertBefore(B.createElement(A),D);E.appendChild(H.removeChild(D));D=E.nextSibling;}else{if (E){FCKDomTools.TrimNode(E);E=null;};D=D.nextSibling;}};if (E) FCKDomTools.TrimNode(E);},GetData:function(A){FCK.Events.FireEvent("OnBeforeGetData");if (FCK.EditMode==1) return FCK.EditingArea.Textarea.value;this.FixBody();var B=FCK.EditorDocument;if (!B) return null;var C=FCKConfig.FullPage;var D=FCK.DataProcessor.ConvertToDataFormat(C?B.documentElement:B.body,!C,FCKConfig.IgnoreEmptyParagraphValue,A);D=FCK.ProtectEventsRestore(D);if (FCKBrowserInfo.IsIE) D=D.replace(FCKRegexLib.ToReplace,'$1');if (C){if (FCK.DocTypeDeclaration&&FCK.DocTypeDeclaration.length>0) D=FCK.DocTypeDeclaration+'\n'+D;if (FCK.XmlDeclaration&&FCK.XmlDeclaration.length>0) D=FCK.XmlDeclaration+'\n'+D;};D=FCKConfig.ProtectedSource.Revert(D);setTimeout(function() { FCK.Events.FireEvent("OnAfterGetData");},0);return D;},UpdateLinkedField:function(){var A=FCK.GetXHTML(FCKConfig.FormatOutput);if (FCKConfig.HtmlEncodeOutput) A=FCKTools.HTMLEncode(A);FCK.LinkedField.value=A;FCK.Events.FireEvent('OnAfterLinkedFieldUpdate');},RegisteredDoubleClickHandlers:{},OnDoubleClick:function(A){var B=FCK.RegisteredDoubleClickHandlers[A.tagName.toUpperCase()];if (B){for (var i=0;i0?'|ABBR|XML|EMBED|OBJECT':'ABBR|XML|EMBED|OBJECT';var C;if (B.length>0){C=new RegExp('<('+B+')(?!\w|:)','gi');A=A.replace(C,'','gi');A=A.replace(C,'<\/FCK:$1>');};B='META';if (FCKBrowserInfo.IsIE) B+='|HR';C=new RegExp('<(('+B+')(?=\s|>)[\s\S]*?)/?>','gi');A=A.replace(C,'');return A;},SetData:function(A,B){this.EditingArea.Mode=FCK.EditMode;if (FCKBrowserInfo.IsIE&&FCK.EditorDocument){FCK.EditorDocument.detachEvent("onselectionchange",Doc_OnSelectionChange);};FCKTempBin.Reset();FCK.Selection.Release();if (FCK.EditMode==0){this._ForceResetIsDirty=(B===true);A=FCKConfig.ProtectedSource.Protect(A);A=FCK.DataProcessor.ConvertToHtml(A);A=A.replace(FCKRegexLib.InvalidSelfCloseTags,'$1>');A=FCK.ProtectEvents(A);A=FCK.ProtectUrls(A);A=FCK.ProtectTags(A);if (FCK.TempBaseTag.length>0&&!FCKRegexLib.HasBaseTag.test(A)) A=A.replace(FCKRegexLib.HeadOpener,'$&'+FCK.TempBaseTag);var C='';if (!FCKConfig.FullPage) C+=_FCK_GetEditorAreaStyleTags();if (FCKBrowserInfo.IsIE) C+=FCK._GetBehaviorsStyle();else if (FCKConfig.ShowBorders) C+=FCKTools.GetStyleHtml(FCK_ShowTableBordersCSS,true);C+=FCKTools.GetStyleHtml(FCK_InternalCSS,true);A=A.replace(FCKRegexLib.HeadCloser,C+'$&');this.EditingArea.OnLoad=_FCK_EditingArea_OnLoad;this.EditingArea.Start(A);}else{FCK.EditorWindow=null;FCK.EditorDocument=null;FCKDomTools.PaddingNode=null;this.EditingArea.OnLoad=null;this.EditingArea.Start(A);this.EditingArea.Textarea._FCKShowContextMenu=true;FCK.EnterKeyHandler=null;if (B) this.ResetIsDirty();FCK.KeystrokeHandler.AttachToElement(this.EditingArea.Textarea);this.EditingArea.Textarea.focus();FCK.Events.FireEvent('OnAfterSetHTML');};if (window.onresize) window.onresize();},RedirectNamedCommands:{},ExecuteNamedCommand:function(A,B,C,D){if (!D) FCKUndo.SaveUndoStep();if (!C&&FCK.RedirectNamedCommands[A]!=null) FCK.ExecuteRedirectedNamedCommand(A,B);else{FCK.Focus();FCK.EditorDocument.execCommand(A,false,B);FCK.Events.FireEvent('OnSelectionChange');};if (!D) FCKUndo.SaveUndoStep();},GetNamedCommandState:function(A){try{if (FCKBrowserInfo.IsSafari&&FCK.EditorWindow&&A.IEquals('Paste')) return 0;if (!FCK.EditorDocument.queryCommandEnabled(A)) return -1;else{return FCK.EditorDocument.queryCommandState(A)?1:0;}}catch (e){return 0;}},GetNamedCommandValue:function(A){var B='';var C=FCK.GetNamedCommandState(A);if (C==-1) return null;try{B=this.EditorDocument.queryCommandValue(A);}catch(e) {};return B?B:'';},Paste:function(A){if (FCK.Status!=2||!FCK.Events.FireEvent('OnPaste')) return false;return A||FCK._ExecPaste();},PasteFromWord:function(){FCKDialog.OpenDialog('FCKDialog_Paste',FCKLang.PasteFromWord,'dialog/fck_paste.html',400,330,'Word');},Preview:function(){var A;if (FCKConfig.FullPage){if (FCK.TempBaseTag.length>0) A=FCK.TempBaseTag+FCK.GetXHTML();else A=FCK.GetXHTML();}else{A=FCKConfig.DocType+''+FCK.TempBaseTag+''+FCKLang.Preview+''+_FCK_GetEditorAreaStyleTags()+''+FCK.GetXHTML()+'';};var B=FCKConfig.ScreenWidth*0.8;var C=FCKConfig.ScreenHeight*0.7;var D=(FCKConfig.ScreenWidth-B)/2;var E='';if (FCK_IS_CUSTOM_DOMAIN&&FCKBrowserInfo.IsIE){window._FCKHtmlToLoad=A;E='javascript:void( (function(){document.open() ;document.domain="'+document.domain+'" ;document.write( window.opener._FCKHtmlToLoad );document.close() ;window.opener._FCKHtmlToLoad = null ;})() )';};var F=window.open(E,null,'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+B+',height='+C+',left='+D);if (!FCK_IS_CUSTOM_DOMAIN||!FCKBrowserInfo.IsIE){F.document.write(A);F.document.close();}},SwitchEditMode:function(A){var B=(FCK.EditMode==0);var C=FCK.IsDirty();var D;if (B){FCKCommands.GetCommand('ShowBlocks').SaveState();if (!A&&FCKBrowserInfo.IsIE) FCKUndo.SaveUndoStep();D=FCK.GetXHTML(FCKConfig.FormatSource);if (FCKBrowserInfo.IsIE) FCKTempBin.ToHtml();if (D==null) return false;}else D=this.EditingArea.Textarea.value;FCK.EditMode=B?1:0;FCK.SetData(D,!C);FCK.Focus();FCKTools.RunFunction(FCK.ToolbarSet.RefreshModeState,FCK.ToolbarSet);return true;},InsertElement:function(A){if (typeof A=='string') A=this.EditorDocument.createElement(A);var B=A.nodeName.toLowerCase();FCKSelection.Restore();var C=new FCKDomRange(this.EditorWindow);C.MoveToSelection();C.DeleteContents();if (FCKListsLib.BlockElements[B]!=null){if (C.StartBlock){if (C.CheckStartOfBlock()) C.MoveToPosition(C.StartBlock,3);else if (C.CheckEndOfBlock()) C.MoveToPosition(C.StartBlock,4);else C.SplitBlock();};C.InsertNode(A);var D=FCKDomTools.GetNextSourceElement(A,false,null,['hr','br','param','img','area','input'],true);if (!D&&FCKConfig.EnterMode!='br'){D=this.EditorDocument.body.appendChild(this.EditorDocument.createElement(FCKConfig.EnterMode));if (FCKBrowserInfo.IsGeckoLike) FCKTools.AppendBogusBr(D);};if (FCKListsLib.EmptyElements[B]==null) C.MoveToElementEditStart(A);else if (D) C.MoveToElementEditStart(D);else C.MoveToPosition(A,4);if (FCKBrowserInfo.IsGeckoLike){if (D) FCKDomTools.ScrollIntoView(D,false);FCKDomTools.ScrollIntoView(A,false);}}else{C.InsertNode(A);C.SetStart(A,4);C.SetEnd(A,4);};C.Select();C.Release();this.Focus();return A;},_InsertBlockElement:function(A){},_IsFunctionKey:function(A){if (A>=16&&A<=20) return true;if (A==27||(A>=33&&A<=40)) return true;if (A==45) return true;return false;},_KeyDownListener:function(A){if (!A) A=FCK.EditorWindow.event;if (FCK.EditorWindow){if (!FCK._IsFunctionKey(A.keyCode)&&!(A.ctrlKey||A.metaKey)&&!(A.keyCode==46)) FCK._KeyDownUndo();};return true;},_KeyDownUndo:function(){if (!FCKUndo.Typing){FCKUndo.SaveUndoStep();FCKUndo.Typing=true;FCK.Events.FireEvent("OnSelectionChange");};FCKUndo.TypesCount++;FCKUndo.Changed=1;if (FCKUndo.TypesCount>FCKUndo.MaxTypes){FCKUndo.TypesCount=0;FCKUndo.SaveUndoStep();}},_TabKeyHandler:function(A){if (!A) A=window.event;var B=A.keyCode;if (B==9&&FCK.EditMode!=0){if (FCKBrowserInfo.IsIE){var C=document.selection.createRange();if (C.parentElement()!=FCK.EditingArea.Textarea) return true;C.text='\t';C.select();}else{var a=[];var D=FCK.EditingArea.Textarea;var E=D.selectionStart;var F=D.selectionEnd;a.push(D.value.substr(0,E));a.push('\t');a.push(D.value.substr(F));D.value=a.join('');D.setSelectionRange(E+1,E+1);};if (A.preventDefault) return A.preventDefault();return A.returnValue=false;};return true;}};FCK.Events=new FCKEvents(FCK);FCK.GetHTML=FCK.GetXHTML=FCK.GetData;FCK.SetHTML=FCK.SetData;FCK.InsertElementAndGetIt=FCK.CreateElement=FCK.InsertElement;function _FCK_ProtectEvents_ReplaceTags(A){return A.replace(FCKRegexLib.EventAttributes,_FCK_ProtectEvents_ReplaceEvents);};function _FCK_ProtectEvents_ReplaceEvents(A,B){return ' '+B+'_fckprotectedatt="'+encodeURIComponent(A)+'"';};function _FCK_ProtectEvents_RestoreEvents(A,B){return decodeURIComponent(B);};function _FCK_MouseEventsListener(A){if (!A) A=window.event;if (A.type=='mousedown') FCK.MouseDownFlag=true;else if (A.type=='mouseup') FCK.MouseDownFlag=false;else if (A.type=='mousemove') FCK.Events.FireEvent('OnMouseMove',A);};function _FCK_PaddingNodeListener(){if (FCKConfig.EnterMode.IEquals('br')) return;FCKDomTools.EnforcePaddingNode(FCK.EditorDocument,FCKConfig.EnterMode);if (!FCKBrowserInfo.IsIE&&FCKDomTools.PaddingNode){var A=FCKSelection.GetSelection();if (A&&A.rangeCount==1){var B=A.getRangeAt(0);if (B.collapsed&&B.startContainer==FCK.EditorDocument.body&&B.startOffset==0){B.selectNodeContents(FCKDomTools.PaddingNode);B.collapse(true);A.removeAllRanges();A.addRange(B);}}}else if (FCKDomTools.PaddingNode){var C=FCKSelection.GetParentElement();var D=FCKDomTools.PaddingNode;if (C&&C.nodeName.IEquals('body')){if (FCK.EditorDocument.body.childNodes.length==1&&FCK.EditorDocument.body.firstChild==D){if (FCKSelection._GetSelectionDocument(FCK.EditorDocument.selection)!=FCK.EditorDocument) return;var B=FCK.EditorDocument.body.createTextRange();var F=false;if (!D.childNodes.firstChild){D.appendChild(FCKTools.GetElementDocument(D).createTextNode('\ufeff'));F=true;};B.moveToElementText(D);B.select();if (F) B.pasteHTML('');}}}};function _FCK_EditingArea_OnLoad(){FCK.EditorWindow=FCK.EditingArea.Window;FCK.EditorDocument=FCK.EditingArea.Document;if (FCKBrowserInfo.IsIE) FCKTempBin.ToElements();FCK.InitializeBehaviors();FCK.MouseDownFlag=false;FCKTools.AddEventListener(FCK.EditorDocument,'mousemove',_FCK_MouseEventsListener);FCKTools.AddEventListener(FCK.EditorDocument,'mousedown',_FCK_MouseEventsListener);FCKTools.AddEventListener(FCK.EditorDocument,'mouseup',_FCK_MouseEventsListener);if (FCKBrowserInfo.IsSafari){FCKTools.AddEventListener(FCK.EditorDocument,'paste',function(evt){var A=new FCKDomRange(FCK.EditorWindow);var B=FCK.EditorDocument.createTextNode('\ufeff');var C=FCK.EditorDocument.createElement('a');C.id='fck_paste_padding';C.innerHTML='';A.MoveToSelection();A.DeleteContents();A.InsertNode(B);A.Collapse();A.InsertNode(C);A.MoveToPosition(C,3);A.Select();setTimeout(function(){B.parentNode.removeChild(B);C=FCK.EditorDocument.getElementById('fck_paste_padding');C.parentNode.removeChild(C);},0);});};if (FCKBrowserInfo.IsSafari){var D=function(evt){if (!(evt.ctrlKey||evt.metaKey)) return;if (FCK.EditMode!=0) return;switch (evt.keyCode){case 89:FCKUndo.Redo();break;case 90:FCKUndo.Undo();break;}};FCKTools.AddEventListener(FCK.EditorDocument,'keyup',D);};FCK.EnterKeyHandler=new FCKEnterKey(FCK.EditorWindow,FCKConfig.EnterMode,FCKConfig.ShiftEnterMode,FCKConfig.TabSpaces);FCK.KeystrokeHandler.AttachToElement(FCK.EditorDocument);if (FCK._ForceResetIsDirty) FCK.ResetIsDirty();if (FCKBrowserInfo.IsIE&&FCK.HasFocus) FCK.EditorDocument.body.setActive();FCK.OnAfterSetHTML();FCKCommands.GetCommand('ShowBlocks').RestoreState();if (FCK.Status!=0) return;FCK.SetStatus(1);};function _FCK_GetEditorAreaStyleTags(){return FCKTools.GetStyleHtml(FCKConfig.EditorAreaCSS)+FCKTools.GetStyleHtml(FCKConfig.EditorAreaStyles);};function _FCK_KeystrokeHandler_OnKeystroke(A,B){if (FCK.Status!=2) return false;if (FCK.EditMode==0){switch (B){case 'Paste':return!FCK.Paste();case 'Cut':FCKUndo.SaveUndoStep();return false;}}else{if (B.Equals('Paste','Undo','Redo','SelectAll','Cut')) return false;};var C=FCK.Commands.GetCommand(B);if (C.GetState()==-1) return false;return (C.Execute.apply(C,FCKTools.ArgumentsToArray(arguments,2))!==false);};(function(){var A=window.parent.document;var B=A.getElementById(FCK.Name);var i=0;while (B||i==0){if (B&&B.tagName.toLowerCase().Equals('input','textarea')){FCK.LinkedField=B;break;};B=A.getElementsByName(FCK.Name)[i++];}})();var FCKTempBin={Elements:[],AddElement:function(A){var B=this.Elements.length;this.Elements[B]=A;return B;},RemoveElement:function(A){var e=this.Elements[A];this.Elements[A]=null;return e;},Reset:function(){var i=0;while (i '+this.Elements[i].outerHTML+'
    ';this.Elements[i].isHtml=true;}},ToElements:function(){var A=FCK.EditorDocument.createElement('div');for (var i=0;i0) C+='TABLE { behavior: '+B+' ; }';C+='';FCK._BehaviorsStyle=C;};return FCK._BehaviorsStyle;};function Doc_OnMouseUp(){if (FCK.EditorWindow.event.srcElement.tagName=='HTML'){FCK.Focus();FCK.EditorWindow.event.cancelBubble=true;FCK.EditorWindow.event.returnValue=false;}};function Doc_OnPaste(){var A=FCK.EditorDocument.body;A.detachEvent('onpaste',Doc_OnPaste);var B=FCK.Paste(!FCKConfig.ForcePasteAsPlainText&&!FCKConfig.AutoDetectPasteFromWord);A.attachEvent('onpaste',Doc_OnPaste);return B;};function Doc_OnDblClick(){FCK.OnDoubleClick(FCK.EditorWindow.event.srcElement);FCK.EditorWindow.event.cancelBubble=true;};function Doc_OnSelectionChange(){if (!FCK.IsSelectionChangeLocked&&FCK.EditorDocument) FCK.Events.FireEvent("OnSelectionChange");};function Doc_OnDrop(){if (FCK.MouseDownFlag){FCK.MouseDownFlag=false;return;};if (FCKConfig.ForcePasteAsPlainText){var A=FCK.EditorWindow.event;if (FCK._CheckIsPastingEnabled()||FCKConfig.ShowDropDialog) FCK.PasteAsPlainText(A.dataTransfer.getData('Text'));A.returnValue=false;A.cancelBubble=true;}};FCK.InitializeBehaviors=function(A){this.EditorDocument.attachEvent('onmouseup',Doc_OnMouseUp);this.EditorDocument.body.attachEvent('onpaste',Doc_OnPaste);this.EditorDocument.body.attachEvent('ondrop',Doc_OnDrop);FCK.ContextMenu._InnerContextMenu.AttachToElement(FCK.EditorDocument.body);this.EditorDocument.attachEvent("onkeydown",FCK._KeyDownListener);this.EditorDocument.attachEvent("ondblclick",Doc_OnDblClick);this.EditorDocument.attachEvent("onbeforedeactivate",function(){ FCKSelection.Save();});this.EditorDocument.attachEvent("onselectionchange",Doc_OnSelectionChange);FCKTools.AddEventListener(FCK.EditorDocument,'mousedown',Doc_OnMouseDown);};FCK.InsertHtml=function(A){A=FCKConfig.ProtectedSource.Protect(A);A=FCK.ProtectEvents(A);A=FCK.ProtectUrls(A);A=FCK.ProtectTags(A);FCKSelection.Restore();FCK.EditorWindow.focus();FCKUndo.SaveUndoStep();var B=FCKSelection.GetSelection();if (B.type.toLowerCase()=='control') B.clear();A=''+A;B.createRange().pasteHTML(A);var C=FCK.EditorDocument.getElementById('__fakeFCKRemove__');if (C.parentNode.childNodes.length==1) C=C.parentNode;C.removeNode(true);FCKDocumentProcessor.Process(FCK.EditorDocument);this.Events.FireEvent("OnSelectionChange");};FCK.SetInnerHtml=function(A){var B=FCK.EditorDocument;B.body.innerHTML='
     
    '+A;B.getElementById('__fakeFCKRemove__').removeNode(true);};function FCK_PreloadImages(){var A=new FCKImagePreloader();A.AddImages(FCKConfig.PreloadImages);A.AddImages(FCKConfig.SkinPath+'fck_strip.gif');A.OnComplete=LoadToolbarSetup;A.Start();};function Document_OnContextMenu(){return (event.srcElement._FCKShowContextMenu==true);};document.oncontextmenu=Document_OnContextMenu;function FCK_Cleanup(){this.LinkedField=null;this.EditorWindow=null;this.EditorDocument=null;};FCK._ExecPaste=function(){if (FCK._PasteIsRunning) return true;if (FCKConfig.ForcePasteAsPlainText){FCK.PasteAsPlainText();return false;};var A=FCK._CheckIsPastingEnabled(true);if (A===false) FCKTools.RunFunction(FCKDialog.OpenDialog,FCKDialog,['FCKDialog_Paste',FCKLang.Paste,'dialog/fck_paste.html',400,330,'Security']);else{if (FCKConfig.AutoDetectPasteFromWord&&A.length>0){var B=/<\w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi;if (B.test(A)){if (confirm(FCKLang.PasteWordConfirm)){FCK.PasteFromWord();return false;}}};FCK._PasteIsRunning=true;FCK.ExecuteNamedCommand('Paste');delete FCK._PasteIsRunning;};return false;};FCK.PasteAsPlainText=function(A){if (!FCK._CheckIsPastingEnabled()){FCKDialog.OpenDialog('FCKDialog_Paste',FCKLang.PasteAsText,'dialog/fck_paste.html',400,330,'PlainText');return;};var B=null;if (!A) B=clipboardData.getData("Text");else B=A;if (B&&B.length>0){B=FCKTools.HTMLEncode(B);B=FCKTools.ProcessLineBreaks(window,FCKConfig,B);var C=B.search('

    ');var D=B.search('

    ');if ((C!=-1&&D!=-1&&C0){if (D){var F=this.EditorDocument.createElement('A');F.href=A;var G=E;G.parentNode.insertBefore(F,G);G.parentNode.removeChild(G);F.appendChild(G);return [F];};var H='javascript:void(0);/*'+(new Date().getTime())+'*/';FCK.ExecuteNamedCommand('CreateLink',H,false,!!B);var I=this.EditorDocument.links;for (i=0;i0&&!isNaN(E)) this.PageConfig[D]=parseFloat(E);else this.PageConfig[D]=E;}};function FCKConfig_LoadPageConfig(){var A=FCKConfig.PageConfig;for (var B in A) FCKConfig[B]=A[B];};function FCKConfig_PreProcess(){var A=FCKConfig;if (A.AllowQueryStringDebug){try{if ((/fckdebug=true/i).test(window.top.location.search)) A.Debug=true;}catch (e) { }};if (!A.PluginsPath.EndsWith('/')) A.PluginsPath+='/';var B=A.ToolbarComboPreviewCSS;if (!B||B.length==0) A.ToolbarComboPreviewCSS=A.EditorAreaCSS;A.RemoveAttributesArray=(A.RemoveAttributes||'').split(',');if (!FCKConfig.SkinEditorCSS||FCKConfig.SkinEditorCSS.length==0) FCKConfig.SkinEditorCSS=FCKConfig.SkinPath+'fck_editor.css';if (!FCKConfig.SkinDialogCSS||FCKConfig.SkinDialogCSS.length==0) FCKConfig.SkinDialogCSS=FCKConfig.SkinPath+'fck_dialog.css';};FCKConfig.ToolbarSets={};FCKConfig.Plugins={};FCKConfig.Plugins.Items=[];FCKConfig.Plugins.Add=function(A,B,C){FCKConfig.Plugins.Items.push([A,B,C]);};FCKConfig.ProtectedSource={};FCKConfig.ProtectedSource._CodeTag=(new Date()).valueOf();FCKConfig.ProtectedSource.RegexEntries=[//g,//gi,//gi];FCKConfig.ProtectedSource.Add=function(A){this.RegexEntries.push(A);};FCKConfig.ProtectedSource.Protect=function(A){var B=this._CodeTag;function _Replace(protectedSource){var C=FCKTempBin.AddElement(protectedSource);return '';};for (var i=0;i|>)","g");return A.replace(D,_Replace);};FCKConfig.GetBodyAttributes=function(){var A='';if (this.BodyId&&this.BodyId.length>0) A+=' id="'+this.BodyId+'"';if (this.BodyClass&&this.BodyClass.length>0) A+=' class="'+this.BodyClass+'"';return A;};FCKConfig.ApplyBodyAttributes=function(A){if (this.BodyId&&this.BodyId.length>0) A.id=FCKConfig.BodyId;if (this.BodyClass&&this.BodyClass.length>0) A.className+=' '+FCKConfig.BodyClass;}; var FCKDebug={Output:function(){},OutputObject:function(){}}; diff --git a/main/inc/lib/formvalidator/Element/html_editor.php b/main/inc/lib/formvalidator/Element/html_editor.php old mode 100755 new mode 100644 index 69fcb1f1c3..d7dde836be --- a/main/inc/lib/formvalidator/Element/html_editor.php +++ b/main/inc/lib/formvalidator/Element/html_editor.php @@ -1,120 +1,115 @@ _persistantFreeze = true; + $this->_type = 'html_editor'; + $this->fullPage = false; + + $name = $this->getAttribute('name'); + $this->fck_editor = new FCKeditor($name); - HTML_QuickForm_element :: HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->_type = 'html_editor'; - $this->fullPage = false; + $this->fck_editor->ToolbarSet = $fck_attribute['ToolbarSet']; + $this->fck_editor->Width = !empty($fck_attribute['Width']) ? $fck_attribute['Width'] : '990'; + $this->fck_editor->Height = !empty($fck_attribute['Height']) ? $fck_attribute['Height'] : '400'; + //We get the optionnals config parameters in $fck_attribute array + $this->fck_editor->Config = !empty($fck_attribute['Config']) ? $fck_attribute['Config'] : array(); - $name = $this->getAttribute('name'); - $this -> fck_editor = new FCKeditor($name); + // This is an alternative (a better) way to pass configuration data to the editor. + if (is_array($config)) { + foreach ($config as $key => $value) { + $this->fck_editor->Config[$key] = $config[$key]; + } + if (isset($config['ToolbarSet'])) { + $this->fck_editor->ToolbarSet = $config['ToolbarSet']; + } + if (isset($config['Width'])) { + $this->fck_editor->Width = $config['Width']; + } + if (isset($config['Height'])) { + $this->fck_editor->Height = $config['Height']; + } + if (isset($config['FullPage'])) { + $this->fullPage = is_bool($config['FullPage']) ? $config['FullPage'] : ($config['FullPage'] === 'true'); + } + } + } - $this->fck_editor->ToolbarSet = $fck_attribute['ToolbarSet'] ; - $this -> fck_editor->Width = !empty($fck_attribute['Width']) ? $fck_attribute['Width'] : '990'; - $this -> fck_editor->Height = !empty($fck_attribute['Height']) ? $fck_attribute['Height'] : '400'; - //We get the optionnals config parameters in $fck_attribute array - $this -> fck_editor->Config = !empty($fck_attribute['Config']) ? $fck_attribute['Config'] : array(); + /** + * Check if the browser supports FCKeditor + * + * @access public + * @return boolean + */ + function browserSupported() { + return FCKeditor :: IsCompatible(); + } - // This is an alternative (a better) way to pass configuration data to the editor. - if (is_array($config)) { - foreach ($config as $key => $value) { - $this->fck_editor->Config[$key] = $config[$key]; - } - if (isset($config['ToolbarSet'])) { - $this->fck_editor->ToolbarSet = $config['ToolbarSet']; - } - if (isset($config['Width'])) { - $this->fck_editor->Width = $config['Width']; - } - if (isset($config['Height'])) { - $this->fck_editor->Height = $config['Height']; - } - if (isset($config['FullPage'])) { - $this->fullPage = is_bool($config['FullPage']) ? $config['FullPage'] : ($config['FullPage'] === 'true'); - } - } - } + /** + * Return the HTML editor in HTML + * @return string + */ + function toHtml() { + $value = $this->getValue(); + if ($this->fullPage) { + if (strlen(trim($value)) == 0) { + // TODO: To be considered whether here to be added DOCTYPE, language and character set declarations. + $value = ''; + $this->setValue($value); + } + } + if ($this->_flagFrozen) { + return $this->getFrozenHtml(); + } else { + return $this->build_FCKeditor(); + } + } - /** - * Check if the browser supports FCKeditor - * - * @access public - * @return boolean - */ - function browserSupported() - { - return FCKeditor :: IsCompatible(); - } - /** - * Return the HTML editor in HTML - * @return string - */ - function toHtml() - { - $value = $this->getValue(); - if ($this->fullPage) { - - if (strlen(trim($value)) == 0) { - // TODO: To be considered whether here to be added DOCTYPE, language and character set declarations. - $value = ''; - $this->setValue($value); - } - } - if ($this->_flagFrozen) { - return $this->getFrozenHtml(); - } else { - return $this->build_FCKeditor(); - } - - } - /** - * Returns the htmlarea content in HTML - *@return string - */ - function getFrozenHtml() - { - return $this->getValue(); - } - /** - * Build this element using FCKeditor - */ - function build_FCKeditor() - { - $result = ''; - if(! FCKeditor :: IsCompatible()) - { - return parent::toHTML(); - } - $this->fck_editor->Value= $this->getValue(); - $result .= $this->fck_editor->CreateHtml(); + /** + * Returns the htmlarea content in HTML + * @return string + */ + function getFrozenHtml() { + return $this->getValue(); + } - //Add a link to open the allowed html tags window - //$result .= ''.get_lang('AllowedHTMLTags').''; - return $result; - } + /** + * Build this element using FCKeditor + */ + function build_FCKeditor() { + if (!FCKeditor :: IsCompatible()) { + return parent::toHTML(); + } + $this->fck_editor->Value = $this->getValue(); + $result = $this->fck_editor->CreateHtml(); + //Add a link to open the allowed html tags window + //$result .= ''.get_lang('AllowedHTMLTags').''; + return $result; + } } \ No newline at end of file diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index 36f4c73859..e10d06cc7a 100644 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -156,8 +156,7 @@ class GroupPortalManager { public static function get_group_data($group_id) { $table = Database :: get_main_table(TABLE_MAIN_GROUP); - $group_id = intval($group_id); - $user_condition = ''; + $group_id = intval($group_id); $sql = "SELECT id, name, description, picture_uri, url, visibility FROM $table WHERE id = $group_id "; $res = Database::query($sql); $item = array(); @@ -296,8 +295,7 @@ class GroupPortalManager { $tag = Database :: get_main_table(TABLE_MAIN_TAG); $table_group_rel_tag = Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG); $group_id = intval($group_id); - $user_condition = ''; - + $sql = "SELECT tag FROM $tag t INNER JOIN $table_group_rel_tag gt ON (gt.tag_id= t.id) WHERE gt.group_id = $group_id "; $res = Database::query($sql); $tags = array(); @@ -326,8 +324,7 @@ class GroupPortalManager { * @return array Database::store_result of the result * @author Julio Montoya * */ - public static function get_groups_by_user($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) { - $where = ''; + public static function get_groups_by_user($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) { $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); $user_id = intval($user_id); @@ -365,8 +362,7 @@ class GroupPortalManager { * @return array with group content * @author Julio Montoya * */ - public static function get_groups_by_popularity($num = 6, $with_image = true) { - $where = ''; + public static function get_groups_by_popularity($num = 6, $with_image = true) { $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); if (empty($num)) { @@ -403,8 +399,7 @@ class GroupPortalManager { * @return array with group content * @author Julio Montoya * */ - public static function get_groups_by_age($num = 6, $with_image = true) { - $where = ''; + public static function get_groups_by_age($num = 6, $with_image = true) { $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); @@ -647,7 +642,7 @@ class GroupPortalManager { $sql = "UPDATE $table_group_rel_user SET relation_type = ".intval($relation_type)." WHERE user_id = $user_id AND group_id = $group_id" ; - $result = Database::query($sql); + Database::query($sql); } @@ -823,8 +818,7 @@ class GroupPortalManager { $medium = self::resize_picture($source_file, 85); $normal = self::resize_picture($source_file, 200); - $big = new Image($source_file); // This is the original picture. - $ok = false; + $big = new Image($source_file); // This is the original picture. $ok = $small->send_image($path.'small_'.$filename) && $medium->send_image($path.'medium_'.$filename) && $normal->send_image($path.'big_'.$filename) diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php index 7299389903..d5236b4106 100644 --- a/main/inc/lib/login.lib.php +++ b/main/inc/lib/login.lib.php @@ -21,7 +21,7 @@ class Login /** * Get user account list * - * @param unknown_type $user + * @param array $user array with keys: email, password, uid, loginName * @param boolean $reset * @param boolean $by_username * @return unknown @@ -80,7 +80,7 @@ class Login /** * This function sends the actual password to the user * - * @param unknown_type $user + * @param int $user * @author Olivier Cauberghe , Ghent University */ public static function send_password_to_user($user, $by_username = false) @@ -125,8 +125,7 @@ class Login * * @author Olivier Cauberghe , Ghent University */ - public static function handle_encrypted_password($user, $by_username = false) - { + public static function handle_encrypted_password($user, $by_username = false) { global $_configuration; $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT @@ -382,21 +381,20 @@ class Login Session::write('_real_cid', $_real_cid); // if a session id has been given in url, we store the session - if (api_get_setting('use_session_mode') == 'true') { - // Database Table Definitions - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - - if (!empty($_GET['id_session'])) { - $_SESSION['id_session'] = intval($_GET['id_session']); - $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"'; - $rs = Database::query($sql); - list($_SESSION['session_name']) = Database::fetch_array($rs); - } else { - Session::erase('session_name'); - Session::erase('id_session'); - } + + // Database Table Definitions + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); + $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + + if (!empty($_GET['id_session'])) { + $_SESSION['id_session'] = intval($_GET['id_session']); + $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"'; + $rs = Database::query($sql); + list($_SESSION['session_name']) = Database::fetch_array($rs); + } else { + Session::erase('session_name'); + Session::erase('id_session'); } if (!isset($_SESSION['login_as'])) { @@ -785,5 +783,39 @@ class Login } } } + + /** + * Returns true if user exists in the platform when asking the password + * + * @param string $username (email or username) + * @return boolean + */ + function get_user_accounts_by_username($username) { + if (strpos($username,'@')){ + $username = api_strtolower($username); + $email = true; + } else { + $username = api_strtolower($username); + $email = false; + } + + $condition = ''; + if ($email) { + $condition = "LOWER(email) = '".Database::escape_string($username)."' "; + } else { + $condition = "LOWER(username) = '".Database::escape_string($username)."'"; + } + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); + $query = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email, + status AS status, official_code, phone, picture_uri, creator_id + FROM $tbl_user + WHERE ( $condition AND active = 1) "; + $result = Database::query($query); + $num_rows = Database::num_rows($result); + if ($result && $num_rows > 0) { + return Database::store_result($result); + } + return false; + } } diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index b7107cc07d..d993f27b45 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -4583,144 +4583,115 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { return true; } - if (api_get_setting('use_session_mode') != 'true') { - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $sql = "SELECT tutor_id, status - FROM $course_user_table - WHERE user_id = '$userid' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." - AND course_code = '$cid' - LIMIT 1"; - - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) { - // This user have a recorded state for this course. - $cuData = Database::fetch_array($result); + $sql = "SELECT + tutor_id, status, role + FROM $tbl_course_user + WHERE + user_id = '$userid' + AND + relation_type <> '".COURSE_RELATION_TYPE_RRHH."' + AND + course_code = '$cid' + LIMIT 1"; - $is_courseMember = true; - $is_courseTutor = ($cuData['tutor_id' ] == 1); - $is_courseAdmin = ($cuData['status'] == 1); + $result = Database::query($sql); - } else { - // This user has no status related to this course. - $is_courseMember = false; - $is_courseAdmin = false; - $is_courseTutor = false; - } + if (Database::num_rows($result) > 0) { + // This user has got a recorded state for this course. + $cuData = Database::fetch_array($result); - $is_courseAdmin = ($is_courseAdmin || $is_platformAdmin); - } else { - $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); + $_courseUser['role'] = $cuData['role']; + $is_courseMember = true; + $is_courseTutor = ($cuData['tutor_id' ] == 1); + $is_courseAdmin = ($cuData['status'] == 1); + } + if (!$is_courseAdmin) { + // This user has no status related to this course. + // Is it the session coach or the session admin? + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); + $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sql = "SELECT - tutor_id, status, role - FROM $tbl_course_user - WHERE - user_id = '$userid' - AND - relation_type <> '".COURSE_RELATION_TYPE_RRHH."' - AND - course_code = '$cid' + session.id_coach, session_admin_id, session.id + FROM + $tbl_session as session + INNER JOIN $tbl_session_course + ON session_rel_course.id_session = session.id + AND session_rel_course.course_code = '$cid' LIMIT 1"; $result = Database::query($sql); + $row = Database::store_result($result); - if (Database::num_rows($result) > 0) { - // This user has got a recorded state for this course. - $cuData = Database::fetch_array($result); - - $_courseUser['role'] = $cuData['role']; - $is_courseMember = true; - $is_courseTutor = ($cuData['tutor_id' ] == 1); - $is_courseAdmin = ($cuData['status'] == 1); + if ($row[0]['id_coach'] == $userid) { + $_courseUser['role'] = 'Professor'; + $is_courseMember = true; + $is_courseTutor = true; + $is_courseAdmin = false; + $is_courseCoach = true; + $is_sessionAdmin = false; + Session::write('_courseUser',$_courseUser); } - if (!$is_courseAdmin) { - // This user has no status related to this course. - // Is it the session coach or the session admin? - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - - $sql = "SELECT - session.id_coach, session_admin_id, session.id - FROM - $tbl_session as session - INNER JOIN $tbl_session_course - ON session_rel_course.id_session = session.id - AND session_rel_course.course_code = '$cid' + elseif ($row[0]['session_admin_id'] == $userid) { + $_courseUser['role'] = 'Professor'; + $is_courseMember = false; + $is_courseTutor = false; + $is_courseAdmin = false; + $is_courseCoach = false; + $is_sessionAdmin = true; + } else { + // Check if the current user is the course coach. + $sql = "SELECT 1 + FROM $tbl_session_course + WHERE session_rel_course.course_code = '$cid' + AND session_rel_course.id_coach = '$userid' LIMIT 1"; $result = Database::query($sql); - $row = Database::store_result($result); - if ($row[0]['id_coach'] == $userid) { + //if ($row = Database::fetch_array($result)) { + if (Database::num_rows($result) > 0 ) { $_courseUser['role'] = 'Professor'; $is_courseMember = true; $is_courseTutor = true; - $is_courseAdmin = false; $is_courseCoach = true; $is_sessionAdmin = false; - Session::write('_courseUser',$_courseUser); - } - elseif ($row[0]['session_admin_id'] == $userid) { - $_courseUser['role'] = 'Professor'; - $is_courseMember = false; - $is_courseTutor = false; - $is_courseAdmin = false; - $is_courseCoach = false; - $is_sessionAdmin = true; - } else { - // Check if the current user is the course coach. - $sql = "SELECT 1 - FROM $tbl_session_course - WHERE session_rel_course.course_code = '$cid' - AND session_rel_course.id_coach = '$userid' - LIMIT 1"; - - $result = Database::query($sql); - //if ($row = Database::fetch_array($result)) { - if (Database::num_rows($result) > 0 ) { - $_courseUser['role'] = 'Professor'; - $is_courseMember = true; - $is_courseTutor = true; - $is_courseCoach = true; - $is_sessionAdmin = false; + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); - $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); + $sql = "SELECT status FROM $tbl_user + WHERE user_id = $userid LIMIT 1"; - $sql = "SELECT status FROM $tbl_user - WHERE user_id = $userid LIMIT 1"; - - $result = Database::query($sql); + $result = Database::query($sql); - if (Database::result($result, 0, 0) == 1) { - $is_courseAdmin = true; - } else { - $is_courseAdmin = false; - } + if (Database::result($result, 0, 0) == 1) { + $is_courseAdmin = true; } else { - // Check if the user is a student is this session. - $sql = "SELECT id - FROM $tbl_session_course_user - WHERE id_user = '$userid' - AND course_code = '$cid' - LIMIT 1"; - - if (Database::num_rows($result) > 0) { - // This user haa got a recorded state for this course. - while ($row = Database::fetch_array($result)) { - $is_courseMember = true; - $is_courseTutor = false; - $is_courseAdmin = false; - $is_sessionAdmin = false; - } + $is_courseAdmin = false; + } + } else { + // Check if the user is a student is this session. + $sql = "SELECT id + FROM $tbl_session_course_user + WHERE id_user = '$userid' + AND course_code = '$cid' + LIMIT 1"; + + if (Database::num_rows($result) > 0) { + // This user haa got a recorded state for this course. + while ($row = Database::fetch_array($result)) { + $is_courseMember = true; + $is_courseTutor = false; + $is_courseAdmin = false; + $is_sessionAdmin = false; } } } } - } + } switch ($visibility) { case COURSE_VISIBILITY_OPEN_WORLD: diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index e33fa33f37..4e59abf7ec 100644 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -885,7 +885,8 @@ class MessageManager * @param int group id */ public static function display_messages_for_group($group_id) { - global $my_group_role; + global $my_group_role; + $rows = self::get_messages_by_group($group_id); $topics_per_page = 10; $html_messages = ''; @@ -904,7 +905,7 @@ class MessageManager $new_topics = array(); - foreach($topics as $id => $value) { + foreach ($topics as $id => $value) { $rows = null; $rows = self::get_messages_by_group_by_message($group_id, $value['id']); if (!empty($rows)) { @@ -922,43 +923,59 @@ class MessageManager foreach ($new_topics as $index => $topic) { $html = ''; // topics - $indent = 0; + //$indent = 0; $user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']); - $files_attachments = self::get_links_message_attachment_files($topic['id']); + //$files_attachments = self::get_links_message_attachment_files($topic['id']); $name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']); - $html .= '

    '; + $html .= '
    '; - $items = $topic['count']; - $reply_label = ($items == 1) ? get_lang('GroupReply'): get_lang('GroupReplies'); - $html .= ''; - //$date. - $html .= Display::div($title.Security::remove_XSS(cut($topic['content'], 150), STUDENT, true).$user_info, array('class'=>'group_discussions_info')).'
    '; - $html .= Display::div(Display::tag('span', $items).$reply_label, array('class' =>'group_discussions_replies')); - $html .= ''; - - $topic['title'] = trim($topic['title']); - - if (empty($topic['title'])) { - $topic['title'] = get_lang('Untitled'); - } - $title = Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), 'group_topics.php?id='.$group_id.'&topic_id='.$topic['id'])); - - $date = ''; - $link = ''; - if ($topic['send_date']!=$topic['update_date']) { - if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) { - $date .= '
    '.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'
    '; - } - } else { + $items = $topic['count']; + $reply_label = ($items == 1) ? get_lang('GroupReply'): get_lang('GroupReplies'); + + $html .= '
    '; + $html .= Display::div(Display::tag('span', $items).$reply_label, array('class' =>'group_discussions_replies')); + $html .= '
    '; + + $topic['title'] = trim($topic['title']); + + if (empty($topic['title'])) { + $topic['title'] = get_lang('Untitled'); + } + + $html .= '
    '; + $html .= Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), 'group_topics.php?id='.$group_id.'&topic_id='.$topic['id'])); + + if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) { + $actions = '
    '.Display::url(get_lang('Delete'), api_get_path(WEB_CODE_PATH).'social/group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic['id'], array('class' => 'btn')); + } + + $date = ''; + if ($topic['send_date']!=$topic['update_date']) { + if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) { + $date .= '
    '.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'
    '; + } + } else { $date .= '
    '.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'
    '; - } - $image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true); - $image_repository = $image_path['dir']; - $existing_image = $image_path['file']; - $user_info = '
    '.$name.' '; - $user_info .= '
    '.$name.'
    '; - $user_info .= '
    '.$user.'
    '; + } + $html .= $date.$actions; + $html .= '
    '; + + $image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true); + $image_repository = $image_path['dir']; + $existing_image = $image_path['file']; + + $user_info = ''.$name.' '; + $user_info .= '
    '.$name.'
    '; + $user_info .= ''; + + $html .= '
    '; + $html .= $user_info; + $html .= '
    '; + //group_topics.php?action=delete&id=3&topic_id=6 + //$date. + + //$html .= Display::div($title.Security::remove_XSS(cut($topic['content'], 150), STUDENT, true).$user_info, array('class'=>'group_discussions_info')).' '.$actions.''; $html .= '
    '; //rounded_div diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index fbad867c56..c5a41185ab 100644 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -386,7 +386,7 @@ class SocialManager extends UserManager { */ public static function get_logged_user_course_html($my_course, $count) { global $nosession, $nbDigestEntries, $orderKey, $digest, $thisCourseSysCode; - if (api_get_setting('use_session_mode')=='true' && !$nosession) { + if (!$nosession) { global $now, $date_start, $date_end; } //initialise @@ -477,7 +477,7 @@ class SocialManager extends UserManager { $result .= ''; $result .= '
    '; - if (api_get_setting('use_session_mode')=='true' && !$nosession) { + if (!$nosession) { $session = ''; $active = false; if (!empty($my_course['session_name'])) { diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index e13977f5bf..a129865544 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -12,39 +12,6 @@ require_once api_get_path(LIBRARY_PATH) . 'symfony/Twig/Autoloader.php'; class Template { - public static function get_icon_path($image, $size = ICON_SIZE_SMALL) { - return Display:: return_icon($image, '', array(), $size, $show_text = false, $return_only_path = true); - } - - public static function format_date($timestamp, $format = null) { - return api_format_date($timestamp, $format); - } - - /** - * Return the item's url key: - * - * c_id=xx&id=xx - * - * @param object $item - * @return string - */ - public static function key($item){ - $id = isset($item->id) ? $item->id : null; - $c_id = isset($item->c_id) ? $item->c_id : null; - $result = ''; - if($c_id){ - $result = "c_id=$c_id"; - } - if($id){ - if($result){ - $result .= "&id=$id"; - }else{ - $result .= "&id=$id"; - } - } - return $result; - } - var $style = 'default'; //see the template folder var $preview_theme = null; var $theme; // the chamilo theme public_admin, chamilo, chamilo_red, etc @@ -169,6 +136,39 @@ class Template { } } } + } + + public static function get_icon_path($image, $size = ICON_SIZE_SMALL) { + return Display:: return_icon($image, '', array(), $size, $show_text = false, $return_only_path = true); + } + + public static function format_date($timestamp, $format = null) { + return api_format_date($timestamp, $format); + } + + /** + * Return the item's url key: + * + * c_id=xx&id=xx + * + * @param object $item + * @return string + */ + public static function key($item){ + $id = isset($item->id) ? $item->id : null; + $c_id = isset($item->c_id) ? $item->c_id : null; + $result = ''; + if($c_id){ + $result = "c_id=$c_id"; + } + if($id){ + if($result){ + $result .= "&id=$id"; + }else{ + $result .= "&id=$id"; + } + } + return $result; } function set_help($help_input = null) { diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 6a83f0af36..da97a684f6 100644 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -189,7 +189,7 @@ class IndexManager { if ($show_course_link) { if (!api_is_drh() && !api_is_session_admin()) { - $html .= '
  • '.get_lang('CourseManagement').'
  • '; + $html .= '
  • '.get_lang('CourseCatalog').'
  • '; } else { $html .= '
  • '.get_lang('Dashboard').'
  • '; } @@ -824,15 +824,14 @@ class IndexManager { //Course management if ($show_course_link) { if (!api_is_drh()) { - $my_account_content .= '
  • '.get_lang('CourseManagement').'
  • '; - - if (api_get_setting('use_session_mode') == 'true') { - if (isset($_GET['history']) && intval($_GET['history']) == 1) { - $my_account_content .= '
  • '.get_lang('DisplayTrainingList').'
  • '; - } else { - $my_account_content .= '
  • '.get_lang('HistoryTrainingSessions').'
  • '; - } - } + $my_account_content .= '
  • '.get_lang('CourseCatalog').'
  • '; + + if (isset($_GET['history']) && intval($_GET['history']) == 1) { + $my_account_content .= '
  • '.get_lang('DisplayTrainingList').'
  • '; + } else { + $my_account_content .= '
  • '.get_lang('HistoryTrainingSessions').'
  • '; + } + } else { $my_account_content .= '
  • '.get_lang('Dashboard').'
  • '; } @@ -898,7 +897,7 @@ class IndexManager { // Sessions and courses that are not in a session category. // If we're not in the history view... - if (!isset($_GET['history'])) { // + if (!isset($_GET['history'])) { //Display special courses $html .= CourseManager :: display_special_courses($user_id, $this->load_directories_preview); //Display courses diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index be29b074c8..7eb5af0495 100644 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -227,8 +227,8 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) { $login = $_POST['login']; $password = $_POST['password']; } - - //lookup the user in the main database + + //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 FROM $user_table WHERE username = '".Database::escape_string($login)."'"; @@ -238,38 +238,19 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) { $uData = Database::fetch_array($result); if ($uData['auth_source'] == PLATFORM_AUTH_SOURCE || $uData['auth_source'] == CAS_AUTH_SOURCE) { - //the authentification of this user is managed by Chamilo itself + //The authentification of this user is managed by Chamilo itself $password = api_get_encrypted_password(trim(stripslashes($password))); - - if (api_get_setting('allow_terms_conditions')=='true') { - if ($password == $uData['password'] AND (trim($login) == $uData['username']) OR $cas_login ) { - $temp_user_id = $uData['user_id']; - - $term_and_condition_status = api_check_term_condition($temp_user_id);//false or true - - if ($term_and_condition_status === false) { - $_SESSION['term_and_condition'] = array('user_id' => $temp_user_id, - 'login' => $login, - 'password' => $password, - 'update_term_status' => true, - ); - header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php'); - exit; - } else { - unset($_SESSION['term_and_condition']); - } - } - } - + // Check the user's password - if ( ($password == $uData['password'] OR $cas_login) AND (trim($login) == $uData['username'])) { + if ( ($password == $uData['password'] OR $cas_login) AND (trim($login) == $uData['username'])) { $update_type = UserManager::get_extra_user_data_by_field($uData['user_id'], 'update_type'); $update_type= $update_type['update_type']; if (!empty($extAuthSource[$update_type]['updateUser']) && file_exists($extAuthSource[$update_type]['updateUser'])) { include_once $extAuthSource[$update_type]['updateUser']; } + // Check if the account is active (not locked) - if ($uData['active']=='1') { + 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') { @@ -689,22 +670,22 @@ if (isset($cidReset) && $cidReset) { Session::write('_course', $_course); // if a session id has been given in url, we store the session - if (api_get_setting('use_session_mode') == 'true') { - // Database Table Definitions - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - - if (!empty($_GET['id_session'])) { - $_SESSION['id_session'] = intval($_GET['id_session']); - $sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']) . '"'; - $rs = Database::query($sql); - list($_SESSION['session_name']) = Database::fetch_array($rs); - } else { - Session::erase('session_name'); - Session::erase('id_session'); - } - } + + // Database Table Definitions + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); + $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + + if (!empty($_GET['id_session'])) { + $_SESSION['id_session'] = intval($_GET['id_session']); + $sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']) . '"'; + $rs = Database::query($sql); + list($_SESSION['session_name']) = Database::fetch_array($rs); + } else { + Session::erase('session_name'); + Session::erase('id_session'); + } + if (!isset($_SESSION['login_as'])) { //Course login diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index 0386b224d0..86d8d129dd 100644 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -385,7 +385,7 @@ if (!empty($student_id)) { $session_name = ''; $nb_login = Tracking :: count_login_per_student($user_info['user_id'], $_GET['course']); //get coach and session_name if there is one and if session_mode is activated - if (api_get_setting('use_session_mode') == 'true' && $session_id > 0) { + if ($session_id > 0) { $session_info = api_get_session_info($session_id); $course_coachs = api_get_coachs_from_course($session_id, $course_code); @@ -850,14 +850,14 @@ if (empty($_GET['details'])) { get_lang('Score'), get_lang('Attempts') ); - + $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST); $sql_exercices = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz WHERE quiz.c_id = ".$info_course['real_id']." AND active='1' AND - quiz.session_id = $session_id + (quiz.session_id = $session_id OR quiz.session_id = 0) ORDER BY quiz.title ASC "; - + $result_exercices = Database::query($sql_exercices); $i = 0; if (Database :: num_rows($result_exercices) > 0) { @@ -892,18 +892,19 @@ if (empty($_GET['details'])) { echo ''; $sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' - WHERE exe_exo_id="'.$exercise_id.'" AND - exe_user_id="'.$student_id.'" AND - exe_cours_id="'.$course_code.'" AND - status = "" AND - orig_lp_id = 0 AND + WHERE exe_exo_id ="'.$exercise_id.'" AND + exe_user_id ="'.$student_id.'" AND + exe_cours_id ="'.$course_code.'" AND + session_id ="'.$session_id.'" AND + status = "" AND + orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY exe_date DESC LIMIT 1'; $result_last_attempt = Database::query($sql_last_attempt); if (Database :: num_rows($result_last_attempt) > 0) { $id_last_attempt = Database :: result($result_last_attempt, 0, 0); if ($count_attempts > 0) - echo ' '; + echo ' '; } echo ''; @@ -977,8 +978,7 @@ if (empty($_GET['details'])) { $links = Tracking::count_student_visited_links($student_id, $course_code, $session_id); $chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id); $documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id); - $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id); - + $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id); $csv_content[] = array ( get_lang('Student_publication'), @@ -1038,8 +1038,7 @@ if (empty($_GET['details'])) { - '.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_SMALL).''; + '.Display::return_icon('pdf.png', get_lang('ExportToPDFOnlyHTMLAndImages'),'',ICON_SIZE_SMALL).''; //} /* DELETE COMMAND */ diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index 3a8d214b02..d087614585 100644 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -372,7 +372,7 @@ if (Database::num_rows($res_media) > 0) { -
    +
    get_html_toc(); ?> @@ -380,7 +380,7 @@ if (Database::num_rows($res_media) > 0) {
    -
    .
    +
    @@ -414,7 +414,12 @@ if (Database::num_rows($res_media) > 0) { var hauteurHeader = document.getElementById('header').offsetHeight; var hauteurAuthorImg = document.getElementById('author_image').offsetHeight; var hauteurAuthorName = document.getElementById('author_name').offsetHeight; - var hauteurMedia = document.getElementById('lp_media_file').offsetHeight; + + var hauteurMedia = 0; + if ($("#lp_media_file").length != 0) { + hauteurMedia = document.getElementById('lp_media_file').offsetHeight; + } + var hauteurTitre = document.getElementById('scorm_title').offsetHeight; var hauteurAction = 0; if (document.getElementById('actions_lp')) hauteurAction = document.getElementById('actions_lp').offsetHeight; diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index a3b8e6da18..bc9b54e04b 100644 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -1495,7 +1495,9 @@ function switch_item(current_item, next_item){ url: "lp_nav.php", data: "", success: function(tmp_data) { - $("#lp_media_file").html(tmp_data); + if ($("#lp_media_file").length != 0) { + $("#lp_media_file").html(tmp_data); + } } }); return true; diff --git a/main/social/group_members.php b/main/social/group_members.php index 2f011fdcbc..4c13b82dca 100644 --- a/main/social/group_members.php +++ b/main/social/group_members.php @@ -57,7 +57,7 @@ if (isset($_GET['action']) && $_GET['action']=='delete') { //if i'm a moderator if (GroupPortalManager::is_group_moderator($group_id)) { GroupPortalManager::delete_user_rel_group($user_join, $group_id); - $show_message = get_lang('UserDeleted'); + $show_message = Display::return_message(get_lang('UserDeleted')); } } @@ -67,7 +67,7 @@ if (isset($_GET['action']) && $_GET['action']=='set_moderator') { //if i'm the admin if (GroupPortalManager::is_group_admin($group_id)) { GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR); - $show_message = get_lang('UserChangeToModerator'); + $show_message = Display::return_message(get_lang('UserChangeToModerator')); } } @@ -77,12 +77,10 @@ if (isset($_GET['action']) && $_GET['action']=='delete_moderator') { //only group admins can do that if (GroupPortalManager::is_group_admin($group_id)) { GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_READER); - $show_message = get_lang('UserChangeToReader'); + $show_message = Display::return_message(get_lang('UserChangeToReader')); } } - - $users = GroupPortalManager::get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000); $new_member_list = array(); @@ -92,10 +90,6 @@ $social_right_content = '

    '.$group_info['name'].'

    '; $social_right_content .= '
    '; -if (! empty($show_message)){ - $social_right_content .= Display :: return_message($show_message,'confirmation', false); -} - foreach($users as $user) { switch ($user['relation_type']) { case GROUP_USER_PERMISSION_ADMIN: diff --git a/main/social/group_topics.php b/main/social/group_topics.php index 6f29634780..bb8ca56d8c 100644 --- a/main/social/group_topics.php +++ b/main/social/group_topics.php @@ -37,10 +37,12 @@ if (empty($group_id)) { } if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { - if (api_is_platform_admin()) { + $group_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id); + + if (api_is_platform_admin() || in_array($group_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) { GroupPortalManager::delete_topic($group_id, $topic_id); header("Location: groups.php?id=$group_id&action=show_message&msg=topic_deleted"); - } + } } // save message group diff --git a/main/social/message_for_group_form.inc.php b/main/social/message_for_group_form.inc.php index ad39c694b2..cc96e3088f 100644 --- a/main/social/message_for_group_form.inc.php +++ b/main/social/message_for_group_form.inc.php @@ -16,8 +16,8 @@ if (api_get_setting('allow_social_tool') !='true') { api_not_allowed(); } -require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php'; +require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php'; $tok = Security::get_token(); @@ -112,7 +112,7 @@ $page_topic = !empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1
    - () + ()

    diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl index 60c4e320a4..203dbfd481 100644 --- a/main/template/default/layout/footer.tpl +++ b/main/template/default/layout/footer.tpl @@ -74,7 +74,7 @@ $(document).ready( function() { }); var tip_options = { - placement : 'right', + placement : 'right' } $('.boot-tooltip').tooltip(tip_options); diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index f9ee799fb2..dda13f6064 100644 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -219,7 +219,7 @@ $(function() { modal : true, width : width_value, height : height_value, - resizable : resizable_value, + resizable : resizable_value }); }); //prevent the browser to follow the link diff --git a/main/template/default/layout/hot_courses.tpl b/main/template/default/layout/hot_courses.tpl index ab70aaf51b..04106f3208 100644 --- a/main/template/default/layout/hot_courses.tpl +++ b/main/template/default/layout/hot_courses.tpl @@ -27,33 +27,36 @@ $(document).ready( function() {
    {{"HottestCourses"|display_page_header}}
    - {% for hot_course in hot_courses %} -
    -
    -
    -
    -
    - - {# html_image file=$hot_course.extra_info.course_image #} + {% for hot_course in hot_courses %} + + {% if hot_course.extra_info.title %} +
    +
    +
    +
    +
    + + {# html_image file=$hot_course.extra_info.course_image #} +
    -
    -
    -
    -

    {{ hot_course.extra_info.name }}

    -
    {{ hot_course.extra_info.teachers }}
    - - {{ hot_course.extra_info.rating_html }} +
    +
    +

    {{ hot_course.extra_info.title}}

    +
    {{ hot_course.extra_info.teachers }}
    + + {{ hot_course.extra_info.rating_html }} +
    +

    + {{ hot_course.extra_info.go_to_course_button }} + {{ hot_course.extra_info.description_button }} +

    -

    - {{ hot_course.extra_info.go_to_course_button }} - {{ hot_course.extra_info.description_button }} -

    -
    - {% endfor %} + {% endif %} + {% endfor %}
    {% endif %} diff --git a/main/template/default/layout/topbar.tpl b/main/template/default/layout/topbar.tpl index 744f9efd1f..628365ffd6 100644 --- a/main/template/default/layout/topbar.tpl +++ b/main/template/default/layout/topbar.tpl @@ -11,85 +11,82 @@ {{"siteName"|get_setting }} {% if _u.logged %} + -
    + + +
    + {% endif %} +
    -
    +
    {% endif %} \ No newline at end of file diff --git a/main/tracking/userLog.php b/main/tracking/userLog.php index 92044e9e46..1ff95d143a 100644 --- a/main/tracking/userLog.php +++ b/main/tracking/userLog.php @@ -78,20 +78,18 @@ $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_U $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER); -if (api_get_setting('use_session_mode') == "true") { - $sql = "SELECT 1 - FROM $tbl_session_course_user AS session_course_user - INNER JOIN $tbl_session AS session - ON session_course_user.id_session = session.id - AND ((date_start<=NOW() - AND date_end>=NOW()) - OR (date_start='0000-00-00' AND date_end='0000-00-00')) - WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'"; - //echo $sql; - $result=Database::query($sql); - if(!Database::num_rows($result)){ - $disabled = true; - } +$sql = "SELECT 1 + FROM $tbl_session_course_user AS session_course_user + INNER JOIN $tbl_session AS session + ON session_course_user.id_session = session.id + AND ((date_start<=NOW() + AND date_end>=NOW()) + OR (date_start='0000-00-00' AND date_end='0000-00-00')) + WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'"; +//echo $sql; +$result=Database::query($sql); +if(!Database::num_rows($result)){ + $disabled = true; } $tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN); @@ -133,15 +131,11 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) { echo "

    ".get_lang('ListStudents')."

    "; if( $is_allowedToTrackEverybodyInCourse ) { // if user can track everybody : list user of course - if(api_get_setting('use_session_mode')) { - $sql = "SELECT count(user_id) - FROM $TABLECOURSUSER - WHERE course_code = '".Database::escape_string($_cid)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH.""; - } else { - $sql = "SELECT count(id_user) - FROM $tbl_session_course_user - WHERE course_code = '".Database::escape_string($_cid)."'"; - } + + $sql = "SELECT count(user_id) + FROM $TABLECOURSUSER + WHERE course_code = '".Database::escape_string($_cid)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH.""; + } else { // if user can only track one group : list users of this group $sql = "SELECT count(user) diff --git a/main/tracking/userlogCSV.php b/main/tracking/userlogCSV.php old mode 100755 new mode 100644 index 82ba809849..ee2b6d9c23 --- a/main/tracking/userlogCSV.php +++ b/main/tracking/userlogCSV.php @@ -68,23 +68,21 @@ $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER); - -if(api_get_setting('use_session_mode') == "true") { - $sql = "SELECT 1 - FROM $tbl_session_course_user AS session_course_user - INNER JOIN $tbl_session AS session - ON session_course_user.id_session = session.id - AND ((date_start<=NOW() - AND date_end>=NOW()) - OR (date_start='0000-00-00' AND date_end='0000-00-00')) - WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'"; - //echo $sql; - $result=Database::query($sql); - if(!Database::num_rows($result)){ - $disabled = true; - } +$sql = "SELECT 1 + FROM $tbl_session_course_user AS session_course_user + INNER JOIN $tbl_session AS session + ON session_course_user.id_session = session.id + AND ((date_start<=NOW() + AND date_end>=NOW()) + OR (date_start='0000-00-00' AND date_end='0000-00-00')) + WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'"; +//echo $sql; +$result=Database::query($sql); +if(!Database::num_rows($result)){ + $disabled = true; } + $tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN); $tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW); @@ -122,17 +120,11 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) if( $is_allowedToTrackEverybodyInCourse ) { - // if user can track everybody : list user of course - if(api_get_setting('use_session_mode')) { - $sql = "SELECT count(user_id) - FROM $TABLECOURSUSER - WHERE course_code = '$_cid' AND relation_type<>".COURSE_RELATION_TYPE_RRHH.""; - } - else { - $sql = "SELECT count(id_user) - FROM $tbl_session_course_user - WHERE course_code = '$_cid'"; - } + // if user can track everybody : list user of course + $sql = "SELECT count(user_id) + FROM $TABLECOURSUSER + WHERE course_code = '$_cid' AND relation_type<>".COURSE_RELATION_TYPE_RRHH.""; + } else { diff --git a/main/user/class.php b/main/user/class.php index b0647a7775..6d1d433cae 100644 --- a/main/user/class.php +++ b/main/user/class.php @@ -15,9 +15,7 @@ $this_section = SECTION_COURSES; */ api_protect_course_script(); -if (api_get_setting('use_session_mode')=='true') { - api_not_allowed(); -} +api_not_allowed(); $tool_name = get_lang("Classes"); //extra entries in breadcrumb diff --git a/main/user/subscribe_class.php b/main/user/subscribe_class.php index 3d8e948c14..dd17cc328f 100644 --- a/main/user/subscribe_class.php +++ b/main/user/subscribe_class.php @@ -12,9 +12,9 @@ $language_file = array('registration','admin'); include ('../inc/global.inc.php'); $this_section = SECTION_COURSES; if (!api_is_allowed_to_edit()) api_not_allowed(true); -if(api_get_setting('use_session_mode')=='true') { - api_not_allowed(true); -} + +api_not_allowed(true); + /* MAIN CODE diff --git a/main/user/subscribe_user.php b/main/user/subscribe_user.php index 077c70218c..949d0905f7 100644 --- a/main/user/subscribe_user.php +++ b/main/user/subscribe_user.php @@ -201,8 +201,11 @@ if (api_is_western_name_order()) { $table->set_header($col ++, get_lang('LastName')); $table->set_header($col ++, get_lang('FirstName')); } -$table->set_header($col ++, get_lang('Email')); -$table->set_column_filter($col -1, 'email_filter'); + +if (api_get_setting('show_email_addresses') == 'true') { + $table->set_header($col ++, get_lang('Email')); + $table->set_column_filter($col -1, 'email_filter'); +} $table->set_header($col ++, get_lang('Active'),false); $table->set_column_filter($col -1, 'active_filter'); $table->set_header($col ++, get_lang('Actions'), false); @@ -248,7 +251,7 @@ function get_number_of_users() { $url_access_id = api_get_current_access_url_id(); if ($url_access_id !=-1) { $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $sql = "SELECT COUNT(u.user_id) FROM $user_table u + $sql = "SELECT COUNT(u.user_id) FROM $user_table u LEFT JOIN $tbl_session_rel_course_user cu on u.user_id = cu.id_user and course_code='".api_get_course_id()."' AND id_session ='".api_get_session_id()."' INNER JOIN $tbl_url_rel_user as url_rel_user ON (url_rel_user.user_id = u.user_id) @@ -293,7 +296,7 @@ function get_number_of_users() { } } } else { - $sql = "SELECT COUNT(u.user_id) + $sql = "SELECT COUNT(u.user_id) FROM $user_table u LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."'"; @@ -383,23 +386,39 @@ function get_user_data($from, $number_of_items, $column, $direction) { $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $table_user_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES); - - // adding teachers + + // adding teachers $is_western_name_order = api_is_western_name_order(); + + if (api_get_setting('show_email_addresses') == 'true') { + + $select_fields = "u.user_id AS col0, + u.official_code AS col1, + ".($is_western_name_order + ? "u.firstname AS col2, + u.lastname AS col3," + : "u.lastname AS col2, + u.firstname AS col3,")." + u.email AS col4, + u.active AS col5, + u.user_id AS col6"; + } else { + $select_fields = "u.user_id AS col0, + u.official_code AS col1, + ".($is_western_name_order + ? "u.firstname AS col2, + u.lastname AS col3," + : "u.lastname AS col2, + u.firstname AS col3,")." + u.active AS col4, + u.user_id AS col5"; + } + + if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') { // adding a teacher through a session if (!empty($_SESSION["id_session"])) { - $sql = "SELECT - u.user_id AS col0, - u.official_code AS col1, - ".($is_western_name_order - ? "u.firstname AS col2, - u.lastname AS col3," - : "u.lastname AS col2, - u.firstname AS col3,")." - u.email AS col4, - u.active AS col5, - u.user_id AS col6 + $sql = "SELECT $select_fields FROM $user_table u LEFT JOIN $tbl_session_rel_course_user cu on u.user_id = cu.id_user AND course_code='".$_SESSION['_course']['id']."' AND id_session ='".$_SESSION["id_session"]."' "; @@ -417,17 +436,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { } } else { // adding a teacher NOT through a session - $sql = "SELECT - u.user_id AS col0, - u.official_code AS col1, - ".($is_western_name_order - ? "u.firstname AS col2, - u.lastname AS col3," - : "u.lastname AS col2, - u.firstname AS col3,")." - u.email AS col4, - u.active AS col5, - u.user_id AS col6 + $sql = "SELECT $select_fields FROM $user_table u LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."'"; @@ -449,17 +458,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id !=-1) { $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $sql = "SELECT - u.user_id AS col0, - u.official_code AS col1, - ".($is_western_name_order - ? "u.firstname AS col2, - u.lastname AS col3," - : "u.lastname AS col2, - u.firstname AS col3,")." - u.email AS col4, - u.active AS col5, - u.user_id AS col6 + $sql = "SELECT $select_fields FROM $user_table u LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."' INNER JOIN $tbl_url_rel_user as url_rel_user ON (url_rel_user.user_id = u.user_id) "; @@ -482,17 +481,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { } else { // adding a student if (!empty($_SESSION["id_session"])) { - $sql = "SELECT - u.user_id AS col0, - u.official_code AS col1, - ".($is_western_name_order - ? "u.firstname AS col2, - u.lastname AS col3," - : "u.lastname AS col2, - u.firstname AS col3,")." - u.email AS col4, - u.active AS col5, - u.user_id AS col6 + $sql = "SELECT $select_fields FROM $user_table u LEFT JOIN $tbl_session_rel_course_user cu on u.user_id = cu.id_user and course_code='".$_SESSION['_course']['id']."' AND id_session ='".$_SESSION["id_session"]."' "; @@ -510,17 +499,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { } } else { - $sql = "SELECT - u.user_id AS col0, - u.official_code AS col1, - ".($is_western_name_order - ? "u.firstname AS col2, - u.lastname AS col3," - : "u.lastname AS col2, - u.firstname AS col3,")." - u.email AS col4, - u.active AS col5, - u.user_id AS col6 + $sql = "SELECT $select_fields FROM $user_table u LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."'"; @@ -544,17 +523,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { if ($url_access_id !=-1) { $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $sql = "SELECT - u.user_id AS col0, - u.official_code AS col1, - ".($is_western_name_order - ? "u.firstname AS col2, - u.lastname AS col3," - : "u.lastname AS col2, - u.firstname AS col3,")." - u.email AS col4, - u.active AS col5, - u.user_id AS col6 + $sql = "SELECT $select_fields FROM $user_table u LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and course_code='".$_SESSION['_course']['id']."' INNER JOIN $tbl_url_rel_user as url_rel_user @@ -608,7 +577,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { $res = Database::query($sql); $users = array (); - while ($user = Database::fetch_row($res)) { + while ($user = Database::fetch_row($res)) { $users[] = $user; $_SESSION['session_user_id'][] = $user[0]; if ($is_western_name_order) { diff --git a/main/user/user.php b/main/user/user.php index b976eecc7f..fee3efde14 100644 --- a/main/user/user.php +++ b/main/user/user.php @@ -89,11 +89,21 @@ if (api_is_allowed_to_edit(null, true)) { $extra_fields = UserManager::get_extra_user_data(api_get_user_id(), false, false, false, true); $extra_fields = array_keys($extra_fields); - if ($sort_by_first_name) { - $a_users[0] = array('id', get_lang('FirstName'), get_lang('LastName'), get_lang('Email'), get_lang('Phone'), get_lang('OfficialCode'), get_lang('Active')); - } else { - $a_users[0] = array('id', get_lang('LastName'), get_lang('FirstName'), get_lang('Email'), get_lang('Phone'), get_lang('OfficialCode'), get_lang('Active')); - } + $select_email_condition = ''; + if (api_get_setting('show_email_addresses') == 'true') { + $select_email_condition = ' user.email, '; + if ($sort_by_first_name) { + $a_users[0] = array('id', get_lang('FirstName'), get_lang('LastName'), get_lang('Email'), get_lang('Phone'), get_lang('OfficialCode'), get_lang('Active')); + } else { + $a_users[0] = array('id', get_lang('LastName'), get_lang('FirstName'), get_lang('Email'), get_lang('Phone'), get_lang('OfficialCode'), get_lang('Active')); + } + } else { + if ($sort_by_first_name) { + $a_users[0] = array('id', get_lang('FirstName'), get_lang('LastName'), get_lang('Phone'), get_lang('OfficialCode'), get_lang('Active')); + } else { + $a_users[0] = array('id', get_lang('LastName'), get_lang('FirstName'), get_lang('Phone'), get_lang('OfficialCode'), get_lang('Active')); + } + } $legal = ''; @@ -113,64 +123,64 @@ if (api_is_allowed_to_edit(null, true)) { $a_users[0] = array_merge($a_users[0], $extra_fields); // users subscribed to the course through a session - if (api_get_setting('use_session_mode') == 'true') { - if (api_get_session_id()) { - $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", user.email, phone, user.official_code, active $legal - FROM $table_session_course_user as session_course_user, $table_users as user "; - if ($_configuration['multiple_access_urls']) { - $sql_query .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; - } - $sql_query .=" WHERE course_code = '$course_code' AND session_course_user.id_user = user.user_id "; - $sql_query .= ' AND id_session = '.$session_id; - - if ($_configuration['multiple_access_urls']) { - $sql_query .= " AND user.user_id = au.user_id AND access_url_id = $current_access_url_id "; - } - - //only users no coaches/teachers - $sql_query .= " AND session_course_user.status = 0 "; - - $sql_query .= $sort_by_first_name ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; - - $rs = Database::query($sql_query); - $counter = 1; - - while ($user = Database:: fetch_array($rs, 'ASSOC')) { - if (isset($user['legal_agreement'])) { - if ($user['legal_agreement'] == 1) { - $user['legal_agreement'] = get_lang('Yes'); - } else { - $user['legal_agreement'] = get_lang('No'); - } + + if (api_get_session_id()) { + $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", $select_email_condition phone, user.official_code, active $legal + FROM $table_session_course_user as session_course_user, $table_users as user "; + if ($_configuration['multiple_access_urls']) { + $sql_query .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; + } + $sql_query .=" WHERE course_code = '$course_code' AND session_course_user.id_user = user.user_id "; + $sql_query .= ' AND id_session = '.$session_id; + + if ($_configuration['multiple_access_urls']) { + $sql_query .= " AND user.user_id = au.user_id AND access_url_id = $current_access_url_id "; + } + + //only users no coaches/teachers + $sql_query .= " AND session_course_user.status = 0 "; + + $sql_query .= $sort_by_first_name ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; + + $rs = Database::query($sql_query); + $counter = 1; + + while ($user = Database:: fetch_array($rs, 'ASSOC')) { + if (isset($user['legal_agreement'])) { + if ($user['legal_agreement'] == 1) { + $user['legal_agreement'] = get_lang('Yes'); + } else { + $user['legal_agreement'] = get_lang('No'); + } + } + $extra_fields = UserManager::get_extra_user_data($user['user_id'], false, false, false, true); + if (!empty($extra_fields)) { + foreach($extra_fields as $key => $extra_value) { + $user[$key] = $extra_value; } - $extra_fields = UserManager::get_extra_user_data($user['user_id'], false, false, false, true); - if (!empty($extra_fields)) { - foreach($extra_fields as $key => $extra_value) { - $user[$key] = $extra_value; - } - } - $data[] = $user; - if ($_GET['type'] == 'pdf') { - if ($is_western_name_order) { - $user_pdf = array($counter, $user['official_code'], $user['firstname'].', '.$user['lastname'] ); - } else { - $user_pdf = array($counter, $user['official_code'], $user['lastname'].', '.$user['firstname'] ); - } - $a_users[] = $user_pdf; - } else { - $a_users[] = $user; + } + $data[] = $user; + if ($_GET['type'] == 'pdf') { + if ($is_western_name_order) { + $user_pdf = array($counter, $user['official_code'], $user['firstname'].', '.$user['lastname'] ); + } else { + $user_pdf = array($counter, $user['official_code'], $user['lastname'].', '.$user['firstname'] ); } - $counter++; - } - } - } + $a_users[] = $user_pdf; + } else { + $a_users[] = $user; + } + $counter++; + } + } + if ($session_id == 0) { // users directly subscribed to the course $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", user.email, phone, user.official_code, active $legal + $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", $select_email_condition phone, user.official_code, active $legal FROM $table_course_user as course_user, $table_users as user "; if ($_configuration['multiple_access_urls']) { $sql_query .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; @@ -344,10 +354,6 @@ if ( api_is_allowed_to_edit(null, true)) { $actions .= ''.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).' '; $actions .= "".Display::return_icon('group.png', get_lang("GroupUserManagement"),'',ICON_SIZE_MEDIUM).""; - if (api_get_setting('use_session_mode') == 'false') { - $actions .= ' '.get_lang('Classes').''; - } - // Build search-form $form = new FormValidator('search_user', 'get', '', '', null, false); $renderer = & $form->defaultRenderer(); diff --git a/main/user/userInfo.php b/main/user/userInfo.php index c6f84ecfd4..1868f94c6d 100644 --- a/main/user/userInfo.php +++ b/main/user/userInfo.php @@ -402,8 +402,10 @@ elseif ($displayMode == "viewContentEdit") { echo "\n", "", "", "\n"; - - echo "

    ".Display :: encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."

    "; + + if (api_get_setting('show_email_addresses') == 'true') { + echo "

    ".Display :: encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."

    "; + } if (api_get_setting('extended_profile') == 'true') { if (!empty($mainUserInfo['competences'])) @@ -522,10 +524,6 @@ elseif ($displayMode == "viewContentEdit") { if (api_get_setting("show_email_addresses") == "true") { echo "

    ". Display::encrypted_mailto_link($mainUserInfo['email'],$mainUserInfo['email']). "

    "; - } else { - if (api_is_allowed_to_edit()) { - echo "

    ". Display::encrypted_mailto_link($mainUserInfo['email'],$mainUserInfo['email']). "

    "; - } } if (api_get_setting('extended_profile') == 'true') {