Fixing production user's file bug see #1682

skala
Julio Montoya 15 years ago
parent 15f86864c2
commit 5cc17d77b3
  1. 1
      documentation/changelog.html
  2. 35
      main/auth/profile.php
  3. 7
      main/inc/lib/usermanager.lib.php

@ -33,6 +33,7 @@
<li>Added more quality at the icons</li> <li>Added more quality at the icons</li>
<li>Fixed an encoding problem about database connection which is specific to Chinese language. The initial solution has been proposed by Oliver Corre (Bug #1802)</li> <li>Fixed an encoding problem about database connection which is specific to Chinese language. The initial solution has been proposed by Oliver Corre (Bug #1802)</li>
<li>Multiple URL feature: Fixed Course user list (BT#1547) </li> <li>Multiple URL feature: Fixed Course user list (BT#1547) </li>
<li>Deleting production user's file fixed see #1682</li>
</ul> </ul>
<h3>Security</h3> <h3>Security</h3>
<ul> <ul>

@ -41,10 +41,11 @@ $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH)
$htmlHeadXtra[] = '<script type="text/javascript"> $htmlHeadXtra[] = '<script type="text/javascript">
function confirmation(name) { function confirmation(name) {
if (confirm("'.get_lang('AreYouSureToDelete', '').' " + name + " ?")) if (confirm("'.get_lang('AreYouSureToDelete', '').' " + name + " ?")) {
{return true;} document.forms["profile"].submit();
else } else {
{return false;} return false;
}
} }
function show_image(image,width,height) { function show_image(image,width,height) {
width = parseInt(width) + 20; width = parseInt(width) + 20;
@ -73,7 +74,6 @@ if (!empty ($_GET['coursePath'])) {
$interbreadcrumb[] = array('url' => $course_url, 'name' => Security::remove_XSS($_GET['courseCode'])); $interbreadcrumb[] = array('url' => $course_url, 'name' => Security::remove_XSS($_GET['courseCode']));
} }
$warning_msg = ''; $warning_msg = '';
if (!empty($_GET['fe'])) { if (!empty($_GET['fe'])) {
$warning_msg .= get_lang('UplUnableToSaveFileFilteredExtension'); $warning_msg .= get_lang('UplUnableToSaveFileFilteredExtension');
@ -510,7 +510,6 @@ function upload_user_production($user_id) {
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);
} }
$filename = replace_dangerous_char($_FILES['production']['name']); $filename = replace_dangerous_char($_FILES['production']['name']);
$filename = disable_dangerous_file($filename); $filename = disable_dangerous_file($filename);
@ -580,15 +579,6 @@ if (!empty($_SESSION['change_email'])) {
} elseif (!empty($_SESSION['production_uploaded'])) { } elseif (!empty($_SESSION['production_uploaded'])) {
$upload_production_success = ($_SESSION['production_uploaded'] == 'success'); $upload_production_success = ($_SESSION['production_uploaded'] == 'success');
unset($_SESSION['production_uploaded']); unset($_SESSION['production_uploaded']);
} elseif (isset($_POST['remove_production'])) {
foreach (array_keys($_POST['remove_production']) as $production) {
UserManager::remove_user_production($_user['user_id'], urldecode($production));
}
if ($production_list = UserManager::build_production_list($_user['user_id'], true, true)) {
$form->insertElementBefore($form->createElement('static', null, null, $production_list), 'productions_list');
}
$form->removeElement('productions_list');
$file_deleted = true;
} }
if ($form->validate()) { if ($form->validate()) {
@ -596,6 +586,7 @@ if ($form->validate()) {
$wrong_current_password = false; $wrong_current_password = false;
// $user_data = $form->exportValues(); // $user_data = $form->exportValues();
$user_data = $form->getSubmitValues(); $user_data = $form->getSubmitValues();
// set password if a new one was provided // set password if a new one was provided
if (!empty($user_data['password0'])) { if (!empty($user_data['password0'])) {
if (check_user_password($user_data['password0'])) { if (check_user_password($user_data['password0'])) {
@ -633,6 +624,20 @@ if ($form->validate()) {
$user_data['picture_uri'] = ''; $user_data['picture_uri'] = '';
} }
//Remove production
if (is_array($user_data['remove_production'])) {
foreach (array_keys($user_data['remove_production']) as $production) {
UserManager::remove_user_production($_user['user_id'], urldecode($production));
}
if ($production_list = UserManager::build_production_list($_user['user_id'], true, true)) {
var_dump($production_list);
$form->insertElementBefore($form->createElement('static', null, null, $production_list), 'productions_list');
}
$form->removeElement('productions_list');
$file_deleted = true;
}
// upload production if a new one is provided // upload production if a new one is provided
if ($_FILES['production']['size']) { if ($_FILES['production']['size']) {
$res = upload_user_production($_user['user_id']); $res = upload_user_production($_user['user_id']);

@ -968,9 +968,12 @@ class UserManager
*/ */
public static function remove_user_production($user_id, $production) { public static function remove_user_production($user_id, $production) {
$production_path = self::get_user_picture_path_by_id($user_id, 'system', true); $production_path = self::get_user_picture_path_by_id($user_id, 'system', true);
if (is_file($production_path['dir'].$production)) { $production_file = $production_path['dir'].$user_id.'/'.$production;
unlink($production_path['dir'].$production); if (is_file($production_file)) {
unlink($production_file);
return true;
} }
return false;
} }
/** /**

Loading…
Cancel
Save