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. 4
      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. 46
      main/inc/lib/social.lib.php
  14. 8
      main/inc/lib/svg-edit/extensions/imagelib/users.php
  15. 55
      main/inc/lib/usermanager.lib.php
  16. 2
      main/messages/download.php
  17. 10
      main/mySpace/myStudents.php
  18. 7
      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'); $message = Display::return_message($err_msg, 'error');
} }
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// USER PICTURE // USER PICTURE
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web'); $image_path = UserManager::get_user_picture_path_by_id($user_id,'web');
$image_dir = $image_path['dir']; $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_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown.jpg');
$image_size = api_getimagesize($image_file); $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']).'" ' .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" '; .'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_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width']; $big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height']; $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; $content = null;
if ($image == '') { if ($image == '') {

@ -323,8 +323,7 @@ function is_profile_editable() {
* @return The filename of the new production or FALSE if the upload has failed * @return The filename of the new production or FALSE if the upload has failed
*/ */
function upload_user_production($user_id) { function upload_user_production($user_id) {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'system'); $production_repository = UserManager::getUserPathById($user_id, 'system');
$production_repository = $image_path['dir'];
if (!file_exists($production_repository)) { if (!file_exists($production_repository)) {
@mkdir($production_repository, api_get_permissions_for_new_directories(), true); @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)); Display::addFlash(Display :: return_message($warning_msg, 'warning', false));
} }
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// User picture size is calculated from SYSTEM path // 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 = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true);
$image_syspath['dir'].$image_syspath['file']; $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_dir = $image_path['dir'];
$image = $image_path['file']; $image = $image_path['file'];
$image_file = $image_dir.$image; $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']).'" ' .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" '; .'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_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width']; $big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height']; $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; $show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false;
$tpl = new Template(get_lang('ModifyProfile')); $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']; $userPhoto = $userImage['dir'].$userImage['file'];
} }
if (api_get_configuration_value('gravatar_enabled')) {
$userPhoto = $userImage['file'];
}
$filePhoto = '<img class="chat-image" src="'.$userPhoto.'"/>'; $filePhoto = '<img class="chat-image" src="'.$userPhoto.'"/>';
if ($isMaster) { if ($isMaster) {

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

@ -720,7 +720,12 @@ class DisplayGradebook
//Web path //Web path
$image_path = UserManager::get_user_picture_path_by_id($userid, 'web', false, true); $image_path = UserManager::get_user_picture_path_by_id($userid, 'web', false, true);
$image_file = $image_path['dir'] . $image_path['file']; $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) { if ($image_size[0] > 200) {
//limit display width to 200px //limit display width to 200px
$img_attributes .= 'width="200" '; $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_path = UserManager::get_user_picture_path_by_id($user_id,'web',false,true);
$image_file = $image_path['dir'].$image_path['file']; $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']).'" ' .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:left; padding:5px;" '; .'style="float:left; padding:5px;" ';

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

@ -1417,8 +1417,7 @@ function _api_format_user($user, $add_password = false)
} }
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename; $image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if ($picture_filename) { if ($picture_filename && file_exists($image_sys_path)) {
if (file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename; $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_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename; $result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
@ -1438,7 +1437,6 @@ function _api_format_user($user, $add_password = false)
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType); $result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
} }
} }
}
if (isset($user['user_is_online'])) { if (isset($user['user_is_online'])) {
$result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0; $result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0;

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

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

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

@ -502,7 +502,7 @@ class MessageManager
if (!empty($group_id)) { if (!empty($group_id)) {
$path_user_info = GroupPortalManager::get_group_picture_path_by_id($group_id, 'system', true); $path_user_info = GroupPortalManager::get_group_picture_path_by_id($group_id, 'system', true);
} else { } 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/'; $path_message_attach = $path_user_info['dir'].'message_attachments/';
@ -548,7 +548,7 @@ class MessageManager
if (!empty($group_id)) { if (!empty($group_id)) {
$path_user_info = GroupPortalManager::get_group_picture_path_by_id($group_id, 'system', true); $path_user_info = GroupPortalManager::get_group_picture_path_by_id($group_id, 'system', true);
} else { } 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/'; $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); $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 = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'].'?'.uniqid(); $big_image = $big_image['file'];
$normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid(); $normal_image = $img_array['dir'].$img_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$big_image .= '?'.uniqid();
$normal_image .= '?'.uniqid();
}
//--- User image //--- User image
if ($img_array['file'] != 'unknown.jpg') { if ($img_array['file'] != 'unknown.jpg') {
@ -953,13 +957,14 @@ class SocialManager extends UserManager
$status_icon = Display::span('', array('class' => 'online_user_in_text')); $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')); $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['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); $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'].'">'; 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'].'">';
$name = '<a href="'.$url.'">'.$status_icon.$user_status.$name.'</a><br>'; $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>'; $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')); $interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
$html .= '<div class ="thumbnail">'; $html .= '<div class ="thumbnail">';
if (strlen(trim($user_object->picture_uri)) > 0) {
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system'); $sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir']; $sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web'); $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
if (strlen(trim($user_object->picture_uri)) > 0) {
$webdir = $webdir_array['dir']; $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; $system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = @getimagesize($system_image_path); list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30; $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.'\');" >'; //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.'" />'; $html .= '<img src="'.$fullurl.'" alt="'.$alt.'" />';
} else { } 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)) { if (!empty($status)) {
$html .= '<div class="caption">'.$status.'</div>'; $html .= '<div class="caption">'.$status.'</div>';
@ -1059,10 +1070,9 @@ class SocialManager extends UserManager
*/ */
public static function display_productions($user_id) 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_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)) { if (!is_dir($sysdir)) {
mkdir($sysdir, api_get_permissions_for_new_directories(), true); 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); $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// create directory // create directory
$pathUserInfo = UserManager::get_user_picture_path_by_id($userId, 'system', true);
$social = '/social/'; $social = '/social/';
$pathMessageAttach = $pathUserInfo['dir'] . 'message_attachments'. $social; $pathMessageAttach = UserManager::getUserPathById($userId, 'system').'message_attachments'.$social;
$safeFileComment = Database::escape_string($fileComment); $safeFileComment = Database::escape_string($fileComment);
$safeFileName = Database::escape_string($fileAttach['name']); $safeFileName = Database::escape_string($fileAttach['name']);
@ -1246,6 +1255,7 @@ class SocialManager extends UserManager
if (empty($start)) { if (empty($start)) {
$start = '0000-00-00'; $start = '0000-00-00';
} }
$tblMessage = Database::get_main_table(TABLE_MESSAGE); $tblMessage = Database::get_main_table(TABLE_MESSAGE);
$tblMessageAttachement = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $tblMessageAttachement = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
@ -1426,9 +1436,13 @@ class SocialManager extends UserManager
$wallImage = ''; $wallImage = '';
if (!empty($message['path'])) { if (!empty($message['path'])) {
$pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true); $pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true);
$pathImg = $pathUserInfo['dir'] . 'message_attachments'; $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); $imageBig = $pathImg .self::getImagePath($message['path'], IMAGE_WALL_BIG);
$imageSmall = $pathImg. self::getImagePath($message['path'], IMAGE_WALL_SMALL); $imageSmall = $pathImg. self::getImagePath($message['path'], IMAGE_WALL_SMALL);
}
$wallImage = '<a class="thumbnail ajax" href="'.$imageBig.'"><img src="'.$imageSmall.'"></a>'; $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_protect_course_script();
api_block_anonymous_users(); api_block_anonymous_users();
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system'); $userId = api_get_user_id();
$user_disk_path = $my_path['dir'].'my_files/'; $user_disk_path = UserManager::getUserPathById($userId, 'system').'my_files/';
$user_web_path = UserManager::getUserPathById($userId, 'web').'my_files/';
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web');
$user_web_path = $my_path['dir'].'my_files/';
//get all files and folders //get all files and folders
$scan_files = scandir($user_disk_path); $scan_files = scandir($user_disk_path);

