";
$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 .= ' ';
+ $x .= sprintf(
+ ' ',
+ 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 .= ' ';
+ $x .= sprintf(
+ ' ',
+ 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 | ";
}
-function row_array($x) {
+function row_array($x, $attrs=null) {
echo "\n";
+ $i = 0;
foreach ($x as $h) {
- echo "$h | \n";
+ $a = $attrs?$attrs[$i]:"";
+ echo "$h | \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('
".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 "
-