pull/2858/head
Alex Aragón 7 years ago
commit cd88c29a89
  1. 46
      main/forum/forumfunction.inc.php
  2. 1
      main/forum/reply.php
  3. 2
      main/forum/viewthread.php
  4. 11
      main/inc/ajax/chat.ajax.php
  5. 83
      main/inc/lib/agenda.lib.php
  6. 112
      main/inc/lib/chat.lib.php
  7. 6
      main/inc/lib/document.lib.php
  8. 24
      main/inc/lib/extra_field_value.lib.php
  9. 86
      main/inc/lib/javascript/chat/js/chat.js
  10. 106
      main/inc/lib/sessionmanager.lib.php
  11. 3
      plugin/buycourses/src/buy_course_plugin.class.php
  12. 8
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php
  13. 29
      src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php

@ -4504,7 +4504,8 @@ function handle_mail_cue($content, $id)
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
send_mail($row, get_thread_information($post_info['forum_id'], $post_info['thread_id']), $post_info); $forumInfo = get_forum_information($post_info['forum_id']);
send_mail($row, $forumInfo, get_thread_information($post_info['forum_id'], $post_info['thread_id']), $post_info);
} }
} elseif ($content == 'thread') { } elseif ($content == 'thread') {
// Sending the mail to all the users that wanted to be informed for replies on this thread. // Sending the mail to all the users that wanted to be informed for replies on this thread.
@ -4521,7 +4522,8 @@ function handle_mail_cue($content, $id)
GROUP BY users.email"; GROUP BY users.email";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
send_mail($row, get_thread_information($row['forum_id'], $id)); $forumInfo = get_forum_information($row['forum_id']);
send_mail($row, $forumInfo, get_thread_information($row['forum_id'], $id));
} }
// Deleting the relevant entries from the mailcue. // Deleting the relevant entries from the mailcue.
@ -4553,29 +4555,35 @@ function handle_mail_cue($content, $id)
* @param array * @param array
* @param array * @param array
* @param array * @param array
* @param array
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* *
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
*/ */
function send_mail($user_info = [], $thread_information = [], $postInfo = []) function send_mail($userInfo, $forumInfo, $thread_information, $postInfo = [])
{ {
if (empty($userInfo) || empty($forumInfo) || empty($thread_information)) {
return false;
}
$_course = api_get_course_info(); $_course = api_get_course_info();
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$thread_link = ''; $thread_link = '';
if (isset($thread_information) && is_array($thread_information)) { if (isset($thread_information) && is_array($thread_information)) {
$thread_link = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&forum='.$thread_information['forum_id'].'&thread='.$thread_information['thread_id']; $thread_link = api_get_path(WEB_CODE_PATH).
'forum/viewthread.php?'.api_get_cidreq().'&forum='.$thread_information['forum_id'].'&thread='.$thread_information['thread_id'];
} }
$email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r"; $email_body = get_lang('Dear').' '.api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
$email_body .= get_lang('NewForumPost')."\n"; $email_body .= get_lang('NewForumPost').': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$courseId = api_get_configuration_value('global_forums_course_id'); $courseId = api_get_configuration_value('global_forums_course_id');
$subject = get_lang('NewForumPost').' - '.$_course['official_code']; $subject = get_lang('NewForumPost').' - '.$_course['official_code'].': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$courseInfoTitle = get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."] - <br />\n"; $courseInfoTitle = get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."] - <br />\n";
if (!empty($courseId) && $_course['real_id'] == $courseId) { if (!empty($courseId) && $_course['real_id'] == $courseId) {
$subject = get_lang('NewForumPost'); $subject = get_lang('NewForumPost').': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$courseInfoTitle = " <br />\n"; $courseInfoTitle = " <br />\n";
} }
$email_body .= $courseInfoTitle; $email_body .= $courseInfoTitle;
@ -4595,9 +4603,9 @@ function send_mail($user_info = [], $thread_information = [], $postInfo = [])
$email_body .= get_lang('ThreadCanBeFoundHere')." : <br /><a href=\"".$thread_link."\">".$thread_link."</a>\n"; $email_body .= get_lang('ThreadCanBeFoundHere')." : <br /><a href=\"".$thread_link."\">".$thread_link."</a>\n";
} }
if ($user_info['user_id'] != $user_id) { if ($userInfo['user_id'] != $user_id) {
MessageManager::send_message( MessageManager::send_message(
$user_info['user_id'], $userInfo['user_id'],
$subject, $subject,
$email_body, $email_body,
[], [],
@ -5761,26 +5769,12 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
// Merging the two // Merging the two
$users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread); $users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread);
//$sender_id = api_get_user_id(); $forumInfo = get_forum_information($forum_id);
if (is_array($users_to_be_notified)) { if (is_array($users_to_be_notified)) {
foreach ($users_to_be_notified as $value) { foreach ($users_to_be_notified as $value) {
/*$user_info = api_get_user_info($value['user_id']);
$email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
$email_body .= get_lang('NewForumPost').": ".$current_forum['forum_title'].' - '.$current_thread['thread_title']." <br />\n";
$email_body .= get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."] <br />\n";
$email_body .= get_lang('YouWantedToStayInformed')."<br />\n";
$email_body .= get_lang('ThreadCanBeFoundHere').': <br /> <a href="'.$thread_link.'">'.$thread_link."</a>\n";
MessageManager::send_message_simple(
$value['user_id'],
$subject,
$email_body,
$sender_id
);*/
$userInfo = api_get_user_info($value['user_id']); $userInfo = api_get_user_info($value['user_id']);
send_mail($userInfo, $current_thread, $postInfo); send_mail($userInfo, $forumInfo, $current_thread, $postInfo);
} }
} }
} }

