Fixing bugs when sending messages/invitations

skala
Julio Montoya 14 years ago
parent 0c0f5bd967
commit c1fc1df767
  1. 4
      main/css/base.css
  2. 11
      main/inc/lib/banner.lib.php
  3. 46
      main/inc/lib/message.lib.php
  4. 110
      main/inc/lib/social.lib.php
  5. 136
      main/social/profile.php
  6. 1
      main/template/default/agenda/month.tpl

@ -212,6 +212,10 @@ footer .container .row {
min-height: 140px;
}
#friend-container .thumbnail img {
max-height: 100px;
}
.show-grid [class*="span"] {
background-color: #EEEEEE;
border-bottom-left-radius: 3px;

@ -92,8 +92,8 @@ function get_tabs() {
// Reports
if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
$navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php';
$navigation['reports']['title'] = get_lang('Reports');
$navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php';
$navigation['reports']['title'] = get_lang('Reports');
}
// Custom tabs
@ -425,6 +425,11 @@ function return_menu() {
$message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>';
}
if (api_get_setting('allow_social_tool')=='true') {
$profile_url = '<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>';
} else {
$profile_url = '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('Profile').'</a>';
}
//start user section line with name, my course, my profile, scorm info, etc
$menu .= '<ul class="nav nav-pills pull-right">';
//echo '<li><span>'.get_lang('LoggedInAsX').' '.$login.'</span></li>';
@ -432,7 +437,7 @@ function return_menu() {
$menu .= '<a class="dropdown-toggle" data-toggle="dropdown" href="#"><img src="'.$user_info['avatar_small'].'"/> '.$user_info['complete_name'].'<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>
'.$profile_url.'
'.$message_link.'
</li>
</ul>';

@ -220,7 +220,6 @@ class MessageManager
$parent_id = intval($parent_id);
$edit_message_id = intval($edit_message_id);
$topic_id = intval($topic_id);
$user_sender_id = api_get_user_id();
$total_filesize = 0;
@ -263,8 +262,6 @@ class MessageManager
$inbox_last_id = Database::insert_id();
}
// Save attachment file for inbox messages
if (is_array($file_attachments)) {
$i = 0;
@ -751,39 +748,27 @@ class MessageManager
$user_image = UserManager::get_picture_user($row['user_sender_id'], $from_user['picture_uri'],80);
$user_image = Display::img($user_image['file'], $name, array('title'=>$name));
$message_content = '<table>
<tr>
<td width="10px">&nbsp; </td>
<td width="100%">
<table>
<tr>
<td valign="top" width="100%">
'.Display::page_subheader(str_replace("\\","",$title)).'
</td>';
$message_content = Display::page_subheader(str_replace("\\","",$title));
if (api_get_setting('allow_social_tool') == 'true') {
$message_content .='<td width="100%">'.$user_image.'</td>';
$message_content .= $user_image.' ';
}
$message_content .='<tr>';
if (api_get_setting('allow_social_tool') == 'true') {
if ($source == 'outbox') {
$message_content .='<td>'.get_lang('From').': <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.GetFullUserName($row[2]).'</b> </td>';
$message_content .= get_lang('From').': <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.GetFullUserName($row[2]).'</b>';
} else {
$message_content .='<td>'.get_lang('From').' <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.get_lang('Me').'</b> </td>';
$message_content .= get_lang('From').' <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.get_lang('Me').'</b>';
}
} else {
if ($source == 'outbox') {
$message_content .='<td>'.get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.GetFullUserName($row['user_receiver_id']).'</b> </td>';
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.GetFullUserName($row['user_receiver_id']).'</b>';
} else {
$message_content .='<td>'.get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.get_lang('Me').'</b> </td>';
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.get_lang('Me').'</b>';
}
}
$message_content .='</tr>
<tr>
<td>'.get_lang('Date').': '.api_get_local_time($row['send_date']).'</td>
</tr>
</tr>
</table>
$message_content .=' '.get_lang('Date').': '.api_get_local_time($row['send_date']).'
<br />
<hr style="color:#ddd" />
<table height="209px" width="100%">
@ -1225,6 +1210,21 @@ class MessageManager
}
return $item;
}
function generate_message_form($id, $params = array()) {
$form = new FormValidator('send_message', null, 'post', null, array('id'=>$id.'_form'));
$form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id'));
$form->addElement('textarea', 'content', get_lang('Message'), array('id' => 'content_id', 'rows' => '5', 'class' => 'span4'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
return $div;
}
function generate_invitation_form($id , $params = array()) {
$form = new FormValidator('send_invitation', null, 'post', null, array('id'=>$id.'_form'));
//$form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id'));
$form->addElement('textarea', 'content', get_lang('AddPersonalMessage'), array('id' => 'content_invitation_id', 'rows' => '5', 'class' => 'span4'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
return $div;
}
}

@ -330,9 +330,9 @@ class SocialManager extends UserManager {
$count_is_true = self::send_invitation_friend(api_get_user_id(), $userfriend_id, $message_title, $content_message);
if ($count_is_true) {
echo Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
echo Display::display_confirmation_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
} else {
echo Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
echo Display::display_warning_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
}
}
}
@ -660,7 +660,7 @@ class SocialManager extends UserManager {
// My friend profile
if ($user_id != api_get_user_id()) {
$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?height=300&width=470&user_friend='.$user_id.'&view=profile&view_panel=1" class="ajax" title="'.get_lang('SendMessage').'">';
$html .= '<li><a href="javascript:void(0);" onclick="javascript:send_message_to_user(\''.$user_id.'\');" title="'.get_lang('SendMessage').'">';
$html .= Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
}
@ -671,7 +671,7 @@ class SocialManager extends UserManager {
$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('YouAlreadySentAnInvitation')).'&nbsp;&nbsp;'.get_lang('YouAlreadySentAnInvitation').'</a></li>';
} else {
if (!$show_full_profile) {
$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=230&width=500&user_friend='.$user_id.'" class="ajax" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a></li>';
$html .= '<li><a href="javascript:void(0);" onclick="javascript:send_invitation_to_user(\''.$user_id.'\');" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a></li>';
}
}
@ -822,81 +822,56 @@ class SocialManager extends UserManager {
$interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
Display::display_header($alt, null, $alt);
echo '<div>';
echo '<div style="margin:0 auto; width:350px; border:1px;">';
echo '<div id="whoisonline-user-image" style="float:left; padding:5px;">';
if (strlen(trim($user_object->picture_uri)) > 0) {
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
$webdir = $webdir_array['dir'];
$fullurl = $webdir.$user_object->picture_uri;
$system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30;
$width += 30;
// get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
echo '<input type="image" src="'.$fullurl.'" alt="'.$alt.'" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/><br />';
} else {
echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
echo '<br />';
}
if (!empty($status)) {
echo '<div style="text-align:center;padding-top:5px;">'.$status.'</div>';
}
echo '</div>';
echo '<div id="whoisonline-user-info" style="float:left; padding-left:15px;">';
echo '<div class ="thumbnail">';
if (strlen(trim($user_object->picture_uri)) > 0) {
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
$webdir = $webdir_array['dir'];
$fullurl = $webdir.$user_object->picture_uri;
$system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30;
$width += 30;
// get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
//echo '<a href="javascript:void()" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');" >';
echo '<img src="'.$fullurl.'" alt="'.$alt.'" />';
} else {
echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
}
if (!empty($status)) {
echo '<div class="caption">'.$status.'</div>';
}
echo '</div>';
global $user_anonymous;
if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
echo '<p><a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.Display :: return_icon('my_shared_profile.png', get_lang('SocialInvitationToFriends'),array('height'=>'18px')).get_lang('ViewSharedProfile').'</a></p>';
$user_anonymous = api_get_anonymous_id();
if (api_get_setting('show_email_addresses') == 'true') {
echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
}
if ($safe_user_id != api_get_user_id() && !api_is_anonymous($safe_user_id)) {
$user_relation = SocialManager::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
if ($user_relation == 0 || $user_relation == 6) {
echo '<p><a href="main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=300&width=610&user_friend='.$safe_user_id.'" class="ajax" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends'),array('height'=>'18px')).'&nbsp;'.get_lang('SendInvitation').'</a></p>
<p><a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="ajax" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage'),array('height'=>'18px')).'&nbsp;'.get_lang('SendAMessage').'</a></p>';
} else {
echo '<p><a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="ajax" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage'),array('height'=>'18px')).'&nbsp;'.get_lang('SendAMessage').'</a></p>';
}
}
}
if (api_get_setting('show_email_addresses') == 'true') {
echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="clear"></div>';
echo '<div>';
if ($user_object->competences) {
echo '<dt><div class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div></dt>';
echo '<dd>'.$user_object->competences.'</dd>';
echo Display::page_subheader(get_lang('MyCompetences'));
echo '<p>'.$user_object->competences.'</p>';
}
if ($user_object->diplomas) {
echo '<dt><div class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div></dt>';
echo '<dd>'.$user_object->diplomas.'</dd>';
echo Display::page_subheader(get_lang('MyDiplomas'));
echo '<p>'.$user_object->diplomas.'</p>';
}
if ($user_object->teach) {
echo '<dt><div class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div></dt>';
echo '<dd>'.$user_object->teach.'</dd>';;
echo Display::page_subheader(get_lang('MyTeach'));
echo '<p>'.$user_object->teach.'</p>';
}
SocialManager::display_productions($user_object->user_id);
if ($user_object->openarea) {
echo '<dt><div class="actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div></dt>';
echo '<dd>'.$user_object->openarea.'</dd>';
echo Display::page_subheader(get_lang('MyPersonalOpenArea'));
echo '<p>'.$user_object->openarea.'</p>';
}
echo '</div>';
} else {
Display::display_header(get_lang('UsersOnLineList'));
echo '<div class="actions-title">';
@ -904,6 +879,7 @@ class SocialManager extends UserManager {
echo '</div>';
}
}
/**
* Display productions in whoisonline
* @param int $user_id User id

@ -61,11 +61,86 @@ require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php';
require_once $libpath.'magpierss/rss_fetch.inc';
$ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
api_block_anonymous_users();
$htmlHeadXtra[] = '
<script type="text/javascript">
$htmlHeadXtra[] = '<script type="text/javascript">
function checkLength( o, n, min, max ) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
return false;
} else {
return true;
}
}
function send_message_to_user(user_id) {
$("#send_message_form").show();
$("#send_message_div").dialog("open");
$("#send_message_div").dialog({
buttons: {
"'. addslashes(get_lang('Sent')).'": function() {
var bValid = true;
//bValid = bValid && checkLength( subject, "subject", 1, 255 );
//bValid = bValid && checkLength( content, "content", 1, 255 );
var url = "'.$ajax_url.'?a=send_message&user_id="+user_id;
var params = $("#send_message_form").serialize();
$.ajax({
url: url+"&"+params,
success:function(data) {
$("#main_content").before(data);
$("#send_message_div").dialog({ buttons:{}});
//$("#send_message_reponse").html(data);
$("#send_message_form").hide();
$("#send_message_div").dialog("close");
$("#subject_id").val("");
$("#content_id").val("");
}
});
},
},
close: function() {
}
});
//prevent the browser to follow the link
}
function send_invitation_to_user(user_id) {
$("#send_invitation_form").show();
$("#send_invitation_div").dialog("open");
$("#send_invitation_div").dialog({
buttons: {
"'. addslashes(get_lang('SendInvitation')).'": function() {
var bValid = true;
//bValid = bValid && checkLength( subject, "subject", 1, 255 );
//bValid = bValid && checkLength( content, "content", 1, 255 );
var url = "'.$ajax_url.'?a=send_invitation&user_id="+user_id;
var params = $("#send_invitation_form").serialize();
$.ajax({
url: url+"&"+params,
success:function(data) {
$("#main_content").before(data);
$("#send_invitation_div").dialog({ buttons:{}});
$("#send_invitation_form").hide();
$("#send_invitation_div").dialog("close");
$("#content_invitation_id").val("");
}
});
},
},
close: function() {
}
});
//prevent the browser to follow the link
}
function toogle_course (element_html, course_code){
elem_id=$(element_html).attr("id");
id_elem=elem_id.split("_");
@ -97,14 +172,28 @@ function toogle_course (element_html, course_code){
}
});
}
</script>';
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready(function (){
$("input#id_btn_send_invitation").bind("click", function(){
if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
$("#form_register_friend").submit();
}
});
$("#send_message_div").dialog({
autoOpen: false,
modal : false,
width : 550,
height : 300
});
$("#send_invitation_div").dialog({
autoOpen: false,
modal : false,
width : 550,
height : 300
});
});
function change_panel (mypanel_id,myuser_id) {
$.ajax({
@ -137,7 +226,7 @@ function action_database_panel (option_id, myuser_id) {
url: "../messages/send_message.php",
data: "panel_id="+option_id+"&user_id="+myuser_id+"&txt_subject="+my_txt_subject+"&txt_content="+my_txt_content,
success: function(datos) {
$("#display_response_id").html(datos);
$("#display_response_id").html(datos);
}
});
}
@ -287,6 +376,8 @@ if ($show_full_profile) {
}
$friend_html.= '</div>'; // close div friend-header
$friend_html.='<ul class="thumbnails">';
$j=1;
for ($k=0;$k<$number_friends;$k++) {
if ($j > $number_of_images) break;
@ -297,24 +388,30 @@ if ($show_full_profile) {
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$status_icon = Display::div('', array('class' => 'online_user'));
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
} else {
$status_icon = Display::div('', array('class' => 'offline_user'));
$status_icon = Display::span('', array('class' => 'offline_user_in_text'));
}
$friend_html.= '<div id=div_'.$friend['friend_user_id'].' class="image_friend_network" >';
$friend_html.= $status_icon.'<span><center>';
//$friend_html.= '<div id=div_'.$friend['friend_user_id'].' class="image_friend_network" >';
$friend_html.= '<li class="span2">';
$friend_html.= '<div class="thumbnail">';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_MEDIUM , 'width="85" height="90" ');
$friend_html.= '<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
$friend_html.= '<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
$friend_html.= '</center></span>';
$friend_html.= '<center class="friend">'.$name_user.'</a></center>';
$friend_html.= '</div>';
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_ORIGINAL);
$friend_html.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
$friend_html.= '<div class="caption">';
$friend_html.= $status_icon.'<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
$friend_html.= $name_user;
$friend_html.= '</a></div>';
$friend_html.= '</div>';
$friend_html.= '</li>';
}
$j++;
}
$friend_html.='</ul>';
} else {
// No friends!! :(
$friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
@ -402,8 +499,6 @@ if ($show_full_profile) {
$social_right_content .= SocialManager::social_wrapper_div($extra_information, 9);
}
if ($show_full_profile) {
// MY GROUPS
@ -430,7 +525,7 @@ if ($show_full_profile) {
} else {
$count_users_group = $count_users_group.' '.get_lang('Members');
}
$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
//$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
$item_name = $url_open.$name.$icon.$url_close;
if ($result['description'] != '') {
@ -608,6 +703,9 @@ if ($show_full_profile) {
$social_right_content .= SocialManager::social_wrapper_div($more_info, 9);
}
}
$social_right_content .= MessageManager::generate_message_form('send_message');
$social_right_content .= MessageManager::generate_invitation_form('send_invitation');
$tpl = new Template(get_lang('Social'));
$tpl->assign('social_left_content', $social_left_content);

@ -423,7 +423,6 @@ $(document).ready(function() {
</div>
</div>
{/if}
<div id="visible_to_read_only" class="control-group" style="display:none">
<label class="control-label" for="date">{"To"|get_lang}</label>
<div class="controls">

Loading…
Cancel
Save