From 549537b9d570ac70c16f4560b9efbafa293834db Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 10 May 2003 17:19:27 +0000 Subject: [PATCH] Returned to instantiation of ucp object ... perhaps this approach is better? Altered basic info for ucp_modules, updated editor to allow alternative form and textarea names ... still lots of fudginess, hhhmmmm fudge, uuuuugggghhh git-svn-id: file:///svn/phpbb/trunk@4003 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- phpBB/includes/functions_user.php | 4 +- phpBB/install/schemas/mysql_basic.sql | 8 +- phpBB/language/en/lang_main.php | 28 +- phpBB/templates/subSilver/editor.js | 68 ++--- phpBB/templates/subSilver/posting_body.html | 3 + phpBB/templates/subSilver/ucp_header.html | 33 +- phpBB/templates/subSilver/ucp_prefs.html | 80 ++--- phpBB/templates/subSilver/ucp_profile.html | 49 +-- phpBB/ucp.php | 317 ++++++-------------- phpBB/ucp/ucp_activate.php | 95 ++++++ phpBB/ucp/ucp_main.php | 198 ++++++++++++ phpBB/ucp/ucp_pm.php | 33 ++ phpBB/ucp/ucp_prefs.php | 30 +- phpBB/ucp/ucp_profile.php | 53 ++-- phpBB/ucp/ucp_register.php | 10 +- 16 files changed, 612 insertions(+), 399 deletions(-) create mode 100644 phpBB/ucp/ucp_activate.php create mode 100644 phpBB/ucp/ucp_main.php create mode 100644 phpBB/ucp/ucp_pm.php diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 74654dd197..c530328658 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -384,7 +384,7 @@ function tz_select($default = '') { if (is_numeric($offset)) { - $selected = ($offset === $default) ? ' selected="selected"' : ''; + $selected = ($offset == $default) ? ' selected="selected"' : ''; $tz_select .= ''; } } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index aaeb16d76d..b12e131d3f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -209,12 +209,12 @@ class userdata extends user if ($config['require_activation'] == USER_ACTIVATION_NONE) { - set_config('newest_user_id', $userdata['user_id']); + set_config('newest_user_id', $user_id); set_config('newest_username', $userdata['username']); set_config('num_users', $config['num_users'] + 1, TRUE); } unset($userdata); - + return $message; } diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index d863d1871a..6a6721613a 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -337,8 +337,12 @@ INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, disp INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/exclaim.gif', 19, 19, 7, 1); # -- ucp modules -INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (1, 'Profile Settings', 'ucp/usercp_profile', 1); -INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (2, 'Black/While Lists', 'ucp/usercp_lists', 2); +INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (1, 'MAIN', 'main', 1); +INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (2, 'PROFILE', 'profile', 2); +INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (3, 'PREFERENCES', 'prefs', 3); +INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (4, 'MESSAGING', 'pm', 4); +INSERT INTO phpbb_ucp_modules (module_id, module_name, module_filename, module_order) VALUES (5, 'LISTS', 'zebra', 5); + # -- wordlist INSERT INTO phpbb_search_wordlist (word_id, word_text, word_common) VALUES ( 1, 'example', 0 ); diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index f618bc9f64..f73c482d17 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -95,11 +95,13 @@ $lang = array( 'VIEW_LATEST_POST' => 'View latest post', 'VIEW_NEWEST_POST' => 'View newest post', 'PAGE_OF' => 'Page %1$d of %2$d', - 'ICQ' => 'ICQ Number', - 'AIM' => 'AIM Address', - 'MSNM' => 'MSN Messenger', - 'YIM' => 'Yahoo Messenger', + + 'ICQ' => 'ICQ', + 'AIM' => 'AIM', + 'MSNM' => 'MSNM', + 'YIM' => 'YIM', 'RANK' => 'Rank', + 'FORUM_INDEX' => 'Board Index', 'ALL_TIMES' => 'All times are %s %s', @@ -624,10 +626,9 @@ $lang = array( 'DOWNLOAD_COUNT' => '%d Time', // replace %d with count 'DOWNLOAD_COUNTS' => '%d Times', // replace %d with count + 'UCP' => 'User Control Panel', - 'UCP_Main' => 'Control Panel', - 'UCP_Profile' => 'Profile Settings', - 'UCP_Lists' => 'Black/White Lists', + 'UCP_Priv_messages' => 'Private Messages', 'SUBSCRIBED_TOPICS' => 'Subscribed Topics', 'SUBSCRIBED_FORUMS' => 'Subscribed Forums', @@ -642,12 +643,16 @@ $lang = array( 'Avatar_settings' => 'Avatar Settings', 'Signature_settings' => 'Signature Settings', + 'UCP_MAIN' => 'Overview', 'UCP_PREFERENCES' => 'Preferences', 'UCP_PERSONAL' => 'Personal Settings', 'UCP_VIEW' => 'Viewing Posts', 'UCP_POST' => 'Posting Messages', + + 'UCP_MESSAGING' => 'Private Messaging', + 'UCP_LISTS' => 'Buddy/Ignore Lists', @@ -656,16 +661,19 @@ $lang = array( 'UCP_REG_DETAILS' => 'Registration details', 'UCP_AVATAR' => 'Your avatar', - 'PROFILE_INFO_NOTICE' => 'Please note that this information will be viewable to other members. Be careful when including any personal details.', + 'PROFILE_INFO_NOTICE' => 'Please note that this information will be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', 'WEBSITE' => 'Website', 'LOCATION' => 'Location', 'CONTACT' => 'Contact', - 'JABBER' => 'Jabber', 'EMAIL_ADDRESS' => 'Email address', 'INTERESTS' => 'Interests', 'OCCUPATION' => 'Occupation', 'BIRTHDAY' => 'Birthday', - + 'UCP_ICQ' => 'ICQ Number', + 'UCP_AIM' => 'AOL Instant Messenger', + 'UCP_MSNM' => 'MSN Messenger', + 'UCP_YIM' => 'Yahoo Messenger', + 'JABBER' => 'Jabber Address', 'UCP_SIGNATURE' => 'Your signature', 'SIGNATURE_NOTICE' => 'Please note that some forums limit the size and content of your signature. Be sure to read any forum or board rules to ensure you comply with them.', diff --git a/phpBB/templates/subSilver/editor.js b/phpBB/templates/subSilver/editor.js index ba75e40987..0ef736c94a 100644 --- a/phpBB/templates/subSilver/editor.js +++ b/phpBB/templates/subSilver/editor.js @@ -20,7 +20,7 @@ var is_mac = (clientPC.indexOf("mac")!=-1); // Shows the help messages in the helpline window function helpline(help) { - document.post.helpbox.value = eval(help + "_help"); + document.forms[form_name].helpbox.value = eval(help + "_help"); } // Replacement for arrayname.length property @@ -49,13 +49,13 @@ function arraypop(thearray) { function emoticon(text) { text = ' ' + text + ' '; - if (document.post.message.createTextRange && document.post.message.caretPos) { - var caretPos = document.post.message.caretPos; + if (document.forms[form_name].elements[text_name].createTextRange && document.forms[form_name].elements[text_name].caretPos) { + var caretPos = document.forms[form_name].elements[text_name].caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; - document.post.message.focus(); + document.forms[form_name].elements[text_name].focus(); } else { - document.post.message.value += text; - document.post.message.focus(); + document.forms[form_name].elements[text_name].value += text; + document.forms[form_name].elements[text_name].focus(); } } @@ -63,19 +63,19 @@ function bbfontstyle(bbopen, bbclose) { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (!theSelection) { - document.post.message.value += bbopen + bbclose; - document.post.message.focus(); + document.forms[form_name].elements[text_name].value += bbopen + bbclose; + document.forms[form_name].elements[text_name].focus(); return; } document.selection.createRange().text = bbopen + theSelection + bbclose; - document.post.message.focus(); + document.forms[form_name].elements[text_name].focus(); return; } else { - document.post.message.value += bbopen + bbclose; - document.post.message.focus(); + document.forms[form_name].elements[text_name].value += bbopen + bbclose; + document.forms[form_name].elements[text_name].focus(); return; } - storeCaret(document.post.message); + storeCaret(document.forms[form_name].message); } @@ -88,19 +88,19 @@ function bbstyle(bbnumber) { if (bbnumber == -1) { // Close all open tags & default button names while (bbcode[0]) { butnumber = arraypop(bbcode) - 1; - document.post.message.value += bbtags[butnumber + 1]; - buttext = eval('document.post.addbbcode' + butnumber + '.value'); + document.forms[form_name].elements[text_name].value += bbtags[butnumber + 1]; + buttext = eval('document.forms[form_name].addbbcode' + butnumber + '.value'); if (buttext != "[*]") { - eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); + eval('document.forms[form_name].addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); } } - document.post.addbbcode10.value = "List"; + document.forms[form_name].addbbcode10.value = "List"; bbtags[10] = "[list]"; - document.post.addbbcode12.value = "List="; + document.forms[form_name].addbbcode12.value = "List="; bbtags[12] = "[list=]"; imageTag = false; // All tags are closed including image tags :D - document.post.message.focus(); + document.forms[form_name].elements[text_name].focus(); return; } @@ -110,7 +110,7 @@ function bbstyle(bbnumber) { if (theSelection) { // Add tags around selection document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1]; - document.post.message.focus(); + document.forms[form_name].elements[text_name].focus(); theSelection = ''; return; } @@ -127,7 +127,7 @@ function bbstyle(bbnumber) { { if (donotinsert) { - document.post.addbbcode12.value = "List="; + document.forms[form_name].addbbcode12.value = "List="; tmp_help = o_help; o_help = e_help; e_help = tmp_help; @@ -135,7 +135,7 @@ function bbstyle(bbnumber) { } else { - document.post.addbbcode12.value = "[*]"; + document.forms[form_name].addbbcode12.value = "[*]"; tmp_help = o_help; o_help = e_help; e_help = tmp_help; @@ -147,7 +147,7 @@ function bbstyle(bbnumber) { { if (donotinsert) { - document.post.addbbcode10.value = "List"; + document.forms[form_name].addbbcode10.value = "List"; tmp_help = l_help; l_help = e_help; e_help = tmp_help; @@ -155,7 +155,7 @@ function bbstyle(bbnumber) { } else { - document.post.addbbcode10.value = "[*]"; + document.forms[form_name].addbbcode10.value = "[*]"; tmp_help = l_help; l_help = e_help; e_help = tmp_help; @@ -168,43 +168,43 @@ function bbstyle(bbnumber) { butnumber = arraypop(bbcode) - 1; if (bbtags[butnumber] != "[*]") { - document.post.message.value += bbtags[butnumber + 1]; + document.forms[form_name].elements[text_name].value += bbtags[butnumber + 1]; } else { - document.post.message.value += bbtags[butnumber]; + document.forms[form_name].elements[text_name].value += bbtags[butnumber]; } - buttext = eval('document.post.addbbcode' + butnumber + '.value'); + buttext = eval('document.forms[form_name].addbbcode' + butnumber + '.value'); if (bbtags[butnumber] != "[*]") { - eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); + eval('document.forms[form_name].addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); } imageTag = false; } - document.post.message.focus(); + document.forms[form_name].elements[text_name].focus(); return; } else { // Open tags if (imageTag && (bbnumber != 14)) { // Close image tag before adding another - document.post.message.value += bbtags[15]; + document.forms[form_name].elements[text_name].value += bbtags[15]; lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list - document.post.addbbcode14.value = "Img"; // Return button back to normal state + document.forms[form_name].addbbcode14.value = "Img"; // Return button back to normal state imageTag = false; } // Open tag - document.post.message.value += bbtags[bbnumber]; + document.forms[form_name].elements[text_name].value += bbtags[bbnumber]; if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag if (bbtags[bbnumber] != "[*]") { arraypush(bbcode,bbnumber+1); - eval('document.post.addbbcode'+bbnumber+'.value += "*"'); + eval('document.forms[form_name].addbbcode'+bbnumber+'.value += "*"'); } - document.post.message.focus(); + document.forms[form_name].elements[text_name].focus(); return; } - storeCaret(document.post.message); + storeCaret(document.forms[form_name].message); } // Insert at Claret position. Code from diff --git a/phpBB/templates/subSilver/posting_body.html b/phpBB/templates/subSilver/posting_body.html index 61297d74c3..6b0dd6d8a3 100644 --- a/phpBB/templates/subSilver/posting_body.html +++ b/phpBB/templates/subSilver/posting_body.html @@ -3,6 +3,9 @@ + + +
diff --git a/phpBB/templates/subSilver/ucp_prefs.html b/phpBB/templates/subSilver/ucp_prefs.html index 71344e320d..a3b77b11e2 100644 --- a/phpBB/templates/subSilver/ucp_prefs.html +++ b/phpBB/templates/subSilver/ucp_prefs.html @@ -3,7 +3,7 @@ -
+ -
@@ -12,13 +12,19 @@ + + + + + +
Options
{ucp_subsection.L_TITLE} - {ucp_subsection.L_TITLE} + {ucp_subsection.L_TITLE}
 
 
+ - + diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 75d86228b7..d38c551a74 100755 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -8,7 +8,6 @@ * * $Id$ * - * ***************************************************************************/ /*************************************************************************** @@ -70,58 +69,60 @@ $user->setup(); $auth->acl($user->data); -// ----------------------- -// Page specific functions // -if (!empty($_REQUEST['mode'])) +$mode = (!empty($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; +$module = (!empty($_REQUEST['i'])) ? $_REQUEST['i'] : 1; + + +// +$ucp = new ucp(); + + +// +switch ($mode) { - $mode = $_REQUEST['mode']; + case 'activate': + $ucp->module('activate'); + $ucp->modules['activate']->main(); + break; - switch ($mode) - { - case 'activate': - include($phpbb_root_path . 'ucp/ucp_activate.'.$phpEx); - ucp_activate::main(); - break; - - case 'register': - if ($user->data['user_id'] != ANONYMOUS) - { - redirect("index.$phpEx$SID"); - } - - include($phpbb_root_path . 'ucp/ucp_register.'.$phpEx); - ucp_register::main(); - break; - - case 'login': - if ($user->data['user_id'] != ANONYMOUS) - { - redirect("index.$phpEx$SID"); - } - - define('IN_LOGIN', true); - login_box("ucp.$phpEx$SID&mode=login"); + case 'register': + if ($user->data['user_id'] != ANONYMOUS) + { redirect("index.$phpEx$SID"); - break; + } - case 'logout': - if ($user->data['user_id'] != ANONYMOUS) - { - $user->destroy(); - } + $ucp->module('register'); + $ucp->modules['register']->main(); + break; + case 'login': + if ($user->data['user_id'] != ANONYMOUS) + { redirect("index.$phpEx$SID"); - break; + } - } + define('IN_LOGIN', true); + login_box("ucp.$phpEx$SID&mode=login"); + redirect("index.$phpEx$SID"); + break; + + case 'logout': + if ($user->data['user_id'] != ANONYMOUS) + { + $user->destroy(); + } + + redirect("index.$phpEx$SID"); + break; } -// Some basic template vars -$template->assign_vars(array( - 'UCP_WELCOME_MSG' => $user->lang['UCP_WELCOME_MESSAGE']) -); +// Only registered users can go beyond this point +if ($user->data['user_id'] == ANONYMOUS) +{ + redirect("index.$phpEx"); +} // Word censors $censors['match'] & $censors['replace'] @@ -129,234 +130,66 @@ $censors = array(); obtain_word_list($censors); -$selected_module = (!empty($_REQUEST['module_id'])) ? $_REQUEST['module_id'] : ''; - -// "Home" module -$template->assign_block_vars('ucp_sections', array( - 'U_SECTION' => "ucp.$phpEx$SID", - 'SECTION' => $user->lang['UCP_Main'], - 'S_IS_TAB' => (!$selected_module) ? true : false) -); - - - // Grab the other enabled UCP modules $sql = "SELECT module_id, module_name, module_filename FROM " . UCP_MODULES_TABLE . " ORDER BY module_order ASC"; $result = $db->sql_query($sql); -$selected_module_name = ''; while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('ucp_sections', array( 'SECTION' => $user->lang['UCP_' . $row['module_name']], - 'U_SECTION' => "ucp.$phpEx$SID&module_id=" . $row['module_id'], + 'U_SECTION' => "ucp.$phpEx$SID&i=" . $row['module_id'], - 'S_IS_TAB' => ($row['module_id'] == $selected_module) ? true : false) + 'S_IS_TAB' => ($row['module_id'] == $module) ? true : false) ); - if ($row['module_id'] == $selected_module) + if ($row['module_id'] == $module) { - $selected_module_name = $row['module_filename']; - $selected_module_id = $row['module_id']; + $selected_module = $row['module_filename']; + $selected_id = $row['module_id']; } } $db->sql_freeresult($result); -if ($selected_module_name) +if ($selected_module) { - include($phpbb_root_path . 'ucp/' . $selected_module_name . '.' . $phpEx); - eval($selected_module_name . '::main(' . $selected_module_id . ');'); + $ucp->module($selected_module); + $ucp->modules[$selected_module]->main($selected_id); } -// Subscribed Topics -$sql = "SELECT tw.topic_id, t.topic_title, t.topic_last_post_time, t.poll_start, t.topic_replies, t.topic_type, t.forum_id - FROM " . TOPICS_TABLE . " t, " . TOPICS_WATCH_TABLE . " tw - WHERE t.topic_id = tw.topic_id - AND tw.user_id = " . $user->data['user_id'] . " - ORDER BY t.topic_last_post_time DESC"; -$result = $db->sql_query($sql); - -$topic_count = 0; -while ($row = $db->sql_fetchrow($result)) -{ - $replies = $row['topic_replies']; - $topic_id = $row['topic_id']; - $forum_id = $row['forum_id']; - - switch ($row['topic_type']) - { - case POST_ANNOUNCE: - $topic_type = $user->lang['Topic_Announcement'] . ' '; - $folder = 'folder_announce'; - $folder_new = 'folder_announce_new'; - break; - - case POST_STICKY: - $topic_type = $user->lang['Topic_Sticky'] . ' '; - $folder = 'folder_sticky'; - $folder_new = 'folder_sticky_new'; - break; - - case ITEM_LOCKED: - $folder = 'folder_locked'; - $folder_new = 'folder_locked_new'; - break; - - default: - if ($replies >= intval($config['hot_threshold'])) - { - $folder = 'folder_hot'; - $folder_new = 'folder_hot_new'; - } - else - { - $folder = 'folder'; - $folder_new = 'folder_new'; - } - break; - } - - $unread_topic = false; - if ($user->data['user_id'] && $row['topic_last_post_time'] > $user->data['session_last_visit']) - { - $unread_topic = true; - } - - - - $newest_post_img = ($unread_topic) ? '' . $user->img('goto_post_newest', 'View_newest_post') . ' ' : ''; - $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'New_posts' : (($row['topic_status'] == ITEM_LOCKED) ? 'Topic_locked' : 'No_new_posts'); - - $view_topic_url = 'viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id; - - $template->assign_block_vars('subscribed_topics', array( - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'NEWEST_POST_IMG' => $newest_post_img, - - 'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], - - 'U_TOPIC' => $view_topic_url) - ); -} -$db->sql_freeresult($result); -// End Subscribed Topics - - -// Subscribed Forums -$sql = "SELECT f.forum_id, f.forum_last_post_time, f.forum_last_post_id, f.left_id, f.right_id, f.forum_status, f.forum_name, f.forum_desc - FROM " . FORUMS_TABLE . " f, " . FORUMS_WATCH_TABLE . " fw - WHERE f.forum_id = fw.forum_id - AND fw.user_id = " . $user->data['user_id'] . " - ORDER BY f.forum_last_post_time DESC"; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $forum_id = $row['forum_id']; - - $unread_topics = ($user->data['user_id'] && $row['forum_last_post_time'] > $user->data['user_lastvisit']) ? TRUE : FALSE; - - $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; - $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; - - if ($row['left_id'] + 1 < $row['right_id']) - { - $folder_image = ($unread_topics) ? 'sub_forum_new' : 'sub_forum'; - $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; - } - elseif ($row['forum_status'] == ITEM_LOCKED) - { - $folder_image = 'forum_locked'; - $folder_alt = 'Forum_locked'; - } - else - { - $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; - $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; - } - - $last_post = '' . $user->img('goto_post_latest', 'View_latest_post') . ''; - - - $template->assign_block_vars('subscribed_forums', array( - 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), - 'NEWEST_FORUM_POST_IMG' => $last_post, - - 'FORUM_NAME' => $row['forum_name'], - - 'U_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id']) - ); -} -$db->sql_freeresult($result); -// End Subscribed forums - - -// Buddy List - -// End Buddy List - - -// Private Messages - -// End Private Messages - - -// Output the page -page_header($user->lang['UCP'] . ' - ' . $this_section); - -$template->set_filenames(array( - 'body' => 'ucp_main.html') -); -make_jumpbox('viewforum.'.$phpEx); - -page_footer(); - - // A wrapper class for ucp modules? class ucp { - function main($module_id) + var $modules = array(); + + function module($module_name) { - return false; - } - - function extra_fields($page) - { - return false; - } - - function gen_rand_string($num_chars) - { - $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'); - - list($usec, $sec) = explode(' ', microtime()); - mt_srand($sec * $usec); - - $max_chars = count($chars) - 1; - $rand_str = ''; - for ($i = 0; $i < $num_chars; $i++) + if (!class_exists('ucp_' . $module_name)) { - $rand_str .= $chars[mt_rand(0, $max_chars)]; + $this->loadfile('ucp/ucp_' . $module_name); + eval('$this->modules[' . $module_name . '] = new ucp_' . $module_name . '();'); } - - return $rand_str; } - function load($filename) + function loadfile($filename) { global $phpbb_root_path, $phpEx; - require($phpbb_root_path . $filename . '.' . $phpEx); + return require($phpbb_root_path . $filename . '.' . $phpEx); + } + + function main($module_id = false) + { + return false; } function subsection(&$module_ary, &$selected_module) @@ -388,6 +221,28 @@ class ucp page_footer(); } + + function extra_fields($page) + { + return false; + } + + function gen_rand_string($num_chars) + { + $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + + list($usec, $sec) = explode(' ', microtime()); + mt_srand($sec * $usec); + + $max_chars = count($chars) - 1; + $rand_str = ''; + for ($i = 0; $i < $num_chars; $i++) + { + $rand_str .= $chars[mt_rand(0, $max_chars)]; + } + + return $rand_str; + } } ?> \ No newline at end of file diff --git a/phpBB/ucp/ucp_activate.php b/phpBB/ucp/ucp_activate.php new file mode 100644 index 0000000000..303a0e225c --- /dev/null +++ b/phpBB/ucp/ucp_activate.php @@ -0,0 +1,95 @@ +sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + if ($row['user_active'] && $row['user_actkey'] == '') + { + meta_refresh(3, "index.$phpEx$SID"); + trigger_error($user->lang['Already_activated']); + } + else if ($row['user_actkey'] == $_GET['key']) + { + $sql_update_pass = ($row['user_newpasswd'] != '') ? ", user_password = '" . $db->sql_escape($row['user_newpasswd']) . "', user_newpasswd = ''" : ''; + + $sql = "UPDATE " . USERS_TABLE . " + SET user_active = 1, user_actkey = ''" . $sql_update_pass . " + WHERE user_id = " . $row['user_id']; + $result = $db->sql_query($sql); + + if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $sql_update_pass == '') + { + ucp::load('includes/emailer'); + $emailer = new emailer($config['smtp_delivery']); + + $emailer->use_template('admin_welcome_activated', $row['user_lang']); + $emailer->to($row['user_email']); + + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'USERNAME' => $row['username'], + 'PASSWORD' => $password_confirm, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig'])) + ); + $emailer->send(); + $emailer->reset(); + + meta_refresh(3, "index.$phpEx$SID"); + trigger_error($user->lang['Account_active_admin']); + } + else + { + meta_refresh(3, "index.$phpEx$SID"); + $message = ($sql_update_pass == '') ? $user->lang['Account_active'] : $user->lang['Password_activated']; + trigger_error($message); + } + + set_config('newest_user_id', $row['user_id']); + set_config('newest_username', $row['username']); + set_config('num_users', $config['num_users'] + 1, TRUE); + } + else + { + trigger_error($user->lang['Wrong_activation']); + } + } + else + { + trigger_error($user->lang['No_such_user']); + } + $db->sql_freeresult($result); + } +} + +?> \ No newline at end of file diff --git a/phpBB/ucp/ucp_main.php b/phpBB/ucp/ucp_main.php new file mode 100644 index 0000000000..1dd4b2795a --- /dev/null +++ b/phpBB/ucp/ucp_main.php @@ -0,0 +1,198 @@ +subsection($submodules, $submode); + unset($submodules); + + switch($submode) + { + case 'view': + break; + + case 'post': + break; + + default: + break; + } + + + // Subscribed Topics + $sql = "SELECT tw.topic_id, t.topic_title, t.topic_last_post_time, t.poll_start, t.topic_replies, t.topic_type, t.forum_id + FROM " . TOPICS_TABLE . " t, " . TOPICS_WATCH_TABLE . " tw + WHERE t.topic_id = tw.topic_id + AND tw.user_id = " . $user->data['user_id'] . " + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query($sql); + + $topic_count = 0; + while ($row = $db->sql_fetchrow($result)) + { + $replies = $row['topic_replies']; + $topic_id = $row['topic_id']; + $forum_id = $row['forum_id']; + + switch ($row['topic_type']) + { + case POST_ANNOUNCE: + $topic_type = $user->lang['Topic_Announcement'] . ' '; + $folder = 'folder_announce'; + $folder_new = 'folder_announce_new'; + break; + + case POST_STICKY: + $topic_type = $user->lang['Topic_Sticky'] . ' '; + $folder = 'folder_sticky'; + $folder_new = 'folder_sticky_new'; + break; + + case ITEM_LOCKED: + $folder = 'folder_locked'; + $folder_new = 'folder_locked_new'; + break; + + default: + if ($replies >= intval($config['hot_threshold'])) + { + $folder = 'folder_hot'; + $folder_new = 'folder_hot_new'; + } + else + { + $folder = 'folder'; + $folder_new = 'folder_new'; + } + break; + } + + $unread_topic = false; + if ($user->data['user_id'] && $row['topic_last_post_time'] > $user->data['session_last_visit']) + { + $unread_topic = true; + } + + $newest_post_img = ($unread_topic) ? '' . $user->img('goto_post_newest', 'View_newest_post') . ' ' : ''; + $folder_img = ($unread_topic) ? $folder_new : $folder; + $folder_alt = ($unread_topic) ? 'New_posts' : (($row['topic_status'] == ITEM_LOCKED) ? 'Topic_locked' : 'No_new_posts'); + + $view_topic_url = 'viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id; + + $template->assign_block_vars('subscribed_topics', array( + 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), + 'NEWEST_POST_IMG' => $newest_post_img, + + 'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], + + 'U_TOPIC' => $view_topic_url) + ); + } + $db->sql_freeresult($result); + // End Subscribed Topics + + + // Subscribed Forums + $sql = "SELECT f.forum_id, f.forum_last_post_time, f.forum_last_post_id, f.left_id, f.right_id, f.forum_status, f.forum_name, f.forum_desc + FROM " . FORUMS_TABLE . " f, " . FORUMS_WATCH_TABLE . " fw + WHERE f.forum_id = fw.forum_id + AND fw.user_id = " . $user->data['user_id'] . " + ORDER BY f.forum_last_post_time DESC"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $forum_id = $row['forum_id']; + + $unread_topics = ($user->data['user_id'] && $row['forum_last_post_time'] > $user->data['user_lastvisit']) ? TRUE : FALSE; + + $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; + + if ($row['left_id'] + 1 < $row['right_id']) + { + $folder_image = ($unread_topics) ? 'sub_forum_new' : 'sub_forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; + } + elseif ($row['forum_status'] == ITEM_LOCKED) + { + $folder_image = 'forum_locked'; + $folder_alt = 'Forum_locked'; + } + else + { + $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; + } + + $last_post = '' . $user->img('goto_post_latest', 'View_latest_post') . ''; + + + $template->assign_block_vars('subscribed_forums', array( + 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), + 'NEWEST_FORUM_POST_IMG' => $last_post, + + 'FORUM_NAME' => $row['forum_name'], + + 'U_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id']) + ); + } + $db->sql_freeresult($result); + // End Subscribed forums + + + // Buddy List + + // End Buddy List + + + // Private Messages + + // End Private Messages + + + + + $template->assign_vars(array( + 'L_TITLE' => $user->lang['UCP_' . strtoupper($submode)], + + 'S_DISPLAY_' . strtoupper($submode) => true, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_UCP_ACTION' => "ucp.$phpEx$SID&i=$id&mode=$submode") + ); + + $this->output($user->lang['UCP_MAIN'], 'ucp_main.html'); + } +} + +?> \ No newline at end of file diff --git a/phpBB/ucp/ucp_pm.php b/phpBB/ucp/ucp_pm.php new file mode 100644 index 0000000000..142cff9f58 --- /dev/null +++ b/phpBB/ucp/ucp_pm.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/phpBB/ucp/ucp_prefs.php b/phpBB/ucp/ucp_prefs.php index d390a92f7c..7ad954e6d6 100644 --- a/phpBB/ucp/ucp_prefs.php +++ b/phpBB/ucp/ucp_prefs.php @@ -1,6 +1,6 @@ subsection($submodules, $submode); unset($submodules); switch($submode) { + case 'personal': + $template->assign_vars(array( + 'VIEW_EMAIL_YES' => ($user->data['user_viewemail ']) ? ' checked="checked"' : '', + 'VIEW_EMAIL_NO' => (!$user->data['user_viewemail ']) ? ' checked="checked"' : '', + 'DATE_FORMAT' => $user->data['user_dateformat'], + + 'S_LANG_OPTIONS' => language_select($user->data['user_lang']), + 'S_STYLE_OPTIONS' => style_select($user->data['user_style']), + 'S_TZ_OPTIONS' => tz_select($user->data['user_timezone']),) + ); + break; + case 'view': break; @@ -54,10 +64,10 @@ class ucp_prefs extends ucp 'S_DISPLAY_' . strtoupper($submode) => true, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_UCP_ACTION' => "ucp.$phpEx$SID&module_id=$module_id&mode=$submode") + 'S_UCP_ACTION' => "ucp.$phpEx$SID&i=$id&mode=$submode") ); - ucp::output($user->lang['UCP_PROFILE'], 'ucp_prefs.html'); + $this->output($user->lang['UCP_PROFILE'], 'ucp_prefs.html'); } } diff --git a/phpBB/ucp/ucp_profile.php b/phpBB/ucp/ucp_profile.php index 48b6a63d92..a37fc6a8a3 100644 --- a/phpBB/ucp/ucp_profile.php +++ b/phpBB/ucp/ucp_profile.php @@ -1,6 +1,6 @@ subsection($submodules, $submode); unset($submodules); switch ($submode) { case 'reg_details': + $template->assign_vars(array( 'USERNAME' => $user->data['username'], 'EMAIL' => $user->data['user_email'], @@ -53,24 +52,30 @@ class ucp_profile extends ucp case 'profile': + list($day, $month, $year) = explode('-', $user->data['user_birthday']); + $s_birthday_day_options = ''; for ($i = 1; $i < 32; $i++) { - $selected = ''; - $s_birthday_day_options .= ""; + $selected = ($i == $day) ? ' selected="selected"' : ''; + $s_birthday_day_options .= ""; } + $s_birthday_month_options = ''; for ($i = 1; $i < 13; $i++) { - $selected = ''; - $s_birthday_month_options .= ""; + $selected = ($i == $month) ? ' selected="selected"' : ''; + $s_birthday_month_options .= ""; } $s_birthday_year_options = ''; - for ($i = 1900; $i < 2004; $i++) + + $now = getdate(); + for ($i = $now['year'] - 100; $i < $now['year']; $i++) { - $selected = ''; - $s_birthday_year_options .= ""; + $selected = ($i == $year) ? ' selected="selected"' : ''; + $s_birthday_year_options .= ""; } + unset($now); $template->assign_vars(array( 'ICQ' => $user->data['user_icq'], @@ -90,7 +95,8 @@ class ucp_profile extends ucp break; case 'signature': - ucp::load('includes/functions_posting'); + + $this->loadfile('includes/functions_posting'); $html_status = ($config['allow_html']) ? true : false; $bbcode_status = ($config['allow_bbcode']) ? true : false; @@ -116,7 +122,7 @@ class ucp_profile extends ucp if (!sizeof($error)) { - ucp::load('includes/message_parser'); + $this->loadfile('includes/message_parser'); $message_parser = new parse_message(); $message_parser->message = trim(stripslashes($signature)); @@ -134,7 +140,7 @@ class ucp_profile extends ucp WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); - meta_refresh(3, "ucp.$phpEx$SID&module_id=$module_id&mode=$submode"); + meta_refresh(3, "ucp.$phpEx$SID&i=$id&mode=$submode"); trigger_error(''); } } @@ -146,7 +152,7 @@ class ucp_profile extends ucp global $phpbb_root_path; - ucp::load('includes/message_parser'); + $this->loadfile('includes/message_parser'); $signature_preview = $signature; @@ -157,7 +163,7 @@ class ucp_profile extends ucp if ($enable_bbcode) { - ucp::load('includes/bbcode'); + $this->loadfile('includes/bbcode'); $bbcode = new bbcode($message_parser->bbcode_bitfield); // Second parse bbcode here @@ -207,6 +213,7 @@ class ucp_profile extends ucp $template->assign_vars(array( 'AVATAR' => '', + 'S_UPLOAD_AVATAR_FILE' => true, 'S_UPLOAD_AVATAR_URL' => true, 'S_LINK_AVATAR' => true, @@ -224,10 +231,10 @@ class ucp_profile extends ucp 'S_DISPLAY_' . strtoupper($submode) => true, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_UCP_ACTION' => "ucp.$phpEx$SID&module_id=$module_id&mode=$submode") + 'S_UCP_ACTION' => "ucp.$phpEx$SID&i=$id&mode=$submode") ); - ucp::output($user->lang['UCP_PROFILE'], 'ucp_profile.html'); + $this->output($user->lang['UCP_PROFILE'], 'ucp_profile.html'); } } diff --git a/phpBB/ucp/ucp_register.php b/phpBB/ucp/ucp_register.php index ad7295492a..e5bad26eae 100644 --- a/phpBB/ucp/ucp_register.php +++ b/phpBB/ucp/ucp_register.php @@ -21,7 +21,7 @@ class ucp_register extends ucp { - function main() + function main($id) { global $config, $db, $user, $SID, $template, $phpEx; @@ -64,7 +64,7 @@ class ucp_register extends ucp ); } - ucp::output($user->lang['REGISTER'], 'ucp_agreement.html'); + $this->output($user->lang['REGISTER'], 'ucp_agreement.html'); } // Check and initialize some variables if needed @@ -72,7 +72,7 @@ class ucp_register extends ucp if (isset($_POST['submit'])) { // Load the userdata manipulation methods - ucp::load('includes/functions_user'); + $this->loadfile('includes/functions_user'); $userdata = new userdata(); if ($message = $userdata->add_user($coppa)) @@ -130,7 +130,7 @@ class ucp_register extends ucp } $db->sql_freeresult($result); - $code = ucp::gen_rand_string(6); + $code = $this->gen_rand_string(6); $confirm_id = md5(uniqid($user_ip)); $sql = "INSERT INTO " . CONFIRM_TABLE . " (confirm_id, session_id, code) @@ -176,7 +176,7 @@ class ucp_register extends ucp ); // - ucp::output($user->lang['REGISTER'], 'ucp_register.html'); + $this->output($user->lang['REGISTER'], 'ucp_register.html'); } }
@@ -31,60 +37,60 @@ - + - + - - + - + - - + + - - + + - - + + - - + - + - + - + diff --git a/phpBB/templates/subSilver/ucp_profile.html b/phpBB/templates/subSilver/ucp_profile.html index 6eb2c34293..ade2418f38 100644 --- a/phpBB/templates/subSilver/ucp_profile.html +++ b/phpBB/templates/subSilver/ucp_profile.html @@ -1,41 +1,4 @@ - - - @@ -99,22 +62,22 @@ function checkForm() - + - + - + - + - + @@ -175,7 +138,7 @@ function checkForm()
{L_TITLE}
{L_PUBLIC_VIEW_EMAIL}:{L_PUBLIC_VIEW_EMAIL}: - + {L_YES}   - + {L_NO}
{L_HIDE_USER}:{L_HIDE_USER}: - + {L_YES}   - + {L_NO}
{L_NOTIFY_ON_REPLY}:
+
{L_NOTIFY_ON_REPLY}:
{L_NOTIFY_ON_REPLY_EXPLAIN}
- + {L_YES}   - + {L_NO}
{L_NOTIFY_ON_PRIVMSG}:{L_NOTIFY_ON_PRIVMSG}: - + {L_YES}   - + {L_NO}
{L_POPUP_ON_PRIVMSG}:
{L_POPUP_ON_PRIVMSG_EXPLAIN}
{L_POPUP_ON_PRIVMSG}:
{L_POPUP_ON_PRIVMSG_EXPLAIN}
- + {L_YES}   - + {L_NO}
{L_BOARD_LANGUAGE}:{L_BOARD_LANGUAGE}:
{L_BOARD_STYLE}:{L_BOARD_STYLE}:
{L_TIMEZONE}:{L_TIMEZONE}:
{L_DATE_FORMAT}:
+
{L_DATE_FORMAT}:
{L_DATE_FORMAT_EXPLAIN}
@@ -95,35 +101,35 @@
{L_ALWAYS_ADD_SIGNATURE}:{L_ALWAYS_ADD_SIGNATURE}: - + {L_YES}   - + {L_NO}
{L_ALWAYS_ALLOW_BBCODE}:{L_ALWAYS_ALLOW_BBCODE}: - + {L_YES}   - + {L_NO}
{L_ALWAYS_ALLOW_HTML}:{L_ALWAYS_ALLOW_HTML}: - + {L_YES}   - + {L_NO}
{L_ALWAYS_ALLOW_SMILIES}:{L_ALWAYS_ALLOW_SMILIES}: - + {L_YES}   - + {L_NO}
{L_PROFILE_INFO_NOTICE}{L_PROFILE_INFO_NOTICE}
{L_ICQ}: {L_UCP_ICQ}:
{L_AIM}: {L_UCP_AIM}:
{L_MSNM}: {L_UCP_MSNM}:
{L_YIM}: {L_UCP_YIM}: