Social network permission fixes , Friend tab should work (deleting a contact) see #190

skala
Julio Montoya 16 years ago
parent eb3bbc80b4
commit fc65aa01b3
  1. 4
      main/inc/ajax/message.ajax.php
  2. 146
      main/inc/ajax/social.ajax.php
  3. 88
      main/inc/lib/social.lib.php
  4. 3
      main/messages/new_message.php
  5. 45
      main/messages/send_message.php
  6. 2
      main/messages/send_message_to_userfriend.inc.php
  7. 84
      main/social/friends.php
  8. 4
      main/social/invitations.php
  9. 14
      main/social/profile.php
  10. 51
      main/social/register_friend.php
  11. 58
      main/social/show_search_image.inc.php

@ -53,7 +53,9 @@ switch ($action) {
}
}
echo json_encode($return);
break;
break;
default:
echo '';

@ -0,0 +1,146 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
* Responses to AJAX calls
*/
require_once '../global.inc.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php';
$action = $_GET['a'];
$current_user_id = api_get_user_id();
switch ($action) {
case 'add_friend':
if (api_is_anonymous()){
echo '';
break;
}
$my_current_friend = Security::remove_XSS($_POST['friend_id']);
$my_denied_current_friend= Security::remove_XSS($_POST['denied_friend_id']);
$my_delete_friend = Security::remove_XSS($_POST['delete_friend_id']);
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']);
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered?
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered?
if (isset($_POST['is_my_friend'])) {
$relation_type=SOCIALFRIEND;//my friend
} else {
$relation_type=SOCIALUNKNOW;//Contact unknown
}
if (isset($_POST['friend_id'])) {
SocialManager::register_friend($current_user_id,$my_current_friend,$relation_type);
SocialManager::register_friend($my_current_friend,$current_user_id,$relation_type);
SocialManager::invitation_accepted($my_current_friend,$current_user_id);
if (isset($_POST['is_my_friend'])) {
echo api_xml_http_response_encode(get_lang('AddedContactToList'));
} else {
Display::display_normal_message(api_xml_http_response_encode(get_lang('AddedContactToList')));
}
}
case 'deny_friend':
if (api_is_anonymous()){
echo '';
break;
}
$my_current_friend = Security::remove_XSS($_POST['friend_id']);
$my_denied_current_friend= Security::remove_XSS($_POST['denied_friend_id']);
$my_delete_friend = Security::remove_XSS($_POST['delete_friend_id']);
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']);
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered?
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered?
if (isset($_POST['is_my_friend'])) {
$relation_type=SOCIALFRIEND;//my friend
} else {
$relation_type=SOCIALUNKNOW;//Contact unknown
}
if (isset($_POST['denied_friend_id'])) {
SocialManager::invitation_denied($my_denied_current_friend,$current_user_id);
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('InvitationDenied')));
}
break;
case 'delete_friend':
if (api_is_anonymous()){
echo '';
break;
}
$my_current_friend = Security::remove_XSS($_POST['friend_id']);
$my_denied_current_friend= Security::remove_XSS($_POST['denied_friend_id']);
$my_delete_friend = Security::remove_XSS($_POST['delete_friend_id']);
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']);
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered?
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered?
if (isset($_POST['delete_friend_id'])) {
SocialManager::removed_friend($my_delete_friend);
}
/*
if(isset($_POST['user_id_friend_q']) && isset($_POST['type_friend_q'])) {
SocialManager::qualify_friend($friend_id_qualify,$type_friend_qualify);
echo api_xml_http_response_encode(get_lang('AttachContactsToGroupSuccesfuly'));
}*/
break;
case 'show_my_friends':
if (api_is_anonymous()){
echo '';
break;
}
$list_path_friends = array();
$user_id = api_get_user_id();
$name_search= Security::remove_XSS($_POST['search_name_q']);
$number_friends = 0;
if (isset($name_search) && $name_search!='undefined') {
$friends = SocialManager::get_friends($user_id,null,$name_search);
} else {
$friends = SocialManager::get_friends($user_id);
}
$friend_html = '';
$number_of_images = 8;
$number_friends = count($friends);
if ($number_friends != 0) {
$number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop);
$j=0;
$friend_html.= '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="" >';
for ($k=0;$k<$loop_friends;$k++) {
$friend_html.='<tr><td valign="top">';
if ($j==$number_of_images) {
$number_of_images=$number_of_images*2;
}
while ($j<$number_of_images) {
if (isset($friends[$j])) {
$friend = $friends[$j];
$user_name = api_xml_http_response_encode($friend['firstName'], $friend['lastName']);
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
$friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
$friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
$friend_html.='<img onclick="delete_friend (this)" id=img_'.$friend['friend_user_id'].' src="../img/blank.gif" alt="" title="" class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';
}
$j++;
}
$friend_html.='</td></tr>';
}
$friend_html.='<br/></table>';
}
echo $friend_html;
break;
default:
echo '';
}
exit;
?>

