Fix jqgrid (no need of formatter), fix PHP errors, fix sql errors

Update from 1.11.x, format code
pull/2944/head
Julio Montoya 6 years ago
parent d9f8b0103c
commit e02700fa20
  1. 1
      main/announcements/announcements.php
  2. 3
      main/coursecopy/import_backup.php
  3. 7
      main/dropbox/dropbox_functions.inc.php
  4. 1
      main/forum/editthread.php
  5. 101
      main/forum/forumfunction.inc.php
  6. 7
      main/inc/lib/api.lib.php
  7. 6
      main/inc/lib/course.lib.php
  8. 7
      main/inc/lib/display.lib.php
  9. 4
      main/inc/lib/extra_field.lib.php
  10. 6
      main/survey/survey.lib.php
  11. 9
      main/survey/surveyUtil.class.php
  12. 3
      main/template/default/coursecopy/import_moodle.html.twig
  13. 1
      main/template/default/my_space/user_details.html.twig
  14. 2
      main/template/default/skill/student_boss_report.html.twig
  15. 2
      main/template/default/skill/student_report.html.twig
  16. 6
      main/work/work.lib.php

@ -250,7 +250,6 @@ switch ($action) {
'index' => 'actions',
'width' => '150',
'align' => 'left',
//'formatter' => 'action_formatter',
'sortable' => 'false',
],
];

@ -24,6 +24,7 @@ if (!api_is_allowed_to_edit()) {
}
api_set_more_memory_and_time_limits();
$isPlatformAdmin = api_is_platform_admin();
// Section for the tabs
$this_section = SECTION_COURSES;
@ -133,7 +134,7 @@ if (Security::check_token('post') && ($action === 'course_select_form' || $impor
}
} else {
$user = api_get_user_info();
$backups = CourseArchiver::getAvailableBackups($is_platformAdmin ? null : $user['user_id']);
$backups = CourseArchiver::getAvailableBackups($isPlatformAdmin ? null : $user['user_id']);
$backups_available = count($backups) > 0;
$form = new FormValidator(

@ -1271,18 +1271,19 @@ function store_feedback()
if (empty($_POST['feedback'])) {
return get_lang('PleaseTypeText');
} else {
$table = Database::get_course_table(TABLE_DROPBOX_FEEDBACK);
$params = [
'c_id' => $course_id,
'file_id' => $_GET['id'],
'author_user_id' => api_get_user_id(),
'feedback' => $_POST['feedback'],
'feedback_date' => api_get_utc_datetime(),
'feedback_id' => 0,
];
$id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FEEDBACK), $params);
$id = Database::insert($table, $params);
if ($id) {
$sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FEEDBACK)."
SET feedback_id = iid WHERE iid = $id";
$sql = "UPDATE $table SET feedback_id = iid WHERE iid = $id";
Database::query($sql);
}

@ -17,6 +17,7 @@ api_protect_course_script(true);
$cidreq = api_get_cidreq();
$nameTools = get_lang('ToolForum');
$_user = api_get_user_info();
require_once 'forumfunction.inc.php';

@ -1690,11 +1690,12 @@ function get_forums_in_category($cat_id, $courseId = 0)
* @version february 2006, dokeos 1.8
*/
function get_forums(
$id = '',
$id = 0,
$course_code = '',
$includeGroupsForum = true,
$sessionId = 0
) {
$id = (int) $id;
$course_info = api_get_course_info($course_code);
$table_forums = Database::get_course_table(TABLE_FORUM);
@ -1720,7 +1721,9 @@ function get_forums(
$includeGroupsForumSelect = " AND (forum_of_group = 0 OR forum_of_group IS NULL) ";
}
if ($id == '') {
$allowToEdit = api_is_allowed_to_edit();
if (empty($id)) {
// Student
// Select all the forum information of all forums (that are visible to students).
$sql = "SELECT item_properties.*, forum.*
@ -1756,7 +1759,7 @@ function get_forums(
GROUP BY threads.forum_id";
// Course Admin
if (api_is_allowed_to_edit()) {
if ($allowToEdit) {
// Select all the forum information of all forums (that are not deleted).
$sql = "SELECT item_properties.*, forum.*
FROM $table_forums forum
@ -1804,7 +1807,7 @@ function get_forums(
INNER JOIN $table_forums forum
ON (forum.forum_id = item_properties.ref AND forum.c_id = item_properties.c_id)
WHERE
forum.forum_id = ".intval($id)." AND
forum.forum_id = $id AND
forum.c_id = $course_id AND
item_properties.visibility != 2 AND
item_properties.tool = '".TOOL_FORUM."'
@ -1814,14 +1817,14 @@ function get_forums(
$sql2 = "SELECT count(*) AS number_of_threads, forum_id
FROM $table_threads
WHERE
forum_id = ".intval($id)."
forum_id = $id
GROUP BY forum_id";
}
// Handling all the forum information.
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
if ($id == '') {
if (empty($id)) {
$forum_list[$row['forum_id']] = $row;
} else {
$forum_list = $row;
@ -1831,7 +1834,7 @@ function get_forums(
// Handling the thread count information.
$result2 = Database::query($sql2);
while ($row2 = Database::fetch_array($result2)) {
if ($id == '') {
if (empty($id)) {
$forum_list[$row2['forum_id']]['number_of_threads'] = $row2['number_of_threads'];
} else {
$forum_list['number_of_threads'] = $row2['number_of_threads'];
@ -1840,44 +1843,44 @@ function get_forums(
/* Finding the last post information
(last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
if ($id == '') {
if (empty($id)) {
if (is_array($forum_list)) {
foreach ($forum_list as $key => $value) {
$last_post_info_of_forum = get_last_post_information(
$lastPost = get_last_post_information(
$key,
api_is_allowed_to_edit(),
$allowToEdit,
$course_id
);
if ($last_post_info_of_forum) {
$forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
$forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
$forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
$forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
$forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
$forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
$forum_list[$key]['last_post_title'] = $last_post_info_of_forum['last_post_title'];
$forum_list[$key]['last_post_text'] = $last_post_info_of_forum['last_post_text'];
if ($lastPost) {
$forum_list[$key]['last_post_id'] = $lastPost['last_post_id'];
$forum_list[$key]['last_poster_id'] = $lastPost['last_poster_id'];
$forum_list[$key]['last_post_date'] = $lastPost['last_post_date'];
$forum_list[$key]['last_poster_name'] = $lastPost['last_poster_name'];
$forum_list[$key]['last_poster_lastname'] = $lastPost['last_poster_lastname'];
$forum_list[$key]['last_poster_firstname'] = $lastPost['last_poster_firstname'];
$forum_list[$key]['last_post_title'] = $lastPost['last_post_title'];
$forum_list[$key]['last_post_text'] = $lastPost['last_post_text'];
}
}
} else {
$forum_list = [];
}
} else {
$last_post_info_of_forum = get_last_post_information(
$lastPost = get_last_post_information(
$id,
api_is_allowed_to_edit(),
$allowToEdit,
$course_id
);
if ($last_post_info_of_forum) {
$forum_list['last_post_id'] = $last_post_info_of_forum['last_post_id'];
$forum_list['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
$forum_list['last_post_date'] = $last_post_info_of_forum['last_post_date'];
$forum_list['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
$forum_list['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
$forum_list['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
$forum_list['last_post_title'] = $last_post_info_of_forum['last_post_title'];
$forum_list['last_post_text'] = $last_post_info_of_forum['last_post_text'];
if ($lastPost) {
$forum_list['last_post_id'] = $lastPost['last_post_id'];
$forum_list['last_poster_id'] = $lastPost['last_poster_id'];
$forum_list['last_post_date'] = $lastPost['last_post_date'];
$forum_list['last_poster_name'] = $lastPost['last_poster_name'];
$forum_list['last_poster_lastname'] = $lastPost['last_poster_lastname'];
$forum_list['last_poster_firstname'] = $lastPost['last_poster_firstname'];
$forum_list['last_post_title'] = $lastPost['last_post_title'];
$forum_list['last_post_text'] = $lastPost['last_post_text'];
}
}
@ -2776,9 +2779,9 @@ function updateThread($values)
} else {
$params = [
'thread_title_qualify' => '',
'thread_qualify_max' => '',
'thread_weight' => '',
'thread_peer_qualify' => '',
'thread_qualify_max' => 0,
'thread_weight' => 0,
'thread_peer_qualify' => 0,
];
$where = ['c_id = ? AND thread_id = ?' => [$courseId, $values['thread_id']]];
Database::update($threadTable, $params, $where);
@ -5603,14 +5606,14 @@ function get_forums_of_group($groupInfo)
// (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname).
if (!empty($forum_list)) {
foreach ($forum_list as $key => $value) {
$last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit());
if ($last_post_info_of_forum) {
$forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
$forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
$forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
$forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
$forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
$forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
$lastPost = get_last_post_information($key, api_is_allowed_to_edit());
if ($lastPost) {
$forum_list[$key]['last_post_id'] = $lastPost['last_post_id'];
$forum_list[$key]['last_poster_id'] = $lastPost['last_poster_id'];
$forum_list[$key]['last_post_date'] = $lastPost['last_post_date'];
$forum_list[$key]['last_poster_name'] = $lastPost['last_poster_name'];
$forum_list[$key]['last_poster_lastname'] = $lastPost['last_poster_lastname'];
$forum_list[$key]['last_poster_firstname'] = $lastPost['last_poster_firstname'];
}
}
}
@ -6122,22 +6125,26 @@ function get_thread_user_post_limit($course_code, $thread_id, $user_id, $limit =
}
/**
* @param string $user_id
* @param int $courseId
* @param string $userId
* @param array $courseInfo
* @param int $sessionId
*
* @return array
*/
function getForumCreatedByUser($user_id, $courseId, $sessionId)
function getForumCreatedByUser($userId, $courseInfo, $sessionId)
{
if (empty($userId) || empty($courseInfo)) {
return [];
}
$courseId = $courseInfo['real_id'];
$items = api_get_item_property_list_by_tool_by_user(
$user_id,
$userId,
'forum',
$courseId,
$sessionId
);
$courseInfo = api_get_course_info_by_id($courseId);
$forumList = [];
if (!empty($items)) {
foreach ($items as $forum) {
@ -6147,7 +6154,7 @@ function getForumCreatedByUser($user_id, $courseId, $sessionId)
true,
$sessionId
);
if (!empty($forumInfo)) {
if (!empty($forumInfo) && isset($forumInfo['forum_title'])) {
$forumList[] = [
$forumInfo['forum_title'],
api_get_local_time($forum['insert_date']),

@ -317,7 +317,6 @@ define('REL_HOME_PATH', 'REL_HOME_PATH');
// Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
define('WEB_PATH', 'WEB_PATH');
define('WEB_APP_PATH', 'WEB_APP_PATH');
define('SYS_PATH', 'SYS_PATH');
define('SYS_APP_PATH', 'SYS_APP_PATH');
define('SYS_UPLOAD_PATH', 'SYS_UPLOAD_PATH');
@ -828,7 +827,7 @@ function api_get_path($path = '', $configuration = [])
SYS_CODE_PATH => 'main/',
REL_CODE_PATH => '/main/',
SYS_LANG_PATH => 'lang/',
WEB_IMG_PATH => 'img/',
WEB_IMG_PATH => 'public/img/',
WEB_CSS_PATH => 'public/build/css/',
SYS_CSS_PATH => 'public/build/css/',
SYS_PLUGIN_PATH => 'plugin/',
@ -840,7 +839,6 @@ function api_get_path($path = '', $configuration = [])
WEB_HOME_PATH => 'app/home/',
REL_HOME_PATH => 'app/home/',
SYS_APP_PATH => 'var/',
WEB_APP_PATH => 'app/',
SYS_UPLOAD_PATH => 'var/upload/',
SYS_INC_PATH => 'inc/',
CONFIGURATION_PATH => 'app/config/',
@ -894,7 +892,6 @@ function api_get_path($path = '', $configuration = [])
$paths[$root_web][WEB_PATH] = $rootWebWithSlash;
$paths[$root_web][WEB_CODE_PATH] = $rootWebWithSlash.$code_folder;
$paths[$root_web][WEB_COURSE_PATH] = $rootWebWithSlash.$course_folder;
$paths[$root_web][WEB_APP_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_APP_PATH];
$paths[$root_web][WEB_PLUGIN_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PLUGIN_PATH];
$paths[$root_web][WEB_PLUGIN_ASSET_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PLUGIN_ASSET_PATH];
$paths[$root_web][WEB_ARCHIVE_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_ARCHIVE_PATH];
@ -903,7 +900,7 @@ function api_get_path($path = '', $configuration = [])
$paths[$root_web][WEB_PUBLIC_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PUBLIC_PATH];
$paths[$root_web][WEB_HOME_PATH] = $rootWebWithSlash.$paths[$root_web][REL_HOME_PATH];
$paths[$root_web][WEB_IMG_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_IMG_PATH];
$paths[$root_web][WEB_IMG_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_IMG_PATH];
$paths[$root_web][WEB_LIBRARY_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_PATH];
$paths[$root_web][WEB_LIBRARY_JS_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_JS_PATH];
$paths[$root_web][WEB_AJAX_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_AJAX_PATH];

@ -1864,9 +1864,11 @@ class CourseManager
$groupId = 0
) {
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
$session_id = (int) $session_id;
$courseInfo = api_get_course_info($course_code);
if (empty($courseInfo)) {
return [];
}
$courseId = $courseInfo['real_id'];
$students = [];

@ -1368,6 +1368,13 @@ class Display
$obj->url = $url;
}
// Needed it in order to render the links/html in the grid
foreach ($column_model as &$columnModel) {
if (!isset($columnModel['formatter'])) {
$columnModel['formatter'] = '';
}
}
//This line should only be used/modified in case of having characters
// encoding problems - see #6159
//$column_names = array_map("utf8_encode", $column_names);

@ -1925,7 +1925,6 @@ class ExtraField extends Model
'width' => '35',
'align' => 'left',
'sortable' => 'true',
'formatter' => '',
],
[
'name' => 'visible_to_self',
@ -1933,7 +1932,6 @@ class ExtraField extends Model
'width' => '45',
'align' => 'left',
'sortable' => 'true',
'formatter' => '',
],
[
'name' => 'visible_to_others',
@ -1941,7 +1939,6 @@ class ExtraField extends Model
'width' => '35',
'align' => 'left',
'sortable' => 'true',
'formatter' => '',
],
[
'name' => 'filter',
@ -1949,7 +1946,6 @@ class ExtraField extends Model
'width' => '30',
'align' => 'left',
'sortable' => 'true',
'formatter' => '',
],
[
'name' => 'field_order',

@ -429,11 +429,11 @@ class SurveyManager
}
$extraParams = [];
$extraParams['one_question_per_page'] = isset($values['one_question_per_page']) ? $values['one_question_per_page'] : null;
$extraParams['shuffle'] = isset($values['shuffle']) ? $values['shuffle'] : null;
$extraParams['one_question_per_page'] = isset($values['one_question_per_page']) ? $values['one_question_per_page'] : 0;
$extraParams['shuffle'] = isset($values['shuffle']) ? $values['shuffle'] : 0;
if ($values['anonymous'] == 0) {
$extraParams['show_form_profile'] = isset($values['show_form_profile']) ? $values['show_form_profile'] : '';
$extraParams['show_form_profile'] = isset($values['show_form_profile']) ? $values['show_form_profile'] : 0;
if ($extraParams['show_form_profile'] == 1) {
$fields = explode(',', $values['input_name_list']);
$field_values = '';

@ -2426,6 +2426,15 @@ class SurveyUtil
(!empty($params['user']) || !empty($params['group_id'])) &&
!empty($params['survey_code'])
) {
if (!isset($params['survey_invitation_id'])) {
$params['survey_invitation_id'] = 0;
}
if (!isset($params['answered'])) {
$params['answered'] = 0;
}
if (!isset($params['group_id'])) {
$params['group_id'] = 0;
}
$insertId = Database::insert($table, $params);
if ($insertId) {
$sql = "UPDATE $table

@ -1,3 +1,4 @@
{% autoescape false %}
{{ info_msg }}
<br />
<div id="loader" class="text-center">
@ -13,3 +14,5 @@ $(function() {
});
});
</script>
{% endautoescape %}

@ -11,7 +11,6 @@
<!-- NO DETAILS -->
{% if details != true %}
<div class="no-details">
{% set user_content %}
<div class="row">
<div class="col-md-4">

@ -1,3 +1,4 @@
{% autoescape false %}
{% if allow_skill_tool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">
@ -43,3 +44,4 @@
</tbody>
</table>
{% endif %}
{% endautoescape %}

@ -1,3 +1,4 @@
{% autoescape false %}
{% if allow_skill_tool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">
@ -39,3 +40,4 @@
{{ skill_table }}
{% endif %}
{% endif %}
{% endautoescape %}

@ -544,7 +544,6 @@ function showTeacherWorkGrid()
'width' => '35',
'align' => 'center',
'sortable' => 'false',
'formatter' => '',
],
[
'name' => 'title',
@ -552,7 +551,6 @@ function showTeacherWorkGrid()
'width' => '300',
'align' => 'left',
'wrap_cell' => "true",
'formatter' => '',
],
['name' => 'sent_date', 'index' => 'sent_date', 'width' => '125', 'align' => 'center'],
['name' => 'expires_on', 'index' => 'expires_on', 'width' => '125', 'align' => 'center'],
@ -562,7 +560,6 @@ function showTeacherWorkGrid()
'width' => '110',
'align' => 'center',
'sortable' => 'false',
'formatter' => '',
],
[
'name' => 'actions',
@ -570,7 +567,6 @@ function showTeacherWorkGrid()
'width' => '110',
'align' => 'left',
'sortable' => 'false',
'formatter' => '',
],
];
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_teacher&'.api_get_cidreq();
@ -4845,14 +4841,12 @@ function showStudentList($workId)
'width' => '350px',
'align' => 'left',
'sortable' => 'false',
'formatter' => '',
],
[
'name' => 'works',
'index' => 'works',
'align' => 'center',
'sortable' => 'false',
'formatter' => '',
],
];
$token = null;

Loading…
Cancel
Save