Minor - partial merge with 1.11.x

pull/2487/merge
Julio Montoya 7 years ago
parent 7a2cc656fa
commit b3cfb3d2d8
  1. 4
      main/admin/languages.php
  2. 6
      main/admin/user_list_consent.php
  3. 26
      main/auth/courses_categories.php
  4. 1
      main/calendar/agenda_list.php
  5. 1
      main/course_info/infocours.php
  6. 2
      main/cron/lang/check_parse_lang.php
  7. 14
      main/cron/lang/langstats.class.php
  8. 12
      main/cron/lang/list_undefined_langvars.php
  9. 59
      main/cron/lang/list_unused_langvars.php
  10. 25
      main/cron/lang/switch_files_to_gettext.php
  11. 1
      main/exercise/Hpdownload.php
  12. 3
      main/exercise/exercise_submit.php
  13. 1
      main/gradebook/gradebook_display_summary.php
  14. 17
      main/gradebook/lib/be/category.class.php
  15. 1
      main/gradebook/lib/gradebook_data_generator.class.php
  16. 8
      main/inc/email_editor.php
  17. 1
      main/inc/lib/add_course.lib.inc.php
  18. 80
      main/inc/lib/api.lib.php
  19. 34
      main/inc/lib/course.lib.php
  20. 2
      main/inc/lib/database.lib.php
  21. 1
      main/inc/lib/display.lib.php
  22. 73
      main/inc/lib/formvalidator/FormValidator.class.php
  23. 15
      main/inc/lib/internationalization.lib.php
  24. 6
      main/inc/lib/usermanager.lib.php
  25. 77
      main/inc/lib/userportal.lib.php
  26. 12
      main/inc/lib/webservices/Rest.php
  27. 9
      main/install/index.php
  28. 2
      main/lp/learnpath.class.php
  29. 69
      main/lp/lp_view.php

