Starting at Line 144 (/admin/user.php) you need to alter it to read
foreach (array_keys($fields) as $i) {
$fieldname = $fields[$i]->getVar('field_name');
if (in_array($fields[$i]->getVar('fieldid'), $editable_fields) && ($fields[$i]->getvar('field_type') != "image" || isset($_REQUEST[$fieldname]))) {
if (in_array($fieldname, $profile_handler->getUserVars())) {
$value = $fields[$i]->getValueForSave($_REQUEST[$fieldname], $user->getVar($fieldname, 'n'));
$user->setVar($fieldname, $value);
}
else {
$value = $fields[$i]->getValueForSave((isset($_REQUEST[$fieldname]) ? $_REQUEST[$fieldname] : ""), $profile->getVar($fieldname, 'n'));
$profile->setVar($fieldname, $value);
}
} elseif ($fields[$i]->getvar('field_type') == "image"){
$value = $fields[$i]->getValueForSave($fieldname, $profile->getVar($fieldname, 'n'),$imageindex);
$profile->setVar($fieldname, $value);
}
}
And starting line 78 you need to alter the foreach also to read
foreach (array_keys($fields) as $i) {
$fieldname = $fields[$i]->getVar('field_name');
if (in_array($fields[$i]->getVar('fieldid'), $editable_fields) && ($fields[$i]->getvar('field_type') != "image" || isset($_REQUEST[$fieldname]))) {
if (in_array($fieldname, $profile_handler->getUserVars())) {
$value = $fields[$i]->getValueForSave($_REQUEST[$fieldname], $edituser->getVar($fieldname, 'n'));
$edituser->setVar($fieldname, $value);
}
else {
$value = $fields[$i]->getValueForSave((isset($_REQUEST[$fieldname]) ? $_REQUEST[$fieldname] : ""), $profile->getVar($fieldname, 'n'));
$profile->setVar($fieldname, $value);
}
} elseif ($fields[$i]->getvar('field_type') == "image"){
$value = $fields[$i]->getValueForSave($fieldname, $profile->getVar($fieldname, 'n'),$imageindex);
$profile->setVar($fieldname, $value);
}
}
The changes to /class/field.php need to be changed as you can't do an
isset on a
$_FILES object it will always read true.
Starting at line 363 of the select case you need to make the following changes through to the
fetchmedia call, the case statement should read
case "image":
foreach ($_POST['xoops_upload_file'] as $result){
$count++;
if ($result==$this->getVar('field_name')){
$index = $count-1;
break;
}
}
if (!isset($_FILES[$_POST['xoops_upload_file'][$index]])||$_FILES[$_POST['xoops_upload_file'][$index]]['error']==4) {
return $oldvalue;
} else {
//print_r($_FILES[$_POST['xoops_upload_file'][$index]]);
}
/*if (!isset($_FILES[$this->getVar('field_name')])) {
return $oldvalue;
}*/
$options = $this->getVar('field_options');
$dirname = XOOPS_UPLOAD_PATH."/smartprofile";
if (!is_dir($dirname)) {
mkdir($dirname);
}
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
$uploader = new XoopsMediaUploader($dirname, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $options['maxsize']*1024, $options['maxwidth'], $options['maxheight']);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][$index])) {
$uploader->setPrefix('image');
if ($uploader->upload()) {
@unlink($dirname."/".$oldvalue);
return $uploader->getSavedFileName();
}
else {
echo $uploader->getErrors();
return $oldvalue;
}
}
else {
echo $uploader->getErrors();
return $oldvalue;
}
break;