From 6d119a0e4505188e33114fb8b738bc405c9eeccd Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 10 May 2003 01:00:29 +0000 Subject: [PATCH] Very rough code in places ... particularly sig parsing ... mainly as a "does it work?" test ... the answer seems to be "yes, it does" ... I don't recall the met office saying "Hell has frozen over", strange ... git-svn-id: file:///svn/phpbb/trunk@3999 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/ucp/ucp_prefs.php | 6 -- phpBB/ucp/ucp_profile.php | 168 +++++++++++++++++++++++++++++++++++--- 2 files changed, 158 insertions(+), 16 deletions(-) diff --git a/phpBB/ucp/ucp_prefs.php b/phpBB/ucp/ucp_prefs.php index 97d38dede8..d390a92f7c 100644 --- a/phpBB/ucp/ucp_prefs.php +++ b/phpBB/ucp/ucp_prefs.php @@ -34,12 +34,6 @@ class ucp_prefs extends ucp $submodules['VIEW'] = "module_id=$module_id&mode=view"; $submodules['POST'] = "module_id=$module_id&mode=post"; - $user->lang = array_merge($user->lang, array( - 'UCP_PERSONAL' => 'Personal Settings', - 'UCP_VIEW' => 'Viewing Posts', - 'UCP_POST' => 'Posting Messages') - ); - ucp::subsection($submodules, $submode); unset($submodules); diff --git a/phpBB/ucp/ucp_profile.php b/phpBB/ucp/ucp_profile.php index 600ea6727e..48b6a63d92 100644 --- a/phpBB/ucp/ucp_profile.php +++ b/phpBB/ucp/ucp_profile.php @@ -35,13 +35,6 @@ class ucp_profile extends ucp $submodules['SIGNATURE'] = "module_id=$module_id&mode=signature"; $submodules['AVATAR'] = "module_id=$module_id&mode=avatar"; - $user->lang = array_merge($user->lang, array( - 'UCP_REG_DETAILS' => 'Registration details', - 'UCP_PROFILE' => 'Your Profile', - 'UCP_SIGNATURE' => 'Your signature', - 'UCP_AVATAR' => 'Your avatar') - ); - ucp::subsection($submodules, $submode); unset($submodules); @@ -49,22 +42,177 @@ class ucp_profile extends ucp { case 'reg_details': $template->assign_vars(array( - 'USERNAME' => $user->data['username'], + 'USERNAME' => $user->data['username'], + 'EMAIL' => $user->data['user_email'], - 'S_CHANGE_USERNAME' => $auth->acl_get('u_chgname'), ) + 'S_CHANGE_USERNAME' => $config['allow_namechange'] & $auth->acl_get('u_chgname'), + 'S_CHANGE_EMAIL' => $auth->acl_get('u_chgemail'), + 'S_CHANGE_PASSWORD' => $auth->acl_get('u_chgpass'), ) ); break; case 'profile': + + $s_birthday_day_options = ''; + for ($i = 1; $i < 32; $i++) + { + $selected = ''; + $s_birthday_day_options .= ""; + } + $s_birthday_month_options = ''; + for ($i = 1; $i < 13; $i++) + { + $selected = ''; + $s_birthday_month_options .= ""; + } + $s_birthday_year_options = ''; + for ($i = 1900; $i < 2004; $i++) + { + $selected = ''; + $s_birthday_year_options .= ""; + } + + $template->assign_vars(array( + 'ICQ' => $user->data['user_icq'], + 'YIM' => $user->data['user_yim'], + 'AIM' => $user->data['user_aim'], + 'MSNM' => $user->data['user_msnm'], + 'JABBER' => $user->data['user_jabber'], + 'WEBSITE' => $user->data['user_website'], + 'LOCATION' => $user->data['user_from'], + 'OCCUPATION'=> $user->data['user_occ'], + 'INTERESTS' => $user->data['user_interests'], + + 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, + 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, + 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,) + ); break; case 'signature': + ucp::load('includes/functions_posting'); + + $html_status = ($config['allow_html']) ? true : false; + $bbcode_status = ($config['allow_bbcode']) ? true : false; + $smilies_status = ($config['allow_smilies']) ? true : false; + $img_status = ($config['allow_img']) ? true : false; + $flash_status = ($config['allow_flash']) ? true : false; + + $enable_html = (isset($_POST['disable_html'])) ? !$_POST['disable_html'] : $config['allow_html']; + $enable_bbcode = (isset($_POST['disable_bbcode'])) ? !$_POST['disable_bbcode'] : $config['allow_bbcode']; + $enable_smilies = (isset($_POST['disable_smilies'])) ? !$_POST['disable_smilies'] : $config['allow_smilies']; + $enable_urls = (isset($_POST['disable_magic_url'])) ? !$_POST['disable_magic_url'] : 1; + + decode_text($user->data['user_sig'], $user->data['user_sig_bbcode_uid']); + $signature = (!empty($_POST['signature'])) ? htmlspecialchars($_POST['signature']) : $user->data['user_sig']; + + $error = array(); + if ($_POST['submit']) + { + if (strlen($signature) > $config['max_sig_chars']) + { + $error[] = $user->lang['SIGNATURE_TOO_LONG']; + } + + if (!sizeof($error)) + { + ucp::load('includes/message_parser'); + + $message_parser = new parse_message(); + $message_parser->message = trim(stripslashes($signature)); + $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies); + $signature = $message_parser->message; + + $sql_ary = array( + 'user_sig' => $signature, + 'user_sig_bbcode_uid' => $message_parser->bbcode_uid, + 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . $user->data['user_id']; + $db->sql_query($sql); + + meta_refresh(3, "ucp.$phpEx$SID&module_id=$module_id&mode=$submode"); + trigger_error(''); + } + } + + $signature_preview = ''; + if ($_POST['preview']) + { + // Fudge-o-rama ... + + global $phpbb_root_path; + + ucp::load('includes/message_parser'); + + $signature_preview = $signature; + + $message_parser = new parse_message(); + $message_parser->message = trim(stripslashes($signature_preview)); + $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies); + $signature_preview = $message_parser->message; + + if ($enable_bbcode) + { + ucp::load('includes/bbcode'); + $bbcode = new bbcode($message_parser->bbcode_bitfield); + + // Second parse bbcode here + $signature_preview = $bbcode->bbcode_second_pass($signature_preview, $message_parser->bbcode_uid); + } + + // If we allow users to disable display of emoticons + // we'll need an appropriate check and preg_replace here + $signature_preview = (empty($enable_smilies) || empty($config['allow_smilies'])) ? preg_replace('#(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1)); + } + + $signature_preview = str_replace("\n", '
', $signature_preview); + } + $template->assign_vars(array( - 'SIGNATURE' => $user->data['signature']) + 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', + 'SIGNATURE' => $signature, + 'SIGNATURE_PREVIEW' => $signature_preview, + + 'S_SIGNATURE_PREVIEW' => ($signature_preview) ? true : false, + + 'S_HTML_CHECKED' => (!$enable_html) ? 'checked="checked"' : '', + 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? 'checked="checked"' : '', + 'S_SMILIES_CHECKED' => (!$enable_smilies) ? 'checked="checked"' : '', + 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? 'checked="checked"' : '', + + 'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'], + 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''), + 'SMILIES_STATUS'=> ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], + 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], + 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], + + 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), + + 'S_HTML_ALLOWED' => $config['allow_html'], + 'S_BBCODE_ALLOWED' => $config['allow_bbcode'], + 'S_SMILIES_ALLOWED' => $config['allow_smilies'],) ); break; case 'avatar': + + $template->assign_vars(array( + 'AVATAR' => '', + 'S_UPLOAD_AVATAR_FILE' => true, + 'S_UPLOAD_AVATAR_URL' => true, + 'S_LINK_AVATAR' => true, + 'S_GALLERY_AVATAR' => true,) + ); + break; default: