|
|
|
@ -1,32 +1,33 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @package chamilo.messages |
|
|
|
* @package chamilo.messages |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Code |
|
|
|
* Code |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
// name of the language file that needs to be included |
|
|
|
// name of the language file that needs to be included |
|
|
|
$language_file = array('registration','messages','userInfo'); |
|
|
|
$language_file = array('registration', 'messages', 'userInfo'); |
|
|
|
$cidReset = true; |
|
|
|
$cidReset = true; |
|
|
|
|
|
|
|
|
|
|
|
require_once '../inc/global.inc.php'; |
|
|
|
require_once '../inc/global.inc.php'; |
|
|
|
|
|
|
|
|
|
|
|
api_block_anonymous_users(); |
|
|
|
api_block_anonymous_users(); |
|
|
|
if (isset($_GET['messages_page_nr'])) { |
|
|
|
if (isset($_GET['messages_page_nr'])) { |
|
|
|
$social_link = ''; |
|
|
|
$social_link = ''; |
|
|
|
if ($_REQUEST['f']=='social') { |
|
|
|
if ($_REQUEST['f'] == 'social') { |
|
|
|
$social_link = '?f=social'; |
|
|
|
$social_link = '?f=social'; |
|
|
|
} |
|
|
|
} |
|
|
|
if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') { |
|
|
|
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { |
|
|
|
header('Location:inbox.php'.$social_link); |
|
|
|
header('Location:inbox.php'.$social_link); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (api_get_setting('allow_message_tool')!='true'){ |
|
|
|
if (api_get_setting('allow_message_tool') != 'true') { |
|
|
|
api_not_allowed(); |
|
|
|
api_not_allowed(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$htmlHeadXtra[]='<script type="text/javascript"> |
|
|
|
$htmlHeadXtra[] = '<script> |
|
|
|
|
|
|
|
|
|
|
|
function show_icon_edit(element_html) { |
|
|
|
function show_icon_edit(element_html) { |
|
|
|
ident="#edit_image"; |
|
|
|
ident="#edit_image"; |
|
|
|
@ -41,91 +42,91 @@ function hide_icon_edit(element_html) { |
|
|
|
</script>'; |
|
|
|
</script>'; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
MAIN CODE |
|
|
|
MAIN CODE |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
$nameTools = get_lang('Messages'); |
|
|
|
$nameTools = get_lang('Messages'); |
|
|
|
$request = api_is_xml_http_request(); |
|
|
|
$request = api_is_xml_http_request(); |
|
|
|
if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) { |
|
|
|
if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) { |
|
|
|
$info_reply=array(); |
|
|
|
$info_reply = array(); |
|
|
|
$info_delete=array(); |
|
|
|
$info_delete = array(); |
|
|
|
|
|
|
|
|
|
|
|
if ( isset($_GET['form_reply']) ) { |
|
|
|
if (isset($_GET['form_reply'])) { |
|
|
|
//allow to insert messages |
|
|
|
//allow to insert messages |
|
|
|
$info_reply=explode(base64_encode('&%ff..x'),$_GET['form_reply']); |
|
|
|
$info_reply = explode(base64_encode('&%ff..x'), $_GET['form_reply']); |
|
|
|
$count_reply=count($info_reply); |
|
|
|
$count_reply = count($info_reply); |
|
|
|
$button_sent=urldecode($info_reply[4]); |
|
|
|
$button_sent = urldecode($info_reply[4]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( isset($_GET['form_delete']) ) { |
|
|
|
if (isset($_GET['form_delete'])) { |
|
|
|
//allow to delete messages |
|
|
|
//allow to delete messages |
|
|
|
$info_delete = explode(',',$_GET['form_delete']); |
|
|
|
$info_delete = explode(',', $_GET['form_delete']); |
|
|
|
$count_delete = (count($info_delete)-1); |
|
|
|
$count_delete = (count($info_delete) - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isset($button_sent)) { |
|
|
|
if (isset($button_sent)) { |
|
|
|
$title = urldecode($info_reply[0]); |
|
|
|
$title = urldecode($info_reply[0]); |
|
|
|
$content = str_replace("\\","",urldecode($info_reply[1])); |
|
|
|
$content = str_replace("\\", "", urldecode($info_reply[1])); |
|
|
|
|
|
|
|
|
|
|
|
$user_reply = $info_reply[2]; |
|
|
|
$user_reply = $info_reply[2]; |
|
|
|
$user_email_base=str_replace(')','(',$info_reply[5]); |
|
|
|
$user_email_base = str_replace(')', '(', $info_reply[5]); |
|
|
|
$user_email_prepare=explode('(',$user_email_base); |
|
|
|
$user_email_prepare = explode('(', $user_email_base); |
|
|
|
if (count($user_email_prepare)==1) { |
|
|
|
if (count($user_email_prepare) == 1) { |
|
|
|
$user_email=trim($user_email_prepare[0]); |
|
|
|
$user_email = trim($user_email_prepare[0]); |
|
|
|
} elseif (count($user_email_prepare)==3) { |
|
|
|
} elseif (count($user_email_prepare) == 3) { |
|
|
|
$user_email=trim($user_email_prepare[1]); |
|
|
|
$user_email = trim($user_email_prepare[1]); |
|
|
|
} |
|
|
|
} |
|
|
|
$user_id_by_email = MessageManager::get_user_id_by_email($user_email); |
|
|
|
$user_id_by_email = MessageManager::get_user_id_by_email($user_email); |
|
|
|
|
|
|
|
|
|
|
|
if ($info_reply[6]=='save_form') { |
|
|
|
if ($info_reply[6] == 'save_form') { |
|
|
|
$user_id_by_email=$info_reply[2]; |
|
|
|
$user_id_by_email = $info_reply[2]; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($user_reply) && !is_null($user_id_by_email) && strlen($info_reply[0]) >0) { |
|
|
|
if (isset($user_reply) && !is_null($user_id_by_email) && strlen($info_reply[0]) > 0) { |
|
|
|
MessageManager::send_message($user_id_by_email, $title, $content); |
|
|
|
MessageManager::send_message($user_id_by_email, $title, $content); |
|
|
|
$show_message .= MessageManager::return_message($user_id_by_email,'confirmation'); |
|
|
|
$show_message .= MessageManager::return_message($user_id_by_email, 'confirmation'); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} elseif (is_null($user_id_by_email)) { |
|
|
|
} elseif (is_null($user_id_by_email)) { |
|
|
|
$message_box=get_lang('ErrorSendingMessage'); |
|
|
|
$message_box = get_lang('ErrorSendingMessage'); |
|
|
|
$show_message .= Display::return_message(api_xml_http_response_encode($message_box),'error'); |
|
|
|
$show_message .= Display::return_message(api_xml_http_response_encode($message_box), 'error'); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif (trim($info_delete[0])=='delete' ) { |
|
|
|
} elseif (trim($info_delete[0]) == 'delete') { |
|
|
|
for ($i=1;$i<=$count_delete;$i++) { |
|
|
|
for ($i = 1; $i <= $count_delete; $i++) { |
|
|
|
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]); |
|
|
|
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]); |
|
|
|
} |
|
|
|
} |
|
|
|
$message_box=get_lang('SelectedMessagesDeleted'); |
|
|
|
$message_box = get_lang('SelectedMessagesDeleted'); |
|
|
|
$show_message .= Display::return_message(api_xml_http_response_encode($message_box)); |
|
|
|
$show_message .= Display::return_message(api_xml_http_response_encode($message_box)); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['f']) && $_GET['f']=='social') { |
|
|
|
if (isset($_GET['f']) && $_GET['f'] == 'social') { |
|
|
|
$this_section = SECTION_SOCIAL; |
|
|
|
$this_section = SECTION_SOCIAL; |
|
|
|
$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('SocialNetwork')); |
|
|
|
$interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('SocialNetwork')); |
|
|
|
$interbreadcrumb[]= array ('url' => '#','name' => get_lang('Inbox')); |
|
|
|
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Inbox')); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this_section = SECTION_MYPROFILE; |
|
|
|
$this_section = SECTION_MYPROFILE; |
|
|
|
$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile')); |
|
|
|
$interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$social_parameter = ''; |
|
|
|
$social_parameter = ''; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['f']) && $_GET['f'] == 'social' || api_get_setting('allow_social_tool') == 'true') { |
|
|
|
if (isset($_GET['f']) && $_GET['f'] == 'social' || api_get_setting('allow_social_tool') == 'true') { |
|
|
|
$social_parameter = '?f=social'; |
|
|
|
$social_parameter = '?f=social'; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
//Comes from normal profile |
|
|
|
//Comes from normal profile |
|
|
|
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { |
|
|
|
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>'; |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (api_get_setting('allow_message_tool') == 'true') { |
|
|
|
if (api_get_setting('allow_message_tool') == 'true') { |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>'; |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>'; |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>'; |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png', get_lang('Inbox')).'</a>'; |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>'; |
|
|
|
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png', get_lang('Outbox')).'</a>'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//LEFT CONTENT |
|
|
|
//LEFT CONTENT |
|
|
|
@ -138,11 +139,11 @@ $social_right_content = null; |
|
|
|
|
|
|
|
|
|
|
|
if (api_get_setting('allow_social_tool') == 'true') { |
|
|
|
if (api_get_setting('allow_social_tool') == 'true') { |
|
|
|
$social_right_content .= '<div class="span9">'; |
|
|
|
$social_right_content .= '<div class="span9">'; |
|
|
|
$social_right_content .= '<div class="actions">'; |
|
|
|
$social_right_content .= '<div class="actions">'; |
|
|
|
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array(), 32).'</a>'; |
|
|
|
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array(), 32).'</a>'; |
|
|
|
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>'; |
|
|
|
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>'; |
|
|
|
$social_right_content .= '</div>'; |
|
|
|
$social_right_content .= '</div>'; |
|
|
|
$social_right_content .= '</div>'; |
|
|
|
$social_right_content .= '</div>'; |
|
|
|
$social_right_content .= '<div class="span9">'; |
|
|
|
$social_right_content .= '<div class="span9">'; |
|
|
|
} |
|
|
|
} |
|
|
|
//MAIN CONTENT |
|
|
|
//MAIN CONTENT |
|
|
|
@ -151,8 +152,8 @@ if (!isset($_GET['del_msg'])) { |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
$social_right_content .= MessageManager::inbox_display(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$num_msg = intval($_POST['total']); |
|
|
|
$num_msg = intval($_POST['total']); |
|
|
|
for ($i=0;$i<$num_msg;$i++) { |
|
|
|
for ($i = 0; $i < $num_msg; $i++) { |
|
|
|
if($_POST[$i]) { |
|
|
|
if ($_POST[$i]) { |
|
|
|
//the user_id was necesarry to delete a message?? |
|
|
|
//the user_id was necesarry to delete a message?? |
|
|
|
$show_message .= MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]); |
|
|
|
$show_message .= MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|