';
}
$j++;
}
}
}
echo $friend_html;
break;
case 'toogle_course':
if (api_is_anonymous()) {
echo '';
break;
}
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$user_id = Session::read('social_user_id');
if ($_POST['action']) {
$action = $_POST['action'];
}
switch ($action) {
case 'load_course':
$course_id = intval($_POST['course_code']); // the int course id
$course_info = api_get_course_info_by_id($course_id);
$course_code = $course_info['code'];
if (api_is_user_of_course($course_id, api_get_user_id())) {
//------Forum messages
$forum_result = get_all_post_from_user($user_id, $course_code);
$all_result_data = 0;
if ($forum_result != '') {
echo '';
echo api_xml_http_response_encode(get_lang('Forum'));
echo '
';
echo '';
echo api_xml_http_response_encode($forum_result);
echo '
';
echo '
';
$all_result_data++;
}
//------Blog posts
$result = Blog::getBlogPostFromUser($course_id, $user_id, $course_code);
if (!empty($result)) {
api_display_tool_title(api_xml_http_response_encode(get_lang('Blog')));
echo '';
echo api_xml_http_response_encode($result);
echo '
';
echo '
';
$all_result_data++;
}
//------Blog comments
$result = Blog::getBlogCommentsFromUser($course_id, $user_id, $course_code);
if (!empty($result)) {
echo '';
api_display_tool_title(api_xml_http_response_encode(get_lang('BlogComments')));
echo api_xml_http_response_encode($result);
echo '
';
echo '
';
$all_result_data++;
}
if ($all_result_data == 0) {
echo api_xml_http_response_encode(get_lang('NoDataAvailable'));
}
} else {
echo '
';
api_display_tool_title(api_xml_http_response_encode(get_lang('Details')));
echo '';
echo api_xml_http_response_encode(get_lang('UserNonRegisteredAtTheCourse'));
echo '
';
echo '
';
echo '
';
}
break;
case 'unload_course':
break;
default:
break;
}
break;
case 'list_wall_message':
$start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) - 1 : 0;
$length = isset($_REQUEST['length']) ? intval($_REQUEST['length']) : 10;
$userId = isset($_REQUEST['u']) ? intval($_REQUEST['u']) : api_get_user_id();
$friendId = $userId;
$array = SocialManager::getWallMessagesPostHTML($userId, $friendId, null, $length, $start);
if (!empty($array)) {
ksort($array);
$html = '';
for ($i = 0; $i < count($array); $i++) {
$post = $array[$i]['html'];
$comment = SocialManager::getWallMessagesHTML($userId, $friendId, $array[$i]['id']);
$html .= '';
}
$html .= Display::div(
Display::url(
get_lang('SeeMore'),
api_get_self().'?u='.$userId.'&a=list_wall_message&start='.
($start + $length + 1).'&length='.$length,
array(
'class' => 'nextPage',
)
),
array(
'class' => 'next',
)
);
echo $html;
}
break;
// Read the Url using OpenGraph and returns the hyperlinks content
case 'read_url_with_open_graph':
$url = isset($_POST['social_wall_new_msg_main']) ? $_POST['social_wall_new_msg_main'] : '';
$url = trim($url);
$html = '';
if (SocialManager::verifyUrl($url) == true) {
$html = Security::remove_XSS(
SocialManager::readContentWithOpenGraph($url)
);
}
echo $html;
break;
default:
echo '';
}
exit;