@ -1234,10 +1234,10 @@ class UserManager
default: // Base: empty, the result path below will be relative. default: // Base: empty, the result path below will be relative.
$base = ''; $base = '';
} }
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$noPicturePath = array('dir' => $base.'img/', 'file' => 'unknown.jpg'); $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' => ''); 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; $sql = "SELECT email, picture_uri FROM $user_table WHERE user_id=".$user_id;
$res = Database::query($sql); $res = Database::query($sql);
if (!Database::num_rows($res)) { if (!Database::num_rows($res) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => ''); return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
} }
@ -1265,14 +1265,7 @@ class UserManager
$dir = $base.$userPath; $dir = $base.$userPath;
} }
if (empty($picture_filename) || if ($gravatarEnabled) {
(!empty($picture_filename) && !file_exists($systemImagePath.$picture_filename))
) {
if ($anonymous) {
return $noPicturePath;
}
if (api_get_configuration_value('gravatar_enabled')) {
$avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']); $avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ? $avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] : $avatarSize['width'] :
@ -1286,6 +1279,9 @@ class UserManager
) )
); );
} }
if (empty($picture_filename) && $anonymous) {
return $noPicturePath;
} }
return array('dir' => $dir, 'file' => $picture_filename); 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 = '') 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 = array();
$picture['style'] = $style; $picture['style'] = $style;
if ($picture_file == 'unknown.jpg') { if ($picture_file == 'unknown.jpg') {
@ -3261,8 +3258,10 @@ class UserManager
break; break;
} }
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file; $picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
if (!$gravatarEnabled) {
return $picture; return $picture;
} }
}
switch ($size_picture) { switch ($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL : case USER_IMAGE_SIZE_ORIGINAL :
@ -3319,6 +3318,9 @@ class UserManager
} }
} }
} }
if ($gravatarEnabled) {
$picture['file'] = $image_array['file'];
}
return $picture; return $picture;
} }
@ -5285,4 +5287,35 @@ EOF;
} }
return $url; 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'])) { if (!empty($row_users['group_id'])) {
$path_user_info = GroupPortalManager::get_group_picture_path_by_id($row_users['group_id'], 'system', true); $path_user_info = GroupPortalManager::get_group_picture_path_by_id($row_users['group_id'], 'system', true);
} else { } 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; $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 '<table width="100%" border="0">';
echo '<tr>'; 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); $image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true);
echo '<td class="borderRight" width="10%" valign="top">'; 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_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width']; $big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height']; $big_image_height = $big_image_size['height'];
$url_big_image = $big_image . '?rnd=' . time(); $url_big_image = $image_file;
$img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' . if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd=' . time();
$image_file .= '?rnd=' . time();
}
$img_attributes = 'src="' . $image_file . '" ' .
'alt="' . $user_info['complete_name']. '" ' . 'alt="' . $user_info['complete_name']. '" ' .
'style="float:' . ($text_dir == 'rtl' ? 'right' : 'left') . '; padding:5px;" '; '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_size = api_getimagesize($big_image);
$big_image_width= $big_image_size['width']; $big_image_width= $big_image_size['width'];
$big_image_height= $big_image_size['height']; $big_image_height= $big_image_size['height'];
$url_big_image = $image_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$url_big_image = $big_image.'?rnd='.time(); $url_big_image = $big_image.'?rnd='.time();
}
if ($image_array['file']=='unknown.jpg') { if ($image_array['file']=='unknown.jpg') {
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">'; 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_size = api_getimagesize($big_image);
$big_image_width= $big_image_size['width']; $big_image_width= $big_image_size['width'];
$big_image_height= $big_image_size['height']; $big_image_height= $big_image_size['height'];
$url_big_image = $image_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$url_big_image = $big_image.'?rnd='.time(); $url_big_image = $big_image.'?rnd='.time();
}
if ($image_array['file']=='unknown.jpg') { if ($image_array['file']=='unknown.jpg') {
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">'; echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
} else { } else {

@ -1853,23 +1853,25 @@ class Wiki
$all_students_pages = array(); $all_students_pages = array();
//data about teacher //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)); $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
$name = $userinfo['complete_name']." - ".$username; $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']; $image_repository = $image_path['dir'];
$existing_image = $image_path['file']; $existing_image = $image_path['file'];
$photo= '<img src="'.$image_repository.$existing_image.'" 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 . '" />';
} else {
$photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
} }
//teacher assignment title //teacher assignment title
$title_orig = $values['title']; $title_orig = $values['title'];
//teacher assignment reflink //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) //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>'; // $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). //Second: student list (names, photo and links to their works).
//Third: Create Students work pages. //Third: Create Students work pages.
foreach ($a_users_to_add as $o_user_to_add) { 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 //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 $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_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) { 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']; $assig_user_id=$o_user_to_add['user_id'];
if ($assignment_type == 1) { if ($assignment_type == 1) {
$values['title']= $title_orig; $values['title']= $title_orig;
@ -3183,7 +3185,7 @@ class Wiki
$sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user $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."' 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()); $result=Database::query($sql) or die(Database::error());
$countWPost = Database::num_rows($result); $countWPost = Database::num_rows($result);
@ -3229,13 +3231,14 @@ class Wiki
$user_id = $row['userc_id']; $user_id = $row['userc_id'];
$name = $userinfo['complete_name']; $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_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
$image_repository = $image_path['dir']; $image_repository = $image_path['dir'];
$existing_image = $image_path['file']; $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).'" />'; $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 //stars

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

Loading…
Cancel
Save