@ -158,7 +158,6 @@ $logInfo = [
'tool_id' => $forumId, 'tool_id' => $forumId,
'tool_id_detail' => $threadId, 'tool_id_detail' => $threadId,
'action' => !empty($my_action) ? $my_action : 'reply', 'action' => !empty($my_action) ? $my_action : 'reply',
'action_details' => '',
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);

@ -628,7 +628,9 @@ foreach ($posts as $post) {
$search = [ $search = [
get_lang('ReplyShort'), get_lang('ReplyShort'),
'Re:', 'Re:',
'RE:',
'AW:', 'AW:',
'Aw:',
]; ];
$replace = '<span>'.Display::returnFontAwesomeIcon('mail-reply').'</span>'; $replace = '<span>'.Display::returnFontAwesomeIcon('mail-reply').'</span>';
$post['post_title'] = str_replace($search, $replace, $post['post_title']); $post['post_title'] = str_replace($search, $replace, $post['post_title']);

@ -103,16 +103,23 @@ switch ($action) {
break; break;
case 'get_previous_messages': case 'get_previous_messages':
$userId = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0; $userId = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0;
$visibleMessages = isset($_REQUEST['visible_messages']) ? $_REQUEST['visible_messages'] : null; $visibleMessages = isset($_REQUEST['visible_messages']) ? $_REQUEST['visible_messages'] : 0;
if (empty($userId)) { if (empty($userId)) {
return ''; return '';
} }
$items = $chat->getPreviousMessages( $items = $chat->getPreviousMessages(
$userId, $userId,
$currentUserId, $currentUserId,
$visibleMessages $visibleMessages
); );
echo json_encode($items);
if (!empty($items)) {
sort($items);
echo json_encode($items);
exit;
}
echo json_encode([]);
exit; exit;
break; break;
case 'notify_not_support': case 'notify_not_support':

@ -2942,62 +2942,41 @@ class Agenda
*/ */
public function displayActions($view, $filter = 0) public function displayActions($view, $filter = 0)
{ {
$courseInfo = api_get_course_info();
$groupInfo = GroupManager::get_group_properties(api_get_group_id()); $groupInfo = GroupManager::get_group_properties(api_get_group_id());
$groupIid = isset($groupInfo['iid']) ? $groupInfo['iid'] : 0; $groupIid = isset($groupInfo['iid']) ? $groupInfo['iid'] : 0;
$courseCondition = ''; $codePath = api_get_path(WEB_CODE_PATH);
if (!empty($courseInfo)) {
$courseCondition = api_get_cidreq();
}
$actionsLeft = ''; $currentUserId = api_get_user_id();
$actionsLeft .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?type={$this->type}&".$courseCondition."'>". $cidReq = api_get_cidreq();
Display::return_icon(
'calendar.png',
get_lang('Calendar'),
'',
ICON_SIZE_MEDIUM
)."</a>";
$actionsLeft .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda_list.php?type={$this->type}&".$courseCondition."'>". $actionsLeft = '';
Display::return_icon( $actionsLeft .= Display::url(
'week.png', Display::return_icon('calendar.png', get_lang('Calendar'), [], ICON_SIZE_MEDIUM),
get_lang('AgendaList'), $codePath."calendar/agenda_js.php?type={$this->type}&$cidReq"
'', );
ICON_SIZE_MEDIUM $actionsLeft .= Display::url(
)."</a>"; Display::return_icon('week.png', get_lang('AgendaList'), [], ICON_SIZE_MEDIUM),
$codePath."calendar/agenda_list.php?type={$this->type}&$cidReq"
);
$form = ''; $form = '';
if (api_is_allowed_to_edit(false, true) || if (api_is_allowed_to_edit(false, true) ||
(api_get_course_setting('allow_user_edit_agenda') == '1' && (api_get_course_setting('allow_user_edit_agenda') == '1' && !api_is_anonymous()) &&
!api_is_anonymous()) && api_is_allowed_to_session_edit(false, true)
api_is_allowed_to_session_edit(false, true) || || (
(GroupManager::user_has_access( GroupManager::user_has_access($currentUserId, $groupIid, GroupManager::GROUP_TOOL_CALENDAR)
api_get_user_id(), && GroupManager::is_tutor_of_group($currentUserId, $groupInfo)
$groupIid, )
GroupManager::GROUP_TOOL_CALENDAR
) &&
GroupManager::is_tutor_of_group(api_get_user_id(), $groupInfo))
) { ) {
$actionsLeft .= Display::url( $actionsLeft .= Display::url(
Display::return_icon( Display::return_icon('new_event.png', get_lang('AgendaAdd'), [], ICON_SIZE_MEDIUM),
'new_event.png', $codePath."calendar/agenda.php?action=add&type={$this->type}&$cidReq"
get_lang('AgendaAdd'),
'',
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH)."calendar/agenda.php?".api_get_cidreq()."&action=add&type=".$this->type
); );
$actionsLeft .= Display::url( $actionsLeft .= Display::url(
Display::return_icon( Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), [], ICON_SIZE_MEDIUM),
'import_calendar.png', $codePath."calendar/agenda.php?action=importical&type={$this->type}&$cidReq"
get_lang('ICalFileImport'),
'',
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH)."calendar/agenda.php?".api_get_cidreq()."&action=importical&type=".$this->type
); );
if ($this->type === 'course') { if ($this->type === 'course') {
@ -3040,26 +3019,20 @@ class Agenda
FormValidator::LAYOUT_INLINE FormValidator::LAYOUT_INLINE
); );
$sessions = [];
if (api_is_drh()) { if (api_is_drh()) {
$sessionList = SessionManager::get_sessions_followed_by_drh( $sessionList = SessionManager::get_sessions_followed_by_drh($currentUserId);
api_get_user_id()
);
if (!empty($sessionList)) { if (!empty($sessionList)) {
$sessions = [];
foreach ($sessionList as $sessionItem) { foreach ($sessionList as $sessionItem) {
$sessions[$sessionItem['id']] = strip_tags($sessionItem['name']); $sessions[$sessionItem['id']] = strip_tags($sessionItem['name']);
} }
} }
} else { } else {
$sessions = SessionManager::get_sessions_by_user( $sessions = SessionManager::get_sessions_by_user($currentUserId);
api_get_user_id() $sessions = array_column($sessions, 'session_name', 'session_id');
);
$sessions = array_column(
$sessions,
'session_name',
'session_id'
);
} }
$form->addHidden('type', 'personal'); $form->addHidden('type', 'personal');
$sessions = ['0' => get_lang('SelectAnOption')] + $sessions; $sessions = ['0' => get_lang('SelectAnOption')] + $sessions;

@ -73,7 +73,7 @@ class Chat extends Model
*/ */
public function getLatestChat($currentUserId, $userId, $latestMessages) public function getLatestChat($currentUserId, $userId, $latestMessages)
{ {
$items = self::getPreviousMessages( $items = $this->getPreviousMessages(
$currentUserId, $currentUserId,
$userId, $userId,
0, 0,
@ -113,14 +113,12 @@ class Chat extends Model
$chats = []; $chats = [];
foreach ($chatHistory as $userId => $time) { foreach ($chatHistory as $userId => $time) {
$total = self::getCountMessagesExchangeBetweenUsers($userId, $currentUserId); $total = $this->getCountMessagesExchangeBetweenUsers($userId, $currentUserId);
$start = $total - $latestMessages; $start = $total - $latestMessages;
if ($start < 0) { if ($start < 0) {
$start = 0; $start = 0;
} }
$items = $this->getMessages($userId, $currentUserId, 1, $start, $latestMessages); $items = $this->getMessages($userId, $currentUserId, $start, $latestMessages);
$chats[$userId]['items'] = $items; $chats[$userId]['items'] = $items;
$chats[$userId]['window_user_info'] = api_get_user_info($userId); $chats[$userId]['window_user_info'] = api_get_user_info($userId);
} }
@ -140,7 +138,7 @@ class Chat extends Model
// $chat->setUserStatus(1); // $chat->setUserStatus(1);
$chatList = Session::read('openChatBoxes'); $chatList = Session::read('openChatBoxes');
$chats = self::getAllLatestChats($chatList); $chats = $this->getAllLatestChats($chatList);
$return = [ $return = [
'user_status' => $this->getUserStatus(), 'user_status' => $this->getUserStatus(),
'me' => get_lang('Me'), 'me' => get_lang('Me'),
@ -191,33 +189,39 @@ class Chat extends Model
$fromUserId, $fromUserId,
$toUserId, $toUserId,
$visibleMessages = 1, $visibleMessages = 1,
$previousMessageCount = 5 $previousMessageCount = 5,
$orderBy = ''
) { ) {
$toUserId = (int) $toUserId; $toUserId = (int) $toUserId;
$fromUserId = (int) $fromUserId; $fromUserId = (int) $fromUserId;
$visibleMessages = (int) $visibleMessages;
$previousMessageCount = (int) $previousMessageCount;
$total = $this->getCountMessagesExchangeBetweenUsers($fromUserId, $toUserId); $total = $this->getCountMessagesExchangeBetweenUsers($fromUserId, $toUserId);
$show = $total - $visibleMessages; $show = $total - $visibleMessages;
if ($show < $previousMessageCount) {
$show = $previousMessageCount;
}
$from = $show - $previousMessageCount; $from = $show - $previousMessageCount;
if ($from < 0) { if ($from < 0) {
return []; return [];
} }
return $this->getMessages($fromUserId, $toUserId, $visibleMessages, $from, $previousMessageCount); return $this->getMessages($fromUserId, $toUserId, $from, $previousMessageCount, $orderBy);
} }
/** /**
* @param int $fromUserId * @param int $fromUserId
* @param int $toUserId * @param int $toUserId
* @param int $visibleMessages * @param int $start
* @param int $start * @param int $end
* @param int $end * @param string $orderBy
* *
* @return array * @return array
*/ */
public function getMessages($fromUserId, $toUserId, $visibleMessages, $start, $end, $orderBy = '') public function getMessages($fromUserId, $toUserId, $start, $end, $orderBy = '')
{ {
$toUserId = (int) $toUserId; $toUserId = (int) $toUserId;
$fromUserId = (int) $fromUserId; $fromUserId = (int) $fromUserId;
@ -227,8 +231,8 @@ class Chat extends Model
if (empty($toUserId) || empty($fromUserId)) { if (empty($toUserId) || empty($fromUserId)) {
return []; return [];
} }
$orderBy = Database::escape_string($orderBy);
$orderBy = Database::escape_string($orderBy);
if (empty($orderBy)) { if (empty($orderBy)) {
$orderBy = 'ORDER BY id ASC'; $orderBy = 'ORDER BY id ASC';
} }
@ -262,17 +266,14 @@ class Chat extends Model
$userInfo = $users[$fromUserId]; $userInfo = $users[$fromUserId];
$toUserInfo = $users[$toUserId]; $toUserInfo = $users[$toUserId];
$item = [ $items[$chat['id']] = [
'id' => $chat['id'], 'id' => $chat['id'],
's' => '0', 'message' => Security::remove_XSS($chat['message']),
'f' => $fromUserId, 'date' => api_strtotime($chat['sent'], 'UTC'),
'm' => Security::remove_XSS($chat['message']),
'recd' => $chat['recd'], 'recd' => $chat['recd'],
'from_user_info' => $userInfo, 'from_user_info' => $userInfo,
'to_user_info' => $toUserInfo, 'to_user_info' => $toUserInfo,
'date' => api_strtotime($chat['sent'], 'UTC'),
]; ];
$items[$chat['id']] = $item;
$_SESSION['openChatBoxes'][$fromUserId] = api_strtotime($chat['sent'], 'UTC'); $_SESSION['openChatBoxes'][$fromUserId] = api_strtotime($chat['sent'], 'UTC');
} }
@ -284,10 +285,23 @@ class Chat extends Model
*/ */
public function heartbeat() public function heartbeat()
{ {
$chatHistory = Session::read('chatHistory');
$currentUserId = api_get_user_id(); $currentUserId = api_get_user_id();
// update current chats
if (!empty($chatHistory) && is_array($chatHistory)) {
foreach ($chatHistory as $fromUserId => &$data) {
$userInfo = api_get_user_info($fromUserId, true);
$count = $this->getCountMessagesExchangeBetweenUsers($fromUserId, $currentUserId);
$chatItems = $this->getLatestChat($fromUserId, $currentUserId, 5);
$data['window_user_info'] = $userInfo;
$data['items'] = $chatItems;
$data['total_messages'] = $count;
}
}
$sql = "SELECT * FROM ".$this->table." $sql = "SELECT * FROM ".$this->table."
WHERE WHERE
to_user = '".$currentUserId."' AND recd = 0 to_user = '".$currentUserId."' AND recd = 0
ORDER BY id ASC"; ORDER BY id ASC";
$result = Database::query($sql); $result = Database::query($sql);
@ -297,29 +311,6 @@ class Chat extends Model
$chatList[$chat['from_user']][] = $chat; $chatList[$chat['from_user']][] = $chat;
} }
$chatHistory = Session::read('chatHistory');
// update current chats
if (!empty($chatHistory) && is_array($chatHistory)) {
foreach ($chatHistory as $fromUserId => &$data) {
$userInfo = api_get_user_info($fromUserId, true);
$count = $this->getCountMessagesExchangeBetweenUsers($fromUserId, $currentUserId);
$chatItems = $this->getLatestChat($fromUserId, $currentUserId, 5);
$item = [
'window_user_info' => $userInfo,
'items' => $chatItems,
'total_messages' => $count,
'user_info' => [
'user_name' => $userInfo['complete_name'],
'online' => $userInfo['user_is_online'],
'avatar' => $userInfo['avatar_small'],
'user_id' => $userInfo['user_id'],
],
];
$data = $item;
}
}
foreach ($chatList as $fromUserId => $messages) { foreach ($chatList as $fromUserId => $messages) {
$userInfo = api_get_user_info($fromUserId, true); $userInfo = api_get_user_info($fromUserId, true);
$count = $this->getCountMessagesExchangeBetweenUsers($fromUserId, $currentUserId); $count = $this->getCountMessagesExchangeBetweenUsers($fromUserId, $currentUserId);
@ -332,24 +323,14 @@ class Chat extends Model
$_SESSION['openChatBoxes'][$fromUserId] = api_strtotime($chat['sent'], 'UTC'); $_SESSION['openChatBoxes'][$fromUserId] = api_strtotime($chat['sent'], 'UTC');
} }
$item = [ $chatHistory[$fromUserId] = [
'window_user_info' => api_get_user_info($fromUserId), 'window_user_info' => $userInfo,
'items' => $chatItems,
'total_messages' => $count, 'total_messages' => $count,
'user_info' => [ 'items' => $chatItems,
'user_name' => $userInfo['complete_name'],
'online' => $userInfo['user_is_online'],
'avatar' => $userInfo['avatar_small'],
'user_id' => $userInfo['user_id'],
],
]; ];
$chatHistory[$fromUserId] = $item;
} }
Session::write('chatHistory', $chatHistory); /*if (!empty($_SESSION['openChatBoxes'])) {
if (!empty($_SESSION['openChatBoxes'])) {
foreach ($_SESSION['openChatBoxes'] as $userId => $time) { foreach ($_SESSION['openChatBoxes'] as $userId => $time) {
if (!isset($_SESSION['tsChatBoxes'][$userId])) { if (!isset($_SESSION['tsChatBoxes'][$userId])) {
$now = time() - $time; $now = time() - $time;
@ -357,12 +338,6 @@ class Chat extends Model
$message = sprintf(get_lang('SentAtX'), $time); $message = sprintf(get_lang('SentAtX'), $time);
if ($now > 180) { if ($now > 180) {
$item = [
's' => '2',
'f' => $userId,
'm' => $message,
];
if (isset($chatHistory[$userId])) { if (isset($chatHistory[$userId])) {
$chatHistory[$userId]['items'][] = $item; $chatHistory[$userId]['items'][] = $item;
} }
@ -370,8 +345,7 @@ class Chat extends Model
} }
} }
} }
} }*/
Session::write('chatHistory', $chatHistory); Session::write('chatHistory', $chatHistory);
$sql = "UPDATE ".$this->table." $sql = "UPDATE ".$this->table."
@ -418,7 +392,7 @@ class Chat extends Model
$_SESSION['openChatBoxes'][$to_user_id] = api_strtotime($now, 'UTC'); $_SESSION['openChatBoxes'][$to_user_id] = api_strtotime($now, 'UTC');
if ($sanitize) { if ($sanitize) {
$messagesan = self::sanitize($message); $messagesan = $this->sanitize($message);
} else { } else {
$messagesan = $message; $messagesan = $message;
} }

@ -717,7 +717,7 @@ class DocumentManager
) { ) {
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); $TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$groupIid = intval($groupIid); $groupIid = (int) $groupIid;
$document_folders = []; $document_folders = [];
$students = CourseManager::get_user_list_from_course_code( $students = CourseManager::get_user_list_from_course_code(
@ -734,7 +734,7 @@ class DocumentManager
$groupCondition = " last.to_group_id = $groupIid"; $groupCondition = " last.to_group_id = $groupIid";
if (empty($groupIid)) { if (empty($groupIid)) {
$groupCondition = " (last.to_group_id = 0 OR last.to_group_id IS NULL)"; $groupCondition = ' (last.to_group_id = 0 OR last.to_group_id IS NULL)';
} }
$show_users_condition = ''; $show_users_condition = '';
@ -821,7 +821,7 @@ class DocumentManager
$condition_session = api_get_session_condition( $condition_session = api_get_session_condition(
$session_id, $session_id,
true, true,
false, true, // needed to don't show files in elfinder browser
'docs.session_id' 'docs.session_id'
); );

@ -5,7 +5,6 @@ use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldRelTag; use Chamilo\CoreBundle\Entity\ExtraFieldRelTag;
use Chamilo\CoreBundle\Entity\ExtraFieldValues; use Chamilo\CoreBundle\Entity\ExtraFieldValues;
use Chamilo\CoreBundle\Entity\Tag; use Chamilo\CoreBundle\Entity\Tag;
use ChamiloSession as Session;
/** /**
* Class ExtraFieldValue * Class ExtraFieldValue
@ -81,12 +80,19 @@ class ExtraFieldValue extends Model
* @param array $params array for the insertion into the *_field_values table * @param array $params array for the insertion into the *_field_values table
* @param bool $onlySubmittedFields Only save parameters in the $param array * @param bool $onlySubmittedFields Only save parameters in the $param array
* @param bool $showQuery * @param bool $showQuery
* @param array $saveOnlyThisFields
* @param array $avoidFields do not insert/modify this field
* *
* @return mixed false on empty params, void otherwise * @return mixed false on empty params, void otherwise
* @assert (array()) === false * @assert (array()) === false
*/ */
public function saveFieldValues($params, $onlySubmittedFields = false, $showQuery = false) public function saveFieldValues(
{ $params,
$onlySubmittedFields = false,
$showQuery = false,
$saveOnlyThisFields = [],
$avoidFields = []
) {
foreach ($params as $key => $value) { foreach ($params as $key => $value) {
$found = strpos($key, '__persist__'); $found = strpos($key, '__persist__');
@ -128,6 +134,18 @@ class ExtraFieldValue extends Model
continue; continue;
} }
if (!empty($avoidFields)) {
if (in_array($field_variable, $avoidFields)) {
continue;
}
}
if (!empty($saveOnlyThisFields)) {
if (!in_array($field_variable, $saveOnlyThisFields)) {
continue;
}
}
$value = ''; $value = '';
if (isset($params['extra_'.$field_variable])) { if (isset($params['extra_'.$field_variable])) {
$value = $params['extra_'.$field_variable]; $value = $params['extra_'.$field_variable];

@ -78,11 +78,6 @@ $(function() {
$('body').on('click', '#chatboxtitlemain', function() { $('body').on('click', '#chatboxtitlemain', function() {
createMyContactsWindow(); createMyContactsWindow();
set_user_status(1); set_user_status(1);
/*if (user_status == 1) {
set_user_status(0);
} else {
set_user_status(1);
}*/
}); });
// User name header toogle // User name header toogle
@ -171,12 +166,7 @@ function startChatSession()
); );
} }
if (item.s == 2) { createChatBubble(my_user_id, item);
// info message
} else {
var chatBubble = createChatBubble(my_user_id, item);
$("#chatbox_"+my_user_id+" .chatboxcontent").append(chatBubble);
}
} }
}); });
}); });
@ -188,7 +178,8 @@ function startChatSession()
); );
} }
} }
}}); }
});
} }
} }
@ -209,7 +200,6 @@ function startChatHeartBeat()
* Item array structure : * Item array structure :
* *
* item.s = type of message: 1 = message, 2 = "sent at" string * item.s = type of message: 1 = message, 2 = "sent at" string
* item.m = message
* item.f = from_user * item.f = from_user
* *
**/ **/
@ -261,6 +251,12 @@ function chatHeartbeat()
// Each window // Each window
my_items = user_items['items']; my_items = user_items['items'];
userInfo = user_items['window_user_info']; userInfo = user_items['window_user_info'];
update_online_user(
my_user_id,
userInfo.user_is_online
);
$.each(my_items, function(i, item) { $.each(my_items, function(i, item) {
if (item) { if (item) {
// fix strange ie bug // fix strange ie bug
@ -273,22 +269,17 @@ function chatHeartbeat()
userInfo.avatar_small userInfo.avatar_small
); );
} }
if ($("#chatbox_"+my_user_id).css('display') == 'none') { if ($("#chatbox_"+my_user_id).css('display') == 'none') {
$("#chatbox_"+my_user_id).css('display','block'); $("#chatbox_"+my_user_id).css('display','block');
restructureChatBoxes(); restructureChatBoxes();
} }
update_online_user(
my_user_id,
user_items.user_info.online
);
if (item.s == 2) { newMessages[my_user_id] = {'status':true, 'username':item.username};
} else { newMessagesWin[my_user_id]= {'status':true, 'username':item.username};
newMessages[my_user_id] = {'status':true, 'username':item.username};
newMessagesWin[my_user_id]= {'status':true, 'username':item.username}; var chatBubble = createChatBubble(my_user_id, item);
var chatBubble = createChatBubble(my_user_id, item); //$("#chatbox_"+my_user_id+" .chatboxcontent").append(chatBubble);
$("#chatbox_"+my_user_id+" .chatboxcontent").append(chatBubble);
}
$("#chatbox_"+my_user_id+" .chatboxcontent").scrollTop( $("#chatbox_"+my_user_id+" .chatboxcontent").scrollTop(
$("#chatbox_"+my_user_id+" .chatboxcontent")[0].scrollHeight $("#chatbox_"+my_user_id+" .chatboxcontent")[0].scrollHeight
@ -324,7 +315,7 @@ function chatHeartbeat()
* @param item * @param item
* @returns {string} * @returns {string}
*/ */
function createChatBubble(my_user_id, item) function createChatBubble(my_user_id, item, appendType = 'append')
{ {
var myDiv = 'chatboxmessage_me'; var myDiv = 'chatboxmessage_me';
if (my_user_id == item.from_user_info.id) { if (my_user_id == item.from_user_info.id) {
@ -345,16 +336,29 @@ function createChatBubble(my_user_id, item)
} }
} }
var message = '<div id="message_id_'+item.id+'" class="boot-tooltip well '+myDiv+'" title="'+sentDate+'" >'; var messageObject = $("#chatbox_"+my_user_id+" .chatboxcontent").find('#message_id_' + item.id);
var exists = messageObject.length !== 0;
var messageHeader = '<div id="message_id_'+item.id+'" class="chatbox-common boot-tooltip well '+myDiv+'" title="'+sentDate+'" >';
var messageEnd = '</div>';
var message = '';
if (my_user_id == item.from_user_info.id) { if (my_user_id == item.from_user_info.id) {
message += '<span class="chatboxmessagefrom">'+item.from_user_info.complete_name+':&nbsp;&nbsp;</span>'; message += '<span class="chatboxmessagefrom">'+item.from_user_info.complete_name+':&nbsp;&nbsp;</span>';
} }
message += '<div class="chatboxmessagecontent">'+item.message+'</div>';
message += '<div class="chatbox_checks' + unCheckClass + '">'+check+'</div>';
message += if (exists) {
'<div class="chatboxmessagecontent">'+item.m+'</div>' + messageObject.html(message);
'<div class="chatbox_checks' + unCheckClass + '">'+check+'</div>' + } else {
'</div>'; message = messageHeader + message + messageEnd;
if (appendType == 'append') {
$("#chatbox_"+my_user_id+" .chatboxcontent").append(message);
} else {
$("#chatbox_"+my_user_id+" .chatboxcontent").prepend(message);
}
}
return message; return message;
} }
@ -746,20 +750,23 @@ function createChatBox(user_id, chatboxtitle, minimizeChatBox, online, userImage
*/ */
function getMoreItems(userId, scrollType) function getMoreItems(userId, scrollType)
{ {
var visibleMessages = $("#chatbox_"+userId+" .chatboxcontent").find('div').length; var visibleMessages = $("#chatbox_"+userId+" .chatboxcontent").find('.chatbox-common').length;
$.ajax({ $.ajax({
url: ajax_url+"?action=get_previous_messages&user_id="+userId+"&visible_messages="+visibleMessages, url: ajax_url+"?action=get_previous_messages&user_id="+userId+"&visible_messages="+visibleMessages,
cache: false, cache: false,
dataType: "json", dataType: "json",
success: function(items) { success: function(items) {
console.log(items);
items = items.reverse();
$.each(items, function(i, item) { $.each(items, function(i, item) {
console.log(i);
if (item) { if (item) {
if ($("#chatbox_"+userId).css('display') == 'none') { if ($("#chatbox_"+userId).css('display') == 'none') {
$("#chatbox_"+userId).css('display','block'); $("#chatbox_"+userId).css('display','block');
restructureChatBoxes(); restructureChatBoxes();
} }
var chatBubble = createChatBubble(userId, item); var chatBubble = createChatBubble(userId, item, 'prepend');
$("#chatbox_"+userId+" .chatboxcontent").prepend(chatBubble); //$("#chatbox_"+userId+" .chatboxcontent").prepend(chatBubble);
if ($('#chatbox_'+userId+' .chatboxcontent').css('display') == 'none') { if ($('#chatbox_'+userId+' .chatboxcontent').css('display') == 'none') {
$('#chatbox_'+userId+' .chatboxhead').toggleClass('chatboxblink'); $('#chatbox_'+userId+' .chatboxhead').toggleClass('chatboxblink');
@ -769,13 +776,12 @@ function getMoreItems(userId, scrollType)
var scrollValue = 10; var scrollValue = 10;
if (scrollType === 'last') { if (scrollType === 'last') {
// When loading for the first time show the last msg // When loading for the first time show the last msg
scrollValue = $("#chatbox_"+userId+" .chatboxcontent").height(); //scrollValue = $("#chatbox_"+userId+" .chatboxcontent").height();
} }
$("#chatbox_"+userId+" .chatboxcontent").scrollTop( /*$("#chatbox_"+userId+" .chatboxcontent").scrollTop(
scrollValue scrollValue
); );*/
} }
}); });
} }
@ -841,7 +847,7 @@ function toggleChatBoxGrowth(user_id)
Cookies.set('chatbox_minimized', newCookie); Cookies.set('chatbox_minimized', newCookie);
$('#chatbox_'+user_id+' .chatboxcontent').css('display','block'); $('#chatbox_'+user_id+' .chatboxcontent').css('display','block');
$('#chatbox_'+user_id+' .chatboxinput').css('display','block'); $('#chatbox_'+user_id+' .chatboxinput').css('display','block');
$("#chatbox_"+user_id+" .chatboxcontent").scrollTop($("#chatbox_"+user_id+" .chatboxcontent")[0].scrollHeight); //$("#chatbox_"+user_id+" .chatboxcontent").scrollTop($("#chatbox_"+user_id+" .chatboxcontent")[0].scrollHeight);
$('.togglelink').html('<em class="fa fa-toggle-down"></em>'); $('.togglelink').html('<em class="fa fa-toggle-down"></em>');
} else { } else {
// hide box // hide box
@ -917,11 +923,11 @@ function checkChatBoxInputKey(event, chatboxtextarea, user_id)
username: username, username: username,
date: moment().unix(), date: moment().unix(),
f: currentUserId, f: currentUserId,
m: message, message: message,
id: messageId id: messageId
}; };
var bubble = createChatBubble(user_id, item); var bubble = createChatBubble(user_id, item);
$("#chatbox_" + user_id + " .chatboxcontent").append(bubble); //$("#chatbox_" + user_id + " .chatboxcontent").append(bubble);
$("#chatbox_" + user_id + " .chatboxcontent").scrollTop( $("#chatbox_" + user_id + " .chatboxcontent").scrollTop(
$("#chatbox_" + user_id + " .chatboxcontent")[0].scrollHeight $("#chatbox_" + user_id + " .chatboxcontent")[0].scrollHeight
); );

@ -9176,6 +9176,60 @@ SQL;
return ['collapsed' => $collapsed, 'collapsable_link' => $link]; return ['collapsed' => $collapsed, 'collapsable_link' => $link];
} }
/**
* Converts "start date" and "end date" to "From start date to end date" string.
*
* @param string $startDate
* @param string $endDate
* @param bool $showTime
* @param bool $dateHuman
*
* @return string
*/
public static function convertSessionDateToString($startDate, $endDate, $showTime, $dateHuman)
{
// api_get_local_time returns empty if date is invalid like 0000-00-00 00:00:00
$startDateToLocal = api_get_local_time(
$startDate,
null,
null,
true,
$showTime,
$dateHuman
);
$endDateToLocal = api_get_local_time(
$endDate,
null,
null,
true,
$showTime,
$dateHuman
);
$format = $showTime ? DATE_TIME_FORMAT_LONG_24H : DATE_FORMAT_LONG_NO_DAY;
$result = '';
if (!empty($startDateToLocal) && !empty($endDateToLocal)) {
$result = sprintf(
get_lang('FromDateXToDateY'),
api_format_date($startDateToLocal, $format),
api_format_date($endDateToLocal, $format)
);
} else {
if (!empty($startDateToLocal)) {
$result = get_lang('From').' '.api_format_date($startDateToLocal, $format);
}
if (!empty($endDateToLocal)) {
$result = get_lang('Until').' '.api_format_date($endDateToLocal, $format);
}
}
if (empty($result)) {
$result = get_lang('NoTimeLimits');
}
return $result;
}
/** /**
* @param int $id * @param int $id
* *
@ -9242,58 +9296,6 @@ SQL;
} }
} }
/**
* Converts "start date" and "end date" to "From start date to end date" string.
*
* @param string $startDate
* @param string $endDate
* @param bool $showTime
* @param bool $dateHuman
*
* @return string
*/
private static function convertSessionDateToString($startDate, $endDate, $showTime, $dateHuman)
{
// api_get_local_time returns empty if date is invalid like 0000-00-00 00:00:00
$startDateToLocal = api_get_local_time(
$startDate,
null,
null,
true,
$showTime,
$dateHuman
);
$endDateToLocal = api_get_local_time(
$endDate,
null,
null,
true,
$showTime,
$dateHuman
);
$result = '';
if (!empty($startDateToLocal) && !empty($endDateToLocal)) {
$result = sprintf(
get_lang('FromDateXToDateY'),
api_format_date($startDateToLocal, DATE_TIME_FORMAT_LONG_24H),
api_format_date($endDateToLocal, DATE_TIME_FORMAT_LONG_24H)
);
} else {
if (!empty($startDateToLocal)) {
$result = get_lang('From').' '.api_format_date($startDateToLocal, DATE_TIME_FORMAT_LONG_24H);
}
if (!empty($endDateToLocal)) {
$result = get_lang('Until').' '.api_format_date($endDateToLocal, DATE_TIME_FORMAT_LONG_24H);
}
}
if (empty($result)) {
$result = get_lang('NoTimeLimits');
}
return $result;
}
/** /**
* @param array $listA * @param array $listA
* @param array $listB * @param array $listB

@ -188,8 +188,7 @@ class BuyCoursesPlugin extends Plugin
seller_address varchar(255) NOT NULL, seller_address varchar(255) NOT NULL,
seller_email varchar(255) NOT NULL, seller_email varchar(255) NOT NULL,
next_number_invoice int unsigned NOT NULL, next_number_invoice int unsigned NOT NULL,
invoice_series varchar(255) NOT NULL, invoice_series varchar(255) NOT NULL
sale_email varchar(255) NOT NULL
)"; )";
$res = Database::query($sql); $res = Database::query($sql);
if (!$res) { if (!$res) {

@ -113,6 +113,11 @@ class Basic extends Toolbar
} }
if (api_get_setting('enabled_wiris') == 'true') { if (api_get_setting('enabled_wiris') == 'true') {
// New version of wiris needs this plugins before it's loaded
$plugins[] = 'mapping';
$plugins[] = 'widgetselection';
$plugins[] = 'panelbutton';
// Commercial plugin // Commercial plugin
$plugins[] = 'ckeditor_wiris'; $plugins[] = 'ckeditor_wiris';
} }
@ -133,7 +138,8 @@ class Basic extends Toolbar
$plugins[] = 'scayt'; $plugins[] = 'scayt';
} }
$this->defaultPlugins = array_merge($this->defaultPlugins, $plugins); $this->defaultPlugins = array_unique(array_merge($this->defaultPlugins, $plugins));
parent::__construct($toolbar, $config, $prefix); parent::__construct($toolbar, $config, $prefix);
} }

@ -102,25 +102,26 @@ class CourseDriver extends Driver implements DriverInterface
'hidden' => true, 'hidden' => true,
'locked' => false, 'locked' => false,
], ],
[
'pattern' => '/^\/learning_path$/', // block delete learning_path
'read' => true,
'write' => false,
'hidden' => false,
'locked' => true,
],
[
'pattern' => '/learning_path\/(.*)/', // allow edit/delete inside learning_path
'read' => true,
'write' => true,
'hidden' => false,
'locked' => false,
],
], ],
]; ];
// admin/teachers can create dirs from ckeditor // admin/teachers can create dirs from ckeditor
if ($this->allowToEdit()) { if ($this->allowToEdit()) {
$config['attributes'][] = [
'pattern' => '/^\/learning_path$/', // block delete learning_path
'read' => true,
'write' => false,
'hidden' => false,
'locked' => true,
];
$config['attributes'][] = [
'pattern' => '/learning_path\/(.*)/', // allow edit/delete inside learning_path
'read' => true,
'write' => true,
'hidden' => false,
'locked' => false,
];
$defaultDisabled = $this->connector->getDefaultDriverSettings()['disabled']; $defaultDisabled = $this->connector->getDefaultDriverSettings()['disabled'];
$defaultDisabled = array_flip($defaultDisabled); $defaultDisabled = array_flip($defaultDisabled);
unset($defaultDisabled['mkdir']); unset($defaultDisabled['mkdir']);

Loading…
Cancel
Save