diff --git a/psalm.xml b/psalm.xml
index 777c858d3b..9a7c5744ba 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -24,10 +24,9 @@
-
-
-
+
+
@@ -134,6 +133,7 @@
+
diff --git a/public/main/calendar/agenda.php b/public/main/calendar/agenda.php
index ccc26b60e0..c7c2ee03d8 100644
--- a/public/main/calendar/agenda.php
+++ b/public/main/calendar/agenda.php
@@ -265,10 +265,7 @@ if ($allowToEdit) {
if (!empty($deleteAttachmentList)) {
foreach ($deleteAttachmentList as $deleteAttachmentId => $value) {
- $agenda->deleteAttachmentFile(
- $deleteAttachmentId,
- $agenda->course
- );
+ $agenda->deleteAttachmentFile($deleteAttachmentId);
}
}
diff --git a/public/main/forum/forumfunction.inc.php b/public/main/forum/forumfunction.inc.php
index 1893637cfc..ccb15cb8a3 100644
--- a/public/main/forum/forumfunction.inc.php
+++ b/public/main/forum/forumfunction.inc.php
@@ -1020,7 +1020,7 @@ function delete_post($post_id)
/** @var CForumPost $post */
$post = $em
->getRepository(CForumPost::class)
- ->findOneBy(['cId' => $course_id, 'iid' => $post_id]);
+ ->findOneBy(['iid' => $post_id]);
if ($post) {
$em
@@ -3201,12 +3201,12 @@ function newThread(CForumForum $forum, $form_values = '', $showPreview = true)
}
/**
- * @param array $threadInfo
- * @param int $user_id
- * @param int $thread_id
- * @param int $thread_qualify
- * @param int $qualify_time
- * @param int $session_id
+ * @param CForumThread $threadInfo
+ * @param int $user_id
+ * @param int $thread_id
+ * @param int $thread_qualify
+ * @param int $qualify_time
+ * @param int $session_id
*
* @return array optional
*
@@ -3215,7 +3215,7 @@ function newThread(CForumForum $forum, $form_values = '', $showPreview = true)
* @version October 2008, dokeos 1.8.6
*/
function saveThreadScore(
- $threadInfo,
+ CForumThread $threadEntity,
$user_id,
$thread_id,
$thread_qualify = 0,
@@ -3223,7 +3223,6 @@ function saveThreadScore(
$session_id = 0
) {
$table_threads_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
- $table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$course_id = api_get_course_int_id();
$session_id = (int) $session_id;
@@ -3233,24 +3232,20 @@ function saveThreadScore(
$thread_id == (string) ((int) $thread_id) &&
$thread_qualify == (string) ((float) $thread_qualify)
) {
- // Testing
- $sql = "SELECT thread_qualify_max FROM $table_threads
- WHERE c_id = $course_id AND thread_id=".$thread_id;
- $res_string = Database::query($sql);
- $row_string = Database::fetch_array($res_string);
- if ($thread_qualify <= $row_string[0]) {
- if (0 == $threadInfo['thread_peer_qualify']) {
+ $max = $threadEntity->getThreadQualifyMax();
+ if ($thread_qualify <= $max) {
+ if ($threadEntity->isThreadPeerQualify()) {
$sql = "SELECT COUNT(*) FROM $table_threads_qualify
WHERE
c_id = $course_id AND
user_id = $user_id AND
+ qualify_user_id = $currentUserId AND
thread_id = ".$thread_id;
} else {
$sql = "SELECT COUNT(*) FROM $table_threads_qualify
WHERE
c_id = $course_id AND
user_id = $user_id AND
- qualify_user_id = $currentUserId AND
thread_id = ".$thread_id;
}
@@ -3261,8 +3256,6 @@ function saveThreadScore(
$sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id)
VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
Database::query($sql);
- $insertId = Database::insert_id();
-
return 'insert';
} else {
saveThreadScoreHistory(
@@ -4086,18 +4079,18 @@ function approve_post($post_id, $action)
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$course_id = api_get_course_int_id();
- if ('invisible' == $action) {
+ if ('invisible' === $action) {
$visibility_value = 0;
}
- if ('visible' == $action) {
+ if ('visible' === $action) {
$visibility_value = 1;
handle_mail_cue('post', $post_id);
}
$sql = "UPDATE $table_posts SET
- visible='".Database::escape_string($visibility_value)."'
- WHERE c_id = $course_id AND post_id='".Database::escape_string($post_id)."'";
+ visible='".Database::escape_string($visibility_value)."'
+ WHERE post_id='".Database::escape_string($post_id)."'";
$return = Database::query($sql);
if ($return) {
@@ -4638,8 +4631,8 @@ function store_move_thread($values)
Database::query($sql);
// Fix group id, if forum is moved to a different group
- if (!empty($forumInfo['to_group_id'])) {
- /*$groupId = $forumInfo['to_group_id'];
+ /*if (!empty($forumInfo['to_group_id'])) {
+ $groupId = $forumInfo['to_group_id'];
$item = api_get_item_property_info(
$courseId,
TABLE_FORUM_THREAD,
@@ -4672,8 +4665,8 @@ function store_move_thread($values)
$sessionCondition
";
Database::query($sql);
- }*/
- }
+ }
+ }*/
return get_lang('Thread moved');
}
@@ -5814,9 +5807,9 @@ function get_all_post_from_user($user_id, $courseId)
$forum_results .= '
';
$forum_results .= '
';
$forum_results .= '
'.
- Display::return_icon('forum.gif', get_lang('Forum')).' '.Security::remove_XSS($forum['forum_title'], STUDENT).
+ Display::return_icon('forum.gif', get_lang('Forum')).' '.Security::remove_XSS($forum->getForumTitle(), STUDENT).
'
';
@@ -5959,9 +5952,9 @@ function forumRecursiveSort($rows, &$threads, $seed = 0, $indent = 0)
/**
* Update forum attachment data, used to update comment and post ID.
*
- * @param array $array (field => value) to update forum attachment row
- * @param attach $id ID to find row to update
- * @param null $courseId course ID to find row to update
+ * @param array $array (field => value) to update forum attachment row
+ * @param int $id ID to find row to update
+ * @param int $courseId course ID to find row to update
*
* @return int number of affected rows
*/
@@ -6439,28 +6432,22 @@ function postIsEditableByStudent($forum, $post)
}
/**
- * @param int $postId
+ * @param CForumPost $post
*
* @return bool
*/
-function savePostRevision($postId)
+function savePostRevision(CForumPost $post)
{
- $postData = get_post_information($postId);
-
- if (empty($postData)) {
- return false;
- }
-
$userId = api_get_user_id();
- if ($postData['poster_id'] != $userId) {
+ if ($post->getPosterId() != $userId) {
return false;
}
- $status = (int) !postNeedsRevision($postId);
+ $status = (int) !postNeedsRevision($post);
$extraFieldValue = new ExtraFieldValue('forum_post');
$params = [
- 'item_id' => $postId,
+ 'item_id' => $post->getIid(),
'extra_ask_for_revision' => ['extra_ask_for_revision' => $status],
];
if (empty($status)) {
@@ -6494,13 +6481,9 @@ function getPostRevision($postId)
return $revision;
}
-/**
- * @param int $postId
- *
- * @return bool
- */
-function postNeedsRevision($postId)
+function postNeedsRevision(CForumPost $post): bool
{
+ $postId = $post->getIid();
$extraFieldValue = new ExtraFieldValue('forum_post');
$value = $extraFieldValue->get_values_by_handler_and_field_variable(
$postId,
@@ -6515,21 +6498,21 @@ function postNeedsRevision($postId)
}
/**
- * @param int $postId
+ * @param CForumPost $post
* @param array $threadInfo
*
* @return string
*/
-function getAskRevisionButton($postId, $threadInfo)
+function getAskRevisionButton(CForumPost $post, $threadInfo)
{
if (false === api_get_configuration_value('allow_forum_post_revisions')) {
return '';
}
- $postId = (int) $postId;
+ $postId = $post->getIid();
$status = 'btn-default';
- if (postNeedsRevision($postId)) {
+ if (postNeedsRevision($post)) {
$status = 'btn-success';
}
@@ -6651,13 +6634,13 @@ function getReportRecipients()
}
/**
- * @param int $postId
- * @param array $forumInfo
- * @param array $threadInfo
+ * @param CForumPost $post
+ * @param array $forumInfo
+ * @param array $threadInfo
*
* @return bool
*/
-function reportPost($postId, $forumInfo, $threadInfo)
+function reportPost(CForumPost $post, $forumInfo, $threadInfo)
{
if (!reportAvailable()) {
return false;
@@ -6667,30 +6650,27 @@ function reportPost($postId, $forumInfo, $threadInfo)
return false;
}
- $postId = (int) $postId;
+ $postId = $post->getIid();
- $postData = get_post_information($postId);
$currentUser = api_get_user_info();
-
- if (!empty($postData)) {
- $users = getReportRecipients();
- if (!empty($users)) {
- $url = api_get_path(WEB_CODE_PATH).
- 'forum/viewthread.php?forum='.$threadInfo['forum_id'].'&thread='.$threadInfo['thread_id'].'&'.api_get_cidreq().'&post_id='.$postId.'#post_id_'.$postId;
- $postLink = Display::url(
- $postData['post_title'],
- $url
- );
- $subject = get_lang('Post reported');
- $content = sprintf(
- get_lang('User %s has reported the message %s in the forum %s'),
- $currentUser['complete_name'],
- $postLink,
- $forumInfo['forum_title']
- );
- foreach ($users as $userId) {
- MessageManager::send_message_simple($userId, $subject, $content);
- }
+ $users = getReportRecipients();
+ if (!empty($users)) {
+ $url = api_get_path(WEB_CODE_PATH).
+ 'forum/viewthread.php?forum='.$threadInfo['forum_id'].'&thread='.$threadInfo['thread_id'].'&'.api_get_cidreq().'&post_id='.$postId.'#post_id_'.$postId;
+ $postLink = Display::url(
+ $post->getPostTitle(),
+ $url
+ );
+ $subject = get_lang('Post reported');
+ $content = sprintf(
+ get_lang('User %s has reported the message %s in the forum %s'),
+ $currentUser['complete_name'],
+ $postLink,
+ $forumInfo['forum_title']
+ );
+ foreach ($users as $userId) {
+ MessageManager::send_message_simple($userId, $subject, $content);
}
}
+
}
diff --git a/public/main/forum/forumqualify.php b/public/main/forum/forumqualify.php
index 3af8331b8c..89b2ee7810 100644
--- a/public/main/forum/forumqualify.php
+++ b/public/main/forum/forumqualify.php
@@ -2,9 +2,14 @@
/* For licensing terms, see /license.txt */
+use Chamilo\CoreBundle\Framework\Container;
+use Chamilo\CourseBundle\Entity\CForumForum;
+use Chamilo\CourseBundle\Entity\CForumThread;
+
/**
* @todo fix all this qualify files avoid including files, use classes POO jmontoya
*/
+
require_once __DIR__.'/../inc/global.inc.php';
require_once 'forumfunction.inc.php';
@@ -19,20 +24,26 @@ $origin = api_get_origin();
$currentUserId = api_get_user_id();
$userIdToQualify = isset($_GET['user_id']) ? (int) ($_GET['user_id']) : null;
$forumId = isset($_GET['forum']) ? (int) ($_GET['forum']) : 0;
-api_block_course_item_locked_by_gradebook($_GET['thread'], LINK_FORUM_THREAD);
+$threadId = isset($_GET['thread']) ? (int) ($_GET['thread']) : 0;
+api_block_course_item_locked_by_gradebook($threadId, LINK_FORUM_THREAD);
$nameTools = get_lang('Forums');
-
$allowed_to_edit = api_is_allowed_to_edit(null, true);
-$currentThread = get_thread_information($forumId, $_GET['thread']);
-$forumId = $currentThread['forum_id'];
-$currentForum = get_forums($currentThread['forum_id']);
-$threadId = $currentThread['thread_id'];
+
+$repo = Container::getForumRepository();
+$repoThread = Container::getForumThreadRepository();
+/** @var CForumForum $forumEntity */
+$forumEntity = $repo->find($forumId);
+/** @var CForumThread $threadEntity */
+$threadEntity = $repoThread->find($threadId);
+
+$course = api_get_course_entity();
+$session = api_get_session_entity();
$allowToQualify = false;
if ($allowed_to_edit) {
$allowToQualify = true;
} else {
- $allowToQualify = 1 == $currentThread['thread_peer_qualify'] && 1 == $currentForum['visibility'] && $userIdToQualify != $currentUserId;
+ $allowToQualify = $threadEntity->isThreadPeerQualify() && $forumEntity->isVisible($course, $session) && $userIdToQualify != $currentUserId;
}
if (!$allowToQualify) {
@@ -48,7 +59,7 @@ if (isset($_POST['idtextqualify'])) {
if ($score <= $maxQualify) {
saveThreadScore(
- $currentThread,
+ $threadEntity,
$userIdToQualify,
$threadId,
$score,
@@ -84,10 +95,7 @@ $htmlHeadXtra[] = '';
-
-$currentForumCategory = get_forumcategory_information(
- $currentForum['forum_category']
-);
+$category = $forumEntity->getForumCategory();
$groupId = api_get_group_id();
if (api_is_in_gradebook()) {
@@ -99,7 +107,7 @@ if (api_is_in_gradebook()) {
$search = isset($_GET['search']) ? Security::remove_XSS(urlencode($_GET['search'])) : '';
-if ('learnpath' == $origin) {
+if ('learnpath' === $origin) {
Display::display_reduced_header();
} else {
if (!empty($groupId)) {
@@ -114,12 +122,12 @@ if ('learnpath' == $origin) {
];
$interbreadcrumb[] = [
'url' => 'viewforum.php?'.api_get_cidreq().'&forum='.(int) ($_GET['forum']).'&search='.$search,
- 'name' => prepare4display($currentForum['forum_title']),
+ 'name' => prepare4display($forumEntity->getForumTitle()),
];
if ('PostDeletedSpecial' != $message) {
$interbreadcrumb[] = [
'url' => 'viewthread.php?'.api_get_cidreq().'&forum='.(int) ($_GET['forum']).'&thread='.(int) ($_GET['thread']),
- 'name' => prepare4display($currentThread['thread_title']),
+ 'name' => prepare4display($threadEntity->getThreadTitle()),
];
}
@@ -132,24 +140,23 @@ if ('learnpath' == $origin) {
Display::display_header('');
api_display_tool_title($nameTools);
} else {
- $info_thread = get_thread_information($currentForum['forum_id'], $_GET['thread']);
$interbreadcrumb[] = [
'url' => 'index.php?'.api_get_cidreq().'&search='.$search,
'name' => $nameTools,
];
$interbreadcrumb[] = [
- 'url' => 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.$currentForumCategory['cat_id'].'&search='.$search,
- 'name' => prepare4display($currentForumCategory['cat_title']),
+ 'url' => 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.$category->getIid().'&search='.$search,
+ 'name' => prepare4display($category->getCatTitle()),
];
$interbreadcrumb[] = [
- 'url' => 'viewforum.php?'.api_get_cidreq().'&forum='.(int) ($_GET['forum']).'&search='.$search,
- 'name' => prepare4display($currentForum['forum_title']),
+ 'url' => 'viewforum.php?'.api_get_cidreq().'&forum='.$forumId.'&search='.$search,
+ 'name' => prepare4display($forumEntity->getForumTitle()),
];
if ('PostDeletedSpecial' != $message) {
$interbreadcrumb[] = [
- 'url' => 'viewthread.php?'.api_get_cidreq().'&forum='.$info_thread['forum_id'].'&thread='.(int) ($_GET['thread']),
- 'name' => prepare4display($currentThread['thread_title']),
+ 'url' => 'viewthread.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId,
+ 'name' => prepare4display($threadEntity->getThreadTitle()),
];
}
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
@@ -166,18 +173,18 @@ if ('learnpath' == $origin) {
*/
$action = isset($_GET['action']) ? $_GET['action'] : '';
-if ('delete' == $action &&
+if ('delete' === $action &&
isset($_GET['content']) &&
isset($_GET['id']) && api_is_allowed_to_edit(false, true)
) {
$message = delete_post($_GET['id']);
}
-if (('invisible' == $action || 'visible' == $action) &&
+if (('invisible' === $action || 'visible' === $action) &&
isset($_GET['id']) && api_is_allowed_to_edit(false, true)
) {
$message = approve_post($_GET['id'], $action);
}
-if ('move' == $action && isset($_GET['post'])) {
+if ('move' === $action && isset($_GET['post'])) {
$message = move_post_form();
}
@@ -212,12 +219,12 @@ $result = get_statistical_information(
);
$url = api_get_path(WEB_CODE_PATH).'forum/forumqualify.php?'.
- api_get_cidreq().'&forum='.(int) ($_GET['forum']).'&thread='.$threadId.'&user='.(int) ($_GET['user']).'&user_id='.(int) ($_GET['user']);
+ api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId.'&user='.(int) ($_GET['user']).'&user_id='.(int) ($_GET['user']);
$userToQualifyInfo = api_get_user_info($userIdToQualify);
$form = new FormValidator('forum-thread-qualify', 'post', $url);
$form->addHeader($userToQualifyInfo['complete_name']);
-$form->addLabel(get_lang('Thread'), $currentThread['thread_title']);
+$form->addLabel(get_lang('Thread'), $threadEntity->getThreadTitle());
$form->addLabel(get_lang('Users in course'), $result['user_course']);
$form->addLabel(get_lang('Number of posts'), $result['post']);
$form->addLabel(get_lang('Number of posts for this user'), $result['user_post']);
@@ -233,7 +240,7 @@ $form->addText(
$course = api_get_course_info();
-$rows = get_thread_user_post($course['code'], $currentThread['thread_id'], $_GET['user']);
+$rows = get_thread_user_post($course['code'], $threadId, $_GET['user']);
if (isset($rows)) {
$counter = 1;
foreach ($rows as $row) {
@@ -306,11 +313,15 @@ $form->display();
if (api_is_allowed_to_edit() && $counter > 0) {
echo '
'.get_lang('ScoreChangesHistory').'
';
if (isset($_GET['type']) && 'false' === $_GET['type']) {
- $buttons = '
'.
+ $buttons = ''.
get_lang('more recent').' '.get_lang('older').'';
} else {
$buttons = '
'.get_lang('more recent').'
-
'.
+ '.
get_lang('older').'';
}
@@ -337,6 +348,6 @@ if (api_is_allowed_to_edit() && $counter > 0) {
echo $table_list;
}
-if ('learnpath' != $origin) {
+if ('learnpath' !== $origin) {
Display:: display_footer();
}
diff --git a/public/main/forum/forumsearch.php b/public/main/forum/forumsearch.php
index 2fa598cb1e..fa3275f862 100644
--- a/public/main/forum/forumsearch.php
+++ b/public/main/forum/forumsearch.php
@@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */
+use Chamilo\CoreBundle\Framework\Container;
+use Chamilo\CourseBundle\Entity\CForumForum;
+
/**
* These files are a complete rework of the forum. The database structure is
* based on phpBB but all the code is rewritten. A lot of new functionalities
@@ -30,6 +33,11 @@ api_protect_course_script(true);
// Including additional library scripts.
include 'forumfunction.inc.php';
+$forumId = isset($_GET['forum']) ? (int) ($_GET['forum']) : 0;
+$repo = Container::getForumRepository();
+/** @var CForumForum $forumEntity */
+$forumEntity = $repo->find($forumId);
+
// Are we in a lp ?
$origin = api_get_origin();
@@ -45,7 +53,7 @@ if (api_is_in_gradebook()) {
$groupId = api_get_group_id();
-if ('group' == $origin) {
+if ('group' === $origin) {
$group_properties = GroupManager:: get_group_properties($groupId);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
@@ -56,8 +64,8 @@ if ('group' == $origin) {
'name' => get_lang('Group area').' ('.$group_properties['name'].')',
];
$interbreadcrumb[] = [
- 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.(int) ($_GET['forum']).'&'.api_get_cidreq(),
- 'name' => prepare4display($current_forum['forum_title']),
+ 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.$forumId.'&'.api_get_cidreq(),
+ 'name' => prepare4display($forumEntity->getForumTitle()),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'forum/forumsearch.php?'.api_get_cidreq(),
@@ -72,7 +80,7 @@ if ('group' == $origin) {
}
// Display the header.
-if ('learnpath' == $origin) {
+if ('learnpath' === $origin) {
Display::display_reduced_header();
} else {
Display::display_header($nameTools);
@@ -88,6 +96,6 @@ Event::event_access_tool(TOOL_FORUM);
forum_search();
// Footer
-if ('learnpath' != $origin) {
+if ('learnpath' !== $origin) {
Display :: display_footer();
}
diff --git a/public/main/forum/viewforum.php b/public/main/forum/viewforum.php
index 134468047d..811e9c172e 100644
--- a/public/main/forum/viewforum.php
+++ b/public/main/forum/viewforum.php
@@ -502,9 +502,13 @@ if (is_array($threads)) {
}*/
$id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
$iconsEdit = '';
- if ('learnpath' != $origin) {
- if (api_is_allowed_to_edit(false, true) &&
- !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId)
+ if ('learnpath' !== $origin) {
+ if (api_is_allowed_to_edit(false, true)
+ /*&& @todo fix session validation
+ !(
+ api_is_session_general_coach() &&
+ $current_forum['session_id'] != $sessionId
+ )*/
) {
$iconsEdit .= '
';
if (!empty($forum->getForumLastPost())) {
$html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY).' ';
- $html .= Display::dateToStringAgoAndLongDate($forum['last_post_date'])
+ $html .= Display::dateToStringAgoAndLongDate($forum->getForumLastPost())
.' '.get_lang('By').' '
.display_user_link($poster_id, $name);
}
diff --git a/public/main/forum/viewthread.php b/public/main/forum/viewthread.php
index 96235eb615..945b16dcd3 100644
--- a/public/main/forum/viewthread.php
+++ b/public/main/forum/viewthread.php
@@ -24,6 +24,7 @@ $my_search = null;
$moveForm = '';
$forumId = isset($_GET['forum']) ? (int) $_GET['forum'] : 0;
+$postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0;
$threadId = isset($_GET['thread']) ? (int) $_GET['thread'] : 0;
$repo = Container::getForumRepository();
@@ -43,6 +44,13 @@ if (empty($threadEntity)) {
exit;
}
+$repoPost = Container::getForumPostRepository();
+$postEntity = null;
+if (!empty($postId)) {
+ /** @var CForumPost $postEntity */
+ $postEntity = $repoPost->find($postId);
+}
+
$courseEntity = api_get_course_entity(api_get_course_int_id());
$sessionEntity = api_get_session_entity(api_get_session_id());
@@ -146,9 +154,8 @@ switch ($my_action) {
break;
case 'report':
- $postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0;
- $result = reportPost($postId, $forumEntity, $threadEntity);
+ $result = reportPost($postEntity, $forumEntity, $threadEntity);
Display::addFlash(Display::return_message(get_lang('Reported')));
header('Location: '.$currentUrl);
exit;
@@ -156,8 +163,7 @@ switch ($my_action) {
break;
case 'ask_revision':
if (api_get_configuration_value('allow_forum_post_revisions')) {
- $postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0;
- $result = savePostRevision($postId);
+ $result = savePostRevision($postEntity);
Display::addFlash(Display::return_message(get_lang('Saved.')));
}
header('Location: '.$currentUrl);
@@ -362,7 +368,7 @@ foreach ($posts as $post) {
);
}
- if ('learnpath' != $origin) {
+ if ('learnpath' !== $origin) {
$post['user_data'] .= Display::tag(
'p',
Display::dateToStringAgoAndLongDate($post['post_date']),
@@ -466,7 +472,7 @@ foreach ($posts as $post) {
if ($post['poster_id'] == $userId) {
$revision = getPostRevision($post['post_id']);
if (empty($revision)) {
- $askForRevision = getAskRevisionButton($post['post_id'], $threadEntity);
+ $askForRevision = getAskRevisionButton($postEntity, $threadEntity);
} else {
$postIsARevision = true;
$languageId = api_get_language_id(strtolower($revision));
@@ -477,7 +483,7 @@ foreach ($posts as $post) {
}
}
} else {
- if (postNeedsRevision($post['post_id'])) {
+ if (postNeedsRevision($postEntity)) {
$askForRevision = giveRevisionButton($post['post_id'], $threadEntity);
} else {
$revision = getPostRevision($post['post_id']);
diff --git a/public/main/inc/lib/agenda.lib.php b/public/main/inc/lib/agenda.lib.php
index be31f6f631..02a45dbba8 100644
--- a/public/main/inc/lib/agenda.lib.php
+++ b/public/main/inc/lib/agenda.lib.php
@@ -269,7 +269,7 @@ class Agenda
->setEndDate($end)
->setAllDay($allDay)
->setColor($color)
- ->setUser(api_get_user_id())
+ ->setUser(api_get_user_entity())
;
$em->persist($event);
$em->flush();
@@ -2932,7 +2932,7 @@ class Agenda
$courseInfo
);
if (!empty($attachment)) {
- $this->deleteAttachmentFile($attachmentId, $courseInfo);
+ $this->deleteAttachmentFile($attachmentId);
}
$this->addAttachment($eventId, $fileUserUpload, $comment, $courseInfo);
}
@@ -2941,39 +2941,26 @@ class Agenda
* This function delete a attachment file by id.
*
* @param int $attachmentId
- * @param array $courseInfo
*
* @return string
*/
- public function deleteAttachmentFile($attachmentId, $courseInfo)
+ public function deleteAttachmentFile($attachmentId)
{
- $table = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
- $attachmentId = (int) $attachmentId;
- $courseId = $courseInfo['real_id'];
+ $repo = Container::getCalendarEventAttachmentRepository();
+ /** @var CCalendarEventAttachment $attachment */
+ $attachment = $repo->find($attachmentId);
- if (empty($courseId) || empty($attachmentId)) {
+ if (empty($attachment)) {
return false;
}
- $sql = "DELETE FROM $table
- WHERE c_id = $courseId AND id = ".$attachmentId;
- $result = Database::query($sql);
+ $repo->getEntityManager()->remove($attachment);
+ $repo->getEntityManager()->flush();
- // update item_property
- api_item_property_update(
- $courseInfo,
- 'calendar_event_attachment',
- $attachmentId,
- 'AgendaAttachmentDeleted',
- api_get_user_id()
+ return Display::return_message(
+ get_lang("The attached file has been deleted"),
+ 'confirmation'
);
-
- if (!empty($result)) {
- return Display::return_message(
- get_lang("The attached file has been deleted"),
- 'confirmation'
- );
- }
}
/**
@@ -3611,17 +3598,19 @@ class Agenda
$type
) {
$tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
- $user_id = intval($user_id);
-
+ $user_id = (int) $user_id;
+ $course_link = '';
// 1. creating the SQL statement for getting the personal agenda items in MONTH view
- if ("month_view" == $type or "" == $type) {
+ if ("month_view" === $type || "" == $type) {
// we are in month view
- $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' ORDER BY date ASC";
+ $sql = "SELECT * FROM ".$tbl_personal_agenda."
+ WHERE user='".$user_id."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."'
+ ORDER BY date ASC";
}
// 2. creating the SQL statement for getting the personal agenda items in WEEK view
// we are in week view
- if ("week_view" == $type) {
+ if ("week_view" === $type) {
$start_end_day_of_week = self::calculate_start_end_of_week(
$week,
$year
@@ -3637,17 +3626,19 @@ class Agenda
$start_filter = api_get_utc_datetime($start_filter);
$end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
$end_filter = api_get_utc_datetime($end_filter);
- $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
+ $sql = "SELECT * FROM ".$tbl_personal_agenda."
+ WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
}
// 3. creating the SQL statement for getting the personal agenda items in DAY view
- if ("day_view" == $type) {
+ if ("day_view" === $type) {
// we are in day view
// we could use mysql date() function but this is only available from 4.1 and higher
$start_filter = $year."-".$month."-".$day." 00:00:00";
$start_filter = api_get_utc_datetime($start_filter);
$end_filter = $year."-".$month."-".$day." 23:59:59";
$end_filter = api_get_utc_datetime($end_filter);
- $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
+ $sql = "SELECT * FROM ".$tbl_personal_agenda."
+ WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
}
$result = Database::query($sql);
@@ -3676,20 +3667,24 @@ class Agenda
$minute = $agendatime[1];
$second = $agendatime[2];
- if ('month_view' == $type) {
+ if ('month_view' === $type) {
$item['calendar_type'] = 'personal';
$item['start_date'] = $item['date'];
$agendaitems[$day][] = $item;
continue;
}
- // Creating the array that will be returned. If we have week or month view we have an array with the date as the key
+ // Creating the array that will be returned.
+ // If we have week or month view we have an array with the date as the key
// if we have a day_view we use a half hour as index => key 33 = 16h30
if ("day_view" !== $type) {
// This is the array construction for the WEEK or MONTH view
//Display events in agenda
- $agendaitems[$day] .= "
";
+ $agendaitems[$day] .= "
";
} else {
// this is the array construction for the DAY view
$halfhour = 2 * $agendatime['0'];
@@ -3698,7 +3693,9 @@ class Agenda
}
//Display events by list
- $agendaitems[$halfhour] .= "";
+ $agendaitems[$halfhour] .= "";
}
}
@@ -3706,7 +3703,7 @@ class Agenda
}
/**
- * Show the monthcalender of the given month.
+ * Show the month calendar of the given month.
*
* @param array Agendaitems
* @param int Month number
@@ -3979,11 +3976,10 @@ class Agenda
*
* @deprecated use agenda events
*/
- public static function get_personal_agenda_items_between_dates(
- $user_id,
- $date_start = '',
- $date_end = ''
- ) {
+ public static function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '')
+ {
+ throw new Exception('fix get_personal_agenda_items_between_dates');
+ /*
$items = [];
if ($user_id != strval(intval($user_id))) {
return $items;
@@ -4006,10 +4002,10 @@ class Agenda
}
// get agenda-items for every course
- $courses = api_get_user_courses($user_id, false);
+ //$courses = api_get_user_courses($user_id, false);
+ $courses = CourseManager::get_courses_list_by_user_id($user_id, false);
foreach ($courses as $id => $course) {
$c = api_get_course_info_by_id($course['real_id']);
- //databases of the courses
$t_a = Database::get_course_table(TABLE_AGENDA, $course['db']);
$t_ip = Database::get_course_table(
TABLE_ITEM_PROPERTY,
@@ -4100,7 +4096,7 @@ class Agenda
}
}
- return $items;
+ return $items;*/
}
/**
diff --git a/src/CoreBundle/Entity/User.php b/src/CoreBundle/Entity/User.php
index 8be7b5475c..1e84ffc773 100644
--- a/src/CoreBundle/Entity/User.php
+++ b/src/CoreBundle/Entity/User.php
@@ -489,7 +489,9 @@ class User implements UserInterface, EquatableInterface
/**
* @var ArrayCollection|TrackEAttempt[]
- * @ORM\OneToMany(targetEntity="TrackEAccessComplete", mappedBy="user", cascade={"persist", "remove"},orphanRemoval=true)
+ * @ORM\OneToMany(
+ * targetEntity="TrackEAccessComplete", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true
+ * )
*/
protected $trackEAccessCompleteList;
@@ -517,9 +519,10 @@ class User implements UserInterface, EquatableInterface
protected $trackECourseAccess;
/**
- * @var ArrayCollection
+ * @var ArrayCollection|UserCourseCategory[]
+ *
* @ORM\OneToMany(
- * targetEntity="Chamilo\CoreBundle\Entity\UserCourseCategory",
+ * targetEntity="UserCourseCategory",
* mappedBy="user",
* cascade={"persist", "remove"},
* orphanRemoval=true
@@ -528,19 +531,19 @@ class User implements UserInterface, EquatableInterface
protected $userCourseCategories;
/**
- * @var ArrayCollection
+ * @var ArrayCollection|UserRelCourseVote[]
* @ORM\OneToMany(targetEntity="UserRelCourseVote", mappedBy="user",cascade={"persist","remove"},orphanRemoval=true)
*/
protected $userRelCourseVotes;
/**
- * @var ArrayCollection
+ * @var ArrayCollection|UserRelTag[]
* @ORM\OneToMany(targetEntity="UserRelTag", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $userRelTags;
/**
- * @var ArrayCollection
+ * @var ArrayCollection|PersonalAgenda[]
* @ORM\OneToMany(targetEntity="PersonalAgenda",mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $personalAgendas;
diff --git a/src/CourseBundle/Entity/CForumForum.php b/src/CourseBundle/Entity/CForumForum.php
index 3743f7360c..57968d0851 100644
--- a/src/CourseBundle/Entity/CForumForum.php
+++ b/src/CourseBundle/Entity/CForumForum.php
@@ -201,14 +201,14 @@ class CForumForum extends AbstractResource implements ResourceInterface
protected $moderated;
/**
- * @var ArrayCollection
+ * @var ArrayCollection|CForumThread[]
*
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", mappedBy="forum")
*/
protected $threads;
/**
- * @var CForumPost[]
+ * @var ArrayCollection|CForumPost[]
*
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="forum")
*/
@@ -219,6 +219,8 @@ class CForumForum extends AbstractResource implements ResourceInterface
*/
public function __construct()
{
+ $this->threads = new ArrayCollection();
+ $this->posts = new ArrayCollection();
$this->locked = 0;
$this->forumImage = '';
$this->forumOfGroup = 0;
@@ -259,10 +261,8 @@ class CForumForum extends AbstractResource implements ResourceInterface
* Set forumComment.
*
* @param string $forumComment
- *
- * @return CForumForum
*/
- public function setForumComment($forumComment)
+ public function setForumComment($forumComment): self
{
$this->forumComment = $forumComment;
@@ -283,10 +283,8 @@ class CForumForum extends AbstractResource implements ResourceInterface
* Set forumThreads.
*
* @param int $forumThreads
- *
- * @return CForumForum
*/
- public function setForumThreads($forumThreads)
+ public function setForumThreads($forumThreads): self
{
$this->forumThreads = $forumThreads;
@@ -303,6 +301,11 @@ class CForumForum extends AbstractResource implements ResourceInterface
return $this->forumThreads;
}
+ public function hasThread($thread)
+ {
+ return $this->threads->contains($thread);
+ }
+
/**
* Set forumPosts.
*
diff --git a/src/CourseBundle/Entity/CForumThread.php b/src/CourseBundle/Entity/CForumThread.php
index 69852a93b6..0c7babd48b 100644
--- a/src/CourseBundle/Entity/CForumThread.php
+++ b/src/CourseBundle/Entity/CForumThread.php
@@ -163,7 +163,7 @@ class CForumThread extends AbstractResource implements ResourceInterface
protected $lpItemId;
/**
- * @var CForumPost[]
+ * @var ArrayCollection|CForumPost[]
*
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="thread", cascade={"persist", "remove"}, orphanRemoval=true)
*/
@@ -171,6 +171,7 @@ class CForumThread extends AbstractResource implements ResourceInterface
public function __construct()
{
+ $this->posts = new ArrayCollection();
$this->threadPeerQualify = false;
$this->threadReplies = 0;
$this->threadViews = 0;
'; $forum_results .= '
'.get_lang('ScoreChangesHistory').'
'; if (isset($_GET['type']) && 'false' === $_GET['type']) { - $buttons = ''. + $buttons = ''. get_lang('more recent').' '.get_lang('older').''; } else { $buttons = ''.get_lang('more recent').' - '. + '. get_lang('older').''; } @@ -337,6 +348,6 @@ if (api_is_allowed_to_edit() && $counter > 0) { echo $table_list; } -if ('learnpath' != $origin) { +if ('learnpath' !== $origin) { Display:: display_footer(); } diff --git a/public/main/forum/forumsearch.php b/public/main/forum/forumsearch.php index 2fa598cb1e..fa3275f862 100644 --- a/public/main/forum/forumsearch.php +++ b/public/main/forum/forumsearch.php @@ -2,6 +2,9 @@ /* For licensing terms, see /license.txt */ +use Chamilo\CoreBundle\Framework\Container; +use Chamilo\CourseBundle\Entity\CForumForum; + /** * These files are a complete rework of the forum. The database structure is * based on phpBB but all the code is rewritten. A lot of new functionalities @@ -30,6 +33,11 @@ api_protect_course_script(true); // Including additional library scripts. include 'forumfunction.inc.php'; +$forumId = isset($_GET['forum']) ? (int) ($_GET['forum']) : 0; +$repo = Container::getForumRepository(); +/** @var CForumForum $forumEntity */ +$forumEntity = $repo->find($forumId); + // Are we in a lp ? $origin = api_get_origin(); @@ -45,7 +53,7 @@ if (api_is_in_gradebook()) { $groupId = api_get_group_id(); -if ('group' == $origin) { +if ('group' === $origin) { $group_properties = GroupManager:: get_group_properties($groupId); $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), @@ -56,8 +64,8 @@ if ('group' == $origin) { 'name' => get_lang('Group area').' ('.$group_properties['name'].')', ]; $interbreadcrumb[] = [ - 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.(int) ($_GET['forum']).'&'.api_get_cidreq(), - 'name' => prepare4display($current_forum['forum_title']), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.$forumId.'&'.api_get_cidreq(), + 'name' => prepare4display($forumEntity->getForumTitle()), ]; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'forum/forumsearch.php?'.api_get_cidreq(), @@ -72,7 +80,7 @@ if ('group' == $origin) { } // Display the header. -if ('learnpath' == $origin) { +if ('learnpath' === $origin) { Display::display_reduced_header(); } else { Display::display_header($nameTools); @@ -88,6 +96,6 @@ Event::event_access_tool(TOOL_FORUM); forum_search(); // Footer -if ('learnpath' != $origin) { +if ('learnpath' !== $origin) { Display :: display_footer(); } diff --git a/public/main/forum/viewforum.php b/public/main/forum/viewforum.php index 134468047d..811e9c172e 100644 --- a/public/main/forum/viewforum.php +++ b/public/main/forum/viewforum.php @@ -502,9 +502,13 @@ if (is_array($threads)) { }*/ $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; $iconsEdit = ''; - if ('learnpath' != $origin) { - if (api_is_allowed_to_edit(false, true) && - !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId) + if ('learnpath' !== $origin) { + if (api_is_allowed_to_edit(false, true) + /*&& @todo fix session validation + !( + api_is_session_general_coach() && + $current_forum['session_id'] != $sessionId + )*/ ) { $iconsEdit .= ''; if (!empty($forum->getForumLastPost())) { $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY).' '; - $html .= Display::dateToStringAgoAndLongDate($forum['last_post_date']) + $html .= Display::dateToStringAgoAndLongDate($forum->getForumLastPost()) .' '.get_lang('By').' ' .display_user_link($poster_id, $name); } diff --git a/public/main/forum/viewthread.php b/public/main/forum/viewthread.php index 96235eb615..945b16dcd3 100644 --- a/public/main/forum/viewthread.php +++ b/public/main/forum/viewthread.php @@ -24,6 +24,7 @@ $my_search = null; $moveForm = ''; $forumId = isset($_GET['forum']) ? (int) $_GET['forum'] : 0; +$postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0; $threadId = isset($_GET['thread']) ? (int) $_GET['thread'] : 0; $repo = Container::getForumRepository(); @@ -43,6 +44,13 @@ if (empty($threadEntity)) { exit; } +$repoPost = Container::getForumPostRepository(); +$postEntity = null; +if (!empty($postId)) { + /** @var CForumPost $postEntity */ + $postEntity = $repoPost->find($postId); +} + $courseEntity = api_get_course_entity(api_get_course_int_id()); $sessionEntity = api_get_session_entity(api_get_session_id()); @@ -146,9 +154,8 @@ switch ($my_action) { break; case 'report': - $postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0; - $result = reportPost($postId, $forumEntity, $threadEntity); + $result = reportPost($postEntity, $forumEntity, $threadEntity); Display::addFlash(Display::return_message(get_lang('Reported'))); header('Location: '.$currentUrl); exit; @@ -156,8 +163,7 @@ switch ($my_action) { break; case 'ask_revision': if (api_get_configuration_value('allow_forum_post_revisions')) { - $postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0; - $result = savePostRevision($postId); + $result = savePostRevision($postEntity); Display::addFlash(Display::return_message(get_lang('Saved.'))); } header('Location: '.$currentUrl); @@ -362,7 +368,7 @@ foreach ($posts as $post) { ); } - if ('learnpath' != $origin) { + if ('learnpath' !== $origin) { $post['user_data'] .= Display::tag( 'p', Display::dateToStringAgoAndLongDate($post['post_date']), @@ -466,7 +472,7 @@ foreach ($posts as $post) { if ($post['poster_id'] == $userId) { $revision = getPostRevision($post['post_id']); if (empty($revision)) { - $askForRevision = getAskRevisionButton($post['post_id'], $threadEntity); + $askForRevision = getAskRevisionButton($postEntity, $threadEntity); } else { $postIsARevision = true; $languageId = api_get_language_id(strtolower($revision)); @@ -477,7 +483,7 @@ foreach ($posts as $post) { } } } else { - if (postNeedsRevision($post['post_id'])) { + if (postNeedsRevision($postEntity)) { $askForRevision = giveRevisionButton($post['post_id'], $threadEntity); } else { $revision = getPostRevision($post['post_id']); diff --git a/public/main/inc/lib/agenda.lib.php b/public/main/inc/lib/agenda.lib.php index be31f6f631..02a45dbba8 100644 --- a/public/main/inc/lib/agenda.lib.php +++ b/public/main/inc/lib/agenda.lib.php @@ -269,7 +269,7 @@ class Agenda ->setEndDate($end) ->setAllDay($allDay) ->setColor($color) - ->setUser(api_get_user_id()) + ->setUser(api_get_user_entity()) ; $em->persist($event); $em->flush(); @@ -2932,7 +2932,7 @@ class Agenda $courseInfo ); if (!empty($attachment)) { - $this->deleteAttachmentFile($attachmentId, $courseInfo); + $this->deleteAttachmentFile($attachmentId); } $this->addAttachment($eventId, $fileUserUpload, $comment, $courseInfo); } @@ -2941,39 +2941,26 @@ class Agenda * This function delete a attachment file by id. * * @param int $attachmentId - * @param array $courseInfo * * @return string */ - public function deleteAttachmentFile($attachmentId, $courseInfo) + public function deleteAttachmentFile($attachmentId) { - $table = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); - $attachmentId = (int) $attachmentId; - $courseId = $courseInfo['real_id']; + $repo = Container::getCalendarEventAttachmentRepository(); + /** @var CCalendarEventAttachment $attachment */ + $attachment = $repo->find($attachmentId); - if (empty($courseId) || empty($attachmentId)) { + if (empty($attachment)) { return false; } - $sql = "DELETE FROM $table - WHERE c_id = $courseId AND id = ".$attachmentId; - $result = Database::query($sql); + $repo->getEntityManager()->remove($attachment); + $repo->getEntityManager()->flush(); - // update item_property - api_item_property_update( - $courseInfo, - 'calendar_event_attachment', - $attachmentId, - 'AgendaAttachmentDeleted', - api_get_user_id() + return Display::return_message( + get_lang("The attached file has been deleted"), + 'confirmation' ); - - if (!empty($result)) { - return Display::return_message( - get_lang("The attached file has been deleted"), - 'confirmation' - ); - } } /** @@ -3611,17 +3598,19 @@ class Agenda $type ) { $tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA); - $user_id = intval($user_id); - + $user_id = (int) $user_id; + $course_link = ''; // 1. creating the SQL statement for getting the personal agenda items in MONTH view - if ("month_view" == $type or "" == $type) { + if ("month_view" === $type || "" == $type) { // we are in month view - $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' ORDER BY date ASC"; + $sql = "SELECT * FROM ".$tbl_personal_agenda." + WHERE user='".$user_id."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' + ORDER BY date ASC"; } // 2. creating the SQL statement for getting the personal agenda items in WEEK view // we are in week view - if ("week_view" == $type) { + if ("week_view" === $type) { $start_end_day_of_week = self::calculate_start_end_of_week( $week, $year @@ -3637,17 +3626,19 @@ class Agenda $start_filter = api_get_utc_datetime($start_filter); $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59"; $end_filter = api_get_utc_datetime($end_filter); - $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; + $sql = "SELECT * FROM ".$tbl_personal_agenda." + WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; } // 3. creating the SQL statement for getting the personal agenda items in DAY view - if ("day_view" == $type) { + if ("day_view" === $type) { // we are in day view // we could use mysql date() function but this is only available from 4.1 and higher $start_filter = $year."-".$month."-".$day." 00:00:00"; $start_filter = api_get_utc_datetime($start_filter); $end_filter = $year."-".$month."-".$day." 23:59:59"; $end_filter = api_get_utc_datetime($end_filter); - $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; + $sql = "SELECT * FROM ".$tbl_personal_agenda." + WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; } $result = Database::query($sql); @@ -3676,20 +3667,24 @@ class Agenda $minute = $agendatime[1]; $second = $agendatime[2]; - if ('month_view' == $type) { + if ('month_view' === $type) { $item['calendar_type'] = 'personal'; $item['start_date'] = $item['date']; $agendaitems[$day][] = $item; continue; } - // Creating the array that will be returned. If we have week or month view we have an array with the date as the key + // Creating the array that will be returned. + // If we have week or month view we have an array with the date as the key // if we have a day_view we use a half hour as index => key 33 = 16h30 if ("day_view" !== $type) { // This is the array construction for the WEEK or MONTH view //Display events in agenda - $agendaitems[$day] .= ""; + $agendaitems[$day] .= "
"; } else { // this is the array construction for the DAY view $halfhour = 2 * $agendatime['0']; @@ -3698,7 +3693,9 @@ class Agenda } //Display events by list - $agendaitems[$halfhour] .= "