@ -12,18 +12,18 @@
// Relation type between users
define('USERUNKNOW', '0');
define('SOCIALUNKNOW', '1');
define('SOCIALPARENT', '2');
define('SOCIALFRIEND', '3');
define('SOCIALGOODFRIEND','4');
define('SOCIALENEMY', '5');
define('SOCIALDELETED', '6');
define('USERUNKNOW', 0);
define('SOCIALUNKNOW', 1);
define('SOCIALPARENT', 2);
define('SOCIALFRIEND', 3);
define('SOCIALGOODFRIEND', 4);
define('SOCIALENEMY', 5);
define('SOCIALDELETED', 6);
//PLUGIN PLACES
define('SOCIAL_LEFT_PLUGIN', '1');
define('SOCIAL_CENTER_PLUGIN', '2');
define('SOCIAL_RIGHT_PLUGIN', '3');
define('SOCIAL_LEFT_PLUGIN', 1);
define('SOCIAL_CENTER_PLUGIN', 2);
define('SOCIAL_RIGHT_PLUGIN', 3);
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'message.lib.php';
@ -33,14 +33,12 @@ class SocialManager extends UserManager {
private function __construct() {
}
/**
* Allow to register contact to social network
* @author isaac flores paz <isaac.flores@dokeos.com>
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
* @param int user friend id
* @param int user id
* @param int relation between users see constants definition
* @return void
*/
public static function register_friend ($friend_id,$my_user_id,$relation_type) {
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
@ -50,27 +48,27 @@ class SocialManager extends UserManager {
$relation_type = intval($relation_type);
$sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE friend_user_id=' .$friend_id.' AND user_id='.$my_user_id;
$result = Database::query($sql, __FILE__, __LINE__);
$row = Database :: fetch_array($result, 'ASSOC');
error_log('1'.$row['count']);
if ($row['count'] == 0) {
$current_date=date('Y-m-d H:i:s');
$sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . $friend_id . ','.$my_user_id.','.$relation_type.',"'.$current_date.'");';
error_log($sql_i);
Database::query($sql_i, __FILE__, __LINE__);
return true;
} else {
$sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE friend_user_id=' . $friend_id . ' AND user_id='.$my_user_id;
$result = Database::query($sql, __FILE__, __LINE__);
$row = Database :: fetch_array($result, 'ASSOC');
error_log($row['count']);
if ($row['count'] == 1) {
$sql_i = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.$relation_type.' WHERE friend_user_id=' . $friend_id.' AND user_id='.$my_user_id;
error_log($sql_i);
$sql_i = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.$relation_type.' WHERE friend_user_id=' . $friend_id.' AND user_id='.$my_user_id;
Database::query($sql_i, __FILE__, __LINE__);
}
return true;
} else {
return false;
}
}
}
/**
@ -91,6 +89,10 @@ class SocialManager extends UserManager {
$sql_delete_relationship1 = 'UPDATE ' . $tbl_my_friend .' SET relation_type='.SOCIALDELETED.' WHERE friend_user_id='.$friend_id;
$sql_delete_relationship2 = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.SOCIALDELETED.' WHERE user_id=' . $friend_id;
// $sql_delete_relationship1 = 'DELETE FROM ' . $tbl_my_friend .' WHERE friend_user_id='.$friend_id;
//$sql_delete_relationship2 = 'DELETE FROM ' . $tbl_my_friend . ' WHERE user_id=' . $friend_id;
Database::query($sql_delete_relationship1, __FILE__, __LINE__);
Database::query($sql_delete_relationship2, __FILE__, __LINE__);
@ -141,9 +143,9 @@ class SocialManager extends UserManager {
}
/**
* Get relation type contact by name
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @param string names of the kind of relation
* @return int
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/
public static function get_relation_type_by_name ($relation_type_name) {
$list_type_friend=array();
@ -156,10 +158,10 @@ class SocialManager extends UserManager {
}
/**
* Get the kind of relation between contacts
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @param int user id
* @param int user friend id
* @param string
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/
public static function get_relation_between_contacts ($user_id,$user_friend) {
$tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
@ -174,6 +176,7 @@ class SocialManager extends UserManager {
return USERUNKNOW;
}
}
/**
* Gets friends id list
* @param int user id
@ -211,11 +214,11 @@ class SocialManager extends UserManager {
/**
* get list web path of contacts by user id
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @param int user id
* @param int group id
* @param string name to search
* @param array
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/
public static function get_list_path_web_by_user_id ($user_id,$id_group=null,$search_name=null) {
$list_paths=array();
@ -230,7 +233,8 @@ class SocialManager extends UserManager {
}
}
return $combine_friend;
}
}
/**
* get web path of user invitate
* @author isaac flores paz <florespaz@bidsoftperu.com>
@ -247,17 +251,15 @@ class SocialManager extends UserManager {
return $list_path_image_friend;
}
/**
* Sends an invitation to contacts
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
* @param int user id
* @param int user friend id
* @param string title of the message
* @param string content of the message
* @return boolean
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
*/
public static function send_invitation_friend ($user_id,$friend_id,$message_title,$message_content) {
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
@ -266,18 +268,17 @@ class SocialManager extends UserManager {
$message_title = Database::escape_string($message_title);
$message_content = Database::escape_string($message_content);
$current_date = date('Y-m-d H:i:s',time());
$status_invitation=5;//status of pending invitation
$sql_exist='SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.($user_id).' AND user_receiver_id='.($friend_id).' AND msg_status IN(5,6,7);';
error_log($sql_exist);
$current_date = date('Y-m-d H:i:s',time());
echo $sql_exist='SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.($user_id).' AND user_receiver_id='.($friend_id).' AND msg_status IN(5,6,7);';
$res_exist=Database::query($sql_exist,__FILE__,__LINE__);
$row_exist=Database::fetch_array($res_exist,'ASSOC');
if ($row_exist['count']==0) {
$sql='INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content) VALUES('.$user_id.','.$friend_id.','.$status_invitation.',"'.$current_date.'","'.$message_title.'","'.$message_content.'")';
if ($row_exist['count']==0) {
$sql='INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content) VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$current_date.'","'.$message_title.'","'.$message_content.'")';
Database::query($sql,__FILE__,__LINE__);
return true;
} elseif ($row_exist['count']==1) {
} else {
//invitation already exist
$sql_if_exist='SELECT COUNT(*) AS count 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_if_exist,__FILE__,__LINE__);
@ -289,11 +290,7 @@ class SocialManager extends UserManager {
} else {
return false;
}
} else {
return false;
}
}
/**
* Get number messages of the inbox
@ -302,9 +299,8 @@ class SocialManager extends UserManager {
* @return int
*/
public static function get_message_number_invitation_by_user_id ($user_receiver_id) {
$status_invitation=5;//status of pending invitation
$tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
$sql='SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.' WHERE user_receiver_id='.((int)$user_receiver_id).' AND msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
$sql='SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.' WHERE user_receiver_id='.intval($user_receiver_id).' AND msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
$res=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($res,'ASSOC');
return $row['count_message_in_box'];
@ -397,8 +393,7 @@ class SocialManager extends UserManager {
$user_info = api_get_user_info($userfriend_id);
$succes = get_lang('MessageSentTo');
$succes.= ' : '.api_get_person_name($user_info['firstName'], $user_info['lastName']);
if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
error_log('1');
if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
$send_message = MessageManager::send_message($userfriend_id, $subject_message, $content_message);
if ($send_message) {
echo Display::display_confirmation_message($succes,true);
@ -406,8 +401,7 @@ class SocialManager extends UserManager {
echo Display::display_error_message($succes,true);
}
exit;
} elseif (isset($userfriend_id) && !isset($subject_message)) {
error_log('2');
} elseif (isset($userfriend_id) && !isset($subject_message)) {
$count_is_true=false;
$count_number_is_true=0;
if (isset($userfriend_id) && $userfriend_id>0) {
@ -487,7 +481,7 @@ class SocialManager extends UserManager {
$course_teacher = $my_course['t'];
$course_teacher_email = isset($my_course['email'])?$my_course['email']:'';
$course_info = Database :: get_course_info($course_system_code);
//error_log(print_r($course_info,true));
$course_access_settings = CourseManager :: get_access_settings($course_system_code);
$course_visibility = $course_access_settings['visibility'];

@ -49,9 +49,8 @@ function validate(form,list) {
</script>';
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready(function (){

@ -17,41 +17,58 @@ $panel_id = intval($_POST['panel_id']);
$content_message = Security::remove_XSS($_POST['txt_content'],COURSEMANAGERLOWSECURITY); //check this is filtered on output
$subject_message = Security::remove_XSS($_POST['txt_subject']); //check this is filtered on output
$user_info = array();
$user_info = api_get_user_info($user_id);
if ($panel_id==2) {
if ($panel_id == 2 || $panel_id == 4 ) {
if (empty($content_message)) {
?>
<td height="20"><?php //echo api_xml_http_response_encode(get_lang('Info')).' :'; ?></td>
<td height="20"><?php //echo api_xml_http_response_encode(get_lang('SocialUserInformationAttach')); ?></td>
<td height="20"><?php echo api_xml_http_response_encode(get_lang('WriteAMessage')); ?> :<br/><textarea id="txt_area_invite" rows="3" cols="25"></textarea></td>
<td height="20"><input type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendInviteMessage')); ?>" onclick="action_database_panel('4','<?php echo $user_id;?>')" /></td>
<div id="display_response_id" style="height:200px;">
<?php echo api_xml_http_response_encode(get_lang('AddPersonalMessage')); ?> :<br /><br />
<textarea id="txt_area_invite" rows="5" cols="40"></textarea><br />
<?php echo api_xml_http_response_encode(get_lang('YouShouldWriteAMessage')); ?><br /><br />
<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $user_id;?>')" >
<?php echo api_xml_http_response_encode(get_lang('SendInvitation')) ?></button>
</div>
<?php
}
if ($panel_id==1) {
}
} elseif ($panel_id==1) {
if (empty($content_message) || empty($subject_message)) {
?>
<td height="20"><?php echo api_xml_http_response_encode(get_lang('To')); ?> &nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?></td>
<td height="20"><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br/><input id="txt_subject_id" type="text" style="width:200px;"></td>
<td height="20"><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br/><textarea id="txt_area_invite" rows="3" cols="25"></textarea></td>
<td height="20"><input type="button" value="<?php echo api_xml_http_response_encode(get_lang('NewMessage')); ?>" onclick="hide_display_message()" />&nbsp;&nbsp;&nbsp; <input type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $user_id;?>')" /></td>
<?php
}
if ($panel_id==3) {
}
}elseif ($panel_id==3) {
?>
<dl>
<dd><a href="javascript:void(0)" onclick="change_panel('2','<?php echo $user_id; ?>')"><?php echo api_xml_http_response_encode(get_lang('SendInviteMessage')); ?></a></dd>
<dd><a href="javascript:void(0)" onclick="change_panel('1','<?php echo $user_id; ?>')"><?php echo api_xml_http_response_encode(get_lang('SendMessage'));?></a></dd>
</dl>
<?php
// <dd><a href="'.api_get_path(WEB_PATH).'main/social/index.php#remote-tab-5"> echo api_xml_http_response_encode(get_lang('SocialSeeContacts'));</a></dd>
}elseif($panel_id == 5 && empty($content_message)) {
?>
<div id="display_response_id" style="height:200px;">
<?php echo api_xml_http_response_encode(get_lang('To')); ?> :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?>
<br />
<br /><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br /><input id="txt_subject_id" type="text" style="width:300px;"><br/>
<br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br /><textarea id="txt_area_invite" rows="4" cols="40"></textarea>
<?php echo api_xml_http_response_encode(get_lang('YouShouldWriteAMessage')); ?><br />
<br />
<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $user_id;?>')">
<?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
</div>
<?php
}
if ($panel_id==4) {
if ($panel_id==4 && !empty($content_message)) {
if ($subject_message=='clear') {
$subject_message=null;
}
}
SocialManager::send_invitation_friend_user($user_id,$subject_message,$content_message);
} elseif ($panel_id==5) {
} elseif ($panel_id==5 && !empty($content_message) ) {
SocialManager::send_invitation_friend_user($user_id,$subject_message,$content_message);
}
?>

@ -62,7 +62,7 @@ if ( isset($_REQUEST['user_friend']) ) {
<?= api_xml_http_response_encode(get_lang('AddPersonalMessage')); ?> :<br /><br />
<textarea id="txt_area_invite" rows="5" cols="40"></textarea><br /><br />
<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $userfriend_id;?>')" >
<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')) ?></button>
<?php echo api_xml_http_response_encode(get_lang('SendInvitation')) ?></button>
</div>
<?php
}

@ -20,33 +20,13 @@ api_block_anonymous_users();
$this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-1.1.3.1.pack.js" type="text/javascript"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.history_remote.pack.js" type="text/javascript"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.tabs.pack.js" type="text/javascript"></script>';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-1.1.3.1.pack.js" type="text/javascript"></script>';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.history_remote.pack.js" type="text/javascript"></script>';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.tabs.pack.js" type="text/javascript"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<script type="text/javascript">
function add_group (my_action,name_rs) {
if(my_action=="show") {
$("div#div_content_messages").html("");
$("div#div_content_table_data").html("");
$(".confirmation-message").remove();
$(".normal-message").remove();
$(".error-message").remove();
$.ajax({
contentType: "application/x-www-form-urlencoded",
type: "GET",
url: "group_add.php",
data:"rs="+name_rs,
success: function(datos) {
$("div#div_add_group").html(datos);
}
});
}
}
function delete_friend (element_div) {
id_image=$(element_div).attr("id");
@ -55,10 +35,9 @@ function delete_friend (element_div) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
type: "POST",
url: "../social/register_friend.php",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=delete_friend",
data: "delete_friend_id="+user_id[1],
success: function(datos) {
//alert(datos);
$("div#"+"div_"+user_id[1]).hide("slow");
$("div#"+"div_"+user_id[1]).html("");
clear_form ();
@ -70,13 +49,12 @@ function delete_friend (element_div) {
function search_image_social(element_html) {
name_search=$(element_html).attr("value");
$.ajax({
contentType: "application/x-www-form-urlencoded",
type: "POST",
url: "../social/show_search_image.inc.php",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=show_my_friends",
data: "search_name_q="+name_search,
success: function(datos) {
$("div#div_content_table").html(datos);
@ -120,14 +98,9 @@ echo '<div class="actions-title">';
echo get_lang('MyFriends');
echo '</div>';
//$list_path_friends=array();
$request=api_is_xml_http_request();
$language_variable=api_xml_http_response_encode(get_lang('Contacts'));
//api_display_tool_title($language_variable);
$language_variable = api_xml_http_response_encode(get_lang('Contacts'));
$user_id = api_get_user_id();
$user_id=api_get_user_id();
$image_path = UserManager::get_user_picture_path_by_id ($user_id,'web',false,true);
?>
<div align="center" >
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
@ -148,7 +121,48 @@ $image_path = UserManager::get_user_picture_path_by_id ($user_id,'web',false,tru
<td height="153" valign="top">
<?php
echo '<div id="div_content_table">';
require_once 'show_search_image.inc.php';
$list_path_friends = array();
$user_id = api_get_user_id();
$name_search= Security::remove_XSS($_POST['search_name_q']);
$number_friends = 0;
if (isset($name_search) && $name_search!='undefined') {
$friends = SocialManager::get_friends($user_id,null,$name_search);
} else {
$friends = SocialManager::get_friends($user_id);
}
$friend_html = '';
$number_of_images = 8;
$number_friends = count($friends);
if ($number_friends != 0) {
$number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop);
$j=0;
$friend_html.= '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="" >';
for ($k=0;$k<$loop_friends;$k++) {
$friend_html.='<tr><td valign="top">';
if ($j==$number_of_images) {
$number_of_images=$number_of_images*2;
}
while ($j<$number_of_images) {
if (isset($friends[$j])) {
$friend = $friends[$j];
$user_name = api_xml_http_response_encode($friend['firstName'], $friend['lastName']);
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
$friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
$friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
$friend_html.='<img onclick="delete_friend (this)" id=img_'.$friend['friend_user_id'].' src="../img/blank.gif" alt="" title="" class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';
}
$j++;
}
$friend_html.='</td></tr>';
}
$friend_html.='<br/></table>';
}
echo $friend_html;
echo '</div>';
?>
</td>

@ -34,7 +34,7 @@ function denied_friend (element_input) {
beforeSend: function(objeto) {
$("#id_response").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "../social/register_friend.php",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=deny_friend",
data: "denied_friend_id="+friend_user_id,
success: function(datos) {
$("div#"+name_div_id).hide("slow");
@ -53,7 +53,7 @@ function register_friend(element_input) {
beforeSend: function(objeto) {
$("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "../social/register_friend.php",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
success: function(datos) { $("div#"+name_div_id).hide("slow");
$("form").submit()

@ -122,19 +122,15 @@ function change_panel (mypanel_id,myuser_id) {
}
});
}
function action_database_panel (option_id,myuser_id) {
function action_database_panel (option_id, myuser_id) {
if (option_id==5) {
my_txt_subject=$("#txt_subject_id").val();
} else {
my_txt_subject="clear";
}
my_txt_content=$("#txt_area_invite").val();
if (my_txt_content.length==0 || my_txt_subject.length==0) {
$("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageInvitationNotSent', '').'");
setTimeout("message_information_display()",3000);
return false;
}
my_txt_content=$("#txt_area_invite").val();
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
@ -173,7 +169,7 @@ function register_friend(element_input) {
beforeSend: function(objeto) {
$("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "../social/register_friend.php",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
success: function(datos) {
$("form").submit()
@ -471,7 +467,7 @@ echo '<div id="social-profile-container">';
}
//check if I already sent an invitation message
$invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id());
if (is_array($invitation_sent_list) && is_array($invitation_sent_list[$user_id]) && count($invitation_sent_list[$user_id]) >0 ) {
$html_actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('YouAlreadySentAnInvitation').'</a>';
} else {

@ -1,51 +0,0 @@
<?php //$id: $
/* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
// names of the language files that needs to be included
$language_file = array('registration','messages','userInfo','admin');
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'image.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php';
$the_current_user_id = api_get_user_id();
$my_current_friend = Security::remove_XSS($_POST['friend_id']);
$my_denied_current_friend= Security::remove_XSS($_POST['denied_friend_id']);
$my_delete_friend = Security::remove_XSS($_POST['delete_friend_id']);
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']);
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered?
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered?
if (isset($_POST['is_my_friend'])) {
$relation_type=SOCIALFRIEND;//my friend
} else {
$relation_type=SOCIALUNKNOW;//Contact unknown
}
if (isset($_POST['friend_id'])) {
SocialManager::register_friend($the_current_user_id,$my_current_friend,$relation_type);
SocialManager::register_friend($my_current_friend,$the_current_user_id,$relation_type);
SocialManager::invitation_accepted($my_current_friend,$the_current_user_id);
if (isset($_POST['is_my_friend'])) {
echo api_xml_http_response_encode(get_lang('AddedContactToList'));
} else {
Display::display_normal_message(api_xml_http_response_encode(get_lang('AddedContactToList')));
}
}
if (isset($_POST['denied_friend_id'])) {
SocialManager::invitation_denied($my_denied_current_friend,$the_current_user_id);
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('InvitationDenied')));
}
if (isset($_POST['delete_friend_id'])) {
SocialManager::removed_friend($my_delete_friend);
}
if(isset($_POST['user_id_friend_q']) && isset($_POST['type_friend_q'])) {
SocialManager::qualify_friend($friend_id_qualify,$type_friend_qualify);
echo api_xml_http_response_encode(get_lang('AttachContactsToGroupSuccesfuly'));
}
?>

@ -1,58 +0,0 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require '../inc/global.inc.php';
$language_file = array('registration','messages','userInfo','admin');
require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'image.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once '../inc/lib/social.lib.php';
$list_path_friends = array();
$user_id = api_get_user_id();
$name_search= Security::remove_XSS($_POST['search_name_q']);
$number_friends = 0;
if (isset($name_search) && $name_search!='undefined') {
$friends = SocialManager::get_friends($user_id,null,$name_search);
} else {
$friends = SocialManager::get_friends($user_id);
}
$friend_html = '';
$number_of_images = 8;
$number_friends = count($friends);
if ($number_friends != 0) {
$number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop);
$j=0;
$friend_html.= '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="" >';
for ($k=0;$k<$loop_friends;$k++) {
$friend_html.='<tr><td valign="top">';
if ($j==$number_of_images) {
$number_of_images=$number_of_images*2;
}
while ($j<$number_of_images) {
if (isset($friends[$j])) {
$friend = $friends[$j];
$user_name = api_xml_http_response_encode($friend['firstName'], $friend['lastName']);
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
$friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$list_friends_id[$j].'>';
$friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
$friend_html.='<img onclick="delete_friend (this)" id=img_'.$friend['friend_user_id'].' src="../img/blank.gif" alt="" title="" class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';
}
$j++;
}
$friend_html.='</td></tr>';
}
$friend_html.='<br/></table>';
}
echo $friend_html;
?>
Loading…
Cancel
Save