diff --git a/db/constraints.sql b/db/constraints.sql index f65f3c77b8b..d66bd05fb65 100644 --- a/db/constraints.sql +++ b/db/constraints.sql @@ -12,7 +12,7 @@ alter table user add unique(email_addr), add unique(authenticator), add index ind_tid (teamid), - add index user_name(name), + add unique(name), add index user_tot (total_credit desc), -- db_dump.C add index user_avg (expavg_credit desc), diff --git a/html/inc/bootstrap.inc b/html/inc/bootstrap.inc index b348d46319f..e75c4b11b59 100644 --- a/html/inc/bootstrap.inc +++ b/html/inc/bootstrap.inc @@ -81,7 +81,7 @@ function navbar_right($user) { if ($user) { echo sprintf('
  • %s
  • - ', url_base(), USER_HOME, $user->name + ', url_base(), HOME_PAGE, $user->name ); $url_tokens = url_tokens($user->authenticator); echo sprintf('
  • Log out
  • ', @@ -156,7 +156,7 @@ function sample_navbar( $x = array(); if ($user) { - $x[] = array(tra("Account"), $url_prefix.USER_HOME); + $x[] = array(tra("Account"), $url_prefix.HOME_PAGE); $x[] = array(tra("Join"), $url_prefix."join.php"); $x[] = array(tra("Preferences"), $url_prefix."prefs.php?subset=project"); } diff --git a/html/inc/forum.inc b/html/inc/forum.inc index a46efa6b47c..d3c62e32959 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -809,6 +809,7 @@ function check_banished($user) { } function post_rules() { + if (defined('FORUM_RULES')) return FORUM_RULES; if (function_exists("project_forum_post_rules")) { $project_rules=project_forum_post_rules(); } else { diff --git a/html/inc/friend.inc b/html/inc/friend.inc index bdb0af84fd7..4c143cc8522 100644 --- a/html/inc/friend.inc +++ b/html/inc/friend.inc @@ -1,7 +1,7 @@ . +// code related to 'friend' features + // The following two are what gets put into notification email digests // function friend_notify_req_email_line($notify) { @@ -36,9 +38,13 @@ function friend_notify_accept_email_line($notify) { function friend_notify_req_web_line($notify) { $user = BoincUser::lookup_id($notify->opaque); if (!$user) return null; - return " - opaque>Friendship request from id>$user->name - "; + return sprintf( + 'Friendship request from %s', + $notify->opaque, + SHOW_USER_PAGE, + $user->id, + $user->name + ); } function friend_notify_accept_web_line($notify) { @@ -61,7 +67,7 @@ $src_user->name says: $msg $message .= " Please accept or decline by visiting -".secure_url_base().USER_HOME." +".secure_url_base().HOME_PAGE." -------------------------- To change email preferences, visit: @@ -83,7 +89,7 @@ $dest_user->name says: $msg $message .= " Visit your Account page at -".secure_url_base().USER_HOME." +".secure_url_base().HOME_PAGE." -------------------------- To change email preferences, visit: @@ -112,7 +118,7 @@ function friend_accept_rss($notify, &$title, &$msg, &$url) { } $title = "Friendship confirmation"; $msg = "$src_user->name has confirmed you as a friend"; - $url = secure_url_base().USER_HOME; + $url = secure_url_base().HOME_PAGE; } // delete friendship connections diff --git a/html/inc/more.inc b/html/inc/more.inc index c50aaefa466..2f81ffb2980 100644 --- a/html/inc/more.inc +++ b/html/inc/more.inc @@ -31,6 +31,7 @@ function show_text_more($text, $nchars) { // function show_text_more_aux($text, $nchars) { static $count = 0; + if (!$text) return ''; $n = strlen($text); if ($n < $nchars) { diff --git a/html/inc/pm.inc b/html/inc/pm.inc index 969892f0fdf..12d4651b056 100644 --- a/html/inc/pm.inc +++ b/html/inc/pm.inc @@ -28,6 +28,7 @@ function pm_header() { } function pm_rules() { + if (defined('PM_RULES')) return PM_RULES; $x = ""; } -function row_array($x) { +function row_array($x, $attrs=null) { echo "\n"; + $i = 0; foreach ($x as $h) { - echo "\n"; + $a = $attrs?$attrs[$i]:""; + echo "\n"; + $i++; } echo "\n"; } diff --git a/html/project.sample/project.inc b/html/project.sample/project.inc index ef15ae17ee1..3ce4d7a71f5 100644 --- a/html/project.sample/project.inc +++ b/html/project.sample/project.inc @@ -47,6 +47,7 @@ display_errors(); //-------------- enable/disable web features +define('UNIQUE_USER_NAME', true); define("FORUM_QA_MERGED_MODE", true); // Set to true to merge Message boards and Q&A section define ("DISABLE_PROFILES", true); diff --git a/html/user/account_finish_action.php b/html/user/account_finish_action.php index ea725fcc6ce..db44b5f31fe 100644 --- a/html/user/account_finish_action.php +++ b/html/user/account_finish_action.php @@ -58,7 +58,7 @@ // if so, skip team-finder // if ($user->teamid) { - Header("Location: ".USER_HOME); + Header("Location: ".HOME_PAGE); } else { Header("Location: team_search.php"); } diff --git a/html/user/create_account_action.php b/html/user/create_account_action.php index c5f009e1b6f..099895d15c6 100644 --- a/html/user/create_account_action.php +++ b/html/user/create_account_action.php @@ -29,7 +29,7 @@ if ($next_url) { Header("Location: ".url_base()."$next_url"); } else { - Header("Location: ".url_base().USER_HOME); + Header("Location: ".url_base().HOME_PAGE); send_cookie('init', "1", true); send_cookie('via_web', "1", true); } diff --git a/html/user/edit_forum_preferences_action.php b/html/user/edit_forum_preferences_action.php index c138a7b2e33..eb1907a52de 100644 --- a/html/user/edit_forum_preferences_action.php +++ b/html/user/edit_forum_preferences_action.php @@ -130,15 +130,27 @@ } // DISABLE_FORUMS -$add_user_to_filter = (isset($_POST["add_user_to_filter"]) && $_POST["add_user_to_filter"]!=""); -if ($add_user_to_filter){ - $user_to_add = trim($_POST["forum_filter_user"]); - if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){ - $other_user = BoincUser::lookup_id($user_to_add); - if (!$other_user) { - echo tra("No such user:")." ".$user_to_add; - } else { - add_ignored_user($user, $other_user); +if (UNIQUE_USER_NAME) { + $name = post_str('forum_filter_user', true); + if ($name) { + $other_user = BoincUser::lookup( + sprintf("name='%s'", BoincDb::escape_string($name)) + ); + if (!$other_user) error_page('No such user'); + add_ignored_user($user, $other_user); + } +} else { + // todo: clean up the following + $add_user_to_filter = (isset($_POST["add_user_to_filter"]) && $_POST["add_user_to_filter"]!=""); + if ($add_user_to_filter){ + $user_to_add = trim($_POST["forum_filter_user"]); + if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){ + $other_user = BoincUser::lookup_id($user_to_add); + if (!$other_user) { + echo tra("No such user:")." ".$user_to_add; + } else { + add_ignored_user($user, $other_user); + } } } } @@ -146,6 +158,7 @@ // Or remove some from the ignore list // $ignored_users = get_ignored_list($user); +// todo: use foreach for ($i=0;$iprefs->signature; $maxlen=250; +$x = ''; +if (!NO_COMPUTING) { + $x = tra( + "Check out %1 various free services %2
    providing dynamic 'signature images'
    showing your latest credit info, project news, etc.", + '', + '' + ); +} row2( - tra("Signature for message board posts") - .bbcode_info() - ."

    " - .tra("Check out %1 various free services %2 -
    providing dynamic 'signature images' -
    showing your latest credit info, project news, etc.", "", ""), - textarea_with_counter("signature", 250, $signature) - ."
    ".tra("Attach signature by default") + sprintf( + 'Signature for message board posts%s

    %s', + bbcode_info(), + $x + ), + sprintf( + '%s
    %s', + textarea_with_counter("signature", 250, $signature), + $signature_by_default, + tra("Attach signature by default") + ) ); if ($user->prefs->signature!=""){ row2(tra("Signature preview"). @@ -134,32 +145,59 @@ // ------------ Message filtering ----------- -row1(tra("Message filtering")); +row1(tra("Message blocking")); -$filtered_userlist = get_ignored_list($user); -$forum_filtered_userlist = ""; -for ($i=0; $iid."\" value=\"".tra("Remove")."\"> ".$filtered_user->id." - ".user_links($filtered_user)."
    "; + $blocked_str .= sprintf( + ' + %s %s + +
    + ', + UNIQUE_USER_NAME?'':"$blocked_user->id -", + user_links($blocked_user), + $blocked_user->id, + tra("Unblock") + ); } } -row2(tra("Filtered users"). - "

    ".tra("Ignore message board posts and private messages from these users.")."

    ", - "$forum_filtered_userlist - ".tra("User ID (For instance: 123456789)")." -

    - " +row2( + sprintf( + '%s

    %s

    ', + tra("Blocked users"), + tra('Ignore message board posts and private messages from these users.') + ), + $blocked_str?$blocked_str:'---' +); +row2( + tra('Block user'), + sprintf( + ' + %s + + + ', + UNIQUE_USER_NAME?tra('User name'):tra('User ID (For instance: 123456789)'), + tra("Block") + ) ); row1(tra("Update")); -row2(tra("Click here to update preferences"), ""); +row2( + tra("Click here to update preferences"), + "" +); echo "\n"; row1(tra("Reset")); row2(tra("Or click here to reset preferences to the defaults"), diff --git a/html/user/edit_user_info_action.php b/html/user/edit_user_info_action.php index 916b27ccd07..5baa94924a0 100644 --- a/html/user/edit_user_info_action.php +++ b/html/user/edit_user_info_action.php @@ -35,6 +35,11 @@ } $name = BoincDb::escape_string($name); +$u = BoincUser::lookup(sprintf("name='%s'", $name)); +if ($u && ($u->id != $user->id)) { + error_page('That name is in use - go back and try another.'); +} + $url = ""; $country = ""; $postal_code = ""; @@ -61,7 +66,7 @@ "name='$name', url='$url', country='$country', postal_code='$postal_code'" ); if ($result) { - Header("Location: ".USER_HOME); + Header("Location: ".HOME_PAGE); } else { error_page(tra("Couldn't update user info.")); } diff --git a/html/user/friend.php b/html/user/friend.php index 94100e04896..44d6b74c961 100644 --- a/html/user/friend.php +++ b/html/user/friend.php @@ -248,7 +248,7 @@ function handle_cancel_confirm($user) { ) ."

    \n" ; show_button("friend.php?action=cancel&userid=$destid", tra("Yes"), tra("Cancel friendship")); - show_button(USER_HOME, tra("No"), tra("Stay friends")); + show_button(HOME_PAGE, tra("No"), tra("Stay friends")); echo ""; page_tail(); } diff --git a/html/user/login_action.php b/html/user/login_action.php index 24dcb3e6de5..5001b93e815 100644 --- a/html/user/login_action.php +++ b/html/user/login_action.php @@ -102,7 +102,7 @@ function login_via_link($id, $t, $h) { // Intercept next_url if consent has not yet been given // - $next_url = intercept_login($user, true, USER_HOME); + $next_url = intercept_login($user, true, HOME_PAGE); Header("Location: ".url_base()."$next_url"); } @@ -165,7 +165,7 @@ function login_with_ldap($uid, $passwd, $next_url, $perm) { $next_url = sanitize_local_url($next_url); } if (!$next_url) { - $next_url = USER_HOME; + $next_url = HOME_PAGE; } $perm = false; diff --git a/html/user/login_form.php b/html/user/login_form.php index 17a5a940204..9553d58b419 100644 --- a/html/user/login_form.php +++ b/html/user/login_form.php @@ -58,9 +58,9 @@ if (!parse_bool($config, "disable_account_creation") && !parse_bool($config, "no_web_account_creation") ) { - echo tra("or %1 create an account %2.", - "", - "" + show_button( + "create_account_form.php?next_url=$next_url", + tra("Create account") ); } diff --git a/html/user/openid_login.php b/html/user/openid_login.php index 719a6a0300d..39044f94f62 100644 --- a/html/user/openid_login.php +++ b/html/user/openid_login.php @@ -146,7 +146,7 @@ function show_error($str) { if ($next_url) { Header("Location: ".url_base()."$next_url"); } else { - Header("Location: ".url_base().USER_HOME); + Header("Location: ".url_base().HOME_PAGE); send_cookie('init', "1", true); send_cookie('via_web', "1", true); } diff --git a/html/user/pm.php b/html/user/pm.php index d5e49f40292..9228f93745e 100644 --- a/html/user/pm.php +++ b/html/user/pm.php @@ -257,7 +257,17 @@ function do_send($logged_in_user) { } BoincForumPrefs::lookup($user); if (is_ignoring($user, $logged_in_user)) { - pm_form($replyto, $userid, tra("User %1 (ID: %2) is not accepting private messages from you.", $user->name, $user->id)); + pm_form( + $replyto, $userid, + UNIQUE_USER_NAME + ?tra("User %1 is not accepting private messages from you.", + $user->name + ) + :tra("User %1 (ID: %2) is not accepting private messages from you.", + $user->name, + $user->id + ) + ); } if (!isset($userids[$user->id])) { $userlist[] = $user; diff --git a/html/user/stats.php b/html/user/stats.php index 13ba26b7169..582737ed14a 100644 --- a/html/user/stats.php +++ b/html/user/stats.php @@ -57,7 +57,7 @@ shuffle($sig_sites); site_list($sig_sites); echo tra("Additionally you can get your individual statistics summed across all BOINC projects from several sites; see your %1 home page %2.", - sprintf('', USER_HOME), "" + sprintf('', HOME_PAGE), "" ); echo ""; diff --git a/html/user/team_founder_transfer_action.php b/html/user/team_founder_transfer_action.php index 888dfcb09a0..8803099ee41 100644 --- a/html/user/team_founder_transfer_action.php +++ b/html/user/team_founder_transfer_action.php @@ -120,7 +120,7 @@ function send_founder_transfer_decline_email($team, $user) { $team->update("userid=$user->id, ping_user=0, ping_time=0"); echo tra("Congratulations, you are now the founder of team %1. Go to %2 Your Account page %3 to find the Team Admin options.", $team->name, - sprintf('', secure_url_base(), USER_HOME), + sprintf('', secure_url_base(), HOME_PAGE), "" ); } else { diff --git a/html/user/team_join.php b/html/user/team_join.php index 76e86e74330..a6399242f03 100644 --- a/html/user/team_join.php +++ b/html/user/team_join.php @@ -39,7 +39,7 @@ } else { $success = user_join_team($team, $user); if ($success) { - Header("Location: ".USER_HOME); + Header("Location: ".HOME_PAGE); } else { error_page(tra("Couldn't join team - please try again later.")); } diff --git a/html/user/team_quit_action.php b/html/user/team_quit_action.php index b774df0a552..0aa827d9b65 100644 --- a/html/user/team_quit_action.php +++ b/html/user/team_quit_action.php @@ -29,7 +29,7 @@ $team = BoincTeam::lookup_id($teamid); if ($user->teamid == $team->id) { user_quit_team($user); - Header("Location: ".USER_HOME); + Header("Location: ".HOME_PAGE); } else { page_head(tra("Unable to quit team")); echo tra("Team doesn't exist, or you don't belong to it."); diff --git a/html/user/team_search.php b/html/user/team_search.php index 595bad1d5d1..0c20fb189ac 100644 --- a/html/user/team_search.php +++ b/html/user/team_search.php @@ -210,7 +210,7 @@ function search($params) { if (isset($_COOKIE['init'])) { echo "

    ".tra("%1 I'm not interested %2 in joining a team right now.", - sprintf('', USER_HOME), + sprintf('', HOME_PAGE), "" ); } diff --git a/html/user/user_agreetermsofuse_action.php b/html/user/user_agreetermsofuse_action.php index e88e06cab11..f6644b627f8 100644 --- a/html/user/user_agreetermsofuse_action.php +++ b/html/user/user_agreetermsofuse_action.php @@ -33,7 +33,7 @@ $next_url = urldecode($next_url); $next_url = sanitize_local_url($next_url); if (strlen($next_url) == 0) { - $next_url = USER_HOME; + $next_url = HOME_PAGE; } // validate checkbox diff --git a/html/user/user_search.php b/html/user/user_search.php index c936e4a7e63..2bd27fdd908 100644 --- a/html/user/user_search.php +++ b/html/user/user_search.php @@ -21,25 +21,37 @@ require_once("../inc/user.inc"); function show_user($user) { - echo " -

    - - "; - if ($user->teamid) { - $team = BoincTeam::lookup_id($user->teamid); - echo " - - "; - } else { - echo ""; + $x = []; + $y = []; + $x[] = sprintf('%s%s', + user_links($user, BADGE_HEIGHT_MEDIUM), + UNIQUE_USER_NAME?'':" (ID $user->id)" + ); + $y[] = null; + if (!DISABLE_TEAMS) { + if ($user->teamid) { + $team = BoincTeam::lookup_id($user->teamid); + $x[] = sprintf( + '%s', + $team->id, + $team->name + ); + } else { + $x[] = ''; + } + $y[] = null; } - echo " - - - - - - "; + if (!NO_COMPUTING) { + $x[] = format_credit($user->expavg_credit); + $y[] = ALIGN_RIGHT; + $x[] = format_credit_large($user->total_credit); + $y[] = ALIGN_RIGHT; + } + $x[] = $user->country; + $x[] = time_str($user->create_time); + $y[] = null; + $y[] = null; + row_array($x, $y); } function user_search_form() { @@ -57,20 +69,26 @@ function user_search_form() { echo ""; - row2(tra("With profile?"), - " ".tra("Either")." -   ".tra("No")." -   ".tra("Yes")." - "); - row2(tra("On a team?"), - " ".tra("Either")." -   ".tra("No")." -   ".tra("Yes")." - "); - row1(tra("Ordering"), 2, "heading"); - row2(tra("Decreasing sign-up time"), ""); - row2(tra("Decreasing average credit"), ""); - row2(tra("Decreasing total credit"), ""); + if (!DISABLE_PROFILES) { + row2(tra("With profile?"), + " ".tra("Either")." +   ".tra("No")." +   ".tra("Yes")." + "); + } + if (!DISABLE_TEAMS) { + row2(tra("On a team?"), + " ".tra("Either")." +   ".tra("No")." +   ".tra("Yes")." + "); + } + if (!NO_COMPUTING) { + row1(tra("Ordering"), 2, "heading"); + row2(tra("Decreasing sign-up time"), ""); + row2(tra("Decreasing average credit"), ""); + row2(tra("Decreasing total credit"), ""); + } row2("", ""); end_table(); echo " @@ -96,17 +114,21 @@ function search_action() { $s = BoincDb::escape_string($country); $where .= " and country='$s'"; } - $t = get_str('team'); - if ($t == 'yes') { - $where .= " and teamid<>0"; - } else if ($t == 'no') { - $where .= " and teamid=0"; + if (!DISABLE_TEAMS) { + $t = get_str('team'); + if ($t == 'yes') { + $where .= " and teamid<>0"; + } else if ($t == 'no') { + $where .= " and teamid=0"; + } } - $t = get_str('profile'); - if ($t == 'yes') { - $where .= " and has_profile<>0"; - } else if ($t == 'no') { - $where .= " and has_profile=0"; + if (!DISABLE_PROFILES) { + $t = get_str('profile'); + if ($t == 'yes') { + $where .= " and has_profile<>0"; + } else if ($t == 'no') { + $where .= " and has_profile=0"; + } } $search_type = get_str('search_type', true); @@ -124,17 +146,23 @@ function search_action() { foreach ($users as $user) { if ($n==0) { start_table('table-striped'); - row_heading_array( - array( - tra("Name"), - tra("Team"), - tra("Average credit"), - tra("Total credit"), - tra("Country"), - tra("Joined") - ), - array(null, null, ALIGN_RIGHT, ALIGN_RIGHT, null, null) - ); + $x = ['Name']; + $y = [null]; + if (!DISABLE_TEAMS) { + $x[] = 'Team'; + $y[] = null; + } + if (!NO_COMPUTING) { + $x[] = 'Average credit'; + $y[] = ALIGN_RIGHT; + $x[] = 'Total credit'; + $y[] = ALIGN_RIGHT; + } + $x[] = 'Country'; + $y[] = null; + $x[] = 'Joined'; + $y[] = null; + row_heading_array($x, $y); } show_user($user); $n++;
    "; $x .= tra("
      @@ -113,8 +114,8 @@ function pm_form($replyto, $userid, $error = null) { ); } - $subject = null; - $content = null; + $subject = ''; + $content = ''; if ($replyto) { $message = BoincPrivateMessage::lookup_id($replyto); if (!$message || $message->userid != $g_logged_in_user->id) { @@ -126,7 +127,7 @@ function pm_form($replyto, $userid, $error = null) { if (!$user) { error_page("Sender no longer exists"); } - $writeto = $userid." (".$user->name.")"; + $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")"; $subject = $message->subject; if (substr($subject, 0, 3) != "re:") { $subject = "re: ".$subject; @@ -136,7 +137,7 @@ function pm_form($replyto, $userid, $error = null) { if (!$user) { error_page("Sender no longer exists"); } - $writeto = $userid." (".$user->name.")"; + $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")"; } else { $writeto = sanitize_tags(post_str("to", true)); $subject = post_str("subject", true); @@ -154,7 +155,13 @@ function pm_form($replyto, $userid, $error = null) { echo "\n"; echo form_tokens($g_logged_in_user->authenticator); start_table(); - row2(tra("To")."
      ".tra("User IDs or unique usernames, separated with commas")."", + row2( + sprintf('%s
      %s', + tra("To"), + UNIQUE_USER_NAME + ?tra('User names, separated with commas') + :tra("User IDs or unique usernames, separated with commas") + ), "", null, '20%' ); diff --git a/html/inc/user.inc b/html/inc/user.inc index 8e75a0bc93d..7087616333c 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -286,7 +286,9 @@ function show_user_info_private($user) { .$delete_account_str ); } - row2(tra("User ID")."

      ".tra("Used in community functions")."

      ", $user->id); + if (!UNIQUE_USER_NAME) { + row2(tra("User ID")."

      ".tra("Used in community functions")."

      ", $user->id); + } if (!NO_COMPUTING) { row2( tra("Account keys"), @@ -323,11 +325,20 @@ function show_preference_links() { } } +// return describing a friend: their name, and profile picture if it exists +// function friend_links($user) { if (is_banished($user)) { return ""; } - $x = "
      "; + $x = sprintf( + '%s', + url_base(), + SHOW_USER_PAGE, + $user->id, + 'vertical-align:top', + $user->name + ); if ($user->has_profile) { $profile = BoincProfile::lookup_fields("has_picture", "userid=$user->id"); if ($profile && $profile->has_picture) { @@ -335,15 +346,20 @@ function friend_links($user) { } else { $img_url = url_base()."img/head_20.png"; } - $title = tra("View the profile of %1", $user->name); $alt = tra("Profile"); - $x .= ' '.$alt.'
      '; + $x .= sprintf( + '%s
      ', + url_base(), + $user->id, + tra("View the profile of %1", $user->name), + $img_url, + tra("Profile") + ); } - $x .= " id."\">".$user->name.""; if (function_exists("project_user_links")) { $x .= project_user_links($user); } - $x .= "
      \n"; + $x .= ''; return $x; } @@ -359,13 +375,26 @@ function user_links($user, $badge_height=0, $name_limit=0) { $x = ""; if ($user->has_profile) { $img_url = url_base()."img/head_20.png"; - $x .= ' Profile'; + $x .= sprintf( + ' Profile', + url_base(), + 'view_profile.php', + $user->id, + $user->name, + $img_url + ); } $name = $user->name; if ($name_limit && strlen($name) > $name_limit) { $name = substr($name, 0, $name_limit)."..."; } - $x .= " id."\">".$name.""; + $x .= sprintf( + '%s', + url_base(), + SHOW_USER_PAGE, + $user->id, + $name + ); if (function_exists("project_user_links")){ $x .= project_user_links($user); } @@ -441,17 +470,16 @@ function show_community_private($user) { } $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); - $x = "".tra("Find friends")."
      \n"; - $n = count($friends); - if ($n) { + $x = ''; + if ($friends) { foreach($friends as $friend) { $fuser = BoincUser::lookup_id($friend->user_dest); if (!$fuser) continue; $x .= friend_links($fuser); } - row2(tra("Friends")." ($n)", $x); - } else { row2(tra("Friends"), $x); + } else { + row2(tra("Friends"), '---'); } } @@ -459,7 +487,9 @@ function show_community_private($user) { // function show_user_summary_public($user) { global $g_logged_in_user; - row2(tra("User ID"), $user->id); + if (!UNIQUE_USER_NAME) { + row2(tra("User ID"), $user->id); + } row2(tra("%1 member since", PROJECT), date_str($user->create_time)); if (USER_COUNTRY) { row2(tra("Country"), $user->country); @@ -505,6 +535,8 @@ function get_community_links_object($user){ return $cache_object; } +// show community links of another user (described by $clo) +// function community_links($clo, $logged_in_user){ $user = $clo->user; $team = $clo->team; @@ -538,11 +570,11 @@ function community_links($clo, $logged_in_user){ } if ($friends) { - $x = ""; + $x = ''; foreach($friends as $friend) { $x .= friend_links($friend); } - row2(tra("Friends")." (".sizeof($friends).")", $x); + row2(tra('Friends'), $x); } } diff --git a/html/inc/user_util.inc b/html/inc/user_util.inc index 44e7708940e..5942b918e62 100644 --- a/html/inc/user_util.inc +++ b/html/inc/user_util.inc @@ -90,6 +90,10 @@ function is_valid_user_name($name, &$reason) { $reason = tra("user name may not contain HTML tags"); return false; } + if (is_numeric($name)) { + $reason = tra("user name may not be a number"); + return false; + } return true; } @@ -228,6 +232,23 @@ function validate_post_make_user() { if (!is_valid_user_name($new_name, $reason)) { show_error($reason); } + if (UNIQUE_USER_NAME) { + $u = BoincUser::lookup_name($new_name); + if ($u) { + page_head("That name is in use"); + echo "

      The following user names are taken; + please go back and use a different one.

      + "; + $users = BoincUser::enum( + sprintf("name like '%s%%'", $new_name) + ); + foreach ($users as $u){ + echo "

      $u->name\n"; + } + page_tail(); + exit; + } + } $new_email_addr = strtolower(post_str("new_email_addr")); if (!is_valid_email_addr($new_email_addr)) { diff --git a/html/inc/util.inc b/html/inc/util.inc index 16e095655e6..9a226f88fce 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -91,9 +91,21 @@ if (!defined('NO_STATS')) { if (!defined('NO_GLOBAL_PREFS')) { define('NO_GLOBAL_PREFS', false); } -if (!defined('USER_HOME')) { - define('USER_HOME', 'home.php'); + +// the 'home page' of the logged-in user. +// go here after login, account creation, team operations, etc. +// +if (!defined('HOME_PAGE')) { + define('HOME_PAGE', 'home.php'); +} + +// the page showing another user. +// Link to here wherever we show a user name. +// +if (!defined('SHOW_USER_PAGE')) { + define('SHOW_USER_PAGE', 'show_user.php'); } + if (!defined('POST_MAX_LINKS')) { define('POST_MAX_LINKS', 0); } @@ -103,6 +115,9 @@ if (!defined('DARK_MODE')) { if (!defined('VALIDATE_EMAIL_TO_POST')) { define('VALIDATE_EMAIL_TO_POST', false); } +if (!defined('UNIQUE_USER_NAME')) { + define('UNIQUE_USER_NAME', false); +} // don't allow anything between .php and ? in URL // @@ -550,10 +565,13 @@ function rowify($string) { echo "

    $string
    $h$h
    ", user_links($user, BADGE_HEIGHT_MEDIUM), " (ID $user->id) id>$team->name
    ", format_credit($user->expavg_credit), "", format_credit_large($user->total_credit), "", $user->country, "", time_str($user->create_time),"