Minor - flint fixes

pull/3215/head
Julio Montoya 6 years ago
parent 442ea1caf0
commit bdf7a91eb6
  1. 4
      config/packages/fos_rest.yaml
  2. 1
      public/main/course_info/delete_course.php
  3. 1
      public/main/course_info/maintenance.php
  4. 10
      public/main/course_progress/index.php
  5. 70
      public/main/cron/import_csv.php
  6. 2
      public/main/exercise/exercise.class.php
  7. 52
      public/main/forum/forumfunction.inc.php
  8. 1
      public/main/forum/index.php
  9. 1
      public/main/forum/viewforum.php
  10. 2
      public/main/forum/viewthread.php
  11. 2
      public/main/inc/ajax/model.ajax.php
  12. 5
      public/main/inc/ajax/sequence.ajax.php
  13. 3
      public/main/inc/introductionSection.inc.php
  14. 10
      public/main/inc/lib/AnnouncementManager.php
  15. 5
      public/main/inc/lib/CourseChatUtils.php
  16. 44
      public/main/inc/lib/agenda.lib.php
  17. 3
      public/main/inc/lib/api.lib.php
  18. 38
      public/main/inc/lib/attendance.lib.php
  19. 3
      public/main/inc/lib/course.lib.php
  20. 2
      public/main/inc/lib/fileUpload.lib.php
  21. 88
      public/main/inc/lib/sessionmanager.lib.php
  22. 1
      public/main/inc/lib/surveymanager.lib.php
  23. 10
      public/main/inc/lib/system_announcements.lib.php
  24. 74
      public/main/inc/lib/template.lib.php
  25. 44
      public/main/inc/lib/thematic.lib.php
  26. 2
      public/main/lp/LearnPathItemForm.php
  27. 50
      public/main/lp/learnpath.class.php
  28. 1
      public/main/lp/learnpathItem.class.php
  29. 2
      public/main/mySpace/access_details_session.php
  30. 470
      src/CoreBundle/Controller/ResourceController.php
  31. 3
      src/CoreBundle/Entity/Resource/ResourceNode.php
  32. 4
      src/CoreBundle/Repository/ResourceRepository.php
  33. 72
      src/CoreBundle/Repository/SequenceResourceRepository.php
  34. 48
      src/CoreBundle/Traits/ResourceControllerTrait.php
  35. 10
      src/CourseBundle/Entity/CAttendance.php
  36. 10
      src/CourseBundle/Entity/CCalendarEventAttachment.php
  37. 10
      src/CourseBundle/Entity/CCourseDescription.php
  38. 10
      src/CourseBundle/Entity/CGlossary.php
  39. 10
      src/CourseBundle/Entity/CThematic.php
  40. 10
      src/CourseBundle/Entity/CThematicAdvance.php
  41. 10
      src/CourseBundle/Entity/CThematicPlan.php

@ -4,8 +4,8 @@ fos_rest:
param_fetcher_listener: true
format_listener:
rules:
- { path: '^/api', priorities:['json'], fallback_format: json, prefer_extension: false }
- { path: '^/', priorities: [ 'html', '*/*'], fallback_format: ~, prefer_extension: true }
- {path: '^/api', priorities:['json'], fallback_format: json, prefer_extension: false}
- {path: '^/', priorities: [ 'html', '*/*'], fallback_format: ~, prefer_extension: true}
view:
view_response_listener: true
# formats:

@ -53,4 +53,3 @@ if (isset($_GET['delete']) && 'yes' === $_GET['delete']) {
$tpl->assign('content', Display::return_message($message, 'warning', false));
$tpl->display_one_col_template();
}

