Fixing deprecated $preview parameter see BT#7110

1.9.x
Julio Montoya 12 years ago
parent 906bba1479
commit a53c260564
  1. 8
      main/auth/profile.php
  2. 3
      main/document/document.php
  3. 10
      main/inc/lib/certificate.lib.php
  4. 19
      main/inc/lib/social.lib.php
  5. 33
      main/inc/lib/usermanager.lib.php
  6. 2
      main/social/message_for_group_form.inc.php

@ -236,7 +236,6 @@ if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') {
// EXTENDED PROFILE this make the page very slow!
if (api_get_setting('extended_profile') == 'true') {
if (!isset($_GET['type']) || (isset($_GET['type']) && $_GET['type'] == 'extended')) {
$width_extended_profile = 500;
//$form->addElement('html', '<a href="javascript: void(0);" onclick="javascript: show_extend();"> show_extend_profile</a>');
//$form->addElement('static', null, '<em>'.get_lang('OptionalTextFields').'</em>');
@ -256,7 +255,7 @@ if (api_get_setting('extended_profile') == 'true') {
$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '350'));
$form->applyFilter(array('competences', 'diplomas', 'teach', 'openarea'), 'stripslashes');
$form->applyFilter(array('competences', 'diplomas', 'teach'), 'trim'); // openarea is untrimmed for maximum openness
}
}
// PASSWORD, if auth_source is platform
@ -336,9 +335,8 @@ 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', true);
$production_repository = $image_path['dir'].$user_id.'/';
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'system');
$production_repository = $image_path['dir'];
if (!file_exists($production_repository)) {
@mkdir($production_repository, api_get_permissions_for_new_directories(), true);

@ -345,8 +345,7 @@ switch ($action) {
$parent_id = $document_info['parent_id'];
$my_path = UserManager::get_user_picture_path_by_id(
api_get_user_id(),
'system',
true
'system'
);
$user_folder = $my_path['dir'].'my_files/';
$my_path = null;

@ -71,23 +71,21 @@ class Certificate extends Model {
/**
* Checks if the certificate user path directory is created
*/
public function check_certificate_path() {
public function check_certificate_path()
{
$this->certification_user_path = null;
//Setting certification path
$path_info = UserManager::get_user_picture_path_by_id($this->user_id, 'system', true);
$web_path_info = UserManager::get_user_picture_path_by_id($this->user_id, 'web', true);
$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');
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 (!is_dir($path_info['dir'])) {
mkdir($path_info['dir'], 0777, true);
}
if (!is_dir($this->certification_user_path)) {
mkdir($this->certification_user_path, 0777);
}

@ -957,26 +957,13 @@ 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'].$user_id.'/';
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
$webdir = $webdir_array['dir'].$user_id.'/';
$webdir = $webdir_array['dir'];
if (!is_dir($sysdir)) {
mkdir($sysdir, api_get_permissions_for_new_directories(), true);
}
/*
$handle = opendir($sysdir);
$productions = array();
while ($file = readdir($handle)) {
if ($file == '.' || $file == '..' || $file == '.htaccess') {
continue; // Skip current and parent directories
}
if (preg_match('/('.$user_id.'|[0-9a-f]{13}|saved)_.+\.(png|jpg|jpeg|gif)$/i', $file)) {
// User's photos should not be listed as productions.
continue;
}
$productions[] = $file;
}
*/
$productions = UserManager::get_user_productions($user_id);
if (count($productions) > 0) {

@ -1120,7 +1120,7 @@ class UserManager
* the same directory.
* @param integer User ID
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
* @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
* @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
*/
@ -1159,11 +1159,12 @@ class UserManager
$picture_filename = trim($user['picture_uri']);
if (api_get_setting('split_users_upload_directory') === 'true') {
if (!empty($picture_filename) or $preview) {
/*if (!empty($picture_filename) or $preview) {
$dir = $base.'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
} else {
$dir = $base.'upload/users/'.$user_id.'/';
}
}*/
$dir = $base.'upload/users/'.substr((string) $user_id, 0, 1).'/'.$user_id.'/';
} else {
$dir = $base.'upload/users/'.$user_id.'/';
}
@ -1352,8 +1353,8 @@ class UserManager
return false;
}
$production_path = self::get_user_picture_path_by_id($user_id, 'web', true);
$production_dir = $production_path['dir'].$user_id.'/';
$production_path = self::get_user_picture_path_by_id($user_id, 'web');
$production_dir = $production_path['dir'];
$del_image = api_get_path(WEB_CODE_PATH).'img/delete.gif';
$del_text = get_lang('Delete');
$production_list = '';
@ -1379,17 +1380,22 @@ class UserManager
*/
public static function get_user_productions($user_id)
{
$production_path = self::get_user_picture_path_by_id($user_id, 'system', true);
$production_repository = $production_path['dir'].$user_id.'/';
$production_path = self::get_user_picture_path_by_id($user_id, 'system');
$production_repository = $production_path['dir'];
$productions = array();
if (is_dir($production_repository)) {
$handle = opendir($production_repository);
while ($file = readdir($handle)) {
if ($file == '.' || $file == '..' || $file == '.htaccess' || is_dir($production_repository.$file)) {
continue; // skip current/parent directory and .htaccess
if ($file == '.' ||
$file == '..' ||
$file == '.htaccess' ||
is_dir($production_repository.$file)
) {
// skip current/parent directory and .htaccess
continue;
}
if (preg_match('/('.$user_id.'|[0-9a-f]{13}|saved)_.+\.(png|jpg|jpeg|gif)$/i', $file)) {
// User's photos should not be listed as productions.
continue;
@ -1398,7 +1404,7 @@ class UserManager
}
}
return $productions; // can be an empty array
return $productions;
}
/**
@ -1409,8 +1415,8 @@ class UserManager
*/
public static function remove_user_production($user_id, $production)
{
$production_path = self::get_user_picture_path_by_id($user_id, 'system', true);
$production_file = $production_path['dir'].$user_id.'/'.$production;
$production_path = self::get_user_picture_path_by_id($user_id, 'system');
$production_file = $production_path['dir'].$production;
if (is_file($production_file)) {
unlink($production_file);
return true;
@ -1725,7 +1731,6 @@ class UserManager
$extra_data = self::get_extra_user_data_by_field($user_id, $extra_field);
$extra_files = $extra_data[$extra_field];
if (is_array($extra_files)) {
var_dump($extra_files); exit;
foreach ($extra_files as $key => $value) {
if (!$full_path) {
// Relative path from user folder

@ -22,8 +22,6 @@ require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
$tok = Security::get_token();
if (isset($_REQUEST['user_friend'])) {
$info_user_friend=array();
$info_path_friend=array();
$userfriend_id = intval($_REQUEST['user_friend']);
// panel=1 send message
// panel=2 send invitation

Loading…
Cancel
Save