pull/2818/head
Alex Aragón 6 years ago
commit 35b70966cb
  1. 2
      main/admin/course_add.php
  2. 19
      main/announcements/announcements.php
  3. 110
      main/course_home/activity.php
  4. 18
      main/course_progress/thematic.php
  5. 15
      main/coursecopy/import_moodle.php
  6. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_corriolis.gif
  7. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_electrolysis.gif
  8. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_japanese.gif
  9. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_loco.gif
  10. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_pendul.gif
  11. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_rome.gif
  12. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_twostroke.gif
  13. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_wave_frequency.gif
  14. BIN
      main/default_course_document/images/diagrams/animated/.thumbs/.anim_yugoslavia.gif
  15. BIN
      main/default_course_document/images/logo_dokeos.png
  16. 10
      main/exercise/TestCategory.php
  17. 4
      main/exercise/exercise.class.php
  18. 73
      main/exercise/question_pool.php
  19. 1
      main/gradebook/lib/fe/gradebooktable.class.php
  20. 10
      main/group/group_space.php
  21. 6
      main/inc/ajax/agenda.ajax.php
  22. 10
      main/inc/ajax/lp.ajax.php
  23. 2
      main/inc/ajax/statistics.ajax.php
  24. 22
      main/inc/lib/AnnouncementManager.php
  25. 972
      main/inc/lib/MoodleImport.php
  26. 234
      main/inc/lib/add_course.lib.inc.php
  27. 3
      main/inc/lib/agenda.lib.php
  28. 7
      main/inc/lib/attendance.lib.php
  29. 28
      main/inc/lib/course.lib.php
  30. 469
      main/inc/lib/course_home.lib.php
  31. 243
      main/inc/lib/document.lib.php
  32. 2
      main/inc/lib/exercise.lib.php
  33. 10
      main/inc/lib/fileUpload.lib.php
  34. 86
      main/inc/lib/formvalidator/FormValidator.class.php
  35. 24
      main/inc/lib/groupmanager.lib.php
  36. 33
      main/inc/lib/message.lib.php
  37. 16
      main/inc/lib/pear/HTML/Common.php
  38. 6
      main/inc/lib/pear/HTML/QuickForm.php
  39. 1
      main/inc/lib/pear/HTML/QuickForm/Renderer.php
  40. 7
      main/inc/lib/pear/HTML/QuickForm/checkbox.php
  41. 93
      main/inc/lib/pear/HTML/QuickForm/element.php
  42. 3
      main/inc/lib/pear/HTML/QuickForm/file.php
  43. 25
      main/inc/lib/pear/HTML/QuickForm/input.php
  44. 10
      main/inc/lib/pear/HTML/QuickForm/label.php
  45. 4
      main/inc/lib/pear/HTML/QuickForm/link.php
  46. 8
      main/inc/lib/pear/HTML/QuickForm/reset.php
  47. 30
      main/inc/lib/pear/HTML/QuickForm/static.php
  48. 11
      main/inc/lib/pear/HTML/QuickForm/submit.php
  49. 29
      main/inc/lib/pear/HTML/QuickForm/textarea.php
  50. 5
      main/inc/lib/social.lib.php
  51. 10
      main/inc/lib/sortable_table.class.php
  52. 10
      main/inc/lib/userportal.lib.php
  53. 21
      main/inc/lib/zombie/zombie_manager.class.php
  54. 114
      main/inc/lib/zombie/zombie_report.class.php
  55. 116
      main/install/install.lib.php
  56. 19
      main/lp/learnpath.class.php
  57. 28
      main/lp/learnpathItem.class.php
  58. 1
      main/lp/lp_add_item.php
  59. 2
      main/lp/scorm_api.php
  60. 4
      main/messages/inbox.php
  61. 4
      main/messages/new_message.php
  62. 22
      main/messages/outbox.php
  63. 5
      main/messages/view_message.php
  64. 6
      main/mySpace/exercise_category_report.php
  65. 2
      main/mySpace/lp_tracking.php
  66. 1
      main/social/personal_data.php
  67. 2
      main/survey/create_meeting.php
  68. 1
      main/survey/reporting.php
  69. 9
      main/survey/surveyUtil.class.php
  70. 11
      main/work/add_document.php
  71. 1
      plugin/customcertificate/config.php
  72. 1
      plugin/customcertificate/src/CustomCertificatePlugin.php
  73. 33
      plugin/customcertificate/src/index.php
  74. 150
      plugin/customcertificate/src/print_certificate.php
  75. 29
      plugin/notebookteacher/src/NotebookTeacherPlugin.php
  76. 2
      plugin/sepe/src/sepe_plugin.class.php
  77. 35
      plugin/test2pdf/src/test2pdf_plugin.class.php
  78. BIN
      public/img/icons/128/add_doodle.png
  79. BIN
      public/img/icons/128/external_link.png
  80. BIN
      public/img/icons/128/multiplicate_survey.png
  81. BIN
      public/img/icons/128/multiplicate_survey_na.png
  82. BIN
      public/img/icons/128/statistics_na.png
  83. BIN
      public/img/icons/16/external_link.png
  84. BIN
      public/img/icons/16/statistics_na.png
  85. BIN
      public/img/icons/22/add_doodle.png
  86. BIN
      public/img/icons/22/external_link.png
  87. BIN
      public/img/icons/22/multiplicate_survey.png
  88. BIN
      public/img/icons/22/multiplicate_survey_na.png
  89. BIN
      public/img/icons/22/scormbuilder.png
  90. BIN
      public/img/icons/22/statistics_na.png
  91. BIN
      public/img/icons/22/test2pdf.png
  92. BIN
      public/img/icons/22/warning.png
  93. BIN
      public/img/icons/32/add_doodle.png
  94. BIN
      public/img/icons/32/agenda_na.png
  95. BIN
      public/img/icons/32/attendance_na.png
  96. BIN
      public/img/icons/32/backup.png
  97. BIN
      public/img/icons/32/blog_admin.png
  98. BIN
      public/img/icons/32/blog_na.png
  99. BIN
      public/img/icons/32/chat_na.png
  100. BIN
      public/img/icons/32/course_progress_na.png
  101. Some files were not shown because too many files have changed in this diff Show More

