ApiPermission: added isCore column
This commit is contained in:
@@ -62,7 +62,7 @@ namespace Core\API\ApiKey {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to create new API-Keys");
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to create new API-Keys", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Core\API\ApiKey {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to fetch new API-Key");
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to fetch new API-Keys", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Core\API\ApiKey {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to refresh API-Key");
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to refresh API-Keys", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Core\API\ApiKey {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to revoke API-Key");
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to revoke API-Keys", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace Core\API\Database {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to view the database status");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to view the database status", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Core\API\Database {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to migrate the database structure");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to migrate the database structure", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to fetch available groups");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to fetch available groups", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to get details about a group");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to get details about a group", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to fetch members of a group");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to fetch members of a group", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to create a new group");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to create a new group", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to delete a group");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to delete a group", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to add members to a group");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to add members to a group", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace Core\API\Groups {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to remove members from a group");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to remove members from a group", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace Core\API\Logs {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch system logs");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch system logs", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Core\API\Mail {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to send a test email to verify configuration");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to send a test email to verify configuration", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Core\API\Permission {
|
||||
}
|
||||
|
||||
$sql = $this->context->getSQL();
|
||||
$res = $sql->select("method", "groups", "description")
|
||||
$res = $sql->select("method", "groups", "description", "isCore")
|
||||
->from("ApiPermission")
|
||||
->execute();
|
||||
|
||||
@@ -117,16 +117,18 @@ namespace Core\API\Permission {
|
||||
$this->lastError = $sql->getLastError();
|
||||
|
||||
if ($this->success) {
|
||||
$permissions = array();
|
||||
$permissions = [];
|
||||
foreach ($res as $row) {
|
||||
$method = $row["method"];
|
||||
$description = $row["description"];
|
||||
$groups = json_decode($row["groups"]);
|
||||
$permissions[] = array(
|
||||
$isCore = $row["isCore"];
|
||||
$permissions[] = [
|
||||
"method" => $method,
|
||||
"groups" => $groups,
|
||||
"description" => $description
|
||||
);
|
||||
"description" => $description,
|
||||
"isCore" => $isCore
|
||||
];
|
||||
}
|
||||
$this->result["permissions"] = $permissions;
|
||||
$this->result["groups"] = $this->groups;
|
||||
@@ -136,7 +138,7 @@ namespace Core\API\Permission {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch API permissions");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch API permissions", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,29 +160,37 @@ namespace Core\API\Permission {
|
||||
$sql = $this->context->getSQL();
|
||||
$methodParam = new StringType('method', 32);
|
||||
$groupsParam = new Parameter('groups', Parameter::TYPE_ARRAY);
|
||||
$descriptionParam = new StringType('method', 128);
|
||||
|
||||
$updateQuery = $sql->insert("ApiPermission", array("method", "groups"))
|
||||
->onDuplicateKeyStrategy(new UpdateStrategy(array("method"), array("groups" => new Column("groups"))));
|
||||
$updateQuery = $sql->insert("ApiPermission", ["method", "groups", "description"])
|
||||
->onDuplicateKeyStrategy(new UpdateStrategy(["method"], [
|
||||
"groups" => new Column("groups"),
|
||||
"description" => new Column("description")
|
||||
]));
|
||||
|
||||
$insertedMethods = array();
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
if (!is_array($permission)) {
|
||||
return $this->createError("Invalid data type found in parameter: permissions, expected: object");
|
||||
} else if (!isset($permission["method"]) || !array_key_exists("groups", $permission)) {
|
||||
return $this->createError("Invalid object found in parameter: permissions, expected keys 'method' and 'groups'");
|
||||
} else if (!isset($permission["method"]) || !isset($permission["description"]) || !array_key_exists("groups", $permission)) {
|
||||
return $this->createError("Invalid object found in parameter: permissions, expected keys: 'method', 'groups', 'description'");
|
||||
} else if (!$methodParam->parseParam($permission["method"])) {
|
||||
$expectedType = $methodParam->getTypeName();
|
||||
return $this->createError("Invalid data type found for attribute 'method', expected: $expectedType");
|
||||
} else if (!$groupsParam->parseParam($permission["groups"])) {
|
||||
$expectedType = $groupsParam->getTypeName();
|
||||
return $this->createError("Invalid data type found for attribute 'groups', expected: $expectedType");
|
||||
} else if (!$descriptionParam->parseParam($permission["description"])) {
|
||||
$expectedType = $descriptionParam->getTypeName();
|
||||
return $this->createError("Invalid data type found for attribute 'description', expected: $expectedType");
|
||||
} else if (empty(trim($methodParam->value))) {
|
||||
return $this->createError("Method cannot be empty.");
|
||||
} else {
|
||||
$method = $methodParam->value;
|
||||
$groups = $groupsParam->value;
|
||||
$updateQuery->addRow($method, $groups);
|
||||
$description = $descriptionParam->value;
|
||||
$updateQuery->addRow($method, $groups, $description);
|
||||
$insertedMethods[] = $method;
|
||||
}
|
||||
}
|
||||
@@ -205,8 +215,11 @@ namespace Core\API\Permission {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN],
|
||||
"Allows users to modify API permissions. This is restricted to the administrator and cannot be changed");
|
||||
$insert->addRow(
|
||||
self::getEndpoint(), [Group::ADMIN],
|
||||
"Allows users to modify API permissions. This is restricted to the administrator and cannot be changed",
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch site routing");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch site routing", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to save the site routing");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to save the site routing", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to add new routes");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to add new routes", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to update existing routes");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to update existing routes", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to remove routes");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to remove routes", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to enable a route");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to enable a route", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to disable a route");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to disable a route", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace Core\API\Routes {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to regenerate the routing cache");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to regenerate the routing cache", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Core\API\Settings {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch site settings");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to fetch site settings", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Core\API\Settings {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to modify site settings");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to modify site settings", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,6 @@ class Stats extends Request {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to view site statistics");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to view site statistics", true);
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ namespace Core\API\User {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to create new users");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to create new users", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Core\API\User {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to fetch all users");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to fetch all users", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace Core\API\User {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to get details about a user");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to get details about a user", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ namespace Core\API\User {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to invite new users");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to invite new users", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -853,7 +853,7 @@ namespace Core\API\User {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to modify other user's details");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to modify other user's details", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ namespace Core\API\User {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to delete other users");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN], "Allows users to delete other users", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Core\API\Visitors {
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to view visitor statistics");
|
||||
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to view visitor statistics", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user