summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authoreric <eric>2004-07-14 02:20:32 +0200
committereric <eric>2004-07-14 02:20:32 +0200
commit1e1eb451def58b0802ce156d91b8afa13d321eb6 (patch)
treee96d74f1a296d7cdbc9772e148405de7ee813ac3 /web/lib
parent56effc6ae4737f955c972177bf3cc0d7a5e320be (diff)
downloadaur-1e1eb451def58b0802ce156d91b8afa13d321eb6.tar.gz
aur-1e1eb451def58b0802ce156d91b8afa13d321eb6.tar.xz
still working on pkgsubmit
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aur.inc39
1 files changed, 39 insertions, 0 deletions
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index 0db5c126..f652b061 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -444,6 +444,45 @@ function dbug($msg) {
return;
}
+# check to see if the package name exists
+#
+function package_exists($name="") {
+ if (!$name) {return 0;}
+ $dbh = db_connect();
+ $q = "SELECT COUNT(*) FROM Packages ";
+ $q.= "WHERE Name = '".mysql_escape_string($name)."'";
+ $result = db_query($q, $dbh);
+ if (!$result) {return 0;}
+ $row = mysql_fetch_row($result);
+ return $row[0];
+}
+
+# check to see if the user can overwrite an existing package
+#
+function can_overwrite_pkg($name="", $sid="") {
+ if (!$name || !$sid) {return 0;}
+ $dbh = db_connect();
+ $q = "SELECT SubmitterUID, MaintainerUID, AURMaintainerUID ";
+ $q.= "FROM Packages WHERE Name = '".mysql_escape_string($name)."'";
+ $result = db_query($q, $dbh);
+ if (!$result) {return 0;}
+ $row = mysql_fetch_row($result);
+ $my_uid = uid_from_sid($sid);
+
+ # user is a dev and maintains the package
+ #
+ if ($my_uid == $row[2]) {return 1;}
+
+ # user is a TU and there is no dev
+ #
+ if (!$row[2] && $my_uid == $row[1]) {return 1;}
+
+ # user is a user and there is no TU or dev
+ #
+ if (!$row[2] && !$row[1] && $my_uid == $row[0]) {return 1;}
+ return 0;
+}
+
# convert an ini_get number to a real integer - stupid PHP!
#
function initeger($inival="0", $isbytes=1) {