@ -139,7 +139,7 @@ if (count($languages) === 1) {
} else {
$form->addSelectLanguage(
'course_language',
get_lang('Ln'),
get_lang('Language'),
[],
['style' => 'width:150px']
);

@ -41,7 +41,6 @@ $allowToEdit = (
$sessionId = api_get_session_id();
$drhHasAccessToSessionContent = api_drh_can_access_all_session_content();
if (!empty($sessionId) && $drhHasAccessToSessionContent) {
$allowToEdit = $allowToEdit || api_is_drh();
}
@ -66,12 +65,12 @@ $isTutor = false;
if (!empty($group_id)) {
$groupProperties = GroupManager:: get_group_properties($group_id);
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
"name" => get_lang('Groups'),
'url' => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace').' '.$groupProperties['name'],
'url' => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
'name' => get_lang('GroupSpace').' '.$groupProperties['name'],
];
if ($allowToEdit === false) {
@ -86,7 +85,7 @@ if (!empty($group_id)) {
/* Tracking */
Event::event_access_tool(TOOL_ANNOUNCEMENT);
$announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null;
$announcement_id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'list';
$announcement_number = AnnouncementManager::getNumberAnnouncements();
@ -118,8 +117,9 @@ switch ($action) {
$announcementInfo = AnnouncementManager::get_by_id($courseId, $thisAnnouncementId);
$sql = "SELECT DISTINCT announcement.id, announcement.display_order
FROM $tbl_announcement announcement,
$tbl_item_property itemproperty
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property itemproperty
ON (announcement.c_id = itemproperty.c_id)
WHERE
announcement.c_id = $courseId AND
itemproperty.c_id = $courseId AND
@ -555,7 +555,8 @@ switch ($action) {
if (!isset($parts[1]) || empty($parts[1])) {
continue;
}
$form->addHtml("
$form->addHtml(
"
<script>
$(document).on('ready', function () {
$('#choose_recipients').click();

@ -43,8 +43,6 @@ if ($enabled === 'true') {
}
// COURSE ADMIN ONLY VIEW
$blocks = [];
// Start of tools for CourseAdmins (teachers/tutors)
if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$content .= '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;">
<div class="normal-message" id="id_normal_message" style="display:none">';
@ -53,46 +51,7 @@ if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, t
$content .= '</div>
<div class="alert alert-success" id="id_confirmation_message" style="display:none"></div>
</div>';
$content .= $pluginExtra;
if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
$content .= '
<div class="row">
<div class="col-xs-12 col-md-12">
<span class="viewcaption">'.get_lang('SessionData').'</span>
<table class="course_activity_home">'.
CourseHome::show_session_data($session_id).'
</table>
</div>
</div>';
}
$my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
$blocks[] = [
'title' => get_lang('Authoring'),
'class' => 'course-tools-author',
'content' => CourseHome::show_tools_category($my_list),
];
$list1 = CourseHome::get_tools_category(TOOL_INTERACTION);
$list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
$my_list = array_merge($list1, $list2);
$blocks[] = [
'title' => get_lang('Interaction'),
'class' => 'course-tools-interaction',
'content' => CourseHome::show_tools_category($my_list),
];
$my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
$blocks[] = [
'title' => get_lang('Administration'),
'class' => 'course-tools-administration',
'content' => CourseHome::show_tools_category($my_list),
];
} elseif (api_is_coach()) {
$content .= $pluginExtra;
if (api_get_setting('show_session_data') === 'true' && $session_id > 0) {
@ -103,76 +62,9 @@ if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, t
$content .= CourseHome::show_session_data($session_id);
$content .= '</table></div></div>';
}
$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
$blocks[] = [
'content' => CourseHome::show_tools_category($my_list),
];
$sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
if ($sessionsCopy === 'true') {
// Adding only maintenance for coaches.
$myList = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
$onlyMaintenanceList = [];
foreach ($myList as $item) {
if ($item['name'] === 'course_maintenance') {
$item['link'] = 'course_info/maintenance_coach.php';
$onlyMaintenanceList[] = $item;
}
}
$blocks[] = [
'title' => get_lang('Administration'),
'content' => CourseHome::show_tools_category($onlyMaintenanceList),
];
}
} else {
$tools = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
// Force user icon for DRH
if ($isDrhOfCourse) {
$addUserTool = true;
foreach ($tools as $tool) {
if ($tool['name'] === 'user') {
$addUserTool = false;
break;
}
}
if ($addUserTool) {
$tools[] = [
'c_id' => api_get_course_int_id(),
'name' => 'user',
'link' => 'user/user.php',
'image' => 'members.gif',
'visibility' => '1',
'admin' => '0',
'address' => 'squaregrey.gif',
'added_tool' => '0',
'target' => '_self',
'category' => 'interaction',
'session_id' => api_get_session_id(),
];
}
}
if (count($tools) > 0) {
$blocks[] = ['content' => CourseHome::show_tools_category($tools)];
}
if ($isDrhOfCourse) {
$drhTool = CourseHome::get_tools_category(TOOL_DRH);
$blocks[] = ['content' => CourseHome::show_tools_category($drhTool)];
}
}
$blocks = CourseHome::getUserBlocks();
$activityView = new Template('', false, false, false, false, false, false);
$activityView->assign('blocks', $blocks);

@ -152,21 +152,21 @@ if ($action == 'thematic_list') {
ICON_SIZE_TINY
),
'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$params.$url_token,
['class' => 'btn btn-outline-secondary']
['class' => 'btn btn-default']
);
if (api_get_session_id() == 0) {
if ($thematic['display_order'] > 1) {
$toolbarThematic .= ' <a class="btn btn-outline-secondary" href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.
$toolbarThematic .= ' <a class="btn btn-default" href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.
Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_TINY).'</a>';
} else {
$toolbarThematic .= '<div class="btn btn-outline-secondary">'.
$toolbarThematic .= '<div class="btn btn-default">'.
Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_TINY).'</div>';
}
if (isset($thematic['max_thematic_item']) && $thematic['display_order'] < $thematic['max_thematic_item']) {
$toolbarThematic .= ' <a class="btn btn-outline-secondary" href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.
$toolbarThematic .= ' <a class="btn btn-default" href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.
Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_TINY).'</a>';
} else {
$toolbarThematic .= '<div class="btn btn-outline-secondary">'.
$toolbarThematic .= '<div class="btn btn-default">'.
Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_TINY).'</div>';
}
}
@ -177,7 +177,7 @@ if ($action == 'thematic_list') {
'action' => 'export_single_thematic',
'thematic_id' => $my_thematic_id,
]),
['class' => 'btn btn-outline-secondary']
['class' => 'btn btn-default']
);
$toolbarThematic .= Display::url(
Display::return_icon(
@ -189,12 +189,12 @@ if ($action == 'thematic_list') {
api_get_self().'?'.api_get_cidreq().$url_token.'&'.http_build_query(
['action' => 'export_single_documents', 'thematic_id' => $my_thematic_id]
),
['class' => 'btn btn-outline-secondary']
['class' => 'btn btn-default']
);
$toolbarThematic .= '<a class="btn btn-outline-secondary" href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='
$toolbarThematic .= '<a class="btn btn-default" href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='
.$my_thematic_id.$params.$url_token.'">'
.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_TINY).'</a>';
$toolbarThematic .= '<a class="btn btn-outline-secondary" onclick="javascript:if(!confirm(\''
$toolbarThematic .= '<a class="btn btn-default" onclick="javascript:if(!confirm(\''
.get_lang('AreYouSureToDelete')
.'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='
.$my_thematic_id.$params.$url_token.'">'

@ -35,21 +35,18 @@ $form->addButtonImport(get_lang('Import'));
if ($form->validate()) {
$file = $_FILES['moodle_file'];
$moodleImport = new MoodleImport();
$responseImport = $moodleImport->import($file);
Display::cleanFlashMessages();
try {
$responseImport = $moodleImport->import($file);
if ($responseImport) {
Display::addFlash(
Display::return_message(
get_lang('MoodleFileImportedSuccessfully'),
'success'
)
Display::return_message(get_lang('MoodleFileImportedSuccessfully'), 'success')
);
} else {
} catch (Exception $exception) {
Display::addFlash(
Display::return_message(get_lang('ErrorImportingFile'), 'error')
Display::return_message($exception->getMessage(), 'error')
);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

@ -305,10 +305,8 @@ class TestCategory
*
* @return string
*/
public static function getCategoryNameForQuestion(
$questionId,
$courseId = 0
) {
public static function getCategoryNameForQuestion($questionId, $courseId = 0)
{
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
@ -399,9 +397,7 @@ class TestCategory
public static function getListOfCategoriesNameForTest($exerciseId, $grouped_by_category = true)
{
$result = [];
$categories = self::getListOfCategoriesIDForTest(
$exerciseId
);
$categories = self::getListOfCategoriesIDForTest($exerciseId);
foreach ($categories as $catInfo) {
$categoryId = $catInfo['id'];

@ -7498,9 +7498,9 @@ class Exercise
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id = q.id AND e.c_id = q.c_id)
INNER JOIN $categoryRelTable catRel
ON (catRel.question_id = e.question_id)
ON (catRel.question_id = e.question_id AND catRel.c_id = e.c_id)
INNER JOIN $categoryTable cat
ON (cat.id = catRel.category_id)
ON (cat.id = catRel.category_id AND cat.c_id = e.c_id)
WHERE
e.c_id = {$this->course_id} AND
e.exercice_id = ".intval($this->id);

@ -432,7 +432,10 @@ if ($exerciseId > 0) {
$from = '';
if (isset($courseCategoryId) && $courseCategoryId > 0) {
$from = ", $TBL_COURSE_REL_CATEGORY crc ";
$where .= " AND crc.c_id=$selected_course AND crc.question_id=qu.id AND crc.category_id=$courseCategoryId";
$where .= " AND
crc.c_id = $selected_course AND
crc.question_id = qu.id AND
crc.category_id = $courseCategoryId";
}
if (isset($exerciseLevel) && $exerciseLevel != -1) {
$where .= ' AND level='.$exerciseLevel;
@ -466,7 +469,8 @@ if ($exerciseId > 0) {
$level_where = '';
$from = '';
if (isset($courseCategoryId) && $courseCategoryId > 0) {
$from = " INNER JOIN $TBL_COURSE_REL_CATEGORY crc ON crc.question_id=q.id AND crc.c_id= q.c_id ";
$from = " INNER JOIN $TBL_COURSE_REL_CATEGORY crc
ON crc.question_id = q.id AND crc.c_id = q.c_id ";
$level_where .= " AND
crc.c_id = $selected_course AND
crc.category_id = $courseCategoryId";
@ -490,7 +494,8 @@ if ($exerciseId > 0) {
WHERE
ex.c_id = '$selected_course' AND
ex.active = '-1'
$level_where $answer_where
$level_where
$answer_where
)
UNION
(
@ -501,7 +506,8 @@ if ($exerciseId > 0) {
WHERE
q.c_id = '$selected_course' AND
r.question_id is null
$level_where $answer_where
$level_where
$answer_where
)
UNION
(
@ -512,7 +518,8 @@ if ($exerciseId > 0) {
WHERE
r.c_id = '$selected_course' AND
(r.exercice_id = '-1' OR r.exercice_id = '0')
$level_where $answer_where
$level_where
$answer_where
)";
$result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -667,14 +674,14 @@ if ($fromExercise <= 0) {
// NOT IN A TEST - IN THE COURSE
if ($selected_course == api_get_course_int_id()) {
$actionLabel = get_lang('Modify');
$actionIcon1 = "edit";
$actionIcon2 = "delete";
$actionIcon1 = 'edit';
$actionIcon2 = 'delete';
// We are in the course, question title can be a link to the question edit page
$questionTagA = 1;
} else { // NOT IN A TEST - NOT IN THE COURSE
$actionLabel = get_lang('Reuse');
$actionIcon1 = get_lang('MustBeInATest');
$actionIcon2 = "";
$actionIcon2 = '';
// We are not in this course, to messy if we link to the question in another course
$questionTagA = 0;
}
@ -682,51 +689,52 @@ if ($fromExercise <= 0) {
// IN A TEST - IN THE COURSE
if ($selected_course == api_get_course_int_id()) {
$actionLabel = get_lang('Reuse');
$actionIcon1 = "add";
$actionIcon2 = "";
$actionIcon1 = 'add';
$actionIcon2 = '';
$questionTagA = 1;
} else {
// IN A TEST - NOT IN THE COURSE
$actionLabel = get_lang('Reuse');
$actionIcon1 = "clone";
$actionIcon2 = "";
$actionIcon1 = 'clone';
$actionIcon2 = '';
$questionTagA = 0;
}
}
// Display table
$header = [
[
get_lang('QuestionUpperCaseFirstLetter'),
false,
["style" => "text-align:center"],
['style' => 'text-align:center'],
'',
],
[
get_lang('Type'),
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
[
get_lang('QuestionCategory'),
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
[
get_lang('Difficulty'),
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
[
$actionLabel,
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
];
@ -735,20 +743,9 @@ $data = [];
if (is_array($mainQuestionList)) {
foreach ($mainQuestionList as $question) {
/*if ($hideDoubles) {
if (in_array($question['question'], $questionAdded)) {
continue;
}
}
$questionAdded[$question['question']] = $question;*/
$row = [];
// This function checks if the question can be read
$question_type = get_question_type_for_question(
$selected_course,
$question['id']
);
$question_type = get_question_type_for_question($selected_course, $question['id']);
if (empty($question_type)) {
continue;
@ -779,7 +776,7 @@ if (is_array($mainQuestionList)) {
$answerType,
$session_id,
$exerciseId
)."&nbsp;".
).'&nbsp;'.
get_action_icon_for_question(
$actionIcon2,
$fromExercise,
@ -900,7 +897,6 @@ function get_action_icon_for_question(
$in_session_id,
$in_exercise_id
) {
$res = "";
$getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
switch ($in_action) {
case 'delete':
@ -931,7 +927,8 @@ function get_action_icon_for_question(
unset($myObjEx);
break;
case 'clone':
$url = api_get_self()."?".api_get_cidreq().$getParams."&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise";
$url = api_get_self()."?".api_get_cidreq().$getParams.
"&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise";
$res = Display::url(
Display::return_icon('cd.png', get_lang('ReUseACopyInCurrentTest')),
$url
@ -968,9 +965,9 @@ function get_question_type_for_question($in_selectedcourse, $in_questionid)
*
* @author hubert.borderiou 13-10-2011
*/
function get_question_categorie_for_question($in_courseid, $in_questionid)
function get_question_categorie_for_question($courseId, $questionId)
{
$cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid);
$cat = TestCategory::getCategoryNameForQuestion($questionId, $courseId);
return $cat;
}

@ -739,6 +739,7 @@ class GradebookTable extends SortableTable
$totalRanking,
SCORE_DIV,
SCORE_BOTH,
true,
true
);

@ -455,11 +455,11 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
user.firstname AS col2,"
)."
user.email AS col3
FROM $table_user user INNER JOIN
$table_group_user group_rel_user
FROM $table_user user
INNER JOIN $table_group_user group_rel_user
ON (group_rel_user.user_id = user.id)
INNER JOIN $tableGroup g
ON (group_rel_user.group_id = g.id)
ON (group_rel_user.group_id = g.iid)
WHERE
group_rel_user.c_id = $course_id AND
g.iid = '".$groupInfo['iid']."'
@ -480,7 +480,7 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
INNER JOIN $table_group_user gu
ON (gu.user_id = u.id)
INNER JOIN $tableGroup g
ON (gu.group_id = g.id)
ON (gu.group_id = g.iid)
WHERE
g.iid = '".$groupInfo['iid']."' AND
gu.c_id = $course_id
@ -501,7 +501,7 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
INNER JOIN $table_group_user group_rel_user
ON (group_rel_user.user_id = user.id)
INNER JOIN $tableGroup g
ON (group_rel_user.group_id = g.id)
ON (group_rel_user.group_id = g.iid)
WHERE
g.iid = '".$groupInfo['iid']."' AND
group_rel_user.c_id = $course_id AND

@ -28,9 +28,9 @@ switch ($action) {
break;
}
$add_as_announcement = isset($_REQUEST['add_as_annonuncement']) ? $_REQUEST['add_as_annonuncement'] : null;
$title = isset($_REQUEST['title']) ? Security::remove_XSS($_REQUEST['title']) : null;
$content = isset($_REQUEST['content']) ? Security::remove_XSS($_REQUEST['content']) : null;
$comment = isset($_REQUEST['comment']) ? Security::remove_XSS($_REQUEST['comment']) : null;
$title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
$content = isset($_REQUEST['content']) ? $_REQUEST['content'] : null;
$comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : null;
$userToSend = isset($_REQUEST['users_to_send']) ? $_REQUEST['users_to_send'] : [];
echo $agenda->addEvent(

@ -26,20 +26,22 @@ switch ($action) {
if (empty($folderId)) {
exit;
}
$lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : null;
$url = isset($_GET['url']) ? $_GET['url'] : null;
$lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : false;
$url = isset($_GET['url']) ? $_GET['url'] : '';
$addMove = isset($_GET['add_move_button']) && $_GET['add_move_button'] == 1 ? true : false;
echo DocumentManager::get_document_preview(
$courseInfo,
$lpId,
null,
api_get_session_id(),
true,
$addMove,
null,
$url,
true,
false,
$folderId
$folderId,
false
);
break;
case 'add_lp_item':

@ -8,8 +8,6 @@ use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
*/
require_once __DIR__.'/../global.inc.php';
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
api_protect_admin_script();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\ExtraFieldValues;
use Chamilo\CourseBundle\Entity\CAnnouncement;
use Chamilo\CourseBundle\Entity\CItemProperty;
@ -1620,8 +1621,11 @@ class AnnouncementManager
$extraGroupCondition = " AND ip.to_group_id = $group_id ";
}
if ((api_is_allowed_to_edit(false, true) || api_is_drh()) &&
($allowUserEditSetting && !api_is_anonymous())
$allowDrhAccess = api_get_configuration_value('allow_drh_access_announcement');
if (api_is_allowed_to_edit(false, true) ||
($allowUserEditSetting && !api_is_anonymous()) ||
($allowDrhAccess && api_is_drh())
) {
// A.1. you are a course admin with a USER filter
// => see only the messages of this specific user + the messages of the group (s)he is member of.
@ -1759,8 +1763,8 @@ class AnnouncementManager
ip.tool='announcement'
$cond_user_id
$condition_session
$searchCondition
AND ip.visibility='1'
$searchCondition AND
ip.visibility='1'
$groupBy
ORDER BY display_order DESC";
} else {
@ -1768,14 +1772,12 @@ class AnnouncementManager
if ($allowUserEditSetting && !api_is_anonymous()) {
$cond_user_id = " AND (
ip.lastedit_user_id = '".api_get_user_id()."' OR
(
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND
((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND
(ip.to_group_id='0' OR ip.to_group_id IS NULL)
)
) ";
} else {
$cond_user_id = " AND (
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND
$cond_user_id = " AND ((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND
(ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
}
@ -1823,8 +1825,8 @@ class AnnouncementManager
}
if (!is_null($start) && !is_null($limit)) {
$start = intval($start);
$limit = intval($limit);
$start = (int) $start;
$limit = (int) $limit;
$sql .= " LIMIT $start, $limit";
}

File diff suppressed because it is too large Load Diff

@ -21,7 +21,8 @@ class AddCourse
* @param bool Add unique prefix
* @param bool Use code-independent keys
*
* @return array An array with the needed keys ['currentCourseCode'], ['currentCourseId'], ['currentCourseDbName'], ['currentCourseRepository']
* @return array An array with the needed keys ['currentCourseCode'], ['currentCourseId'], ['currentCourseDbName'],
* ['currentCourseRepository']
*
* @todo Eliminate the global variables.
* @assert (null) === false
@ -401,9 +402,7 @@ class AddCourse
/**
* Fills the course database with some required content and example content.
*
* @param int Course (int) ID
* @param string Course directory name (e.g. 'ABC')
* @param string Language used for content (e.g. 'spanish')
* @param array $courseInfo
* @param bool Whether to fill the course with example content
* @param int $authorId
*
@ -414,18 +413,16 @@ class AddCourse
* @assert (1, 'ABC', null, null) === false
* @assert (1, 'TEST', 'spanish', true) === true
*/
public static function fill_db_course(
$course_id,
$course_repository,
$language,
public static function fillCourse(
$courseInfo,
$fill_with_exemplary_content = null,
$authorId = 0
) {
if (is_null($fill_with_exemplary_content)) {
$fill_with_exemplary_content = api_get_setting('example_material_course_creation') !== 'false';
}
$course_id = (int) $course_id;
$courseInfo = api_get_course_info_by_id($course_id);
$course_id = (int) $courseInfo['real_id'];
if (empty($courseInfo)) {
return false;
@ -443,10 +440,9 @@ class AddCourse
$settingsManager->setCourse($course);
$alert = api_get_setting('email_alert_manager_on_new_quiz');
$defaultEmailExerciseAlert = 0;
if ($alert === 'true') {
$defaultEmailExerciseAlert = 1;
} else {
$defaultEmailExerciseAlert = 0;
}
/* course_setting table (courseinfo tool) */
@ -479,7 +475,7 @@ class AddCourse
$counter = 1;
foreach ($settings as $variable => $setting) {
$title = isset($setting['title']) ? $setting['title'] : '';
$title = $setting['title'] ?? '';
Database::query(
"INSERT INTO $TABLESETTING (id, c_id, title, variable, value, category)
VALUES ($counter, $course_id, '".$title."', '".$variable."', '".$setting['default']."', '".$setting['category']."')"
@ -488,7 +484,6 @@ class AddCourse
}
/* Course homepage tools for platform admin only */
/* Group tool */
Database::insert(
$TABLEGROUPCATEGORIES,
@ -525,7 +520,7 @@ class AddCourse
$counter++;
}
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$certificateId = 'NULL';
/* Documents */
if ($fill_with_exemplary_content) {
@ -543,140 +538,54 @@ class AddCourse
$counter++;
}
// FILL THE COURSE DOCUMENT WITH DEFAULT COURSE PICTURES
$folders_to_copy_from_default_course = [
'images',
'audio',
'flash',
'video',
'certificates',
];
$default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document/';
$default_document_array = [];
foreach ($folders_to_copy_from_default_course as $folder) {
$default_course_folder_path = $default_course_path.$folder.'/';
$files = self::browse_folders(
$default_course_folder_path,
[],
$folder
);
$finder = new Symfony\Component\Finder\Finder();
$defaultPath = api_get_path(SYS_CODE_PATH).'default_course_document';
$finder->in($defaultPath);
/** @var SplFileInfo $file */
foreach ($finder as $file) {
$path = str_replace($defaultPath, '', $file->getRealPath());
$parentName = dirname(str_replace($defaultPath, '', $file->getRealPath()));
$title = $file->getFilename();
if ($file->isDir()) {
create_unexisting_directory(
$courseInfo,
api_get_user_id(),
0,
0,
0,
$path,
$path,
$title
);
} else {
$parent = DocumentManager::getDocumentByPathInCourse($courseInfo, $parentName);
$parentId = 0;
if (!empty($parent)) {
$parent = $parent[0];
$parentId = $parent['iid'];
}
$sorted_array = self::sort_pictures($files, 'dir');
$sorted_array = array_merge(
$sorted_array,
self::sort_pictures($files, 'file')
);
$default_document_array[$folder] = $sorted_array;
}
$realPath = str_replace($defaultPath, '', $file->getRealPath());
$document = DocumentManager::addDocument(
$courseInfo,
$realPath,
'file',
$file->getSize(),
$title,
'',
null,
null,
null,
null,
null,
false,
null,
$parentId,
$file->getRealPath()
);
$example_cert_id = 0;
if (is_array($default_document_array) && count(
$default_document_array
) > 0
) {
foreach ($default_document_array as $media_type => $array_media) {
$path_documents = "/$media_type/";
/*
//hack until feature #5242 is implemented
if ($media_type == 'images') {
$media_type = 'images/gallery';
$images_folder = $sys_course_path.$course_repository."/document/images/";
if (!is_dir($images_folder)) {
//Creating index.html
mkdir($images_folder, $perm);
$fd = fopen($images_folder.'index.html', 'w');
fwrite($fd, $htmlpage);
@chmod($images_folder.'index.html', $perm_file);
}
}*/
$course_documents_folder = $sys_course_path.$course_repository."/document/$media_type/";
$default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document'.$path_documents;
/*
if (!is_dir($course_documents_folder)) {
// Creating index.html
mkdir($course_documents_folder, $perm);
$fd = fopen(
$course_documents_folder.'index.html',
'w'
);
fwrite($fd, $htmlpage);
@chmod(
$course_documents_folder.'index.html',
$perm_file
);
}*/
if (is_array($array_media) && count($array_media) > 0) {
foreach ($array_media as $key => $value) {
if (isset($value['dir']) && !empty($value['dir'])) {
if (!is_dir($course_documents_folder.$value['dir'])) {
// Inserting folder in the DB
$folder_path = substr(
$value['dir'],
0,
strlen($value['dir']) - 1
);
$temp = explode('/', $folder_path);
$title = $temp[count($temp) - 1];
//hack until feature #5242 is implemented
if ($title == 'gallery') {
$title = get_lang('DefaultCourseImages');
}
if ($media_type == 'images/gallery') {
$folder_path = 'gallery/'.$folder_path;
}
create_unexisting_directory(
$courseInfo,
api_get_user_id(),
0,
0,
0,
$path_documents.$folder_path,
$title,
$title
);
}
}
if (isset($value['file']) && !empty($value['file'])) {
if (!file_exists($default_course_path.$value['file'])) {
// Copying file
/*copy(
$default_course_path.$value['file'],
$course_documents_folder.$value['file']
);*/
$temp = explode('/', $value['file']);
//hack until feature #5242 is implemented
if ($media_type == 'images/gallery') {
$value["file"] = 'gallery/'.$value["file"];
}
//$default_course_path.$value['file']
DocumentManager::addDocument(
$courseInfo,
$default_course_path.$value['file'],
'file',
filesize($default_course_path.$value['file']),
$temp[count($temp) - 1],
''
);
// Inserting file in the DB
/*Database::query(
"INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size)
VALUES ($course_id,'$path_documents".$value["file"]."','".$temp[count($temp) - 1]."','file','$file_size')"
);
$image_id = Database:: insert_id();*/
}
}
}
if ($document && $document->getTitle() === 'default.html') {
$certificateId = $document->getIid();
}
}
}
@ -843,12 +752,12 @@ class AddCourse
// father gradebook
Database::query(
"INSERT INTO $TABLEGRADEBOOK (name, locked, generate_certificates, description, user_id, c_id, parent_id, weight, visible, certif_min_score, session_id, document_id)
VALUES ('$course_code','0',0,'',1,$course_id,0,100,0,75,NULL,$example_cert_id)"
VALUES ('$course_code','0',0,'',1,$course_id,0,100,0,75,NULL,$certificateId)"
);
$gbid = Database:: insert_id();
Database::query(
"INSERT INTO $TABLEGRADEBOOK (name, locked, generate_certificates, description, user_id, c_id, parent_id, weight, visible, certif_min_score, session_id, document_id)
VALUES ('$course_code','0',0,'',1,$course_id,$gbid,100,1,75,NULL,$example_cert_id)"
VALUES ('$course_code','0',0,'',1,$course_id,$gbid,100,1,75,NULL,$certificateId)"
);
$gbid = Database:: insert_id();
Database::query(
@ -1017,33 +926,6 @@ class AddCourse
$courseManager = Container::$container->get('chamilo_core.entity.manager.course_manager');
/** @var \Chamilo\CoreBundle\Entity\Course $course */
$course = $courseManager->create();
// Here we must add 2 fields.
/*$course_id = Database::insert(
$TABLECOURSE,
[
'code' => $code,
'directory' => $directory,
'course_language' => $course_language,
'title' => $title,
'description' => get_lang('CourseDescription'),
'category_code' => $category_code,
'visibility' => $visibility,
'show_score' => 1,
'disk_quota' => intval($disk_quota),
'creation_date' => $time,
'expiration_date' => $expiration_date,
'last_edit' => $time,
'last_visit' => null,
'tutor_name' => $tutor_name,
'department_name' => $department_name,
'department_url' => $department_url,
'subscribe' => intval($subscribe),
'unsubscribe' => intval($unsubscribe),
'visual_code' => $visual_code,
]
);*/
$urlId = 1;
if (api_get_current_access_url_id() !== -1) {
$urlId = api_get_current_access_url_id();

@ -2337,10 +2337,9 @@ class Agenda
$action = isset($params['action']) ? Security::remove_XSS($params['action']) : null;
$id = isset($params['id']) ? (int) $params['id'] : 0;
$url = api_get_self().'?action='.$action.'&id='.$id.'&type='.$this->type;
if ($this->type == 'course') {
$url = api_get_self().'?'.api_get_cidreq().'&action='.$action.'&id='.$id.'&type='.$this->type;
} else {
$url = api_get_self().'?action='.$action.'&id='.$id.'&type='.$this->type;
}
$form = new FormValidator(

@ -117,9 +117,9 @@ class Attendance
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = (int) $column;
$from = (int) $from;
$number_of_items = (int) $number_of_items;
if (!in_array($direction, ['ASC', 'DESC'])) {
$direction = 'ASC';
@ -163,6 +163,7 @@ class Attendance
if (api_get_session_id() == $attendance[6]) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
}
if ($attendance[5] == 1) {
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),

@ -88,29 +88,29 @@ class CourseManager
/**
* Creates a course.
*
* @param array $params columns in the main.course table
* @param int $authorId
* @param array $params Columns in the main.course table.
* @param int $authorId Optional.
* @param int $accessUrlId Optional.
*
* @return mixed false if the course was not created, array with the course info
*/
public static function create_course($params, $authorId = 0)
public static function create_course($params, $authorId = 0, $accessUrlId = 0)
{
global $_configuration;
$hook = HookCreateCourse::create();
// Check portal limits
$access_url_id = 1;
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
}
$accessUrlId = empty($accessUrlId)
? (api_get_multiple_access_url() ? api_get_current_access_url_id() : 1)
: $accessUrlId;
$authorId = empty($authorId) ? api_get_user_id() : (int) $authorId;
if (isset($_configuration[$access_url_id]) && is_array($_configuration[$access_url_id])) {
if (isset($_configuration[$accessUrlId]) && is_array($_configuration[$accessUrlId])) {
$return = self::checkCreateCourseAccessUrlParam(
$_configuration,
$access_url_id,
$accessUrlId,
'hosting_limit_courses',
'PortalCoursesLimitReached'
);
@ -119,7 +119,7 @@ class CourseManager
}
$return = self::checkCreateCourseAccessUrlParam(
$_configuration,
$access_url_id,
$accessUrlId,
'hosting_limit_active_courses',
'PortalActiveCoursesLimitReached'
);
@ -153,7 +153,7 @@ class CourseManager
$params['directory'] = $keys['currentCourseRepository'];
$courseInfo = api_get_course_info($params['code']);
if (empty($courseInfo)) {
$courseId = AddCourse::register_course($params);
$courseId = AddCourse::register_course($params, $accessUrlId);
$courseInfo = api_get_course_info_by_id($courseId);
if ($hook) {
@ -6845,10 +6845,8 @@ class CourseManager
$authorId = empty($authorId) ? api_get_user_id() : (int) $authorId;
AddCourse::prepare_course_repository($courseInfo['directory']);
AddCourse::fill_db_course(
$courseInfo['real_id'],
$courseInfo['directory'],
$courseInfo['course_language'],
AddCourse::fillCourse(
$courseInfo,
$params['exemplary_content'],
$authorId
);

@ -133,9 +133,10 @@ class CourseHome
}
foreach ($all_tools as &$tool) {
if ($tool['image'] == 'scormbuilder.gif') {
if (isset($tool['image']) && $tool['image'] == 'scormbuilder.gif') {
// check if the published learnpath is visible for student
$lpId = self::getPublishedLpIdFromLink($tool['link']);
if (!api_is_allowed_to_edit(null, true) &&
!learnpath::is_lp_visible_for_student(
$lpId,
@ -175,6 +176,7 @@ class CourseHome
// Setting the actual image url
$tool['img'] = Display::returnIconPath($tool['img']);
$target = isset($tool['target']) ? $tool['target'] : '';
// VISIBLE
if (($tool['visibility'] ||
@ -190,7 +192,7 @@ class CourseHome
$cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} else {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
$cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$target.'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
}
} else {
// INVISIBLE
@ -341,8 +343,8 @@ class CourseHome
$all_tools_list[] = $properties;
}
}
$lnk = [];
if (isset($all_tools_list)) {
$lnk = [];
foreach ($all_tools_list as &$tool) {
if ($tool['image'] == 'scormbuilder.gif') {
// check if the published learnpath is visible for student
@ -391,7 +393,9 @@ class CourseHome
} elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
$html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq().'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'" '.$class.'>';
} else {
$html .= '<a href="'.htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$tool['target'].'" '.$class.'>';
$target = isset($tool['target']) ? $tool['target'] : '';
$html .= '<a href="'.
htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$target.'" '.$class.'>';
}
$tool_name = self::translate_tool_name($tool);
@ -406,7 +410,7 @@ class CourseHome
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
$lnk = [];
if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) {
$link['name'] = Display::returnFontAwesomeIcon('minus');
@ -759,12 +763,10 @@ class CourseHome
}
if (isset($tmp_all_tools_list)) {
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
foreach ($tmp_all_tools_list as $tool) {
if ($tool['image'] == 'blog.gif') {
// Init
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
// Get blog id
$blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link']));
// Get blog members
@ -802,6 +804,7 @@ class CourseHome
{
$_user = api_get_user_info();
$theme = api_get_setting('homepage_view');
if ($theme === 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = [];
@ -824,7 +827,6 @@ class CourseHome
$session_id = api_get_session_id();
$is_platform_admin = api_is_platform_admin();
$allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
if ($session_id == 0) {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin();
} else {
@ -834,7 +836,6 @@ class CourseHome
}
}
$i = 0;
$items = [];
$app_plugin = new AppPlugin();
@ -984,13 +985,12 @@ class CourseHome
$tool['link'] = $web_code_path.$tool['link'];
}
$class = '';
if ($tool['visibility'] == '0' && $toolAdmin != '1') {
$class = 'text-muted';
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
$tool['image'] = $basename.'_na.'.$info['extension'];
} else {
$class = '';
}
$qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
@ -1051,6 +1051,7 @@ class CourseHome
.$tool['original_link'].$qm_or_amp.api_get_cidreq();
}
// Use in the course home
$icon = Display::return_icon(
$tool['image'],
$tool_name,
@ -1059,6 +1060,24 @@ class CourseHome
false
);
// Used in the top bar
$iconMedium = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_MEDIUM,
false
);
// Used for vertical navigation
$iconSmall = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-img', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_SMALL,
false
);
/*if (!empty($tool['custom_icon'])) {
$image = self::getCustomWebIconPath().$tool['custom_icon'];
$icon = Display::img(
@ -1081,6 +1100,10 @@ class CourseHome
}
$item['url_params'] = $tool_link_params;
$item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
$item['only_icon'] = $icon;
$item['only_icon_medium'] = $iconMedium;
$item['only_icon_small'] = $iconSmall;
$item['only_href'] = $tool_link_params['href'];
$item['tool'] = $tool;
$item['name'] = $tool_name;
$tool_link_params['id'] = 'is'.$tool_link_params['id'];
@ -1090,21 +1113,21 @@ class CourseHome
$tool_link_params
);
$items[] = $item;
$i++;
} // end of foreach
}
if (api_get_setting('homepage_view') != 'activity_big') {
return $items;
}
foreach ($items as &$item) {
$originalImage = self::getToolIcon($item);
$item['tool']['image'] = Display::url(
$originalImage,
$item['url_params']['href'],
$item['url_params']
);
$originalImage = self::getToolIcon($item, ICON_SIZE_BIG);
$item['tool']['only_icon_medium'] = self::getToolIcon($item, ICON_SIZE_MEDIUM, false);
$item['tool']['only_icon_small'] = self::getToolIcon($item, ICON_SIZE_SMALL, false);
if ($theme === 'activity_big') {
$item['tool']['image'] = Display::url(
$originalImage,
$item['url_params']['href'],
$item['url_params']
);
}
}
return $items;
@ -1183,13 +1206,15 @@ class CourseHome
$toolName = Security::remove_XSS(stripslashes($tool['name']));
if (in_array($tool['image'], $already_translated_icons)) {
if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) {
return $toolName;
}
$toolName = api_underscore_to_camel_case($toolName);
if (isset($GLOBALS['Tool'.$toolName])) {
if (isset($tool['category']) && 'plugin' !== $tool['category'] &&
isset($GLOBALS['Tool'.$toolName])
) {
return get_lang('Tool'.$toolName);
}
@ -1236,121 +1261,12 @@ class CourseHome
return $category;
}
/**
* @param bool $include_admin_tools
*
* @return array
*/
public static function get_navigation_items($include_admin_tools = false)
{
$navigation_items = [];
$course_id = api_get_course_int_id();
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$conditionSession = api_get_session_condition(
$sessionId,
true,
true,
'session_id'
);
if (!empty($course_id)) {
$course_tools_table = Database::get_course_table(TABLE_TOOL_LIST);
/* Link to the Course homepage */
$navigation_items['home']['image'] = 'home.png';
$navigation_items['home']['link'] = $courseInfo['course_public_url'];
$navigation_items['home']['name'] = get_lang('CourseHomepageLink');
$sql = "SELECT * FROM $course_tools_table
WHERE
c_id = $course_id AND
visibility = '1' AND
admin = '0'
$conditionSession
ORDER BY id ASC";
$result = Database::query($sql);
$hideTools = [];
$hideToolsKeys = [];
if (!api_is_platform_admin()) {
$hideTools = api_get_setting('course_hide_tools');
$hideToolsKeys = array_keys($hideTools);
}
while ($row = Database::fetch_array($result)) {
if (!empty($hideTools)) {
if (in_array($row['name'], $hideToolsKeys)) {
// Tool is hidden
if ($hideTools[$row['name']] == 'true') {
continue;
}
}
}
$navigation_items[$row['id']] = $row;
if (stripos($row['link'], 'http://') === false &&
stripos($row['link'], 'https://') === false
) {
$navigation_items[$row['id']]['link'] = api_get_path(WEB_CODE_PATH);
if ($row['category'] == 'plugin') {
$plugin = new AppPlugin();
$pluginInfo = $plugin->getPluginInfo($row['name']);
if (isset($pluginInfo['title'])) {
$navigation_items[$row['id']]['link'] = api_get_path(WEB_PLUGIN_PATH);
$navigation_items[$row['id']]['name'] = $pluginInfo['title'];
}
} else {
$navigation_items[$row['id']]['name'] = self::translate_tool_name($row);
}
$navigation_items[$row['id']]['link'] .= $row['link'];
}
}
/* Admin (edit rights) only links
- Course settings (course admin only)
- Course rights (roles & rights overview) */
if ($include_admin_tools) {
$sql = "SELECT name, image FROM $course_tools_table
WHERE c_id = $course_id AND link='course_info/infocours.php'";
$sql_result = Database::query($sql);
$course_setting_info = Database::fetch_array($sql_result);
$course_setting_visual_name = self::translate_tool_name($course_setting_info);
if ($sessionId == 0) {
// course settings item
$navigation_items['course_settings']['image'] = $course_setting_info['image'];
$navigation_items['course_settings']['link'] = api_get_path(WEB_CODE_PATH).'course_info/infocours.php';
$navigation_items['course_settings']['name'] = $course_setting_visual_name;
}
}
}
foreach ($navigation_items as $key => $navigation_item) {
if (strstr($navigation_item['link'], '?')) {
//link already contains a parameter, add course id parameter with &
$parameter_separator = '&amp;';
} else {
//link doesn't contain a parameter yet, add course id parameter with ?
$parameter_separator = '?';
}
//$navigation_items[$key]['link'] .= $parameter_separator.api_get_cidreq();
$navigation_items[$key]['link'] .= $parameter_separator.'cidReq='.api_get_course_id().'&gidReq=0&id_session='.$sessionId;
}
return $navigation_items;
}
/**
* Show a navigation menu.
*/
public static function show_navigation_menu()
{
$navigation_items = self::get_navigation_items(true);
$course_id = api_get_course_id();
$blocks = self::getUserBlocks();
$class = null;
$idLearn = null;
$item = null;
@ -1358,62 +1274,37 @@ class CourseHome
$html = '<div id="toolnav">';
$html .= '<ul id="toolnavbox">';
$count = 0;
foreach ($navigation_items as $key => $navigation_item) {
//students can't see the course settings option
$count++;
if (!api_is_allowed_to_edit() && $key == 'course_settings') {
continue;
}
$html .= '<li>';
$url_item = parse_url($navigation_item['link']);
$url_current = parse_url($_SERVER['REQUEST_URI']);
$showOnlyText = api_get_setting('show_navigation_menu') === 'text';
$showOnlyIcons = api_get_setting('show_navigation_menu') === 'icons';
if (api_get_setting('show_navigation_menu') == 'text') {
foreach ($blocks as $block) {
$blockItems = $block['content'];
foreach ($blockItems as $item) {
$html .= '<li>';
if ($showOnlyText) {
$class = 'text';
$marginLeft = 170;
$item = $navigation_item['name'];
} elseif (api_get_setting('show_navigation_menu') == 'icons') {
$class = 'icons';
$marginLeft = 25;
$item = Display::return_icon(
substr($navigation_item['image'], 0, -3)."png",
$navigation_item['name'],
['class' => 'tool-img'],
ICON_SIZE_SMALL
);
} else {
$class = 'icons-text';
$item = $navigation_item['name'].
Display::return_icon(
substr($navigation_item['image'], 0, -3)."png",
$navigation_item['name'],
['class' => 'tool-img'],
ICON_SIZE_SMALL
);
}
if (stristr($url_item['path'], $url_current['path'])) {
if (!isset($_GET['learnpath_id']) || strpos($url_item['query'], 'learnpath_id='.intval($_GET['learnpath_id'])) === 0) {
$idLearn = ' id="here"';
$show = $item['name'];
} elseif ($showOnlyIcons) {
$class = 'icons';
$marginLeft = 25;
$show = $item['tool']['only_icon_small'];
} else {
$class = 'icons-text';
$show = $item['name'].$item['tool']['only_icon_small'];
}
}
if (strpos($navigation_item['link'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window', $course_id)
) {
$html .= '<a '.$idLearn.' class="btn btn-default text-left '.$class.' " href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['link'].'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$navigation_item['target'].'"';
$html .= ' title="'.$navigation_item['name'].'">';
$html .= $item;
$html .= '</a>';
} else {
$html .= '<a '.$idLearn.' class="btn btn-default text-left '.$class.'" href="'.$navigation_item['link'].'" target="_top" title="'.$navigation_item['name'].'">';
$html .= $item;
$html .= '</a>';
}
$item['url_params']['class'] = 'btn btn-default text-left '.$class;
$html .= Display::url(
$show,
$item['only_href'],
$item['url_params']
);
$html .= '</li>';
}
}
$html .= '</ul>';
$html .= '<script>$(function() {
$("#toolnavbox a").stop().animate({"margin-left":"-'.$marginLeft.'px"},1000);
@ -1443,52 +1334,40 @@ class CourseHome
public static function getCourseToolBar($orientation = SHORTCUTS_HORIZONTAL): string
{
$origin = api_get_origin();
$courseInfo = api_get_course_info();
if ($origin === 'learnpath') {
return '';
}
$navigation_items = self::get_navigation_items(false);
$blocks = self::getUserBlocks();
$html = '';
if (!empty($navigation_items)) {
if (!empty($blocks)) {
$style_id = 'toolshortcuts_vertical';
if ($orientation === SHORTCUTS_HORIZONTAL) {
if ($orientation == SHORTCUTS_HORIZONTAL) {
$style_id = 'toolshortcuts_horizontal';
}
$html .= '<div id="'.$style_id.'">';
foreach ($navigation_items as $key => $navigation_item) {
if (strpos($navigation_item['link'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window')
) {
$html .= '<a class="items-icon" href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['link'].'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$navigation_item['target'].'"';
} else {
$html .= '<a class="items-icon" href="'.$navigation_item['link'].'"';
}
if (strpos(api_get_self(), $navigation_item['link']) !== false) {
$html .= ' id="here"';
}
$html .= ' target="_top" title="'.$navigation_item['name'].'">';
if (isset($navigation_item['category']) && $navigation_item['category'] == 'plugin') {
/*$plugin_info = $app_plugin->getPluginInfo($navigation_item['name']);
if (isset($plugin_info) && isset($plugin_info['title'])) {
$tool_name = $plugin_info['title'];
}*/
if (!file_exists(api_get_path(SYS_CODE_PATH).'img/'.$navigation_item['image']) &&
!file_exists(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_MEDIUM.'/'.$navigation_item['image'])
) {
$navigation_item['image'] = 'plugins.png';
}
}
$html .= Display::url(
Display::return_icon('home.png', get_lang('CourseHomepageLink'), '', ICON_SIZE_MEDIUM),
$courseInfo['course_public_url'],
['class' => 'items-icon']
);
$html .= Display::return_icon(
substr($navigation_item['image'], 0, -3).'png',
$navigation_item['name'],
[],
ICON_SIZE_MEDIUM
);
$html .= '</a> ';
if ($orientation == SHORTCUTS_VERTICAL) {
$html .= '<br />';
foreach ($blocks as $block) {
$blockItems = $block['content'];
foreach ($blockItems as $item) {
$item['url_params']['id'] = '';
$item['url_params']['class'] = 'items-icon';
$html .= Display::url(
$item['tool']['only_icon_medium'],
$item['only_href'],
$item['url_params']
);
if ($orientation == SHORTCUTS_VERTICAL) {
$html .= '<br />';
}
}
}
$html .= '</div>';
@ -1688,6 +1567,145 @@ class CourseHome
}
}
/**
* @return array
*/
public static function getCourseAdminBlocks()
{
$blocks = [];
$my_list = self::get_tools_category(TOOL_AUTHORING);
$blocks[] = [
'title' => get_lang('Authoring'),
'class' => 'course-tools-author',
'content' => self::show_tools_category($my_list),
];
$list1 = self::get_tools_category(TOOL_INTERACTION);
$list2 = self::get_tools_category(TOOL_COURSE_PLUGIN);
$my_list = array_merge($list1, $list2);
$blocks[] = [
'title' => get_lang('Interaction'),
'class' => 'course-tools-interaction',
'content' => self::show_tools_category($my_list),
];
$my_list = self::get_tools_category(TOOL_ADMIN_PLATFORM);
$blocks[] = [
'title' => get_lang('Administration'),
'class' => 'course-tools-administration',
'content' => self::show_tools_category($my_list),
];
return $blocks;
}
/**
* @return array
*/
public static function getCoachBlocks()
{
$blocks = [];
$my_list = self::get_tools_category(TOOL_STUDENT_VIEW);
$blocks[] = [
'content' => self::show_tools_category($my_list),
];
$sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
if ($sessionsCopy === 'true') {
// Adding only maintenance for coaches.
$myList = self::get_tools_category(TOOL_ADMIN_PLATFORM);
$onlyMaintenanceList = [];
foreach ($myList as $item) {
if ($item['name'] === 'course_maintenance') {
$item['link'] = 'course_info/maintenance_coach.php';
$onlyMaintenanceList[] = $item;
}
}
$blocks[] = [
'title' => get_lang('Administration'),
'content' => self::show_tools_category($onlyMaintenanceList),
];
}
return $blocks;
}
/**
* @return array
*/
public static function getStudentBlocks()
{
$blocks = [];
$tools = self::get_tools_category(TOOL_STUDENT_VIEW);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
// Force user icon for DRH
if ($isDrhOfCourse) {
$addUserTool = true;
foreach ($tools as $tool) {
if ($tool['name'] === 'user') {
$addUserTool = false;
break;
}
}
if ($addUserTool) {
$tools[] = [
'c_id' => api_get_course_int_id(),
'name' => 'user',
'link' => 'user/user.php',
'image' => 'members.gif',
'visibility' => '1',
'admin' => '0',
'address' => 'squaregrey.gif',
'added_tool' => '0',
'target' => '_self',
'category' => 'interaction',
'session_id' => api_get_session_id(),
];
}
}
if (count($tools) > 0) {
$blocks[] = ['content' => self::show_tools_category($tools)];
}
if ($isDrhOfCourse) {
$drhTool = self::get_tools_category(TOOL_DRH);
$blocks[] = ['content' => self::show_tools_category($drhTool)];
}
return $blocks;
}
/**
* @return array
*/
public static function getUserBlocks()
{
$sessionId = api_get_session_id();
// Start of tools for CourseAdmins (teachers/tutors)
if ($sessionId === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$blocks = self::getCourseAdminBlocks();
} elseif (api_is_coach()) {
$blocks = self::getCoachBlocks();
} else {
$blocks = self::getStudentBlocks();
}
return $blocks;
}
/**
* Filter tool icons. Only show if $patronKey is = :teacher
* Example dataIcons[i]['name']: parameter titleIcons1:teacher || titleIcons2 || titleIcons3:teacher.
@ -1749,10 +1767,12 @@ class CourseHome
* Find the tool icon when homepage_view is activity_big.
*
* @param array $item
* @param int $iconSize
* @param bool $generateId
*
* @return string
*/
private static function getToolIcon(array $item)
private static function getToolIcon(array $item, $iconSize, $generateId = true)
{
$image = str_replace('.gif', '.png', $item['tool']['image']);
$toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null;
@ -1779,11 +1799,16 @@ class CourseHome
);
}
$id = '';
if ($generateId) {
$id = 'toolimage_'.$toolIid;
}
return Display::return_icon(
'tool_'.$image,
$image,
$item['name'],
['id' => 'toolimage_'.$toolIid],
ICON_SIZE_BIG,
['id' => $id],
$iconSize,
false
);
}

@ -431,7 +431,7 @@ class DocumentManager
*/
public static function getSessionFolderFilters($path, $sessionId)
{
$sessionId = intval($sessionId);
$sessionId = (int) $sessionId;
$condition = null;
if (!empty($sessionId)) {
@ -638,7 +638,7 @@ class DocumentManager
* Gets the paths of all folders in a course
* can show all folders (except for the deleted ones) or only visible ones.
*
* @param array $_course
* @param array $courseInfo
* @param int $groupIid iid
* @param bool $can_see_invisible
* @param bool $getInvisibleList
@ -647,19 +647,20 @@ class DocumentManager
* @return array with paths
*/
public static function get_all_document_folders(
$_course,
$courseInfo,
$groupIid = 0,
$can_see_invisible = false,
$getInvisibleList = false,
$path = ''
) {
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$groupIid = intval($groupIid);
$document_folders = [];
$groupIid = (int) $groupIid;
$courseId = $courseInfo['real_id'];
$sessionId = api_get_session_id();
$folders = [];
$students = CourseManager::get_user_list_from_course_code(
$_course['code'],
$courseInfo['code'],
api_get_session_id()
);
@ -670,9 +671,9 @@ class DocumentManager
}
}
$groupCondition = " l.to_group_id = $groupIid";
$groupCondition = " l.group_id = $groupIid";
if (empty($groupIid)) {
$groupCondition = " (l.group_id = 0 OR l.group_id IS NULL)";
$groupCondition = ' (l.group_id = 0 OR l.group_id IS NULL)';
}
$show_users_condition = '';
@ -681,50 +682,32 @@ class DocumentManager
}
if ($can_see_invisible) {
// condition for the session
$session_id = api_get_session_id();
$session_id = $session_id ?: api_get_session_id();
$condition_session = " AND (l.session_id = '$session_id' OR (l.session_id = '0' OR l.session_id IS NULL) )";
$condition_session .= self::getSessionFolderFilters($path, $session_id);
$sessionId = $sessionId ?: api_get_session_id();
$condition_session = " AND (l.session_id = '$sessionId' OR (l.session_id = '0' OR l.session_id IS NULL) )";
$condition_session .= self::getSessionFolderFilters($path, $sessionId);
$sql = "SELECT DISTINCT docs.id, docs.path
FROM resource_node AS n
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.resource_node_id = n.id)
INNER JOIN resource_link l
ON (l.resource_node_id = n.id)
WHERE
docs.c_id = $courseId AND
docs.filetype = 'folder' AND
$groupCondition AND
docs.path NOT LIKE '%shared_folder%' AND
docs.path NOT LIKE '%_DELETED_%' AND
l.visibility NOT IN ('".ResourceLink::VISIBILITY_DELETED."')
$condition_session ";
if ($groupIid != 0) {
$sql = "SELECT DISTINCT docs.id, path
FROM $TABLE_ITEMPROPERTY AS last
INNER JOIN $TABLE_DOCUMENT AS docs
ON (
docs.id = last.ref AND
docs.c_id = last.c_id
)
WHERE
last.tool = '".TOOL_DOCUMENT."' AND
last.c_id = {$_course['real_id']} AND
docs.c_id = {$_course['real_id']} AND
docs.filetype = 'folder' AND
$groupCondition AND
docs.path NOT LIKE '%shared_folder%' AND
docs.path NOT LIKE '%_DELETED_%' AND
last.visibility <> 2
$condition_session ";
$sql .= " AND docs.path NOT LIKE '%shared_folder%' ";
} else {
$sql = "SELECT DISTINCT docs.id, docs.path
FROM resource_node AS n
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.resource_node_id = n.id)
INNER JOIN resource_link l
ON (l.resource_node_id = n.id)
WHERE
docs.c_id = {$_course['real_id']} AND
docs.filetype = 'folder' AND
docs.path NOT LIKE '%_DELETED_%' AND
$groupCondition AND
l.visibility NOT IN ('".ResourceLink::VISIBILITY_DELETED."')
$show_users_condition
$condition_session
";
$sql .= $show_users_condition;
}
$result = Database::query($sql);
if ($result && Database::num_rows($result) != 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
if (self::is_folder_to_avoid($row['path'])) {
@ -737,53 +720,49 @@ class DocumentManager
}
}
$document_folders[$row['id']] = $row['path'];
$folders[$row['id']] = $row['path'];
}
if (!empty($document_folders)) {
natsort($document_folders);
if (!empty($folders)) {
natsort($folders);
}
return $document_folders;
return $folders;
} else {
return false;
}
} else {
// No invisible folders
// Condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition(
$session_id,
$sessionId,
true,
false,
'docs.session_id'
);
$visibilityCondition = 'last.visibility = 1';
$visibilityCondition = 'l.visibility = 1';
$fileType = "docs.filetype = 'folder' AND";
if ($getInvisibleList) {
$visibilityCondition = 'last.visibility = 0';
$visibilityCondition = 'l.visibility = 0';
$fileType = '';
}
//get visible folders
$sql = "SELECT DISTINCT docs.id, path
FROM
$TABLE_ITEMPROPERTY AS last
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.id = last.ref AND last.c_id = docs.c_id)
$sql = "SELECT DISTINCT docs.id, docs.path
FROM resource_node AS n
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.resource_node_id = n.id)
INNER JOIN resource_link l
ON (l.resource_node_id = n.id)
WHERE
$fileType
last.tool = '".TOOL_DOCUMENT."' AND
$fileType
$groupCondition AND
$visibilityCondition
$show_users_condition
$condition_session AND
last.c_id = {$_course['real_id']} AND
docs.c_id = {$_course['real_id']} ";
$condition_session AND
docs.c_id = $courseId ";
$result = Database::query($sql);
$visibleFolders = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$visibleFolders[$row['id']] = $row['path'];
@ -793,34 +772,36 @@ class DocumentManager
return $visibleFolders;
}
//get invisible folders
$sql = "SELECT DISTINCT docs.id, path
FROM $TABLE_ITEMPROPERTY AS last
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.id = last.ref AND last.c_id = docs.c_id)
// get invisible folders
$sql = "SELECT DISTINCT docs.id, docs.path
FROM resource_node AS n
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.resource_node_id = n.id)
INNER JOIN resource_link l
ON (l.resource_node_id = n.id)
WHERE
docs.filetype = 'folder' AND
last.tool = '".TOOL_DOCUMENT."' AND
$groupCondition AND
last.visibility = 0 $condition_session AND
last.c_id = {$_course['real_id']} AND
docs.c_id = {$_course['real_id']} ";
docs.filetype = 'folder' AND
$groupCondition AND
l.visibility IN ('".ResourceLink::VISIBILITY_PENDING."')
$condition_session AND
docs.c_id = $courseId ";
$result = Database::query($sql);
$invisibleFolders = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
//get visible folders in the invisible ones -> they are invisible too
$sql = "SELECT DISTINCT docs.id, path
FROM $TABLE_ITEMPROPERTY AS last
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.id = last.ref AND docs.c_id = last.c_id)
$sql = "SELECT DISTINCT docs.id, docs.path
FROM resource_node AS n
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.resource_node_id = n.id)
INNER JOIN resource_link l
ON (l.resource_node_id = n.id)
WHERE
docs.path LIKE '".Database::escape_string($row['path'].'/%')."' AND
docs.filetype = 'folder' AND
last.tool = '".TOOL_DOCUMENT."' AND
docs.filetype = 'folder' AND
$groupCondition AND
last.visibility = 1 $condition_session AND
last.c_id = {$_course['real_id']} AND
docs.c_id = {$_course['real_id']} ";
l.visibility NOT IN ('".ResourceLink::VISIBILITY_DELETED."')
$condition_session AND
docs.c_id = $courseId ";
$folder_in_invisible_result = Database::query($sql);
while ($folders_in_invisible_folder = Database::fetch_array($folder_in_invisible_result, 'ASSOC')) {
$invisibleFolders[$folders_in_invisible_folder['id']] = $folders_in_invisible_folder['path'];
@ -829,18 +810,20 @@ class DocumentManager
// If both results are arrays -> //calculate the difference between the 2 arrays -> only visible folders are left :)
if (is_array($visibleFolders) && is_array($invisibleFolders)) {
$document_folders = array_diff($visibleFolders, $invisibleFolders);
natsort($document_folders);
$folders = array_diff($visibleFolders, $invisibleFolders);
natsort($folders);
return $folders;
}
return $document_folders;
} elseif (is_array($visibleFolders)) {
if (is_array($visibleFolders)) {
natsort($visibleFolders);
return $visibleFolders;
} else {
//no visible folders found
return false;
}
// no visible folders found
return false;
}
}
@ -851,7 +834,7 @@ class DocumentManager
* @param array $_course
* @param int $user_id id of the current user
* @param string $file path stored in the database (if not defined, $documentId must be used)
* @param int $document_id in case you dont have the file path ,
* @param int $document_id in case you don't have the file path ,
* insert the id of the file here and leave $file in blank ''
* @param bool $to_delete
* @param int $sessionId
@ -867,16 +850,13 @@ class DocumentManager
$sessionId = null,
$documentId = null
) {
$sessionId = (int) $sessionId;
if (empty($sessionId)) {
$sessionId = api_get_session_id();
} else {
$sessionId = intval($sessionId);
}
if (empty($document_id) || !is_numeric($document_id)) {
$document_id = (int) $document_id;
if (empty($document_id)) {
$document_id = self::get_document_id($_course, $file, $sessionId);
} else {
$document_id = intval($document_id);
}
$TABLE_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -884,7 +864,7 @@ class DocumentManager
$course_id = $_course['real_id'];
if ($to_delete) {
if (self::is_folder($_course, $document_id)) {
if (self::isFolder($_course, $document_id)) {
if (!empty($file)) {
$path = Database::escape_string($file);
// Check
@ -952,7 +932,7 @@ class DocumentManager
*
* @return bool true/false
* */
public static function is_folder($_course, $id)
public static function isFolder($_course, $id)
{
$table = Database::get_course_table(TABLE_DOCUMENT);
if (empty($_course)) {
@ -964,7 +944,7 @@ class DocumentManager
WHERE c_id = $course_id AND id= $id";
$result = Database::fetch_array(Database::query($sql), 'ASSOC');
return $result['filetype'] == 'folder';
return $result['filetype'] === 'folder';
}
/**
@ -4380,7 +4360,7 @@ class DocumentManager
}
/**
* Check if the past is used in this course.
* Check if the path is used in this course.
*
* @param array $courseInfo
* @param string $path
@ -4648,7 +4628,7 @@ class DocumentManager
return false;
}
$sessionId = intval($sessionId);
$sessionId = (int) $sessionId;
$folderWithSuffix = self::fixDocumentName(
$folder,
'folder',
@ -4667,7 +4647,7 @@ class DocumentManager
filetype = 'folder' AND
c_id = $courseId AND
(path = '$folder' OR path = '$folderWithSuffix') AND
(session_id = 0 OR session_id = $sessionId)
(session_id = 0 OR session_id IS NULL OR session_id = $sessionId)
";
$rs = Database::query($sql);
@ -6418,13 +6398,14 @@ class DocumentManager
* @param string $title
* @param string $comment
* @param int $readonly
* @param int $visibility see ResourceLink constants
* @param int $group_id group.id
* @param int $sessionId Session ID, if any
* @param int $userId creator user id
* @param int $visibility see ResourceLink constants
* @param int $groupId group.id
* @param int $sessionId Session ID, if any
* @param int $userId creator user id
* @param bool $sendNotification
* @param string $content
* @param int $parentId
* @param string $realPath
*
* @return CDocument|false
*/
@ -6437,15 +6418,15 @@ class DocumentManager
$comment = null,
$readonly = 0,
$visibility = null,
$group_id = 0,
$groupId = 0,
$sessionId = 0,
$userId = 0,
$sendNotification = true,
$content = '',
$parentId = 0
$parentId = 0,
$realPath = ''
) {
$userId = empty($userId) ? api_get_user_id() : $userId;
if (empty($userId)) {
return false;
}
@ -6456,19 +6437,18 @@ class DocumentManager
}
$courseEntity = api_get_course_entity($courseInfo['real_id']);
if (empty($courseEntity)) {
return false;
}
$sessionId = empty($sessionId) ? api_get_session_id() : $sessionId;
$session = api_get_session_entity($sessionId);
$group = api_get_group_entity($group_id);
$group = api_get_group_entity($groupId);
$readonly = (int) $readonly;
$em = Database::getManager();
$documentRepo = Container::$container->get('Chamilo\CourseBundle\Repository\CDocumentRepository');
//$documentRepo = $em->getRepository('ChamiloCourseBundle:CDocument');
$parentNode = null;
if (!empty($parentId)) {
@ -6508,9 +6488,10 @@ class DocumentManager
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
$media->setContext('default');
$provider = 'sonata.media.provider.image';
if (!in_array($extension, ['jpeg', 'jpg', 'gif', 'png'])) {
$provider = 'sonata.media.provider.file';
$provider = 'sonata.media.provider.file';
$isImage = in_array($extension, ['jpeg', 'jpg', 'gif', 'png']);
if ($isImage) {
$provider = 'sonata.media.provider.image';
}
$media->setProviderName($provider);
@ -6520,10 +6501,22 @@ class DocumentManager
$file = $content;
$media->setSize($file->getSize());
} else {
$handle = tmpfile();
fwrite($handle, $content);
$file = new \Sonata\MediaBundle\Extra\ApiMediaFile($handle);
$file->setMimetype($media->getContentType());
// $path points to a file in the directory
if (file_exists($realPath) && !is_dir($realPath)) {
$media->setSize(filesize($realPath));
if ($isImage) {
$size = getimagesize($realPath);
$media->setWidth($size[0]);
$media->setHeight($size[1]);
}
$file = $realPath;
} else {
// We get the content and create a file
$handle = tmpfile();
fwrite($handle, $content);
$file = new \Sonata\MediaBundle\Extra\ApiMediaFile($handle);
$file->setMimetype($media->getContentType());
}
}
$media->setBinaryContent($file);
@ -6591,7 +6584,7 @@ class DocumentManager
api_set_default_visibility(
$documentId,
TOOL_DOCUMENT,
$group_id,
$groupId,
$courseInfo,
$sessionId,
$userId

@ -3205,7 +3205,7 @@ EOT;
// only end is set
$time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
// nothing is set
$time_conditions .= " (start_time IS NULL AND end_time IS NULL)) ";
$time_conditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
}
$needle_where = !empty($search) ? " AND title LIKE '?' " : '';

@ -1563,7 +1563,7 @@ function create_unexisting_directory(
$title = basename($desired_dir_name);
}
if (!is_dir($base_work_dir.$systemFolderName)) {
//if (!is_dir($base_work_dir.$systemFolderName)) {
/*$result = mkdir(
$base_work_dir.$systemFolderName,
api_get_permissions_for_new_directories(),
@ -1580,12 +1580,6 @@ function create_unexisting_directory(
path = '".Database::escape_string($systemFolderName)."'
)
";
$groupInfo = [];
if (!empty($to_group_id)) {
$groupInfo = GroupManager::get_group_properties($to_group_id);
}
$rs = Database::query($sql);
if (Database::num_rows($rs) == 0) {
$document = DocumentManager::addDocument(
@ -1655,7 +1649,7 @@ function create_unexisting_directory(
return $document;
}
}
}
//}
return false;
}

@ -1290,92 +1290,6 @@ EOT;
return $this->returnForm();
}
/**
* Create a form validator based on an array of form data:.
*
* array(
* 'name' => 'zombie_report_parameters', //optional
* 'method' => 'GET', //optional
* 'items' => array(
* array(
* 'name' => 'ceiling',
* 'label' => 'Ceiling', //optional
* 'type' => 'date',
* 'default' => date() //optional
* ),
* array(
* 'name' => 'active_only',
* 'label' => 'ActiveOnly',
* 'type' => 'checkbox',
* 'default' => true
* ),
* array(
* 'name' => 'submit_button',
* 'type' => 'style_submit_button',
* 'value' => get_lang('Search'),
* 'attributes' => array('class' => 'search')
* )
* )
* );
*
* @param array $form_data
*
* @deprecated use normal FormValidator construct
*
* @return FormValidator
*/
public static function create($form_data)
{
if (empty($form_data)) {
return null;
}
$form_name = isset($form_data['name']) ? $form_data['name'] : 'form';
$form_method = isset($form_data['method']) ? $form_data['method'] : 'POST';
$form_action = isset($form_data['action']) ? $form_data['action'] : '';
$form_target = isset($form_data['target']) ? $form_data['target'] : '';
$form_attributes = isset($form_data['attributes']) ? $form_data['attributes'] : null;
$form_track_submit = isset($form_data['track_submit']) ? $form_data['track_submit'] : true;
$reset = null;
$result = new FormValidator($form_name, $form_method, $form_action, $form_target, $form_attributes, $form_track_submit);
$defaults = [];
foreach ($form_data['items'] as $item) {
$name = $item['name'];
$type = isset($item['type']) ? $item['type'] : 'text';
$label = isset($item['label']) ? $item['label'] : '';
if ($type == 'wysiwyg') {
$element = $result->addHtmlEditor($name, $label);
} else {
$element = $result->addElement($type, $name, $label);
}
if (isset($item['attributes'])) {
$attributes = $item['attributes'];
$element->setAttributes($attributes);
}
if (isset($item['value'])) {
$value = $item['value'];
$element->setValue($value);
}
if (isset($item['default'])) {
$defaults[$name] = $item['default'];
}
if (isset($item['rules'])) {
$rules = $item['rules'];
foreach ($rules as $rule) {
$message = $rule['message'];
$type = $rule['type'];
$format = isset($rule['format']) ? $rule['format'] : null;
$validation = isset($rule['validation']) ? $rule['validation'] : 'server';
$force = isset($rule['force']) ? $rule['force'] : false;
$result->addRule($name, $message, $type, $format, $validation, $reset, $force);
}
}
}
$result->setDefaults($defaults);
return $result;
}
/**
* @return HTML_QuickForm_Renderer_Default
*/

@ -109,7 +109,7 @@ class GroupManager
$course_id = $course_info['real_id'];
$table_group = Database::get_course_table(TABLE_GROUP);
$select = " g.id,
$select = ' g.id,
g.iid,
g.name,
g.description,
@ -119,9 +119,9 @@ class GroupManager
g.self_registration_allowed,
g.self_unregistration_allowed,
g.session_id,
g.status";
g.status';
if ($getCount) {
$select = " DISTINCT count(g.iid) as count ";
$select = ' DISTINCT count(g.iid) as count ';
}
$sql = "SELECT
@ -148,7 +148,7 @@ class GroupManager
if (!empty($session_condition)) {
$sql .= $session_condition;
}
$sql .= "ORDER BY UPPER(g.name)";
$sql .= ' ORDER BY UPPER(g.name)';
$result = Database::query($sql);
@ -1685,15 +1685,19 @@ class GroupManager
*/
public static function get_subscribed_users($groupInfo)
{
if (empty($groupInfo)) {
return [];
}
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_group_user = Database::get_course_table(TABLE_GROUP_USER);
$order_clause = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname';
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$order_clause = " ORDER BY u.official_code, u.firstname, u.lastname";
$order_clause = ' ORDER BY u.official_code, u.firstname, u.lastname';
}
$group_id = intval($groupInfo['id']);
$group_id = (int) $groupInfo['iid'];
if (empty($group_id)) {
return [];
@ -1741,16 +1745,20 @@ class GroupManager
*/
public static function get_subscribed_tutors($groupInfo, $id_only = false)
{
if (empty($groupInfo)) {
return [];
}
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_group_tutor = Database::get_course_table(TABLE_GROUP_TUTOR);
$order_clause = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname';
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$order_clause = " ORDER BY u.official_code, u.firstname, u.lastname";
$order_clause = ' ORDER BY u.official_code, u.firstname, u.lastname';
}
$group_id = intval($groupInfo['id']);
$group_id = (int) $groupInfo['iid'];
$course_id = api_get_course_int_id();
$sql = "SELECT tg.id, u.user_id, u.lastname, u.firstname, u.email

@ -1213,8 +1213,8 @@ class MessageManager
user_sender_id
FROM $table
WHERE
user_sender_id = " . api_get_user_id() . " AND
msg_status = " . MESSAGE_STATUS_OUTBOX . "
user_sender_id = ".api_get_user_id()." AND
msg_status = ".MESSAGE_STATUS_OUTBOX."
$keywordCondition
ORDER BY col$column $direction
LIMIT $from, $number_of_items";
@ -1229,7 +1229,7 @@ class MessageManager
$senderId = $row['user_sender_id'];
if ($request === true) {
$message[0] = '<input type="checkbox" value=' . $messageId . ' name="out[]">';
$message[0] = '<input type="checkbox" value='.$messageId.' name="out[]">';
} else {
$message[0] = $messageId;
}
@ -1238,29 +1238,29 @@ class MessageManager
$title = Security::remove_XSS($title);
$userInfo = api_get_user_info($senderId);
if ($request === true) {
$message[1] = '<a onclick="show_sent_message(' . $messageId . ')" href="javascript:void(0)">' . $userInfo['complete_name_with_username'] . '</a>';
$message[2] = '<a onclick="show_sent_message(' . $messageId . ')" href="javascript:void(0)">' . str_replace(
$message[1] = '<a onclick="show_sent_message('.$messageId.')" href="javascript:void(0)">'.$userInfo['complete_name_with_username'].'</a>';
$message[2] = '<a onclick="show_sent_message('.$messageId.')" href="javascript:void(0)">'.str_replace(
"\\",
"",
$title
) . '</a>';
).'</a>';
//date stays the same
$message[3] = api_convert_and_format_date($sendDate, DATE_TIME_FORMAT_LONG);
$message[4] = '<a class="btn btn-outline-secondary btn-sm" title="' . addslashes(
$message[4] = '<a class="btn btn-outline-secondary btn-sm" title="'.addslashes(
get_lang('DeleteMessage')
) . '" onclick="delete_one_message_outbox(' . $messageId . ')" href="javascript:void(0)" >' .
Display::returnFontAwesomeIcon('trash', 2) . '</a>';
).'" onclick="delete_one_message_outbox('.$messageId.')" href="javascript:void(0)" >'.
Display::returnFontAwesomeIcon('trash', 2).'</a>';
} else {
$message[1] = '<img class="rounded-circle mr-2" src="'.$userInfo['avatar_small'].'"/>';
$message[1].= $userInfo['complete_name_with_username'];
$message[2] = '<a ' . $class . ' onclick="show_sent_message(' . $messageId . ')" href="../messages/view_message.php?id_send=' . $messageId . '">' . $title . '</a>';
$message[1] .= $userInfo['complete_name_with_username'];
$message[2] = '<a '.$class.' onclick="show_sent_message('.$messageId.')" href="../messages/view_message.php?id_send='.$messageId.'">'.$title.'</a>';
$message[3] = api_convert_and_format_date($sendDate, DATE_TIME_FORMAT_LONG);
$message[4] = '<a class="btn btn-outline-secondary btn-sm" title="' . addslashes(
$message[4] = '<a class="btn btn-outline-secondary btn-sm" title="'.addslashes(
get_lang('DeleteMessage')
) . '" href="outbox.php?action=deleteone&id=' . $messageId . '" onclick="javascript:if(!confirm(' . "'" . addslashes(
).'" href="outbox.php?action=deleteone&id='.$messageId.'" onclick="javascript:if(!confirm('."'".addslashes(
api_htmlentities(get_lang('ConfirmDeleteMessage'))
) . "'" . ')) return false;" >' .
Display::returnFontAwesomeIcon('trash', 'fa-sm') . '</a>';
)."'".')) return false;" >'.
Display::returnFontAwesomeIcon('trash', 'fa-sm').'</a>';
}
$message_list[] = $message;
@ -2166,7 +2166,8 @@ class MessageManager
2,
20,
'DESC',
null,'table-custom'
null,
'table-custom'
);
$table->set_header(0, '', false, ['style' => 'width:15px;']);
$table->set_header(1, get_lang('Messages'), false);

@ -146,6 +146,7 @@ class HTML_Common
$strAttr .= ' ' . $key . '= "' . $value. '"';
}
}
return $strAttr;
}
@ -155,7 +156,7 @@ class HTML_Common
* @access private
* @return array
*/
function _parseAttributes($attributes)
public function _parseAttributes($attributes)
{
if (is_array($attributes)) {
$ret = array();
@ -457,17 +458,6 @@ class HTML_Common
*/
function charset($newCharset = null)
{
// Modified by Ivan Tcholakov, 16-MAR-2010
//static $charset = 'ISO-8859-1';
static $charset;
if (!isset($charset)) {
$charset = api_get_system_encoding();
}
//
if (!is_null($newCharset)) {
$charset = $newCharset;
}
return $charset;
return 'UTF-8';
} // end func charset
}

@ -350,19 +350,19 @@ class HTML_QuickForm extends HTML_Common
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
foreach ($filter as $val) {
if (!is_callable($val)) {
throw new \Exception("Callback function does not exist in QuickForm::setDefaults()");
throw new \Exception('Callback function does not exist in QuickForm::setDefaults()');
} else {
$defaultValues = $this->_recursiveFilter($val, $defaultValues);
}
}
} elseif (!is_callable($filter)) {
throw new \Exception("Callback function does not exist in QuickForm::setDefaults()");
throw new \Exception('Callback function does not exist in QuickForm::setDefaults()');
} else {
$defaultValues = $this->_recursiveFilter($filter, $defaultValues);
}
}
$this->_defaultValues = HTML_QuickForm::arrayMerge($this->_defaultValues, $defaultValues);
$this->_defaultValues = self::arrayMerge($this->_defaultValues, $defaultValues);
$this->_constantValues = $this->_defaultValues;
foreach (array_keys($this->_elements) as $key) {
$this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);

@ -155,4 +155,3 @@ class HTML_QuickForm_Renderer
return;
} // end func finishGroup
} // end class HTML_QuickForm_Renderer
?>

@ -140,10 +140,11 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
} elseif ($this->_flagFrozen) {
$label = $this->_text;
} else {
$className = $this->checkboxClass;
$labelClass = $this->labelClass;
$checkClass = $this->checkboxClass;
$name = $this->_attributes['name'];
$label ='<div id="'.$name.'" class="'.$className.'_'.$name.'">
<label>' .
$label ='<div id="'.$name.'" class="'.$checkClass.'">
<label class="'.$labelClass.'">' .
HTML_QuickForm_input::toHtml().' '.$this->_text.
'</label>
</div>

@ -43,17 +43,15 @@ class HTML_QuickForm_element extends HTML_Common
/**
* Label of the field
* @var string
* @since 1.3
* @access private
*/
var $_label = '';
public $_label = '';
/**
* Label "for" a field... (Chamilo LMS customization)
* @var string
* @access private
*/
var $_label_for = '';
public $_label_for = '';
/**
* Form element type
@ -61,7 +59,7 @@ class HTML_QuickForm_element extends HTML_Common
* @since 1.0
* @access private
*/
var $_type = '';
public $_type = '';
/**
* Flag to tell if element is frozen
@ -69,7 +67,7 @@ class HTML_QuickForm_element extends HTML_Common
* @since 1.0
* @access private
*/
var $_flagFrozen = false;
public $_flagFrozen = false;
/**
* Does the element support persistant data when frozen
@ -77,7 +75,7 @@ class HTML_QuickForm_element extends HTML_Common
* @since 1.3
* @access private
*/
var $_persistantFreeze = false;
public $_persistantFreeze = false;
protected $columnsSize;
@ -179,9 +177,6 @@ class HTML_QuickForm_element extends HTML_Common
return 3.2;
} // end func apiVersion
// }}}
// {{{ getType()
/**
* Returns element type
*
@ -194,9 +189,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_type;
} // end func getType
// }}}
// {{{ setName()
/**
* Sets the input field name
*
@ -207,12 +199,8 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function setName($name)
{
// interface method
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -222,12 +210,8 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function getName()
{
// interface method
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets the value of the form element
*
@ -238,12 +222,8 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function setValue($value)
{
// interface
} // end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
@ -253,12 +233,30 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function getValue()
{
// interface
return null;
} // end func getValue
// }}}
// {{{ freeze()
/**
* @return string
*/
public function getCleanValue()
{
$value = $this->cleanValueFromParameter($this->getValue());
return $value;
}
/**
* @param string $value
*
* @return string
*/
public function cleanValueFromParameter($value)
{
$value = @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset());
return $value;
}
/**
* Freeze the element so that only its value is returned
@ -271,9 +269,6 @@ class HTML_QuickForm_element extends HTML_Common
$this->_flagFrozen = true;
} //end func freeze
// }}}
// {{{ unfreeze()
/**
* Unfreezes the element so that it becomes editable
*
@ -286,9 +281,6 @@ class HTML_QuickForm_element extends HTML_Common
$this->_flagFrozen = false;
}
// }}}
// {{{ getFrozenHtml()
/**
* Returns the value of field without HTML tags
*
@ -302,12 +294,16 @@ class HTML_QuickForm_element extends HTML_Common
// Modified by Ivan Tcholakov, 16-MAR-2010.
//return ('' != $value? htmlspecialchars($value): '&nbsp;') .
// $this->_getPersistantData();
if (!empty($value)) {
$value = $this->getCleanValue();
} else {
$value = '&nbsp;';
}
$value .= $this->_getPersistantData();
$value = ('' != $value ? @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset()): '&nbsp;') .
$this->_getPersistantData();
return '<span class="freeze">'.$value.'</span>';
//
} //end func getFrozenHtml
}
/**
* Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on
@ -329,9 +325,6 @@ class HTML_QuickForm_element extends HTML_Common
}
}
// }}}
// {{{ isFrozen()
/**
* Returns whether or not the element is frozen
*
@ -344,9 +337,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_flagFrozen;
} // end func isFrozen
// }}}
// {{{ setPersistantFreeze()
/**
* Sets wether an element value should be kept in an hidden field
* when the element is frozen or not
@ -361,9 +351,6 @@ class HTML_QuickForm_element extends HTML_Common
$this->_persistantFreeze = $persistant;
} //end func setPersistantFreeze
// }}}
// {{{ setLabel()
/**
* Sets display text for the element
*
@ -381,9 +368,6 @@ class HTML_QuickForm_element extends HTML_Common
}
} //end func setLabel
// }}}
// {{{ getLabel()
/**
* Returns display text for the element
*
@ -407,9 +391,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_label_for;
} //end func getLabelFor
// }}}
// {{{ _findValue()
/**
* Tries to find the element value from the values array
*
@ -451,9 +432,6 @@ class HTML_QuickForm_element extends HTML_Common
}
} //end func _findValue
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
@ -547,9 +525,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_prepareValue($value, $assoc);
}
// }}}
// {{{ _prepareValue()
/**
* Used by exportValue() to prepare the value for returning
*

@ -268,8 +268,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
$image = $(\'#'.$id.'_preview_image\'),
$input = $(\'[name="'.$id.'_crop_result"]\'),
$cropButton = $(\'#'.$id.'_crop_button\'),
$formGroup = $(\'#'.$id.'-form-group\');
$formGroup = $(\'#'.$id.'-form-group\');
function isValidType(file) {
var fileTypes = [\'image/jpg\', \'image/jpeg\', \'image/gif\', \'image/png\'];

@ -1,6 +1,4 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Base class for <input /> form elements
*
@ -35,8 +33,6 @@
*/
class HTML_QuickForm_input extends HTML_QuickForm_element
{
// {{{ constructor
/**
* Class constructor
*
@ -52,9 +48,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
parent::__construct($elementName, $elementLabel, $attributes);
} //end constructor
// }}}
// {{{ setType()
/**
* Sets the element type
*
@ -69,9 +62,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
$this->updateAttributes(array('type'=>$type));
} // end func setType
// }}}
// {{{ setName()
/**
* Sets the input field name
*
@ -85,9 +75,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -100,9 +87,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets the value of the form element
*
@ -116,9 +100,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
$this->updateAttributes(array('value'=>$value));
} // end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
@ -131,9 +112,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
return $this->getAttribute('value');
} // end func getValue
// }}}
// {{{ toHtml()
/**
* Returns the input field in HTML
*
@ -150,9 +128,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
}
} //end func toHtml
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*

@ -19,8 +19,6 @@
*/
class HTML_QuickForm_label extends HTML_QuickForm_static
{
// {{{ constructor
/**
* Class constructor
*
@ -36,12 +34,4 @@ class HTML_QuickForm_label extends HTML_QuickForm_static
parent::__construct(null, $label, $text, $attributes);
$this->_type = 'html';
}
/**
* @return string
*/
public function toHtml()
{
return parent::toHtml();
}
}

@ -188,8 +188,4 @@ class HTML_QuickForm_link extends HTML_QuickForm_static
{
return;
} //end func getFrozenHtml
// }}}
} //end class HTML_QuickForm_textarea
?>

@ -2,8 +2,6 @@
class HTML_QuickForm_reset extends HTML_QuickForm_button
{
// {{{ constructor
/**
* Class constructor
*
@ -22,9 +20,6 @@ class HTML_QuickForm_reset extends HTML_QuickForm_button
$this->setType('reset');
} //end constructor
// }}}
// {{{ freeze()
/**
* Freeze the element so that only its value is returned
*
@ -35,7 +30,4 @@ class HTML_QuickForm_reset extends HTML_QuickForm_button
{
return false;
} //end func freeze
// }}}
}

@ -32,9 +32,6 @@
*/
class HTML_QuickForm_static extends HTML_QuickForm_element
{
// {{{ properties
/**
* Display text
* @var string
@ -42,9 +39,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
*/
var $_text = null;
// }}}
// {{{ constructor
/**
* Class constructor
*
@ -61,9 +55,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->_text = $text;
} //end constructor
// }}}
// {{{ setName()
/**
* Sets the element name
*
@ -76,9 +67,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -90,9 +78,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setText()
/**
* Sets the text
*
@ -105,9 +90,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->_text = $text;
} // end func setText
// }}}
// {{{ setValue()
/**
* Sets the text (uses the standard setValue call to emulate a form element.
*
@ -120,9 +102,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->setText($text);
} // end func setValue
// }}}
// {{{ toHtml()
/**
* Returns the static text element in HTML
*
@ -134,9 +113,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return $this->_getTabs() . $this->_text;
} //end func toHtml
// }}}
// {{{ getFrozenHtml()
/**
* Returns the value of field without HTML tags
*
@ -148,9 +124,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return $this->toHtml();
} //end func getFrozenHtml
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
@ -181,9 +154,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return true;
} // end func onQuickFormEvent
// }}}
// {{{ exportValue()
/**
* We override this here because we don't want any values from static elements
*/

@ -34,8 +34,6 @@
*/
class HTML_QuickForm_submit extends HTML_QuickForm_input
{
// {{{ constructor
/**
* Class constructor
*
@ -53,9 +51,6 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
$this->setType('submit');
} //end constructor
// }}}
// {{{ freeze()
/**
* Freeze the element so that only its value is returned
*
@ -67,9 +62,6 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
return false;
} //end func freeze
// }}}
// {{{ exportValue()
/**
* Only return the value if it is found within $submitValues (i.e. if
* this particular submit button was clicked)
@ -78,4 +70,5 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
{
return $this->_prepareValue($this->_findValue($submitValues), $assoc);
}
}
}

@ -40,7 +40,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
* @since 1.0
* @access private
*/
public $_value = null;
public $_value;
/**
* Class constructor
@ -62,6 +62,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'textarea';
$this->_value = null;
}
/**
@ -77,9 +78,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -92,9 +90,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets value for textarea element
*
@ -108,9 +103,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->_value = $value;
} //end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
@ -123,9 +115,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
return $this->_value;
} // end func getValue
// }}}
// {{{ setWrap()
/**
* Sets wrap type for textarea element
*
@ -139,9 +128,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('wrap' => $wrap));
} //end func setWrap
// }}}
// {{{ setRows()
/**
* Sets height in rows for textarea element
*
@ -155,9 +141,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('rows' => $rows));
} //end func setRows
// }}}
// {{{ setCols()
/**
* Sets width in cols for textarea element
*
@ -171,9 +154,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('cols' => $cols));
} //end func setCols
// }}}
// {{{ toHtml()
/**
* Returns the textarea element in HTML
*
@ -206,10 +186,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
*/
public function getFrozenHtml()
{
// Modified by Ivan Tcholakov, 16-MAR-2010.
//$value = htmlspecialchars($this->getValue());
$value = @htmlspecialchars($this->getValue(), ENT_COMPAT, HTML_Common::charset());
//
$value = $this->getCleanValue();
if ($this->getAttribute('wrap') == 'off') {
$html = $this->_getTabs() . '<pre>' . $value."</pre>\n";
} else {

@ -320,8 +320,11 @@ class SocialManager extends UserManager
msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
$res = Database::query($sql);
$row = Database::fetch_array($res, 'ASSOC');
if ($row) {
return (int) $row['count_message_in_box'];
}
return $row['count_message_in_box'];
return 0;
}
/**

@ -104,16 +104,16 @@ class SortableTable extends HTML_Table
/**
* Create a new SortableTable.
*
* @param string $table_name A name for the table (default = 'table')
* @param string $table_name A name for the table (default = 'table')
* @param string $get_total_number_function A user defined function to get
* the total number of items in the table
* @param string $get_data_function A function to get the data to display on
* @param string $get_data_function A function to get the data to display on
* the current page
* @param int $default_column The default column on which the data should be
* @param int $default_column The default column on which the data should be
* sorted
* @param int $default_items_per_page The default number of items to show
* @param int $default_items_per_page The default number of items to show
* on one page
* @param string $default_order_direction The default order direction;
* @param string $default_order_direction The default order direction;
* either the constant 'ASC' or 'DESC'
* @param string $table_id
* @param string $style

@ -827,6 +827,7 @@ class IndexManager
'link' => api_get_path(WEB_PATH).'main/messages/inbox.php',
'title' => get_lang('Inbox').$cant_msg,
];
$items[] = [
'class' => 'new-message-social',
'icon' => Display::return_icon('new-message.png', get_lang('Compose')),
@ -842,6 +843,13 @@ class IndexManager
'link' => api_get_path(WEB_PATH).'main/social/invitations.php',
'title' => get_lang('PendingInvitations').$total_invitations,
];
} else {
$items[] = [
'class' => 'personal-data',
'icon' => Display::return_icon('database.png', get_lang('PersonalDataReport')),
'link' => api_get_path(WEB_CODE_PATH).'social/personal_data.php',
'title' => get_lang('PersonalDataReport'),
];
}
if (api_get_configuration_value('allow_my_files_link_in_homepage')) {
@ -889,7 +897,6 @@ class IndexManager
}
if (true === api_get_configuration_value('whispeak_auth_enabled')) {
//if (!WhispeakAuthPlugin::checkUserIsEnrolled($userId)) {
$itemTitle = WhispeakAuthPlugin::create()->get_title();
$items[] = [
@ -898,7 +905,6 @@ class IndexManager
'link' => WhispeakAuthPlugin::getEnrollmentUrl(),
'title' => $itemTitle,
];
//}
}
return $items;

@ -28,8 +28,14 @@ class ZombieManager
*
* @return ResultSet
*/
public static function listZombies($ceiling, $active_only = true, $count = 0, $from = 10, $column = 'user.firstname', $direction = 'desc')
{
public static function listZombies(
$ceiling,
$active_only = true,
$from = 0,
$count = 10,
$column = 'user.firstname',
$direction = 'desc'
) {
if (empty($column)) {
$column = 'user.firstname';
}
@ -41,6 +47,7 @@ class ZombieManager
$sql = 'SELECT
user.user_id,
user.official_code,
user.firstname,
user.lastname,
user.username,
@ -74,15 +81,17 @@ class ZombieManager
access.login_date <= '$ceiling' AND
user.user_id = access.login_user_id";
}
if ($active_only) {
$sql .= ' AND user.active = 1';
}
$sql .= " ORDER BY $column $direction";
if (!is_null($from) && !is_null($count)) {
$count = intval($count);
$from = intval($from);
$sql .= " ORDER BY $column $direction";
$sql .= " LIMIT $count, $from ";
$sql .= " LIMIT $from, $count ";
}
$result = Database::query($sql);
@ -94,7 +103,7 @@ class ZombieManager
*/
public static function deactivate_zombies($ceiling)
{
$zombies = self::list_zombies($ceiling);
$zombies = self::listZombies($ceiling);
$ids = [];
foreach ($zombies as $zombie) {
$ids[] = $zombie['user_id'];

@ -34,9 +34,6 @@ class ZombieReport implements Countable
public function get_parameters()
{
$result = [
'name' => 'zombie_report_parameters',
'method' => 'GET',
'attributes' => ['class' => 'well form-horizontal form-search'],
'items' => [
[
'name' => 'ceiling',
@ -44,10 +41,6 @@ class ZombieReport implements Countable
'type' => 'date_picker',
'default' => $this->get_ceiling('Y-m-d'),
'rules' => [
// array(
// 'type' => 'required',
// 'message' => get_lang('Required')
// ),
[
'type' => 'date',
'message' => get_lang('Date'),
@ -68,14 +61,6 @@ class ZombieReport implements Countable
],
],
];
$additional_parameters = $this->get_additional_parameters();
foreach ($additional_parameters as $key => $value) {
$result['items'][] = [
'type' => 'hidden',
'name' => $key,
'value' => $value,
];
}
return $result;
}
@ -85,31 +70,37 @@ class ZombieReport implements Countable
*/
public function get_parameters_form()
{
$parameters = $this->get_parameters();
if (empty($parameters)) {
return null;
}
if (empty($this->parameters_form)) {
$this->parameters_form = new FormValidator(
$parameters['name'],
$parameters['method'],
$form = new FormValidator(
'zombie_report_parameters',
'get',
null,
null,
$parameters['attributes']
['class' => 'well form-horizontal form-search']
);
$form->addDatePicker('ceiling', get_lang('LastAccess'));
$form->addCheckBox('active_only', get_lang('ActiveOnly'));
$form->addButtonSearch(get_lang('Search'));
$params = [
'active_only' => $this->get_active_only(),
'ceiling' => $this->get_ceiling('Y-m-d'),
];
$form->setDefaults($params);
$additional = $this->get_additional_parameters();
foreach ($additional as $key => $value) {
$value = Security::remove_XSS($value);
$form->addHidden($key, $value);
}
return $this->parameters_form;
return $form;
}
public function display_parameters($return = false)
{
$form = $this->get_parameters_form();
if (empty($form)) {
return '';
}
$result = $form->returnForm();
if ($return) {
return $result;
} else {
@ -120,9 +111,6 @@ class ZombieReport implements Countable
public function is_valid()
{
$form = $this->get_parameters_form();
if (empty($form)) {
return true;
}
return $form->isSubmitted() == false || $form->validate();
}
@ -175,57 +163,39 @@ class ZombieReport implements Countable
}
$action = $this->get_action();
$f = [$this, 'action_'.$action];
if (is_callable($f)) {
return call_user_func($f, $ids);
switch ($action) {
case 'activate':
return UserManager::activate_users($ids);
break;
case 'deactivate':
return UserManager::deactivate_users($ids);
break;
case 'delete':
return UserManager::delete_users($ids);
}
return false;
}
public function action_deactivate($ids)
{
return UserManager::deactivate_users($ids);
}
public function action_activate($ids)
{
return UserManager::activate_users($ids);
}
public function action_delete($ids)
{
return UserManager::delete_users($ids);
}
public function count()
{
if (!$this->is_valid()) {
return 0;
}
$ceiling = $this->get_ceiling();
$active_only = $this->get_active_only();
$items = ZombieManager::listZombies($ceiling, $active_only);
$items = ZombieManager::listZombies($ceiling, $active_only, null, null);
return count($items);
}
public function get_data($from, $count, $column, $direction)
{
if (!$this->is_valid()) {
return [];
}
$ceiling = $this->get_ceiling();
$active_only = $this->get_active_only();
$items = ZombieManager::listZombies($ceiling, $active_only, $count, $from, $column, $direction);
$items = ZombieManager::listZombies($ceiling, $active_only, $from, $count, $column, $direction);
$result = [];
foreach ($items as $item) {
$row = [];
$row[] = $item['user_id'];
$row[] = $item['code'];
$row[] = $item['official_code'];
$row[] = $item['firstname'];
$row[] = $item['lastname'];
$row[] = $item['username'];
@ -253,12 +223,12 @@ class ZombieReport implements Countable
$additional_parameters = $this->get_additional_parameters();
$parameters = array_merge($additional_parameters, $parameters);
$table = new SortableTable('users', $count, $data, 1, 50);
$table = new SortableTable('zombie_users', $count, $data, 1, 50);
$table->set_additional_parameters($parameters);
$col = 0;
$table->set_header($col++, '', false);
$table->set_header($col++, get_lang('Code'));
$table->set_header($col++, get_lang('OfficialCode'));
$table->set_header($col++, get_lang('FirstName'));
$table->set_header($col++, get_lang('LastName'));
$table->set_header($col++, get_lang('LoginName'));
@ -267,7 +237,7 @@ class ZombieReport implements Countable
$table->set_header($col++, get_lang('AuthenticationSource'));
$table->set_header($col++, get_lang('RegisteredDate'));
$table->set_header($col++, get_lang('LastAccess'), false);
$table->set_header($col++, get_lang('Active'), false);
$table->set_header($col, get_lang('Active'), false);
$table->set_column_filter(5, [$this, 'format_email']);
$table->set_column_filter(6, [$this, 'format_status']);
@ -295,7 +265,7 @@ class ZombieReport implements Countable
*/
public function format_active($active)
{
$active = ($active == '1');
$active = $active == '1';
if ($active) {
$image = 'accept';
$text = get_lang('Yes');
@ -324,14 +294,14 @@ class ZombieReport implements Countable
public function display($return = false)
{
$result = $this->display_parameters($return);
if ($this->perform_action()) {
if ($return) {
$result .= Display::return_message(get_lang('Done'), 'confirmation');
} else {
echo Display::return_message(get_lang('Done'), 'confirmation');
}
$valid = $this->perform_action();
if ($valid) {
echo Display::return_message(get_lang('Updated'), 'confirmation');
}
$result .= $this->display_data($return);
if ($return) {
return $result;
}

@ -429,6 +429,8 @@ function write_system_config_file($path)
Your problems can be related on two possible causes:<br />
<ul>
<li>Permission problems.<br />Try initially with <em>chmod -R 777</em> and increase restrictions gradually.</li>
<li>PHP is running in <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">Safe-Mode</a>.
If possible, try to switch it off.</li>
</ul>
<a href="http://forum.chamilo.org/" target="_blank">Read about this problem in Support Forum</a><br /><br />
Please go back to step 5.
@ -577,6 +579,8 @@ function get_config_param($param, $updatePath = '')
*/
function get_config_param_from_db($param = '')
{
$param = Database::escape_string($param);
if (($res = Database::query("SELECT * FROM settings_current WHERE variable = '$param'")) !== false) {
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
@ -1960,12 +1964,17 @@ function updateDirAndFilesPermissions()
$permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
$permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
// use decoct() to store as string
$sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."'
WHERE variable = 'permissions_for_new_directories'";
Database::query($sql);
Database::update(
$table,
['selected_value' => '0'.decoct($permissions_for_new_directories)],
['variable = ?' => 'permissions_for_new_directories']
);
$sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable = 'permissions_for_new_files'";
Database::query($sql);
Database::update(
$table,
['selected_value' => '0'.decoct($permissions_for_new_files)],
['variable = ?' => 'permissions_for_new_files']
);
if (isset($_SESSION['permissions_for_new_directories'])) {
unset($_SESSION['permissions_for_new_directories']);
@ -2324,9 +2333,8 @@ function fixIds(EntityManager $em)
// Delete group data of groups that don't exist.
$sql = "DELETE FROM c_item_property
WHERE to_group_id IS NOT NULL AND to_group_id NOT IN (SELECT DISTINCT id FROM c_group_info)";
WHERE to_group_id <> 0 AND to_group_id IS NOT NULL AND to_group_id NOT IN (SELECT DISTINCT iid FROM c_group_info)";
$connection->executeQuery($sql);
// This updates the group_id with c_group_info.iid instead of c_group_info.id
if ($debug) {
@ -2399,7 +2407,8 @@ function fixIds(EntityManager $em)
$ref = $item['ref'];
// Fix group id
if (!empty($groupId)) {
// Commented group id is already fixed in Version20150603181728.php
/*if (!empty($groupId)) {
$sql = "SELECT * FROM c_group_info
WHERE c_id = $courseId AND id = $groupId";
$data = $connection->fetchAssoc($sql);
@ -2413,7 +2422,7 @@ function fixIds(EntityManager $em)
$sql = "DELETE FROM c_item_property WHERE iid = $iid";
$connection->executeQuery($sql);
}
}
}*/
$sql = '';
$newId = '';
@ -3259,9 +3268,7 @@ function finishInstallationWithContainer(
$manager = Database::getManager();
$connection = $manager->getConnection();
$sql = getVersionTable();
// Add version table
$connection->executeQuery($sql);
@ -3412,8 +3419,11 @@ function finishInstallationWithContainer(
);
// Set default language
$sql = "UPDATE language SET available = 1 WHERE dokeos_folder = '$languageForm'";
Database::query($sql);
Database::update(
Database::get_main_table(TABLE_MAIN_LANGUAGE),
['available' => 1],
['dokeos_folder = ?' => $languageForm]
);
// Install settings
installSettings(
@ -3502,14 +3512,21 @@ function installProfileSettings($installationProfile = '')
if (!empty($params->parent)) {
installProfileSettings($params->parent);
}
$tblSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
foreach ($settings as $id => $param) {
$sql = "UPDATE settings_current
SET selected_value = '".$param->selected_value."'
WHERE variable = '".$param->variable."'";
$conditions = ['variable = ? ' => $param->variable];
if (!empty($param->subkey)) {
$sql .= " AND subkey='".$param->subkey."'";
$conditions['AND subkey = ? '] = $param->subkey;
}
Database::query($sql);
Database::update(
$tblSettings,
['selected_value' => $param->selected_value],
$conditions
);
}
return true;
@ -3538,6 +3555,16 @@ function rrmdir($dir)
}
}
/**
* @param $id
* @param string $type
* @param bool $preview
* @param bool $anonymous
*
* @throws \Doctrine\DBAL\DBALException
*
* @return array
*/
function get_group_picture_path_by_id($id, $type = 'web', $preview = false, $anonymous = false)
{
switch ($type) {
@ -3596,6 +3623,8 @@ function get_group_picture_path_by_id($id, $type = 'web', $preview = false, $ano
* @param EntityManager $manager
* @param bool $processFiles
*
* @throws \Doctrine\DBAL\DBALException
*
* @return bool Always returns true except if the process is broken
*/
function migrateSwitch($fromVersion, $manager, $processFiles = true)
@ -3668,7 +3697,6 @@ function migrateSwitch($fromVersion, $manager, $processFiles = true)
case '1.10.2':
case '1.10.4':
case '1.10.6':
case '1.10.8':
case '1.10.8':
$database = new Database();
$database->setManager($manager);
@ -3735,6 +3763,8 @@ function migrateSwitch($fromVersion, $manager, $processFiles = true)
/**
* @param \Doctrine\DBAL\Connection $connection
*
* @throws \Doctrine\DBAL\DBALException
*/
function fixPostGroupIds($connection)
{
@ -3790,26 +3820,36 @@ function fixPostGroupIds($connection)
$courseId = $row['c_id'];
$sessionId = $row['session_id'];
$workId = $row['id'];
$itemInfo = api_get_item_property_info(
$courseId,
'work',
$workId,
$sessionId
);
$courseInfo = api_get_course_info_by_id($courseId);
$sessionCondition = " session_id = $sessionId";
if (empty($sessionId)) {
$sessionCondition = ' (session_id = 0 OR session_id IS NULL) ';
}
$sql = "SELECT * FROM c_item_property
WHERE
c_id = $courseId AND
tool = 'work' AND
ref = $workId AND
$sessionCondition ";
$itemInfo = $connection->fetchAssoc($sql);
if (empty($itemInfo)) {
api_item_property_update(
$courseInfo,
'work',
$workId,
'visible',
1,
$groupId,
null,
null,
null,
$sessionId
);
$params = [
'c_id' => $courseId,
'to_group_id' => $groupId,
//'to_user_id' => null,
'insert_user_id' => 1,
'session_id' => $sessionId,
'tool' => 'work',
'insert_date' => api_get_utc_datetime(),
'lastedit_date' => api_get_utc_datetime(),
'ref' => $workId,
'lastedit_type' => 'visible',
'lastedit_user_id' => 1,
'visibility' => 1,
];
$connection->insert('c_item_property', $params);
$id = $connection->lastInsertId();
$sql = "UPDATE c_item_property SET id = iid WHERE iid = $id";
$connection->executeQuery($sql);
}
}
error_log('End - Fix work documents');

@ -5,6 +5,7 @@ use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Entity\CItemProperty;
use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\CourseBundle\Entity\CLpCategory;
@ -3671,7 +3672,6 @@ class learnpath
}
$type_quiz = false;
foreach ($list as $toc) {
if ($toc['id'] == $lp_item_id && ($toc['type'] == 'quiz')) {
$type_quiz = true;
@ -3705,7 +3705,6 @@ class learnpath
if (strpos($document_name, '_DELETED_')) {
$file = 'blank.php?error=document_deleted';
}
break;
case 2:
if ($this->debug > 2) {
@ -6259,10 +6258,14 @@ class learnpath
if (file_exists($iconPath.'lp_'.$icon_name.'.png')) {
$icon = Display::return_icon('lp_'.$icon_name.'.png');
} else {
if ($arrLP[$i]['item_type'] === TOOL_LP_FINAL_ITEM) {
$icon = Display::return_icon('certificate.png');
if (file_exists($iconPath.'lp_'.$icon_name.'.gif')) {
$icon = Display::return_icon('lp_'.$icon_name.'.gif');
} else {
$icon = Display::return_icon('folder_document.png');
if ($arrLP[$i]['item_type'] === TOOL_LP_FINAL_ITEM) {
$icon = Display::return_icon('certificate.png');
} else {
$icon = Display::return_icon('folder_document.png');
}
}
}
@ -10216,8 +10219,10 @@ class learnpath
public function display_item_prerequisites_form($item_id = 0)
{
$course_id = api_get_course_int_id();
$item_id = (int) $item_id;
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$item_id = intval($item_id);
/* Current prerequisite */
$sql = "SELECT * FROM $tbl_lp_item
WHERE iid = $item_id";
@ -12513,7 +12518,7 @@ EOD;
$link = 'lp/lp_controller.php?cidReq='.$courseInfo['code'].'&id_session='.$sessionId.'&gidReq=0&gradebook=0&origin=&action=view_category&id='.$id;
// Delete tools
$sql = "DELETE FROM $tbl_tool
WHERE c_id = ".$courseId." AND (link LIKE '$link%' AND image LIKE 'lp_category.%')";
WHERE c_id = ".$courseId." AND (link LIKE '$link%' AND image='lp_category.gif')";
Database::query($sql);
}
}

@ -2495,8 +2495,18 @@ class learnpathItem
LIMIT 0, 1';
$rs_quiz = Database::query($sql);
if ($quiz = Database::fetch_array($rs_quiz)) {
$minScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMinScore();
$maxScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMaxScore();
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
$maxScore = $myItemToCheck->getPrerequisiteMaxScore();
if (empty($minScore)) {
// Try with mastery_score
$masteryScoreAsMin = $myItemToCheck->get_mastery_score();
if (!empty($masteryScoreAsMin)) {
$minScore = $masteryScoreAsMin;
}
}
if (isset($minScore) && isset($minScore)) {
// Taking min/max prerequisites values see BT#5776
@ -2547,8 +2557,18 @@ class learnpathItem
$rs_quiz = Database::query($sql);
if (Database::num_rows($rs_quiz) > 0) {
while ($quiz = Database::fetch_array($rs_quiz)) {
$minScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMinScore();
$maxScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMaxScore();
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
$maxScore = $myItemToCheck->getPrerequisiteMaxScore();
if (empty($minScore)) {
// Try with mastery_score
$masteryScoreAsMin = $myItemToCheck->get_mastery_score();
if (!empty($masteryScoreAsMin)) {
$minScore = $masteryScoreAsMin;
}
}
if (isset($minScore) && isset($minScore)) {
// Taking min/max prerequisites values see BT#5776

@ -24,7 +24,6 @@ $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0;
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
$type = isset($_GET['type']) ? $_GET['type'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$is_allowed_to_edit = api_is_allowed_to_edit(null, false);
$listUrl = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=view&lp_id='.$lpId.'&'.api_get_cidreq().'&isStudentView=true';

@ -1692,6 +1692,8 @@ function switch_item(current_item, next_item) {
if ($("#lp_media_file").length != 0) {
$("#lp_media_file").html(tmp_data);
}
LPViewUtils.setHeightLPToc();
}
});

@ -26,7 +26,6 @@ if (isset($_GET['messages_page_nr'])) {
$nameTools = get_lang('Messages');
$show_message = null;
if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
$info_reply = [];
$info_delete = [];
@ -112,7 +111,7 @@ $keyword = '';
// Comes from normal profile
if ($allowMessage) {
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'),null,ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
@ -174,4 +173,3 @@ $content = $tpl->fetch($social_layout);
$tpl->assign('message', $show_message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -343,10 +343,9 @@ $message_content = null;
$actions = null;
if ($group_id != 0) {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
Display::return_icon('back.png', api_xml_http_response_encode(get_lang('ComposeMessage')),null, ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('back.png', api_xml_http_response_encode(get_lang('ComposeMessage')), null, ICON_SIZE_MEDIUM).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
Display::return_icon('message_new.png', api_xml_http_response_encode(get_lang('ComposeMessage')), null, ICON_SIZE_MEDIUM).'</a>';
} else {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM).'</a>';
@ -419,4 +418,3 @@ $social_layout = $tpl->get_template('message/inbox.tpl');
$content = $tpl->fetch($social_layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -42,16 +42,16 @@ $interbreadcrumb[] = [
$actions = null;
if ($allowMessage) {
$actionsLeft = '<a href="' . api_get_path(WEB_PATH) . 'main/messages/inbox.php">' .
Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM) . '</a>';
$actionsLeft .= '<a href="' . api_get_path(WEB_PATH) . 'main/messages/new_message.php">' .
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM) . '</a>';
$actionsLeft .= '<a href="' . api_get_path(WEB_PATH) . 'main/messages/inbox.php">' .
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM) . '</a>';
$actionsLeft .= '<a href="' . api_get_path(WEB_PATH) . 'main/messages/outbox.php">' .
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM) . '</a>';
$form = MessageManager::getSearchForm(api_get_path(WEB_PATH) . 'main/messages/outbox.php');
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).'</a>';
$form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php');
if ($form->validate()) {
$values = $form->getSubmitValues();
$keyword = $values['keyword'];
@ -68,7 +68,6 @@ if (isset($_REQUEST['action'])) {
$keyword = '';
$message_content = null;
$actions .= Display::toolbarAction(
'toolbar',
[$actionsLeft, $actionsRight]
@ -117,4 +116,3 @@ $content = $tpl->fetch($social_layout);
$tpl->assign('message', $show_message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -28,14 +28,13 @@ $actions = null;
if (api_get_setting('allow_message_tool') === 'true') {
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null,ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).'</a>';
}
$actions .= Display::toolbarAction(
'toolbar',
[$actionsLeft]
@ -51,7 +50,6 @@ if (empty($_GET['id'])) {
$show_menu = 'messages_inbox';
}
// MAIN CONTENT
$message_content = MessageManager::showMessageBox($messageId, $source);
@ -73,4 +71,3 @@ $social_layout = $tpl->get_template('message/inbox.tpl');
$content = $tpl->fetch($social_layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -94,7 +94,11 @@ if ($form->validate() && !empty($courseInfo)) {
$exerciseId = isset($values['exercise_id']) ? $values['exercise_id'] : 0;
$startDate = Security::remove_XSS($values['start_date']);
$exportFilename = 'exercise_results_report_'.$exerciseId.'_'.$courseInfo['code'];
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results_report&exercise_id='.$exerciseId.'&start_date='.$startDate.'&cidReq='.$courseInfo['code'].'&export_filename='.$exportFilename;
$url = api_get_path(WEB_AJAX_PATH).
'model.ajax.php?a=get_exercise_results_report&exercise_id='.$exerciseId.
'&start_date='.$startDate.'&cidReq='.$courseInfo['code'].
'&course_id='.$courseId.
'&export_filename='.$exportFilename;
$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
$columns = [

@ -90,7 +90,7 @@ $actions[] = Display::url(
);
$actions[] = Display::url(
Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM),
'window.print();'
'javascript:window.print();'
);
$actions[] = Display::url(
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM),

@ -51,7 +51,6 @@ if (api_get_setting('allow_terms_conditions') === 'true') {
$formDelete->addButtonDelete(get_lang('DeleteAccount'));
$formToString .= $formDelete->returnForm();
}
switch ($action) {
case 'send_legal':
$language = api_get_interface_language();

@ -68,7 +68,7 @@ $hideList = '';
$maxEvents = 20;
for ($i = 1; $i <= $maxEvents; $i++) {
$name = 'time_'.$i;
$form->addDateTimeRangePicker($name, get_lang('Time'));
$form->addDateTimeRangePicker($name, get_lang('Date'));
if ($i > 3) {
$hideList .= "$('#".$name."_alt').parent().parent().parent().hide();";
}

@ -76,7 +76,6 @@ if (!empty($exportReport) && !empty($format)) {
$userId
);
$filename = 'survey_results_'.$survey_id.'.csv';
header('Content-type: application/octet-stream');
header('Content-Type: application/force-download');

@ -107,7 +107,6 @@ class SurveyUtil
if (empty($question_id)) {
return false;
}
// Table definition
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
@ -1554,8 +1553,12 @@ class SurveyUtil
count(options.question_option_id) as number_of_options
FROM $table_survey_question questions
LEFT JOIN $table_survey_question_option options
ON questions.question_id = options.question_id AND options.c_id = questions.c_id
ON
questions.question_id = options.question_id AND
options.c_id = questions.c_id
WHERE
survey_question NOT LIKE '%{{%' AND
questions.type <> 'pagebreak' AND
questions.survey_id = $surveyId AND
questions.c_id = $course_id
GROUP BY questions.question_id
@ -1620,6 +1623,8 @@ class SurveyUtil
survey_question.question_id = survey_question_option.question_id AND
survey_question_option.c_id = survey_question.c_id
WHERE
survey_question NOT LIKE '%{{%' AND
survey_question.type <> 'pagebreak' AND
survey_question.survey_id = $surveyId AND
survey_question.c_id = $course_id
ORDER BY survey_question.sort ASC, survey_question_option.sort ASC";

@ -60,11 +60,12 @@ if (empty($docId)) {
if (!empty($documents)) {
echo Display::page_subheader(get_lang('DocumentsAdded'));
echo '<div class="well">';
$urlDocument = api_get_path(WEB_CODE_PATH).'work/add_document.php';
foreach ($documents as $doc) {
$documentId = $doc['document_id'];
$docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
if ($docData) {
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?action=delete&id='.$workId.'&document_id='.$documentId.'&'.api_get_cidreq();
$url = $urlDocument.'?action=delete&id='.$workId.'&document_id='.$documentId.'&'.api_get_cidreq();
$link = Display::url(get_lang('Remove'), $url, ['class' => 'btn btn-danger']);
echo $docData['title'].' '.$link.'<br />';
}
@ -74,12 +75,16 @@ if (empty($docId)) {
$documentTree = DocumentManager::get_document_preview(
$courseInfo,
null,
false,
null,
api_get_session_id(),
false,
'/',
api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq()
api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq(),
false,
false,
false,
false
);
echo Display::page_subheader(get_lang('Documents'));
echo $documentTree;

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin.
*

@ -259,7 +259,6 @@ class CustomCertificatePlugin extends Plugin
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true') {
$infoCertificate = self::getCertificateData($certId, $userId);
var_dump($infoCertificate);
if (!empty($infoCertificate)) {
if ($certificate->user_id == api_get_user_id() && !empty($certificate->certificate_data)) {
$certificateId = $certificate->certificate_data['id'];

@ -1,7 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
if (intval($_GET['default']) == 1) {
$isDefault = isset($_GET['default']) ? (int) $_GET['default'] : null;
if ($isDefault === 1) {
$cidReset = true;
}
@ -17,7 +19,7 @@ $enable = $plugin->get('enable_plugin_customcertificate') == 'true';
$accessUrlId = api_get_current_access_url_id();
$course_info = api_get_course_info();
if (intval($_GET['default']) == 1) {
if ($isDefault === 1) {
$courseId = 0;
$courseCode = '';
$sessionId = 0;
@ -72,15 +74,6 @@ $infoCertificate = Database::select(
],
'first'
);
if (!is_array($infoCertificate)) {
$infoCertificate = [
'type_date_expediction' => '',
'year' => '',
'month' => '',
'day' => '',
'date_change' => '',
];
}
$form = new FormValidator(
'formEdit',
@ -106,13 +99,13 @@ if ($form->validate()) {
'c_id' => $formValues['c_id'],
'session_id' => $formValues['session_id'],
'content_course' => $formValues['content_course'],
'contents_type' => intval($formValues['contents_type']),
'contents_type' => (int) $formValues['contents_type'],
'contents' => $contents,
'date_change' => intval($formValues['date_change']),
'date_start' => date("Y-m-d", strtotime($date_start)),
'date_end' => date("Y-m-d", strtotime($date_end)),
'place' => $formValues['place'],
'type_date_expediction' => intval($formValues['type_date_expediction']),
'type_date_expediction' => (int) $formValues['type_date_expediction'],
'day' => $formValues['day'],
'month' => $formValues['month'],
'year' => $formValues['year'],
@ -120,8 +113,8 @@ if ($form->validate()) {
'signature_text2' => $formValues['signature_text2'],
'signature_text3' => $formValues['signature_text3'],
'signature_text4' => $formValues['signature_text4'],
'margin_left' => intval($formValues['margin_left']),
'margin_right' => intval($formValues['margin_right']),
'margin_left' => (int) $formValues['margin_left'],
'margin_right' => (int) $formValues['margin_right'],
'certificate_default' => 0,
];
@ -215,7 +208,13 @@ if (empty($infoCertificate)) {
);
if (!is_array($infoCertificate)) {
$infoCertificate = [];
$infoCertificate = [
'type_date_expediction' => '',
'year' => '',
'month' => '',
'day' => '',
'date_change' => '',
];
}
if (!empty($infoCertificate)) {
$useDefault = true;
@ -245,7 +244,7 @@ $dir = '/';
$courseInfo = api_get_course_info();
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
$editorConfig = [
'ToolbarSet' => ($isAllowedToEdit ? 'Documents' : 'DocumentsStudent'),
'ToolbarSet' => $isAllowedToEdit ? 'Documents' : 'DocumentsStudent',
'Width' => '100%',
'Height' => '300',
'cols-size' => [0, 12, 0],

@ -5,7 +5,7 @@ use Chamilo\CourseBundle\Entity\CLpCategory;
$default = isset($_GET['default']) ? (int) $_GET['default'] : null;
if ($default == 1) {
if ($default === 1) {
$cidReset = true;
}
@ -41,6 +41,8 @@ if (empty($courseCode)) {
if (!empty($courseInfo)) {
$courseId = $courseInfo['real_id'];
}
} else {
$courseInfo = api_get_course_info($courseCode);
}
if (empty($sessionId)) {
@ -116,17 +118,21 @@ if (empty($infoCertificate)) {
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']);
$widthCell = intval($workSpace / 6);
$htmlText = '<html>';
$htmlText .= '
$htmlList = [];
$currentLocalTime = api_get_local_time();
foreach ($userList as $userInfo) {
$htmlText = '<html>';
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">';
$htmlText .= '
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'document.css">';
$htmlText .= '<body>';
foreach ($userList as $userInfo) {
$htmlText .= '<body>';
$studentId = $userInfo['user_id'];
if (empty($infoCertificate['background'])) {
@ -248,8 +254,10 @@ foreach ($userList as $userInfo) {
);
}
} else {
$dateInfo = api_get_local_time($sessionInfo['access_end_date']);
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG);
if (!empty($sessionInfo)) {
$dateInfo = api_get_local_time($sessionInfo['access_end_date']);
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG);
}
}
}
@ -284,52 +292,52 @@ foreach ($userList as $userInfo) {
$htmlText .= '<tr>';
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : '').
'</td>
((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : '').
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : '').
'</td>
((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : '').
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : '').
'</td>
((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : '').
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text4'])) ? $infoCertificate['signature_text4'] : '').
'</td>
((!empty($infoCertificate['signature_text4'])) ? $infoCertificate['signature_text4'] : '').
'</td>
<td colspan="4" class="seals" style="width:'.(2 * $widthCell).'mm">
'.((!empty($infoCertificate['seal'])) ? $plugin->get_lang('Seal') : '').
'</td>';
'</td>';
$htmlText .= '</tr>';
$htmlText .= '<tr>';
$htmlText .= '<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature1']))
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;"
((!empty($infoCertificate['signature1']))
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature1'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature2']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
((!empty($infoCertificate['signature2']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature2'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature3']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
((!empty($infoCertificate['signature3']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature3'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature4']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
((!empty($infoCertificate['signature4']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature4'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="4" class="logo-seals" style="width:'.(2 * $widthCell).'mm">'.
((!empty($infoCertificate['seal']))
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
((!empty($infoCertificate['seal']))
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['seal'].'" />'
: '').
'</td>';
: '').
'</td>';
$htmlText .= '</tr>';
$htmlText .= '</table>';
$htmlText .= '</div>';
@ -465,24 +473,50 @@ foreach ($userList as $userInfo) {
}
$htmlText .= '</div>';
}
$htmlText .= '</body></html>';
$fileName = 'certificate_'.$courseInfo['code'].'_'.$userInfo['complete_name'].'_'.$currentLocalTime;
$htmlList[$fileName] = $htmlText;
}
$fileList = [];
$archivePath = api_get_path(SYS_ARCHIVE_PATH).'certificates/';
if (!is_dir($archivePath)) {
mkdir($archivePath, api_get_permissions_for_new_directories());
}
foreach ($htmlList as $fileName => $content) {
$fileName = api_replace_dangerous_char($fileName);
$params = [
'filename' => $fileName,
'pdf_title' => 'Certificate',
'pdf_description' => '',
'format' => 'A4-L',
'orientation' => 'L',
'left' => 15,
'top' => 15,
'bottom' => 0,
];
$pdf = new PDF($params['format'], $params['orientation'], $params);
if (count($htmlList) == 1) {
$pdf->content_to_pdf($content, '', $fileName, null, 'D', false, null, false, false, false);
exit;
} else {
$filePath = $archivePath.$fileName.'.pdf';
$pdf->content_to_pdf($content, '', $fileName, null, 'F', true, $filePath, false, false, false);
$fileList[] = $filePath;
}
}
if (!empty($fileList)) {
$zipFile = $archivePath.'certificates_'.api_get_unique_id().'.zip';
$zipFolder = new PclZip($zipFile);
foreach ($fileList as $file) {
$zipFolder->add($file, PCLZIP_OPT_REMOVE_ALL_PATH);
}
$name = 'certificates_'.$courseInfo['code'].'_'.$currentLocalTime.'.zip';
DocumentManager::file_send_for_download($zipFile, true, $name);
exit;
}
$htmlText .= '</body></html>';
$fileName = 'certificate_'.date('Ymd_His');
$params = [
'filename' => $fileName,
'pdf_title' => 'Certificate',
'pdf_description' => '',
'format' => 'A4-L',
'orientation' => 'L',
'left' => 15,
'top' => 15,
'bottom' => 0,
];
$pdf = new PDF($params['format'], $params['orientation'], $params);
$pdf->content_to_pdf($htmlText, '', $fileName, null, 'D', false, null, false, false, false);
exit;
function getIndexFiltered($index)
{
@ -491,12 +525,16 @@ function getIndexFiltered($index)
$lines = explode(chr(13).chr(10), $txt);
$text1 = '';
for ($x = 0; $x < 47; $x++) {
$text1 .= $lines[$x].chr(13).chr(10);
if (isset($lines[$x])) {
$text1 .= $lines[$x].chr(13).chr(10);
}
}
$text2 = '';
for ($x = 47; $x < 94; $x++) {
$text2 .= $lines[$x].chr(13).chr(10);
if (isset($lines[$x])) {
$text2 .= $lines[$x].chr(13).chr(10);
}
}
$showLeft = str_replace(chr(13).chr(10), "<br/>", $text1);

@ -58,18 +58,23 @@ class NotebookTeacherPlugin extends Plugin
return false;
}
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png';
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png';
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png';
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png';
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png';
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png';
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png';
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png';
copy($srcfile1, $dstfile1);
copy($srcfile2, $dstfile2);
copy($srcfile3, $dstfile3);
copy($srcfile4, $dstfile4);
$list = [
'/64/notebookteacher.png',
'/64/notebookteacher_na.png',
'/32/notebookteacher.png',
'/32/notebookteacher_na.png',
'/32/test2pdf_na.png',
'/22/notebookteacher.png',
];
foreach ($list as $file) {
$source = __DIR__.'/../resources/img/'.$file;
$destination = __DIR__.'/../../../main/img/icons/'.$file;
$res = @copy($source, $destination);
if (!$res) {
break;
}
}
require_once api_get_path(SYS_PLUGIN_PATH).'notebookteacher/database.php';
}

@ -80,7 +80,7 @@ class SepePlugin extends Plugin
$sm = $cn->getSchemaManager();
$tables = $sm->tablesExist($tablesToBeCompared);
if ($tables) {
if (empty($tables)) {
return false;
}

@ -39,19 +39,28 @@ class Test2pdfPlugin extends Plugin
//Installing course settings
$this->install_course_fields_in_all_courses();
$srcfile1 = __DIR__.'/../resources/img/64/test2pdf.png';
$srcfile2 = __DIR__.'/../resources/img/64/test2pdf_na.png';
$srcfile3 = __DIR__.'/../resources/img/22/test2pdf.png';
$dstfile1 = __DIR__.'/../../../main/img/icons/64/test2pdf.png';
$dstfile2 = __DIR__.'/../../../main/img/icons/64/test2pdf_na.png';
$dstfile3 = __DIR__.'/../../../main/img/test2pdf.png';
$res1 = @copy($srcfile1, $dstfile1);
$res2 = @copy($srcfile2, $dstfile2);
$res3 = @copy($srcfile3, $dstfile3);
if (!$res1 || !$res2 || !$res3) {
$warning = 'Test2PDF plugin icons could not be copied to main/img/ because of folder permissions. To fix, give web server user permissions to write to main/img/ before enabling this plugin.';
Display::addFlash($warning);
error_log($warning);
$list = [
'/64/test2pdf.png',
'/64/test2pdf_na.png',
'/32/test2pdf.png',
'/32/test2pdf_na.png',
'/22/test2pdf.png',
];
$res = true;
foreach ($list as $file) {
$source = __DIR__.'/../resources/img/'.$file;
$destination = __DIR__.'/../../../main/img/icons/'.$file;
$res = @copy($source, $destination);
if (!$res) {
break;
}
}
if (!$res) {
$warning = 'Test2PDF plugin icons could not be copied to main/img/ because of folder permissions.
To fix, give web server user permissions to write to main/img/ before enabling this plugin.';
Display::addFlash(Display::return_message($warning, 'warning'));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save