diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 48a4cf9c12..f0bee95d7c 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -185,7 +185,18 @@ class MessageManager $receiver_user_id = intval($receiver_user_id); $parent_id = intval($parent_id); $user_sender_id = api_get_user_id(); - + + $total_filesize = 0; + if (is_array($file_attachments)) { + foreach ($file_attachments as $file_attach) { + $total_filesize += $file_attach['size']; + } + } + + if ($total_filesize > intval(api_get_setting('message_max_upload_filesize'))) { + return sprintf(get_lang("FilesSizeExceedsX"),format_file_size(api_get_setting('message_max_upload_filesize'))); + } + if (!empty($receiver_user_id) || !empty($group_id)) { // message for user friend $title = api_convert_encoding($title,$charset); @@ -331,7 +342,6 @@ class MessageManager // user's file name $file_name =$file_attach['name']; - if (!filter_extension($new_file_name)) { Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); } else { diff --git a/main/install/dokeos_main.sql b/main/install/dokeos_main.sql index a4e229e6ec..186a4304af 100755 --- a/main/install/dokeos_main.sql +++ b/main/install/dokeos_main.sql @@ -744,7 +744,8 @@ VALUES ('students_download_folders',NULL,'radio','Tools','true','AllowStudentsDownloadFoldersTitle','AllowStudentsDownloadFoldersComment',NULL,NULL, 0), ('show_tabs', 'social', 'checkbox', 'Platform', 'true', 'ShowTabsTitle','ShowTabsComment',NULL,'TabsSocial', 0), ('allow_students_to_create_groups_in_social',NULL,'radio','Tools','false','AllowStudentsToCreateGroupsInSocialTitle','AllowStudentsToCreateGroupsInSocialComment',NULL,NULL, 0), -('allow_send_message_to_all_platform_users',NULL,'radio','Tools','false','AllowSendMessageToAllPlatformUsersTitle','AllowSendMessageToAllPlatformUsersComment',NULL,NULL, 0); +('allow_send_message_to_all_platform_users',NULL,'radio','Tools','false','AllowSendMessageToAllPlatformUsersTitle','AllowSendMessageToAllPlatformUsersComment',NULL,NULL, 0), +('message_max_upload_filesize',NULL,'textfield','Tools','20971520','MessageMaxUploadFilesizeTitle','MessageMaxUploadFilesizeComment',NULL,NULL, 0); UNLOCK TABLES; /*!40000 ALTER TABLE settings_current ENABLE KEYS */; diff --git a/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql b/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql index 9645b33476..562d2ab096 100755 --- a/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql +++ b/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql @@ -84,6 +84,7 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value, INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_send_message_to_all_platform_users', 'true', 'Yes'); INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_send_message_to_all_platform_users', 'false', 'No'); +INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('message_max_upload_filesize', NULL, 'textfield', 'Tools', '20971520', 'MessageMaxUploadFilesizeTitle','MessageMaxUploadFilesizeComment',NULL,NULL, 0); -- xxSTATSxx ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00'; diff --git a/main/lang/english/admin.inc.php b/main/lang/english/admin.inc.php old mode 100755 new mode 100644 index 4729ce0693..dc3220f9f6 --- a/main/lang/english/admin.inc.php +++ b/main/lang/english/admin.inc.php @@ -1121,4 +1121,5 @@ $AllowStudentsToCreateGroupsInSocialTitle = "Allow students to create groups in $AllowStudentsToCreateGroupsInSocialComment = "Allow students to create groups in social network"; $AllowSendMessageToAllPlatformUsersTitle = "Allow send message to all platform users"; $AllowSendMessageToAllPlatformUsersComment = "Allow send message to all platform users"; +$TabsSocial = "Tabs social"; ?> \ No newline at end of file diff --git a/main/lang/english/userInfo.inc.php b/main/lang/english/userInfo.inc.php old mode 100755 new mode 100644 index ce9a93d284..a78f449393 --- a/main/lang/english/userInfo.inc.php +++ b/main/lang/english/userInfo.inc.php @@ -121,7 +121,7 @@ $Members = "Members"; $Admin = "Administrator"; $AttachmentFiles = "Attachments"; $AddOneMoreFile = "Add one more file"; -$MaximunFileSizeXMB = "Maximun file size %s MB"; +$MaximunFileSizeX = "Maximun file size %s MB"; $ModifyInformation = "Modify information"; $GroupList = "Groups list"; $GroupEdit = "Edit group"; diff --git a/main/lang/spanish/admin.inc.php b/main/lang/spanish/admin.inc.php index 1dc1afaef2..47b85bf964 100644 --- a/main/lang/spanish/admin.inc.php +++ b/main/lang/spanish/admin.inc.php @@ -1121,5 +1121,5 @@ $AllowStudentsToCreateGroupsInSocialTitle = "Permitir a los alumnos de crear gru $AllowStudentsToCreateGroupsInSocialComment = "Permitir a los alumnos crear sus propios grupos en la red social"; $AllowSendMessageToAllPlatformUsersTitle = "Permitir enviar mensajes a todos los usuarios de la plataforma"; $AllowSendMessageToAllPlatformUsersComment = "Permite poder enviar mensajes a todos los usuarios de la plataforma"; -$TabsSocial = "Pestaña red social"; +$TabsSocial = "Pestaña Red social"; ?> \ No newline at end of file diff --git a/main/lang/spanish/userInfo.inc.php b/main/lang/spanish/userInfo.inc.php index ee028d7cf4..ab33d8462b 100644 --- a/main/lang/spanish/userInfo.inc.php +++ b/main/lang/spanish/userInfo.inc.php @@ -121,7 +121,7 @@ $Members = "Miembros"; $Admin = "Administrador"; $AttachmentFiles = "Adjuntar archivos"; $AddOneMoreFile = "Agregar otro fichero"; -$MaximunFileSizeXMB = "Tamaño máximo de archivo %s MB"; +$MaximunFileSizeX = "Tamaño máximo de archivo %s"; $ModifyInformation = "Modificar información"; $GroupList = "Lista de grupos"; $GroupEdit = "Editar grupo"; diff --git a/main/messages/new_message.php b/main/messages/new_message.php index 8c38db0890..5a3bb34934 100755 --- a/main/messages/new_message.php +++ b/main/messages/new_message.php @@ -69,23 +69,36 @@ $(document).ready(function (){ }); }); -var counter_image = 1; +var counter_image = 1; +/* function remove_image_form(id_elem1) { var elem1 = document.getElementById(id_elem1); - elem1.parentNode.removeChild(elem1); -} -function add_image_form() { - counter_image = counter_image + 1; + elem1.parentNode.removeChild(elem1); +} +*/ +function add_image_form() { // Multiple filepaths for image form - var filepaths = document.getElementById("filepaths"); + var filepaths = document.getElementById("filepaths"); + if (document.getElementById("filepath_"+counter_image)) { + counter_image = counter_image + 1; + } else { + counter_image = counter_image; + } var elem1 = document.createElement("div"); elem1.setAttribute("id","filepath_"+counter_image); filepaths.appendChild(elem1); id_elem1 = "filepath_"+counter_image; id_elem1 = "\'"+id_elem1+"\'"; - document.getElementById("filepath_"+counter_image).innerHTML = "  "; -} - + //document.getElementById("filepath_"+counter_image).innerHTML = " "; + document.getElementById("filepath_"+counter_image).innerHTML = " "; + if (filepaths.childNodes.length == 6) { + var link_attach = document.getElementById("link-more-attach"); + if (link_attach) { + link_attach.innerHTML=""; + } + } +} + '; $nameTools = get_lang('ComposeMessage'); @@ -190,7 +203,7 @@ function manage_form ($default, $select_from_user_list = null) { '); - $form->addElement('html','
'.get_lang('AddOneMoreFile').' ('.sprintf(get_lang('MaximunFileSizeXMB'),25).')
'); + $form->addElement('html','
'.get_lang('AddOneMoreFile').' ('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')
'); } $form->addElement('style_submit_button','compose',api_xml_http_response_encode(get_lang('SendMessage')),'class="save"'); @@ -212,8 +225,14 @@ function manage_form ($default, $select_from_user_list = null) { if (is_array($user_list) && count($user_list)> 0) { //all is well, send the message foreach ($user_list as $user) { - MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id); - MessageManager::display_success_message($user); + $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id); + if ($res) { + if (is_string($res)) { + Display::display_error_message($res); + } else { + MessageManager::display_success_message($user); + } + } } } } else { diff --git a/main/social/group_add.php b/main/social/group_add.php index 9b31fbf9c7..64a6b403f0 100755 --- a/main/social/group_add.php +++ b/main/social/group_add.php @@ -14,6 +14,9 @@ require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; api_block_anonymous_users(); +if (api_get_setting('allow_students_to_create_groups_in_social') == 'false' && !api_is_allowed_to_edit()) { + api_not_allowed(); +} global $charset; $table_message = Database::get_main_table(TABLE_MESSAGE); diff --git a/main/social/groups.php b/main/social/groups.php index 264d68e23d..44fcb3a9c4 100755 --- a/main/social/groups.php +++ b/main/social/groups.php @@ -28,7 +28,7 @@ function remove_image_form(id_elem1) { var elem1 = document.getElementById(id_elem1); elem1.parentNode.removeChild(elem1); counter_image--; - var filepaths = document.getElementById("filepaths"); + var filepaths = document.getElementById("filepaths"); if (filepaths.childNodes.length < 3) { var link_attach = document.getElementById("link-more-attach"); if (link_attach) { @@ -66,6 +66,12 @@ $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social')); $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Groups')); Display :: display_header($tool_name, 'Groups'); +//show the action menu +SocialManager::show_social_menu(); +echo '
'; +echo get_lang('Groups'); +echo '
'; + // save message group if (isset($_POST['token']) && $_POST['token'] == $_SESSION['sec_token']) { if (isset($_POST['action']) && $_POST['action']=='send_message_group') { @@ -73,19 +79,16 @@ if (isset($_POST['token']) && $_POST['token'] == $_SESSION['sec_token']) { $content = $_POST['content']; $group_id = $_POST['group_id']; $parent_id = $_POST['parent_id']; - MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id); + $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id); + if (is_string($res)) { + Display::display_error_message($res); + } Security::clear_token(); } } else { $tok = Security::get_token(); } -//show the action menu -SocialManager::show_social_menu(); -echo '
'; -echo get_lang('Groups'); -echo '
'; - // getting group information $group_id = intval($_GET['id']); diff --git a/main/social/message_for_group_form.inc.php b/main/social/message_for_group_form.inc.php index cd29b34747..9fee165bcd 100755 --- a/main/social/message_for_group_form.inc.php +++ b/main/social/message_for_group_form.inc.php @@ -65,7 +65,7 @@ if (!empty($group_id)) {
:
- +