From ca2cd707a6a20679252377398cd19b37c40936ba Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 18 Apr 2019 08:56:40 +0200 Subject: [PATCH] Updating from 1.11.x --- main/admin/user_edit.php | 5 +- main/messages/inbox.php | 81 ++--- main/messages/new_message.php | 94 ++++-- main/messages/outbox.php | 74 +++-- main/messages/view_message.php | 51 ++- main/mySpace/myStudents.php | 303 ++++++------------ main/social/groups.php | 6 +- main/social/message_for_group_form.inc.php | 2 +- main/social/profile.php | 6 +- main/social/search.php | 2 +- main/timeline/index.php | 2 + main/work/add_user.php | 2 +- main/work/upload.php | 2 +- main/work/upload_from_template.php | 3 +- main/work/work.lib.php | 48 ++- .../features/bootstrap/FeatureContext.php | 38 ++- tests/behat/features/toolLp.feature | 18 +- 17 files changed, 331 insertions(+), 406 deletions(-) diff --git a/main/admin/user_edit.php b/main/admin/user_edit.php index e6cad5166f..63088664fb 100755 --- a/main/admin/user_edit.php +++ b/main/admin/user_edit.php @@ -512,11 +512,11 @@ $actions = [ ), ]; -$actionBar = Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL, $actions)]); +$content = Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL, $actions)]); $bigImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG); $normalImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL); -$content = '
'; +$content .= '
'; $content .= '
'; // Display form $content .= $form->returnForm(); @@ -526,6 +526,5 @@ $content .= ''. + Display::return_icon('message_new.png', get_lang('ComposeMessage')).''; + $actions .= ''. + Display::return_icon('inbox.png', get_lang('Inbox')).''; + $actions .= ''. + Display::return_icon('outbox.png', get_lang('Outbox')).''; +} + +// LEFT CONTENT +$social_menu_block = ''; +if ($allowSocial) { + // Block Social Menu + $social_menu_block = SocialManager::show_social_menu('messages'); +} + +// Right content +$social_right_content = ''; +$keyword = ''; +if ($allowSocial) { $actionsLeft = ''. - Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).''; - $actionsLeft .= ''. - Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).''; + Display::return_icon('new-message.png', get_lang('ComposeMessage'), [], 32).''; $actionsLeft .= ''. - Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).''; + Display::return_icon('outbox.png', get_lang('Outbox'), [], 32).''; $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/inbox.php'); - try { if ($form->validate()) { $values = $form->getSubmitValues(); $keyword = $values['keyword']; } - } catch (HTML_QuickForm_Error $e) { - echo $e->getMessage(); - } - $actionsRight = $form->returnForm(); - $actions = Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]); + $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]); } -// SOCIAL MENU -/*$social_menu_block = ''; -if ($allowSocial) { - // Block Social Menu - $social_menu_block = SocialManager::show_social_menu('messages'); -}*/ - -// Right content -$message_content = ''; - -//MAIN CONTENT - if (!isset($_GET['del_msg'])) { - $message_content .= MessageManager::inbox_display($keyword); + $social_right_content .= MessageManager::inbox_display($keyword); } else { $num_msg = (int) $_POST['total']; for ($i = 0; $i < $num_msg; $i++) { @@ -165,20 +164,24 @@ if (!isset($_GET['del_msg'])) { ); } } - $message_content .= MessageManager::inbox_display(); + $social_right_content .= MessageManager::inbox_display(); } -$tpl = new Template($nameTools); +$tpl = new Template(null); if ($actions) { - $tpl->assign('actions', $actions); + $tpl->assign('actions', Display::toolbarAction('toolbar', [$actions])); } // Block Social Avatar -// SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); - -$tpl->assign('content_inbox', $message_content); -$social_layout = $tpl->get_template('message/inbox.html.twig'); -$content = $tpl->fetch($social_layout); -$tpl->assign('message', $show_message); -$tpl->assign('content', $content); -$tpl->display_one_col_template(); +SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); +if (api_get_setting('allow_social_tool') == 'true') { + $tpl->assign('social_menu_block', $social_menu_block); + $tpl->assign('social_right_content', $social_right_content); + $social_layout = $tpl->get_template('social/inbox.tpl'); + $tpl->display($social_layout); +} else { + $content = $social_right_content; + $tpl->assign('message', $show_message); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); +} diff --git a/main/messages/new_message.php b/main/messages/new_message.php index 9739f3d527..f07beba367 100755 --- a/main/messages/new_message.php +++ b/main/messages/new_message.php @@ -60,7 +60,7 @@ function add_image_form() { '; $nameTools = get_lang('ComposeMessage'); -$tpl = new Template($nameTools); +$tpl = new Template(get_lang('ComposeMessage')); /** * Shows the compose area + a list of users to select from. @@ -347,36 +347,57 @@ $interbreadcrumb[] = [ ]; $group_id = isset($_REQUEST['group_id']) ? (int) $_REQUEST['group_id'] : 0; -$message_content = null; -$actions = null; +$social_right_content = null; if ($group_id != 0) { - $actions .= ''. - Display::return_icon('back.png', api_xml_http_response_encode(get_lang('ComposeMessage')), null, ICON_SIZE_MEDIUM).''; - $actions .= ''. - Display::return_icon('message_new.png', api_xml_http_response_encode(get_lang('ComposeMessage')), null, ICON_SIZE_MEDIUM).''; + $social_right_content .= ''; } else { - $actions .= ''. - Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM).''; - if (api_get_setting('allow_message_tool') === 'true') { - $actions .= ''. - Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).''; - $actions .= ''. - Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).''; - } + if ($allowSocial) { + } else { + $social_right_content .= '
'; + if (api_get_setting('allow_message_tool') === 'true') { + $social_right_content .= ''. + Display::return_icon('message_new.png', get_lang('ComposeMessage')).''; + $social_right_content .= ''. + Display::return_icon('inbox.png', get_lang('Inbox')).''; + $social_right_content .= ''. + Display::return_icon('outbox.png', get_lang('Outbox')).''; + } + $social_right_content .= '
'; +} } -$show_message = null; + +// LEFT COLUMN +$social_left_content = ''; +if ($allowSocial) { + // Block Social Menu + $social_menu_block = SocialManager::show_social_menu('messages'); + $social_right_content .= '
'; + $social_right_content .= '
'; + $social_right_content .= '
'; + $social_right_content .= ''. + Display::return_icon('back.png', get_lang('Back'), [], 32).''; + $social_right_content .= '
'; + $social_right_content .= '
'; + $social_right_content .= '
'; +} + // MAIN CONTENT if (!isset($_POST['compose'])) { if (isset($_GET['re_id'])) { - $message_content .= show_compose_reply_to_message( + $social_right_content .= show_compose_reply_to_message( $_GET['re_id'], api_get_user_id(), $tpl ); } elseif (isset($_GET['send_to_user'])) { - $message_content .= show_compose_to_user($_GET['send_to_user'], $tpl); + $social_right_content .= show_compose_to_user($_GET['send_to_user'], $tpl); } else { - $message_content .= show_compose_to_any($tpl); + $social_right_content .= show_compose_to_any($tpl); } } else { $restrict = false; @@ -393,7 +414,7 @@ if (!isset($_POST['compose'])) { // comes from a reply button if (isset($_GET['re_id']) || isset($_GET['forward_id'])) { - $message_content .= manageForm($default, null, null, $tpl); + $social_right_content .= manageForm($default, null, null, $tpl); } else { // post if ($restrict) { @@ -405,24 +426,29 @@ if (!isset($_POST['compose'])) { if (isset($_POST['hidden_user'])) { $default['users'] = [$_POST['hidden_user']]; } - $message_content .= manageForm($default, null, null, $tpl); + $social_right_content .= manageForm($default, null, null, $tpl); } else { - $show_message = Display::return_message(get_lang('ErrorSendingMessage'), 'error'); + $social_right_content .= Display::return_message(get_lang('ErrorSendingMessage'), 'error'); } } } -MessageManager::cleanAudioMessage(); +if ($allowSocial) { + $social_right_content .= '
'; + $social_right_content .= '
'; +} -if ($actions) { - $tpl->assign( - 'actions', - Display::toolbarAction('toolbar', [$actions]) - ); +// Block Social Avatar +SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); + +MessageManager::cleanAudioMessage(); +if ($allowSocial) { + $tpl->assign('social_menu_block', $social_menu_block); + $tpl->assign('social_right_content', $social_right_content); + $social_layout = $tpl->get_template('social/inbox.tpl'); + $tpl->display($social_layout); +} else { + $content = $social_right_content; + $tpl->assign('content', $content); + $tpl->display_one_col_template(); } -$tpl->assign('message', $show_message); -$tpl->assign('content_inbox', $message_content); -$social_layout = $tpl->get_template('message/inbox.html.twig'); -$content = $tpl->fetch($social_layout); -$tpl->assign('content', $content); -$tpl->display_one_col_template(); diff --git a/main/messages/outbox.php b/main/messages/outbox.php index ca50755fb4..718bdb7949 100755 --- a/main/messages/outbox.php +++ b/main/messages/outbox.php @@ -48,39 +48,40 @@ $interbreadcrumb[] = [ 'name' => get_lang('Messages'), ]; -$actions = null; +$actions = ''; if ($allowMessage) { - $actionsLeft = ''. - Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM).''; - $actionsLeft .= ''. - Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).''; - $actionsLeft .= ''. - Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).''; - $actionsLeft .= ''. - Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).''; - - $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php'); - if ($form->validate()) { - $values = $form->getSubmitValues(); - $keyword = $values['keyword']; - } - $actionsRight = $form->returnForm(); + $actions .= ''. + Display::return_icon('message_new.png', get_lang('ComposeMessage')).''; + $actions .= ''. + Display::return_icon('inbox.png', get_lang('Inbox')).''; + $actions .= ''. + Display::return_icon('outbox.png', get_lang('Outbox')).''; } $action = null; - if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } $keyword = ''; -$message_content = null; +$social_right_content = ''; +if ($allowSocial) { -$actions .= Display::toolbarAction( + $social_menu_block = SocialManager::show_social_menu('messages'); + $actionsLeft = ''. + Display::return_icon('back.png', get_lang('Back'), [], 32).''; + + $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php'); + if ($form->validate()) { + $values = $form->getSubmitValues(); + $keyword = $values['keyword']; + } + $actionsRight = $form->returnForm(); + $social_right_content .= Display::toolbarAction( 'toolbar', [$actionsLeft, $actionsRight] ); - +} //MAIN CONTENT if ($action == 'delete') { $delete_list_id = []; @@ -91,33 +92,40 @@ if ($action == 'delete') { $delete_list_id = $_POST['id']; } for ($i = 0; $i < count($delete_list_id); $i++) { - $show_message .= MessageManager::delete_message_by_user_sender( + MessageManager::delete_message_by_user_sender( api_get_user_id(), $delete_list_id[$i] ); } $delete_list_id = []; - $message_content .= MessageManager::outbox_display($keyword); + $social_right_content .= MessageManager::outbox_display($keyword); } elseif ($action == 'deleteone') { $delete_list_id = []; $id = Security::remove_XSS($_GET['id']); MessageManager::delete_message_by_user_sender(api_get_user_id(), $id); $delete_list_id = []; - $message_content .= MessageManager::outbox_display($keyword); + $social_right_content .= MessageManager::outbox_display($keyword); } else { - $message_content .= MessageManager::outbox_display($keyword); + $social_right_content .= MessageManager::outbox_display($keyword); } $tpl = new Template(get_lang('Outbox')); // Block Social Avatar +SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); -if ($actions) { - $tpl->assign('actions', $actions); +if ($allowSocial) { + $tpl->assign('social_menu_block', $social_menu_block); + $tpl->assign('social_right_content', $social_right_content); + $social_layout = $tpl->get_template('social/inbox.tpl'); + $tpl->display($social_layout); +} else { + $content = $social_right_content; + if ($actions) { + $tpl->assign( + 'actions', + Display::toolbarAction('toolbar', [$actions]) + ); + } + $tpl->assign('content', $content); + $tpl->display_one_col_template(); } - -$tpl->assign('content_inbox', $message_content); -$social_layout = $tpl->get_template('message/inbox.html.twig'); -$content = $tpl->fetch($social_layout); -$tpl->assign('message', $show_message); -$tpl->assign('content', $content); -$tpl->display_one_col_template(); diff --git a/main/messages/view_message.php b/main/messages/view_message.php index 7d63181306..eb6b3526f8 100755 --- a/main/messages/view_message.php +++ b/main/messages/view_message.php @@ -24,33 +24,16 @@ if ($allowSocial) { } $interbreadcrumb[] = ['url' => 'inbox.php', 'name' => get_lang('Messages')]; +$social_right_content = '
'; if (api_get_setting('allow_message_tool') === 'true') { - $actionLeft = Display::url( - Display::return_icon( - 'new-message.png', - get_lang('ComposeMessage') - ), - api_get_path(WEB_PATH).'main/messages/new_message.php' - ); - - $actionLeft .= Display::url( - Display::return_icon( - 'inbox.png', - get_lang('Inbox') - ), - api_get_path(WEB_PATH).'main/messages/inbox.php' - ); - - $actionLeft .= Display::url( - Display::return_icon( - 'outbox.png', - get_lang('Outbox') - ), - api_get_path(WEB_PATH).'main/messages/outbox.php' - ); - - $toolbar = Display::toolbarAction('inbox', [0 => $actionLeft]); + $social_right_content .= ''. + Display::return_icon('new-message.png', get_lang('ComposeMessage')).''; + $social_right_content .= ''. + Display::return_icon('inbox.png', get_lang('Inbox')).''; + $social_right_content .= ''. + Display::return_icon('outbox.png', get_lang('Outbox')).''; } +$social_right_content .= '
'; if (empty($_GET['id'])) { $messageId = $_GET['id_send']; @@ -74,26 +57,30 @@ $logInfo = [ Event::registerLog($logInfo); // MAIN CONTENT -$message = MessageManager::showMessageBox($messageId, $source); -$messageContent = ''; +if (api_get_setting('allow_social_tool') === 'true') { + // Block Social Menu + $social_menu_block = SocialManager::show_social_menu($show_menu); +} +// MAIN CONTENT +$message .= MessageManager::showMessageBox($messageId, $source); if (!empty($message)) { - $messageContent = $message; + $social_right_content .= $message; } else { api_not_allowed(true); } - $tpl = new Template(get_lang('View')); // Block Social Avatar SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu); if (api_get_setting('allow_social_tool') === 'true') { - $tpl->assign('actions', $toolbar); - $tpl->assign('message', $messageContent); - $social_layout = $tpl->get_template('message/view_message.html.twig'); + $tpl->assign('social_menu_block', $social_menu_block); + $tpl->assign('social_right_content', $social_right_content); + $social_layout = $tpl->get_template('social/inbox.tpl'); $tpl->display($social_layout); } else { $content = $social_right_content; + $tpl->assign('content', $content); $tpl->display_one_col_template(); } diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index d268170d5c..eb8e2be05e 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -13,6 +13,7 @@ use ChamiloSession as Session; require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); +$htmlHeadXtra[] = ''; $export = isset($_GET['export']) ? $_GET['export'] : false; $sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0; @@ -267,6 +268,7 @@ switch ($action) { $table->setCellContents(1, 4, $last); $courseTable = ''; + if (!empty($courses)) { $courseTable .= ''; $courseTable .= ''; @@ -851,9 +853,7 @@ $csv_content[] = [ $coachs_name = ''; $session_name = ''; -$table_title = Display::return_icon('user.png', get_lang('User')).$user_info['complete_name']; -echo Display::page_subheader($table_title); $userPicture = UserManager::getUserPicture($user_info['user_id'], USER_IMAGE_SIZE_BIG); $userGroupManager = new UserGroup(); @@ -879,56 +879,8 @@ $userInfo = [ 'online' => $online, ]; -?> -
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- '.$user_info['email'].'' - : get_lang('NoEmail'); - ?> -
- 'btn btn-default'] - ); ?> -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 'btn btn-danger btn-xs'] + ['class' => 'btn btn-danger'] ); + $timeLegalAccept = api_get_local_time($legalTime); } else { - $icon .= ' '.Display::url( + $btn = Display::url( get_lang('SendLegal'), api_get_self().'?action=send_legal&student='.$student_id.'&course='.$course_code, - ['class' => 'btn btn-primary btn-xs'] + ['class' => 'btn btn-primary'] ); + $timeLegalAccept = get_lang('NotRegistered'); } - echo ' - '; } + $userInfo['legal'] = [ + 'icon' => $icon, + 'datetime' => $timeLegalAccept, + 'url_send' => $btn, + ]; } + +$details = false; + +if (!empty($courseInfo)) { + $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $sessionId); + $messages = Tracking::count_student_messages($student_id, $course_code, $sessionId); + $links = Tracking::count_student_visited_links($student_id, $courseInfo['real_id'], $sessionId); + $chat_last_connection = Tracking::chat_last_connection($student_id, $courseInfo['real_id'], $sessionId); + $documents = Tracking::count_student_downloaded_documents($student_id, $courseInfo['real_id'], $sessionId); + $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $sessionId); + + $userInfo['tools'] = [ + 'tasks' => $nb_assignments, + 'messages' => $messages, + 'links' => $links, + 'chat_connection' => $chat_last_connection, + 'documents' => $documents, + 'upload_documents' => $uploaded_documents, + ]; +} else { + $details = true; +} + +$tpl = new Template('', + false, + false, + false, + false, + false, + false); +$tpl->assign('user', $userInfo); +$tpl->assign('details', $details); +$templateName = $tpl->get_template('my_space/user_details.tpl'); +$content = $tpl->fetch($templateName); + +echo $content; + +$allowAll = api_get_configuration_value('allow_teacher_access_student_skills'); +if ($allowAll) { + // Show all skills + echo Tracking::displayUserSkills( + $user_info['user_id'], + 0, + 0, + true + ); +} else { + // Default behaviour - Show all skills depending the course and session id + echo Tracking::displayUserSkills( + $user_info['user_id'], + $courseInfo ? $courseInfo['real_id'] : 0, + $sessionId + ); +} +echo '

'; + ?> - -
- 'absmiddle', 'hspace' => '3px'] - ); ?> -
- 'absmiddle', 'hspace' => '3px'] - ); ?> - - -
'; - echo get_lang('LegalAccepted').' '.$icon; - echo '
+
+ +
+ + + @@ -1083,19 +1048,6 @@ $userInfo = [ assign('user', $userInfo); -$templateName = $tpl->get_template('my_space/user_details.tpl'); -$content = $tpl->fetch($templateName); - $exportCourseList = []; $lpIdList = []; if (empty($details)) { @@ -1423,7 +1375,7 @@ if (empty($details)) { if ($user_info['status'] != INVITEE) { $csv_content[] = []; - $csv_content[] = [str_replace(' ', '', strip_tags($table_title))]; + $csv_content[] = [str_replace(' ', '', strip_tags($userInfo['complete_name']))]; $trackingColumns = api_get_configuration_value('tracking_columns'); if (isset($trackingColumns['my_students_lp'])) { foreach ($columnHeaders as $key => $value) { @@ -1969,22 +1921,7 @@ if (empty($details)) { '; - echo '
-
- - - - - - - '; $csv_content[] = []; - $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $sessionId); - $messages = Tracking::count_student_messages($student_id, $course_code, $sessionId); - $links = Tracking::count_student_visited_links($student_id, $courseInfo['real_id'], $sessionId); - $chat_last_connection = Tracking::chat_last_connection($student_id, $courseInfo['real_id'], $sessionId); - $documents = Tracking::count_student_downloaded_documents($student_id, $courseInfo['real_id'], $sessionId); - $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $sessionId); $csv_content[] = [ get_lang('OtherTools'), @@ -2013,53 +1950,7 @@ if (empty($details)) { $csv_content[] = [ get_lang('ChatLastConnection'), $chat_last_connection, - ]; ?> - - - - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('OtherTools').'
-
- setHelp('Groups'); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_right_content', $social_right_content); -$social_layout = $tpl->get_template('social/groups.html.twig'); -$content = $tpl->fetch($social_layout); -$tpl->assign('content', $content); -$tpl->display_one_col_template(); +$social_layout = $tpl->get_template($templateName); +$tpl->display($social_layout); diff --git a/main/social/message_for_group_form.inc.php b/main/social/message_for_group_form.inc.php index 44a65a9ede..8f2323e5df 100755 --- a/main/social/message_for_group_form.inc.php +++ b/main/social/message_for_group_form.inc.php @@ -114,4 +114,4 @@ if (api_get_setting('allow_message_tool') === 'true') { $tpl->assign('content', $form->returnForm()); } -$tpl->display_one_col_template(); +$tpl->displayBlankTemplateNoHeader(); diff --git a/main/social/profile.php b/main/social/profile.php index 3685f946e3..0ca3c237ae 100755 --- a/main/social/profile.php +++ b/main/social/profile.php @@ -394,12 +394,10 @@ $tpl->assign('social_right_information', $socialRightInformation); $tpl->assign('social_auto_extend_link', $socialAutoExtendLink); $formModalTpl = new Template(); -$formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form('send_invitation')); +$formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form()); $template = $formModalTpl->get_template('social/form_modals.tpl'); $formModals = $formModalTpl->fetch($template); $tpl->assign('form_modals', $formModals); $social_layout = $tpl->get_template('social/profile.tpl'); -$content = $tpl->fetch($social_layout); -$tpl->assign('content', $content); -$tpl->display_one_col_template(); +$tpl->display($social_layout); diff --git a/main/social/search.php b/main/social/search.php index 89c1cb3baf..3b10cb4731 100755 --- a/main/social/search.php +++ b/main/social/search.php @@ -247,7 +247,7 @@ $tpl->assign('social_search', $block_search); $tpl->assign('search_form', $searchForm); $formModalTpl = new Template(); -$formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form('send_invitation')); +$formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form()); $template = $formModalTpl->get_template('social/form_modals.tpl'); $formModals = $formModalTpl->fetch($template); diff --git a/main/timeline/index.php b/main/timeline/index.php index d69bb3c9db..399259f5e5 100755 --- a/main/timeline/index.php +++ b/main/timeline/index.php @@ -20,6 +20,8 @@ $action = isset($_GET['action']) ? $_GET['action'] : null; $check = Security::check_token('request'); $token = Security::get_token(); +$actions = ''; +$message = ''; switch ($action) { case 'add': diff --git a/main/work/add_user.php b/main/work/add_user.php index a87cd78199..ecba32ae50 100755 --- a/main/work/add_user.php +++ b/main/work/add_user.php @@ -115,7 +115,7 @@ if (!empty($userToAddList)) { $url, ['class' => 'btn btn-primary btn-sm'] ); - echo '
  • '.$userName.'
    '.$link.'
  • '; + echo '
  • '.$userName.'
    '.$link.'
  • '; } echo ''; } else { diff --git a/main/work/upload.php b/main/work/upload.php index 2a679d27ff..e1d6d0f79e 100755 --- a/main/work/upload.php +++ b/main/work/upload.php @@ -11,7 +11,7 @@ require_once 'work.lib.php'; $this_section = SECTION_COURSES; -$work_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null; +$work_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null; $is_allowed_to_edit = api_is_allowed_to_edit(); $course_id = api_get_course_int_id(); diff --git a/main/work/upload_from_template.php b/main/work/upload_from_template.php index 9012e291bd..b7b8aa31e9 100755 --- a/main/work/upload_from_template.php +++ b/main/work/upload_from_template.php @@ -22,6 +22,7 @@ $session_id = api_get_session_id(); $course_info = api_get_course_info(); $course_code = $course_info['code']; $group_id = api_get_group_id(); +$sessionId = api_get_session_id(); if (empty($work_id)) { api_not_allowed(true); @@ -92,7 +93,7 @@ if ($form->validate()) { $workInfo, $values, $course_info, - $id_session, + $sessionId, $group_id, $user_id, [], diff --git a/main/work/work.lib.php b/main/work/work.lib.php index f82d0496b8..d02f333955 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -3743,21 +3743,23 @@ function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo * * @param int $workId * @param array $courseInfo - * @param int $session_id + * @param int $sessionId */ -function sendAlertToUsers($workId, $courseInfo, $session_id) +function sendAlertToUsers($workId, $courseInfo, $sessionId) { - $user_list = []; - $workData = get_work_data_by_id($workId, $courseInfo['real_id'], $session_id); + $sessionId = (int) $sessionId; + + $workData = get_work_data_by_id($workId, $courseInfo['real_id'], $sessionId); // last value is to check this is not "just" an edit // YW Tis part serve to send a e-mail to the tutors when a new file is sent $send = api_get_course_setting('email_alert_manager_on_new_doc'); + $userList = []; if ($send == SEND_EMAIL_EVERYONE || $send == SEND_EMAIL_TEACHERS) { // Lets predefine some variables. Be sure to change the from address! - if (empty($session_id)) { + if (empty($sessionId)) { //Teachers - $user_list = CourseManager::get_user_list_from_course_code( + $userList = CourseManager::get_user_list_from_course_code( api_get_course_id(), null, null, @@ -3766,9 +3768,9 @@ function sendAlertToUsers($workId, $courseInfo, $session_id) ); } else { // Coaches - $user_list = CourseManager::get_user_list_from_course_code( + $userList = CourseManager::get_user_list_from_course_code( api_get_course_id(), - $session_id, + $sessionId, null, null, 2 @@ -3777,34 +3779,22 @@ function sendAlertToUsers($workId, $courseInfo, $session_id) } if ($send == SEND_EMAIL_EVERYONE || $send == SEND_EMAIL_STUDENTS) { - if (!$session_id) { - $session_id = null; - } - $student = CourseManager::get_user_list_from_course_code( - api_get_course_id(), - $session_id, - null, - null, - STUDENT, - null, - null, - null, - null, - null, - [api_get_user_id()] - ); - $user_list = array_merge($user_list, $student); + // Send mail only to sender + $studentList = [[ + 'user_id' => api_get_user_id(), + ]]; + $userList = array_merge($userList, $studentList); } if ($send) { $subject = "[".api_get_setting('siteName')."] ".get_lang('SendMailBody')."\n ".get_lang('CourseName').": ".$courseInfo['name']." "; - foreach ($user_list as $user_data) { + foreach ($userList as $user_data) { $to_user_id = $user_data['user_id']; $user_info = api_get_user_info($to_user_id); $message = get_lang('SendMailBody')."\n".get_lang('CourseName')." : ".$courseInfo['name']."\n"; $message .= get_lang('UserName')." : ".$user_info['complete_name']."\n"; $message .= get_lang('DateSent')." : ".api_format_date(api_get_local_time())."\n"; - $url = api_get_path(WEB_CODE_PATH)."work/work.php?cidReq=".$courseInfo['code']."&id_session=".$session_id."&id=".$workData['id']; + $url = api_get_path(WEB_CODE_PATH)."work/work.php?cidReq=".$courseInfo['code']."&id_session=".$sessionId."&id=".$workData['id']; $message .= get_lang('WorkName')." : ".$workData['title']."\n\n".''.get_lang('DownloadLink')."\n"; MessageManager::send_message_simple( $to_user_id, @@ -3978,12 +3968,13 @@ function processWorkForm( } if (array_key_exists('document_id', $workInfo)) { - $documentId = isset($values['document_id']) ? intval($values['document_id']) : 0; + $documentId = isset($values['document_id']) ? (int) $values['document_id'] : 0; $sql = "UPDATE $work_table SET document_id = '$documentId' WHERE iid = $workId"; Database::query($sql); } + api_item_property_update( $courseInfo, 'work', @@ -4037,6 +4028,7 @@ function processWorkForm( $courseId, $sessionId ); + if (count($userWorks) == 1) { // The student only uploaded one doc so far, so add the // considered work time to his course connection time diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 1b485e30f7..bd7174b29c 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -132,16 +132,22 @@ class FeatureContext extends MinkContext $friendId = $friendId; $friendUsername = $friendUsername; - $sendInvitationURL = '/main/inc/ajax/message.ajax.php?' . http_build_query([ + $sendInvitationURL = '/main/inc/ajax/message.ajax.php?'. + http_build_query( + [ 'a' => 'send_invitation', 'user_id' => $friendId, - 'content' => 'Add me' - ]); - $acceptInvitationURL = '/main/inc/ajax/social.ajax.php?' . http_build_query([ + 'content' => 'Add me', + ] + ); + $acceptInvitationURL = '/main/inc/ajax/social.ajax.php?'. + http_build_query( + [ 'a' => 'add_friend', 'friend_id' => $adminId, - 'is_my_friend' => 'friend' - ]); + 'is_my_friend' => 'friend', + ] + ); $this->iAmAPlatformAdministrator(); $this->visit($sendInvitationURL); @@ -156,11 +162,15 @@ class FeatureContext extends MinkContext public function iHaveAPublicPasswordProtectedCourse($code, $password) { $this->visit('/main/admin/course_add.php'); - $this->fillFields(new TableNode([ + $this->fillFields( + new TableNode( + [ ['title', 'Password Protected'], ['visual_code', $code], - ['visibility', 3] - ])); + ['visibility', 3], + ] + ) + ); $this->pressButton('submit'); $this->visit('/main/course_info/infocours.php?cidReq=' . $code); $this->assertPageContainsText('Course registration password'); @@ -230,11 +240,15 @@ class FeatureContext extends MinkContext */ public function iTryDeleteAFriendFromSocialGroup($friendId, $groupId) { - $this->visit('/main/social/group_members.php?' . http_build_query([ + $this->visit( + '/main/social/group_members.php?'.http_build_query( + [ 'id' => $groupId, 'u' => $friendId, - 'action' => 'delete' - ])); + 'action' => 'delete', + ] + ) + ); } /** diff --git a/tests/behat/features/toolLp.feature b/tests/behat/features/toolLp.feature index 8e0c59fd9a..b312b60a76 100644 --- a/tests/behat/features/toolLp.feature +++ b/tests/behat/features/toolLp.feature @@ -48,11 +48,9 @@ Feature: LP tool Then I should see "LP 1" And I should see "Document 1" And I should see "Exercise 1" + And I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list" + Then I should see "LP 1" - Scenario: Delete a LP category - Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list" - And I follow "Delete" - Then I should not see "LP category 1" # Scenario: Check the PDF export in LP list if hide SCORM PDF link is false # Given I am on "/main/admin/settings.php?category=Course" @@ -67,9 +65,19 @@ Feature: LP tool # And I press "Save settings" # And I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=true" # Then I should not see an icon with title "Export to PDF" + Scenario: LP exists and LP category exists + And I am on "/main/lp/lp_controller.php?cidReq=TEMP&id_session=0&gidReq=0&gradebook=0&origin=" + Then I should see "LP 1" + And I should see "LP category 1" Scenario: Delete a LP - Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list" + Given I am on "/main/lp/lp_controller.php?cidReq=TEMP" And I follow "Delete" And I confirm the popup Then I should not see "LP 1" + + Scenario: Delete a LP category + Given I am on "/main/lp/lp_controller.php?cidReq=TEMP" + Then I should see "LP category 1" + And I follow "Delete" + Then I should see "Deleted"