diff --git a/html/user/view_profile.php b/html/user/view_profile.php index b920dad5c7..683d8d098b 100644 --- a/html/user/view_profile.php +++ b/html/user/view_profile.php @@ -1,154 +1,17 @@ "); - exit(); -} - -$user = get_user_from_id($userid); - -if (!$user) { - profile_error_page("No user exists for that ID, or there was a database error.

"); - exit(); -} - -// Check for recommendation or rejection votes. +// Check for recommendation or rejection votes.; if ($_POST['recommend']) { - process_results("recommend"); - exit(); -} else if ($_POST['reject']) { - process_results("reject"); - exit(); -} - -$result = mysql_query("SELECT * FROM profile WHERE userid = $user->id"); - -if (mysql_num_rows($result) > 0) { - $profile_info = mysql_fetch_array($result, MYSQL_ASSOC); -} else { - // TODO: Standardize this to a global error page. - echo "No user profile exists for that user ID."; - exit(); -} - -$logged_in_user = get_logged_in_user(false); // (false) since anyone can look at profiles. -$can_edit = $logged_in_user && $user->id == $logged_in_user->id; - - -page_head("User Profile: ".$user->name); - -if ($can_edit) { - echo "[Edit Your Profile]"; -} - -start_table_noborder(); -echo ""; -show_profile_summary(); -echo ""; -show_profile_heading1(); -echo "", $profile_info['response1'], "

"; -show_profile_heading2(); -echo "", $profile_info['response2'], ""; -end_table(); -page_tail(); - - -function show_profile_summary() { - global $user; - global $profile_info; - global $can_edit; - - - echo " -\n -\n -

$user->name

"; - - if (!$can_edit) { - show_buttons(); - } - -echo "
\n"; - - // Only display an image if the user has uploaded one. - if (file_exists(IMAGE_PATH . $user->id . '_sm.jpg')) { - echo " -id , '.jpg' . "\">id , '_sm.jpg' . "\">\n"; - } - - echo " - -Country: ", $user->country, "  Language: ", $profile_info['language'], "
"; - if (!$profile_info['hide_email']) { - echo "Email: email_addr, "\">", $user->email_addr, "
"; - } - echo "Total Credit: ", $user->total_credit, "
"; - - if ($user->teamid) { - $result = mysql_query("select * from team where id = $user->teamid"); - $team = mysql_fetch_object($result); - echo "Team: id>$team->name
"; - } - echo " -Date Registered: ", date_str($user->create_time), " -
-
-
\n"; -} - -function show_buttons() { - global $userid; - - echo " -

- -what is recommend? -
- -what is vote to reject? -
-"; -} - -function process_results($vote) { - global $userid; - - if ($vote != "recommend" && $vote != "reject") { - echo "Invalid vote type.
"; + process_view_results("recommend", $userid); + exit(); +} else if ($_POST['reject']) { + process_view_results("reject", $userid); exit(); - } - - $result = mysql_query("SELECT * FROM profile WHERE userid = $userid"); - $profile = mysql_fetch_array($result); - - $newValue = $profile[$vote] + 1; - $newresult = mysql_query("UPDATE profile SET $vote = $newValue WHERE userid = $userid"); - - page_head("Vote Recorded"); - - start_table_noborder(); - - row1("Thank you"); - - if ($vote == "recommend") { - rowify("Your recommendation has been recorded."); - } else { - rowify("Your vote to reject has been recorded."); - } - end_table(); - echo "
Return to profile."; - - - page_tail(); - } + +show_profile($userid, array_key_exists('verify', $_GET)); ?>