@ -66,7 +66,7 @@ $htmlHeadXtra[] = '<script>
if(confirm("'.get_lang('ConfirmYourChoice').'")) { if(confirm("'.get_lang('ConfirmYourChoice').'")) {
$.ajax({ $.ajax({
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) { beforeSend: function(myObject) {
$("#id_content_message").html("<div class=\"warning-message alert alert-warning\"><em class=\"fa fa-refresh fa-spin\"></em> '.get_lang('Loading').'</div>"); $("#id_content_message").html("<div class=\"warning-message alert alert-warning\"><em class=\"fa fa-refresh fa-spin\"></em> '.get_lang('Loading').'</div>");
}, },
type: "GET", type: "GET",
@ -108,7 +108,7 @@ $htmlHeadXtra[] = '<script>
$.ajax({ $.ajax({
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) { beforeSend: function(myObject) {
$("#id_content_message").html("<div class=\"warning-message alert alert-warning\"><em class=\"fa fa-refresh fa-spin\"></em> '.get_lang('Loading').'</div>"); $("#id_content_message").html("<div class=\"warning-message alert alert-warning\"><em class=\"fa fa-refresh fa-spin\"></em> '.get_lang('Loading').'</div>");
}, },
type: "POST", type: "POST",

@ -645,7 +645,11 @@ $toolbarActions = Display::toolbarAction(
[4, 4, 4] [4, 4, 4]
); );
$notice = Display::return_message(get_lang('InformationRightToBeForgottenText'), 'normal', false); $noticeMessage = sprintf(
get_lang('InformationRightToBeForgottenLinkX'),
'<a href="https://gdpr-info.eu/art-17-gdpr/">https://gdpr-info.eu/art-17-gdpr/</a>'
);
$notice = Display::return_message($noticeMessage, 'normal', false);
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$tpl->assign('actions', $toolbarActions); $tpl->assign('actions', $toolbarActions);

@ -308,8 +308,8 @@ function returnThumbnail($course, $registeredUser)
{ {
$html = ''; $html = '';
$title = cut($course['title'], 70); $title = cut($course['title'], 70);
$linkCourse = api_get_course_url($course['code']); //$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
// course path // course path
$course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; $course_path = api_get_path(SYS_COURSE_PATH).$course['directory'];
@ -329,15 +329,9 @@ function returnThumbnail($course, $registeredUser)
} }
$html .= '<div class="image">'; $html .= '<div class="image">';
if (!$registeredUser) { $html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
$html .= '<img class="img-responsive"' .'<img class="img-responsive" src="'.$courseMediumImage.'" '
.' src="'.$courseMediumImage.'" ' .'alt="'.api_htmlentities($title).'"/></a>';
.' alt="'.api_htmlentities($title).'"/>';
} else {
$html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
.'<img class="img-responsive" src="'.$courseMediumImage.'" '
.'alt="'.api_htmlentities($title).'"/></a>';
}
$categoryTitle = isset($course['category_title']) ? $course['category_title'] : ''; $categoryTitle = isset($course['category_title']) ? $course['category_title'] : '';
if (!empty($categoryTitle)) { if (!empty($categoryTitle)) {
@ -421,14 +415,10 @@ function return_teacher($courseInfo)
*/ */
function return_title($course, $registeredUser) function return_title($course, $registeredUser)
{ {
$linkCourse = api_get_course_url($course['code']); //$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
$html = '<div class="block-title"><h4 class="title">'; $html = '<div class="block-title"><h4 class="title">';
if (!$registeredUser) { $html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
$html .= $course['title'];
} else {
$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
}
$html .= '</h4></div>'; $html .= '</h4></div>';
if (api_get_configuration_value('hide_course_rating') === false) { if (api_get_configuration_value('hide_course_rating') === false) {

@ -29,7 +29,6 @@ if (!empty($groupId)) {
]; ];
} }
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
$agenda = new Agenda($type); $agenda = new Agenda($type);
$events = $agenda->getEvents( $events = $agenda->getEvents(
null, null,

@ -95,7 +95,6 @@ if (file_exists($course_path.'/course-pic85x85.png')) {
<div class="col-md-8"><img src="'.$course_medium_image.'" /></div></div>'; <div class="col-md-8"><img src="'.$course_medium_image.'" /></div></div>';
} }
$form->addHtml($image); $form->addHtml($image);
$form->addText('title', get_lang('Title'), true); $form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');

@ -27,7 +27,7 @@ foreach ($langs as $lang) {
$out = []; $out = [];
if (is_file($file)) { if (is_file($file)) {
//$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true)); //$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true));
@exec('php5 -l '.$file, $out); @exec('php -l '.$file, $out);
if (substr($out[0], 0, 2) != 'No') { if (substr($out[0], 0, 2) != 'No') {
echo $out[0]."\n"; echo $out[0]."\n";
$ok = false; $ok = false;

@ -14,12 +14,12 @@
* goal of this DB is to get stats on the usage of language vars for a common * goal of this DB is to get stats on the usage of language vars for a common
* user. This class requires the SQLite extension of PHP to be installed. The * user. This class requires the SQLite extension of PHP to be installed. The
* check for the availability of sqlite_open() should be made before calling * check for the availability of sqlite_open() should be made before calling
* the constructor (preferrably). * the constructor (preferably).
*/ */
class langstats class langstats
{ {
public $db; //database connector public $db; //database connector
public $error; //errores almacenados public $error; //stored errors
public $db_type = 'sqlite'; public $db_type = 'sqlite';
public function __construct($file = '') public function __construct($file = '')
@ -97,7 +97,7 @@ class langstats
* @param string The language term used * @param string The language term used
* @param string The file from which the language term came from * @param string The file from which the language term came from
* *
* @return bool true * @return mixed
*/ */
public function add_use($term, $term_file = '') public function add_use($term, $term_file = '')
{ {
@ -114,6 +114,7 @@ class langstats
while ($row = $ress->fetchArray(SQLITE3_BOTH)) { while ($row = $ress->fetchArray(SQLITE3_BOTH)) {
$num = $row[3]; $num = $row[3];
$num++; $num++;
$i++;
$res = $this->db->query( $res = $this->db->query(
'UPDATE lang_freq SET term_count = '.$num.' WHERE id = '.$row[0] 'UPDATE lang_freq SET term_count = '.$num.' WHERE id = '.$row[0]
); );
@ -124,7 +125,6 @@ class langstats
} else { } else {
return $row[0]; return $row[0];
} }
$i++;
} }
if ($i == 0) { if ($i == 0) {
//No term found in the table, register as new term //No term found in the table, register as new term
@ -139,6 +139,8 @@ class langstats
return $this->db->lastInsertRowID(); return $this->db->lastInsertRowID();
} }
} }
return true;
} }
/** /**
@ -164,13 +166,13 @@ class langstats
/** /**
* Clear all records in lang_freq. * Clear all records in lang_freq.
* *
* @return bool true * @return resource true
*/ */
public function clear_all() public function clear_all()
{ {
$res = sqlite_query($this->db, 'DELETE FROM lang_freq WHERE 1=1'); $res = sqlite_query($this->db, 'DELETE FROM lang_freq WHERE 1=1');
return $list; return $res;
} }
/** /**

@ -25,12 +25,17 @@ foreach ($list as $entry) {
// get only the array keys (the language variables defined in language files) // get only the array keys (the language variables defined in language files)
$defined_terms = array_flip(array_keys($terms)); $defined_terms = array_flip(array_keys($terms));
$terms = null; $terms = null;
$hidePlugins = !empty($_GET['hidePlugins']);
// now get all terms found in all PHP files of Chamilo (this takes some time and memory) // now get all terms found in all PHP files of Chamilo (this takes some time and memory)
$undefined_terms = []; $undefined_terms = [];
$l = strlen(api_get_path(SYS_PATH)); $l = strlen(api_get_path(SYS_PATH));
$files = getAllPhpFiles(api_get_path(SYS_PATH)); $files = getAllPhpFiles(api_get_path(SYS_PATH));
foreach ($files as $file) { foreach ($files as $file) {
$isPlugin = preg_match('#/plugin/#', $file);
if ($isPlugin && $hidePlugins) {
continue;
}
//echo 'Analyzing '.$file."<br />"; //echo 'Analyzing '.$file."<br />";
$shortfile = substr($file, $l); $shortfile = substr($file, $l);
$lines = file($file); $lines = file($file);
@ -64,11 +69,14 @@ if (count($undefined_terms) < 1) {
} else { } else {
echo "The following terms were nowhere to be found: <br />\n<table>"; echo "The following terms were nowhere to be found: <br />\n<table>";
} }
$i = 1;
foreach ($undefined_terms as $term => $file) { foreach ($undefined_terms as $term => $file) {
echo "<tr><td>$term</td><td>in $file"; $isPlugin = substr($file, 0, 7) == 'plugin/';
if (substr($file, 0, 7) == 'plugin/') { echo "<tr><td>$i</td><td>$term</td><td>in $file";
if ($isPlugin) {
echo " <span style=\"color: #00ff00;\">(this one should be taken care of by the plugin's language files)</span>"; echo " <span style=\"color: #00ff00;\">(this one should be taken care of by the plugin's language files)</span>";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
$i++;
} }
echo "</table>\n"; echo "</table>\n";

@ -32,26 +32,39 @@ echo count($defined_terms)." terms were found in language files<br />";
$usedTerms = []; $usedTerms = [];
$l = strlen(api_get_path(SYS_PATH)); $l = strlen(api_get_path(SYS_PATH));
$files = getAllPhpFiles(api_get_path(SYS_PATH)); $files = getAllPhpFiles(api_get_path(SYS_PATH));
$files[] = api_get_path(SYS_PATH).'main/install/data.sql';
// Browse files // Browse files
foreach ($files as $file) { foreach ($files as $file) {
//echo 'Analyzing '.$file."<br />"; //echo 'Analyzing '.$file."<br />";
$shortFile = substr($file, $l); $shortFile = substr($file, $l);
//echo 'Analyzing '.$shortFile."<br />"; //echo 'Analyzing '.$shortFile."<br />";
$lines = file($file); $lines = file($file);
$isDataSQL = false;
if (substr($file, -21) === 'main/install/data.sql') {
$isDataSQL = true;
}
// Browse lines inside file $file // Browse lines inside file $file
foreach ($lines as $line) { foreach ($lines as $line) {
$myTerms = []; if ($isDataSQL) {
$res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms); // Check main/install/data.sql
if ($res > 0) { // Should recognize stuff like
foreach ($myTerms[1] as $term) { // INSERT INTO settings_current (variable, type, category, selected_value, title, comment) VALUES ('enable_profile_user_address_geolocalization', 'radio', 'User', 'false', 'EnableProfileUsersAddressGeolocalizationTitle', 'EnableProfileUsersAddressGeolocalizationComment');
if (substr($term, 0, 4) == 'lang') { // INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_profile_user_address_geolocalization', 'true', 'Yes');
$term = substr($term, 4); // ('show_teacher_data',NULL,'radio','Platform','true','ShowTeacherDataTitle','ShowTeacherDataComment',NULL,NULL, 1),
$res = 0;
$myTerms = [];
$res = preg_match_all('/\'(\w*)\',/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4);
}
$usedTerms[$term] = $shortFile;
} }
$usedTerms[$term] = $shortFile;
} }
} else { } else {
$res = 0; $myTerms = [];
$res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/', $line, $myTerms); $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms);
if ($res > 0) { if ($res > 0) {
foreach ($myTerms[1] as $term) { foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4) == 'lang') { if (substr($term, 0, 4) == 'lang') {
@ -59,6 +72,34 @@ foreach ($files as $file) {
} }
$usedTerms[$term] = $shortFile; $usedTerms[$term] = $shortFile;
} }
} else {
$res = 0;
$myTerms = [];
// Should catch:
// {{ 'CopyTextToClipboard' | get_lang }}
// {{ "HelloX" | get_lang | format(show_user_info.user_info.complete_name) }}
// {{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
$res = preg_match_all('/\{\s*[\'"](\w*)[\'"]\s*\|\s*get_lang\s*(\|\s*\w*(\s*\([\w_\.,\s]*\))?\s*)?\}/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4);
}
$usedTerms[$term] = $shortFile;
}
}
// {{ display.panel('PersonalDataResponsibleOrganizationTitle' | get_lang , personal_data.responsible ) }}
// {{ display.panel('PersonalDataIntroductionTitle' | get_lang , 'PersonalDataIntroductionText' | get_lang) }}
$myTerms = [];
$res = preg_match_all('/\{\s*[\w\.]*\([\'"](\w*)[\'"]\s*\|\s*get_lang\s*(,\s*[\w_\.,\s\|\'"]*\s*)?\)\s*\}/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4);
}
$usedTerms[$term] = $shortFile;
}
}
} }
} }
} }

@ -1,4 +1,5 @@
<?php /* For licensing terms, see /license.txt */ <?php
/* For licensing terms, see /license.txt */
/** /**
* Script to switch all PHP files in Chamilo to a more Gettext-like syntax. * Script to switch all PHP files in Chamilo to a more Gettext-like syntax.
* *
@ -56,14 +57,11 @@ foreach ($files as $file) {
if (substr($term, 0, 4) == 'lang') { if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4); $term = substr($term, 4);
} }
// Replace all variables by their English translation, if (!empty($terms[$term])) {
// except those translations larger than 120 characters $translation = $terms[$term];
// as these would be impractical
if (!empty($terms[$term]) and strlen($terms[$term]) <= 120) {
$translation = str_replace("'", "\\'", $terms[$term]);
$quotedTerm = $myTerms[1][0]; $quotedTerm = $myTerms[1][0];
echo "Doing sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n"; //echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
system("sed -i \"s#$quotedTerm#'$translation'#g\" $file"); system("sed -i \"s#$term#'$translation'#g\" $file");
$countReplaces++; $countReplaces++;
} }
} }
@ -76,14 +74,11 @@ foreach ($files as $file) {
if (substr($term, 0, 4) == 'lang') { if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4); $term = substr($term, 4);
} }
// Replace all variables by their English translation, if (!empty($terms[$term])) {
// except those translations larger than 120 characters $translation = $terms[$term];
// as these would be impractical
if (!empty($terms[$term]) and strlen($terms[$term]) <= 120) {
$translation = str_replace("'", "\\'", $terms[$term]);
$quotedTerm = $myTerms[1][0]; $quotedTerm = $myTerms[1][0];
echo "Doing sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n"; //echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
system("sed -i \"s#$quotedTerm#'$translation'#g\" $file"); system("sed -i \"s#$term#'$translation'#g\" $file");
$countReplaces++; $countReplaces++;
} }
} }

@ -107,7 +107,6 @@ if ($content_type == 'text/html') {
$content = $file_content; $content = $file_content;
$mit = "function Finish(){"; $mit = "function Finish(){";
$js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
"function mySaveScore() // This function included by Dokeos System\n". "function mySaveScore() // This function included by Dokeos System\n".
"{\n". "{\n".

@ -1265,7 +1265,8 @@ if (!empty($error)) {
url = url_extra; url = url_extra;
} }
$("#save_for_now_"+question_id).html(\''.Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\'); $("#save_for_now_"+question_id).html(\''.
Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
window.location = url; window.location = url;
} }

@ -14,7 +14,6 @@ $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script(); api_protect_course_script();
api_set_more_memory_and_time_limits(); api_set_more_memory_and_time_limits();
api_block_anonymous_users(); api_block_anonymous_users();
GradebookUtils::block_students(); GradebookUtils::block_students();
$cat_id = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : null; $cat_id = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : null;

@ -1220,12 +1220,12 @@ class Category implements GradebookItem
) { ) {
$main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_grade_categories = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$course_code = Database::escape_string($course_code); $course_code = Database::escape_string($course_code);
$session_id = (int) $session_id; $session_id = (int) $session_id;
$sql = "SELECT * FROM $tbl_grade_categories WHERE parent_id = 0"; $sql = "SELECT * FROM $table WHERE parent_id = 0";
if (!api_is_allowed_to_edit()) { if (!api_is_allowed_to_edit()) {
$sql .= ' AND visible = 1'; $sql .= ' AND visible = 1';
@ -1262,7 +1262,7 @@ class Category implements GradebookItem
if (!empty($session_id)) { if (!empty($session_id)) {
$sql .= " AND session_id = ".$session_id; $sql .= " AND session_id = ".$session_id;
} else { } else {
$sql .= "AND session_id IS NULL OR session_id=0"; $sql .= 'AND session_id IS NULL OR session_id = 0';
} }
} else { } else {
$sql .= ' AND course_code IN $sql .= ' AND course_code IN
@ -1287,7 +1287,7 @@ class Category implements GradebookItem
// course independent categories // course independent categories
if (empty($course_code)) { if (empty($course_code)) {
$cats = self::getIndependentCategoriesWithStudentResult( $cats = $this->getIndependentCategoriesWithStudentResult(
0, 0,
$stud_id, $stud_id,
$cats $cats
@ -1462,7 +1462,7 @@ class Category implements GradebookItem
$cat->get_name(), $cat->get_name(),
$level + 1, $level + 1,
]; ];
$targets = self::add_subtree( $targets = $this->add_subtree(
$targets, $targets,
$level + 1, $level + 1,
$cat->get_id(), $cat->get_id(),
@ -1471,14 +1471,14 @@ class Category implements GradebookItem
} }
} else { } else {
// student // student
$cats = self::get_root_categories_for_student(api_get_user_id()); $cats = $this->get_root_categories_for_student(api_get_user_id());
foreach ($cats as $cat) { foreach ($cats as $cat) {
$targets[] = [ $targets[] = [
$cat->get_id(), $cat->get_id(),
$cat->get_name(), $cat->get_name(),
$level + 1, $level + 1,
]; ];
$targets = self::add_subtree( $targets = $this->add_subtree(
$targets, $targets,
$level + 1, $level + 1,
$cat->get_id(), $cat->get_id(),
@ -1616,6 +1616,7 @@ class Category implements GradebookItem
$this->id, $this->id,
api_is_allowed_to_edit() ? null : 1 api_is_allowed_to_edit() ? null : 1
); );
/** @var Category $cat */ /** @var Category $cat */
foreach ($cats as $cat) { foreach ($cats as $cat) {
if ($cat->hasEvaluationsWithStudentResults($studentId)) { if ($cat->hasEvaluationsWithStudentResults($studentId)) {
@ -1694,7 +1695,7 @@ class Category implements GradebookItem
if (isset($studentId)) { if (isset($studentId)) {
// Special case: this is the root // Special case: this is the root
if ($this->id == 0) { if ($this->id == 0) {
return self::get_root_categories_for_student($studentId, $course_code, $session_id); return $this->get_root_categories_for_student($studentId, $course_code, $session_id);
} else { } else {
return self::load( return self::load(
null, null,

@ -127,7 +127,6 @@ class GradebookDataGenerator
$row[] = $item->get_weight(); $row[] = $item->get_weight();
$item->setStudentList($studentList); $item->setStudentList($studentList);
//if (count($this->evals_links) > 0) {
if (get_class($item) == 'Evaluation') { if (get_class($item) == 'Evaluation') {
// Items inside a category. // Items inside a category.
$resultColumn = $this->build_result_column( $resultColumn = $this->build_result_column(

@ -66,7 +66,7 @@ $defaults = [
$form->setDefaults($defaults); $form->setDefaults($defaults);
if ($form->validate()) { if ($form->validate()) {
$text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromLMS')." ".api_get_path(WEB_PATH); $text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromLMS').' '.api_get_path(WEB_PATH);
$email_administrator = Security::remove_XSS($_POST['dest']); $email_administrator = Security::remove_XSS($_POST['dest']);
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$title = Security::remove_XSS($_POST['email_title']); $title = Security::remove_XSS($_POST['email_title']);
@ -80,12 +80,6 @@ if ($form->validate()) {
api_get_person_name($_user['firstname'], $_user['lastname']), api_get_person_name($_user['firstname'], $_user['lastname']),
$_user['mail'] $_user['mail']
); );
UserManager::send_message_in_outbox(
$email_administrator,
$user_id,
$title,
$content
);
} else { } else {
api_mail_html( api_mail_html(
'', '',

@ -712,6 +712,7 @@ class AddCourse
); );
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
$files = [ $files = [
['path' => '/shared_folder', 'title' => get_lang('UserFolders'), 'filetype' => 'folder', 'size' => 0], ['path' => '/shared_folder', 'title' => get_lang('UserFolders'), 'filetype' => 'folder', 'size' => 0],
['path' => '/chat_files', 'title' => get_lang('ChatFiles'), 'filetype' => 'folder', 'size' => 0], ['path' => '/chat_files', 'title' => get_lang('ChatFiles'), 'filetype' => 'folder', 'size' => 0],

@ -5401,11 +5401,16 @@ function copyr($source, $dest, $exclude = [], $copied_files = [])
return true; return true;
} }
// TODO: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach. Documentation header to be added here.
/** /**
* @todo: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach.
* Documentation header to be added here.
*
* @param string $pathname * @param string $pathname
* @param string $base_path_document * @param string $base_path_document
* @param int $session_id * @param int $session_id
*
* @return mixed True if directory already exists, false if a file already exists at
* the destination and null if everything goes according to plan
*/ */
function copy_folder_course_session( function copy_folder_course_session(
$pathname, $pathname,
@ -6366,7 +6371,16 @@ function api_is_element_in_the_session($tool, $element_id, $session_id = null)
*/ */
function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true) function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true)
{ {
return URLify::filter( // Some non-properly encoded file names can cause the whole file to be
// skipped when uploaded. Avoid this by detecting the encoding and
// converting to UTF-8, setting the source as ASCII (a reasonably
// limited characters set) if nothing could be found (BT#
$encoding = api_detect_encoding($filename);
if (empty($encoding)) {
$encoding = 'ASCII';
}
$filename = api_to_system_encoding($filename, $encoding);
$url = URLify::filter(
$filename, $filename,
250, 250,
'', '',
@ -6376,6 +6390,8 @@ function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true)
false, false,
$treat_spaces_as_hyphens $treat_spaces_as_hyphens
); );
return $url;
} }
/** /**
@ -6790,7 +6806,7 @@ function api_get_tool_information_by_name($name)
*/ */
function api_is_global_platform_admin($user_id = null) function api_is_global_platform_admin($user_id = null)
{ {
$user_id = intval($user_id); $user_id = (int) $user_id;
if (empty($user_id)) { if (empty($user_id)) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
@ -7343,41 +7359,55 @@ function api_get_jquery_libraries_js($libraries)
} }
/** /**
* Returns the course's URL. * Returns the URL to the course or session, removing the complexity of the URL
* building piece by piece.
* *
* This function relies on api_get_course_info() * This function relies on api_get_course_info()
* *
* @param string The course code - optional (takes it from session if not given) * @param string $courseCode The course code - optional (takes it from context if not given)
* @param int The session id - optional (takes it from session if not given) * @param int $sessionId The session ID - optional (takes it from context if not given)
* @param int $session_id * @param int $groupId The group ID - optional (takes it from context if not given)
* *
* @return string|null The URL of the course or null if something does not work * @return string The URL to a course, a session, or empty string if nothing works e.g. https://localhost/courses/ABC/index.php?session_id=3&gidReq=1
* *
* @author Julio Montoya <gugli100@gmail.com> * @author Julio Montoya <gugli100@gmail.com>
*/ */
function api_get_course_url($course_code = null, $session_id = null) function api_get_course_url($courseCode = null, $sessionId = null, $groupId = null)
{ {
if (empty($course_code)) { $courseDirectory = '';
$course_info = api_get_course_info(); $url = '';
// If courseCode not set, get context or []
if (empty($courseCode)) {
$courseInfo = api_get_course_info();
} else { } else {
$course_info = api_get_course_info($course_code); $courseInfo = api_get_course_info($courseCode);
} }
if (empty($session_id)) {
$session_url = '?id_session='.api_get_session_id(); // If course defined, get directory, otherwise keep empty string
} else { if (!empty($courseInfo['directory'])) {
$session_url = '?id_session='.intval($session_id); $courseDirectory = $courseInfo['directory'];
} }
/*
if (empty($group_id)) { // If sessionId not set, get context or 0
$group_url = '&gidReq='.api_get_group_id(); if (empty($sessionId)) {
} else { $sessionId = api_get_session_id();
$group_url = '&gidReq='.intval($group_id);
}*/
if (!empty($course_info['path'])) {
return api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php'.$session_url;
} }
return null; // If groupId not set, get context or 0
if (empty($groupId)) {
$groupId = api_get_group_id();
}
// Build the URL
if (!empty($courseDirectory)) {
// directory not empty, so we do have a course
$url = api_get_path(WEB_COURSE_PATH).$courseDirectory.'/index.php?id_session='.$sessionId.'&gidReq='.$groupId;
} elseif (!empty($sessionId) && api_get_configuration_value('remove_session_url') !== true) {
// if the course was unset and the session was set, send directly to the session
$url = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$sessionId;
}
// if not valid combination was found, return an empty string
return $url;
} }
/** /**

@ -189,15 +189,16 @@ class CourseManager
/** /**
* Returns a list of courses. Should work with quickform syntax. * Returns a list of courses. Should work with quickform syntax.
* *
* @param int $from Offset (from the 7th = '6'). Optional. * @param int $from Offset (from the 7th = '6'). Optional.
* @param int $howmany Number of results we want. Optional. * @param int $howmany Number of results we want. Optional.
* @param int $orderby The column we want to order it by. Optional, defaults to first column. * @param int $orderby The column we want to order it by. Optional, defaults to first column.
* @param string $orderdirection The direction of the order (ASC or DESC). Optional, defaults to ASC. * @param string $orderdirection The direction of the order (ASC or DESC). Optional, defaults to ASC.
* @param int $visibility the visibility of the course, or all by default * @param int $visibility the visibility of the course, or all by default
* @param string $startwith If defined, only return results for which the course *title* begins with this string * @param string $startwith If defined, only return results for which the course *title* begins with this string
* @param string $urlId The Access URL ID, if using multiple URLs * @param string $urlId The Access URL ID, if using multiple URLs
* @param bool $alsoSearchCode An extension option to indicate that we also want to search for course codes (not *only* titles) * @param bool $alsoSearchCode An extension option to indicate that we also want to search for course codes (not *only* titles)
* @param array $conditionsLike * @param array $conditionsLike
* @param array $onlyThisCourseList
* *
* @return array * @return array
*/ */
@ -210,7 +211,8 @@ class CourseManager
$startwith = '', $startwith = '',
$urlId = null, $urlId = null,
$alsoSearchCode = false, $alsoSearchCode = false,
$conditionsLike = [] $conditionsLike = [],
$onlyThisCourseList = []
) { ) {
$sql = "SELECT course.* FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course "; $sql = "SELECT course.* FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course ";
@ -219,27 +221,35 @@ class CourseManager
$sql .= " INNER JOIN $table url ON (url.c_id = course.id) "; $sql .= " INNER JOIN $table url ON (url.c_id = course.id) ";
} }
$visibility = (int) $visibility;
if (!empty($startwith)) { if (!empty($startwith)) {
$sql .= "WHERE (title LIKE '".Database::escape_string($startwith)."%' "; $sql .= "WHERE (title LIKE '".Database::escape_string($startwith)."%' ";
if ($alsoSearchCode) { if ($alsoSearchCode) {
$sql .= "OR code LIKE '".Database::escape_string($startwith)."%' "; $sql .= "OR code LIKE '".Database::escape_string($startwith)."%' ";
} }
$sql .= ') '; $sql .= ') ';
if ($visibility !== -1 && $visibility == strval(intval($visibility))) { if ($visibility !== -1) {
$sql .= " AND visibility = $visibility "; $sql .= " AND visibility = $visibility ";
} }
} else { } else {
$sql .= "WHERE 1 "; $sql .= "WHERE 1 ";
if ($visibility !== -1 && $visibility == strval(intval($visibility))) { if ($visibility !== -1) {
$sql .= " AND visibility = $visibility "; $sql .= " AND visibility = $visibility ";
} }
} }
if (!empty($urlId)) { if (!empty($urlId)) {
$urlId = intval($urlId); $urlId = (int) $urlId;
$sql .= " AND access_url_id = $urlId"; $sql .= " AND access_url_id = $urlId";
} }
if (!empty($onlyThisCourseList)) {
$onlyThisCourseList = array_map('intval', $onlyThisCourseList);
$onlyThisCourseList = implode("','", $onlyThisCourseList);
$sql .= " AND course.id IN ('$onlyThisCourseList') ";
}
$allowedFields = [ $allowedFields = [
'title', 'title',
'code', 'code',

@ -304,6 +304,8 @@ class Database
return $result[$row][$field]; return $result[$row][$field];
} }
return false;
} }
/** /**

@ -1422,6 +1422,7 @@ class Display
$json_encode = str_replace('"wrap_cell":true', 'cellattr : function(rowId, value, rowObject, colModel, arrData) { return \'class = "jqgrid_whitespace"\'; }', $json_encode); $json_encode = str_replace('"wrap_cell":true', 'cellattr : function(rowId, value, rowObject, colModel, arrData) { return \'class = "jqgrid_whitespace"\'; }', $json_encode);
$json_encode = str_replace(':"false"', ':false', $json_encode); $json_encode = str_replace(':"false"', ':false', $json_encode);
$json_encode = str_replace('"formatter":"action_formatter"', 'formatter:action_formatter', $json_encode); $json_encode = str_replace('"formatter":"action_formatter"', 'formatter:action_formatter', $json_encode);
$json_encode = str_replace('"formatter":"extra_formatter"', 'formatter:extra_formatter', $json_encode);
$json_encode = str_replace(['{"first":"first",', '"end":"end"}'], '', $json_encode); $json_encode = str_replace(['{"first":"first",', '"end":"end"}'], '', $json_encode);
// Creating the jqgrid element. // Creating the jqgrid element.

@ -185,9 +185,14 @@ EOT;
* *
* @return HTML_QuickForm_text * @return HTML_QuickForm_text
*/ */
public function addText($name, $label, $required = true, $attributes = []) public function addText($name, $label, $required = true, $attributes = [], $createElement = false)
{ {
$element = $this->addElement('text', $name, $label, $attributes); if ($createElement) {
$element = $this->createElement('text', $name, $label, $attributes);
} else {
$element = $this->addElement('text', $name, $label, $attributes);
}
$this->applyFilter($name, 'trim'); $this->applyFilter($name, 'trim');
if ($required) { if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
@ -291,12 +296,19 @@ EOT;
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $attributes * @param array $attributes
* @param bool $required
* *
* @return HTML_QuickForm_textarea * @return HTML_QuickForm_textarea
*/ */
public function addTextarea($name, $label, $attributes = []) public function addTextarea($name, $label, $attributes = [], $required = false)
{ {
return $this->addElement('textarea', $name, $label, $attributes); $element = $this->addElement('textarea', $name, $label, $attributes);
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
return $element;
} }
/** /**
@ -860,11 +872,20 @@ EOT;
/** /**
* @param string $label * @param string $label
* @param string $text * @param string $text
* @param bool $createElement
* *
* @return HTML_QuickForm_label * @return HTML_QuickForm_Element
*/ */
public function addLabel($label, $text) public function addLabel($label, $text, $createElement = false)
{ {
if ($createElement) {
return $this->createElement(
'label',
$label,
$text
);
}
return $this->addElement('label', $label, $text); return $this->addElement('label', $label, $text);
} }
@ -917,6 +938,46 @@ EOT;
$this->addElement('html', $snippet); $this->addElement('html', $snippet);
} }
/**
* Draws a panel of options see the course_info/infocours.php page.
*
* @param string $name internal name
* @param string $title visible title
* @param array $groupList list of group or elements
*/
public function addPanelOption($name, $title, $groupList)
{
$this->addHtml('<div class="panel panel-default">');
$this->addHtml(
'
<div class="panel-heading" role="tab" id="heading-'.$name.'-settings">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
href="#collapse-'.$name.'-settings" aria-expanded="false" aria-controls="collapse-'.$name.'-settings">
'
);
$this->addHtml($title);
$this->addHtml('</a></h4></div>');
$this->addHtml('<div id="collapse-'.$name.'-settings" class="panel-collapse collapse" role="tabpanel"
aria-labelledby="heading-'.$name.'-settings">
<div class="panel-body">
');
foreach ($groupList as $groupName => $group) {
// Add group array
if (!empty($groupName) && is_array($group)) {
$this->addGroup($group, '', $groupName);
}
// Add element
if ($group instanceof HTML_QuickForm_element) {
$this->addElement($group);
}
}
$this->addHtml('</div></div>');
$this->addHtml('</div>');
}
/** /**
* Adds a HTML-editor to the form. * Adds a HTML-editor to the form.
* *

@ -351,8 +351,9 @@ function api_get_timezone()
* @param bool $returnNullIfInvalidDate if the date is not correct return null instead of the current date * @param bool $returnNullIfInvalidDate if the date is not correct return null instead of the current date
* @param bool $returnObj * @param bool $returnObj
* *
* @return string The DATETIME in UTC to be inserted in the DB, * @return string|DateTime The DATETIME in UTC to be inserted in the DB,
* or null if the format of the argument is not supported * or null if the format of the argument is not supported
* or datetime
* *
* @author Julio Montoya - Adding the 2nd parameter * @author Julio Montoya - Adding the 2nd parameter
* @author Guillaume Viguier <guillaume.viguier@beeznest.com> * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
@ -367,7 +368,7 @@ function api_get_utc_datetime(
return null; return null;
} }
if ($returnObj) { if ($returnObj) {
return $date = new DateTime(gmdate('Y-m-d H:i:s'), new DateTimeZone('UTC')); return new DateTime(gmdate('Y-m-d H:i:s'), new DateTimeZone('UTC'));
} }
return gmdate('Y-m-d H:i:s'); return gmdate('Y-m-d H:i:s');
@ -431,7 +432,7 @@ function api_get_local_time(
} }
if (is_numeric($time)) { if (is_numeric($time)) {
$time = intval($time); $time = (int) $time;
if ($return_null_if_invalid_date) { if ($return_null_if_invalid_date) {
if (strtotime(date('d-m-Y H:i:s', $time)) !== (int) $time) { if (strtotime(date('d-m-Y H:i:s', $time)) !== (int) $time) {
return null; return null;
@ -1016,9 +1017,9 @@ function api_utf8_decode($string, $to_encoding = null)
} }
/** /**
* Converts a given string into the system ecoding (or platform character set). * Converts a given string into the system encoding (or platform character set).
* When $from encoding is omited on UTF-8 platforms then language dependent encoding * When $from encoding is omitted on UTF-8 platforms then language dependent encoding
* is guessed/assumed. On non-UTF-8 platforms omited $from encoding is assumed as UTF-8. * is guessed/assumed. On non-UTF-8 platforms omitted $from encoding is assumed as UTF-8.
* When the parameter $check_utf8_validity is true the function checks string's * When the parameter $check_utf8_validity is true the function checks string's
* UTF-8 validity and decides whether to try to convert it or not. * UTF-8 validity and decides whether to try to convert it or not.
* This function is useful for problem detection or making workarounds. * This function is useful for problem detection or making workarounds.

@ -2966,7 +2966,7 @@ class UserManager
$position $position
FROM ChamiloCoreBundle:Session AS s FROM ChamiloCoreBundle:Session AS s
LEFT JOIN ChamiloCoreBundle:SessionRelCourseRelUser AS scu WITH scu.session = s LEFT JOIN ChamiloCoreBundle:SessionRelCourseRelUser AS scu WITH scu.session = s
INNER JOIN ChamiloCoreBundle:AccessUrlRelSession AS url WITH url.sessionId = s.id INNER JOIN ChamiloCoreBundle:AccessUrlRelSession AS url WITH url.session = s.id
LEFT JOIN ChamiloCoreBundle:SessionCategory AS sc WITH s.category = sc "; LEFT JOIN ChamiloCoreBundle:SessionCategory AS sc WITH s.category = sc ";
// A single OR operation on scu.user = :user OR s.generalCoach = :user // A single OR operation on scu.user = :user OR s.generalCoach = :user
@ -2974,8 +2974,8 @@ class UserManager
// sessions, BT#14115) but executing a similar query twice and grouping // sessions, BT#14115) but executing a similar query twice and grouping
// the results afterwards in PHP takes about 1/1000th of the time // the results afterwards in PHP takes about 1/1000th of the time
// (0.1s + 0.0s) for the same set of data, so we do it this way... // (0.1s + 0.0s) for the same set of data, so we do it this way...
$dqlStudent = $dql." WHERE scu.user = :user AND url.accessUrlId = :url "; $dqlStudent = $dql." WHERE scu.user = :user AND url.url = :url ";
$dqlCoach = $dql." WHERE s.generalCoach = :user AND url.accessUrlId = :url "; $dqlCoach = $dql." WHERE s.generalCoach = :user AND url.url = :url ";
// Default order // Default order
$order = 'ORDER BY sc.name, s.name'; $order = 'ORDER BY sc.name, s.name';

@ -188,83 +188,6 @@ class IndexManager
return false; return false;
} }
/**
* @return null|string
*/
public function return_teacher_link()
{
$html = '';
$show_menu = false;
if (!empty($this->user_id)) {
// tabs that are deactivated are added here
$show_menu = false;
$show_create_link = false;
$show_course_link = false;
if (api_is_allowed_to_create_course()) {
$show_menu = true;
$show_course_link = true;
$show_create_link = true;
} else {
if (api_get_setting('allow_students_to_browse_courses') === 'true') {
$show_menu = true;
$show_course_link = true;
}
if (api_is_allowed_to_create_course()) {
$show_create_link = true;
}
}
if ($show_menu && ($show_create_link || $show_course_link)) {
$show_menu = true;
} else {
$show_menu = false;
}
}
// My Account section
if ($show_menu) {
$html .= '<ul class="nav nav-pills nav-stacked">';
if ($show_create_link) {
$html .= '<li class="add-course"><a href="'.api_get_path(WEB_CODE_PATH).'create_course/add_course.php">'
.Display::return_icon('new-course.png', get_lang('CourseCreate'))
.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang(
'CourseCreate'
))
.'</a></li>';
}
if ($show_course_link) {
if (!api_is_drh() && !api_is_session_admin()) {
$html .= '<li class="list-course"><a href="'.api_get_path(WEB_CODE_PATH).'auth/courses.php">'
.Display::return_icon('catalog-course.png', get_lang('CourseCatalog'))
.get_lang('CourseCatalog')
.'</a></li>';
} else {
$html .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'dashboard/index.php">'.get_lang(
'Dashboard'
).'</a></li>';
}
}
$html .= '</ul>';
}
if (!empty($html)) {
$html = self::show_right_block(
get_lang('Courses'),
$html,
'teacher_block',
null,
'teachers',
'teachersCollapse'
);
}
return $html;
}
/** /**
* Includes a created page. * Includes a created page.
* *

@ -792,13 +792,13 @@ class Rest extends WebService
'title' => Security::remove_XSS($lpDetails['lp_name']), 'title' => Security::remove_XSS($lpDetails['lp_name']),
'progress' => intval($progress), 'progress' => intval($progress),
'url' => api_get_path(WEB_CODE_PATH).'webservices/api/v2.php?'.http_build_query([ 'url' => api_get_path(WEB_CODE_PATH).'webservices/api/v2.php?'.http_build_query([
'hash' => $this->encodeParams([ 'hash' => $this->encodeParams([
'action' => 'course_learnpath', 'action' => 'course_learnpath',
'lp_id' => $lpId, 'lp_id' => $lpId,
'course' => $this->course->getId(), 'course' => $this->course->getId(),
'session' => $sessionId, 'session' => $sessionId,
]),
]), ]),
]),
]; ];
} }

@ -25,10 +25,13 @@ use Symfony\Component\Translation\Translator;
* *
* @package chamilo.install * @package chamilo.install
*/ */
$originalDisplayErrors = ini_get('display_errors');
$originalMemoryLimit = ini_get('memory_limit');
ini_set('display_errors', '1'); ini_set('display_errors', '1');
ini_set('log_errors', '1'); ini_set('log_errors', '1');
//ini_set('memory_limit', -1); ini_set('memory_limit', -1);
//ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
error_reporting(-1); error_reporting(-1);
require_once __DIR__.'/../../vendor/autoload.php'; require_once __DIR__.'/../../vendor/autoload.php';
@ -39,10 +42,12 @@ define('FORM_FIELD_DISPLAY_LENGTH', 40);
define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25); define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25);
define('MAX_FORM_FIELD_LENGTH', 80); define('MAX_FORM_FIELD_LENGTH', 80);
require_once '../inc/lib/api.lib.php'; require_once '../inc/lib/api.lib.php';
require_once '../inc/lib/text.lib.php'; require_once '../inc/lib/text.lib.php';
api_check_php_version('../inc/'); api_check_php_version('../inc/');
ob_implicit_flush(true);
// Defaults settings // Defaults settings
putenv("APP_LOCALE=en"); putenv("APP_LOCALE=en");

@ -4080,7 +4080,7 @@ class learnpath
Database::query($sql_upd2); Database::query($sql_upd2);
} }
// Update next item (new previous item). // Update next item (new previous item).
if ($next != 0) { if (!empty($next)) {
$sql_upd2 = "UPDATE $tbl_lp_item SET previous_item_id = $previous $sql_upd2 = "UPDATE $tbl_lp_item SET previous_item_id = $previous
WHERE iid = $next"; WHERE iid = $next";
if ($this->debug > 2) { if ($this->debug > 2) {

@ -121,45 +121,54 @@ $htmlHeadXtra[] = '<script>
var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\'; var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\';
--> -->
</script>'; </script>';
//$htmlHeadXtra[] = api_get_css_asset('qtip2/jquery.qtip.min.css');
//$htmlHeadXtra[] = api_get_asset('qtip2/jquery.qtip.min.js');
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>'; $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
$(document).ready(function() { $(document).ready(function() {
$("div#log_content_cleaner").bind("click", function() { $("div#log_content_cleaner").bind("click", function() {
$("div#log_content").empty(); $("div#log_content").empty();
}); });
$(".scorm_item_normal").qtip({
content: {
text: function(event, api) {
var item = $(this);
var itemId = $(this).attr("id");
itemId = itemId.replace("toc_", "");
var textToShow = "";
$.ajax({
type: "GET",
url: "'.$ajaxUrl.'&item_id="+ itemId,
async: false
})
.then(function(content) {
if (content == 1) {
textToShow = "'.addslashes(get_lang('LPItemCanBeAccessed')).'";
api.set("style.classes", "qtip-green qtip-shadow");
} else {
textToShow = content;
api.set("style.classes", "qtip-red qtip-shadow");
}
return textToShow;
});
return textToShow;
}
}
});
}); });
var chamilo_xajax_handler = window.oxajax; var chamilo_xajax_handler = window.oxajax;
</script>'; </script>';
$allowLpItemTip = api_get_configuration_value('hide_accessibility_label_on_lp_item') === false;
if ($allowLpItemTip) {
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
$(".scorm_item_normal").qtip({
content: {
text: function(event, api) {
var item = $(this);
var itemId = $(this).attr("id");
itemId = itemId.replace("toc_", "");
var textToShow = "";
$.ajax({
type: "GET",
url: "'.$ajaxUrl.'&item_id="+ itemId,
async: false
})
.then(function(content) {
if (content == 1) {
textToShow = "'.addslashes(get_lang('LPItemCanBeAccessed')).'";
api.set("style.classes", "qtip-green qtip-shadow");
} else {
textToShow = content;
api.set("style.classes", "qtip-red qtip-shadow");
}
return textToShow;
});
return textToShow;
}
}
});
});
</script>';
}
// Impress js // Impress js
if ($lp->mode == 'impress') { if ($lp->mode == 'impress') {
$lp_id = $lp->get_id(); $lp_id = $lp->get_id();

Loading…
Cancel
Save