';
// get attach id
- $attachment_list=get_attachment($row['post_id']);
- $id_attach = !empty($attachment_list)?$attachment_list['id']:'';
+ $attachment_list = get_attachment($row['post_id']);
+ $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
// The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum
// The course admin him/herself can do this off course always
if (
@@ -74,7 +80,9 @@ if (isset($current_thread['thread_id'])) {
echo "".Display::return_icon('delete.png', get_lang('Delete'),array(), ICON_SIZE_SMALL)."";
}
}
- if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
+ if (api_is_allowed_to_edit(false,true) &&
+ !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])
+ ) {
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$clean_forum_id,'thread'=>$clean_thread_id, 'origin'=>$origin ));
echo "";
if ($increment>0) {
@@ -120,13 +128,17 @@ if (isset($current_thread['thread_id'])) {
}
echo "
";
// prepare the notification icon
- if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) && !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])) {
- $post_image=Display::return_icon('forumpostnew.gif');
+ if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) &&
+ !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) &&
+ !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])
+ ) {
+ $post_image = Display::return_icon('forumpostnew.gif');
} else {
- $post_image=Display::return_icon('forumpost.gif');
+ $post_image = Display::return_icon('forumpost.gif');
}
- if ($row['post_notification']=='1' && $row['poster_id']==$_user['user_id']) {
- $post_image.=Display::return_icon('forumnotification.gif',get_lang('YouWillBeNotified'));
+
+ if ($row['post_notification']=='1' && $row['poster_id'] == $_user['user_id']) {
+ $post_image .= Display::return_icon('forumnotification.gif', get_lang('YouWillBeNotified'));
}
// The post title
@@ -151,7 +163,7 @@ if (isset($current_thread['thread_id'])) {
if (!empty($attachment_list) && is_array($attachment_list)) {
foreach ($attachment_list as $attachment) {
echo '
';
+
return $formattedList;
}
@@ -1377,7 +1307,6 @@ class SocialManager extends UserManager
$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'];
@@ -1414,7 +1343,7 @@ class SocialManager extends UserManager
* @param boolean $isOwnWall Determines if the author is in its own social wall or not
* @return string $html The formatted header message post
*/
- private static function headerMessagePost($authorId, $receiverId, $users, $message, $isOwnWall = false)
+ private static function headerMessagePost($authorId, $receiverId, $users, $message, $isOwnWall = false)
{
$date = api_get_local_time($message['send_date']);
$avatarAuthor = $users[$authorId]['avatar'];
@@ -1423,8 +1352,7 @@ class SocialManager extends UserManager
$users[$authorId]['firstname'],
$users[$authorId]['lastname']
);
- // Deprecated since 2014-10-29
- //$avatarReceiver = $users[$receiverId]['avatar'];
+
$urlReceiver = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$receiverId;
$nameCompleteReceiver = api_get_person_name(
$users[$receiverId]['firstname'],
@@ -1438,14 +1366,9 @@ class SocialManager extends UserManager
$wallImage = '';
if (!empty($message['path'])) {
- $pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true);
- $imageBig = $pathUserInfo['file'];
- $imageSmall = $pathUserInfo['file'];
- if (!api_get_configuration_value('gravatar_enabled')) {
- $pathImg = UserManager::getUserPathById($authorId, 'web').'message_attachments';
- $imageBig = $pathImg .self::getImagePath($message['path'], IMAGE_WALL_BIG);
- $imageSmall = $pathImg. self::getImagePath($message['path'], IMAGE_WALL_SMALL);
- }
+ $imageBig = UserManager::getUserPicture($authorId, USER_IMAGE_SIZE_BIG);
+ $imageSmall = UserManager::getUserPicture($authorId, USER_IMAGE_SIZE_SMALL);
+
$wallImage = '';
}
@@ -1628,7 +1551,7 @@ class SocialManager extends UserManager
if (isset($friends[$k])) {
$friend = $friends[$k];
- $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
+ $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']) {
@@ -1639,8 +1562,8 @@ class SocialManager extends UserManager
$friendHtml.= '
';
// the height = 92 must be the same 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.= '';
+ $friends_profile = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_SMALL);
+ $friendHtml.= '';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml.= $statusIcon .'' . $name_user .'';
$friendHtml.= '
';
diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php
index 228e8e0a5a..1d04f3b21b 100755
--- a/main/inc/lib/usermanager.lib.php
+++ b/main/inc/lib/usermanager.lib.php
@@ -410,10 +410,10 @@ class UserManager
// Delete user picture
/* TODO: Logic about api_get_setting('split_users_upload_directory') == 'true'
- a user has 4 differnt sized photos to be deleted. */
+ a user has 4 different sized photos to be deleted. */
$user_info = api_get_user_info($user_id);
if (strlen($user_info['picture_uri']) > 0) {
- $img_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$user_id.'/'.$user_info['picture_uri'];
+ $img_path = api_get_path(SYS_APP_PATH).'upload/users/'.$user_id.'/'.$user_info['picture_uri'];
if (file_exists($img_path))
unlink($img_path);
}
@@ -1175,7 +1175,7 @@ class UserManager
* @param string The id
* @param boolean Whether to return the user's extra fields (defaults to false)
* @return array All user information as an associative array
- * @todo Use api_get_user_info() instead
+ * @deprecated Use api_get_user_info() instead
*/
public static function get_user_info_by_id($user_id, $user_fields = false)
{
@@ -1191,7 +1191,9 @@ class UserManager
$resf = Database::query($sqlf);
if (Database::num_rows($resf) > 0) {
while ($rowf = Database::fetch_array($resf)) {
- $sqlv = "SELECT * FROM $t_ufv WHERE field_id = ".$rowf['id']." AND user_id = ".$user['user_id']." ORDER BY id DESC";
+ $sqlv = "SELECT * FROM $t_ufv
+ WHERE field_id = ".$rowf['id']." AND user_id = ".$user['user_id']."
+ ORDER BY id DESC";
$resv = Database::query($sqlv);
if (Database::num_rows($resv) > 0) {
//There should be only one value for a field and a user
@@ -1213,93 +1215,194 @@ class UserManager
* with dirname() or the file with basename(). This also works for the
* functions dealing with the user's productions, as they are located in
* the same directory.
- * @param integer User ID
- * @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
- * @param bool deprecated see #7110
- * @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
- * @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
+ * @param integer $id User ID
+ * @param string $type Type of path to return (can be 'system', 'web')
+ * @param array $userInfo user information to avoid query the DB
+ * returns the /main/img/unknown.jpg image set it at true
+ *
+ * @return array Array of 2 elements: 'dir' and 'file' which contain
+ * the dir and file as the name implies if image does not exist it will
+ * return the unknow image if anonymous parameter is true if not it returns an empty array
*/
- public static function get_user_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
+ public static function get_user_picture_path_by_id($id, $type = 'web', $userInfo = [])
{
switch ($type) {
case 'system': // Base: absolute system path.
$base = api_get_path(SYS_CODE_PATH);
break;
- case 'rel': // Base: semi-absolute web path (no server base).
- $base = api_get_path(REL_CODE_PATH);
- break;
case 'web': // Base: absolute web path.
+ default:
$base = api_get_path(WEB_CODE_PATH);
break;
- case 'none':
- default: // Base: empty, the result path below will be relative.
- $base = '';
}
- $gravatarEnabled = api_get_configuration_value('gravatar_enabled');
- $noPicturePath = array('dir' => $base.'img/', 'file' => 'unknown.jpg');
- if ((empty($id) || empty($type)) && !$gravatarEnabled) {
- return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
- }
+ $anonymousPath = array(
+ 'dir' => $base.'img/',
+ 'file' => 'unknown.jpg',
+ 'email' => '',
+ );
- $user_id = intval($id);
+ if ((empty($id) || empty($type))) {
+ return $anonymousPath;
+ }
- $user_table = Database :: get_main_table(TABLE_MAIN_USER);
- $sql = "SELECT email, picture_uri FROM $user_table WHERE user_id=".$user_id;
- $res = Database::query($sql);
+ $id = intval($id);
+ if (empty($userInfo)) {
+ $user_table = Database:: get_main_table(TABLE_MAIN_USER);
+ $sql = "SELECT email, picture_uri FROM $user_table
+ WHERE user_id=".$id;
+ $res = Database::query($sql);
- if (!Database::num_rows($res) && !$gravatarEnabled) {
- return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
+ if (!Database::num_rows($res)) {
+ return $anonymousPath;
+ }
+ $user = Database::fetch_array($res);
+ } else {
+ $user = $userInfo;
}
- $user = Database::fetch_array($res);
+ $pictureFilename = trim($user['picture_uri']);
+
+ $dir = self::getUserPathById($id, $type);
- $picture_filename = trim($user['picture_uri']);
+ return array(
+ 'dir' => $dir,
+ 'file' => $pictureFilename,
+ 'email' => $user['email'],
+ );
+ }
+ /**
+ * Get user path from user ID (returns an array).
+ * The return format is a complete path to a folder ending with "/"
+ * @param integer $id User ID
+ * @param string $type Type of path to return (can be 'system', 'web')
+ * @return string User folder path (i.e. /var/www/chamilo/main/upload/users/1/1/)
+ */
+ public static function getUserPathById($id, $type)
+ {
+ $id = intval($id);
+ if (!$id) {
+ return null;
+ }
+
+ $userPath = "upload/users/$id/";
if (api_get_setting('split_users_upload_directory') === 'true') {
- $userPath = 'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
- $systemImagePath = api_get_path(SYS_CODE_PATH).$userPath;
- $dir = $base.$userPath;
- } else {
- $userPath = 'upload/users/'.$user_id.'/';
- $systemImagePath = api_get_path(SYS_CODE_PATH).$userPath;
- $dir = $base.$userPath;
+ $userPath = 'upload/users/'.substr((string) $id, 0, 1).'/'.$id.'/';
+ }
+
+ switch ($type) {
+ case 'system': // Base: absolute system path.
+ $userPath = api_get_path(SYS_APP_PATH).$userPath;
+ break;
+ case 'web': // Base: absolute web path.
+ $userPath = api_get_path(WEB_PATH).'app/'.$userPath;
+ break;
}
+ return $userPath;
+ }
+
+ /**
+ * Gets the current user image
+ * @param string $user_id
+ * @param string $size it can be USER_IMAGE_SIZE_SMALL,
+ * USER_IMAGE_SIZE_MEDIUM, USER_IMAGE_SIZE_BIG or USER_IMAGE_SIZE_ORIGINAL
+ * @param bool $addRandomId
+ * @param array $userInfo to avoid query the DB
+ *
+ * @return string
+ */
+ public static function getUserPicture(
+ $user_id,
+ $size = USER_IMAGE_SIZE_MEDIUM,
+ $addRandomId = true,
+ $userInfo = []
+ ) {
+ $imageWebPath = self::get_user_picture_path_by_id($user_id, 'web', $userInfo);
+ $pictureWebFile = $imageWebPath['file'];
+ $pictureWebDir = $imageWebPath['dir'];
+
+ switch ($size) {
+ case USER_IMAGE_SIZE_SMALL:
+ $pictureAnonymous = 'unknown_22.jpg';
+ $realSizeName = 'small_';
+ $gravatarSize = 22;
+ break;
+ case USER_IMAGE_SIZE_MEDIUM:
+ $pictureAnonymous = 'unknown_50_50.jpg';
+ $realSizeName = 'medium_';
+ $gravatarSize = 50;
+ break;
+ case USER_IMAGE_SIZE_ORIGINAL:
+ $pictureAnonymous = 'unknown.jpg';
+ $realSizeName = '';
+ $gravatarSize = 108;
+ break;
+ case USER_IMAGE_SIZE_BIG:
+ $pictureAnonymous = 'unknown.jpg';
+ $realSizeName = 'big_';
+ $gravatarSize = 200;
+ break;
+ }
+
+ $gravatarEnabled = api_get_configuration_value('gravatar_enabled');
+
if ($gravatarEnabled) {
- $avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']);
- $avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
- $avatarSize['width'] :
- $avatarSize['height'];
- return array(
- 'dir' => '',
- 'file' => self::getGravatar(
- $user['email'],
- $avatarSize,
- api_get_configuration_value('gravatar_type')
- )
+ $file = self::getGravatar(
+ $imageWebPath['email'],
+ $gravatarSize,
+ api_get_configuration_value('gravatar_type')
);
+
+ if ($addRandomId) {
+ $file .= '&rand='.uniqid();
+ }
+ return $file;
+ }
+ $anonymousPath = api_get_path(WEB_CODE_PATH).'img/'.$pictureAnonymous;
+
+ if ($pictureWebFile == 'unknown.jpg') {
+
+ return $anonymousPath;
+ }
+
+ $pictureSysPath = self::get_user_picture_path_by_id($user_id, 'system');
+
+ $file = $pictureSysPath['dir'].$realSizeName.$pictureWebFile;
+ $picture = '';
+ if (file_exists($file)) {
+ $picture = $pictureWebDir.$realSizeName.$pictureWebFile;
+ } else {
+ $file = $pictureSysPath['dir'].$pictureWebFile;
+ if (file_exists($file) && !is_dir($file)) {
+ $picture = $pictureWebFile['dir'].$pictureWebFile;
+ }
+ }
+
+ if (empty($picture)) {
+ return $anonymousPath;
}
- if (empty($picture_filename) && $anonymous) {
- return $noPicturePath;
+ if ($addRandomId) {
+ $picture .= '?rand='.uniqid();
}
- return array('dir' => $dir, 'file' => $picture_filename);
+ return $picture;
}
/**
* Creates new user photos in various sizes of a user, or deletes user photos.
* Note: This method relies on configuration setting from main/inc/conf/profile.conf.php
- * @param int $user_id The user internal identification number.
- * @param string $file The common file name for the newly created photos.
- * It will be checked and modified for compatibility with the file system.
- * If full name is provided, path component is ignored.
- * If an empty name is provided, then old user photos are deleted only,
+ * @param int $user_id The user internal identification number.
+ * @param string $file The common file name for the newly created photos.
+ * It will be checked and modified for compatibility with the file system.
+ * If full name is provided, path component is ignored.
+ * If an empty name is provided, then old user photos are deleted only,
* @see UserManager::delete_user_picture() as the prefered way for deletion.
- * @param string $source_file The full system name of the image from which user photos will be created.
- * @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
- * When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE.
+ * @param string $source_file The full system name of the image from which user photos will be created.
+ * @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
+ * When deletion is requested returns empty string. In case of internal error or negative validation returns FALSE.
*/
public static function update_user_picture($user_id, $file = null, $source_file = null)
{
@@ -1312,11 +1415,12 @@ class UserManager
}
// User-reserved directory where photos have to be placed.
- $path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
+ $path_info = self::get_user_picture_path_by_id($user_id, 'system');
+
$path = $path_info['dir'];
// If this directory does not exist - we create it.
if (!file_exists($path)) {
- @mkdir($path, api_get_permissions_for_new_directories(), true);
+ mkdir($path, api_get_permissions_for_new_directories(), true);
}
// The old photos (if any).
@@ -1358,7 +1462,7 @@ class UserManager
$filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
$filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
} else {
- $filename = replace_dangerous_char($filename);
+ $filename = api_replace_dangerous_char($filename);
if (PREFIX_IMAGE_FILENAME_WITH_UID) {
$filename = uniqid('').'_'.$filename;
}
@@ -1406,7 +1510,7 @@ class UserManager
}
// User-reserved directory where extra file have to be placed.
- $path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
+ $path_info = self::get_user_picture_path_by_id($user_id, 'system');
$path = $path_info['dir'];
if (!empty($extra_field)) {
$path .= $extra_field . '/';
@@ -1450,7 +1554,7 @@ class UserManager
* productions on the filesystem before the removal request has been carried
* out because they'll have to be re-read afterwards anyway.
*
- * @param $user_id User id
+ * @param int $user_id User id
* @param $force Optional parameter to force building after a removal request
* @return A string containing the XHTML code to dipslay the production list, or FALSE
*/
@@ -1489,7 +1593,7 @@ class UserManager
* Returns an array with the user's productions.
*
* @param $user_id User id
- * @return An array containing the user's productions
+ * @return array An array containing the user's productions
*/
public static function get_user_productions($user_id)
{
@@ -1847,7 +1951,7 @@ class UserManager
return false;
}
- $path_info = self::get_user_picture_path_by_id($user_id, 'web', true);
+ $path_info = self::get_user_picture_path_by_id($user_id, 'web');
$path = $path_info['dir'];
$del_image = api_get_path(WEB_CODE_PATH).'img/delete.png';
$del_text = get_lang('Delete');
@@ -1879,7 +1983,7 @@ class UserManager
if (!$full_path) {
// Nothing to do
} else {
- $path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
+ $path_info = self::get_user_picture_path_by_id($user_id, 'system');
$path = $path_info['dir'];
}
$extra_data = self::get_extra_user_data_by_field($user_id, $extra_field);
@@ -1914,7 +2018,7 @@ class UserManager
public static function remove_user_extra_file($user_id, $extra_field, $extra_file)
{
$extra_file = Security::filter_filename($extra_file);
- $path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
+ $path_info = self::get_user_picture_path_by_id($user_id, 'system');
if (strpos($extra_file, $extra_field) !== false) {
$path_extra_file = $path_info['dir'].$extra_file;
} else {
@@ -3239,97 +3343,7 @@ class UserManager
return $temp;
}
- /**
- * Gets the current user image
- * @param string user id
- * @param string picture user name
- * @param string height
- * @param string picture size it can be USER_IMAGE_SIZE_SMALL, USER_IMAGE_SIZE_MEDIUM, USER_IMAGE_SIZE_BIG or USER_IMAGE_SIZE_ORIGINAL
- * @param string style css
- * @return array with the file and the style of an image i.e $array['file'] $array['style']
- */
- public static function get_picture_user($user_id, $picture_file, $height, $size_picture = USER_IMAGE_SIZE_MEDIUM, $style = '')
- {
- $gravatarEnabled = api_get_configuration_value('gravatar_enabled');
- $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;
- if (!$gravatarEnabled) {
- return $picture;
- }
- }
- switch ($size_picture) {
- case USER_IMAGE_SIZE_ORIGINAL :
- $size_picture = '';
- break;
- case USER_IMAGE_SIZE_BIG :
- $size_picture = 'big_';
- break;
- case USER_IMAGE_SIZE_MEDIUM :
- $size_picture = 'medium_';
- break;
- case USER_IMAGE_SIZE_SMALL :
- $size_picture = 'small_';
- break;
- default:
- $size_picture = 'medium_';
- }
-
- $image_array_sys = self::get_user_picture_path_by_id($user_id, 'system', false, true);
- $image_array = self::get_user_picture_path_by_id($user_id, 'web', false, true);
-
- $file = $image_array_sys['dir'].$size_picture.$picture_file;
-
- if (file_exists($file)) {
- $picture['file'] = $image_array['dir'].$size_picture.$picture_file;
- $picture['style'] = '';
- if ($height > 0) {
- $dimension = api_getimagesize($picture['file']);
- $margin = (($height - $dimension['width']) / 2);
-
- //@ todo the padding-top should not be here
- $picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension['width'].'px; height:'.$dimension['height'].'px;" ';
- $picture['original_height'] = $dimension['width'];
- $picture['original_width'] = $dimension['height'];
- }
- } else {
- $file = $image_array_sys['dir'].$picture_file;
- if (file_exists($file) && !is_dir($file)) {
- $picture['file'] = $image_array['dir'].$picture_file;
- } else {
- switch ($size_picture) {
- case 'big_' :
- $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
- break;
- case 'medium_' :
- $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_50_50.jpg';
- break;
- case 'small_' :
- $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
- break;
- default:
- $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
- break;
- }
- }
- }
- if ($gravatarEnabled) {
- $picture['file'] = $image_array['file'];
- }
- return $picture;
- }
/**
* @author Isaac flores
@@ -5287,7 +5301,14 @@ EOF;
* @return String containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
- public static function getGravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
+ private static function getGravatar(
+ $email,
+ $s = 80,
+ $d = 'mm',
+ $r = 'g',
+ $img = false,
+ $atts = array()
+ ) {
$url = 'http://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
@@ -5300,40 +5321,13 @@ EOF;
return $url;
}
- /**
- * Get user path from user ID (returns an array).
- * The return format is a complete path to a folder ending with "/"
- * @param integer User ID
- * @param string Optional. Type of path to return (can be 'system', 'rel', 'web')
- * @return string User folder path (i.e. /var/www/chamilo/main/upload/users/1/1/)
- */
- public static function getUserPathById($id, $type = null)
- {
- $user_id = intval($id);
- if (!$user_id) {
- return null;
- }
- $userPath = "upload/users/$user_id/";
- if (api_get_setting('split_users_upload_directory') === 'true') {
- $userPath = 'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
- }
- switch ($type) {
- case 'system': // Base: absolute system path.
- $userPath = api_get_path(SYS_CODE_PATH).$userPath;
- break;
- case 'rel': // Base: semi-absolute web path (no server base).
- $userPath = api_get_path(REL_CODE_PATH).$userPath;
- break;
- case 'web': // Base: absolute web path.
- $userPath = api_get_path(WEB_CODE_PATH).$userPath;
- break;
- }
- return $userPath;
- }
+
/**
* Displays the name of the user and makes the link to the user profile
- * @param $userInfo
+ * @param array $userInfo
+ *
+ * @return string
*/
public static function getUserProfileLink($userInfo)
{
@@ -5346,14 +5340,13 @@ EOF;
/**
* Displays the name of the user and makes the link to the user profile
+ *
* @param $userInfo
- * @todo
+ *
+ * @return string
*/
public static function getUserProfileLinkWithPicture($userInfo)
{
- $imagePath = UserManager::get_user_picture_path_by_id($userInfo['user_id'], 'web', false, true);
- $userProfile = UserManager::get_picture_user($userInfo['user_id'], $imagePath['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
-
- return Display::url(Display::img($userProfile['file']), $userInfo['profile_url']);
+ return Display::url(Display::img($userInfo['avatar']), $userInfo['profile_url']);
}
}
diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php
index 3d384ddbf5..6692b23629 100755
--- a/main/inc/lib/userportal.lib.php
+++ b/main/inc/lib/userportal.lib.php
@@ -853,30 +853,25 @@ class IndexManager
{
$html = null;
if (!api_is_anonymous()) {
- $img_array = UserManager::get_user_picture_path_by_id(
- api_get_user_id(),
- 'web', true, true
- );
- $img_array = UserManager::get_picture_user(
- api_get_user_id(),
- $img_array['file'],
- 50,
- USER_IMAGE_SIZE_MEDIUM,
- ' width="90" height="90" '
- );
- $profile_content = null;
+ $userPicture = UserManager::getUserPicture(api_get_user_id());
+ $content = null;
+
if (api_get_setting('allow_social_tool') == 'true') {
- $profile_content .= '';
+ $content .= '
+ ';
} else {
- $profile_content .= '';
+ $content .= '
+ ';
}
+
$html = self::show_right_block(
null,
- $profile_content,
+ $content,
'user_image_block',
array('style' => 'text-align:center;')
);
}
+
return $html;
}
diff --git a/main/install/install.lib.php b/main/install/install.lib.php
index 3b9c99232d..7d82385416 100755
--- a/main/install/install.lib.php
+++ b/main/install/install.lib.php
@@ -900,7 +900,7 @@ function display_requirements(
'.$_POST['content'];
//Second: student list (names, photo and links to their works).
//Third: Create Students work pages.
foreach ($a_users_to_add as $o_user_to_add) {
if ($o_user_to_add['user_id'] != $userId) {
- //except that puts the task
- $assig_user_id = $o_user_to_add['user_id']; //identifies each page as created by the student, not by teacher
- $image_path = UserManager::get_user_picture_path_by_id($assig_user_id,'web',false, true);
- $image_repository = $image_path['dir'];
- $existing_image = $image_path['file'];
+ // except that puts the task
+ $assig_user_id = $o_user_to_add['user_id'];
+ // identifies each page as created by the student, not by teacher
+
+ $userPicture = UserManager::getUserPicture($assig_user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
$name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
- $photo= '';
+ $photo= '';
- $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id,$groupId); //student is tutor
- $is_tutor_and_member = (GroupManager::is_tutor_of_group($assig_user_id,$groupId) && GroupManager::is_subscribed($assig_user_id, $groupId));
- //student is tutor and member
+ $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor
+ $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
+ // student is tutor and member
- if($is_tutor_and_member) {
+ if ($is_tutor_and_member) {
$status_in_group=get_lang('GroupTutorAndMember');
} else {
if($is_tutor_of_group) {
@@ -1958,7 +1950,6 @@ class Wiki
if ($assignment_type==1) {
$values['title']= $title_orig;
- //$values['comment'] = get_lang('AssignmentFirstComToStudent');
$values['content'] = '
'.get_lang('AssignmentWork').'
@@ -3236,9 +3227,9 @@ class Wiki
if (isset($_POST['Submit']) && self::double_post($_POST['wpost_id'])) {
$dtime = date( "Y-m-d H:i:s" );
$message_author = api_get_user_id();
- $sql="INSERT INTO $tbl_wiki_discuss (c_id, publication_id, userc_id, comment, p_score, dtime) VALUES
- ($course_id, '".$id."','".$message_author."','".Database::escape_string($_POST['comment'])."','".Database::escape_string($_POST['rating'])."','".$dtime."')";
- $result = Database::query($sql);
+ $sql = "INSERT INTO $tbl_wiki_discuss (c_id, publication_id, userc_id, comment, p_score, dtime)
+ VALUES ($course_id, '".$id."','".$message_author."','".Database::escape_string($_POST['comment'])."','".Database::escape_string($_POST['rating'])."','".$dtime."')";
+ Database::query($sql);
self::check_emailcue($id, 'D', $dtime, $message_author);
}
}//end discuss lock
@@ -3280,13 +3271,16 @@ class Wiki
echo ' - '.get_lang('RatingMedia').': '.$avg_WPost_score; // average rating
- $sql = 'UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'"
- WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
+ $sql = 'UPDATE '.$tbl_wiki.' SET
+ score="'.Database::escape_string($avg_WPost_score).'"
+ WHERE
+ c_id = '.$course_id.' AND
+ reflink="'.Database::escape_string($page).'" AND
+ '.$groupfilter.$condition_session;
// check if work ok. TODO:
Database::query($sql);
echo '';
- //echo '
';
while ($row=Database::fetch_array($result)) {
$userinfo = api_get_user_info($row['userc_id']);
@@ -3296,17 +3290,9 @@ class Wiki
$author_status=get_lang('Teacher');
}
- $user_id = $row['userc_id'];
$name = $userinfo['complete_name'];
- $author_photo= '';
-
- if ($user_id) {
- $image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
- $image_repository = $image_path['dir'];
- $existing_image = $image_path['file'];
- $author_photo= '';
- }
+ $author_photo= '';
//stars
$p_score=$row['p_score'];
diff --git a/main/work/work.lib.php b/main/work/work.lib.php
index 63e20b19ac..31f2c15448 100755
--- a/main/work/work.lib.php
+++ b/main/work/work.lib.php
@@ -3188,13 +3188,7 @@ function getWorkComments($work)
$comments = Database::store_result($result, 'ASSOC');
if (!empty($comments)) {
foreach ($comments as &$comment) {
- $pictureInfo = UserManager::get_picture_user(
- $comment['user_id'],
- $comment['picture_uri'],
- 24,
- USER_IMAGE_SIZE_SMALL
- );
- $comment['picture'] = $pictureInfo['file'];
+ $comment['picture'] = UserManager::getUserPicture($comment['user_id']);
$commentInfo = getWorkComment($comment['id']);
if (!empty($commentInfo)) {
diff --git a/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php b/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php
index 979f961934..33a1b949d3 100644
--- a/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php
+++ b/plugin/advanced_subscription/ajax/advanced_subscription.ajax.php
@@ -106,18 +106,8 @@ if ($verified) {
}
// Get student data
$studentArray = api_get_user_info($data['studentUserId']);
- $studentArray['picture'] = UserManager::get_user_picture_path_by_id(
- $studentArray['user_id'],
- 'web',
- false,
- true
- );
- $studentArray['picture'] = UserManager::get_picture_user(
- $studentArray['user_id'],
- $studentArray['picture']['file'],
- 22,
- USER_IMAGE_SIZE_MEDIUM
- );
+ $studentArray['picture'] = $studentArray['avatar'];
+
// Get superior data if exist
$superiorId = UserManager::getStudentBoss($data['studentUserId']);
if (!empty($superiorId)) {
@@ -272,18 +262,7 @@ if ($verified) {
}
// Prepare student data
$studentArray = api_get_user_info($data['studentUserId']);
- $studentArray['picture'] = UserManager::get_user_picture_path_by_id(
- $studentArray['user_id'],
- 'web',
- false,
- true
- );
- $studentArray['picture'] = UserManager::get_picture_user(
- $studentArray['user_id'],
- $studentArray['picture']['file'],
- 22,
- USER_IMAGE_SIZE_MEDIUM
- );
+ $studentArray['picture'] = $studentArray['avatar'];
// Prepare superior data
$superiorId = UserManager::getStudentBoss($data['studentUserId']);
if (!empty($superiorId)) {
diff --git a/plugin/advanced_subscription/test/mails.php b/plugin/advanced_subscription/test/mails.php
index 617eea1b9d..8eaec4d157 100644
--- a/plugin/advanced_subscription/test/mails.php
+++ b/plugin/advanced_subscription/test/mails.php
@@ -56,8 +56,8 @@ foreach ($sessionFieldValueList as $sessionFieldValue) {
}
// Get student data
$studentArray = api_get_user_info($data['studentUserId']);
-$studentArray['picture'] = UserManager::get_user_picture_path_by_id($studentArray['user_id'], 'web', false, true);
-$studentArray['picture'] = UserManager::get_picture_user($studentArray['user_id'], $studentArray['picture']['file'], 22, USER_IMAGE_SIZE_MEDIUM);
+$studentArray['picture'] = $studentArray['avatar'];
+
// Get superior data if exist
$superiorId = UserManager::getStudentBoss($data['studentUserId']);
if (!empty($superiorId)) {
diff --git a/plugin/ticket/src/new_ticket.php b/plugin/ticket/src/new_ticket.php
index 8c29143fff..7518849b78 100755
--- a/plugin/ticket/src/new_ticket.php
+++ b/plugin/ticket/src/new_ticket.php
@@ -547,25 +547,29 @@ function get_user_data($from, $number_of_items, $column, $direction)
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction ";
- $sql .= " LIMIT $from,$number_of_items";
+ $sql .= " LIMIT $from, $number_of_items";
$res = Database::query($sql);
$users = array();
while ($user = Database::fetch_row($res)) {
$user_id = $user[0];
- $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
- $user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
- if (!api_is_anonymous()) {
- $photo = '