Internal - Fix entities, format code, fix legacy code use resources.

pull/3570/head
Julio Montoya 5 years ago
parent a64171a189
commit cc68cc54c0
  1. 38
      public/main/calendar/agenda.php
  2. 43
      public/main/course_progress/index.php
  3. 47
      public/main/forum/forumfunction.inc.php
  4. 4
      public/main/gradebook/lib/be/forumthreadlink.class.php
  5. 61
      public/main/inc/introductionSection.inc.php
  6. 265
      public/main/inc/lib/agenda.lib.php
  7. 364
      public/main/inc/lib/api.lib.php
  8. 2
      public/main/inc/lib/display.lib.php
  9. 2
      public/main/inc/lib/template.lib.php
  10. 131
      public/main/inc/lib/thematic.lib.php
  11. 6
      public/main/inc/lib/tracking.lib.php
  12. 38
      public/main/work/work.lib.php
  13. 14
      src/CoreBundle/Entity/ResourceLink.php
  14. 2
      src/CoreBundle/Entity/ResourceNode.php
  15. 88
      src/CourseBundle/Entity/CCalendarEvent.php
  16. 24
      src/CourseBundle/Entity/CThematic.php

@ -5,7 +5,6 @@
use Chamilo\CoreBundle\Framework\Container;
// use anonymous mode when accessing this course tool
$use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_CALENDAR_EVENT;
@ -36,27 +35,24 @@ $logInfo = [
Event::registerLog($logInfo);
$group_id = api_get_group_id();
$groupInfo = GroupManager::get_group_properties($group_id);
$eventId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$type = $event_type = isset($_GET['type']) ? $_GET['type'] : null;
$htmlHeadXtra[] = '<script>
$(function() {
var checked = $("input[name=repeat]").attr("checked");
if (checked) {
$("#options2").show();
}
});
$htmlHeadXtra[] = "<script>
function plus_repeated_event() {
if (document.getElementById('options2').style.display == 'none') {
document.getElementById('options2').style.display = 'block';
if (document.getElementById("options2").style.display == "none") {
document.getElementById("options2").style.display = "block";
} else {
document.getElementById('options2').style.display = 'none';
document.getElementById("options2").style.display = "none";
}
}
$(function() {
var checked = $('input[name=repeat]').attr('checked');
if (checked) {
$('#options2').show();
}
});
</script>";
$htmlHeadXtra[] = '<script>
var counter_image = 1;
function add_image_form() {
// Multiple filepaths for image form
@ -310,20 +306,20 @@ if ($allowToEdit) {
}
if (!empty($group_id)) {
$group_properties = GroupManager :: get_group_properties($group_id);
$group_properties = GroupManager::get_group_properties($group_id);
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
"name" => get_lang('Groups'),
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
"name" => get_lang('Group area').' '.$group_properties['name'],
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('Group area').' '.$group_properties['name'],
];
}
if (!empty($actionName)) {
$interbreadcrumb[] = [
"url" => $url,
"name" => get_lang('Agenda'),
'url' => $url,
'name' => get_lang('Agenda'),
];
} else {
$actionName = '';

@ -504,7 +504,7 @@ switch ($action) {
$thematic_plan_data = $thematicManager->get_thematic_plan_data();
// Third column
$thematic_advance_data = $thematicManager->get_thematic_advance_list(null, null, true);
$thematic_advance_data = $thematicManager->get_thematic_advance_list(null, true);
if (!empty($message) && !empty($total_average_of_advances)) {
$tpl->assign('message', $message);
@ -512,16 +512,16 @@ switch ($action) {
$tpl->assign('score_progress', $total_average_of_advances);
if (isset($last_id) && $last_id) {
$link_to_thematic_plan = '<a href="index.php?'.api_get_cidreq(
).'&action=thematic_plan_list&thematic_id='.$last_id.'">'.
$link_to_thematic_plan = '<a
href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$last_id.'">'.
Display::return_icon(
'lesson_plan.png',
get_lang('Thematic plan'),
['style' => 'vertical-align:middle;float:none;'],
ICON_SIZE_SMALL
).'</a>';
$link_to_thematic_advance = '<a href="index.php?'.api_get_cidreq(
).'&action=thematic_advance_list&thematic_id='.$last_id.'">'.
$link_to_thematic_advance = '<a
href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$last_id.'">'.
Display::return_icon(
'lesson_plan_calendar.png',
get_lang('Thematic advance'),
@ -555,16 +555,6 @@ switch ($action) {
/** @var CThematic $thematic */
foreach ($thematic_data as $thematic) {
$id = $thematic->getIid();
//$list['id'] = $thematic->getIid();
//$list['id_course'] = $thematic['c_id'];
//$list['id_session'] = $thematic['session_id'];
//$list['title'] = Security::remove_XSS($thematic->getTitle(), STUDENT);
//$list['content'] = Security::remove_XSS($thematic->getContent(), STUDENT);
//$list['display_orden'] = $thematic->getDisplayOrder();
//$list['active'] = $thematic->getActive();
//$my_thematic_id = $thematic['id'];
$session_star = '';
if (api_is_allowed_to_edit(null, true)) {
if (api_get_session_id() == $thematic->getSessionId()) {
@ -588,8 +578,9 @@ switch ($action) {
);
if (0 == api_get_session_id()) {
if ($thematic->getDisplayOrder() > 1) {
$toolbarThematic .= ' <a class="btn btn-default" href="'.api_get_self(
).'?action=moveup&'.api_get_cidreq().'&thematic_id='.$id.$params.$url_token.'">'.
$toolbarThematic .= ' <a
class="btn btn-default"
href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$id.$params.$url_token.'">'.
Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_TINY).'</a>';
} else {
$toolbarThematic .= '<div class="btn btn-default">'.
@ -597,8 +588,9 @@ switch ($action) {
}
//$thematic->getDisplayOrder()
if ($thematic->getDisplayOrder() < $max_thematic_item) {
$toolbarThematic .= ' <a class="btn btn-default" href="'.api_get_self(
).'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$id.$params.$url_token.'">'.
$toolbarThematic .= ' <a
class="btn btn-default"
href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$id.$params.$url_token.'">'.
Display::return_icon('down.png', get_lang('down'), '', ICON_SIZE_TINY).'</a>';
} else {
$toolbarThematic .= '<div class="btn btn-default">'.
@ -628,14 +620,15 @@ switch ($action) {
),
['class' => 'btn btn-default']
);
$toolbarThematic .= '<a class="btn btn-default" href="index.php?'.api_get_cidreq(
).'&action=thematic_edit&thematic_id='
.$id.$params.$url_token.'">'
$toolbarThematic .= '<a
class="btn btn-default"
href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$id.$params.$url_token.'">'
.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_TINY).'</a>';
$toolbarThematic .= '<a class="btn btn-default" onclick="javascript:if(!confirm(\''
$toolbarThematic .= '<a
class="btn btn-default"
onclick="javascript:if(!confirm(\''
.get_lang('Are you sure you want to delete')
.'\')) return false;" href="index.php?'.api_get_cidreq(
).'&action=thematic_delete&thematic_id='
.'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='
.$id.$params.$url_token.'">'
.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_TINY).'</a>';
}

@ -2649,11 +2649,14 @@ function store_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)
* 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)
* 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
*
@ -5829,29 +5832,27 @@ function getForumCreatedByUser($userId, $courseInfo, $sessionId)
}
$courseId = $courseInfo['real_id'];
$items = api_get_item_property_list_by_tool_by_user(
$userId,
'forum',
$courseId,
$sessionId
);
$repo = Container::getForumRepository();
$courseEntity = api_get_course_entity($courseId);
$sessionEntity = api_get_session_entity($sessionId);
$qb = $repo->getResourcesByCourse($courseEntity, $sessionEntity);
$qb->andWhere('node.creator = :creator');
$qb->setParameter('creator', $userId);
$items = $qb->getQuery()->getResult();
$forumList = [];
if (!empty($items)) {
/** @var CForumForum $forum */
foreach ($items as $forum) {
$forumInfo = get_forums(
$forum['ref'],
$courseInfo['code'],
true,
$sessionId
);
if (!empty($forumInfo) && isset($forumInfo['forum_title'])) {
$forumList[] = [
$forumInfo['forum_title'],
api_get_local_time($forum['insert_date']),
api_get_local_time($forum['lastedit_date']),
];
}
$forumList[] = [
$forum->getForumTitle(),
api_get_local_time($forum->getResourceNode()->getCreatedAt()),
api_get_local_time($forum->getResourceNode()->getUpdatedAt()),
];
}
}

@ -49,7 +49,6 @@ class ForumThreadLink extends AbstractLink
}
$tbl_grade_links = Database::get_course_table(TABLE_FORUM_THREAD);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sessionId = $this->get_session_id();
if ($sessionId) {
@ -73,9 +72,8 @@ class ForumThreadLink extends AbstractLink
$cats[] = [$data['thread_id'], $data['thread_title']];
}
}
$my_cats = isset($cats) ? $cats : [];
return $my_cats;
return isset($cats) ? $cats : [];
}
/**

@ -181,41 +181,36 @@ if (TOOL_COURSE_HOMEPAGE == $tool && !isset($_GET['intro_cmdEdit'])) {
if ('1' === $displayMode) {
// Show only the current course progress step
$last_done_advance = $thematic->get_last_done_thematic_advance();
$thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
$thematicAdvance = $thematic->getThematicAdvance($last_done_advance);
$subTitle1 = get_lang('Current topic');
$class1 = ' current';
} elseif ('2' === $displayMode) {
// Show only the two next course progress steps
$last_done_advance = $thematic->get_next_thematic_advance_not_done();
$next_advance_not_done = $thematic->get_next_thematic_advance_not_done(2);
$thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
$thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done);
$thematicAdvance = $thematic->getThematicAdvance($last_done_advance);
$thematicAdvance2 = $thematic->getThematicAdvance($next_advance_not_done);
$subTitle1 = $subTitle2 = get_lang('Next topic');
} elseif ('3' === $displayMode) {
// Show the current and next course progress steps
$last_done_advance = $thematic->get_last_done_thematic_advance();
$next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
$thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
$thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done);
$thematicAdvance = $thematic->getThematicAdvance($last_done_advance);
$thematicAdvance2 = $thematic->getThematicAdvance($next_advance_not_done);
$subTitle1 = get_lang('Current topic');
$subTitle2 = get_lang('Next topic');
$class1 = ' current';
}
if (!empty($thematic_advance_info)) {
if (!empty($thematicAdvance)) {
$thematic_advance = get_lang('Course progress');
$thematicScore = $thematic->get_total_average_of_thematic_advances().'%';
$thematicUrl = api_get_path(WEB_CODE_PATH).'course_progress/index.php?action=thematic_details&'.api_get_cidreq();
$thematic_info = $thematicAdvance->getThematic();
$startDate = $thematicAdvance->getStartDate();
$repo = \Chamilo\CoreBundle\Framework\Container::getThematicRepository();
/** @var \Chamilo\CourseBundle\Entity\CThematic $thematic_info */
$thematic_info = $repo->find($thematic_advance_info['thematic_id']);
$thematic_advance_info['start_date'] = api_get_local_time($thematic_advance_info['start_date']);
$thematic_advance_info['start_date'] = api_format_date(
$thematic_advance_info['start_date'],
DATE_TIME_FORMAT_LONG
);
//$thematicAdvance['start_date'] = api_get_local_time($startDate);
//$thematicAdvance['start_date'] = api_format_date($startDate, DATE_TIME_FORMAT_LONG);
$userInfo = api_get_user_info();
$courseInfo = api_get_course_info();
$titleThematic = $thematic_advance.' : '.$courseInfo['name'].' <b>( '.$thematicScore.' )</b>';
@ -231,26 +226,36 @@ if (TOOL_COURSE_HOMEPAGE == $tool && !isset($_GET['intro_cmdEdit'])) {
<div class="col-md-6 items-progress">
<div class="thematic-cont '.$class1.'">
<div class="topics">'.$subTitle1.'</div>
<h4 class="title-topics">'.Display::returnFontAwesomeIcon('book').strip_tags($thematic_info->getTitle()).'</h4>
<p class="date">'.Display::returnFontAwesomeIcon('calendar-o').$thematic_advance_info['start_date'].'</p>
<div class="views">'.Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematic_advance_info['content']).'</div>
<p class="time">'.Display::returnFontAwesomeIcon('clock-o').get_lang('Duration in hours').' : '.$thematic_advance_info['duration'].' - <a href="'.$thematicUrl.'">'.get_lang('See detail').'</a></p>
<h4 class="title-topics">'.
Display::returnFontAwesomeIcon('book').strip_tags($thematic_info->getTitle()).'</h4>
<p class="date">'.
Display::returnFontAwesomeIcon('calendar-o').$thematicAdvance['start_date'].'</p>
<div class="views">'.
Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematicAdvance->getContent()).'</div>
<p class="time">'.
Display::returnFontAwesomeIcon('clock-o').get_lang('Duration in hours').' : '.$thematicAdvance->getDuration().' -
<a href="'.$thematicUrl.'">'.get_lang('See detail').'</a></p>
</div>
</div>';
if (!empty($thematic_advance_info2)) {
$thematic_info2 = $repo->find($thematic_advance_info2['thematic_id']);
$thematic_advance_info2['start_date'] = api_get_local_time($thematic_advance_info2['start_date']);
$thematic_advance_info2['start_date'] = api_format_date($thematic_advance_info2['start_date'], DATE_TIME_FORMAT_LONG);
if (!empty($thematicAdvance2)) {
$thematic_info2 = $thematicAdvance2->getThematic();
//$thematicAdvance2['start_date'] = api_get_local_time($thematicAdvance2['start_date']);
//$thematicAdvance2['start_date'] = api_format_date($thematicAdvance2['start_date'], DATE_TIME_FORMAT_LONG);
$thematicItemTwo = '
<div class="col-md-6 items-progress">
<div class="thematic-cont">
<div class="topics">'.$subTitle2.'</div>
<h4 class="title-topics">'.Display::returnFontAwesomeIcon('book').api_get_local_time($thematic_info2->getStartDate()).'</h4>
<p class="date">'.Display::returnFontAwesomeIcon('calendar-o').$thematic_advance_info2['start_date'].'</p>
<div class="views">'.Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematic_advance_info2['content']).'</div>
<p class="time">'.Display::returnFontAwesomeIcon('clock-o').get_lang('Duration in hours').' : '.$thematic_advance_info2['duration'].' - <a href="'.$thematicUrl.'">'.get_lang('See detail').'</a></p>
<h4 class="title-topics">'.
Display::returnFontAwesomeIcon('book').api_get_local_time($thematic_info2->getStartDate()).'</h4>
<p class="date">'.
Display::returnFontAwesomeIcon('calendar-o').api_get_local_time($thematicAdvance2->getStartDate()).'</p>
<div class="views">'.
Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematicAdvance2->getContent()).'</div>
<p class="time">'.
Display::returnFontAwesomeIcon('clock-o').get_lang('Duration in hours').' : '.$thematicAdvance2->getDuration().' -
<a href="'.$thematicUrl.'">'.get_lang('See detail').'</a></p>
</div>
</div>';
}
@ -275,7 +280,7 @@ if (TOOL_COURSE_HOMEPAGE == $tool && !isset($_GET['intro_cmdEdit'])) {
}
$thematicSection = '';
if (!empty($thematic_advance_info)) {
if (!empty($thematicAdvance)) {
$thematicSection = $thematic_description_html;
$thematicSection .= $thematicProgress;
}

@ -658,6 +658,8 @@ class Agenda
$updateContent = true,
$authorId = 0
) {
$startObject = api_get_utc_datetime($start, true, true);
$endObject = api_get_utc_datetime($end, true, true);
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
$allDay = isset($allDay) && 'true' == $allDay ? 1 : 0;
@ -691,208 +693,108 @@ class Agenda
);
break;
case 'course':
$eventInfo = $this->get_event($id);
$repo = Container::getCalendarEventRepository();
$em = $repo->getEntityManager();
/** @var CCalendarEvent $event */
$event = $repo->find($id);
if (empty($eventInfo)) {
if (empty($event)) {
return false;
}
$groupId = api_get_group_id();
$groupIid = 0;
$groupInfo = [];
if ($groupId) {
$groupInfo = GroupManager::get_group_properties($groupId);
if ($groupInfo) {
$groupIid = $groupInfo['iid'];
}
}
$sentToEvent = $event->getUsersAndGroupSubscribedToEvent();
$courseId = $this->course['real_id'];
if (empty($courseId)) {
return false;
}
$courseEntity = api_get_course_entity($courseId);
$sessionEntity = api_get_session_entity($this->sessionId);
$groupEntity = api_get_group_entity(api_get_group_id());
if ($this->getIsAllowedToEdit()) {
$attributes = [
'title' => $title,
'start_date' => $start,
'end_date' => $end,
'all_day' => $allDay,
'comment' => $comment,
];
$event
->setTitle($title)
->setStartDate($startObject)
->setEndDate($endObject)
->setAllDay($allDay)
->setComment($comment)
;
if ($updateContent) {
$attributes['content'] = $content;
$event->setContent($content);
}
if (!empty($color)) {
$attributes['color'] = $color;
$event->setColor($color);
}
Database::update(
$this->tbl_course_agenda,
$attributes,
[
'iid = ? AND c_id = ? AND session_id = ? ' => [
$id,
$courseId,
$this->sessionId,
],
]
);
$em->persist($event);
if (!empty($usersToSend)) {
$sendTo = $this->parseSendToArray($usersToSend);
$usersToDelete = array_diff(
$eventInfo['send_to']['users'],
$sendTo['users']
);
$usersToAdd = array_diff(
$sendTo['users'],
$eventInfo['send_to']['users']
);
$groupsToDelete = array_diff(
$eventInfo['send_to']['groups'],
$sendTo['groups']
);
$groupToAdd = array_diff(
$sendTo['groups'],
$eventInfo['send_to']['groups']
);
$usersToDelete = array_diff($sentToEvent['users'], $sendTo['users']);
$usersToAdd = array_diff($sendTo['users'], $sentToEvent['users']);
$groupsToDelete = array_diff($sentToEvent['groups'], $sendTo['groups']);
$groupToAdd = array_diff($sendTo['groups'], $sentToEvent['groups']);
$links = $event->getResourceNode()->getResourceLinks();
if ($sendTo['everyone']) {
// Delete all from group
if (isset($eventInfo['send_to']['groups']) &&
!empty($eventInfo['send_to']['groups'])
) {
foreach ($eventInfo['send_to']['groups'] as $group) {
$groupIidItem = 0;
if ($group) {
$groupInfoItem = GroupManager::get_group_properties(
$group
);
if ($groupInfoItem) {
$groupIidItem = $groupInfoItem['iid'];
if (isset($sentToEvent['groups']) && !empty($sentToEvent['groups'])) {
foreach ($sentToEvent['groups'] as $group) {
foreach ($links as $link) {
if ($link->hasGroup() && $link->getGroup()->getIid() === $group) {
$em->remove($link);
}
}
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
0,
$groupIidItem,
$this->sessionId
);
}
}
// Storing the selected users.
if (isset($eventInfo['send_to']['users']) &&
!empty($eventInfo['send_to']['users'])
) {
foreach ($eventInfo['send_to']['users'] as $userId) {
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
$userId,
$groupIid,
$this->sessionId
);
if (isset($sentToEvent['users']) && !empty($sentToEvent['users'])) {
foreach ($sentToEvent['users'] as $userId) {
foreach ($links as $link) {
if ($link->hasUser() && $link->getUser()->getId() === $userId) {
$em->remove($link);
}
}
}
}
// Add to everyone only.
api_item_property_update(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
'visible',
$authorId,
$groupInfo,
null,
$start,
$end,
$this->sessionId
);
} else {
// Delete "everyone".
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
0,
0,
$this->sessionId
);
foreach ($links as $link) {
$em->remove($link);
}
// Add groups
if (!empty($groupToAdd)) {
foreach ($groupToAdd as $group) {
$groupInfoItem = [];
if ($group) {
$groupInfoItem = GroupManager::get_group_properties(
$group
);
}
api_item_property_update(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
'visible',
$authorId,
$groupInfoItem,
0,
$start,
$end,
$this->sessionId
);
$group = api_get_group_entity($group);
$event->addCourseLink($courseEntity, $sessionEntity, $group);
}
}
// Delete groups.
if (!empty($groupsToDelete)) {
foreach ($groupsToDelete as $group) {
$groupIidItem = 0;
if ($group) {
$groupInfoItem = GroupManager::get_group_properties(
$group
);
if ($groupInfoItem) {
$groupIidItem = $groupInfoItem['iid'];
foreach ($links as $link) {
if ($link->hasGroup() && $link->getGroup()->getIid() === $group) {
$em->remove($link);
}
}
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
0,
$groupIidItem,
$this->sessionId
);
}
}
// Add users.
if (!empty($usersToAdd)) {
foreach ($usersToAdd as $userId) {
api_item_property_update(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
'visible',
$authorId,
$groupInfo,
$userId,
$start,
$end,
$this->sessionId
$event->addUserLink(
api_get_user_entity($userId),
$courseEntity,
$sessionEntity,
$groupEntity
);
}
}
@ -900,46 +802,45 @@ class Agenda
// Delete users.
if (!empty($usersToDelete)) {
foreach ($usersToDelete as $userId) {
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
$userId,
$groupInfo,
$this->sessionId
);
foreach ($links as $link) {
if ($link->hasUser() && $link->getUser()->getId() === $userId) {
$em->remove($link);
}
}
}
}
}
}
$em->persist($event);
$em->flush();
// Add announcement.
if (isset($addAnnouncement) && !empty($addAnnouncement)) {
$this->storeAgendaEventAsAnnouncement(
$id,
$usersToSend
);
$this->storeAgendaEventAsAnnouncement($id, $usersToSend);
}
// Add attachment.
if (isset($attachmentArray) && !empty($attachmentArray)) {
$counter = 0;
foreach ($attachmentArray as $attachmentItem) {
$this->updateAttachment(
$attachmentItem['id'],
$id,
$attachmentItem,
$attachmentCommentList[$counter],
$this->course
);
$counter++;
if (isset($attachmentItem['id'])) {
$this->updateAttachment(
$attachmentItem['id'],
$id,
$attachmentItem,
$attachmentCommentList[$counter],
$this->course
);
$counter++;
}
}
}
return true;
} else {
return false;
}
return false;
break;
case 'admin':
case 'platform':
@ -1399,7 +1300,7 @@ class Agenda
case 'course':
if (!empty($this->course['real_id'])) {
$sql = "SELECT * FROM ".$this->tbl_course_agenda."
WHERE c_id = ".$this->course['real_id']." AND iid = ".$id;
WHERE iid = ".$id;
$result = Database::query($sql);
if (Database::num_rows($result)) {
$event = Database::fetch_array($result, 'ASSOC');
@ -1419,9 +1320,7 @@ class Agenda
);
if (!empty($event['parent_event_id'])) {
$event['parent_info'] = $this->get_event(
$event['parent_event_id']
);
$event['parent_info'] = $this->get_event($event['parent_event_id']);
}
$event['attachment'] = $this->getAttachmentList($id, $this->course);
@ -1529,11 +1428,8 @@ class Agenda
*
* @return array
*/
public function getUsersAndGroupSubscribedToEvent(
$eventId,
$courseId,
$sessionId
) {
public function getUsersAndGroupSubscribedToEvent($eventId, $courseId, $sessionId)
{
$eventId = (int) $eventId;
$courseId = (int) $courseId;
$sessionId = (int) $sessionId;
@ -1546,9 +1442,6 @@ class Agenda
return [];
}
$course = api_get_course_entity($courseId);
$session = api_get_session_entity($sessionId);
$users = [];
$groups = [];
$everyone = false;
@ -1558,7 +1451,7 @@ class Agenda
$users[] = $link->getUser()->getId();
}
if ($link->getGroup()) {
$groups[] = $link->getGroup()->getId();
$groups[] = $link->getGroup()->getIid();
}
}
@ -2495,7 +2388,7 @@ class Agenda
]
);
if ('course' == $this->type) {
if ('course' === $this->type) {
$form->addElement('textarea', 'comment', get_lang('Comment'));
$form->addLabel(
get_lang('Files attachments'),

@ -840,38 +840,6 @@ function api_get_path($path = '', $configuration = [])
$root_sys = api_add_trailing_slash($root_sys);
$root_rel = api_add_trailing_slash($root_rel);
// Initialization of a table that contains common-purpose paths.
/*$paths[$root_web][REL_PATH] = $root_rel;
$paths[$root_web][REL_CODE_PATH] = $root_rel.$code_folder;
$paths[$root_web][WEB_PATH] = $rootWebWithSlash;
$paths[$root_web][WEB_CODE_PATH] = $rootWebWithSlash.'main/';
$paths[$root_web][WEB_COURSE_PATH] = $rootWebWithSlash.$course_folder;
$paths[$root_web][WEB_PLUGIN_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PLUGIN_PATH];
$paths[$root_web][WEB_PLUGIN_ASSET_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PLUGIN_ASSET_PATH];
$paths[$root_web][WEB_ARCHIVE_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_ARCHIVE_PATH];
$paths[$root_web][WEB_CSS_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_CSS_PATH];
//$paths[$root_web][WEB_UPLOAD_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_UPLOAD_PATH];
$paths[$root_web][WEB_PUBLIC_PATH] = $rootWebWithSlash;
$paths[$root_web][WEB_IMG_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_IMG_PATH];
$paths[$root_web][WEB_LIBRARY_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_PATH];
$paths[$root_web][WEB_LIBRARY_JS_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_JS_PATH];
$paths[$root_web][WEB_AJAX_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_AJAX_PATH];
$paths[$root_web][SYS_PATH] = $root_sys;
$paths[$root_web][SYS_CODE_PATH] = $root_sys.$code_folder;
$paths[$root_web][SYS_TEST_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_TEST_PATH];
$paths[$root_web][SYS_TEMPLATE_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][SYS_TEMPLATE_PATH];
$paths[$root_web][SYS_PUBLIC_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_PUBLIC_PATH];
$paths[$root_web][SYS_CSS_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_CSS_PATH];
$paths[$root_web][SYS_FONTS_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][SYS_FONTS_PATH];
$paths[$root_web][SYS_ARCHIVE_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_ARCHIVE_PATH];
$paths[$root_web][SYS_APP_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_APP_PATH];
$paths[$root_web][SYS_UPLOAD_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_UPLOAD_PATH];
$paths[$root_web][SYS_PLUGIN_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_PLUGIN_PATH];
$paths[$root_web][LIBRARY_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][LIBRARY_PATH];
$paths[$root_web][CONFIGURATION_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][CONFIGURATION_PATH];*/
global $virtualChamilo;
if (!empty($virtualChamilo)) {
$paths[SYS_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[SYS_ARCHIVE_PATH]);
@ -3834,309 +3802,6 @@ function convert_sql_date($last_post_datetime)
return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
}
/**
* Delete a row in the c_item_property table.
*
* @param array $courseInfo
* @param string $tool
* @param int $itemId
* @param int $userId
* @param int $groupId group.iid
* @param int $sessionId
*
* @return false|null
*/
function api_item_property_delete(
$courseInfo,
$tool,
$itemId,
$userId,
$groupId = 0,
$sessionId = 0
) {
if (empty($courseInfo)) {
return false;
}
$courseId = (int) $courseInfo['real_id'];
if (empty($courseId) || empty($tool) || empty($itemId)) {
return false;
}
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tool = Database::escape_string($tool);
$itemId = intval($itemId);
$userId = intval($userId);
$groupId = intval($groupId);
$sessionId = intval($sessionId);
$groupCondition = " AND to_group_id = $groupId ";
if (empty($groupId)) {
$groupCondition = " AND (to_group_id is NULL OR to_group_id = 0) ";
}
$userCondition = " AND to_user_id = $userId ";
if (empty($userId)) {
$userCondition = " AND (to_user_id is NULL OR to_user_id = 0) ";
}
$sessionCondition = api_get_session_condition($sessionId, true, false, 'session_id');
$sql = "DELETE FROM $table
WHERE
c_id = $courseId AND
tool = '$tool' AND
ref = $itemId
$sessionCondition
$userCondition
$groupCondition
";
Database::query($sql);
}
/**
* Gets item property by tool.
*
* @param string course code
* @param string tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
* @param int id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
* @param int $session_id
* @param string $tool
* @param string $course_code
*
* @return array All fields from c_item_property (all rows found) or empty array
*/
function api_get_item_property_by_tool($tool, $course_code, $session_id = null)
{
$course_info = api_get_course_info($course_code);
$tool = Database::escape_string($tool);
// Definition of tables.
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$session_id = (int) $session_id;
$session_condition = ' AND session_id = '.$session_id;
if (empty($session_id)) {
$session_condition = " AND (session_id = 0 OR session_id IS NULL) ";
}
$course_id = $course_info['real_id'];
$sql = "SELECT * FROM $item_property_table
WHERE
c_id = $course_id AND
tool = '$tool'
$session_condition ";
$rs = Database::query($sql);
$list = [];
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$list[] = $row;
}
}
return $list;
}
/**
* Gets item property by tool and user.
*
* @param int $userId
* @param int $tool
* @param int $courseId
* @param int $session_id
*
* @return array
*/
function api_get_item_property_list_by_tool_by_user(
$userId,
$tool,
$courseId,
$session_id = 0
) {
$userId = intval($userId);
$tool = Database::escape_string($tool);
$session_id = intval($session_id);
$courseId = intval($courseId);
// Definition of tables.
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$session_condition = ' AND session_id = '.$session_id;
if (empty($session_id)) {
$session_condition = " AND (session_id = 0 OR session_id IS NULL) ";
}
$sql = "SELECT * FROM $item_property_table
WHERE
insert_user_id = $userId AND
c_id = $courseId AND
tool = '$tool'
$session_condition ";
$rs = Database::query($sql);
$list = [];
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$list[] = $row;
}
}
return $list;
}
/**
* Gets item property id from tool of a course.
*
* @param string $course_code course code
* @param string $tool tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
* @param int $ref id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
* @param int $sessionId Session ID (optional)
*
* @return int
*/
function api_get_item_property_id($course_code, $tool, $ref, $sessionId = 0)
{
$course_info = api_get_course_info($course_code);
$tool = Database::escape_string($tool);
$ref = (int) $ref;
// Definition of tables.
$tableItemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = $course_info['real_id'];
$sessionId = (int) $sessionId;
$sessionCondition = " AND session_id = $sessionId ";
if (empty($sessionId)) {
$sessionCondition = ' AND (session_id = 0 OR session_id IS NULL) ';
}
$sql = "SELECT id FROM $tableItemProperty
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref = $ref
$sessionCondition";
$rs = Database::query($sql);
$item_property_id = '';
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs);
$item_property_id = $row['id'];
}
return $item_property_id;
}
/**
* Inserts a record in the track_e_item_property table (No update).
*
* @param string $tool
* @param int $ref
* @param string $title
* @param string $content
* @param int $progress
*
* @return bool|int
*/
function api_track_item_property_update($tool, $ref, $title, $content, $progress)
{
$tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
$course_id = api_get_course_int_id(); //numeric
$course_code = api_get_course_id(); //alphanumeric
$item_property_id = api_get_item_property_id($course_code, $tool, $ref);
if (!empty($item_property_id)) {
$sql = "INSERT IGNORE INTO $tbl_stats_item_property SET
course_id = '$course_id',
item_property_id = '$item_property_id',
title = '".Database::escape_string($title)."',
content = '".Database::escape_string($content)."',
progress = '".intval($progress)."',
lastedit_date = '".api_get_utc_datetime()."',
lastedit_user_id = '".api_get_user_id()."',
session_id = '".api_get_session_id()."'";
$result = Database::query($sql);
$affected_rows = Database::affected_rows($result);
return $affected_rows;
}
return false;
}
/**
* @param string $tool
* @param int $ref
*
* @return array|resource
*/
function api_get_track_item_property_history($tool, $ref)
{
$tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
$course_id = api_get_course_int_id(); //numeric
$course_code = api_get_course_id(); //alphanumeric
$item_property_id = api_get_item_property_id($course_code, $tool, $ref);
$sql = "SELECT * FROM $tbl_stats_item_property
WHERE item_property_id = $item_property_id AND course_id = $course_id
ORDER BY lastedit_date DESC";
$result = Database::query($sql);
if (false === $result or null === $result) {
$result = [];
} else {
$result = Database::store_result($result, 'ASSOC');
}
return $result;
}
/**
* Gets item property data from tool of a course id.
*
* @deprecated
*
* @param int $course_id
* @param string $tool tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
* @param int $ref id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
* @param int $session_id
* @param int $groupId
*
* @return array with all fields from c_item_property, empty array if not found or false if course could not be found
*/
function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0, $groupId = 0)
{
$courseInfo = api_get_course_info_by_id($course_id);
if (empty($courseInfo)) {
return false;
}
$tool = Database::escape_string($tool);
$course_id = $courseInfo['real_id'];
$ref = (int) $ref;
$session_id = (int) $session_id;
$sessionCondition = " session_id = $session_id";
if (empty($session_id)) {
$sessionCondition = ' (session_id = 0 OR session_id IS NULL) ';
}
// Definition of tables.
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "SELECT * FROM $table
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref = $ref AND
$sessionCondition ";
if (!empty($groupId)) {
$groupId = (int) $groupId;
$sql .= " AND to_group_id = $groupId ";
}
$rs = Database::query($sql);
$row = [];
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs, 'ASSOC');
}
return $row;
}
/**
* Displays a combo box so the user can select his/her preferred language.
*
@ -4896,21 +4561,7 @@ function copy_folder_course_session(
'size' => '0',
'session_id' => $session_id,
];
$document_id = Database::insert($table, $params);
if ($document_id) {
/*api_item_property_update(
$course_info,
TOOL_DOCUMENT,
$document_id,
'FolderCreated',
api_get_user_id(),
0,
0,
null,
null,
$session_id
);*/
}
Database::insert($table, $params);
}
}
} // en foreach
@ -7161,19 +6812,6 @@ function api_set_default_visibility(
$visibility = DocumentManager::getDocumentDefaultVisibility($courseInfo);
}
/*api_item_property_update(
$courseInfo,
$original_tool_id,
$item_id,
$visibility,
$userId,
$groupInfo,
null,
null,
null,
$sessionId
);*/
// Fixes default visibility for tests
switch ($original_tool_id) {
case TOOL_QUIZ:

@ -128,7 +128,7 @@ class Display
$url = $courseInfo['course_public_url'];
$sessionId = api_get_session_id();
if (!empty($sessionId)) {
$url.= '&sid='.$sessionId;
$url .= '&sid='.$sessionId;
}
array_unshift(

@ -1110,7 +1110,7 @@ class Template
$url = $courseInfo['course_public_url'];
$sessionId = api_get_session_id();
if (!empty($sessionId)) {
$url.= '&sid='.$sessionId;
$url .= '&sid='.$sessionId;
}
array_unshift(
$interbreadcrumb,

@ -620,53 +620,11 @@ class Thematic
$qb->andWhere($qb->expr()->eq('resource.thematic', $thematic_id));
return $qb->getQuery()->getResult();
// set current course
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$thematic_id = (int) $thematic_id;
$data = [];
$sql = "SELECT * FROM $table
WHERE c_id = $course_id AND thematic_id = $thematic_id ";
$elements = [];
$list = api_get_item_property_by_tool(
'thematic_advance',
$course_info['code'],
api_get_session_id()
);
foreach ($list as $value) {
$elements[] = $value['ref'];
}
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res, 'ASSOC')) {
if (in_array($row['id'], $elements)) {
$data[] = $row;
}
}
}
return $data;
}
public function getThematicAdvance($id)
public function getThematicAdvance($id): ?CThematicAdvance
{
$repo = Container::getThematicAdvanceRepository();
/*
$courseEntity = api_get_course_entity($courseId);
$sessionEntity = null;
if ($sessionId) {
$sessionEntity = api_get_session_entity($sessionId);
$list = api_get_item_property_by_tool(
'thematic_advance',
$course_info['code'],
api_get_session_id()
);
foreach ($list as $value) {
$elements[$value['ref']] = $value;
}
}*/
return $repo->find($id);
}
@ -674,40 +632,20 @@ class Thematic
/**
* Get thematic advance list.
*
* @param int $thematic_advance_id Thematic advance id (optional), get data by thematic advance list
* @param string $course_code Course code (optional)
* @param bool $force_session_id Force to have a session id
* @param bool $withLocalTime Force start_date to local time
*
* @return array $data
* @return CThematicAdvance[]
*/
public function get_thematic_advance_list(
$thematic_advance_id = null,
$course_code = null,
$force_session_id = false,
$withLocalTime = false
) {
public function get_thematic_advance_list($course_code = null, $force_session_id = false, $withLocalTime = false)
{
$course_info = api_get_course_info($course_code);
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$data = [];
$condition = '';
$thematic_advance_id = (int) $thematic_advance_id;
if (!empty($thematic_advance_id)) {
$condition = " AND a.id = $thematic_advance_id ";
}
$course_id = $course_info['real_id'];
$sql = "SELECT * FROM $tbl_thematic_advance a
WHERE c_id = $course_id $condition
ORDER BY start_date ";
$repo = Container::getThematicAdvanceRepository();
$courseEntity = api_get_course_entity($course_id);
$sessionEntity = null;
$elements = [];
if ($force_session_id) {
$sessionEntity = api_get_session_entity(api_get_session_id());
/*$list = api_get_item_property_by_tool(
@ -724,34 +662,6 @@ class Thematic
$qb->orderBy('resource.startDate', 'DESC');
return $qb->getQuery()->getResult();
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
if (!empty($thematic_advance_id)) {
$data = Database::fetch_array($res);
} else {
// group all data group by thematic id
$tmp = [];
while ($row = Database::fetch_array($res, 'ASSOC')) {
if (true == $withLocalTime) {
$row['start_date'] = api_get_local_time($row['start_date']);
}
$tmp[] = $row['thematic_id'];
if (in_array($row['thematic_id'], $tmp)) {
if ($force_session_id) {
if (in_array($row['id'], array_keys($elements))) {
$row['session_id'] = $elements[$row['id']]['session_id'];
$data[$row['thematic_id']][$row['id']] = $row;
}
} else {
$data[$row['thematic_id']][$row['id']] = $row;
}
}
}
}
}
return $data;
}
/**
@ -763,19 +673,12 @@ class Thematic
*/
public function thematic_advance_save()
{
$_course = api_get_course_info();
// definition database table
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
// protect data
$id = intval($this->thematic_advance_id);
$id = (int) $this->thematic_advance_id;
$thematic_id = intval($this->thematic_id);
$attendance_id = intval($this->attendance_id);
$content = $this->thematic_advance_content;
$start_date = $this->start_date;
$duration = intval($this->duration);
$user_id = api_get_user_id();
$repo = Container::getThematicAdvanceRepository();
$em = $repo->getEntityManager();
@ -816,16 +719,6 @@ class Thematic
$em->flush();
$last_id = $advance->getIid();
if ($last_id) {
/*api_item_property_update(
$_course,
'thematic_advance',
$last_id,
'ThematicAdvanceAdded',
$user_id
);*/
}
} else {
$advance
->setCId($this->course_int_id)
@ -843,20 +736,6 @@ class Thematic
}
$em->persist($advance);
$em->flush();
/*
Database::update(
$table,
$params,
['id = ? AND c_id = ?' => [$id, $this->course_int_id]]
);
api_item_property_update(
$_course,
'thematic_advance',
$id,
'ThematicAdvanceUpdated',
$user_id
);*/
}
return $last_id;

@ -6861,11 +6861,7 @@ class Tracking
);
}
$courseWorkInformationArray = getWorkCreatedByUser(
$userId,
$courseInfo['real_id'],
$sessionId
);
$courseWorkInformationArray = getWorkCreatedByUser($userId, $courseInfo['real_id'], $sessionId);
if (!empty($courseWorkInformationArray)) {
$csvContent[] = null;

@ -5858,36 +5858,34 @@ function preAddAllWorkStudentCallback($p_event, &$p_header)
/**
* Get all work created by a user.
*
* @param int $user_id
* @param int $userId
* @param int $courseId
* @param int $sessionId
*
* @return array
*/
function getWorkCreatedByUser($user_id, $courseId, $sessionId)
function getWorkCreatedByUser($userId, $courseId, $sessionId)
{
$items = api_get_item_property_list_by_tool_by_user(
$user_id,
'work',
$courseId,
$sessionId
);
$repo = Container::getStudentPublicationRepository();
$courseEntity = api_get_course_entity($courseId);
$sessionEntity = api_get_session_entity($sessionId);
$qb = $repo->getResourcesByCourse($courseEntity, $sessionEntity);
$qb->andWhere('node.creator = :creator');
$qb->setParameter('creator', $userId);
$items = $qb->getQuery()->getResult();
$list = [];
if (!empty($items)) {
/** @var CStudentPublication $work */
foreach ($items as $work) {
$item = get_work_data_by_id(
$work['ref'],
$courseId,
$sessionId
);
if (!empty($item)) {
$list[] = [
$item['title'],
api_get_local_time($work['insert_date']),
api_get_local_time($work['lastedit_date']),
];
}
$list[] = [
$work->getTitle(),
api_get_local_time($work->getResourceNode()->getCreatedAt()),
api_get_local_time($work->getResourceNode()->getUpdatedAt()),
];
}
}

@ -189,6 +189,11 @@ class ResourceLink
return $this;
}
public function hasGroup(): bool
{
return null !== $this->group;
}
public function getGroup(): ?CGroup
{
return $this->group;
@ -215,14 +220,17 @@ class ResourceLink
/**
* Get user.
*
* @return User
*/
public function getUser()
public function getUser(): ?User
{
return $this->user;
}
public function hasUser(): bool
{
return null !== $this->user;
}
/**
* Get course.
*/

@ -275,7 +275,7 @@ class ResourceNode
/**
* Return the lvl value of the resource in the tree.
*/
public function getLevel(): int
public function getLevel()
{
return (int) $this->level;
}

@ -115,7 +115,9 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
/**
* @var ArrayCollection|CCalendarEventAttachment[]
*
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CCalendarEventAttachment", mappedBy="event", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OneToMany(
* targetEntity="Chamilo\CourseBundle\Entity\CCalendarEventAttachment", mappedBy="event", cascade={"persist", "remove"}, orphanRemoval=true
* )
*/
protected $attachments;
@ -132,10 +134,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set title.
*
* @param string $title
*
* @return CCalendarEvent
*/
public function setTitle($title)
public function setTitle($title): self
{
$this->title = $title;
@ -156,10 +156,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set content.
*
* @param string $content
*
* @return CCalendarEvent
*/
public function setContent($content)
public function setContent($content): self
{
$this->content = $content;
@ -180,10 +178,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set startDate.
*
* @param \DateTime $startDate
*
* @return CCalendarEvent
*/
public function setStartDate($startDate)
public function setStartDate($startDate): self
{
$this->startDate = $startDate;
@ -204,10 +200,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set endDate.
*
* @param \DateTime $endDate
*
* @return CCalendarEvent
*/
public function setEndDate($endDate)
public function setEndDate($endDate): self
{
$this->endDate = $endDate;
@ -228,10 +222,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set parentEventId.
*
* @param int $parentEventId
*
* @return CCalendarEvent
*/
public function setParentEventId($parentEventId)
public function setParentEventId($parentEventId): self
{
$this->parentEventId = $parentEventId;
@ -252,10 +244,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set sessionId.
*
* @param int $sessionId
*
* @return CCalendarEvent
*/
public function setSessionId($sessionId)
public function setSessionId($sessionId): self
{
$this->sessionId = $sessionId;
@ -276,10 +266,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
* Set allDay.
*
* @param int $allDay
*
* @return CCalendarEvent
*/
public function setAllDay($allDay)
public function setAllDay($allDay): self
{
$this->allDay = $allDay;
@ -330,10 +318,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
/**
* @param string $comment
*
* @return CCalendarEvent
*/
public function setComment($comment)
public function setComment($comment): self
{
$this->comment = $comment;
@ -350,10 +336,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
/**
* @param Room $room
*
* @return $this
*/
public function setRoom($room)
public function setRoom($room): self
{
$this->room = $room;
@ -370,10 +354,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
/**
* @param string $color
*
* @return $this
*/
public function setColor($color)
public function setColor($color): self
{
$this->color = $color;
@ -388,18 +370,6 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
return $this->iid;
}
/**
* @param int $iid
*
* @return CCalendarEvent
*/
public function setIid($iid)
{
$this->iid = $iid;
return $this;
}
/**
* @return CCalendarEventAttachment[]|ArrayCollection
*/
@ -410,23 +380,47 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
/**
* @param CCalendarEventAttachment[]|ArrayCollection $attachments
*
* @return CCalendarEvent
*/
public function setAttachments($attachments)
public function setAttachments($attachments): self
{
$this->attachments = $attachments;
return $this;
}
public function addAttachment(CCalendarEventAttachment $attachment)
public function addAttachment(CCalendarEventAttachment $attachment): self
{
$this->attachments->add($attachment);
return $this;
}
public function getUsersAndGroupSubscribedToEvent()
{
$users = [];
$groups = [];
$everyone = false;
$links = $this->getResourceNode()->getResourceLinks();
foreach ($links as $link) {
if ($link->getUser()) {
$users[] = $link->getUser()->getId();
}
if ($link->getGroup()) {
$groups[] = $link->getGroup()->getIid();
}
}
if (empty($users) && empty($groups)) {
$everyone = true;
}
return [
'everyone' => $everyone,
'users' => $users,
'groups' => $groups,
];
}
/**
* Resource identifier.
*/

@ -80,7 +80,9 @@ class CThematic extends AbstractResource implements ResourceInterface
/**
* @var CThematicPlan[]
*
* @ORM\OneToMany(targetEntity="CThematicPlan", mappedBy="thematic", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OneToMany(
* targetEntity="CThematicPlan", mappedBy="thematic", cascade={"persist", "remove"}, orphanRemoval=true
* )
*/
protected $plans;
@ -89,7 +91,9 @@ class CThematic extends AbstractResource implements ResourceInterface
*
* @ORM\OrderBy({"startDate" = "ASC"})
*
* @ORM\OneToMany(targetEntity="CThematicAdvance", mappedBy="thematic", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OneToMany(
* targetEntity="CThematicAdvance", mappedBy="thematic", cascade={"persist", "remove"}, orphanRemoval=true
* )
*/
protected $advances;
@ -108,10 +112,8 @@ class CThematic extends AbstractResource implements ResourceInterface
* Set title.
*
* @param string $title
*
* @return CThematic
*/
public function setTitle($title)
public function setTitle($title): self
{
$this->title = $title;
@ -132,10 +134,8 @@ class CThematic extends AbstractResource implements ResourceInterface
* Set content.
*
* @param string $content
*
* @return CThematic
*/
public function setContent($content)
public function setContent($content): self
{
$this->content = $content;
@ -156,10 +156,8 @@ class CThematic extends AbstractResource implements ResourceInterface
* Set displayOrder.
*
* @param int $displayOrder
*
* @return CThematic
*/
public function setDisplayOrder($displayOrder)
public function setDisplayOrder($displayOrder): self
{
$this->displayOrder = $displayOrder;
@ -180,10 +178,8 @@ class CThematic extends AbstractResource implements ResourceInterface
* Set active.
*
* @param bool $active
*
* @return CThematic
*/
public function setActive($active)
public function setActive($active): self
{
$this->active = $active;

Loading…
Cancel
Save