Modify course's list and add session's list in 'My shared profile' - refs #5637

1.9.x
Imanol Losada 11 years ago
parent 9963cfdd43
commit 4129c54c0f
  1. 2
      main/inc/lib/main_api.lib.php
  2. 10
      main/inc/lib/message.lib.php
  3. 1
      main/inc/lib/notification.lib.php
  4. 1
      main/inc/lib/opengraph
  5. 8
      main/inc/lib/sessionmanager.lib.php
  6. 389
      main/inc/lib/social.lib.php
  7. 11
      main/inc/lib/usermanager.lib.php
  8. 3
      main/lang/english/userInfo.inc.php
  9. 334
      main/social/home.php
  10. 247
      main/social/profile.php
  11. 9
      main/work/work.lib.php

@ -3981,7 +3981,7 @@ function api_disp_html_area($name, $content = '', $height = '', $width = '100%',
* @deprecated
*/
function api_return_html_area($name, $content = '', $height = '', $width = '100%', $attributes = null, $editor_config = null) {
global $_configuration, $_course, $fck_attribute;
global $fck_attribute;
require_once api_get_path(LIBRARY_PATH).'formvalidator/Element/html_editor.php';
$editor = new HTML_QuickForm_html_editor($name, null, $attributes, $editor_config);
$editor->setValue($content);

@ -25,6 +25,16 @@ define('MESSAGE_STATUS_OUTBOX', '4');
define('MESSAGE_STATUS_INVITATION_PENDING', '5');
define('MESSAGE_STATUS_INVITATION_ACCEPTED', '6');
define('MESSAGE_STATUS_INVITATION_DENIED', '7');
define('MESSAGE_STATUS_WALL', '8');
define('MESSAGE_STATUS_WALL_DELETE', '9');
define('MESSAGE_STATUS_WALL_POST', '10');
// Images
define('IMAGE_WALL_SMALL_SIZE', 200);
define('IMAGE_WALL_MEDIUM_SIZE', 500);
define('IMAGE_WALL_BIG_SIZE', 2000);
define('IMAGE_WALL_SMALL', 'small');
define('IMAGE_WALL_MEDIUM', 'medium');
define('IMAGE_WALL_BIG', 'big');
/**
* Class

@ -46,6 +46,7 @@ class Notification extends Model
const NOTIFICATION_TYPE_MESSAGE = 1;
const NOTIFICATION_TYPE_INVITATION = 2;
const NOTIFICATION_TYPE_GROUP = 3;
const NOTIFICATION_TYPE_WALL_MESSAGE = 4;
/**
*

@ -0,0 +1 @@
Subproject commit faba415deb9a84ae534dce78afdd5ca6535bdf12

@ -2624,6 +2624,13 @@ class SessionManager
$whereConditions = " OR (s.id_coach = $userId) ";
break;
default:
$sessionQuery = "SELECT sru.id_session
FROM
$tbl_session_rel_user sru
WHERE
sru.id_user = $userId";
break;
}
$keywordCondition = null;
@ -2646,7 +2653,6 @@ class SessionManager
$orderCondition
$limitCondition";
if ($getSql) {
return $sql;
}

@ -474,19 +474,20 @@ class SocialManager extends UserManager
//display course entry
$result .= '<div id="div_'.$count.'">';
$result .= '<h3><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_course(this,\''.$course_id.'\' )">';
//$result .= '<h3><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_course(this,\''.$course_id.'\' )">';
$result .= $s_htlm_status_icon;
//show a hyperlink to the course, unless the course is closed and user is not course admin
if ($course_visibility != COURSE_VISIBILITY_HIDDEN && ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER)) {
$result .= '<a href="javascript:void(0)" id="ln_'.$count.'" onclick=toogle_course(this,\''.$course_id.'\');>&nbsp;'.$course_title.'</a>';
//$result .= '<a href="javascript:void(0)" id="ln_'.$count.'" onclick=toogle_course(this,\''.$course_id.'\');>&nbsp;'.$course_title.'</a>';
$result .= $course_title;
} else {
$result .= $course_title." "." ".get_lang('CourseClosed')."";
}
$result .= '</h3>';
//$current_course_settings = CourseManager :: get_access_settings($my_course['k']);
// display the what's new icons
if ($nbDigestEntries > 0) {
/*if ($nbDigestEntries > 0) {
reset($digest);
$result .= '<ul>';
while (list ($key2) = each($digest[$thisCourseSysCode])) {
@ -522,7 +523,7 @@ class SocialManager extends UserManager
$result .= '</li>';
}
$result .= '</ul>';
}
}*/
$result .= '</li>';
$result .= '</div>';
@ -1029,4 +1030,384 @@ class SocialManager extends UserManager
}
return $content;
}
/**
* Sends a message to someone's wall
* @param int $userId id of author
* @param int $friendId id where we send the message
* @param string $messageContent of the message
* @param int $messageId id parent
* @param string $messageStatus status type of message
* @return boolean
* @author Yannick Warnier
*/
public static function sendWallMessage($userId, $friendId, $messageContent, $messageId = 0 ,$messageStatus)
{
$tblMessage = Database::get_main_table(TABLE_MAIN_MESSAGE);
$userId = intval($userId);
$friendId = intval($friendId);
$messageId = intval($messageId);
$return = false;
//Just in case we replace the and \n and \n\r while saving in the DB
$messageContent = str_replace(array("\n", "\n\r"), '<br />', $messageContent);
$cleanMessageContent = Database::escape_string($messageContent);
$now = api_get_utc_datetime();
$sql = 'INSERT INTO '.$tblMessage.'(
user_sender_id,user_receiver_id,msg_status,send_date,title,content,parent_id
) VALUES(
'.$userId.','.$friendId.','.$messageStatus.',"'.$now.'","","'.$cleanMessageContent.'", "'.$messageId.'" ) ';
Database::query($sql);
$return = Database::insert_id();
/*
$senderInfo = api_get_user_info($userId);
$notification = new Notification();
$notification->save_notification(Notification::NOTIFICATION_TYPE_WALL_MESSAGE, array($friendId), '', $messageContent, $senderInfo);
*/
return $return;
}
/**
* Send File attachment (jpg,png)
* @author Anibal Copitan
* @param int $userId id user
* @param array $fileAttach
* @param int $messageId id message (relation with main message)
* @param string $fileComment description attachment file
* @return bool
*/
public static function sendWallMessageAttachmentFile($userId, $fileAttach, $messageId, $fileComment = '')
{
$flag = false;
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// create directory
$pathUserInfo = UserManager::get_user_picture_path_by_id($userId, 'system', true);
$social = '/social/';
$pathMessageAttach = $pathUserInfo['dir'] . 'message_attachments'. $social;
$safeFileComment = Database::escape_string($fileComment);
$safeFileName = Database::escape_string($fileAttach['name']);
$extension = strtolower(substr(strrchr($safeFileName, '.'), 1));
$allowedTypes = array('jpg', 'jpeg', 'png', 'gif');
if (!in_array($extension, $allowedTypes)) {
$flag = false;
} else {
$newFileName = uniqid('') . '.' . $extension;
if (!file_exists($pathMessageAttach)) {
@mkdir($pathMessageAttach, api_get_permissions_for_new_directories(), true);
}
$newPath = $pathMessageAttach . $newFileName;
if (is_uploaded_file($fileAttach['tmp_name'])) {
@copy($fileAttach['tmp_name'], $newPath);
}
$small = self::resize_picture($newPath, IMAGE_WALL_SMALL_SIZE);
$medium = self::resize_picture($newPath, IMAGE_WALL_MEDIUM_SIZE);
$big = new Image($newPath);
$ok = $small && $small->send_image($pathMessageAttach . IMAGE_WALL_SMALL . '_' . $newFileName) &&
$medium && $medium->send_image($pathMessageAttach . IMAGE_WALL_MEDIUM .'_' . $newFileName) &&
$big && $big->send_image($pathMessageAttach . IMAGE_WALL_BIG . '_' . $newFileName);
// Insert
$newFileName = $social.$newFileName;
$sql = "INSERT INTO $tbl_message_attach(filename, comment, path, message_id, size)
VALUES ( '$safeFileName', '$safeFileComment', '$newFileName' , '$messageId', '".$fileAttach['size']."' )";
Database::query($sql);
$flag = true;
}
return $flag;
}
/**
* Gets all messages from someone's wall (within specific limits)
* @param int $userId id of wall shown
* @param string $messageStatus status wall message
* @param int $parentId id message (Post main)
* @param string Date from which we want to show the messages, in UTC time
* @param int Limit for the number of parent messages we want to show
* @return boolean
* @author Yannick Warnier
*/
public static function getWallMessages($userId, $messageStatus, $parentId = '', $start = null, $limit = 10)
{
if (empty($start)) {
$start = '0000-00-00';
}
$tblMessage = Database::get_main_table(TABLE_MAIN_MESSAGE);
$userId = intval($userId);
$start = Database::escape_string($start);
// TODO: set a maximum of 3 months for messages
//if ($start == '0000-00-00') {
//
//}
$limit = intval($limit);
$messages = array();
$sql = "SELECT id, user_sender_id,user_receiver_id, send_date, content, parent_id,
(SELECT ma.path from message_attachment ma WHERE ma.message_id = tm.id ) as path,
(SELECT ma.filename from message_attachment ma WHERE ma.message_id = tm.id ) as filename
FROM $tblMessage tm
WHERE user_receiver_id = $userId
AND send_date > '$start' ";
$sql .= (empty($messageStatus) || is_null($messageStatus)) ? '' : " AND msg_status = '$messageStatus' ";
$sql .= (empty($parentId) || is_null($parentId)) ? '' : " AND parent_id = '$parentId' ";
$sql .= " ORDER BY send_date DESC
LIMIT $limit ";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
$messages[] = $row;
}
}
return $messages;
}
/**
* Gets all messages from someone's wall (within specific limits), formatted
* @param int $userId USER ID of the person's wall
* @param int $friendId id person
* @param int $idMessage id message
* @param string Start date (from when we want the messages until today)
* @param int Limit to the number of messages we want
* @return string HTML formatted string to show messages
*/
public static function getWallMessagesHTML($userId, $friendId, $idMessage, $start = null, $limit = 10)
{
if (empty($start)) {
$start = '0000-00-00';
}
$visibility = (api_get_user_id() == $userId && $userId == $friendId);
$messages = self::getWallMessages($userId, MESSAGE_STATUS_WALL, $idMessage, $start, $limit);
$formattedList = '<div>';
$users = array();
foreach ($messages as $message) {
$date = api_get_local_time($message['send_date']);
$userIdLoop = $message['user_sender_id'];
if (!isset($users[$userIdLoop])) {
$users[$userIdLoop] = api_get_user_info($userIdLoop);
}
$nameComplete = api_is_western_name_order()
? $users[$userIdLoop]['firstname'] .' ' . $users[$userIdLoop]['lastname']
: $users[$userIdLoop]['lastname'] . ' ' . $users[$userIdLoop]['firstname'];
$url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$userIdLoop;
$media = '';
$media .= '<div class="media">';
$media .= '<a href="'.$url.'" class="pull-left">'
. '<img class="" src="'. $users[$userIdLoop]['avatar'] .'" '
. 'width="32" height="32" alt="'.$users[$userIdLoop]['complete_name'].'" style="width: 32px; height: 32px;"> '
. '</a>';
$media .= '<div class="media-body">'
. '<h4 class="media-heading">'
. '<a href="'.$url.'">' . $nameComplete . '</a> '
. '<small><span class="time" title="' . $date . '">' . $date . '</span></small>'
. '</h4>'
. '</div>';
$media .= '<span class="content">'.Security::remove_XSS($message['content']).'</span>';
if ($visibility) {
$media .= '<div><a href="'.api_get_path(WEB_PATH).'main/social/profile.php?messageId=' . $message['id'].'">'.get_lang('SocialMessageDelete').'</a></div>';
}
$media .= '</div>'; // end media
$formattedList .= $media;
}
$formattedList .= '<form name="social_wall_message" method="POST">
<label for="social_wall_new_msg" class="hide">' . get_lang('SocialWriteNewComment') . '</label>
<input type="hidden" name = "messageId" value="'.$idMessage.'" />
<textarea placeholder="' . get_lang('SocialWriteNewComment') . '" name="social_wall_new_msg" rows="1" cols="80" style="width: 98%"></textarea>
<br />
<input type="submit" name="social_wall_new_msg_submit" value="'.get_lang('Post').'" />
</form>';
$formattedList .= '</div>';
return $formattedList;
}
/**
* @param int $userId id
* @param int $friendId id
* @param null $start
* @param int $limit
* @return array $data return array associative
*/
public static function getWallMessagesPostHTML($userId, $friendId = 0, $start = null, $limit = 10)
{
if (empty($start)) {
$start = '0000-00-00';
}
$visibility = (api_get_user_id() == $userId && $userId == $friendId);
$messages = self::getWallMessages($userId, MESSAGE_STATUS_WALL_POST , null, $start, $limit);
$users = array();
$data = array();
foreach ($messages as $key => $message) {
$date = api_get_local_time($message['send_date']);
$userIdLoop = $message['user_sender_id'];
$userFriendIdLoop = $message['user_receiver_id'];
if (!isset($users[$userIdLoop])) {
$users[$userIdLoop] = api_get_user_info($userIdLoop);
}
if (!isset($users[$userFriendIdLoop])) {
$users[$userFriendIdLoop] = api_get_user_info($userFriendIdLoop);
}
$html = '';
$html .= self::_headerMessagePost($message['user_sender_id'], $message['user_receiver_id'], $users, $message, $visibility);
$html .= '<hr>';
$data[$key]['id'] = $message['id'];
$data[$key]['html'] = $html;
}
return $data;
}
private static function _headerMessagePost($authorId, $reciverId, $users, $message, $visibility = false)
{
$date = api_get_local_time($message['send_date']);
$avatarAuthor = $users[$authorId]['avatar'];
$urlAuthor = api_get_path(WEB_PATH).'main/social/profile.php?u='.$authorId;
$nameCompleteAuthor = api_is_western_name_order()
? $users[$authorId]['firstname'] .' ' . $users[$authorId]['lastname']
: $users[$authorId]['lastname'] . ' ' . $users[$authorId]['firstname'];
$avatarReciver = $users[$reciverId]['avatar'];
$urlReciber = api_get_path(WEB_PATH).'main/social/profile.php?u='.$reciverId;
$nameCompleteReciver = api_is_western_name_order()
? $users[$reciverId]['firstname'] .' ' . $users[$reciverId]['lastname']
: $users[$reciverId]['lastname'] . ' ' . $users[$reciverId]['firstname'];
$htmlReciber = '';
if ($authorId != $reciverId) {
$htmlReciber = ' > <a href="'.$urlReciber.'">' . $nameCompleteReciver . '</a> ';
}
$wallImage = '';
if (!empty($message['path'])) {
$pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true);
$pathImg = $pathUserInfo['dir'] . 'message_attachments';
$imageBig = $pathImg .self::_geImage($message['path'], IMAGE_WALL_BIG);
$imageSmall = $pathImg. self::_geImage($message['path'], IMAGE_WALL_SMALL);
$wallImage = '<hr><a class="thumbnail thickbox" href="'.$imageBig.'"><img src="'.$imageSmall.'"> </a>';
}
$htmlDelete = '';
if ($visibility) {
$htmlDelete .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?messageId=' . $message['id'].'">'.get_lang('SocialMessageDelete').'</a>';
}
$html = '';
$html .= '<div class="mediaPost">';
$html .= '<a href="'.$urlAuthor.'" class="pull-left">'
. '<img class="" src="'. $avatarAuthor .'" width="40" height="40" alt="'.$nameCompleteAuthor.'" style="width: 40px; height: 40px;"></a>';
$html .= '<div class="media-body">';
$html .= '<h4 class="media-heading"> <a href="'.$urlAuthor.'">' . $nameCompleteAuthor . '</a> ' . $htmlReciber;
$html .= '<small><span class="time" title="' . $date . '">' . $date . '</span></small></h4>';
$html .= $htmlDelete;
$html .= $wallImage;
$html .= '</div>';
$html .= '<span class="content">'.Security::remove_XSS(self::readContentWithOpenGraph($message['content'])).'</span>';
$html .= '</div>'; // end mediaPost
return $html;
}
/**
* Get schedule html (with data openGrap)
* @param $text content text
*/
public function readContentWithOpenGraph($text)
{
// search link in first line
$regExUrl = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$newText = '';
$count = 0;
if(preg_match($regExUrl, $text, $url)) {
// make the urls hyper links
$newText .= preg_replace($regExUrl, "<a target=\"_blank\" href=" . $url[0] . ">".$url[0]."</a> ", $text);
if ($count == 0) {
//$newText .= self::getHtmlByLink($url[0]);
}
$count++;
} else {
$newText .= $text;
}
return $newText;
}
/**
* html with data OpenGrap
* @param $link url
* @return string data html
*/
public function getHtmlByLink($link)
{
$graph = OpenGraph::fetch($link);
$title = !empty($graph->site_name) ? $graph->site_name .' : '.$graph->title : $graph->title;
$html = '<div style="border:1px solid gray">';
$html .= '<h3><a target="_blank" href="'.$link.'">' . $title . '</h3>';
$html .= empty($graph->image) ? '' : '<img alt="" src="'.$graph->image.'" height="160" >';
$html .= empty($graph->description) ? '' : '<div>'.$graph->description.'</div>';
$html .= "</div>";
return $html;
}
/**
* Get name img by sizes
* @param string$path
* @return string
*/
private static function _geImage($path, $size = '')
{
$name = '';
$array = preg_split('#\/#', $path);
if (isset($array[2]) && !empty($array[2])) {
if ($size == IMAGE_WALL_SMALL) {
$name = IMAGE_WALL_SMALL. '_' . $array[2];
}else if($size == IMAGE_WALL_MEDIUM){
$name = IMAGE_WALL_MEDIUM. '_' . $array[2];
}else if($size == IMAGE_WALL_BIG){
$name = IMAGE_WALL_BIG. '_' . $array[2];
}else {
$name = IMAGE_WALL_SMALL. '_' . $array[2];
}
$lessImage = str_replace($array[2], '', $path);
$name = $lessImage . $name;
}
return $name;
}
/**
* Delete messages delete logic
* @param int $id indice message to delete.
* @return status query
*/
public static function deleteMessage($id)
{
$id = intval($id);
$tblMessage = Database::get_main_table(TABLE_MESSAGE);
$statusMessage = MESSAGE_STATUS_WALL_DELETE;
$sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' ";
return Database::query($sql);
}
}

