mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Refactor code for printing account links
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
19ee268935
commit
a2f79eb2e1
4 changed files with 12 additions and 39 deletions
|
@ -181,10 +181,19 @@ function username_from_sid($sid="") {
|
||||||
*
|
*
|
||||||
* @param string $username The user name to format
|
* @param string $username The user name to format
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string The generated HTML code for the account link
|
||||||
*/
|
*/
|
||||||
function html_format_username($username) {
|
function html_format_username($username) {
|
||||||
return $username ? htmlspecialchars($username) : __("None");
|
$username_fmt = $username ? htmlspecialchars($username, ENT_QUOTES) : __("None");
|
||||||
|
|
||||||
|
if ($username && $_COOKIE["AURSID"]) {
|
||||||
|
$link = '<a href="' . get_uri('/account/') . $username_fmt;
|
||||||
|
$link .= '" title="' . __('View account information for %s', $username_fmt);
|
||||||
|
$link .= '">' . $username_fmt . '</a>';
|
||||||
|
return $link;
|
||||||
|
} else {
|
||||||
|
return $username_fmt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -289,33 +289,15 @@ if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Submitter') .': ' ?></th>
|
<th><?= __('Submitter') .': ' ?></th>
|
||||||
<?php if ($row["SubmitterUID"] && $SID): ?>
|
|
||||||
<td><a href="<?= get_uri('/account/') . html_format_username($submitter, ENT_QUOTES) ?>" title="<?= __('View account information for %s', html_format_username($submitter)) ?>"><?= html_format_username($submitter) ?></a></td>
|
|
||||||
<?php elseif ($row["SubmitterUID"] && !$SID): ?>
|
|
||||||
<td><?= html_format_username($submitter) ?></td>
|
<td><?= html_format_username($submitter) ?></td>
|
||||||
<?php else: ?>
|
|
||||||
<td><?= __('None') ?></td>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Maintainer') .': ' ?></th>
|
<th><?= __('Maintainer') .': ' ?></th>
|
||||||
<?php if ($row["MaintainerUID"] && $SID): ?>
|
|
||||||
<td><a href="<?= get_uri('/account/') . html_format_username($maintainer) ?>" title="<?= __('View account information for %s', html_format_username($maintainer)) ?>"><?= html_format_username($maintainer) ?></a></td>
|
|
||||||
<?php elseif ($row["MaintainerUID"] && !$SID): ?>
|
|
||||||
<td><?= html_format_username($maintainer) ?></td>
|
<td><?= html_format_username($maintainer) ?></td>
|
||||||
<?php else: ?>
|
|
||||||
<td><?= __('None') ?></td>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Last Packager') .': ' ?></th>
|
<th><?= __('Last Packager') .': ' ?></th>
|
||||||
<?php if ($row["PackagerUID"] && $SID): ?>
|
|
||||||
<td><a href="<?= get_uri('/account/') . html_format_username($packager) ?>" title="<?= __('View account information for %s', html_format_username($packager)) ?>"><?= html_format_username($packager) ?></a></td>
|
|
||||||
<?php elseif ($row["PackagerUID"] && !$SID): ?>
|
|
||||||
<td><?= html_format_username($packager) ?></td>
|
<td><?= html_format_username($packager) ?></td>
|
||||||
<?php else: ?>
|
|
||||||
<td><?= __('None') ?></td>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Votes') . ': ' ?></th>
|
<th><?= __('Votes') . ': ' ?></th>
|
||||||
|
|
|
@ -148,33 +148,15 @@ if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Submitter') .': ' ?></th>
|
<th><?= __('Submitter') .': ' ?></th>
|
||||||
<?php if ($row["SubmitterUID"] && $SID): ?>
|
|
||||||
<td><a href="<?= get_uri('/account/') . html_format_username($submitter, ENT_QUOTES) ?>" title="<?= __('View account information for %s', html_format_username($submitter)) ?>"><?= html_format_username($submitter) ?></a></td>
|
|
||||||
<?php elseif ($row["SubmitterUID"] && !$SID): ?>
|
|
||||||
<td><?= html_format_username($submitter) ?></td>
|
<td><?= html_format_username($submitter) ?></td>
|
||||||
<?php else: ?>
|
|
||||||
<td><?= __('None') ?></td>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Maintainer') .': ' ?></th>
|
<th><?= __('Maintainer') .': ' ?></th>
|
||||||
<?php if ($row["MaintainerUID"] && $SID): ?>
|
|
||||||
<td><a href="<?= get_uri('/account/') . html_format_username($maintainer) ?>" title="<?= __('View account information for %s', html_format_username($maintainer)) ?>"><?= html_format_username($maintainer) ?></a></td>
|
|
||||||
<?php elseif ($row["MaintainerUID"] && !$SID): ?>
|
|
||||||
<td><?= html_format_username($maintainer) ?></td>
|
<td><?= html_format_username($maintainer) ?></td>
|
||||||
<?php else: ?>
|
|
||||||
<td><?= __('None') ?></td>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Last Packager') .': ' ?></th>
|
<th><?= __('Last Packager') .': ' ?></th>
|
||||||
<?php if ($row["PackagerUID"] && $SID): ?>
|
|
||||||
<td><a href="<?= get_uri('/account/') . html_format_username($packager) ?>" title="<?= __('View account information for %s', html_format_username($packager)) ?>"><?= html_format_username($packager) ?></a></td>
|
|
||||||
<?php elseif ($row["PackagerUID"] && !$SID): ?>
|
|
||||||
<td><?= html_format_username($packager) ?></td>
|
<td><?= html_format_username($packager) ?></td>
|
||||||
<?php else: ?>
|
|
||||||
<td><?= __('None') ?></td>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= __('Votes') . ': ' ?></th>
|
<th><?= __('Votes') . ': ' ?></th>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
?>
|
?>
|
||||||
<tr class="<?= $c ?>">
|
<tr class="<?= $c ?>">
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= get_uri('/account/') . html_format_username($username) ?>" title="<?= __('View account information for %s', html_format_username($username)) ?>"><?= html_format_username($username) ?></a>
|
<?= html_format_username($username) ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= get_uri('/tu/'); ?>?id=<?= $row['LastVote'] ?>"><?= intval($row["LastVote"]) ?></a>
|
<a href="<?= get_uri('/tu/'); ?>?id=<?= $row['LastVote'] ?>"><?= intval($row["LastVote"]) ?></a>
|
||||||
|
|
Loading…
Add table
Reference in a new issue