Add a homepage field to accounts

Allow users to add a link to their homepage to their profile.

Implements FS#22774.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2016-06-02 08:51:29 +02:00
parent 9fec03d655
commit e3670ef188
6 changed files with 62 additions and 19 deletions

View file

@ -32,6 +32,7 @@ CREATE TABLE Users (
ResetKey CHAR(32) NOT NULL DEFAULT '', ResetKey CHAR(32) NOT NULL DEFAULT '',
RealName VARCHAR(64) NOT NULL DEFAULT '', RealName VARCHAR(64) NOT NULL DEFAULT '',
LangPreference VARCHAR(5) NOT NULL DEFAULT 'en', LangPreference VARCHAR(5) NOT NULL DEFAULT 'en',
Homepage TEXT NULL DEFAULT NULL,
IRCNick VARCHAR(32) NOT NULL DEFAULT '', IRCNick VARCHAR(32) NOT NULL DEFAULT '',
PGPKey VARCHAR(40) NULL DEFAULT NULL, PGPKey VARCHAR(40) NULL DEFAULT NULL,
LastLogin BIGINT UNSIGNED NOT NULL DEFAULT 0, LastLogin BIGINT UNSIGNED NOT NULL DEFAULT 0,

View file

@ -15,3 +15,9 @@ ALTER TABLE Users MODIFY LastLoginIPAddress VARCHAR(45) NULL DEFAULT NULL;
---- ----
ALTER TABLE OfficialProviders ADD COLUMN Repo VARCHAR(64) NOT NULL; ALTER TABLE OfficialProviders ADD COLUMN Repo VARCHAR(64) NOT NULL;
---- ----
4. Add a column to store users' homepages:
----
ALTER TABLE Users ADD COLUMN Homepage TEXT NULL DEFAULT NULL;
----

View file

@ -78,12 +78,25 @@ if (isset($_COOKIE["AURSID"])) {
} else { } else {
/* Verify user has permission to edit the account */ /* Verify user has permission to edit the account */
if (can_edit_account($row)) { if (can_edit_account($row)) {
display_account_form("UpdateAccount", $row["Username"], display_account_form("UpdateAccount",
$row["AccountTypeID"], $row["Suspended"], $row["Email"], $row["Username"],
$row["HideEmail"], "", "", $row["RealName"], $row["AccountTypeID"],
$row["LangPreference"], $row["IRCNick"], $row["PGPKey"], $PK, $row["Suspended"],
$row["InactivityTS"] ? 1 : 0, $row["CommentNotify"], $row["Email"],
$row["UpdateNotify"], $row["ID"], $row["Username"]); $row["HideEmail"],
"",
"",
$row["RealName"],
$row["LangPreference"],
$row["Homepage"],
$row["IRCNick"],
$row["PGPKey"],
$PK,
$row["InactivityTS"] ? 1 : 0,
$row["CommentNotify"],
$row["UpdateNotify"],
$row["ID"],
$row["Username"]);
} else { } else {
print __("You do not have permission to edit this account."); print __("You do not have permission to edit this account.");
} }
@ -116,15 +129,25 @@ if (isset($_COOKIE["AURSID"])) {
print $update_account_message; print $update_account_message;
if (!$success) { if (!$success) {
display_account_form("UpdateAccount", in_request("U"), display_account_form("UpdateAccount",
in_request("T"), in_request("S"), in_request("U"),
in_request("E"), in_request("H"), in_request("T"),
in_request("P"), in_request("C"), in_request("S"),
in_request("R"), in_request("L"), in_request("E"),
in_request("I"), in_request("K"), in_request("H"),
in_request("PK"), in_request("J"), in_request("P"),
in_request("CN"), in_request("UN"), in_request("C"),
in_request("ID"), $row["Username"]); in_request("R"),
in_request("L"),
in_request("HP"),
in_request("I"),
in_request("K"),
in_request("PK"),
in_request("J"),
in_request("CN"),
in_request("UN"),
in_request("ID"),
$row["Username"]);
} }
} else { } else {

View file

@ -52,6 +52,7 @@ function html_format_pgp_fingerprint($fingerprint) {
* @param string $C The confirmed password value of the displayed user * @param string $C The confirmed password value of the displayed user
* @param string $R The real name of the displayed user * @param string $R The real name of the displayed user
* @param string $L The language preference of the displayed user * @param string $L The language preference of the displayed user
* @param string $HP The homepage of the displayed user
* @param string $I The IRC nickname of the displayed user * @param string $I The IRC nickname of the displayed user
* @param string $K The PGP key fingerprint of the displayed user * @param string $K The PGP key fingerprint of the displayed user
* @param string $PK The list of SSH public keys * @param string $PK The list of SSH public keys
@ -65,7 +66,7 @@ function html_format_pgp_fingerprint($fingerprint) {
* @return void * @return void
*/ */
function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R="", function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R="",
$L="",$I="",$K="",$PK="",$J="",$CN="",$UN="",$ON="",$UID=0,$N="") { $L="",$HP="",$I="",$K="",$PK="",$J="",$CN="",$UN="",$ON="",$UID=0,$N="") {
global $SUPPORTED_LANGS; global $SUPPORTED_LANGS;
include("account_edit_form.php"); include("account_edit_form.php");
@ -87,6 +88,7 @@ function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R=""
* @param string $C The confirmed password for the user * @param string $C The confirmed password for the user
* @param string $R The real name of the user * @param string $R The real name of the user
* @param string $L The language preference of the user * @param string $L The language preference of the user
* @param string $HP The homepage of the displayed user
* @param string $I The IRC nickname of the user * @param string $I The IRC nickname of the user
* @param string $K The PGP fingerprint of the user * @param string $K The PGP fingerprint of the user
* @param string $PK The list of public SSH keys * @param string $PK The list of public SSH keys
@ -100,7 +102,7 @@ function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R=""
* @return array Boolean indicating success and message to be printed * @return array Boolean indicating success and message to be printed
*/ */
function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="", function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",
$R="",$L="",$I="",$K="",$PK="",$J="",$CN="",$UN="",$ON="",$UID=0,$N="") { $R="",$L="",$HP="",$I="",$K="",$PK="",$J="",$CN="",$UN="",$ON="",$UID=0,$N="") {
global $SUPPORTED_LANGS; global $SUPPORTED_LANGS;
$error = ''; $error = '';
@ -276,13 +278,14 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C=""
$salt = $dbh->quote($salt); $salt = $dbh->quote($salt);
$R = $dbh->quote($R); $R = $dbh->quote($R);
$L = $dbh->quote($L); $L = $dbh->quote($L);
$HP = $dbh->quote($HP);
$I = $dbh->quote($I); $I = $dbh->quote($I);
$K = $dbh->quote(str_replace(" ", "", $K)); $K = $dbh->quote(str_replace(" ", "", $K));
$q = "INSERT INTO Users (AccountTypeID, Suspended, "; $q = "INSERT INTO Users (AccountTypeID, Suspended, ";
$q.= "InactivityTS, Username, Email, Passwd, Salt, "; $q.= "InactivityTS, Username, Email, Passwd, Salt, ";
$q.= "RealName, LangPreference, IRCNick, PGPKey) "; $q.= "RealName, LangPreference, Homepage, IRCNick, PGPKey) ";
$q.= "VALUES (1, 0, 0, $U, $E, $P, $salt, $R, $L, "; $q.= "VALUES (1, 0, 0, $U, $E, $P, $salt, $R, $L, ";
$q.= "$I, $K)"; $q.= "$HP, $I, $K)";
$result = $dbh->exec($q); $result = $dbh->exec($q);
if (!$result) { if (!$result) {
$message = __("Error trying to create account, %s%s%s.", $message = __("Error trying to create account, %s%s%s.",
@ -344,6 +347,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C=""
} }
$q.= ", RealName = " . $dbh->quote($R); $q.= ", RealName = " . $dbh->quote($R);
$q.= ", LangPreference = " . $dbh->quote($L); $q.= ", LangPreference = " . $dbh->quote($L);
$q.= ", Homepage = " . $dbh->quote($HP);
$q.= ", IRCNick = " . $dbh->quote($I); $q.= ", IRCNick = " . $dbh->quote($I);
$q.= ", PGPKey = " . $dbh->quote(str_replace(" ", "", $K)); $q.= ", PGPKey = " . $dbh->quote(str_replace(" ", "", $K));
$q.= ", InactivityTS = " . $inactivity_ts; $q.= ", InactivityTS = " . $inactivity_ts;

View file

@ -41,6 +41,10 @@
<th><?= __("Real Name") . ":" ?></th> <th><?= __("Real Name") . ":" ?></th>
<td><?= htmlspecialchars($row["RealName"], ENT_QUOTES) ?></td> <td><?= htmlspecialchars($row["RealName"], ENT_QUOTES) ?></td>
</tr> </tr>
<tr>
<th><?= __("Homepage") . ":" ?></th>
<td><?= htmlspecialchars($row["Homepage"], ENT_QUOTES) ?></td>
</tr>
<tr> <tr>
<th><?= __("IRC Nick") . ":" ?></th> <th><?= __("IRC Nick") . ":" ?></th>
<td><?= htmlspecialchars($row["IRCNick"], ENT_QUOTES) ?></td> <td><?= htmlspecialchars($row["IRCNick"], ENT_QUOTES) ?></td>

View file

@ -98,6 +98,11 @@
<input type="text" size="30" maxlength="32" name="R" id="id_realname" value="<?= htmlspecialchars($R,ENT_QUOTES) ?>" /> <input type="text" size="30" maxlength="32" name="R" id="id_realname" value="<?= htmlspecialchars($R,ENT_QUOTES) ?>" />
</p> </p>
<p>
<label for="id_homepage"><?= __("Homepage") ?>:</label>
<input type="text" size="30" name="HP" id="id_homepage" value="<?= htmlspecialchars($HP,ENT_QUOTES) ?>" />
</p>
<p> <p>
<label for="id_irc"><?= __("IRC Nick") ?>:</label> <label for="id_irc"><?= __("IRC Nick") ?>:</label>
<input type="text" size="30" maxlength="32" name="I" id="id_irc" value="<?= htmlspecialchars($I,ENT_QUOTES) ?>" /> <input type="text" size="30" maxlength="32" name="I" id="id_irc" value="<?= htmlspecialchars($I,ENT_QUOTES) ?>" />