1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02: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') 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); return e107::getForm()->password('password1', '', 20, $options);
} }

View File

@@ -104,7 +104,7 @@ $USEREXTENDED_FIELD = "<tr>
$REQUIRED_FIELD = "{FIELDNAME}<span class='required'> *</span>"; $REQUIRED_FIELD = "{FIELDNAME}<span class='required'> *</span>";
// After Saving has occurred. // After Saving has occurred.
$USERSETTINGS_MESSAGE = "<div style='text-align:center'>{MESSAGE}</div>"; $USERSETTINGS_MESSAGE = "{MESSAGE}";
$USERSETTINGS_MESSAGE_CAPTION = LAN_OK; $USERSETTINGS_MESSAGE_CAPTION = LAN_OK;
$USERSETTINGS_EDIT_CAPTION = LAN_USET_39; // 'Update User Settings' $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_IMAGE/' => '{e_MEDIA_IMAGE}',
'e_MEDIA_ICON/' => '{e_MEDIA_ICON}', 'e_MEDIA_ICON/' => '{e_MEDIA_ICON}',
'e_AVATAR/' => '{e_AVATAR}', 'e_AVATAR/' => '{e_AVATAR}',
'e_AVATAR_DEFAULT/' => '{e_AVATAR_DEFAULT}',
'e_AVATAR_UPLOAD/' => '{e_AVATAR_UPLOAD}',
'e_WEB_JS/' => '{e_WEB_JS}', 'e_WEB_JS/' => '{e_WEB_JS}',
'e_WEB_CSS/' => '{e_WEB_CSS}', 'e_WEB_CSS/' => '{e_WEB_CSS}',
'e_WEB_IMAGE/' => '{e_WEB_IMAGE}', 'e_WEB_IMAGE/' => '{e_WEB_IMAGE}',

View File

@@ -399,8 +399,12 @@ class e_form
$previnput = $idinput."-preview"; $previnput = $idinput."-preview";
$optioni = $idinput."-options"; $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) if(!$curVal)
{ {
$img = $blankImg; $img = $blankImg;
@@ -409,25 +413,25 @@ class e_form
if($localonly == true) if($localonly == true)
{ {
$text = "<input class='tbox' style='width:80%' id='{$idinput}' type='hidden' name='image' size='40' value='{$curVal}' maxlength='100' />"; $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 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 = "<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 .= "<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"); $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'])) 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) : ""); $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 /> $text .= "<div style='margin-bottom:10px'>".LAN_USET_26."
<input class='tbox' name='file_userfile[avatar]' type='file' size='47' title=\"{$diz}\" /> <input class='tbox' name='file_userfile[avatar]' type='file' size='47' title=\"{$diz}\" />
</div> </div>
<div class='divider'><span>OR</span></div>"; <div class='divider'><span>OR</span></div>";
} }
@@ -1695,6 +1699,11 @@ class e_form
if($optval) $ret .= " placeholder='{$optval}'"; if($optval) $ret .= " placeholder='{$optval}'";
break; break;
case 'autocomplete':
if($optval) $ret .= " autocomplete='{$optval}'";
break;
case 'pattern': case 'pattern':
if($optval) $ret .= " pattern='{$optval}'"; if($optval) $ret .= " pattern='{$optval}'";
break; break;
@@ -1807,7 +1816,8 @@ class e_form
'label' => '', 'label' => '',
'placeholder' => '', 'placeholder' => '',
'pattern' => '', 'pattern' => '',
'other' => '' 'other' => '',
'autocomplete' => ''
// 'multiple' => false, - see case 'select' // 'multiple' => false, - see case 'select'
); );

View File

@@ -775,29 +775,37 @@ class user_class
{ {
$classIndex = abs($classnum); // Handle negative class values $classIndex = abs($classnum); // Handle negative class values
$classSign = (substr($classnum, 0, 1) == '-') ? '-' : ''; $classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
if ($classIndex == e_UC_BLANK) return ''; if ($classIndex == e_UC_BLANK) return '';
$tmp = explode(',',$current_value); $tmp = explode(',',$current_value);
$chk = in_array($classnum, $tmp) ? " checked='checked'" : ''; $chk = in_array($classnum, $tmp) ? " checked='checked'" : '';
if ($nest_level == 0) if ($nest_level == 0)
{ {
$style = " style='font-weight:bold'"; $style = " style='font-weight:bold'";
} }
else else
{ {
$style = " style='text-indent:".(1.2*$nest_level)."em'"; $style = " style='text-indent:".(0.3 * $nest_level)."em'";
} }
$id = "{$treename}_{$classnum}"; $id = "{$treename}_{$classnum}";
$ucString = $this->class_tree[$classIndex]['userclass_name']; $ucString = $this->class_tree[$classIndex]['userclass_name'];
if ($classSign == '-') if ($classSign == '-')
{ {
$ucString = str_replace('--CLASS--', $ucString, UC_LAN_INVERT); $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.'upload_handler.php');
require_once (e_HANDLER.'resize_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) foreach ($uploaded as $upload)
{ {
@@ -232,8 +232,11 @@ if (isset($_POST['updatesettings']))
{ {
$extraErrors[] = $upload['message']; $extraErrors[] = $upload['message'];
} }
} }
} }
} }
@@ -291,14 +294,13 @@ if (isset($_POST['updatesettings']))
} }
if ($udata['user_image'] && !isset($changedUserData['user_image'])) 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']); $avatar_to_delete = str_replace('-upload-', '', $udata['user_image']);
} }
// Validate Extended User Fields. // Validate Extended User Fields.
$changedEUFData = array(); $changedEUFData = array();
if (isset($_POST['ue'])) if (isset($_POST['ue']))
@@ -367,6 +369,9 @@ if (isset($_POST['updatesettings']))
$error = TRUE; $error = TRUE;
} }
} }
} // End - update setttings } // End - update setttings
elseif (isset($_POST['SaveValidatedInfo'])) elseif (isset($_POST['SaveValidatedInfo']))
{ // Next bit only valid if user editing their own data { // Next bit only valid if user editing their own data
@@ -632,7 +637,7 @@ if ($dataToSave && !$promptPassword)
{ {
$message = str_replace("{MESSAGE}",$message,$USERSETTINGS_MESSAGE); $message = str_replace("{MESSAGE}",$message,$USERSETTINGS_MESSAGE);
} }
else // backwards compatible elseif(!deftrue('e_BOOTSTRAP')) // backwards compatible
{ {
$message = "<div style='text-align:center'>".$message.'</div>'; $message = "<div style='text-align:center'>".$message.'</div>';
@@ -681,9 +686,17 @@ if ($error)
// --- User data has been updated here if appropriate --- // --- User data has been updated here if appropriate ---
$testSessionMessage = e107::getMessage()->get(E_MESSAGE_SUCCESS, 'default', true); // only success in the session $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($testSessionMessage) $message = implode('<br />', $testSessionMessage); // we got raw message - array
if (isset($message)) if (isset($message))
{ {
$ns->tablerender($caption, $message); if(deftrue('e_BOOTSTRAP'))
{
echo e107::getMessage()->addInfo($message)->render();
}
else
{
$ns->tablerender($caption, $message);
}
} }