Merge branch 'ilosada-4507' into 1.10.x

1.10.x
Yannick Warnier 11 years ago
commit 97b47c717f
  1. 13
      main/admin/user_edit.php
  2. 16
      main/auth/profile.php
  3. 4
      main/chat/chat_functions.lib.php
  4. 5
      main/chat/chat_whoisonline.php
  5. 7
      main/gradebook/lib/fe/displaygradebook.php
  6. 6
      main/gradebook/user_info.php
  7. 7
      main/inc/course_document.inc.php
  8. 38
      main/inc/lib/api.lib.php
  9. 14
      main/inc/lib/certificate.lib.php
  10. 6
      main/inc/lib/extra_field_value.lib.php
  11. 10
      main/inc/lib/group_portal_manager.lib.php
  12. 4
      main/inc/lib/message.lib.php
  13. 62
      main/inc/lib/social.lib.php
  14. 8
      main/inc/lib/svg-edit/extensions/imagelib/users.php
  15. 81
      main/inc/lib/usermanager.lib.php
  16. 2
      main/messages/download.php
  17. 10
      main/mySpace/myStudents.php
  18. 11
      main/user/userInfo.php
  19. 29
      main/wiki/wiki.inc.php
  20. 20
      src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php

@ -442,6 +442,8 @@ if ($error_drh) {
$message = Display::return_message($err_msg, 'error');
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// USER PICTURE
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web');
$image_dir = $image_path['dir'];
@ -449,7 +451,11 @@ $image = $image_path['file'];
$image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown.jpg');
$image_size = api_getimagesize($image_file);
$img_attributes = 'src="'.$image_file.'?rand='.time().'" '
if (!$gravatarEnabled) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
@ -462,7 +468,10 @@ $big_image = $image_dir.'big_'.$image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd='.time();
}
$content = null;
if ($image == '') {

@ -323,8 +323,7 @@ function is_profile_editable() {
* @return The filename of the new production or FALSE if the upload has failed
*/
function upload_user_production($user_id) {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'system');
$production_repository = $image_path['dir'];
$production_repository = UserManager::getUserPathById($user_id, 'system');
if (!file_exists($production_repository)) {
@mkdir($production_repository, api_get_permissions_for_new_directories(), true);
@ -692,6 +691,8 @@ if (!empty($msg_is_not_password)){
Display::addFlash(Display :: return_message($warning_msg, 'warning', false));
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// User picture size is calculated from SYSTEM path
$image_syspath = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true);
$image_syspath['dir'].$image_syspath['file'];
@ -701,7 +702,10 @@ $image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web',
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = $image_dir.$image;
$img_attributes = 'src="'.$image_file.'?rand='.time().'" '
if (!$gravatarEnabled) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" ';
@ -711,8 +715,10 @@ $big_image = $image_dir.'big_'.$image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd='.time();
}
$show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false;
$tpl = new Template(get_lang('ModifyProfile'));

@ -222,6 +222,10 @@ function saveMessage($message, $userId, $_course, $session_id, $group_id, $previ
$userPhoto = $userImage['dir'].$userImage['file'];
}
if (api_get_configuration_value('gravatar_enabled')) {
$userPhoto = $userImage['file'];
}
$filePhoto = '<img class="chat-image" src="'.$userPhoto.'"/>';
if ($isMaster) {

@ -122,6 +122,11 @@ if (!empty($course)) {
} else {
$fileUrl = $userImage['dir'].$userImage['file'];
}
if (api_get_configuration_value('gravatar_enabled')) {
$fileUrl = $userImage['file'];
}
$email = $user['email'];
$url_user_profile=api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user['user_id'].'&';
?>

@ -720,7 +720,12 @@ class DisplayGradebook
//Web path
$image_path = UserManager::get_user_picture_path_by_id($userid, 'web', false, true);
$image_file = $image_path['dir'] . $image_path['file'];
$img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . $user['complete_name'] . '" ';
if (!api_get_configuration_value('gravatar_enabled')) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="' . $image_file . '" ' . 'alt="' . $user['complete_name'] . '" ';
if ($image_size[0] > 200) {
//limit display width to 200px
$img_attributes .= 'width="200" ';

@ -48,7 +48,11 @@ $image_size = getimagesize($image_syspath['dir'].$image_syspath['file']);
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false,true);
$image_file = $image_path['dir'].$image_path['file'];
$img_attributes = 'src="'.$image_file.'?rand='.time().'" '
if (!api_get_configuration_value('gravatar_enabled')) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:left; padding:5px;" ';

@ -64,10 +64,9 @@ if (api_is_in_course()) {
$http_www = $_configuration['root_web'].'home/default_platform_document/';
} else {
// 4. The user is outside courses.
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'system');
$base_work_dir = $my_path['dir'].'my_files/';
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web');
$http_www = $my_path['dir'].'my_files/';
$userId = api_get_user_id();
$base_work_dir = UserManager::getUserPathById($userId, 'system').'my_files/';
$http_www = UserManager::getUserPathById($userId, 'web').'my_files/';
}
}

@ -1417,26 +1417,24 @@ function _api_format_user($user, $add_password = false)
}
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if ($picture_filename) {
if (file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$result['avatar_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
} else if (api_get_configuration_value('gravatar_enabled')) {
$userEmail = isset($user['email']) ? $user['email'] : '';
$gravatarType = api_get_configuration_value('gravatar_type');
$avatarPaths = array(
'avatar' => $result['avatar'],
'avatar_small' => $result['avatar_small'],
'avatar_sys_path' => $result['avatar_sys_path']
);
foreach ($avatarPaths as $key => $value) {
$avatarSize = api_getimagesize($value);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
}
if ($picture_filename && file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$result['avatar_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
} else if (api_get_configuration_value('gravatar_enabled')) {
$userEmail = isset($user['email']) ? $user['email'] : '';
$gravatarType = api_get_configuration_value('gravatar_type');
$avatarPaths = array(
'avatar' => $result['avatar'],
'avatar_small' => $result['avatar_small'],
'avatar_sys_path' => $result['avatar_sys_path']
);
foreach ($avatarPaths as $key => $value) {
$avatarSize = api_getimagesize($value);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
}
}

@ -89,15 +89,15 @@ class Certificate extends Model
$this->certification_user_path = null;
//Setting certification path
$path_info = UserManager::get_user_picture_path_by_id($this->user_id, 'system');
$web_path_info = UserManager::get_user_picture_path_by_id($this->user_id, 'web');
$path_info = UserManager::getUserPathById($this->user_id, 'system');
$web_path_info = UserManager::getUserPathById($this->user_id, 'web');
if (!empty($path_info) && isset($path_info['dir'])) {
$this->certification_user_path = $path_info['dir'].'certificate/';
$this->certification_web_user_path = $web_path_info['dir'].'certificate/';
if (!empty($path_info) && isset($path_info)) {
$this->certification_user_path = $path_info.'certificate/';
$this->certification_web_user_path = $web_path_info.'certificate/';
if (!is_dir($path_info['dir'])) {
mkdir($path_info['dir'], 0777, true);
if (!is_dir($path_info)) {
mkdir($path_info, 0777, true);
}
if (!is_dir($this->certification_user_path)) {
mkdir($this->certification_user_path, 0777);

@ -173,8 +173,7 @@ class ExtraFieldValue extends Model
$fileDir = "upload/sessions/";
break;
case 'user':
$userPath = UserManager::get_user_picture_path_by_id($this->handler_id);
$fileDir = $userPath['dir'];
$fileDir = UserManager::getUserPathById($this->handler_id);
break;
}
@ -213,8 +212,7 @@ class ExtraFieldValue extends Model
$fileDir = "upload/sessions/";
break;
case 'user':
$userPath = UserManager::get_user_picture_path_by_id($this->handler_id);
$fileDir = $userPath['dir'];
$fileDir = UserManager::getUserPathById($this->handler_id);
break;
}

@ -912,8 +912,10 @@ class GroupPortalManager
$base = '';
}
$noPicturePath = array('dir' => $base.'img/', 'file' => 'unknown.jpg');
if (empty($id) || empty($type)) {
return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
$id = intval($id);
@ -923,7 +925,7 @@ class GroupPortalManager
$res = Database::query($sql);
if (!Database::num_rows($res)) {
return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
$user = Database::fetch_array($res);
@ -940,9 +942,11 @@ class GroupPortalManager
} else {
$dir = $base.'upload/users/groups/'.$id.'/';
}
if (empty($picture_filename) && $anonymous) {
return array('dir' => $base.'img/', 'file' => 'unknown.jpg');
return $noPicturePath;
}
return array('dir' => $dir, 'file' => $picture_filename);
}

@ -502,7 +502,7 @@ class MessageManager
if (!empty($group_id)) {
$path_user_info = GroupPortalManager::get_group_picture_path_by_id($group_id, 'system', true);
} else {
$path_user_info = UserManager::get_user_picture_path_by_id($message_user_id, 'system', true);
$path_user_info['dir'] = UserManager::getUserPathById($message_user_id, 'system');
}
$path_message_attach = $path_user_info['dir'].'message_attachments/';
@ -548,7 +548,7 @@ class MessageManager
if (!empty($group_id)) {
$path_user_info = GroupPortalManager::get_group_picture_path_by_id($group_id, 'system', true);
} else {
$path_user_info = UserManager::get_user_picture_path_by_id($message_uid, 'system', true);
$path_user_info['dir'] = UserManager::getUserPathById($message_uid, 'system');
}
$path_message_attach = $path_user_info['dir'].'message_attachments/';

@ -643,8 +643,12 @@ class SocialManager extends UserManager
$img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'].'?'.uniqid();
$normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
$big_image = $big_image['file'];
$normal_image = $img_array['dir'].$img_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$big_image .= '?'.uniqid();
$normal_image .= '?'.uniqid();
}
//--- User image
if ($img_array['file'] != 'unknown.jpg') {
@ -953,13 +957,14 @@ class SocialManager extends UserManager
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
$user_status = $user_info['status'] == 1 ? Display::span('', array('class' => 'teacher_online')) : Display::span('', array('class' => 'student_online'));
if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'].$image_array['file'])) {
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
if (($image_array['file'] == 'unknown.jpg'
|| !file_exists($image_array['dir'].$image_array['file'])) &&
!api_get_configuration_value('gravatar_enabled')) {
$friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
} else {
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
}
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
$name = '<a href="'.$url.'">'.$status_icon.$user_status.$name.'</a><br>';
$html .= '<li class="col-md-'.($column_size / 3).' thumbnail">'.$img.'<div class="caption">'.$name.'</div></li>';
}
@ -997,12 +1002,16 @@ class SocialManager extends UserManager
$interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
$html .= '<div class ="thumbnail">';
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
if (strlen(trim($user_object->picture_uri)) > 0) {
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
$webdir = $webdir_array['dir'];
$fullurl = $webdir.$user_object->picture_uri;
$fullurl = $webdir;
$fullurl .= api_get_configuration_value('gravatar_enabled') ?
$webdir_array['file'] :
$user_object->picture_uri;
$system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30;
@ -1016,7 +1025,9 @@ class SocialManager extends UserManager
//echo '<a href="javascript:void()" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');" >';
$html .= '<img src="'.$fullurl.'" alt="'.$alt.'" />';
} else {
$html .= Display::return_icon('unknown.jpg', get_lang('Unknown'));
$html .= api_get_configuration_value('gravatar_enabled') ?
'<img src="'.$webdir_array['file'].'" alt="'.$alt.'" />' :
Display::return_icon('unknown.jpg', get_lang('Unknown'));
}
if (!empty($status)) {
$html .= '<div class="caption">'.$status.'</div>';
@ -1059,10 +1070,9 @@ class SocialManager extends UserManager
*/
public static function display_productions($user_id)
{
$sysdir_array = UserManager::get_user_picture_path_by_id($user_id, 'system', true);
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
$webdir = $webdir_array['dir'];
$sysdir = UserManager::getUserPathById($user_id, 'system');
$webdir = UserManager::getUserPathById($user_id, 'web');
if (!is_dir($sysdir)) {
mkdir($sysdir, api_get_permissions_for_new_directories(), true);
@ -1190,9 +1200,8 @@ class SocialManager extends UserManager
$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;
$pathMessageAttach = UserManager::getUserPathById($userId, 'system').'message_attachments'.$social;
$safeFileComment = Database::escape_string($fileComment);
$safeFileName = Database::escape_string($fileAttach['name']);
@ -1246,6 +1255,7 @@ class SocialManager extends UserManager
if (empty($start)) {
$start = '0000-00-00';
}
$tblMessage = Database::get_main_table(TABLE_MESSAGE);
$tblMessageAttachement = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
@ -1254,10 +1264,10 @@ class SocialManager extends UserManager
$limit = intval($limit);
$sql = "SELECT id, user_sender_id,user_receiver_id, send_date, content, parent_id,
(SELECT ma.path FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as path,
(SELECT ma.filename FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as filename
FROM $tblMessage tm
WHERE user_receiver_id = $userId
(SELECT ma.path FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as path,
(SELECT ma.filename FROM $tblMessageAttachement 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' ";
@ -1426,9 +1436,13 @@ class SocialManager extends UserManager
$wallImage = '';
if (!empty($message['path'])) {
$pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true);
$pathImg = $pathUserInfo['dir'] . 'message_attachments';
$imageBig = $pathImg .self::getImagePath($message['path'], IMAGE_WALL_BIG);
$imageSmall = $pathImg. self::getImagePath($message['path'], IMAGE_WALL_SMALL);
$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);
}
$wallImage = '<a class="thumbnail ajax" href="'.$imageBig.'"><img src="'.$imageSmall.'"></a>';
}

@ -10,11 +10,9 @@ require_once '../../../../../inc/global.inc.php';
api_protect_course_script();
api_block_anonymous_users();
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system');
$user_disk_path = $my_path['dir'].'my_files/';
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web');
$user_web_path = $my_path['dir'].'my_files/';
$userId = api_get_user_id();
$user_disk_path = UserManager::getUserPathById($userId, 'system').'my_files/';
$user_web_path = UserManager::getUserPathById($userId, 'web').'my_files/';
//get all files and folders
$scan_files = scandir($user_disk_path);

@ -1234,10 +1234,10 @@ class UserManager
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)) {
if ((empty($id) || empty($type)) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
@ -1247,7 +1247,7 @@ class UserManager
$sql = "SELECT email, picture_uri FROM $user_table WHERE user_id=".$user_id;
$res = Database::query($sql);
if (!Database::num_rows($res)) {
if (!Database::num_rows($res) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
@ -1265,27 +1265,23 @@ class UserManager
$dir = $base.$userPath;
}
if (empty($picture_filename) ||
(!empty($picture_filename) && !file_exists($systemImagePath.$picture_filename))
) {
if ($anonymous) {
return $noPicturePath;
}
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')
)
);
}
if (api_get_configuration_value('gravatar_enabled')) {
$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')
)
);
}
if (empty($picture_filename) && $anonymous) {
return $noPicturePath;
}
return array('dir' => $dir, 'file' => $picture_filename);
@ -3247,6 +3243,7 @@ class UserManager
*/
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') {
@ -3261,7 +3258,9 @@ class UserManager
break;
}
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
return $picture;
if (!$gravatarEnabled) {
return $picture;
}
}
switch ($size_picture) {
@ -3319,6 +3318,9 @@ class UserManager
}
}
}
if ($gravatarEnabled) {
$picture['file'] = $image_array['file'];
}
return $picture;
}
@ -5285,4 +5287,35 @@ 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;
}
}

