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').'")) {
$.ajax({
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>");
},
type: "GET",
@ -108,7 +108,7 @@ $htmlHeadXtra[] = '<script>
$.ajax({
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>");
},
type: "POST",

@ -645,7 +645,11 @@ $toolbarActions = Display::toolbarAction(
[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->assign('actions', $toolbarActions);

@ -308,8 +308,8 @@ function returnThumbnail($course, $registeredUser)
{
$html = '';
$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 = api_get_path(SYS_COURSE_PATH).$course['directory'];
@ -329,15 +329,9 @@ function returnThumbnail($course, $registeredUser)
}
$html .= '<div class="image">';
if (!$registeredUser) {
$html .= '<img class="img-responsive"'
.' src="'.$courseMediumImage.'" '
.' alt="'.api_htmlentities($title).'"/>';
} else {
$html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
.'<img class="img-responsive" src="'.$courseMediumImage.'" '
.'alt="'.api_htmlentities($title).'"/></a>';
}
$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'] : '';
if (!empty($categoryTitle)) {
@ -421,14 +415,10 @@ function return_teacher($courseInfo)
*/
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">';
if (!$registeredUser) {
$html .= $course['title'];
} else {
$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
}
$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
$html .= '</h4></div>';
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);
$events = $agenda->getEvents(
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>';
}
$form->addHtml($image);
$form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');

@ -27,7 +27,7 @@ foreach ($langs as $lang) {
$out = [];
if (is_file($file)) {
//$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') {
echo $out[0]."\n";
$ok = false;

@ -14,12 +14,12 @@
* 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
* check for the availability of sqlite_open() should be made before calling
* the constructor (preferrably).
* the constructor (preferably).
*/
class langstats
{
public $db; //database connector
public $error; //errores almacenados
public $error; //stored errors
public $db_type = 'sqlite';
public function __construct($file = '')
@ -97,7 +97,7 @@ class langstats
* @param string The language term used
* @param string The file from which the language term came from
*
* @return bool true
* @return mixed
*/
public function add_use($term, $term_file = '')
{
@ -114,6 +114,7 @@ class langstats
while ($row = $ress->fetchArray(SQLITE3_BOTH)) {
$num = $row[3];
$num++;
$i++;
$res = $this->db->query(
'UPDATE lang_freq SET term_count = '.$num.' WHERE id = '.$row[0]
);
@ -124,7 +125,6 @@ class langstats
} else {
return $row[0];
}
$i++;
}
if ($i == 0) {
//No term found in the table, register as new term
@ -139,6 +139,8 @@ class langstats
return $this->db->lastInsertRowID();
}
}
return true;
}
/**
@ -164,13 +166,13 @@ class langstats
/**
* Clear all records in lang_freq.
*
* @return bool true
* @return resource true
*/
public function clear_all()
{
$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)
$defined_terms = array_flip(array_keys($terms));
$terms = null;
$hidePlugins = !empty($_GET['hidePlugins']);
// now get all terms found in all PHP files of Chamilo (this takes some time and memory)
$undefined_terms = [];
$l = strlen(api_get_path(SYS_PATH));
$files = getAllPhpFiles(api_get_path(SYS_PATH));
foreach ($files as $file) {
$isPlugin = preg_match('#/plugin/#', $file);
if ($isPlugin && $hidePlugins) {
continue;
}
//echo 'Analyzing '.$file."<br />";
$shortfile = substr($file, $l);
$lines = file($file);
@ -64,11 +69,14 @@ if (count($undefined_terms) < 1) {
} else {
echo "The following terms were nowhere to be found: <br />\n<table>";
}
$i = 1;
foreach ($undefined_terms as $term => $file) {
echo "<tr><td>$term</td><td>in $file";
if (substr($file, 0, 7) == 'plugin/') {
$isPlugin = 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 "</td></tr>\n";
$i++;
}
echo "</table>\n";

@ -32,26 +32,39 @@ echo count($defined_terms)." terms were found in language files<br />";
$usedTerms = [];
$l = strlen(api_get_path(SYS_PATH));
$files = getAllPhpFiles(api_get_path(SYS_PATH));
$files[] = api_get_path(SYS_PATH).'main/install/data.sql';
// Browse files
foreach ($files as $file) {
//echo 'Analyzing '.$file."<br />";
$shortFile = substr($file, $l);
//echo 'Analyzing '.$shortFile."<br />";
$lines = file($file);
$isDataSQL = false;
if (substr($file, -21) === 'main/install/data.sql') {
$isDataSQL = true;
}
// Browse lines inside file $file
foreach ($lines as $line) {
$myTerms = [];
$res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4);
if ($isDataSQL) {
// Check main/install/data.sql
// Should recognize stuff like
// INSERT INTO settings_current (variable, type, category, selected_value, title, comment) VALUES ('enable_profile_user_address_geolocalization', 'radio', 'User', 'false', 'EnableProfileUsersAddressGeolocalizationTitle', 'EnableProfileUsersAddressGeolocalizationComment');
// INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_profile_user_address_geolocalization', 'true', 'Yes');
// ('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 {
$res = 0;
$res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/', $line, $myTerms);
$myTerms = [];
$res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms);
if ($res > 0) {
foreach ($myTerms[1] as $term) {
if (substr($term, 0, 4) == 'lang') {
@ -59,6 +72,34 @@ foreach ($files as $file) {
}
$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.
*
@ -56,14 +57,11 @@ foreach ($files as $file) {
if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4);
}
// Replace all variables by their English translation,
// except those translations larger than 120 characters
// as these would be impractical
if (!empty($terms[$term]) and strlen($terms[$term]) <= 120) {
$translation = str_replace("'", "\\'", $terms[$term]);
if (!empty($terms[$term])) {
$translation = $terms[$term];
$quotedTerm = $myTerms[1][0];
echo "Doing sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
system("sed -i \"s#$quotedTerm#'$translation'#g\" $file");
//echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
system("sed -i \"s#$term#'$translation'#g\" $file");
$countReplaces++;
}
}
@ -76,14 +74,11 @@ foreach ($files as $file) {
if (substr($term, 0, 4) == 'lang') {
$term = substr($term, 4);
}
// Replace all variables by their English translation,
// except those translations larger than 120 characters
// as these would be impractical
if (!empty($terms[$term]) and strlen($terms[$term]) <= 120) {
$translation = str_replace("'", "\\'", $terms[$term]);
if (!empty($terms[$term])) {
$translation = $terms[$term];
$quotedTerm = $myTerms[1][0];
echo "Doing sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
system("sed -i \"s#$quotedTerm#'$translation'#g\" $file");
//echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
system("sed -i \"s#$term#'$translation'#g\" $file");
$countReplaces++;
}
}

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

@ -1265,7 +1265,8 @@ if (!empty($error)) {
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;
}

@ -14,7 +14,6 @@ $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_set_more_memory_and_time_limits();
api_block_anonymous_users();
GradebookUtils::block_students();
$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);
$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);
$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()) {
$sql .= ' AND visible = 1';
@ -1262,7 +1262,7 @@ class Category implements GradebookItem
if (!empty($session_id)) {
$sql .= " AND session_id = ".$session_id;
} else {
$sql .= "AND session_id IS NULL OR session_id=0";
$sql .= 'AND session_id IS NULL OR session_id = 0';
}
} else {
$sql .= ' AND course_code IN
@ -1287,7 +1287,7 @@ class Category implements GradebookItem
// course independent categories
if (empty($course_code)) {
$cats = self::getIndependentCategoriesWithStudentResult(
$cats = $this->getIndependentCategoriesWithStudentResult(
0,
$stud_id,
$cats
@ -1462,7 +1462,7 @@ class Category implements GradebookItem
$cat->get_name(),
$level + 1,
];
$targets = self::add_subtree(
$targets = $this->add_subtree(
$targets,
$level + 1,
$cat->get_id(),
@ -1471,14 +1471,14 @@ class Category implements GradebookItem
}
} else {
// 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) {
$targets[] = [
$cat->get_id(),
$cat->get_name(),
$level + 1,
];
$targets = self::add_subtree(
$targets = $this->add_subtree(
$targets,
$level + 1,
$cat->get_id(),
@ -1616,6 +1616,7 @@ class Category implements GradebookItem
$this->id,
api_is_allowed_to_edit() ? null : 1
);
/** @var Category $cat */
foreach ($cats as $cat) {
if ($cat->hasEvaluationsWithStudentResults($studentId)) {
@ -1694,7 +1695,7 @@ class Category implements GradebookItem
if (isset($studentId)) {
// Special case: this is the root
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 {
return self::load(
null,

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

@ -66,7 +66,7 @@ $defaults = [
$form->setDefaults($defaults);
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']);
$user_id = api_get_user_id();
$title = Security::remove_XSS($_POST['email_title']);
@ -80,12 +80,6 @@ if ($form->validate()) {
api_get_person_name($_user['firstname'], $_user['lastname']),
$_user['mail']
);
UserManager::send_message_in_outbox(
$email_administrator,
$user_id,
$title,
$content
);
} else {
api_mail_html(
'',

@ -712,6 +712,7 @@ class AddCourse
);
$now = api_get_utc_datetime();
$files = [
['path' => '/shared_folder', 'title' => get_lang('UserFolders'), '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;
}
// 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 $base_path_document
* @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(
$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)
{
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,
250,
'',
@ -6376,6 +6390,8 @@ function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true)
false,
$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)
{
$user_id = intval($user_id);
$user_id = (int) $user_id;
if (empty($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()
*
* @param string The course code - optional (takes it from session if not given)
* @param int The session id - optional (takes it from session if not given)
* @param int $session_id
* @param string $courseCode The course code - optional (takes it from context if not given)
* @param int $sessionId The session ID - optional (takes it from context if not given)
* @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>
*/
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)) {
$course_info = api_get_course_info();
$courseDirectory = '';
$url = '';
// If courseCode not set, get context or []
if (empty($courseCode)) {
$courseInfo = api_get_course_info();
} 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();
} else {
$session_url = '?id_session='.intval($session_id);
// If course defined, get directory, otherwise keep empty string
if (!empty($courseInfo['directory'])) {
$courseDirectory = $courseInfo['directory'];
}
/*
if (empty($group_id)) {
$group_url = '&gidReq='.api_get_group_id();
} else {
$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;
// If sessionId not set, get context or 0
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
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.
*
* @param int $from Offset (from the 7th = '6'). 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 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 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 bool $alsoSearchCode An extension option to indicate that we also want to search for course codes (not *only* titles)
* @param int $from Offset (from the 7th = '6'). 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 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 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 bool $alsoSearchCode An extension option to indicate that we also want to search for course codes (not *only* titles)
* @param array $conditionsLike
* @param array $onlyThisCourseList
*
* @return array
*/
@ -210,7 +211,8 @@ class CourseManager
$startwith = '',
$urlId = null,
$alsoSearchCode = false,
$conditionsLike = []
$conditionsLike = [],
$onlyThisCourseList = []
) {
$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) ";
}
$visibility = (int) $visibility;
if (!empty($startwith)) {
$sql .= "WHERE (title LIKE '".Database::escape_string($startwith)."%' ";
if ($alsoSearchCode) {
$sql .= "OR code LIKE '".Database::escape_string($startwith)."%' ";
}
$sql .= ') ';
if ($visibility !== -1 && $visibility == strval(intval($visibility))) {
if ($visibility !== -1) {
$sql .= " AND visibility = $visibility ";
}
} else {
$sql .= "WHERE 1 ";
if ($visibility !== -1 && $visibility == strval(intval($visibility))) {
if ($visibility !== -1) {
$sql .= " AND visibility = $visibility ";
}
}
if (!empty($urlId)) {
$urlId = intval($urlId);
$urlId = (int) $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 = [
'title',
'code',

@ -304,6 +304,8 @@ class Database
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(':"false"', ':false', $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);
// Creating the jqgrid element.

@ -185,9 +185,14 @@ EOT;
*
* @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');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
@ -291,12 +296,19 @@ EOT;
* @param string $name
* @param string $label
* @param array $attributes
* @param bool $required
*
* @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 $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);
}
@ -917,6 +938,46 @@ EOT;
$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.
*

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

@ -2966,7 +2966,7 @@ class UserManager
$position
FROM ChamiloCoreBundle:Session AS 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 ";
// 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
// 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...
$dqlStudent = $dql." WHERE scu.user = :user AND url.accessUrlId = :url ";
$dqlCoach = $dql." WHERE s.generalCoach = :user AND url.accessUrlId = :url ";
$dqlStudent = $dql." WHERE scu.user = :user AND url.url = :url ";
$dqlCoach = $dql." WHERE s.generalCoach = :user AND url.url = :url ";
// Default order
$order = 'ORDER BY sc.name, s.name';

@ -188,83 +188,6 @@ class IndexManager
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.
*

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

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

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

@ -121,45 +121,54 @@ $htmlHeadXtra[] = '<script>
var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\';
-->
</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>
$(document).ready(function() {
$(document).ready(function() {
$("div#log_content_cleaner").bind("click", function() {
$("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;
</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
if ($lp->mode == 'impress') {
$lp_id = $lp->get_id();

Loading…
Cancel
Save