1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-29 10:38:08 +01:00

Issue #257 , Issue #64, Issue #236 - usersettings and avatar upload issues.

This commit is contained in:
Cameron 2013-05-07 20:30:20 -07:00
parent a47cadb9b9
commit b8362372df
6 changed files with 52 additions and 19 deletions

View File

@ -92,7 +92,7 @@ class usersettings_shortcodes extends e_shortcode
if(!isset($pref['auth_method']) || $pref['auth_method'] == '' || $pref['auth_method'] == 'e107' || $pref['auth_method'] == '>e107')
{
$options = array('size' => 40,'title'=>LAN_USET_23, 'required'=>0);
$options = array('size' => 40,'title'=>LAN_USET_23, 'required'=>0,'autocomplete'=>'off');
return e107::getForm()->password('password1', '', 20, $options);
}

View File

@ -104,7 +104,7 @@ $USEREXTENDED_FIELD = "<tr>
$REQUIRED_FIELD = "{FIELDNAME}<span class='required'> *</span>";
// After Saving has occurred.
$USERSETTINGS_MESSAGE = "<div style='text-align:center'>{MESSAGE}</div>";
$USERSETTINGS_MESSAGE = "{MESSAGE}";
$USERSETTINGS_MESSAGE_CAPTION = LAN_OK;
$USERSETTINGS_EDIT_CAPTION = LAN_USET_39; // 'Update User Settings'

View File

@ -1935,6 +1935,8 @@ class e_parse extends e_parser
'e_MEDIA_IMAGE/' => '{e_MEDIA_IMAGE}',
'e_MEDIA_ICON/' => '{e_MEDIA_ICON}',
'e_AVATAR/' => '{e_AVATAR}',
'e_AVATAR_DEFAULT/' => '{e_AVATAR_DEFAULT}',
'e_AVATAR_UPLOAD/' => '{e_AVATAR_UPLOAD}',
'e_WEB_JS/' => '{e_WEB_JS}',
'e_WEB_CSS/' => '{e_WEB_CSS}',
'e_WEB_IMAGE/' => '{e_WEB_IMAGE}',

View File

@ -399,8 +399,12 @@ class e_form
$previnput = $idinput."-preview";
$optioni = $idinput."-options";
$img = (strpos($curVal,"://")!==false) ? $curVal : $tp->thumbUrl(e_AVATAR_DEFAULT.$curVal);
$path = (substr($curVal,0,8) == '-upload-') ? '{e_AVATAR}upload/' : '{e_AVATAR}default/';
$curVal = str_replace('-upload-','',$curVal);
$img = (strpos($curVal,"://")!==false) ? $curVal : $tp->thumbUrl($path.$curVal);
if(!$curVal)
{
$img = $blankImg;
@ -409,25 +413,25 @@ class e_form
if($localonly == true)
{
$text = "<input class='tbox' style='width:80%' id='{$idinput}' type='hidden' name='image' size='40' value='{$curVal}' maxlength='100' />";
$text .= "<img src='".$img."' id='{$previnput}' class='e-expandit e-tip avatar' style='cursor:pointer; width:".$pref['im_width']."px; height:".$pref['im_height']."px' title='Choose an avatar for yourself'/>"; // TODO LAN
$text .= "<img src='".$img."' id='{$previnput}' class='img-rounded e-expandit e-tip avatar' style='cursor:pointer; width:".$pref['im_width']."px; height:".$pref['im_height']."px' title='Choose an avatar for yourself'/>"; // TODO LAN
}
else
{
$text = "<input class='tbox' style='width:80%' id='{$idinput}' type='text' name='image' size='40' value='$curVal' maxlength='100' title=\"".LAN_SIGNUP_111."\" />";
$text .= "<img src='".$img."' id='{$previnput}' style='display:none' />";
$text .= "<input class='btn button e-expandit' type ='button' style='cursor:pointer' size='30' value=\"Choose Avatar\" />"; //TODO Common LAN.
$text .= "<input class='img-rounded btn button e-expandit' type ='button' style='cursor:pointer' size='30' value=\"Choose Avatar\" />"; //TODO Common LAN.
}
$avFiles = e107::getFile()->get_files(e_AVATAR_DEFAULT,".jpg|.png|.gif|.jpeg|.JPG|.GIF|.PNG");
$text .= "\n<div id='{$optioni}' style='display:none' >\n"; //TODO unique id.
$text .= "\n<div id='{$optioni}' style='display:none;padding:10px' >\n"; //TODO unique id.
if (vartrue($pref['avatar_upload']) && FILE_UPLOADS && vartrue($options['upload']))
{
$diz = LAN_USET_32.($pref['im_width'] || $pref['im_height'] ? "\n".str_replace(array('--WIDTH--','--HEIGHT--'), array($pref['im_width'], $pref['im_height']), LAN_USER_86) : "");
$text .= "<div>".LAN_USET_26."<br />
<input class='tbox' name='file_userfile[avatar]' type='file' size='47' title=\"{$diz}\" />
$text .= "<div style='margin-bottom:10px'>".LAN_USET_26."
<input class='tbox' name='file_userfile[avatar]' type='file' size='47' title=\"{$diz}\" />
</div>
<div class='divider'><span>OR</span></div>";
}
@ -1695,6 +1699,11 @@ class e_form
if($optval) $ret .= " placeholder='{$optval}'";
break;
case 'autocomplete':
if($optval) $ret .= " autocomplete='{$optval}'";
break;
case 'pattern':
if($optval) $ret .= " pattern='{$optval}'";
break;
@ -1807,7 +1816,8 @@ class e_form
'label' => '',
'placeholder' => '',
'pattern' => '',
'other' => ''
'other' => '',
'autocomplete' => ''
// 'multiple' => false, - see case 'select'
);

