Store account type in local var when possible

No need to call this function way too often, especially when on the package
list page where it could be called up to once per row.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Dan McGee 2008-12-29 22:36:06 -06:00 committed by Loui Chang
parent bf4fe7f47c
commit 8f97330100
3 changed files with 11 additions and 10 deletions

View file

@ -271,6 +271,7 @@ function pkgname_from_id($id="") {
function package_details($id=0, $SID="") { function package_details($id=0, $SID="") {
global $_REQUEST; global $_REQUEST;
global $pkgsearch_vars; global $pkgsearch_vars;
$atype = account_from_sid($SID);
$q = "SELECT Packages.*,Location,Category "; $q = "SELECT Packages.*,Location,Category ";
$q.= "FROM Packages,PackageLocations,PackageCategories "; $q.= "FROM Packages,PackageLocations,PackageCategories ";
$q.= "WHERE Packages.LocationID = PackageLocations.ID "; $q.= "WHERE Packages.LocationID = PackageLocations.ID ";
@ -304,8 +305,8 @@ function package_details($id=0, $SID="") {
echo " <tr><td class='boxSoft' colspan='2'><span class='f3'>"; echo " <tr><td class='boxSoft' colspan='2'><span class='f3'>";
if ($row["Location"] == "unsupported" and ( if ($row["Location"] == "unsupported" and (
uid_from_sid($SID) == $row["MaintainerUID"] or uid_from_sid($SID) == $row["MaintainerUID"] or
(account_from_sid($SID) == "Developer" or ($atype == "Developer" or
account_from_sid($SID) == "Trusted User"))) { $atype == "Trusted User"))) {
$edit_cat = "<a href='pkgedit.php?change_Category=1&ID="; $edit_cat = "<a href='pkgedit.php?change_Category=1&ID=";
$edit_cat .= intval($_REQUEST["ID"])."'>".$row["Category"]."</a>"; $edit_cat .= intval($_REQUEST["ID"])."'>".$row["Category"]."</a>";
$edit_cat .= " &nbsp;<span class='fix'>("; $edit_cat .= " &nbsp;<span class='fix'>(";
@ -511,14 +512,12 @@ function package_details($id=0, $SID="") {
echo "<input type='submit' class='button' name='do_Adopt'"; echo "<input type='submit' class='button' name='do_Adopt'";
echo " value='".__("Adopt Packages")."'>\n"; echo " value='".__("Adopt Packages")."'>\n";
} else if ($row["MaintainerUID"] == uid_from_sid($SID) || } else if ($row["MaintainerUID"] == uid_from_sid($SID) ||
account_from_sid($SID) == "Trusted User" || $atype == "Trusted User" || $atype == "Developer") {
account_from_sid($SID) == "Developer") {
echo "<input type='submit' class='button' name='do_Disown'"; echo "<input type='submit' class='button' name='do_Disown'";
echo " value='".__("Disown Packages")."'>\n"; echo " value='".__("Disown Packages")."'>\n";
} }
if (account_from_sid($SID) == "Trusted User" || if ($atype == "Trusted User" || $atype == "Developer") {
account_from_sid($SID) == "Developer") {
echo "<input type='submit' class='button' name='do_Delete'"; echo "<input type='submit' class='button' name='do_Delete'";
echo " value='".__("Delete Packages")."'>\n"; echo " value='".__("Delete Packages")."'>\n";
} }
@ -554,7 +553,7 @@ function package_details($id=0, $SID="") {
echo " <table class='boxSoft' width='100%'>\n"; echo " <table class='boxSoft' width='100%'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td class='boxSoftTitle'><span class='f3'>"; echo " <td class='boxSoftTitle'><span class='f3'>";
if (canDeleteComment($carr["ID"], account_from_sid($SID), $SID)) { if (canDeleteComment($carr["ID"], $atype, $SID)) {
$durl = "<a href='pkgedit.php?del_Comment=1"; $durl = "<a href='pkgedit.php?del_Comment=1";
$durl.= "&comment_id=".$carr["ID"]."&ID=".$row["ID"]; $durl.= "&comment_id=".$carr["ID"]."&ID=".$row["ID"];
$durl.= "'><img src='/images/x.png' border='0'"; $durl.= "'><img src='/images/x.png' border='0'";

View file

@ -49,8 +49,9 @@ if (isset($_COOKIE["AURSID"])) {
<li><a href="pkgsubmit.php"><?php print __("Submit"); ?></a></li> <li><a href="pkgsubmit.php"><?php print __("Submit"); ?></a></li>
<li><a href="packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li> <li><a href="packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li>
<?php <?php
if (account_from_sid($_COOKIE["AURSID"]) == "Trusted User" $SID = $_COOKIE['AURSID'];
|| account_from_sid($_COOKIE["AURSID"]) == "Developer") { $atype = account_from_sid($SID);
if ($atype == "Trusted User" || $atype == "Developer") {
?> ?>
<li><a href="tu.php"><?php print __("Trusted User"); ?></a></li> <li><a href="tu.php"><?php print __("Trusted User"); ?></a></li>
<?php <?php

View file

@ -48,6 +48,7 @@ $_GET['K'] = urlencode($_GET['K']);
</tr> </tr>
<?php <?php
$atype = account_from_sid($_COOKIE['AURSID']);
for ($i = 0; $row = mysql_fetch_assoc($result); $i++) { for ($i = 0; $row = mysql_fetch_assoc($result); $i++) {
(($i % 2) == 0) ? $c = "data1" : $c = "data2"; (($i % 2) == 0) ? $c = "data1" : $c = "data2";
if ($row["OutOfDate"]): $c = "outofdate"; endif; if ($row["OutOfDate"]): $c = "outofdate"; endif;
@ -99,7 +100,7 @@ for ($i = 0; $row = mysql_fetch_assoc($result); $i++) {
<option value='do_UnFlag'><?php print __("Unflag Out-of-date") ?></option> <option value='do_UnFlag'><?php print __("Unflag Out-of-date") ?></option>
<option value='do_Adopt'><?php print __("Adopt Packages") ?></option> <option value='do_Adopt'><?php print __("Adopt Packages") ?></option>
<option value='do_Disown'><?php print __("Disown Packages") ?></option> <option value='do_Disown'><?php print __("Disown Packages") ?></option>
<?php if (account_from_sid($SID) == "Trusted User" || account_from_sid($SID) == "Developer"): ?> <?php if ($atype == "Trusted User" || $atype == "Developer"): ?>
<option value='do_Delete'><?php print __("Delete Packages") ?></option> <option value='do_Delete'><?php print __("Delete Packages") ?></option>
<?php endif; ?> <?php endif; ?>
<option value='do_Notify'><?php print __("Notify") ?></option> <option value='do_Notify'><?php print __("Notify") ?></option>