@ -3039,9 +3039,20 @@ class UserManager
$picture = array();
$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') {
switch($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL :
case USER_IMAGE_SIZE_BIG :
case USER_IMAGE_SIZE_MEDIUM :
$picture_file = 'unknown.jpg';
break;
case USER_IMAGE_SIZE_SMALL:
$picture_file = 'unknown_22.jpg';
break;
}
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
return $picture;
}
switch ($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL :
$size_picture = '';

@ -96,6 +96,9 @@ $ToChangeYourEmailMustTypeYourPassword = "In order to change your e-mail address
$Invitations = "Invitations";
$MyGroups = "My groups";
$Social = "Social";
$SocialWallWhatAreYouThinkingAbout = "What's on your mind?";
$SocialWriteNewComment = "Write a new Comment...";
$SocialMessageDelete = "Delete";
$Profile = "Profile";
$MyFriends = "My friends";
$Messages = "Messages";

@ -11,49 +11,73 @@ $language_file = array('userInfo');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'skill.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'skill.lib.php';
$user_id = api_get_user_id();
$show_full_profile = true;
//social tab
$this_section = SECTION_SOCIAL;
unset($_SESSION['this_section']);//for hmtl editor repository
unset($_SESSION['this_section']); //for hmtl editor repository
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true' ) {
$url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
header('Location: '.$url);
if (api_get_setting('allow_social_tool') != 'true') {
$url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
header('Location: ' . $url);
exit;
api_not_allowed();
}
//fast upload image
if (api_get_setting('profile', 'picture') == 'true') {
$form = new FormValidator('profile', 'post', 'home.php', null, array());
// PICTURE
$form->addElement('file', 'picture', get_lang('AddImage'));
$form->add_progress_bar();
if (!empty($user_data['picture_uri'])) {
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
$form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"');
if ($form->validate()) {
$user_data = $form->getSubmitValues();
// upload picture if a new one is provided
if ($_FILES['picture']['size']) {
if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id = ".api_get_user_id();
$result = Database::query($sql);
}
}
}
$form = new FormValidator('profile', 'post', 'home.php', null, array());
// PICTURE
$form->addElement('file', 'picture', get_lang('AddImage'));
$form->add_progress_bar();
if (!empty($user_data['picture_uri'])) {
$form->addElement(
'checkbox',
'remove_picture',
null,
get_lang('DelImage')
);
}
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed') . ' (' . implode(
',',
$allowed_picture_types
) . ')',
'filetype',
$allowed_picture_types
);
$form->addElement(
'style_submit_button',
'apply_change',
get_lang('SaveSettings'),
'class="save"'
);
if ($form->validate()) {
$user_data = $form->getSubmitValues();
// upload picture if a new one is provided
if ($_FILES['picture']['size']) {
if ($new_picture = UserManager::update_user_picture(
api_get_user_id(),
$_FILES['picture']['name'],
$_FILES['picture']['tmp_name']
)
) {
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $table_user
SET picture_uri = '$new_picture' WHERE user_id = " . api_get_user_id();
$result = Database::query($sql);
}
}
}
}
$user_info = UserManager :: get_user_info_by_id(api_get_user_id());
@ -62,104 +86,188 @@ $social_left_content = SocialManager::show_social_menu('home');
$social_right_content = '<div class="span5">';
$social_right_content .= '<div class="well_border">';
$social_right_content .= '<h3>'.get_lang('ContactInformation').'</h3>';
$social_right_content .= '<h3>' . get_lang('ContactInformation') . '</h3>';
$list = array(
array('title' => get_lang('Name'), 'content' => api_get_person_name($user_info['firstname'], $user_info['lastname'])),
array('title' => get_lang('Email'), 'content' => $user_info['email']),
);
array(
'title' => get_lang('Name'),
'content' => api_get_person_name(
$user_info['firstname'],
$user_info['lastname']
)
),
array('title' => get_lang('Email'), 'content' => $user_info['email']),
);
// information current user
$social_right_content .= '<div>'.Display::description($list).'</div>';
$social_right_content .= '<div>' . Display::description($list) . '</div>';
$social_right_content .= '
<div class="form-actions">
<a class="btn" href="'.api_get_path(WEB_PATH).'main/auth/profile.php">
'.get_lang('EditProfile').'
<a class="btn" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php">
' . get_lang('EditProfile') . '
</a>
</div></div>';
if (api_get_setting('allow_skills_tool') == 'true') {
$social_right_content .= '<div class="well_border">';
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH).'social/skills_ranking.php';
$ranking_url = Display::url(sprintf(get_lang('YourSkillRankingX'), $ranking), $url, array('class' => 'btn'));
if (api_get_setting('allow_skills_tool') == 'true') {
$social_right_content .= '<div class="well_border">';
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php';
$ranking_url = Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
$url,
array('class' => 'btn')
);
$skills = $skill->get_user_skills(api_get_user_id(), true);
$skills = $skill->get_user_skills(api_get_user_id(), true);
$social_right_content .= '<h3>'.get_lang('Skills').'</h3>';
$lis = '';
if (!empty($skills)) {
foreach($skills as $skill) {
$lis .= Display::tag('li', Display::span($skill['name'], array('class'=>'label_tag skill')));
}
$social_right_content .= Display::tag('ul', $lis);
$social_right_content .= '<h3>' . get_lang('Skills') . '</h3>';
$lis = '';
if (!empty($skills)) {
foreach ($skills as $skill) {
$lis .= Display::tag(
'li',
Display::span(
$skill['name'],
array('class' => 'label_tag skill')
)
);
}
$url = api_get_path(WEB_CODE_PATH).'social/skills_wheel.php';
$skill_wheel_url = Display::url(get_lang('ViewSkillsWheel'), $url, array('class' => 'btn'));
$social_right_content .= '<div class="btn-group">'.$skill_wheel_url.$ranking_url.'</div>';
$social_right_content .= '</div>';
$social_right_content .= Display::tag('ul', $lis);
}
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php';
$skill_wheel_url = Display::url(
get_lang('ViewSkillsWheel'),
$url,
array('class' => 'btn')
);
$social_right_content .= '<div class="btn-group">' . $skill_wheel_url . $ranking_url . '</div>';
$social_right_content .= '</div>';
}
$social_right_content .= '</div>';
//Search box
$social_right_content .= '<div class="span4">';
$social_right_content .= UserManager::get_search_form('');
$social_right_content .= '<br />';
//Group box by age
$results = GroupPortalManager::get_groups_by_age(1, false);
//Search box
$social_right_content .= '<div class="span4">';
$social_right_content .= UserManager::get_search_form('');
$social_right_content .= '<br />';
//Group box by age
$results = GroupPortalManager::get_groups_by_age(1,false);
$groups_newest = array();
if (!empty($results)) {
foreach ($results as $result) {
$id = $result['id'];
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
if ($result['count'] == 1 ) {
$result['count'] = '1 '.get_lang('Member');
} else {
$result['count'] = $result['count'].' '.get_lang('Members');
}
$group_url = "groups.php?id=$id";
$result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
$picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
$groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], cut($result['description'],120,true).$group_actions);
}
}
$results = GroupPortalManager::get_groups_by_popularity(1,false);
$groups_pop = array();
foreach ($results as $result) {
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$id = $result['id'];
$group_url = "groups.php?id=$id";
if ($result['count'] == 1 ) {
$result['count'] = '1 '.get_lang('Member');
} else {
$result['count'] = $result['count'].' '.get_lang('Members');
}
$result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
$picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
$groups_pop[]= array(Display::url($result['picture_uri'], $group_url) , $result['name'], cut($result['description'],120,true).$group_actions);
}
if (count($groups_newest) > 0) {
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));
}
if (count($groups_pop) > 0) {
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
}
$groups_newest = array();
if (!empty($results)) {
foreach ($results as $result) {
$id = $result['id'];
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
if ($result['count'] == 1) {
$result['count'] = '1 ' . get_lang('Member');
} else {
$result['count'] = $result['count'] . ' ' . get_lang('Members');
}
$group_url = "groups.php?id=$id";
$result['name'] = Display::url(
api_ucwords(cut($result['name'], 40, true)),
$group_url
) . Display::span(
'<br />' . $result['count'],
array('class' => 'box_description_group_member')
);
$picture = GroupPortalManager::get_picture_group(
$id,
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">' . get_lang(
'SeeMore'
) . '</a></div>';
$groups_newest[] = array(
Display::url(
$result['picture_uri'],
$group_url
),
$result['name'],
cut($result['description'], 120, true) . $group_actions
);
}
}
$results = GroupPortalManager::get_groups_by_popularity(1, false);
$groups_pop = array();
foreach ($results as $result) {
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$id = $result['id'];
$group_url = "groups.php?id=$id";
if ($result['count'] == 1) {
$result['count'] = '1 ' . get_lang('Member');
} else {
$result['count'] = $result['count'] . ' ' . get_lang('Members');
}
$result['name'] = Display::url(
api_ucwords(cut($result['name'], 40, true)),
$group_url
) . Display::span(
'<br />' . $result['count'],
array('class' => 'box_description_group_member')
);
$picture = GroupPortalManager::get_picture_group(
$id,
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">' . get_lang(
'SeeMore'
) . '</a></div>';
$groups_pop[] = array(
Display::url($result['picture_uri'], $group_url),
$result['name'],
cut($result['description'], 120, true) . $group_actions
);
}
if (count($groups_newest) > 0) {
$social_right_content .= '<div class="social-groups-home-title">' . get_lang(
'Newest'
) . '</div>';
$social_right_content .= Display::return_sortable_grid(
'home_group',
array(),
$groups_newest,
array('hide_navigation' => true, 'per_page' => 100),
array(),
false,
array(true, true, true, false)
);
}
if (count($groups_pop) > 0) {
$social_right_content .= '<div class="social-groups-home-title">' . get_lang(
'Popular'
) . '</div>';
$social_right_content .= Display::return_sortable_grid(
'home_group',
array(),
$groups_pop,
array('hide_navigation' => true, 'per_page' => 100),
array(),
false,
array(true, true, true, true, true)
);
}
$social_right_content .= '</div>';
$tpl = new Template(get_lang('SocialNetwork'));