View File

@ -775,29 +775,37 @@ class user_class
{
$classIndex = abs($classnum); // Handle negative class values
$classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
if ($classIndex == e_UC_BLANK) return '';
$tmp = explode(',',$current_value);
$chk = in_array($classnum, $tmp) ? " checked='checked'" : '';
if ($nest_level == 0)
{
$style = " style='font-weight:bold'";
}
else
{
$style = " style='text-indent:".(1.2*$nest_level)."em'";
$style = " style='text-indent:".(0.3 * $nest_level)."em'";
}
$id = "{$treename}_{$classnum}";
$ucString = $this->class_tree[$classIndex]['userclass_name'];
if ($classSign == '-')
{
$ucString = str_replace('--CLASS--', $ucString, UC_LAN_INVERT);
}
return "<div {$style}><label>
".e107::getForm()->checkbox($treename.'[]', $classnum , $chk, "id=".$id)." ".$ucString.' ('.$this->class_tree[$classIndex]['userclass_description'].")</label></div>\n";
$description = $ucString.' ('.$this->class_tree[$classIndex]['userclass_description'].")";
$id ="{$treename}_{$classSign}{$classnum}";
return "<div class='checkbox' {$style}>".e107::getForm()->checkbox($treename.'[]', $classnum , $chk, array("id"=>$id,'label'=>$description))."</div>\n";
return "<div {$style}><input type='checkbox' class='checkbox' name='{$treename}[]' id='{$treename}_{$classSign}{$classnum}' value='{$classSign}{$classnum}'{$chk} />".$this->class_tree[$classIndex]['userclass_name'].' ('.$this->class_tree[$classIndex]['userclass_description'].")</div>\n";
// return "<div {$style}><input type='checkbox' class='checkbox' name='{$treename}[]' id='{$treename}_{$classSign}{$classnum}' value='{$classSign}{$classnum}'{$chk} />".$this->class_tree[$classIndex]['userclass_name'].' ('.$this->class_tree[$classIndex]['userclass_description'].")</div>\n";
}

View File

@ -213,7 +213,7 @@ if (isset($_POST['updatesettings']))
require_once (e_HANDLER.'upload_handler.php');
require_once (e_HANDLER.'resize_handler.php');
if ($uploaded = process_uploaded_files(e_AVATAR_UPLOAD, 'prefix+ap_'.$udata['user_id'].'_', array('overwrite' => TRUE, 'file_mask'=>'jpg,png,gif', 'max_file_count' => 2)))
if ($uploaded = process_uploaded_files(e_AVATAR_UPLOAD, 'prefix+ap_'.$tp->leadingZeros($udata['user_id'],7).'_', array('overwrite' => TRUE, 'file_mask'=>'jpg,png,gif', 'max_file_count' => 2)))
{
foreach ($uploaded as $upload)
{
@ -232,8 +232,11 @@ if (isset($_POST['updatesettings']))
{
$extraErrors[] = $upload['message'];
}
}
}
}
@ -291,14 +294,13 @@ if (isset($_POST['updatesettings']))
}
if ($udata['user_image'] && !isset($changedUserData['user_image']))
{
$changedUserData['user_image'] = '';
// $changedUserData['user_image'] = ''; // FIXME Deletes the user's image when no changes made.
$avatar_to_delete = str_replace('-upload-', '', $udata['user_image']);
}
// Validate Extended User Fields.
$changedEUFData = array();
if (isset($_POST['ue']))
@ -367,6 +369,9 @@ if (isset($_POST['updatesettings']))
$error = TRUE;
}
}
} // End - update setttings
elseif (isset($_POST['SaveValidatedInfo']))
{ // Next bit only valid if user editing their own data
@ -632,7 +637,7 @@ if ($dataToSave && !$promptPassword)
{
$message = str_replace("{MESSAGE}",$message,$USERSETTINGS_MESSAGE);
}
else // backwards compatible
elseif(!deftrue('e_BOOTSTRAP')) // backwards compatible
{
$message = "<div style='text-align:center'>".$message.'</div>';
@ -681,9 +686,17 @@ if ($error)
// --- User data has been updated here if appropriate ---
$testSessionMessage = e107::getMessage()->get(E_MESSAGE_SUCCESS, 'default', true); // only success in the session
if($testSessionMessage) $message = implode('<br />', $testSessionMessage); // we got raw message - array
if (isset($message))
{
$ns->tablerender($caption, $message);
if(deftrue('e_BOOTSTRAP'))
{
echo e107::getMessage()->addInfo($message)->render();
}
else
{
$ns->tablerender($caption, $message);
}
}