diff --git a/public/main/inc/ajax/social.ajax.php b/public/main/inc/ajax/social.ajax.php index a7f3b2968f..e4ce20ae07 100644 --- a/public/main/inc/ajax/social.ajax.php +++ b/public/main/inc/ajax/social.ajax.php @@ -195,67 +195,6 @@ switch ($action) { break; } break; - case 'send_comment': - if (api_is_anonymous()) { - exit; - } - - if ('true' !== api_get_setting('allow_social_tool')) { - exit; - } - - $messageId = isset($_GET['id']) ? (int) $_GET['id'] : 0; - - if (empty($messageId)) { - exit; - } - - $userId = api_get_user_id(); - $messageInfo = MessageManager::get_message_by_id($messageId); - if (!empty($messageInfo)) { - $comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : ''; - if (!empty($comment)) { - $messageId = SocialManager::sendWallMessage( - $userId, - $messageInfo['user_receiver_id'], - $comment, - $messageId, - MESSAGE_STATUS_WALL - ); - if ($messageId) { - $messageInfo = MessageManager::get_message_by_id($messageId); - echo SocialManager::processPostComment($messageInfo); - } - } - } - break; - case 'delete_message': - if (api_is_anonymous()) { - exit; - } - - if ('true' !== api_get_setting('allow_social_tool')) { - exit; - } - - $messageId = isset($_GET['id']) ? (int) $_GET['id'] : 0; - - if (empty($messageId)) { - exit; - } - - $userId = api_get_user_id(); - $messageInfo = MessageManager::get_message_by_id($messageId); - if (!empty($messageInfo)) { - $canDelete = ($messageInfo['user_receiver_id'] == $userId || $messageInfo['user_sender_id'] == $userId) && - empty($messageInfo['group_id']); - if ($canDelete || api_is_platform_admin()) { - SocialManager::deleteMessage($messageId); - echo Display::return_message(get_lang('The message has been deleted')); - break; - } - } - break; case 'list_wall_message': if (api_is_anonymous()) { break; diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index 257040176e..27f9eaa936 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -563,13 +563,18 @@ define('MESSAGE_STATUS_UNREAD', 1); //2 ?? define('MESSAGE_STATUS_DELETED', 3); define('MESSAGE_STATUS_OUTBOX', 4); + define('MESSAGE_STATUS_INVITATION_PENDING', 5); define('MESSAGE_STATUS_INVITATION_ACCEPTED', 6); define('MESSAGE_STATUS_INVITATION_DENIED', 7); define('MESSAGE_STATUS_WALL', 8); + define('MESSAGE_STATUS_WALL_DELETE', 9); + define('MESSAGE_STATUS_WALL_POST', 10); + define('MESSAGE_STATUS_CONVERSATION', 11); + define('MESSAGE_STATUS_FORUM', 12); define('MESSAGE_STATUS_PROMOTED', 13); diff --git a/public/main/inc/lib/message.lib.php b/public/main/inc/lib/message.lib.php index 25017a3636..c0ac0e45cb 100644 --- a/public/main/inc/lib/message.lib.php +++ b/public/main/inc/lib/message.lib.php @@ -746,97 +746,6 @@ class MessageManager return $result; } - /** - * @param int $user_receiver_id - * @param int $id - * - * @return bool - */ - public static function delete_message_by_user_receiver($user_receiver_id, $id) - { - $id = (int) $id; - $user_receiver_id = (int) $user_receiver_id; - - if (empty($id) || empty($user_receiver_id)) { - return false; - } - - $em = Database::getManager(); - $repo = $em->getRepository(Message::class); - $criteria = ['id' => $id, 'userReceiver' => $user_receiver_id]; - /** @var Message $message */ - $message = $repo->findOneBy($criteria); - - if (null === $message || ($message && MESSAGE_STATUS_OUTBOX === $message->getMsgType())) { - return false; - } - - $message->setMsgStatus(MESSAGE_STATUS_DELETED); - $attachments = $message->getAttachments(); - if (!empty($attachments)) { - $repo = Container::getMessageAttachmentRepository(); - foreach ($attachments as $file) { - $repo->softDelete($file); - } - } - $em->persist($message); - $em->flush(); - - /* - // Delete attachment file. - self::delete_message_attachment_file($id, $user_receiver_id); - // Soft delete message. - $query = "UPDATE $table - SET msg_status = ".MESSAGE_STATUS_DELETED." - WHERE - id = $id AND - user_receiver_id = $user_receiver_id "; - Database::query($query);*/ - - return true; - } - - /** - * Set status deleted. - * - * @author Isaac FLores Paz - * - * @param int - * @param int - * - * @return bool - */ - public static function delete_message_by_user_sender($user_sender_id, $id) - { - $user_sender_id = (int) $user_sender_id; - $id = (int) $id; - - if (empty($id) || empty($user_sender_id)) { - return false; - } - $em = Database::getManager(); - $repo = $em->getRepository(Message::class); - $criteria = ['id' => $id, 'userSender' => $user_sender_id]; - $message = $repo->findOneBy($criteria); - - /*$table = Database::get_main_table(TABLE_MESSAGE); - $sql = "SELECT * FROM $table WHERE id = $id AND user_sender_id= $user_sender_id"; - $rs = Database::query($sql);*/ - - if (null !== $message) { - // delete attachment file - //self::delete_message_attachment_file($id, $user_sender_id); - $message->setMsgStatus(MESSAGE_STATUS_DELETED); - self::softDeleteAttachments($message); - $em->persist($message); - $em->flush(); - - return true; - } - - return false; - } - public static function softDeleteAttachments(Message $message): void { $attachments = $message->getAttachments(); @@ -1826,206 +1735,6 @@ class MessageManager return $html; } - /** - * @param string $keyword - * - * @return string - */ - public static function getPromotedMessagesGrid($keyword) - { - $actions = ['delete']; - $currentUserId = api_get_user_id(); - - $success = get_lang('The selected messages have been deleted'); - if (isset($_REQUEST['action'])) { - switch ($_REQUEST['action']) { - case 'delete': - foreach ($_POST['id'] as $index => $messageId) { - self::delete_message_by_user_receiver($currentUserId, $messageId); - } - Display::addFlash(Display::return_message( - $success, - 'normal', - false - )); - break; - case 'deleteone': - self::delete_message_by_user_receiver($currentUserId, $_GET['id']); - Display::addFlash(Display::return_message( - $success, - 'confirmation', - false - )); - break; - } - - header('Location: '.api_get_self()); - exit; - } - - return self::getMessageGrid(Message::MESSAGE_TYPE_PROMOTED, $keyword, $actions); - } - - /** - * Get the data of the last received messages for a user. - * - * @param int $userId The user id - * @param int $lastId The id of the last received message - * - * @return Message[] - */ - public static function getMessagesFromLastReceivedMessage($userId, $lastId = 0) - { - $userId = (int) $userId; - $lastId = (int) $lastId; - - if (empty($userId)) { - return []; - } - - $user = api_get_user_entity($userId); - $criteria = Criteria::create() - ->where( - Criteria::expr()->gt('id', $lastId) - )->andWhere( - Criteria::expr()->in('msgStatus', [MESSAGE_STATUS_UNREAD]) - )->orderBy(['sendDate' => Criteria::DESC]); - - return $user->getSentMessages()->matching($criteria); - - /*$messagesTable = Database::get_main_table(TABLE_MESSAGE); - $userTable = Database::get_main_table(TABLE_MAIN_USER); - - $sql = "SELECT m.*, u.user_id, u.lastname, u.firstname - FROM $messagesTable as m - INNER JOIN $userTable as u - ON m.user_sender_id = u.user_id - WHERE - m.user_receiver_id = $userId AND - m.msg_status = ".MESSAGE_STATUS_UNREAD." - AND m.id > $lastId - ORDER BY m.send_date DESC"; - - $result = Database::query($sql); - - $messages = []; - if (false !== $result) { - while ($row = Database::fetch_assoc($result)) { - $messages[] = $row; - } - } - - return $messages;*/ - } - - /** - * Get the data of the last received messages for a user. - * - * @param int $userId The user id - * @param int $lastId The id of the last received message - * - * @return Message[] - */ - public static function getReceivedMessages($userId, $lastId = 0) - { - $userId = (int) $userId; - $lastId = (int) $lastId; - - if (empty($userId)) { - return []; - } - - $user = api_get_user_entity($userId); - $criteria = Criteria::create() - ->where( - Criteria::expr()->gt('id', $lastId) - )->andWhere( - Criteria::expr()->in('msgStatus', [MESSAGE_STATUS_NEW, MESSAGE_STATUS_UNREAD]) - )->orderBy(['sendDate' => Criteria::DESC]); - - return $user->getReceivedMessages()->matching($criteria); - - /*$messagesTable = Database::get_main_table(TABLE_MESSAGE); - $userTable = Database::get_main_table(TABLE_MAIN_USER); - $sql = "SELECT m.*, u.user_id, u.lastname, u.firstname, u.picture_uri - FROM $messagesTable as m - INNER JOIN $userTable as u - ON m.user_sender_id = u.user_id - WHERE - m.user_receiver_id = $userId AND - m.msg_status IN (".MESSAGE_STATUS_NEW.", ".MESSAGE_STATUS_UNREAD.") - AND m.id > $lastId - ORDER BY m.send_date DESC"; - $result = Database::query($sql); - $messages = []; - if (false !== $result) { - while ($row = Database::fetch_assoc($result)) { - $messages[] = $row; - } - } - - return $messages;*/ - } - - /** - * Get the data of the last received messages for a user. - * - * @param int $userId The user id - * @param int $lastId The id of the last received message - * - * @return array - */ - public static function getSentMessages($userId, $lastId = 0) - { - $userId = (int) $userId; - $lastId = (int) $lastId; - - if (empty($userId)) { - return []; - } - - $user = api_get_user_entity($userId); - $criteria = Criteria::create() - ->where( - Criteria::expr()->gt('id', $lastId) - )->andWhere( - Criteria::expr()->in('msgStatus', [MESSAGE_STATUS_OUTBOX]) - )->orderBy(['sendDate' => Criteria::DESC]); - - if ($user->getSentMessages()->count()) { - return $user->getSentMessages()->matching($criteria); - } - - return []; - - /* - $messagesTable = Database::get_main_table(TABLE_MESSAGE); - $userTable = Database::get_main_table(TABLE_MAIN_USER); - - $sql = "SELECT m.*, u.user_id, u.lastname, u.firstname, u.picture_uri - FROM $messagesTable as m - INNER JOIN $userTable as u - ON m.user_receiver_id = u.user_id - WHERE - m.user_sender_id = $userId - AND m.msg_status = ".MESSAGE_STATUS_OUTBOX." - AND m.id > $lastId - ORDER BY m.send_date DESC"; - - $result = Database::query($sql); - - $messages = []; - if (false !== $result) { - while ($row = Database::fetch_assoc($result)) { - $pictureInfo = UserManager::get_user_picture_path_by_id($row['user_id'], 'web'); - $row['pictureUri'] = $pictureInfo['dir'].$pictureInfo['file']; - $messages[] = $row; - } - } - - return $messages;*/ - } - /** * Check whether a message has attachments. * diff --git a/public/main/inc/lib/social.lib.php b/public/main/inc/lib/social.lib.php index 2eef0dd2a6..cadab68f4f 100644 --- a/public/main/inc/lib/social.lib.php +++ b/public/main/inc/lib/social.lib.php @@ -222,118 +222,6 @@ class SocialManager extends UserManager return $list; } - /** - * get web path of user invitate. - * - * @author isaac flores paz - * @author Julio Montoya setting variable array - * - * @param int user id - * - * @return array - */ - public static function get_list_web_path_user_invitation_by_user_id($user_id) - { - return []; - // @todo - /*$list_ids = self::get_list_invitation_of_friends_by_user_id($user_id); - $list = []; - foreach ($list_ids as $values_ids) { - $list[] = UserManager::get_user_picture_path_by_id( - $values_ids['user_sender_id'], - 'web' - ); - } - - return $list;*/ - } - - /** - * Sends an invitation to contacts. - * - * @param int user id - * @param int user friend id - * @param string title of the message - * @param string content of the message - * - * @return bool - * - * @author isaac flores paz - * @author Julio Montoya Cleaning code - */ - public static function send_invitation_friend( - $user_id, - $friend_id, - $message_title, - $message_content - ) { - $tbl_message = Database::get_main_table(TABLE_MESSAGE); - $user_id = (int) $user_id; - $friend_id = (int) $friend_id; - - //Just in case we replace the and \n and \n\r while saving in the DB - $message_content = str_replace(["\n", "\n\r"], '
', $message_content); - $clean_message_content = Database::escape_string($message_content); - $sql = 'SELECT COUNT(*) AS count FROM '.$tbl_message.' - WHERE - user_sender_id='.$user_id.' AND - user_receiver_id='.$friend_id.' AND - msg_status IN('.MESSAGE_STATUS_INVITATION_PENDING.', '.MESSAGE_STATUS_INVITATION_ACCEPTED.', '.MESSAGE_STATUS_INVITATION_DENIED.'); - '; - $res_exist = Database::query($sql); - $row_exist = Database::fetch_array($res_exist, 'ASSOC'); - if (0 === (int) $row_exist['count']) { - $em = Database::getManager(); - $message = new Message(); - $message - ->setUserSender(api_get_user_entity($user_id)) - ->setUserReceiver(api_get_user_entity($friend_id)) - ->setMsgStatus(MESSAGE_STATUS_INVITATION_PENDING) - ->setTitle($message_title) - ->setContent($message_content) - ; - $em->persist($message); - $em->flush(); - $messageId = $message->getId(); - if ($messageId) { - $senderInfo = api_get_user_info($user_id); - $notification = new Notification(); - $notification->saveNotification( - $messageId, - Notification::NOTIFICATION_TYPE_INVITATION, - [$friend_id], - $message_title, - $message_content, - $senderInfo - ); - } - - return true; - } else { - // invitation already exist - $sql = 'SELECT COUNT(*) AS count, id FROM '.$tbl_message.' - WHERE - user_sender_id='.$user_id.' AND - user_receiver_id='.$friend_id.' AND - msg_status = 7'; - $res_if_exist = Database::query($sql); - $row_if_exist = Database::fetch_array($res_if_exist, 'ASSOC'); - if (1 == $row_if_exist['count']) { - $sql = 'UPDATE '.$tbl_message.' SET - msg_status = 5, content = "'.$clean_message_content.'" - WHERE - user_sender_id='.$user_id.' AND - user_receiver_id='.$friend_id.' AND - msg_status = 7 '; - Database::query($sql); - - return true; - } - } - - return false; - } - /** * Get number messages of the inbox. * @@ -651,67 +539,6 @@ class SocialManager extends UserManager return $res; } - /** - * Sends invitations to friends. - * - * @param int $userId - * @param string $subject - * @param string $content - * - * @return bool - */ - public static function sendInvitationToUser($userId, $subject = '', $content = '') - { - $user_info = api_get_user_info($userId); - $success = get_lang('The message has been sent to'); - $success .= ' : '.api_get_person_name($user_info['firstName'], $user_info['lastName']); - - if (!empty($subject) && !empty($content) && !empty($userId)) { - $result = MessageManager::send_message($userId, $subject, $content); - - if ($result) { - Display::addFlash( - Display::return_message($success, 'normal', false) - ); - } else { - Display::addFlash( - Display::return_message( - get_lang('There was an error while trying to send the message.'), - 'error', - false - ) - ); - } - - return false; - } elseif (!empty($userId) && empty($subject)) { - $count = self::send_invitation_friend( - api_get_user_id(), - $userId, - get_lang('Invitation'), - $content - ); - - if ($count) { - Display::addFlash( - Display::return_message( - api_htmlentities(get_lang('The invitation has been sent')), - 'normal', - false - ) - ); - } else { - Display::addFlash( - Display::return_message( - api_htmlentities(get_lang('You already sent an invitation')), - 'warning', - false - ) - ); - } - } - } - /** * Shows the avatar block in social pages. * @@ -1332,89 +1159,6 @@ class SocialManager extends UserManager return $content; } - /** - * Sends a message to someone's wall. - * - * @param int $userId id of author - * @param int $friendId id where we send the message - * @param string $messageContent of the message - * @param int $messageId id parent - * @param string $messageStatus status type of message - * - * @return Message - * - * @author Yannick Warnier - */ - public static function sendWallMessage( - $userId, - $friendId, - $messageContent, - $messageId = 0, - $messageStatus = '' - ) { - $userId = (int) $userId; - $friendId = (int) $friendId; - $messageId = (int) $messageId; - - if (empty($userId) || empty($friendId)) { - return 0; - } - $em = Database::getManager(); - - $repo = $em->getRepository(Message::class); - $parent = $repo->find($messageId); - - // Just in case we replace the and \n and \n\r while saving in the DB - $messageContent = str_replace(["\n", "\n\r"], '
', $messageContent); - - $message = new Message(); - $message - ->setUserSender(api_get_user_entity($userId)) - ->setUserReceiver(api_get_user_entity($friendId)) - ->setMsgStatus($messageStatus) - ->setTitle('') - ->setContent($messageContent) - ->setParent($parent) - ; - $em->persist($message); - $em->flush(); - - return $message; - } - - /** - * Send File attachment (jpg,png). - * - * @param int $userId id user - * @param array $fileAttach - * @param Message $message - * @param string $fileComment description attachment file - * - * @return bool|int - * - * @author Anibal Copitan - */ - public static function sendWallMessageAttachmentFile( - $userId, - $fileAttach, - $message, - $fileComment = '' - ) { - $safeFileName = Database::escape_string($fileAttach['name']); - $extension = strtolower(substr(strrchr($safeFileName, '.'), 1)); - $allowedTypes = api_get_supported_image_extensions(); - - $allowedTypes[] = 'mp4'; - $allowedTypes[] = 'webm'; - $allowedTypes[] = 'ogg'; - - if (in_array($extension, $allowedTypes)) { - return MessageManager::saveMessageAttachmentFile($fileAttach, $fileComment, $message); - } - - return false; - } - /** * Gets all messages from someone's wall (within specific limits). * @@ -1624,133 +1368,6 @@ class SocialManager extends UserManager return $messages; } - /** - * Gets all messages from someone's wall (within specific limits), formatted. - * - * @param int $userId USER ID of the person's wall - * @param array $messageInfo - * @param string $start Start date (from when we want the messages until today) - * @param int $limit Limit to the number of messages we want - * @param int $offset Wall messages offset - * - * @return string HTML formatted string to show messages - */ - public static function getWallPostComments( - $userId, - $messageInfo, - $start = null, - $limit = 10, - $offset = 0 - ) { - $messageId = $messageInfo['id']; - $messages = MessageManager::getMessagesByParent($messageInfo['id'], 0, $offset, $limit); - $formattedList = '
'; - $users = []; - - // The messages are ordered by date descendant, for comments we need ascendant - krsort($messages); - foreach ($messages as $message) { - $userIdLoop = $message['user_sender_id']; - if (!isset($users[$userIdLoop])) { - $users[$userIdLoop] = api_get_user_info($userIdLoop); - } - $media = self::processPostComment($message, $users); - $formattedList .= $media; - } - - $formattedList .= '
'; - $formattedList .= '
'; - $formattedList .= '
-
- - - -
- -
'; - $formattedList .= '
'; - - return $formattedList; - } - - /** - * @param array $message - * @param array $users - * - * @return string - */ - public static function processPostComment($message, $users = []) - { - if (empty($message)) { - return false; - } - - $date = Display::dateToStringAgoAndLongDate($message['send_date']); - $currentUserId = api_get_user_id(); - $userIdLoop = $message['user_sender_id']; - $receiverId = $message['user_receiver_id']; - - if (!isset($users[$userIdLoop])) { - $users[$userIdLoop] = api_get_user_info($userIdLoop); - } - - $iconStatus = $users[$userIdLoop]['icon_status']; - $nameComplete = $users[$userIdLoop]['complete_name']; - $url = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$userIdLoop; - - $comment = '
'; - $comment .= ''; - $comment .= ''; - - $comment .= ''; - $comment .= '
'; - - return $comment; - } - /** * @return array */ @@ -1885,61 +1502,6 @@ class SocialManager extends UserManager return false; } - /** - * Soft delete a message and his children. - * - * @param int $id id message to delete - * - * @return bool status query - */ - public static function deleteMessage($id) - { - $em = Database::getManager(); - $repo = $em->getRepository(Message::class); - - /** @var Message $message */ - $message = $repo->find($id); - - if (null === $message) { - return false; - } - - $children = $message->getChildren(); - if ($children->count()) { - foreach ($children as $child) { - self::deleteMessage($child->getId()); - } - } - - $message->setMsgStatus(MESSAGE_STATUS_WALL_DELETE); - MessageManager::softDeleteAttachments($message); - - /*$id = (int) $id; - $messageInfo = MessageManager::get_message_by_id($id); - if (!empty($messageInfo)) { - // Delete comments too - $messages = MessageManager::getMessagesByParent($id); - if (!empty($messages)) { - foreach ($messages as $message) { - self::deleteMessage($message['id']); - } - } - - // Soft delete message - $tblMessage = Database::get_main_table(TABLE_MESSAGE); - $statusMessage = MESSAGE_STATUS_WALL_DELETE; - $sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' "; - Database::query($sql); - - MessageManager::delete_message_attachment_file($id, $messageInfo['user_sender_id']); - MessageManager::delete_message_attachment_file($id, $messageInfo['user_receiver_id']); - - return true; - } - - return false;*/ - } - /** * Generate the social block for a user. * @@ -2242,61 +1804,6 @@ class SocialManager extends UserManager return $html; } - /** - * @param int $userId - * @param int $start - * @param int $length - * @param array $threadList - * - * @return array - */ - public static function getMyWallMessages($userId, $start = 0, $length = 10, $threadList = []) - { - $userGroup = new UserGroupModel(); - $groups = $userGroup->get_groups_by_user($userId, [GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_ADMIN]); - $groupList = []; - if (!empty($groups)) { - $groupList = array_column($groups, 'id'); - } - - $friends = self::get_friends($userId, USER_RELATION_TYPE_FRIEND); - $friendList = []; - if (!empty($friends)) { - $friendList = array_column($friends, 'friend_user_id'); - } - - $messages = self::getWallMessages( - $userId, - 0, - $groupList, - $friendList, - '', - $start, - $length, - false, - $threadList - ); - - $countPost = self::getCountWallMessagesByUser($userId, $groupList, $friendList, $threadList); - $messages = self::formatWallMessages($messages); - - $html = ''; - foreach ($messages as $message) { - $post = $message['html']; - $comments = ''; - if (in_array($message['msg_status'], [MESSAGE_STATUS_WALL_POST, MESSAGE_STATUS_PROMOTED])) { - $comments = self::getWallPostComments($userId, $message); - } - - $html .= self::wrapPost($message, $post.$comments); - } - - return [ - 'posts' => $html, - 'count' => $countPost, - ]; - } - /** * @param string $message * @param string $content @@ -2320,51 +1827,6 @@ class SocialManager extends UserManager ); } - /** - * @param int $userId - * @param array $groupList - * @param array $friendList - * @param array $threadList - * - * @return int - */ - public static function getCountWallMessagesByUser($userId, $groupList = [], $friendList = [], $threadList = []) - { - $count = self::getWallMessages( - $userId, - 0, - $groupList, - $friendList, - '', - 0, - 0, - true, - $threadList - ); - - return $count; - } - - /** - * @param int $userId - * - * @return string - */ - public static function getWallMessagesByUser($userId) - { - $messages = self::getWallMessages($userId); - $messages = self::formatWallMessages($messages); - - $html = ''; - foreach ($messages as $message) { - $post = $message['html']; - $comments = self::getWallPostComments($userId, $message); - $html .= self::wrapPost($message, $post.$comments); - } - - return $html; - } - /** * Get HTML code block for user skills. * @@ -2658,43 +2120,6 @@ class SocialManager extends UserManager return $extra_information; } - /** - * @param string $url - */ - public static function handlePosts($url) - { - $friendId = isset($_GET['u']) ? (int) $_GET['u'] : api_get_user_id(); - $url = Security::remove_XSS($url); - - // Main post - if (!empty($_POST['social_wall_new_msg_main']) || !empty($_FILES['picture']['tmp_name'])) { - $messageContent = $_POST['social_wall_new_msg_main']; - if (!empty($_POST['url_content'])) { - $messageContent = $_POST['social_wall_new_msg_main'].'

'.$_POST['url_content']; - } - - $message = self::sendWallMessage( - api_get_user_id(), - $friendId, - $messageContent, - 0, - MESSAGE_STATUS_WALL_POST - ); - - if ($message && !empty($_FILES['picture']['tmp_name'])) { - self::sendWallMessageAttachmentFile( - api_get_user_id(), - $_FILES['picture'], - $message - ); - } - - Display::addFlash(Display::return_message(get_lang('Message Sent'))); - header('Location: '.$url); - exit; - } - } - /** * @param int $countPost * @param array $htmlHeadXtra diff --git a/public/main/inc/lib/webservices/Rest.php b/public/main/inc/lib/webservices/Rest.php index b11e2bc4cd..6bc85858ba 100644 --- a/public/main/inc/lib/webservices/Rest.php +++ b/public/main/inc/lib/webservices/Rest.php @@ -252,7 +252,7 @@ class Rest extends WebService * * @return array */ - public function getUserMessages($lastMessageId = 0) + /*public function getUserMessages($lastMessageId = 0) { $lastMessages = MessageManager::getMessagesFromLastReceivedMessage($this->user->getId(), $lastMessageId); $messages = []; @@ -261,12 +261,12 @@ class Rest extends WebService } return $messages; - } + }*/ /** * @return array */ - public function getUserReceivedMessages() + /*public function getUserReceivedMessages() { $lastMessages = MessageManager::getReceivedMessages($this->user->getId(), 0); $messages = []; @@ -275,12 +275,12 @@ class Rest extends WebService } return $messages; - } + }*/ /** * @return array */ - public function getUserSentMessages() + /*public function getUserSentMessages() { $lastMessages = MessageManager::getSentMessages($this->user->getId(), 0); $messages = []; @@ -290,7 +290,7 @@ class Rest extends WebService } return $messages; - } + }*/ /** * Get the user courses. @@ -1454,7 +1454,7 @@ class Rest extends WebService return [false]; } - public function deleteUserMessage($messageId, $messageType) + /*public function deleteUserMessage($messageId, $messageType) { if ("sent" === $messageType) { return MessageManager::delete_message_by_user_sender($this->user->getId(), $messageId); @@ -1466,7 +1466,7 @@ class Rest extends WebService public function setMessageRead($messageId) { MessageManager::update_message($this->user->getId(), $messageId); - } + }*/ /** * Add Campus Virtual. diff --git a/public/main/social/home.php b/public/main/social/home.php deleted file mode 100644 index f949a86ea0..0000000000 --- a/public/main/social/home.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @autor Alex Aragon CSS Design and Template - */ -$cidReset = true; - -require_once __DIR__.'/../inc/global.inc.php'; - -api_block_anonymous_users(); - -$user_id = api_get_user_id(); -$show_full_profile = true; -// social tab -Session::erase('this_section'); -$this_section = SECTION_SOCIAL; - -if ('true' !== api_get_setting('allow_social_tool')) { - $url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; - header('Location: '.$url); - exit; -} - -$userGroup = new UserGroupModel(); - -SocialManager::handlePosts(api_get_self()); - -$threadList = SocialManager::getThreadList($user_id); -$threadIdList = []; -if (!empty($threadList)) { - $threadIdList = array_column($threadList, 'id'); -} - -$posts = SocialManager::getMyWallMessages($user_id, 0, 10, $threadIdList); -$countPost = $posts['count']; -$posts = $posts['posts']; -$htmlHeadXtra = []; -SocialManager::getScrollJs($countPost, $htmlHeadXtra); - -// Block Menu -$menu = SocialManager::show_social_menu('home'); - -$social_search_block = Display::panel( - UserManager::get_search_form(''), - get_lang('Search users') -); - -$social_group_block = SocialManager::getGroupBlock($user_id); - -// My friends -$friend_html = SocialManager::listMyFriendsBlock($user_id); - -// Block Social Sessions -$wallSocialAddPost = SocialManager::getWallForm(api_get_self()); -$socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost); - -$formSearch = new FormValidator( - 'find_friends_form', - 'get', - api_get_path(WEB_CODE_PATH).'social/search.php?search_type=1', - null, - null, - FormValidator::LAYOUT_BOX_NO_LABEL -); -$formSearch->addHidden('search_type', 1); -$formSearch->addText( - 'q', - get_lang('Search'), - false, - [ - 'aria-label' => get_lang('Search users'), - 'custom' => true, - 'placeholder' => get_lang('Search usersByName'), - ] -); - -// Added a Jquery Function to return the Preview of OpenGraph URL Content -$htmlHeadXtra[] = SocialManager::getScriptToGetOpenGraph(); - -$tpl = new Template(get_lang('Social network')); -SocialManager::setSocialUserBlock($tpl, $user_id, 'home'); -$tpl->assign('add_post_form', $wallSocialAddPost); -$tpl->assign('posts', $posts); -$tpl->assign('social_menu_block', $menu); -$tpl->assign('social_auto_extend_link', $socialAutoExtendLink); -$tpl->assign('search_friends_form', $formSearch->returnForm()); -$tpl->assign('social_friend_block', $friend_html); -$tpl->assign('social_search_block', $social_search_block); -$tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id, 'vertical')); -$tpl->assign('social_group_block', $social_group_block); -$tpl->assign('social_right_content', ''); - -$tpl->assign('session_list', null); -$social_layout = $tpl->get_template('social/home.tpl'); -$tpl->display($social_layout); diff --git a/public/main/social/profile.php b/public/main/social/profile.php deleted file mode 100644 index 341d23cfde..0000000000 --- a/public/main/social/profile.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @author Isaac Flores Paz - * - * @todo use Display::panel() - */ -$cidReset = true; -require_once __DIR__.'/../inc/global.inc.php'; - -if ('true' != api_get_setting('allow_social_tool')) { - $url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']); - header('Location: '.$url); - exit; -} - -$bossId = isset($_REQUEST['sup']) ? (int) $_REQUEST['sup'] : 0; -$user_id = api_get_user_id(); - -$redirectToBossId = 0; -if (!empty($bossId)) { - $bossList = UserManager::getStudentBossList($user_id); - if (!empty($bossList)) { - foreach ($bossList as $boss) { - $bossId = $boss['boss_id']; - $bossInfo = api_get_user_info($bossId); - if (!empty($bossInfo)) { - $redirectToBossId = $bossId; - break; - } - } - } -} - -if (!empty($redirectToBossId)) { - header('Location: '.api_get_self().'?u='.$redirectToBossId); - exit; -} - -$friendId = isset($_GET['u']) ? (int) $_GET['u'] : api_get_user_id(); -$show_full_profile = true; -//social tab -$this_section = SECTION_SOCIAL; - -// Initialize blocks -$social_course_block = null; -$social_group_info_block = null; -$social_rss_block = null; -$social_session_block = null; - -SocialManager::handlePosts(api_get_self().'?u='.$friendId); - -if (isset($_GET['u'])) { - //I'm your friend? I can see your profile? - $user_id = (int) $_GET['u']; - if (api_is_anonymous($user_id, true)) { - api_not_allowed(true); - } - // It's me! - if (api_get_user_id() != $user_id) { - $user_info = api_get_user_info($user_id); - $show_full_profile = false; - if (!$user_info) { - // user does no exist !! - api_not_allowed(true); - } else { - //checking the relationship between me and my friend - $my_status = SocialManager::get_relation_between_contacts( - api_get_user_id(), - $user_id - ); - if (in_array($my_status, [ - USER_RELATION_TYPE_PARENT, - USER_RELATION_TYPE_FRIEND, - USER_RELATION_TYPE_GOODFRIEND, - ]) - ) { - $show_full_profile = true; - } - //checking the relationship between my friend and me - $my_friend_status = SocialManager::get_relation_between_contacts( - $user_id, - api_get_user_id() - ); - if (in_array($my_friend_status, [ - USER_RELATION_TYPE_PARENT, - USER_RELATION_TYPE_FRIEND, - USER_RELATION_TYPE_GOODFRIEND, - ]) - ) { - $show_full_profile = true; - } else { - // im probably not a good friend - $show_full_profile = false; - } - } - } -} - -api_block_anonymous_users(); -$countPost = SocialManager::getCountWallMessagesByUser($friendId); -$htmlHeadXtra = []; -SocialManager::getScrollJs($countPost, $htmlHeadXtra); -$link_shared = ''; -if (isset($_GET['shared'])) { - $link_shared = 'shared='.Security::remove_XSS($_GET['shared']); -} -$interbreadcrumb[] = [ - 'url' => 'home.php', - 'name' => get_lang('Social network'), -]; - -if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) { - $info_user = api_get_user_info($_GET['u']); - $interbreadcrumb[] = [ - 'url' => '#', - 'name' => $info_user['complete_name'], - ]; -} - -Session::write('social_user_id', $user_id); - -// Social Block Menu -$menu = SocialManager::show_social_menu( - 'shared_profile', - null, - $user_id, - $show_full_profile -); - -//Setting some session info -$user_info = api_get_user_info($friendId); -$sessionList = []; - -// My friends -$friend_html = SocialManager::listMyFriendsBlock($user_id, $link_shared); -$addPostForm = SocialManager::getWallForm(api_get_self()); - -$posts = SocialManager::getWallMessagesByUser($friendId); -$socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost); - -// Added a Jquery Function to return the Preview of OpenGraph URL Content -$htmlHeadXtra[] = SocialManager::getScriptToGetOpenGraph(); - -$socialRightInformation = ''; -$listInvitations = ''; - -if ($show_full_profile) { - $social_group_info_block = SocialManager::getGroupBlock($friendId); - // Block Social Sessions - if (count($sessionList) > 0) { - $social_session_block = $sessionList; - } - - // Block Social User Feeds - $user_feeds = SocialManager::getUserRssFeed($user_id); - - if (!empty($user_feeds)) { - $social_rss_block = Display::panel($user_feeds, get_lang('RSS feed')); - } - - // Productions - $production_list = UserManager::build_production_list($user_id); - - // Images uploaded by course - $file_list = ''; - $count_pending_invitations = 0; - if (!isset($_GET['u']) || - (isset($_GET['u']) && $_GET['u'] == api_get_user_id()) - ) { - $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id()); - $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id()); - $count_pending_invitations = count($pending_invitations); - } - - if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) { - // Pending invitations - if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u'] == api_get_user_id())) { - if ($count_pending_invitations > 0) { - $invitations = '
    '; - for ($i = 0; $i < $count_pending_invitations; $i++) { - $user_invitation_id = $pending_invitations[$i]['user_sender_id']; - $invitations .= '
  • '; - $invitations .= ''; - $userInfo = api_get_user_info($user_invitation_id); - $invitations .= '' - .api_get_person_name($userInfo['firstname'], $userInfo['lastname']).''; - - $invitations .= '
    '; - $invitations .= Display::toolbarButton( - get_lang('Add to my contacts'), - api_get_path(WEB_AJAX_PATH).'social.ajax.php?'.http_build_query([ - 'a' => 'add_friend', - 'friend_id' => $user_invitation_id, - 'is_my_friend' => 'friend', - ]), - 'plus', - 'default', - ['class' => 'btn-sm'], - false - ); - $invitations .= '
    '; - $invitations .= '
    '; - $invitations .= '
  • '; - } - $invitations .= '