@ -4,7 +4,6 @@
/**
* @author Created on 18 October 2006 by Elixir Interactive http://www.elixir-interactive.com
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_MAINTENANCE;
$this_section = SECTION_COURSES;

@ -551,7 +551,7 @@ switch ($action) {
$list = [];
// Display thematic data
if (!empty($thematic_data)) {
$listThematic = [ ];
$listThematic = [];
/** @var CThematic $thematic */
foreach ($thematic_data as $thematic) {
$id = $thematic->getIid();
@ -699,7 +699,7 @@ switch ($action) {
$description_list = $_REQUEST['description'];
$description_type = $_REQUEST['description_type'];
for ($i = 1; $i < count($title_list) + 1; ++$i) {
for ($i = 1; $i < count($title_list) + 1; $i++) {
$thematicManager->set_thematic_plan_attributes(
$_REQUEST['thematic_id'],
$title_list[$i],
@ -1103,7 +1103,7 @@ switch ($action) {
$attendance_select_item_id = $key;
break;
}
++$i;
$i++;
}
if (!empty($attendance_select_item_id)) {
$default['attendance_select'] = $attendance_select_item_id;
@ -1128,11 +1128,11 @@ switch ($action) {
$default['start_date_type'] = 2;
//$default['custom_start_date'] = null;
//if ($advance->getStartDate()) {
$default['custom_start_date'] = date(
$default['custom_start_date'] = date(
'Y-m-d H:i:s',
api_strtotime(api_get_local_time($advance->getStartDate()))
);
//}
//}
} else {
$default['start_date_type'] = 1;
if (!empty($thematic_advance_data['start_date'])) {

@ -131,7 +131,7 @@ class ImportCsv
if (!empty($files)) {
foreach ($files as $file) {
$fileInfo = pathinfo($file);
if (isset($fileInfo['extension']) && $fileInfo['extension'] === 'csv') {
if (isset($fileInfo['extension']) && 'csv' === $fileInfo['extension']) {
// Checking teachers_yyyymmdd.csv,
// courses_yyyymmdd.csv, students_yyyymmdd.csv and sessions_yyyymmdd.csv
$parts = explode('_', $fileInfo['filename']);
@ -141,37 +141,37 @@ class ImportCsv
$isStatic = strpos($method, 'Static');
if ($method == 'importSessionsextidStatic') {
if ('importSessionsextidStatic' == $method) {
$method = 'importSessionsExtIdStatic';
}
if ($method == 'importCourseinsertStatic') {
if ('importCourseinsertStatic' == $method) {
$method = 'importSubscribeUserToCourse';
}
if ($method == 'importUnsubsessionsextidStatic') {
if ('importUnsubsessionsextidStatic' == $method) {
$method = 'importUnsubsessionsExtidStatic';
}
if ($method == 'importCareersdiagram') {
if ('importCareersdiagram' == $method) {
$method = 'importCareersDiagram';
}
if ($method == 'importCareersresults') {
if ('importCareersresults' == $method) {
$method = 'importCareersResults';
}
if ($method == 'importOpensessions') {
if ('importOpensessions' == $method) {
$method = 'importOpenSessions';
}
if ($method == 'importSubsessionsextidStatic') {
if ('importSubsessionsextidStatic' == $method) {
$method = 'importSubscribeUserToCourseSessionExtStatic';
}
if (method_exists($this, $method)) {
if ((
$method == 'importSubscribeStatic' ||
$method == 'importSubscribeUserToCourse'
'importSubscribeStatic' == $method ||
'importSubscribeUserToCourse' == $method
) ||
empty($isStatic)
) {
@ -231,7 +231,7 @@ class ImportCsv
$this->logger->addInfo('====================================================');
$this->logger->addInfo("Reading file: $file");
$this->logger->addInfo("Loading method $method ");
if ($method == 'importSessions' || $method == 'importOpenSessions') {
if ('importSessions' == $method || 'importOpenSessions' == $method) {
$this->$method(
$file,
true,
@ -405,7 +405,7 @@ class ImportCsv
$this->logger->addInfo("Post id saved #".$post->getId());
if (($counter % $batchSize) === 0) {
if (0 === ($counter % $batchSize)) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
}
@ -437,7 +437,7 @@ class ImportCsv
*/
public function updateUsersEmails()
{
if ($this->getUpdateEmailToDummy() === true) {
if (true === $this->getUpdateEmailToDummy()) {
$sql = "UPDATE user SET email = CONCAT(username,'@example.com') WHERE id NOT IN (SELECT user_id FROM admin)";
Database::query($sql);
}
@ -693,7 +693,7 @@ class ImportCsv
if ($userId) {
foreach ($row as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
if ('extra_' == substr($key, 0, 6)) {
//an extra field
UserManager::update_extra_field_value(
$userId,
@ -740,7 +740,7 @@ class ImportCsv
if ($result) {
foreach ($row as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
if ('extra_' == substr($key, 0, 6)) {
//an extra field
UserManager::update_extra_field_value(
$userInfo['user_id'],
@ -755,7 +755,7 @@ class ImportCsv
}
}
if (($counter % $batchSize) === 0) {
if (0 === ($counter % $batchSize)) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
}
@ -895,7 +895,7 @@ class ImportCsv
if ($result) {
foreach ($row as $key => $value) {
if (substr($key, 0, 6) === 'extra_') {
if ('extra_' === substr($key, 0, 6)) {
//an extra field
UserManager::update_extra_field_value(
$result,
@ -916,7 +916,7 @@ class ImportCsv
continue;
}
if (isset($row['action']) && $row['action'] === 'delete') {
if (isset($row['action']) && 'delete' === $row['action']) {
// Inactive one year later
$userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + $secondsInYear));
}
@ -1005,7 +1005,7 @@ class ImportCsv
$this->logger->addInfo("Students - Username was changes from '".$userInfo['username']."' to '".$row['username']."' ");
}
foreach ($row as $key => $value) {
if (substr($key, 0, 6) === 'extra_') {
if ('extra_' === substr($key, 0, 6)) {
//an extra field
UserManager::update_extra_field_value(
$userInfo['user_id'],
@ -1020,7 +1020,7 @@ class ImportCsv
}
}
if (($counter % $batchSize) === 0) {
if (0 === ($counter % $batchSize)) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
$this->logger->addInfo("Detaches all objects");
@ -1091,7 +1091,7 @@ class ImportCsv
'disable_import_calendar'
);
if (!empty($item) && isset($item['value']) && $item['value'] == 1) {
if (!empty($item) && isset($item['value']) && 1 == $item['value']) {
$this->logger->addInfo(
"Course '".$courseInfo['code']."' has 'disable_import_calendar' turn on. Skip"
);
@ -1101,7 +1101,7 @@ class ImportCsv
if (empty($courseInfo)) {
$this->logger->addInfo("Course '$courseCode' does not exists");
} else {
if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN) {
if (COURSE_VISIBILITY_HIDDEN == $courseInfo['visibility']) {
$this->logger->addInfo("Course '".$courseInfo['code']."' has hidden visiblity. Skip");
$errorFound = true;
}
@ -1119,7 +1119,7 @@ class ImportCsv
$courseInfo['real_id']
);
if ($courseIncluded == false) {
if (false == $courseIncluded) {
$this->logger->addInfo(
"Course '$courseCode' is not included in session: $sessionId"
);
@ -1183,7 +1183,7 @@ class ImportCsv
}
}
if ($errorFound == false) {
if (false == $errorFound) {
$eventsToCreate[] = [
'start' => $startDate,
'end' => $endDate,
@ -1416,7 +1416,7 @@ class ImportCsv
}
// Send announcement to users
if ($sendMail && $alreadyAdded == false) {
if ($sendMail && false == $alreadyAdded) {
$start = $firstDate;
$end = $firstEndDate;
@ -1448,7 +1448,7 @@ class ImportCsv
'careerid'
);
$externalCareerIdList = $externalCareerIdList['value'];
if (substr($externalCareerIdList, 0, 1) === '[') {
if ('[' === substr($externalCareerIdList, 0, 1)) {
$externalCareerIdList = substr($externalCareerIdList, 1, -1);
$externalCareerIds = preg_split('/,/', $externalCareerIdList);
} else {
@ -1513,7 +1513,7 @@ class ImportCsv
1
);
if (count($announcementsWithTitleList) === 0) {
if (0 === count($announcementsWithTitleList)) {
$this->logger->addInfo(
'Mail to be sent because start date: '.$event['start'].' and no announcement found.'
);
@ -1568,7 +1568,7 @@ class ImportCsv
$this->logger->addInfo(
"Send Mail: ".intval($sendMail).' - Already added: '.intval($alreadyAdded)
);
if ($sendMail == false) {
if (false == $sendMail) {
$report['mail_not_sent_because_date']++;
}
}
@ -1636,7 +1636,7 @@ class ImportCsv
$this->defaultAdminId
);
if ($eventResult !== false) {
if (false !== $eventResult) {
$this->logger->addInfo(
"Event updated #".$item['item_id']." External cal Id: (".$externalEventId.") $info"
);
@ -1681,7 +1681,7 @@ class ImportCsv
}
}
if (($counter % $batchSize) === 0) {
if (0 === ($counter % $batchSize)) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
}
@ -2273,7 +2273,7 @@ class ImportCsv
$courseCoachId = UserManager::get_user_id_from_username(
$courseCoach
);
if ($courseCoachId !== false) {
if (false !== $courseCoachId) {
// Just insert new coaches
$coachList[] = $courseCoachId;
}
@ -3228,7 +3228,7 @@ $logger->pushHandler(new BufferHandler($stream, 0, $minLevel));
$logger->pushHandler(new RotatingFileHandler('import_csv', 5, $minLevel));
$verbose = false;
if (isset($argv[1]) && $argv[1] === '--verbose') {
if (isset($argv[1]) && '--verbose' === $argv[1]) {
$verbose = true;
}
if ($verbose) {
@ -3246,12 +3246,12 @@ if (isset($_configuration['default_admin_user_id_for_cron'])) {
}
// @todo in production disable the dump option
$dump = false;
if (isset($argv[1]) && $argv[1] === '--dump') {
if (isset($argv[1]) && '--dump' === $argv[1]) {
$dump = true;
}
if (isset($_configuration['import_csv_disable_dump']) &&
$_configuration['import_csv_disable_dump'] == true
true == $_configuration['import_csv_disable_dump']
) {
$import->setDumpValues(false);
} else {
@ -3287,7 +3287,7 @@ $executionTime = round(($timeEnd - $timeStart) / 60, 2);
$logger->addInfo("Total execution Time $executionTime Min");
if (isset($_configuration['import_csv_fix_permissions']) &&
$_configuration['import_csv_fix_permissions'] == true
true == $_configuration['import_csv_fix_permissions']
) {
$command = "sudo find ".api_get_path(SYS_COURSE_PATH)." -type d -exec chmod 777 {} \; ";
echo "Executing: ".$command.PHP_EOL;

@ -7989,7 +7989,7 @@ class Exercise
public function getPreventBackwards()
{
$allow = api_get_configuration_value('quiz_prevent_backwards_move');
if ($allow === false) {
if (false === $allow) {
return 0;
}

@ -151,7 +151,7 @@ function handleForum($url)
$message = set_notification($content, $id);
Display::addFlash(Display::return_message($message, 'confirm', false));
header('Location: '. $url);
header('Location: '.$url);
exit;
break;
case 'lock':
@ -160,7 +160,7 @@ function handleForum($url)
if ('lock' === $action) {
$locked = 1;
$message = get_lang('Locked: students can no longer post new messages in this forum category, forum or thread but they can still read the messages that were already posted');
} else {
} else {
$locked = 0;
$message = get_lang('Unlocked: learners can post new messages in this forum category, forum or thread');
}
@ -174,12 +174,12 @@ function handleForum($url)
);
}
header('Location: '. $url);
header('Location: '.$url);
exit;
break;
case 'move':
move_up_down($content, $_REQUEST['direction'] ?? '', $id);
header('Location: '. $url);
header('Location: '.$url);
exit;
break;
case 'move_thread':
@ -202,7 +202,7 @@ function handleForum($url)
Display::addFlash(
Display::return_message(get_lang('Updated'), 'confirmation', false)
);
header('Location: '. $url);
header('Location: '.$url);
exit;
break;
case 'delete':
@ -229,7 +229,7 @@ function handleForum($url)
}
Display::addFlash(Display::return_message(get_lang('Forum category deleted'), 'confirmation', false));
header('Location: '. $url);
header('Location: '.$url);
exit;
break;
}
@ -1260,7 +1260,6 @@ function return_up_down_icon($content, $id, $list)
return $return_value;
}
/**
* This function moves a forum or a forum category up or down.
*
@ -1365,7 +1364,6 @@ function move_up_down($content, $direction, $id)
/** @var CForumCategory $forum */
$category = $repo->find($id);
if ($category) {
$category->setCatOrder($next_sort);
$repo->getEntityManager()->persist($category);
$repo->getEntityManager()->flush();
@ -1380,8 +1378,8 @@ function move_up_down($content, $direction, $id)
* Retrieve all the information off the forum categories (or one specific) for the current course.
* The categories are sorted according to their sorting order (cat_order.
*
* @param int $courseId Optional. The course ID
* @param int $sessionId Optional. The session ID
* @param int $courseId Optional. The course ID
* @param int $sessionId Optional. The session ID
*
* @return CForumCategory[]
*/
@ -1400,8 +1398,8 @@ function get_forum_categories($courseId = 0, $sessionId = 0)
/**
* This function retrieves all the fora in a given forum category.
*
* @param int $categoryId the id of the forum category
* @param int $courseId Optional. The course ID
* @param int $categoryId the id of the forum category
* @param int $courseId Optional. The course ID
*
* @return CForumForum[] containing all the information about the forums (regardless of their category)
*
@ -2035,7 +2033,7 @@ function getPosts(
'visible' => $post->getVisible(),
'status' => $post->getStatus(),
'indent_cnt' => $depth,
'entity' => $post
'entity' => $post,
];
$posterId = $post->getPosterId();
@ -2714,17 +2712,15 @@ function store_thread(
/**
* This function displays the form that is used to add a post. This can be a new thread or a reply.
*
* @param CForumForum $forum
* @param CForumThread $thread
* @param string $action
* is the parameter that determines if we are
* 2. replythread: Replying to a thread ($action = replythread) => I-frame with the complete thread (if enabled)
* 3. replymessage: Replying to a message ($action =replymessage) => I-frame with the complete thread (if enabled)
* (I first thought to put and I-frame with the message only)
* 4. quote: Quoting a message ($action= quotemessage) => I-frame with the complete thread (if enabled).
* The message will be in the reply. (I first thought not to put an I-frame here)
* @param array $form_values
* @param bool $showPreview
* @param string $action
* is the parameter that determines if we are
* 2. replythread: Replying to a thread ($action = replythread) => I-frame with the complete thread (if enabled)
* 3. replymessage: Replying to a message ($action =replymessage) => I-frame with the complete thread (if enabled)
* (I first thought to put and I-frame with the message only)
* 4. quote: Quoting a message ($action= quotemessage) => I-frame with the complete thread (if enabled).
* The message will be in the reply. (I first thought not to put an I-frame here)
* @param array $form_values
* @param bool $showPreview
*
* @return FormValidator
*/
@ -4504,7 +4500,6 @@ function move_post_form()
// Setting the rules
$form->addRule('thread', get_lang('Required field'), 'required');
return $form;
}
@ -4568,7 +4563,6 @@ function store_move_post($values)
$new_thread_id = $thread->getIid();
// Storing a new thread.
/*$params = [
'c_id' => $course_id,
@ -4588,7 +4582,7 @@ function store_move_post($values)
$new_thread_id,
'visible',
$current_post['poster_id']
);*/;
);*/
// Moving the post to the newly created thread.
$sql = "UPDATE $table_posts SET thread_id='".(int) $new_thread_id."', post_parent_id = NULL
@ -4985,8 +4979,8 @@ function search_link()
/**
* This function adds an attachment file into a forum.
*
* @param string $file_comment a comment about file
* @param CForumPost $post from forum_post table
* @param string $file_comment a comment about file
* @param CForumPost $post from forum_post table
*
* @return false|null
*/

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CForumPost;
use ChamiloSession as Session;

@ -306,7 +306,6 @@ if (api_is_allowed_to_edit(false, true) ||
}
echo '</div>';
/* Display the action messages */
if (!empty($message)) {
echo $message;

@ -39,7 +39,7 @@ $threadEntity = $repoThread->find($threadId);
if (empty($threadEntity)) {
$url = api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.api_get_cidreq().'&forum='.$forumId;
header('Location: '. $url);
header('Location: '.$url);
exit;
}

@ -1143,7 +1143,7 @@ switch ($action) {
'currently_learning',
'rank',
];
if (trim($whereCondition) === '1 = 1') {
if ('1 = 1' === trim($whereCondition)) {
$whereCondition = '';
}
$result = $skill->getUserListSkillRanking(

@ -2,10 +2,10 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Repository\SequenceRepository;
use Chamilo\CoreBundle\Repository\SequenceResourceRepository;
use Chamilo\CoreBundle\Entity\Sequence;
use Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CoreBundle\Repository\SequenceRepository;
use Chamilo\CoreBundle\Repository\SequenceResourceRepository;
use ChamiloSession as Session;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex;
@ -440,7 +440,6 @@ switch ($action) {
$view->assign('sequence_type', $type);
$view->assign('allow_subscription', $allowSubscription);
if ($allowSubscription) {
$view->assign(
'subscribe_button',

@ -215,7 +215,8 @@ if (TOOL_COURSE_HOMEPAGE == $tool && !isset($_GET['intro_cmdEdit'])) {
$thematic_advance_info['start_date'] = api_format_date(
$thematic_advance_info['start_date'],
DATE_TIME_FORMAT_LONG
); $userInfo = api_get_user_info();
);
$userInfo = api_get_user_info();
$courseInfo = api_get_course_info();
$titleThematic = $thematic_advance.' : '.$courseInfo['name'].' <b>( '.$thematicScore.' )</b>';

@ -179,15 +179,15 @@ class AnnouncementManager
announcement.id,
announcement.title,
announcement.content
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property i
ON (announcement.id = i.ref AND announcement.c_id = i.c_id)
WHERE
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property i
ON (announcement.id = i.ref AND announcement.c_id = i.c_id)
WHERE
i.tool='announcement' AND
announcement.session_id = '$session_id' AND
announcement.c_id = $courseId AND
i.c_id = $courseId
ORDER BY display_order DESC";
ORDER BY display_order DESC";
$rs = Database::query($sql);
$num_rows = Database::num_rows($rs);
if ($num_rows > 0) {

@ -8,7 +8,6 @@ use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
use Chamilo\CoreBundle\Entity\Resource\ResourceNode;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CoreBundle\Repository\ResourceNodeRepository;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CourseBundle\Entity\CChatConnected;
use Chamilo\CourseBundle\Entity\CChatConversation;
@ -127,8 +126,6 @@ class CourseChatUtils
$fileTitle = $basename_chat.'-log.html';
$userPhoto = UserManager::getUserPicture($this->userId, USER_IMAGE_SIZE_MEDIUM);
if ($isMaster) {
@ -171,7 +168,6 @@ class CourseChatUtils
}
}
/*fputs($fp, $fileContent);
fclose($fp);
$size = filesize($absoluteFilePath);
@ -500,7 +496,6 @@ class CourseChatUtils
return '';
$remove = 0;
$content = [];

@ -224,18 +224,18 @@ class Agenda
/**
* Adds an event to the calendar.
*
* @param string $start datetime format: 2012-06-14 09:00:00 in local time
* @param string $end datetime format: 2012-06-14 09:00:00 in local time
* @param string $allDay (true, false)
* @param string $title
* @param string $content
* @param array $usersToSend array('everyone') or a list of user/group ids
* @param bool $addAsAnnouncement event as a *course* announcement
* @param int $parentEventId
* @param UploadedFile[] $attachmentArray array of $_FILES['']
* @param array $attachmentCommentList
* @param string $eventComment
* @param string $color
* @param string $start datetime format: 2012-06-14 09:00:00 in local time
* @param string $end datetime format: 2012-06-14 09:00:00 in local time
* @param string $allDay (true, false)
* @param string $title
* @param string $content
* @param array $usersToSend array('everyone') or a list of user/group ids
* @param bool $addAsAnnouncement event as a *course* announcement
* @param int $parentEventId
* @param UploadedFile[] $attachmentArray array of $_FILES['']
* @param array $attachmentCommentList
* @param string $eventComment
* @param string $color
*
* @return int
*/
@ -2137,6 +2137,24 @@ class Agenda
$event['type'] = 'session';
}
$everyone = false;
$links = $row->getResourceNode()->getResourceLinks();
$sentTo = [];
foreach ($links as $link) {
if ($link->getUser()) {
$sentTo[] = $link->getUser()->getFirstname();
}
if ($link->getCourse()) {
$sentTo[] = $link->getCourse()->getName();
}
if ($link->getSession()) {
$sentTo[] = $link->getSession()->getName();
}
if ($link->getGroup()) {
$sentTo[] = $link->getGroup()->getName();
}
}
// Event Sent to a group?
/*if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
$sent_to = [];
@ -2185,6 +2203,7 @@ class Agenda
/*if (empty($event['sent_to'])) {
$event['sent_to'] = '<div class="label_tag notice">'.get_lang('Everyone').'</div>';
}*/
$event['sent_to'] = implode('<br />', $sentTo);
$event['description'] = $row->getContent();
$event['visibility'] = $row->isVisible($courseEntity, $session) ? 1 : 0;
$event['real_id'] = $eventId;
@ -2940,7 +2959,6 @@ class Agenda
api_get_user_id()
);*/
}
}
}

@ -6111,8 +6111,7 @@ function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true)
true,
false,
false,
false,
$treat_spaces_as_hyphens
false
);
return $url;

@ -1664,8 +1664,8 @@ class Attendance
/**
* Add new datetime inside attendance calendar table.
*
* @param CAttendance $attendance
* @param array $groupList
* @param CAttendance $attendance
* @param array $groupList
*
* @return int affected rows
*/
@ -1694,7 +1694,7 @@ class Attendance
if ($id) {
$sql = "UPDATE $tbl_attendance_calendar SET id = iid WHERE iid = $id";
Database::query($sql);
++$affected_rows;
$affected_rows++;
}
$this->addAttendanceCalendarToGroup($id, $course_id, $groupList);
//}
@ -1809,11 +1809,11 @@ class Attendance
/**
* save repeated date inside attendance calendar table.
*
* @param CAttendance $attendance
* @param int $start_date start date in tms
* @param int $end_date end date in tms
* @param string $repeat_type daily, weekly, monthlyByDate
* @param array $groupList
* @param CAttendance $attendance
* @param int $start_date start date in tms
* @param int $end_date end date in tms
* @param string $repeat_type daily, weekly, monthlyByDate
* @param array $groupList
*/
public function attendance_repeat_calendar_add(
$attendance,
@ -1862,8 +1862,8 @@ class Attendance
/**
* edit a datetime inside attendance calendar table.
*
* @param int $calendar_id
* @param CAttendance $attendance
* @param int $calendar_id
* @param CAttendance $attendance
*
* @return int affected rows
*/
@ -2086,7 +2086,7 @@ class Attendance
$dateTimeStart->format('Y-m-d'),
];
for ($i = 0; $i < $days; ++$i) {
for ($i = 0; $i < $days; $i++) {
$dateTimeStart = $dateTimeStart->add(new DateInterval('P1D'));
$date = $dateTimeStart->format('Y-m-d');
$dateList[] = $date;
@ -2162,7 +2162,7 @@ class Attendance
$status = 'X';
}
$table->setCellContents($row, $column, $status);
++$column;
$column++;
}
$row++;
$column = 1;
@ -2542,7 +2542,7 @@ class Attendance
</td>
</tr>';
++$i;
$i++;
}
$form .= '</tbody>
</table>
@ -2694,7 +2694,7 @@ class Attendance
</td>';
}
echo '</tr>';
++$i;
$i++;
}
$form .= '</tbody></table>';
$form .= '</div></div>';
@ -2868,9 +2868,9 @@ class Attendance
} else {
$result[$class_day['id']] = ' ';
}
++$cols;
$cols++;
}
++$count;
$count++;
$data_table[] = $result;
}
}
@ -2885,7 +2885,7 @@ class Attendance
$tables = [];
$changed = 1;
for ($i = 0; $i <= $rows; ++$i) {
for ($i = 0; $i <= $rows; $i++) {
$row = isset($data_table[$i]) ? $data_table[$i] : null;
$key = 1;
$max_dates_per_page = 10;
@ -2895,14 +2895,14 @@ class Attendance
if (!empty($item)) {
foreach ($item as $value) {
if ($count_j >= $max_dates_per_page) {
++$key;
$key++;
$max_dates_per_page = $max_dates_per_page_original * $key;
//magic hack
$tables[$key][$i][] = $tables[1][$i][0];
$tables[$key][$i][] = $tables[1][$i][1];
}
$tables[$key][$i][] = $value;
++$count_j;
$count_j++;
}
}
}

@ -3,11 +3,11 @@
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use Chamilo\CoreBundle\Repository\SequenceResourceRepository;
use Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Hook\HookCreateCourse;
use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\CoreBundle\Repository\SequenceResourceRepository;
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
@ -2307,7 +2307,6 @@ class CourseManager
$courseId = $course['real_id'];
$courseEntity = api_get_course_entity($courseId);
/** @var SequenceResourceRepository $repo */
$repo = Database::getManager()->getRepository('ChamiloCoreBundle:SequenceResource');
$sequenceResource = $repo->findRequirementForResource(

@ -90,7 +90,7 @@ function process_uploaded_file($uploadedFileData, $show_output = true)
$uploadedFile = [];
if ($uploadedFileData instanceof UploadedFile) {
$uploadedFile['error'] = $uploadedFileData->getError();
$uploadedFile['tmp_name'] =$uploadedFileData->getPathname() ;
$uploadedFile['tmp_name'] = $uploadedFileData->getPathname();
$uploadedFile['size'] = $uploadedFileData->getSize();
} else {
$uploadedFile = $uploadedFileData;

@ -4,7 +4,6 @@
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Repository\SequenceResourceRepository;
use Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourse;
@ -133,27 +132,27 @@ class SessionManager
*
* @author Carlos Vargas <carlos.vargas@beeznest.com>, from existing code
*
* @param string $name
* @param string $startDate (YYYY-MM-DD hh:mm:ss)
* @param string $endDate (YYYY-MM-DD hh:mm:ss)
* @param string $displayStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $displayEndDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachEndDate (YYYY-MM-DD hh:mm:ss)
* @param mixed $coachId If int, this is the session coach id,
* if string, the coach ID will be looked for from the user table
* @param int $sessionCategoryId ID of the session category in which this session is registered
* @param int $visibility Visibility after end date (0 = read-only, 1 = invisible, 2 = accessible)
* @param bool $fixSessionNameIfExists
* @param string $duration
* @param string $description Optional. The session description
* @param int $showDescription Optional. Whether show the session description
* @param array $extraFields
* @param int $sessionAdminId Optional. If this sessions was created by a session admin, assign it to him
* @param bool $sendSubscriptionNotification Optional.
* Whether send a mail notification to users being subscribed
* @param int $accessUrlId Optional.
* @param int $status
* @param string $name
* @param string $startDate (YYYY-MM-DD hh:mm:ss)
* @param string $endDate (YYYY-MM-DD hh:mm:ss)
* @param string $displayStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $displayEndDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachEndDate (YYYY-MM-DD hh:mm:ss)
* @param mixed $coachId If int, this is the session coach id,
* if string, the coach ID will be looked for from the user table
* @param int $sessionCategoryId ID of the session category in which this session is registered
* @param int $visibility Visibility after end date (0 = read-only, 1 = invisible, 2 = accessible)
* @param bool $fixSessionNameIfExists
* @param string $duration
* @param string $description Optional. The session description
* @param int $showDescription Optional. Whether show the session description
* @param array $extraFields
* @param int $sessionAdminId Optional. If this sessions was created by a session admin, assign it to him
* @param bool $sendSubscriptionNotification Optional.
* Whether send a mail notification to users being subscribed
* @param int $accessUrlId Optional.
* @param int $status
*
* @return mixed Session ID on success, error message otherwise
*
@ -1688,7 +1687,7 @@ class SessionManager
}
if (api_get_configuration_value('allow_session_status')) {
$sessionEntity->setStatus($status);
$sessionEntity->setStatus($status);
}
$em->merge($sessionEntity);
@ -9322,6 +9321,27 @@ class SessionManager
];
}
public static function getStatusList()
{
return [
self::STATUS_PLANNED => get_lang('Planned'),
self::STATUS_PROGRESS => get_lang('InProgress'),
self::STATUS_FINISHED => get_lang('Finished'),
self::STATUS_CANCELLED => get_lang('Cancelled'),
];
}
public static function getStatusLabel($status)
{
$list = self::getStatusList();
if (!isset($list[$status])) {
return get_lang('NoStatus');
}
return $list[$status];
}
/**
* @param int $id
*
@ -9459,26 +9479,4 @@ class SessionManager
return -1;
}
}
public static function getStatusList()
{
return [
self::STATUS_PLANNED => get_lang('Planned'),
self::STATUS_PROGRESS => get_lang('InProgress'),
self::STATUS_FINISHED => get_lang('Finished'),
self::STATUS_CANCELLED => get_lang('Cancelled'),
];
}
public static function getStatusLabel($status)
{
$list = self::getStatusList();
if (!isset($list[$status])) {
return get_lang('NoStatus');
}
return $list[$status];
}
}

@ -861,7 +861,7 @@ class SystemAnnouncementManager
// Expiration date
$sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') ";
if ((empty($teacher) || $teacher == '0') && (empty($student) || $student == '0')) {
if ((empty($teacher) || '0' == $teacher) && (empty($student) || '0' == $student)) {
return true;
}
@ -957,7 +957,7 @@ class SystemAnnouncementManager
$sql .= " AND access_url_id IN ('1', '$current_url_id') ";
}
$checkCareers = api_get_configuration_value('allow_careers_in_global_announcements') === true;
$checkCareers = true === api_get_configuration_value('allow_careers_in_global_announcements');
$userId = api_get_user_id();
@ -984,14 +984,14 @@ class SystemAnnouncementManager
foreach ($sessionList as $session) {
$sessionId = $session['id'];
// Check student
if ($visible === self::VISIBLE_STUDENT &&
if (self::VISIBLE_STUDENT === $visible &&
SessionManager::isUserSubscribedAsStudent($sessionId, $userId)
) {
$show = true;
break 2;
}
if ($visible === self::VISIBLE_TEACHER &&
if (self::VISIBLE_TEACHER === $visible &&
SessionManager::user_is_general_coach($userId, $sessionId)
) {
$show = true;
@ -1001,7 +1001,7 @@ class SystemAnnouncementManager
// Check course coach
$coaches = SessionManager::getCoachesBySession($sessionId);
if ($visible === self::VISIBLE_TEACHER && in_array($userId, $coaches)) {
if (self::VISIBLE_TEACHER === $visible && in_array($userId, $coaches)) {
$show = true;
break 2;
}

@ -398,39 +398,6 @@ class Template
return $themeDir;
}
/**
* Set system parameters from api_get_configuration into _s array for use in TPLs
* Also fills the _p array from getWebPaths().
*
* @uses \self::getWebPaths()
*/
public function set_system_parameters()
{
$this->theme = api_get_visual_theme();
if (!empty($this->preview_theme)) {
$this->theme = $this->preview_theme;
}
$this->assign('theme', $this->theme);
$this->themeDir = self::getThemeDir($this->theme);
// Setting app paths/URLs
//$this->assign('_p', $this->getWebPaths());
// Here we can add system parameters that can be use in any template
$_s = [
'software_name' => api_get_configuration_value('software_name'),
'system_version' => api_get_configuration_value('system_version'),
'site_name' => api_get_setting('siteName'),
'institu_tion' => api_get_setting('Institution'),
'date' => api_format_date('now', DATE_FORMAT_LONG),
'timezone' => api_get_timezone(),
'gamification_mode' => api_get_setting('gamification_mode'),
];
$this->assign('_s', $_s);
}
/**
* Set legacy twig globals in order to be hook in the LegacyListener.php.
*
@ -438,41 +405,14 @@ class Template
*/
public static function getGlobals()
{
$queryString = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
$requestURI = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
/*$_p = [
'web' => api_get_path(WEB_PATH),
'web_relative' => api_get_path(REL_PATH),
'web_course' => api_get_path(WEB_COURSE_PATH),
'web_main' => api_get_path(WEB_CODE_PATH),
'web_css' => api_get_path(WEB_CSS_PATH),
//'web_css_theme' => api_get_path(WEB_CSS_PATH).$this->themeDir,
'web_ajax' => api_get_path(WEB_AJAX_PATH),
'web_img' => api_get_path(WEB_IMG_PATH),
'web_plugin' => api_get_path(WEB_PLUGIN_PATH),
'web_lib' => api_get_path(WEB_LIBRARY_PATH),
'web_self' => api_get_self(),
'web_self_query_vars' => api_htmlentities($requestURI),
'web_cid_query' => api_get_cidreq(),
];*/
$_s = [
'software_name' => api_get_configuration_value('software_name'),
'system_version' => api_get_configuration_value('system_version'),
'site_name' => api_get_setting('siteName'),
'institution' => api_get_setting('Institution'),
//'date' => api_format_date('now', DATE_FORMAT_LONG),
'date' => '',
'timezone' => '',
//'timezone' => api_get_timezone(),
'gamification_mode' => api_get_setting('gamification_mode'),
];
//$user_info = api_get_user_info();
return [
'_s' => $_s,
// '_u' => $user_info,
'_s' => [
'software_name' => api_get_configuration_value('software_name'),
'system_version' => api_get_configuration_value('system_version'),
'site_name' => api_get_setting('siteName'),
'institution' => api_get_setting('Institution'),
'gamification_mode' => api_get_setting('gamification_mode'),
],
'template' => 'default', // @todo setup template folder in config.yml;
];
}

@ -591,16 +591,16 @@ class Thematic
$i = 1;
while ($thematic_advance = Database::fetch_row($res)) {
//if (in_array($thematic_advance[0], $elements)) {
$thematic_advance[1] = api_get_local_time($thematic_advance[1]);
$thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG);
$actions = '';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
$thematic_advance[1] = api_get_local_time($thematic_advance[1]);
$thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG);
$actions = '';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
$actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('Are you sure you want to delete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
$actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('Are you sure you want to delete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a></center>';
$data[] = [$i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions];
++$i;
// }
$data[] = [$i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions];
$i++;
// }
}
}
@ -805,15 +805,13 @@ class Thematic
;
if ($thematic) {
$advance ->setThematic($thematic);
$advance->setThematic($thematic);
}
if ($attendance) {
$advance ->setAttendance($attendance);
$advance->setAttendance($attendance);
}
$em->persist($advance);
$repo->addResourceToCourse(
@ -849,11 +847,11 @@ class Thematic
;
if ($thematic) {
$advance ->setThematic($thematic);
$advance->setThematic($thematic);
}
if ($attendance) {
$advance ->setAttendance($attendance);
$advance->setAttendance($attendance);
}
$em->persist($advance);
$em->flush();
@ -895,7 +893,6 @@ class Thematic
return true;
$_course = api_get_course_info();
$course_id = api_get_course_int_id();
@ -1092,7 +1089,7 @@ class Thematic
$em->persist($plan);
$em->flush();
// update
// update
/*$params = [
'title' => $title,
'description' => $description,
@ -1258,7 +1255,7 @@ class Thematic
$repo = Container::getThematicRepository();
$em = $repo->getEntityManager();
$list = self::get_thematic_list( api_get_course_id());
$list = self::get_thematic_list(api_get_course_id());
$ordered = [];
foreach ($list as $thematic) {
@ -1270,7 +1267,6 @@ class Thematic
}*/
$advance->setDoneAdvance($done);
}
}
$done = true;
@ -1284,16 +1280,14 @@ class Thematic
$advance->setDoneAdvance($done);
$em->persist($advance);
}
$em->flush();
return true;
$_course = api_get_course_info();
$thematic_data = self::get_thematic_list( api_get_course_id());
$thematic_data = self::get_thematic_list(api_get_course_id());
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$affected_rows = 0;
@ -1456,7 +1450,7 @@ class Thematic
}
if (!empty($a_thematic_advance_ids)) {
for ($i = 0; $i < $offset; ++$i) {
for ($i = 0; $i < $offset; $i++) {
$next_advance_not_done = array_shift($a_thematic_advance_ids);
}
$next_advance_not_done = intval($next_advance_not_done);
@ -1479,9 +1473,9 @@ class Thematic
$course_code = api_get_course_id();
}
if (api_get_session_id()) {
$thematic_data = self::get_thematic_list( $course_code);
$thematic_data = self::get_thematic_list($course_code);
} else {
$thematic_data = self::get_thematic_list( $course_code, 0);
$thematic_data = self::get_thematic_list($course_code, 0);
}
$a_average_of_advances_by_thematic = [];
@ -1511,7 +1505,7 @@ class Thematic
* Get average of advances by thematic.
*
* @param CThematic $thematic
* @param string $course_code
* @param string $course_code
*
* @return float Average of thematic advances
*/

@ -7,7 +7,7 @@ use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Entity\CLpItem;
/**
* Class LearnPathItemForm
* Class LearnPathItemForm.
*/
class LearnPathItemForm
{

@ -4174,7 +4174,7 @@ class learnpath
* to normal users.
* Can be used as abstract.
*
* @param int $id Learnpath ID
* @param int $id Learnpath ID
* @param int $visibility New visibility
*
* @return bool
@ -4262,7 +4262,7 @@ class learnpath
* on the course homepage
* Can be used as abstract.
*
* @param int $id Learnpath id
* @param int $id Learnpath id
* @param string $setVisibility New visibility (v/i - visible/invisible)
*
* @return bool
@ -6860,7 +6860,6 @@ class learnpath
/**
* Edit a document based on $_POST and $_GET parameters 'dir' and 'path'.
*
*/
public function edit_document()
{
@ -6990,7 +6989,7 @@ class learnpath
if (empty($lpItem)) {
return '';
}
$item_id = $lpItem->getIid();
$item_id = $lpItem->getIid();
$itemType = $lpItem->getItemType();
$path = $lpItem->getPath();
@ -7167,10 +7166,10 @@ class learnpath
/**
* Displays a document by id.
*
* @param CDocument $document
* @param bool $show_title
* @param bool $iframe
* @param bool $edit_link
* @param CDocument $document
* @param bool $show_title
* @param bool $iframe
* @param bool $edit_link
*
* @return string
*/
@ -7205,9 +7204,9 @@ class learnpath
/**
* Return HTML form to add/edit a link item.
*
* @param string $action (add/edit)
* @param CLpItem $lpItem
* @param CLink $link
* @param string $action (add/edit)
* @param CLpItem $lpItem
* @param CLink $link
*
* @throws Exception
* @throws HTML_QuickForm_Error
@ -7241,9 +7240,9 @@ class learnpath
/**
* Return HTML form to add/edit a quiz.
*
* @param string $action Action (add/edit)
* @param CLpItem $lpItem Item ID if already exists
* @param CQuiz $exercise Extra information (quiz ID if integer)
* @param string $action Action (add/edit)
* @param CLpItem $lpItem Item ID if already exists
* @param CQuiz $exercise Extra information (quiz ID if integer)
*
* @throws Exception
*
@ -7294,9 +7293,9 @@ class learnpath
/**
* Return HTML form to add/edit forum threads.
*
* @param string $action
* @param CLpItem $lpItem
* @param string $resource
* @param string $action
* @param CLpItem $lpItem
* @param string $resource
*
* @throws Exception
*
@ -7321,9 +7320,9 @@ class learnpath
* Return the HTML form to display an item (generally a dir item).
*
* @param CLpItem $lpItem
* @param string $title
* @param string $action
* @param string $extra_info
* @param string $title
* @param string $action
* @param string $extra_info
*
* @throws Exception
* @throws HTML_QuickForm_Error
@ -7346,12 +7345,10 @@ class learnpath
return $form->returnForm();
}
/**
* Return HTML form to add/edit a student publication (work).
*
* @param string $action
* @param CLpItem $lpItem
* @param string $action
* @param CStudentPublication $resource
*
* @throws Exception
@ -7394,17 +7391,16 @@ class learnpath
return $form->returnForm();
}
/**
* Returns the form to update or create a document.
*
* @param string $action (add/edit)
* @param CLpItem $lpItem
*
* @return string HTML form
* @throws HTML_QuickForm_Error
*
* @throws Exception
*
* @return string HTML form
*/
public function displayDocumentForm($action = 'add', $lpItem = null)
{
@ -7844,8 +7840,6 @@ class learnpath
*
* @todo use FormValidator
*
* @param CLpItem $lpItem
*
* @return string HTML form
*/
public function display_item_prerequisites_form(CLpItem $lpItem)

@ -1834,7 +1834,6 @@ class learnpathItem
];
if ($this->status_is($completedStatusList)) {
return true;
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -235,7 +236,6 @@ if ($form->validate()) {
$row++;
$column = 0;
$table->setCellContents($row, $column++, customDate($minLogin));
$table->setCellContents($row, $column++, customDate($maxLogin));
$table->setRowAttributes($row, ['style' => 'font-weight:bold']);

@ -459,165 +459,6 @@ class ResourceController extends AbstractResourceController implements CourseCon
return $this->createResource($request, 'folder');
}
/**
* @param string $fileType
*
* @return RedirectResponse|Response
*/
private function createResource(Request $request, $fileType = 'file')
{
$resourceNodeParentId = $request->get('id');
$repository = $this->getRepositoryFromRequest($request);
// Default parent node is course.
$parentNode = $this->getParentResourceNode($request);
$this->denyAccessUnlessGranted(
ResourceNodeVoter::CREATE,
$parentNode,
$this->trans('Unauthorised access to resource')
);
$form = $repository->getForm($this->container->get('form.factory'), null);
$settings = $repository->getResourceSettings();
if ('file' === $fileType && $settings->isAllowToSaveEditorToResourceFile()) {
$resourceParams = $this->getResourceParams($request);
$form->add(
$this->fileContentName,
CKEditorType::class,
[
'mapped' => false,
'config' => [
'filebrowserImageBrowseRoute' => 'resources_filemanager',
'filebrowserImageBrowseRouteParameters' => $resourceParams,
'fullPage' => true,
],
]
);
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$course = $this->getCourse();
$session = $this->getSession();
/** @var ResourceInterface $newResource */
$newResource = $repository->saveResource($form, $course, $session, $fileType);
$file = null;
if ('file' === $fileType && $settings->isAllowToSaveEditorToResourceFile()) {
$content = $form->get($this->fileContentName)->getViewData();
$newResource->setTitle($newResource->getTitle().'.html');
$fileName = $newResource->getTitle();
$handle = tmpfile();
fwrite($handle, $content);
$meta = stream_get_meta_data($handle);
$file = new UploadedFile($meta['uri'], $fileName, 'text/html', null, true);
$em->persist($newResource);
}
$repository->addResourceToCourseWithParent(
$newResource,
$parentNode,
ResourceLink::VISIBILITY_PUBLISHED,
$this->getUser(),
$course,
$session,
null,
$file
);
$em->flush();
// Loops all sharing options
/*foreach ($shareList as $share) {
$idList = [];
if (isset($share['search'])) {
$idList = explode(',', $share['search']);
}
$resourceRight = null;
if (isset($share['mask'])) {
$resourceRight = new ResourceRight();
$resourceRight
->setMask($share['mask'])
->setRole($share['role'])
;
}
// Build links
switch ($share['sharing']) {
case 'everyone':
$repository->addResourceToEveryone(
$resourceNode,
$resourceRight
);
break;
case 'course':
$repository->addResourceToCourse(
$resourceNode,
$course,
$resourceRight
);
break;
case 'session':
$repository->addResourceToSession(
$resourceNode,
$course,
$session,
$resourceRight
);
break;
case 'user':
// Only for me
if (isset($share['only_me'])) {
$repository->addResourceOnlyToMe($resourceNode);
} else {
// To other users
$repository->addResourceToUserList($resourceNode, $idList);
}
break;
case 'group':
// @todo
break;
}*/
//}
$em->flush();
$this->addFlash('success', $this->trans('Saved'));
$params = $this->getResourceParams($request);
$params['id'] = $resourceNodeParentId;
return $this->redirectToRoute(
'chamilo_core_resource_list',
$params
);
}
switch ($fileType) {
case 'folder':
$template = $repository->getTemplates()->getFromAction('newFolderAction');
break;
case 'file':
$template = $repository->getTemplates()->getFromAction('newAction');
break;
}
$routeParams = $this->getResourceParams($request);
$routeParams['form'] = $form->createView();
$routeParams['parent'] = $resourceNodeParentId;
$routeParams['file_type'] = $fileType;
return $this->render($template, $routeParams);
}
/**
* @Route("/{tool}/{type}/{id}/new", methods={"GET", "POST"}, name="chamilo_core_resource_new")
*/
@ -1087,82 +928,6 @@ class ResourceController extends AbstractResourceController implements CourseCon
return $this->showFile($request, $resourceNode, $mode, $filter);
}
/**
* @param string $mode
* @param string $filter
*
* @return mixed|StreamedResponse
*/
private function showFile(Request $request, ResourceNode $resourceNode, $mode = 'show', $filter = '')
{
$this->denyAccessUnlessGranted(
ResourceNodeVoter::VIEW,
$resourceNode,
$this->trans('Unauthorised access to resource')
);
$repo = $this->getRepositoryFromRequest($request);
$resourceFile = $resourceNode->getResourceFile();
if (!$resourceFile) {
throw new NotFoundHttpException($this->trans('File not found for resource'));
}
$fileName = $resourceNode->getSlug();
$mimeType = $resourceFile->getMimeType();
switch ($mode) {
case 'download':
$forceDownload = true;
break;
case 'show':
default:
$forceDownload = false;
// If it's an image then send it to Glide.
if (false !== strpos($mimeType, 'image')) {
$glide = $this->getGlide();
$server = $glide->getServer();
$params = $request->query->all();
// The filter overwrites the params from get
if (!empty($filter)) {
$params = $glide->getFilters()[$filter] ?? [];
}
// The image was cropped manually by the user, so we force to render this version,
// no matter other crop parameters.
$crop = $resourceFile->getCrop();
if (!empty($crop)) {
$params['crop'] = $crop;
}
$fileName = $repo->getResourceNodeRepository()->getFilename($resourceFile);
return $server->getImageResponse($fileName, $params);
}
break;
}
$stream = $repo->getResourceNodeFileStream($resourceNode);
$response = new StreamedResponse(
function () use ($stream): void {
stream_copy_to_stream($stream, fopen('php://output', 'wb'));
}
);
$disposition = $response->headers->makeDisposition(
$forceDownload ? ResponseHeaderBag::DISPOSITION_ATTACHMENT : ResponseHeaderBag::DISPOSITION_INLINE,
$fileName
//Transliterator::transliterate($fileName)
);
$response->headers->set('Content-Disposition', $disposition);
$response->headers->set('Content-Type', $mimeType ?: 'application/octet-stream');
return $response;
}
/**
* Shows the associated resource file.
*
@ -1311,4 +1076,239 @@ class ResourceController extends AbstractResourceController implements CourseCon
return $this->render($repository->getTemplates()->getFromAction(__FUNCTION__), $routeParams);
}
/**
* @param string $fileType
*
* @return RedirectResponse|Response
*/
private function createResource(Request $request, $fileType = 'file')
{
$resourceNodeParentId = $request->get('id');
$repository = $this->getRepositoryFromRequest($request);
// Default parent node is course.
$parentNode = $this->getParentResourceNode($request);
$this->denyAccessUnlessGranted(
ResourceNodeVoter::CREATE,
$parentNode,
$this->trans('Unauthorised access to resource')
);
$form = $repository->getForm($this->container->get('form.factory'), null);
$settings = $repository->getResourceSettings();
if ('file' === $fileType && $settings->isAllowToSaveEditorToResourceFile()) {
$resourceParams = $this->getResourceParams($request);
$form->add(
$this->fileContentName,
CKEditorType::class,
[
'mapped' => false,
'config' => [
'filebrowserImageBrowseRoute' => 'resources_filemanager',
'filebrowserImageBrowseRouteParameters' => $resourceParams,
'fullPage' => true,
],
]
);
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$course = $this->getCourse();
$session = $this->getSession();
/** @var ResourceInterface $newResource */
$newResource = $repository->saveResource($form, $course, $session, $fileType);
$file = null;
if ('file' === $fileType && $settings->isAllowToSaveEditorToResourceFile()) {
$content = $form->get($this->fileContentName)->getViewData();
$newResource->setTitle($newResource->getTitle().'.html');
$fileName = $newResource->getTitle();
$handle = tmpfile();
fwrite($handle, $content);
$meta = stream_get_meta_data($handle);
$file = new UploadedFile($meta['uri'], $fileName, 'text/html', null, true);
$em->persist($newResource);
}
$repository->addResourceToCourseWithParent(
$newResource,
$parentNode,
ResourceLink::VISIBILITY_PUBLISHED,
$this->getUser(),
$course,
$session,
null,
$file
);
$em->flush();
// Loops all sharing options
/*foreach ($shareList as $share) {
$idList = [];
if (isset($share['search'])) {
$idList = explode(',', $share['search']);
}
$resourceRight = null;
if (isset($share['mask'])) {
$resourceRight = new ResourceRight();
$resourceRight
->setMask($share['mask'])
->setRole($share['role'])
;
}
// Build links
switch ($share['sharing']) {
case 'everyone':
$repository->addResourceToEveryone(
$resourceNode,
$resourceRight
);
break;
case 'course':
$repository->addResourceToCourse(
$resourceNode,
$course,
$resourceRight
);
break;
case 'session':
$repository->addResourceToSession(
$resourceNode,
$course,
$session,
$resourceRight
);
break;
case 'user':
// Only for me
if (isset($share['only_me'])) {
$repository->addResourceOnlyToMe($resourceNode);
} else {
// To other users
$repository->addResourceToUserList($resourceNode, $idList);
}
break;
case 'group':
// @todo
break;
}*/
//}
$em->flush();
$this->addFlash('success', $this->trans('Saved'));
$params = $this->getResourceParams($request);
$params['id'] = $resourceNodeParentId;
return $this->redirectToRoute(
'chamilo_core_resource_list',
$params
);
}
switch ($fileType) {
case 'folder':
$template = $repository->getTemplates()->getFromAction('newFolderAction');
break;
case 'file':
$template = $repository->getTemplates()->getFromAction('newAction');
break;
}
$routeParams = $this->getResourceParams($request);
$routeParams['form'] = $form->createView();
$routeParams['parent'] = $resourceNodeParentId;
$routeParams['file_type'] = $fileType;
return $this->render($template, $routeParams);
}
/**
* @param string $mode
* @param string $filter
*
* @return mixed|StreamedResponse
*/
private function showFile(Request $request, ResourceNode $resourceNode, $mode = 'show', $filter = '')
{
$this->denyAccessUnlessGranted(
ResourceNodeVoter::VIEW,
$resourceNode,
$this->trans('Unauthorised access to resource')
);
$repo = $this->getRepositoryFromRequest($request);
$resourceFile = $resourceNode->getResourceFile();
if (!$resourceFile) {
throw new NotFoundHttpException($this->trans('File not found for resource'));
}
$fileName = $resourceNode->getSlug();
$mimeType = $resourceFile->getMimeType();
switch ($mode) {
case 'download':
$forceDownload = true;
break;
case 'show':
default:
$forceDownload = false;
// If it's an image then send it to Glide.
if (false !== strpos($mimeType, 'image')) {
$glide = $this->getGlide();
$server = $glide->getServer();
$params = $request->query->all();
// The filter overwrites the params from get
if (!empty($filter)) {
$params = $glide->getFilters()[$filter] ?? [];
}
// The image was cropped manually by the user, so we force to render this version,
// no matter other crop parameters.
$crop = $resourceFile->getCrop();
if (!empty($crop)) {
$params['crop'] = $crop;
}
$fileName = $repo->getResourceNodeRepository()->getFilename($resourceFile);
return $server->getImageResponse($fileName, $params);
}
break;
}
$stream = $repo->getResourceNodeFileStream($resourceNode);
$response = new StreamedResponse(
function () use ($stream): void {
stream_copy_to_stream($stream, fopen('php://output', 'wb'));
}
);
$disposition = $response->headers->makeDisposition(
$forceDownload ? ResponseHeaderBag::DISPOSITION_ATTACHMENT : ResponseHeaderBag::DISPOSITION_INLINE,
$fileName
//Transliterator::transliterate($fileName)
);
$response->headers->set('Content-Disposition', $disposition);
$response->headers->set('Content-Type', $mimeType ?: 'application/octet-stream');
return $response;
}
}

@ -28,6 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
class ResourceNode
{
public const PATH_SEPARATOR = '`';
//use TimestampableEntity;
/**
@ -49,8 +50,6 @@ class ResourceNode
*/
protected $updatedAt;
public const PATH_SEPARATOR = '`';
/**
* @ORM\Id
* @ORM\Column(type="integer")

@ -114,9 +114,7 @@ class ResourceRepository extends BaseEntityRepository
$this->resourceType = $repo->findOneBy(['name' => $name]);
if (empty($this->resourceType)) {
throw new \Exception(
"Resource Type missing in repo: $service, you need to add a record in the resource_type table"
);
throw new \Exception("Resource Type missing in repo: $service, you need to add a record in the resource_type table");
}
}

@ -208,42 +208,6 @@ class SequenceResourceRepository extends ServiceEntityRepository
return $result;
}
/**
* Get sessions from vertices.
*
* @param Vertices $verticesEdges The vertices
* @param int $type
*
* @return array
*/
protected function findVerticesEdges(Vertices $verticesEdges, $type)
{
$sessionVertices = [];
$em = $this->getEntityManager();
foreach ($verticesEdges as $supVertex) {
$vertexId = $supVertex->getId();
switch ($type) {
case SequenceResource::SESSION_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Session')->find($vertexId);
break;
case SequenceResource::COURSE_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Course')->find($vertexId);
break;
}
if (empty($resource)) {
continue;
}
$sessionVertices[$vertexId] = $resource;
}
return $sessionVertices;
}
/**
* Check if the ser has completed the requirements for the sequences.
*
@ -419,4 +383,40 @@ class SequenceResourceRepository extends ServiceEntityRepository
return false;
}
/**
* Get sessions from vertices.
*
* @param Vertices $verticesEdges The vertices
* @param int $type
*
* @return array
*/
protected function findVerticesEdges(Vertices $verticesEdges, $type)
{
$sessionVertices = [];
$em = $this->getEntityManager();
foreach ($verticesEdges as $supVertex) {
$vertexId = $supVertex->getId();
switch ($type) {
case SequenceResource::SESSION_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Session')->find($vertexId);
break;
case SequenceResource::COURSE_TYPE:
$resource = $em->getRepository('ChamiloCoreBundle:Course')->find($vertexId);
break;
}
if (empty($resource)) {
continue;
}
$sessionVertices[$vertexId] = $resource;
}
return $sessionVertices;
}
}

@ -56,6 +56,30 @@ trait ResourceControllerTrait
}
}
public function getResourceParams(Request $request): array
{
$tool = $request->get('tool');
$type = $request->get('type');
$id = (int) $request->get('id');
$courseId = null;
$sessionId = null;
if ($this->hasCourse()) {
$courseId = $this->getCourse()->getId();
$session = $this->getCourseSession();
$sessionId = $session ? $session->getId() : 0;
}
return [
'id' => $id,
'tool' => $tool,
'type' => $type,
'cid' => $courseId,
'sid' => $sessionId,
];
}
protected function getParentResourceNode(Request $request): ResourceNode
{
$parentNodeId = $request->get('id');
@ -82,30 +106,6 @@ trait ResourceControllerTrait
return $parentResourceNode;
}
public function getResourceParams(Request $request): array
{
$tool = $request->get('tool');
$type = $request->get('type');
$id = (int) $request->get('id');
$courseId = null;
$sessionId = null;
if ($this->hasCourse()) {
$courseId = $this->getCourse()->getId();
$session = $this->getCourseSession();
$sessionId = $session ? $session->getId() : 0;
}
return [
'id' => $id,
'tool' => $tool,
'type' => $type,
'cid' => $courseId,
'sid' => $sessionId,
];
}
private function setBreadCrumb(Request $request)
{
$tool = $request->get('tool');

@ -109,6 +109,11 @@ class CAttendance extends AbstractResource implements ResourceInterface
$this->locked = 0;
}
public function __toString(): string
{
return (string) $this->getIid();
}
/**
* Set name.
*
@ -349,11 +354,6 @@ class CAttendance extends AbstractResource implements ResourceInterface
return $this->cId;
}
public function __toString(): string
{
return (string) $this->getIid();
}
public function getIid(): int
{
return $this->iid;

@ -80,6 +80,11 @@ class CCalendarEventAttachment extends AbstractResource implements ResourceInter
*/
protected $event;
public function __toString(): string
{
return $this->getFilename();
}
/**
* Set path.
*
@ -247,11 +252,6 @@ class CCalendarEventAttachment extends AbstractResource implements ResourceInter
return $this;
}
public function __toString(): string
{
return $this->getFilename();
}
/**
* Resource identifier.
*/

@ -95,6 +95,11 @@ class CCourseDescription extends AbstractResource implements ResourceInterface
$this->descriptionType = 1;
}
public function __toString(): string
{
return $this->getTitle();
}
/**
* Set title.
*
@ -271,11 +276,6 @@ class CCourseDescription extends AbstractResource implements ResourceInterface
return $this->iid;
}
public function __toString(): string
{
return $this->getTitle();
}
/**
* Resource identifier.
*/

@ -68,6 +68,11 @@ class CGlossary extends AbstractResource implements ResourceInterface
*/
protected $sessionId;
public function __toString(): string
{
return $this->getName();
}
/**
* Set name.
*
@ -217,11 +222,6 @@ class CGlossary extends AbstractResource implements ResourceInterface
return $this->iid;
}
public function __toString(): string
{
return $this->getName();
}
/**
* Resource identifier.
*/

@ -104,6 +104,11 @@ class CThematic extends AbstractResource implements ResourceInterface
$this->advances = new ArrayCollection();
}
public function __toString(): string
{
return $this->getTitle();
}
/**
* Set title.
*
@ -293,11 +298,6 @@ class CThematic extends AbstractResource implements ResourceInterface
return $this->advances;
}
public function __toString(): string
{
return $this->getTitle();
}
/**
* Resource identifier.
*/

@ -105,6 +105,11 @@ class CThematicAdvance extends AbstractResource implements ResourceInterface
$this->duration = 1;
}
public function __toString(): string
{
return (string) $this->getIid();
}
/**
* Set content.
*
@ -299,11 +304,6 @@ class CThematicAdvance extends AbstractResource implements ResourceInterface
return $this->iid;
}
public function __toString(): string
{
return (string) $this->getIid();
}
/**
* Resource identifier.
*/

@ -74,6 +74,11 @@ class CThematicPlan extends AbstractResource implements ResourceInterface
*/
protected $descriptionType;
public function __toString(): string
{
return (string) $this->getIid();
}
/**
* Set thematicId.
*
@ -218,11 +223,6 @@ class CThematicPlan extends AbstractResource implements ResourceInterface
return $this->cId;
}
public function __toString(): string
{
return (string) $this->getIid();
}
public function getIid(): int
{
return $this->iid;

Loading…
Cancel
Save