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);
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') {
// 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";
$result = Database::query($sql);
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.
@ -4553,29 +4555,35 @@ function handle_mail_cue($content, $id)
* @param array
* @param array
* @param array
* @param array
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @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();
$user_id = api_get_user_id();
$thread_link = '';
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('NewForumPost')."\n";
$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').': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$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";
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";
}
$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";
}
if ($user_info['user_id'] != $user_id) {
if ($userInfo['user_id'] != $user_id) {
MessageManager::send_message(
$user_info['user_id'],
$userInfo['user_id'],
$subject,
$email_body,
[],
@ -5761,26 +5769,12 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
// Merging the two
$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)) {
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']);
send_mail($userInfo, $current_thread, $postInfo);
send_mail($userInfo, $forumInfo, $current_thread, $postInfo);
}
}
}

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

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

@ -103,16 +103,23 @@ switch ($action) {
break;
case 'get_previous_messages':
$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)) {
return '';
}
$items = $chat->getPreviousMessages(
$userId,
$currentUserId,
$visibleMessages
);
echo json_encode($items);
if (!empty($items)) {
sort($items);
echo json_encode($items);
exit;
}
echo json_encode([]);
exit;
break;
case 'notify_not_support':

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

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

@ -717,7 +717,7 @@ class DocumentManager
) {
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$groupIid = intval($groupIid);
$groupIid = (int) $groupIid;
$document_folders = [];
$students = CourseManager::get_user_list_from_course_code(
@ -734,7 +734,7 @@ class DocumentManager
$groupCondition = " last.to_group_id = $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 = '';
@ -821,7 +821,7 @@ class DocumentManager
$condition_session = api_get_session_condition(
$session_id,
true,
false,
true, // needed to don't show files in elfinder browser
'docs.session_id'
);

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

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

@ -9176,6 +9176,60 @@ SQL;
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
*
@ -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 $listB

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

@ -113,6 +113,11 @@ class Basic extends Toolbar
}
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
$plugins[] = 'ckeditor_wiris';
}
@ -133,7 +138,8 @@ class Basic extends Toolbar
$plugins[] = 'scayt';
}
$this->defaultPlugins = array_merge($this->defaultPlugins, $plugins);
$this->defaultPlugins = array_unique(array_merge($this->defaultPlugins, $plugins));
parent::__construct($toolbar, $config, $prefix);
}

@ -102,25 +102,26 @@ class CourseDriver extends Driver implements DriverInterface
'hidden' => true,
'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
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 = array_flip($defaultDisabled);
unset($defaultDisabled['mkdir']);

Loading…
Cancel
Save