@ -78,7 +78,7 @@ if ($not_allowed_to_edit) {
if (!empty($row_users['group_id'])) {
$path_user_info = GroupPortalManager::get_group_picture_path_by_id($row_users['group_id'], 'system', true);
} else {
$path_user_info = UserManager::get_user_picture_path_by_id($message_uid, 'system', true);
$path_user_info['dir'] = UserManager::getUserPathById($message_uid, 'system');
}
$full_file_name = $path_user_info['dir'].'message_attachments/'.$file_url;

@ -461,6 +461,7 @@ if (!empty($student_id)) {
echo '<table width="100%" border="0">';
echo '<tr>';
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true);
echo '<td class="borderRight" width="10%" valign="top">';
@ -470,8 +471,13 @@ if (!empty($student_id)) {
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image . '?rnd=' . time();
$img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' .
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd=' . time();
$image_file .= '?rnd=' . time();
}
$img_attributes = 'src="' . $image_file . '" ' .
'alt="' . $user_info['complete_name']. '" ' .
'style="float:' . ($text_dir == 'rtl' ? 'right' : 'left') . '; padding:5px;" ';

@ -338,7 +338,10 @@ elseif ($displayMode == "viewContentEdit") {
$big_image_size = api_getimagesize($big_image);
$big_image_width= $big_image_size['width'];
$big_image_height= $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
$url_big_image = $image_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$url_big_image = $big_image.'?rnd='.time();
}
if ($image_array['file']=='unknown.jpg') {
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
@ -428,8 +431,10 @@ elseif ($displayMode == "viewContentEdit") {
$big_image_size = api_getimagesize($big_image);
$big_image_width= $big_image_size['width'];
$big_image_height= $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
$url_big_image = $image_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$url_big_image = $big_image.'?rnd='.time();
}
if ($image_array['file']=='unknown.jpg') {
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
} else {

@ -1853,23 +1853,25 @@ class Wiki
$all_students_pages = array();
//data about teacher
$userinfo = api_get_user_info(api_get_user_id());
$userId = api_get_user_id();
$userinfo = api_get_user_info($userId);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
$name = $userinfo['complete_name']." - ".$username;
if (api_get_user_id()<>0) {
$image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web',false, true);
$photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
if ($userId) {
$image_path = UserManager::get_user_picture_path_by_id($userId, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$photo= '<img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
} else {
$photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
$photo = '<img src="' . $image_repository . $existing_image . '" alt="' . $name . '" width="40" height="50" align="top" title="' . $name . '" />';
}
//teacher assignment title
$title_orig = $values['title'];
//teacher assignment reflink
$link2teacher = $values['title'] = $title_orig."_uass".api_get_user_id();
$link2teacher = $values['title'] = $title_orig."_uass".$userId;
//first: teacher name, photo, and assignment description (original content)
// $content_orig_A='<div align="center" style="background-color: #F5F8FB; border:double">'.$photo.'<br />'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'<br />('.get_lang('Teacher').')</div><br/><div>';
@ -1883,7 +1885,7 @@ class Wiki
//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'] != api_get_user_id()) {
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);
@ -1933,7 +1935,7 @@ class Wiki
}
foreach ($a_users_to_add as $o_user_to_add) {
if ($o_user_to_add['user_id'] == api_get_user_id()) {
if ($o_user_to_add['user_id'] == $userId) {
$assig_user_id=$o_user_to_add['user_id'];
if ($assignment_type == 1) {
$values['title']= $title_orig;
@ -3183,7 +3185,7 @@ class Wiki
$sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user
WHERE reviews.c_id = $course_id AND reviews.publication_id='".$id."' AND user.user_id='".$firstuserid."'
ORDER BY id DESC";
ORDER BY reviews.id DESC";
$result=Database::query($sql) or die(Database::error());
$countWPost = Database::num_rows($result);
@ -3229,13 +3231,14 @@ class Wiki
$user_id = $row['userc_id'];
$name = $userinfo['complete_name'];
if ($user_id<>0) {
$author_photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
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= '<img src="'.$image_repository.$existing_image.'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
} else {
$author_photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
}
//stars

@ -18,9 +18,9 @@ class PersonalDriver extends Driver implements DriverInterface
public function setup()
{
$userId = api_get_user_id();
$path = \UserManager::get_user_picture_path_by_id($userId, 'none');
if (!empty($path['dir'])) {
$dir = api_get_path(SYS_CODE_PATH) . $path['dir'];
$path = \UserManager::getUserPathById($userId);
if (!empty($path)) {
$dir = api_get_path(SYS_CODE_PATH) . $path;
if (!is_dir($dir)) {
mkdir($dir);
@ -44,21 +44,15 @@ class PersonalDriver extends Driver implements DriverInterface
if (!empty($userId)) {
// Adding user personal files
$dir = \UserManager::get_user_picture_path_by_id(
$userId,
'system'
);
$dir = \UserManager::getUserPathById($userId, 'system');
$dirWeb = \UserManager::get_user_picture_path_by_id(
$userId,
'web'
);
$dirWeb = \UserManager::getUserPathById($userId, 'web');
$driver = array(
'driver' => 'PersonalDriver',
'alias' => get_lang('MyFiles'),
'path' => $dir['dir'] . 'my_files',
'URL' => $dirWeb['dir'] . 'my_files',
'path' => $dir.'my_files',
'URL' => $dirWeb.'my_files',
'accessControl' => array($this, 'access')
);

Loading…
Cancel
Save