'; - $listInvitations = Display::panelCollapse( - get_lang('Pending invitations'), - $invitations, - 'invitations', - null, - 'invitations-acordion', - 'invitations-collapse' - ); - } - } - - // Productions - $production_list = UserManager::build_production_list($user_id); - $product_content = ''; - if (!empty($production_list)) { - $product_content .= '

'.get_lang('My productions').'

'; - $product_content .= $production_list; - $socialRightInformation .= SocialManager::social_wrapper_div($product_content, 4); - } - - $images_uploaded = null; - } - - if (!empty($user_info['competences']) || !empty($user_info['diplomas']) - || !empty($user_info['openarea']) || !empty($user_info['teach'])) { - $more_info = '

'.get_lang('More information').'

'; - if (!empty($user_info['competences'])) { - $more_info .= '
'; - $more_info .= ''; - $more_info .= ''; - $more_info .= '
'; - } - if (!empty($user_info['diplomas'])) { - $more_info .= ''; - $more_info .= ''; - $more_info .= '
'; - } - if (!empty($user_info['openarea'])) { - $more_info .= ''; - $more_info .= ''; - $more_info .= '
'; - } - if (!empty($user_info['teach'])) { - $more_info .= ''; - $more_info .= ''; - $more_info .= '
'; - } - $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4); - } -} - -$tpl = new Template(get_lang('Social')); -// Block Avatar Social -SocialManager::setSocialUserBlock( - $tpl, - $friendId, - 'shared_profile', - 0, - $show_full_profile -); - -$tpl->assign('social_friend_block', $friend_html); -$tpl->assign('social_menu_block', $menu); -$tpl->assign('add_post_form', $addPostForm); -$tpl->assign('posts', $posts); -$tpl->assign('social_course_block', $social_course_block); -$tpl->assign('social_group_info_block', $social_group_info_block); -$tpl->assign('social_rss_block', $social_rss_block); -$tpl->assign('social_skill_block', SocialManager::getSkillBlock($friendId, 'vertical')); -$tpl->assign('session_list', $social_session_block); -$tpl->assign('invitations', $listInvitations); -$tpl->assign('social_right_information', $socialRightInformation); -$tpl->assign('social_auto_extend_link', $socialAutoExtendLink); - -$formModalTpl = new Template(); -$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'); -$tpl->display($social_layout); diff --git a/public/main/social/promoted_messages.php b/public/main/social/promoted_messages.php index ef8abc347b..05eb01d96a 100644 --- a/public/main/social/promoted_messages.php +++ b/public/main/social/promoted_messages.php @@ -44,7 +44,7 @@ if ($form->validate()) { } $actionsRight = $form->returnForm(); $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]); -$social_right_content .= MessageManager::getPromotedMessagesGrid($keyword); +//$social_right_content .= MessageManager::getPromotedMessagesGrid($keyword); $tpl = new Template(null); // Block Social Avatar diff --git a/public/main/webservices/cm_webservice_user.php b/public/main/webservices/cm_webservice_user.php index d99bf9ed0f..aae19bc1d7 100644 --- a/public/main/webservices/cm_webservice_user.php +++ b/public/main/webservices/cm_webservice_user.php @@ -96,7 +96,7 @@ class WSCMUser extends WSCM return "0"; } - public function send_invitation( + /*public function send_invitation( $username, $password, $userfriend_id, @@ -166,7 +166,7 @@ class WSCMUser extends WSCM } return get_lang('Login failed - incorrect login or password.'); - } + }*/ /** * Get a list of users of which the given conditions match with a LIKE '%cond%'. diff --git a/src/CoreBundle/Entity/Listener/SkillRelUserListener.php b/src/CoreBundle/Entity/Listener/SkillRelUserListener.php index 82a297c38f..2dd6d5c0de 100644 --- a/src/CoreBundle/Entity/Listener/SkillRelUserListener.php +++ b/src/CoreBundle/Entity/Listener/SkillRelUserListener.php @@ -1,4 +1,5 @@