Replace 'get_user_picture_path_by_id' with 'getUserPathById' calls when only directory is needed - refs #4507

1.10.x
Imanol Losada 11 years ago
parent 8637521bb2
commit 1cecc9abbe
  1. 3
      main/auth/profile.php
  2. 7
      main/inc/course_document.inc.php
  3. 14
      main/inc/lib/certificate.lib.php
  4. 6
      main/inc/lib/extra_field_value.lib.php
  5. 4
      main/inc/lib/message.lib.php
  6. 5
      main/inc/lib/social.lib.php
  7. 8
      main/inc/lib/svg-edit/extensions/imagelib/users.php
  8. 2
      main/messages/download.php
  9. 20
      src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php

@ -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);

@ -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/';
} }
} }

@ -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);

@ -172,8 +172,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;
} }
@ -212,8 +211,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;
} }

@ -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/';

@ -1172,9 +1172,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']);
@ -1410,10 +1409,10 @@ 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']; $imageBig = $pathUserInfo['file'];
$imageSmall = $pathUserInfo['file']; $imageSmall = $pathUserInfo['file'];
if (!api_get_configuration_value('gravatar_enabled')) { 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);
} }

@ -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);

@ -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;

@ -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