@ -10,6 +10,8 @@
$language_file = array('userInfo', 'index');
$cidReset = true;
require_once '../inc/global.inc.php';
// Include OpenGraph NOT AVAILABLE
// require_once api_get_path(LIBRARY_PATH) . 'opengraph/OpenGraph.php';
if (api_get_setting('allow_social_tool') !='true') {
$url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']);
@ -18,13 +20,39 @@ if (api_get_setting('allow_social_tool') !='true') {
}
$user_id = api_get_user_id();
$friendId = isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
$show_full_profile = true;
//social tab
$this_section = SECTION_SOCIAL;
//I'm your friend? I can see your profile?
if (isset($_GET['u'])) {
if (!empty($_POST['social_wall_new_msg_main'])) {
$messageId = 0;
$idMessage = SocialManager::sendWallMessage(api_get_user_id(), $friendId, $_POST['social_wall_new_msg_main'], $messageId, MESSAGE_STATUS_WALL_POST);
if (!empty($_FILES['picture']['tmp_name']) && $idMessage > 0) {
$error = SocialManager::sendWallMessageAttachmentFile(api_get_user_id(), $_FILES['picture'], $idMessage, $fileComment = '');
}
$url = api_get_path(WEB_CODE_PATH) . 'social/profile.php';
$url .= empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING'];
header('Location: ' . $url);
exit;
} else if (!empty($_POST['social_wall_new_msg']) && !empty($_POST['messageId'])) {
$messageId = intval($_POST['messageId']);
$res = SocialManager::sendWallMessage(api_get_user_id(), $friendId, $_POST['social_wall_new_msg'], $messageId , MESSAGE_STATUS_WALL);
$url = api_get_path(WEB_CODE_PATH) . 'social/profile.php';
$url .= empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING'];
header('Location: ' . $url);
exit;
} else if (isset($_GET['messageId'])) {
$messageId = Security::remove_XSS($_GET['messageId']);
$status = SocialManager::deleteMessage($messageId);
header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/profile.php');
exit;
} else if (isset($_GET['u'])) { //I'm your friend? I can see your profile?
$user_id = (int) Database::escape_string($_GET['u']);
if (api_is_anonymous($user_id, true)) {
api_not_allowed(true);
@ -65,6 +93,7 @@ if (isset($_GET['u'])) {
} else {
$user_info = UserManager::get_user_info_by_id($user_id);
}
$libpath = api_get_path(LIBRARY_PATH);
require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php';
@ -275,6 +304,7 @@ if (isset($_GET['u'])) {
$info_user = api_get_user_info(api_get_user_id());
$param_user = '';
}
$_SESSION['social_user_id'] = intval($user_id);
/**
@ -282,7 +312,7 @@ $_SESSION['social_user_id'] = intval($user_id);
*/
//Setting some course info
$my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
$my_user_id = isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
$personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
$course_list_code = array();
@ -304,9 +334,24 @@ if (is_array($personal_course_list)) {
$social_left_content = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
//Setting some session info
$user_info = api_get_user_info($my_user_id);
$sessionList = SessionManager::getSessionsFollowedByUser($my_user_id, $user_info['status']);
$htmlSessionList = null;
foreach ($sessionList as $session) {
$htmlSessionList .= '<div>';
$htmlSessionList .= Display::return_icon('session.png', get_lang('Session'));
$htmlSessionList .= $session['name'];
$htmlSessionList .= '</div>';
}
// My friends
$friend_html = _listMyFriends($user_id, $link_shared ,$show_full_profile);
$social_left_content.= '<div class="well sidebar-nav">' .$friend_html . '</div>';
$personal_info = null;
if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
$personal_info .= '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
$personal_info .= '<div DATA="DATA"><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
} else {
//--- Basic Information
$personal_info .= '<div><h3>'.get_lang('Profile').'</h3></div>';
@ -339,98 +384,16 @@ if ($show_full_profile) {
$personal_info .= '</dl>';
}
$social_right_content = SocialManager::social_wrapper_div($personal_info, 4);
if ($show_full_profile) {
//SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
$wallSocialAddPost .= _wallSocialAddPost();
$social_right_content .= SocialManager::social_wrapper_div($wallSocialAddPost, 5);
$friend_html = '';
$number_of_images = 6;
$number_friends = 0;
$number_friends = count($friends);
$social_right_content .= SocialManager::social_wrapper_div($personal_info, 4);
if ($number_friends != 0) {
$friend_html.= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
$friend_html.= '<div id="friend-container" class="social-friend-container">';
$friend_html.= '<div id="friend-header">';
$social_right_content .= _wallSocialPost($my_user_id, $friendId);
//$social_right_content .= SocialManager::social_wrapper_div($wallSocial, 5);
if ($number_friends == 1) {
$friend_html.= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friend').'</div>';
} else {
$friend_html.= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friends').'</div>';
}
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friend_html.= '<div style="float:right;width:20%">'
.'<a href="friends.php">'.get_lang('SeeAll').'</a></div>';
} else {
$friend_html.= '<div style="float:right;width:20%">'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></div>';
}
}
$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;
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
} else {
$status_icon = Display::span('', array('class' => 'offline_user_in_text'));
}
$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_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>';
$friend_html.= '<div id="friend-container" class="social-friend-container">';
$friend_html.= '<div id="friend-header">';
$friend_html.= '<div>'.get_lang('NoFriendsInYourContactList').'<br />'
.'<a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'
.get_lang('TryAndFindSomeFriends')
.'</a></div>';
$friend_html.= '</div>'; // close div friend-header
}
$friend_html.= '</div>';
$social_right_content .= SocialManager::social_wrapper_div($friend_html, 5);
if ($show_full_profile) {
// Extra information
$t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
@ -641,6 +604,12 @@ if ($show_full_profile) {
$social_right_content .= SocialManager::social_wrapper_div($my_courses, 9);
}
$sessions .= '<div><h3>'.api_ucfirst(get_lang('MySessions')).'</h3></div>';
$sessions .= "<div class='social-content-training'>$htmlSessionList</div>";
$social_right_content .= SocialManager::social_wrapper_div($sessions, 9);
// user feeds
$user_feeds = SocialManager::get_user_feeds($user_id);
if (!empty($user_feeds)) {
@ -768,3 +737,97 @@ $tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);
/*
* function list my friends
*/
function _listMyFriends($user_id, $link_shared, $show_full_profile)
{
//SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
$friendHtml = '';
$number_of_images = 30;
$number_friends = 0;
$number_friends = count($friends);
$friendHtml = '<div class="nav-list"><h3>'.get_lang('SocialFriend').'<span>(' . $number_friends . ')</span></h3></div>';
if ($number_friends != 0) {
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friendHtml.= ' : <span><a href="friends.php">'.get_lang('SeeAll').'</a></span>';
} else {
$friendHtml.= ' : <span>'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></span>';
}
}
$friendHtml.= '<ul class="nav nav-list">';
$j = 1;
for ($k=0; $k < $number_friends; $k++) {
if ($j > $number_of_images) break;
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$statusIcon = Display::span('', array('class' => 'online_user_in_text'));
} else {
$statusIcon = Display::span('', array('class' => 'offline_user_in_text'));
}
$friendHtml.= '<li class="">';
// 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'], 20, USER_IMAGE_SIZE_SMALL);
$friendHtml.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml.= $statusIcon .'<a href="profile.php?' .'u=' . $friend['friend_user_id'] . $link_shared . '">' . $name_user .'</a>';
$friendHtml.= '</li>';
}
$j++;
}
$friendHtml.='</ul>';
} else {
$friendHtml.= '<div class="">'.get_lang('NoFriendsInYourContactList').'<br />'
.'<a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'. get_lang('TryAndFindSomeFriends').'</a></div>';
}
return $friendHtml;
}
function _wallSocialAddPost()
{
$html = '';
$html .= '<h3>' . get_lang('SocialWall') . '</h3>';
$html .=
'<form name="social_wall_main" method="POST" enctype="multipart/form-data">
<label for="social_wall_new_msg_main" class="hide">' . get_lang('SocialWallWhatAreYouThinkingAbout') . '</label>
<textarea name="social_wall_new_msg_main" rows="2" cols="80" style="width: 98%" placeholder="'.get_lang('SocialWallWhatAreYouThinkingAbout').'"></textarea>
<br />
<input class="" name="picture" type="file">
<input type="submit" name="social_wall_new_msg_main_submit" value="'.get_lang('Post').'" class="float right btn btn-primary" />
</form>';
return $html;
}
function _wallSocialPost($userId, $friendId)
{
$array = SocialManager::getWallMessagesPostHTML($userId, $friendId);
$html = '';
for($i = 0; $i < count($array); $i++) {
$post = $array[$i]['html'];
$comment = SocialManager::getWallMessagesHTML($userId, $friendId, $array[$i]['id']);
$html .= SocialManager::social_wrapper_div($post.$comment, 5);
}
return $html;
}

@ -4198,16 +4198,21 @@ function downloadFile($id, $course_info)
}
/**
* Get the file contents for an assigment
* @param int $id
* @param array $course_info
* @param int Session ID
* @return array|bool
*/
function getFileContents($id, $course_info)
function getFileContents($id, $course_info, $sessionId = 0)
{
$id = intval($id);
if (empty($course_info) || empty($id)) {
return false;
}
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
@ -4219,7 +4224,7 @@ function getFileContents($id, $course_info)
$row = Database::fetch_array($result, 'ASSOC');
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id'], $sessionId);
allowOnlySubscribedUser(api_get_user_id(), $row['parent_id'], $course_info['real_id']);
if (empty($item_info)) {

Loading…
Cancel
Save