[aur-dev] [PATCH 3/3] Add a new user group "Trusted User & Developer"

Lukas Fleischer archlinux at cryptocrack.de
Tue Jul 15 16:59:30 EDT 2014


This group has full permissions on everything.

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 schema/aur-schema.sql                 |  1 +
 upgrading/3.4.0.txt                   |  5 +++++
 web/lib/acctfuncs.inc.php             |  6 +++++-
 web/lib/credentials.inc.php           | 12 ++++++++----
 web/template/account_details.php      |  2 ++
 web/template/account_edit_form.php    |  4 ++++
 web/template/search_accounts_form.php |  1 +
 7 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 upgrading/3.4.0.txt

diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql
index 8d89487..0ec4f75 100644
--- a/schema/aur-schema.sql
+++ b/schema/aur-schema.sql
@@ -15,6 +15,7 @@ CREATE TABLE AccountTypes (
 INSERT INTO AccountTypes (ID, AccountType) VALUES (1, 'User');
 INSERT INTO AccountTypes (ID, AccountType) VALUES (2, 'Trusted User');
 INSERT INTO AccountTypes (ID, AccountType) VALUES (3, 'Developer');
+INSERT INTO AccountTypes (ID, AccountType) VALUES (4, 'Trusted User & Developer');
 
 
 -- User information for each user regardless of type.
diff --git a/upgrading/3.4.0.txt b/upgrading/3.4.0.txt
new file mode 100644
index 0000000..c2f1688
--- /dev/null
+++ b/upgrading/3.4.0.txt
@@ -0,0 +1,5 @@
+1. Add the "Trusted User & Developer" user group:
+
+----
+INSERT INTO AccountTypes (ID, AccountType) VALUES (4, 'Trusted User & Developer');
+----
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index 578c376..73d01a5 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -338,6 +338,9 @@ function search_results_page($O=0,$SB="",$U="",$T="",
 	} elseif ($T == "d") {
 		$q.= "AND AccountTypes.ID = 3 ";
 		$search_vars[] = "T";
+	} elseif ($T == "td") {
+		$q.= "AND AccountTypes.ID = 4 ";
+		$search_vars[] = "T";
 	}
 	if ($S) {
 		$q.= "AND Users.Suspended = 1 ";
@@ -1080,7 +1083,8 @@ function cast_proposal_vote($voteid, $uid, $vote, $newtotal) {
  * @return bool True if permission to edit the account, otherwise false
  */
 function can_edit_account($acctinfo) {
-	if ($acctinfo['AccountType'] == 'Developer') {
+	if ($acctinfo['AccountType'] == 'Developer' ||
+	    $acctinfo['AccountType'] == 'Trusted User & Developer') {
 		return has_credential(CRED_ACCOUNT_EDIT_DEV);
 	}
 
diff --git a/web/lib/credentials.inc.php b/web/lib/credentials.inc.php
index 22068e4..47dd3fd 100644
--- a/web/lib/credentials.inc.php
+++ b/web/lib/credentials.inc.php
@@ -48,7 +48,8 @@ function has_credential($credential, $approved_users=array()) {
 	case CRED_PKGBASE_NOTIFY:
 	case CRED_PKGBASE_VOTE:
 		return ($atype == 'User' || $atype == 'Trusted User' ||
-			$atype == 'Developer');
+			$atype == 'Developer' ||
+			$atype == 'Trusted User & Developer');
 	case CRED_ACCOUNT_CHANGE_TYPE:
 	case CRED_ACCOUNT_EDIT:
 	case CRED_ACCOUNT_LAST_LOGIN:
@@ -63,13 +64,16 @@ function has_credential($credential, $approved_users=array()) {
 	case CRED_PKGBASE_UNFLAG:
 	case CRED_PKGREQ_CLOSE:
 	case CRED_PKGREQ_LIST:
-		return ($atype == 'Trusted User' || $atype == 'Developer');
+		return ($atype == 'Trusted User' || $atype == 'Developer' ||
+			$atype == 'Trusted User & Developer');
 	case CRED_TU_ADD_VOTE:
 	case CRED_TU_LIST_VOTES:
 	case CRED_TU_VOTE:
-		return ($atype == 'Trusted User');
+		return ($atype == 'Trusted User' ||
+			$atype == 'Trusted User & Developer');
 	case CRED_ACCOUNT_EDIT_DEV:
-		return ($atype == 'Developer');
+		return ($atype == 'Developer' ||
+			$atype == 'Trusted User & Developer');
 	}
 
 	return false;
diff --git a/web/template/account_details.php b/web/template/account_details.php
index c4263d7..9282b2c 100644
--- a/web/template/account_details.php
+++ b/web/template/account_details.php
@@ -17,6 +17,8 @@
 							print __("Trusted User");
 						} elseif ($row["AccountType"] == "Developer") {
 							print __("Developer");
+						} elseif ($row["AccountType"] == "Trusted User & Developer") {
+							print __("Trusted User & Developer");
 						}
 						?>
 					</td>
diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php
index 9a99e78..f5890fc 100644
--- a/web/template/account_edit_form.php
+++ b/web/template/account_edit_form.php
@@ -37,6 +37,10 @@
 				<?php $T == 3 ? print " selected=\"selected\">" : print ">";
 				print __("Developer")."\n"; ?>
 				</option>
+				<option value="4"
+				<?php $T == 4 ? print " selected=\"selected\">" : print ">";
+				print __("Trusted User & Developer")."\n"; ?>
+				</option>
 				<?php endif; ?>
 
 			</select>
diff --git a/web/template/search_accounts_form.php b/web/template/search_accounts_form.php
index 3531eb0..f7824a9 100644
--- a/web/template/search_accounts_form.php
+++ b/web/template/search_accounts_form.php
@@ -15,6 +15,7 @@
 				<option value="u"><?= __("Normal user"); ?></option>
 				<option value="t"><?= __("Trusted user"); ?></option>
 				<option value="d"><?= __("Developer"); ?></option>
+				<option value="td"><?= __("Trusted User & Developer"); ?></option>
 			</select>
 		</p>
 		<p>
-- 
2.0.1


More information about the aur-dev mailing list