parent
c1d32bde0f
commit
50960831c0
@ -1,201 +1,197 @@ |
|||||||
<?php |
<?php |
||||||
/* For licensing terms, see /chamilo_license.txt */ |
/* For licensing terms, see /chamilo_license.txt */ |
||||||
/** |
/** |
||||||
* Responses to AJAX calls |
* Responses to AJAX calls |
||||||
*/ |
*/ |
||||||
$language_file = array('messages','userInfo'); |
$language_file = array('messages','userInfo'); |
||||||
require_once '../global.inc.php'; |
require_once '../global.inc.php'; |
||||||
|
|
||||||
$action = isset($_GET['a']) ? $_GET['a'] : null; |
$action = isset($_GET['a']) ? $_GET['a'] : null; |
||||||
|
|
||||||
$current_user_id = api_get_user_id(); |
$current_user_id = api_get_user_id(); |
||||||
switch ($action) { |
switch ($action) { |
||||||
case 'add_friend': |
case 'add_friend': |
||||||
if (api_is_anonymous()) { |
if (api_is_anonymous()) { |
||||||
echo ''; |
echo ''; |
||||||
break; |
break; |
||||||
} |
} |
||||||
|
|
||||||
$my_current_friend = Security::remove_XSS($_POST['friend_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']); |
if (isset($_POST['is_my_friend'])) { |
||||||
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']); |
$relation_type = USER_RELATION_TYPE_FRIEND; //My friend |
||||||
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered? |
} else { |
||||||
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered? |
$relation_type = USER_RELATION_TYPE_UNKNOW; //Unknown contact |
||||||
|
} |
||||||
if (isset($_POST['is_my_friend'])) { |
|
||||||
$relation_type = USER_RELATION_TYPE_FRIEND; //My friend |
if (isset($_POST['friend_id'])) { |
||||||
} else { |
UserManager::relate_users($current_user_id, $my_current_friend, $relation_type); |
||||||
$relation_type = USER_RELATION_TYPE_UNKNOW; //Unknown contact |
UserManager::relate_users($my_current_friend, $current_user_id, $relation_type); |
||||||
} |
SocialManager::invitation_accepted($my_current_friend, $current_user_id); |
||||||
|
Display::display_normal_message(api_xml_http_response_encode(get_lang('AddedContactToList'))); |
||||||
if (isset($_POST['friend_id'])) { |
} |
||||||
UserManager::relate_users($current_user_id,$my_current_friend,$relation_type); |
break; |
||||||
UserManager::relate_users($my_current_friend,$current_user_id,$relation_type); |
case 'deny_friend': |
||||||
SocialManager::invitation_accepted($my_current_friend,$current_user_id); |
if (api_is_anonymous()) { |
||||||
Display::display_normal_message(api_xml_http_response_encode(get_lang('AddedContactToList'))); |
echo ''; |
||||||
} |
break; |
||||||
break; |
} |
||||||
case 'deny_friend': |
$my_current_friend = Security::remove_XSS($_POST['friend_id']); |
||||||
if (api_is_anonymous()){ |
$my_denied_current_friend= Security::remove_XSS($_POST['denied_friend_id']); |
||||||
echo ''; |
$my_delete_friend = Security::remove_XSS($_POST['delete_friend_id']); |
||||||
break; |
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']); |
||||||
} |
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered? |
||||||
$my_current_friend = Security::remove_XSS($_POST['friend_id']); |
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered? |
||||||
$my_denied_current_friend= Security::remove_XSS($_POST['denied_friend_id']); |
if (isset($_POST['is_my_friend'])) { |
||||||
$my_delete_friend = Security::remove_XSS($_POST['delete_friend_id']); |
$relation_type=USER_RELATION_TYPE_FRIEND;//my friend |
||||||
$friend_id_qualify = Security::remove_XSS($_POST['user_id_friend_q']); |
} else { |
||||||
$type_friend_qualify = Security::remove_XSS($_POST['type_friend_q']); //filtered? |
$relation_type=USER_RELATION_TYPE_UNKNOW;//Contact unknown |
||||||
$is_my_friend = Security::remove_XSS($_POST['is_my_friend']); //filtered? |
} |
||||||
if (isset($_POST['is_my_friend'])) { |
if (isset($_POST['denied_friend_id'])) { |
||||||
$relation_type=USER_RELATION_TYPE_FRIEND;//my friend |
SocialManager::invitation_denied($my_denied_current_friend, $current_user_id); |
||||||
} else { |
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('InvitationDenied'))); |
||||||
$relation_type=USER_RELATION_TYPE_UNKNOW;//Contact unknown |
} |
||||||
} |
break; |
||||||
if (isset($_POST['denied_friend_id'])) { |
case 'delete_friend': |
||||||
SocialManager::invitation_denied($my_denied_current_friend,$current_user_id); |
if (api_is_anonymous()) { |
||||||
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('InvitationDenied'))); |
echo ''; |
||||||
} |
break; |
||||||
break; |
} |
||||||
case 'delete_friend': |
$my_delete_friend = intval($_POST['delete_friend_id']); |
||||||
if (api_is_anonymous()) { |
if (isset($_POST['delete_friend_id'])) { |
||||||
echo ''; |
SocialManager::remove_user_rel_user($my_delete_friend); |
||||||
break; |
} |
||||||
} |
break; |
||||||
$my_delete_friend = intval($_POST['delete_friend_id']); |
case 'show_my_friends': |
||||||
if (isset($_POST['delete_friend_id'])) { |
if (api_is_anonymous()) { |
||||||
SocialManager::remove_user_rel_user($my_delete_friend); |
echo ''; |
||||||
} |
break; |
||||||
break; |
} |
||||||
case 'show_my_friends': |
$user_id = api_get_user_id(); |
||||||
if (api_is_anonymous()) { |
$name_search= Security::remove_XSS($_POST['search_name_q']); |
||||||
echo ''; |
$number_friends = 0; |
||||||
break; |
|
||||||
} |
if (isset($name_search) && $name_search != 'undefined') { |
||||||
$user_id = api_get_user_id(); |
$friends = SocialManager::get_friends($user_id, null, $name_search); |
||||||
$name_search= Security::remove_XSS($_POST['search_name_q']); |
} else { |
||||||
$number_friends = 0; |
$friends = SocialManager::get_friends($user_id); |
||||||
|
} |
||||||
if (isset($name_search) && $name_search != 'undefined') { |
|
||||||
$friends = SocialManager::get_friends($user_id, null, $name_search); |
$friend_html = ''; |
||||||
} else { |
$number_of_images = 8; |
||||||
$friends = SocialManager::get_friends($user_id); |
|
||||||
} |
$number_friends = count($friends); |
||||||
|
if ($number_friends != 0) { |
||||||
$friend_html = ''; |
$number_loop = ($number_friends/$number_of_images); |
||||||
$number_of_images = 8; |
$loop_friends = ceil($number_loop); |
||||||
|
$j=0; |
||||||
$number_friends = count($friends); |
$friend_html.= '<ul class="thumbnails">'; |
||||||
if ($number_friends != 0) { |
for ($k=0; $k<$loop_friends; $k++) { |
||||||
$number_loop = ($number_friends/$number_of_images); |
if ($j==$number_of_images) { |
||||||
$loop_friends = ceil($number_loop); |
$number_of_images=$number_of_images*2; |
||||||
$j=0; |
} |
||||||
$friend_html.= '<ul class="thumbnails">'; |
while ($j<$number_of_images) { |
||||||
for ($k=0;$k<$loop_friends;$k++) { |
if (isset($friends[$j])) { |
||||||
if ($j==$number_of_images) { |
|
||||||
$number_of_images=$number_of_images*2; |
|
||||||
} |
|
||||||
while ($j<$number_of_images) { |
|
||||||
if (isset($friends[$j])) { |
|
||||||
$friend_html.='<li class="span2">'; |
$friend_html.='<li class="span2">'; |
||||||
$friend = $friends[$j]; |
$friend = $friends[$j]; |
||||||
$user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']); |
$user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']); |
||||||
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92); |
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92); |
||||||
$friend_html.='<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>'; |
$friend_html.='<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>'; |
||||||
$friend_html.='<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" />'; |
$friend_html.='<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" />'; |
||||||
$friend_html.='<div class="caption">'; |
$friend_html.='<div class="caption">'; |
||||||
$friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'"><h5>'.$user_name.'</h5></a>'; |
$friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'"><h5>'.$user_name.'</h5></a>'; |
||||||
$friend_html.='<p><button class="btn" onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].'>'.get_lang('Delete').'</button></p>'; |
$friend_html.='<p><button class="btn" onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].'>'.get_lang('Delete').'</button></p>'; |
||||||
$friend_html.='</div>'; |
$friend_html.='</div>'; |
||||||
$friend_html.='</div>'; |
$friend_html.='</div>'; |
||||||
|
|
||||||
$friend_html.='</li>'; |
$friend_html.='</li>'; |
||||||
} |
} |
||||||
$j++; |
$j++; |
||||||
} |
} |
||||||
} |
} |
||||||
$friend_html.='</ul>'; |
$friend_html.='</ul>'; |
||||||
} |
} |
||||||
echo $friend_html; |
echo $friend_html; |
||||||
break; |
break; |
||||||
case 'toogle_course': |
case 'toogle_course': |
||||||
if (api_is_anonymous()){ |
if (api_is_anonymous()) { |
||||||
echo ''; |
echo ''; |
||||||
break; |
break; |
||||||
} |
} |
||||||
require_once api_get_path(LIBRARY_PATH).'blog.lib.php'; |
require_once api_get_path(LIBRARY_PATH).'blog.lib.php'; |
||||||
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
||||||
|
|
||||||
$user_id = intval($_SESSION['social_user_id']); |
$user_id = intval($_SESSION['social_user_id']); |
||||||
|
|
||||||
if ($_POST['action']) {$action = $_POST['action'];} |
if ($_POST['action']) { |
||||||
|
$action = $_POST['action']; |
||||||
switch ($action) { |
} |
||||||
case 'load_course' : |
|
||||||
$course_id = intval($_POST['course_code']); // the int course id |
switch ($action) { |
||||||
$course_info = api_get_course_info_by_id($course_id); |
case 'load_course': |
||||||
$course_code = $course_info['code']; |
$course_id = intval($_POST['course_code']); // the int course id |
||||||
|
$course_info = api_get_course_info_by_id($course_id); |
||||||
if (api_is_user_of_course($course_code, api_get_user_id())) { |
$course_code = $course_info['code']; |
||||||
//------Forum messages |
|
||||||
$forum_result = get_all_post_from_user($user_id, $course_code); |
if (api_is_user_of_course($course_code, api_get_user_id())) { |
||||||
$all_result_data = 0; |
//------Forum messages |
||||||
if ($forum_result !='') { |
$forum_result = get_all_post_from_user($user_id, $course_code); |
||||||
echo '<div id="social-forum-main-title">'; |
$all_result_data = 0; |
||||||
echo api_xml_http_response_encode(get_lang('Forum')); |
if ($forum_result !='') { |
||||||
echo '</div>'; |
echo '<div id="social-forum-main-title">'; |
||||||
|
echo api_xml_http_response_encode(get_lang('Forum')); |
||||||
echo '<div style="background:#FAF9F6; padding:0px;" >'; |
echo '</div>'; |
||||||
echo api_xml_http_response_encode($forum_result); |
|
||||||
echo '</div>'; |
echo '<div style="background:#FAF9F6; padding:0px;" >'; |
||||||
echo '<br />'; |
echo api_xml_http_response_encode($forum_result); |
||||||
$all_result_data++; |
echo '</div>'; |
||||||
} |
echo '<br />'; |
||||||
|
$all_result_data++; |
||||||
//------Blog posts |
} |
||||||
$result = get_blog_post_from_user($course_code, $user_id); |
|
||||||
|
//------Blog posts |
||||||
if (!empty($result)) { |
$result = get_blog_post_from_user($course_code, $user_id); |
||||||
api_display_tool_title(api_xml_http_response_encode(get_lang('Blog'))); |
|
||||||
echo '<div style="background:#FAF9F6; padding:0px;">'; |
if (!empty($result)) { |
||||||
echo api_xml_http_response_encode($result); |
api_display_tool_title(api_xml_http_response_encode(get_lang('Blog'))); |
||||||
echo '</div>'; |
echo '<div style="background:#FAF9F6; padding:0px;">'; |
||||||
echo '<br />'; |
echo api_xml_http_response_encode($result); |
||||||
$all_result_data++; |
echo '</div>'; |
||||||
} |
echo '<br />'; |
||||||
|
$all_result_data++; |
||||||
//------Blog comments |
} |
||||||
$result = get_blog_comment_from_user($course_code, $user_id); |
|
||||||
if (!empty($result)) { |
//------Blog comments |
||||||
echo '<div style="background:#FAF9F6; padding-left:10px;">'; |
$result = get_blog_comment_from_user($course_code, $user_id); |
||||||
api_display_tool_title(api_xml_http_response_encode(get_lang('BlogComments'))); |
if (!empty($result)) { |
||||||
echo api_xml_http_response_encode($result); |
echo '<div style="background:#FAF9F6; padding-left:10px;">'; |
||||||
echo '</div>'; |
api_display_tool_title(api_xml_http_response_encode(get_lang('BlogComments'))); |
||||||
echo '<br />'; |
echo api_xml_http_response_encode($result); |
||||||
$all_result_data++; |
echo '</div>'; |
||||||
} |
echo '<br />'; |
||||||
if ($all_result_data == 0) { |
$all_result_data++; |
||||||
echo api_xml_http_response_encode(get_lang('NoDataAvailable')); |
} |
||||||
} |
if ($all_result_data == 0) { |
||||||
|
echo api_xml_http_response_encode(get_lang('NoDataAvailable')); |
||||||
} else { |
} |
||||||
echo '<div class="clear"></div><br />'; |
|
||||||
api_display_tool_title(api_xml_http_response_encode(get_lang('Details'))); |
} else { |
||||||
echo '<div style="background:#FAF9F6; padding:0px;">'; |
echo '<div class="clear"></div><br />'; |
||||||
echo api_xml_http_response_encode(get_lang('UserNonRegisteredAtTheCourse')); |
api_display_tool_title(api_xml_http_response_encode(get_lang('Details'))); |
||||||
echo '<div class="clear"></div><br />'; |
echo '<div style="background:#FAF9F6; padding:0px;">'; |
||||||
echo '</div>'; |
echo api_xml_http_response_encode(get_lang('UserNonRegisteredAtTheCourse')); |
||||||
echo '<div class="clear"></div><br />'; |
echo '<div class="clear"></div><br />'; |
||||||
} |
echo '</div>'; |
||||||
break; |
echo '<div class="clear"></div><br />'; |
||||||
case 'unload_course' : |
} |
||||||
//echo 'load2'; |
break; |
||||||
break; |
case 'unload_course': |
||||||
default: |
break; |
||||||
break; |
default: |
||||||
} |
break; |
||||||
break; |
} |
||||||
default: |
break; |
||||||
echo ''; |
default: |
||||||
|
echo ''; |
||||||
} |
} |
||||||
exit; |
exit; |
||||||
|
|||||||
Loading…
Reference in new issue