Fixed table names in the Chandler editor (#772)

This commit is contained in:
n1rwana 2022-11-02 15:48:35 +03:00 committed by GitHub
parent f5b1890645
commit e8c0fe8c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 20 deletions

View file

@ -13,9 +13,9 @@ class ChandlerGroups
public function __construct() public function __construct()
{ {
$this->context = DB::i()->getContext(); $this->context = DB::i()->getContext();
$this->groups = $this->context->table("chandlergroups"); $this->groups = $this->context->table("ChandlerGroups");
$this->members = $this->context->table("chandleraclrelations"); $this->members = $this->context->table("ChandlerACLRelations");
$this->perms = $this->context->table("chandleraclgroupspermissions"); $this->perms = $this->context->table("ChandlerACLGroupsPermissions");
} }
function get(string $UUID): ?ActiveRow function get(string $UUID): ?ActiveRow
@ -32,7 +32,7 @@ class ChandlerGroups
{ {
foreach($this->members->where("group", $UUID) as $member) foreach($this->members->where("group", $UUID) as $member)
yield (new Users)->getByChandlerUser( yield (new Users)->getByChandlerUser(
new ChandlerUser($this->context->table("chandlerusers")->where("id", $member->user)->fetch()) new ChandlerUser($this->context->table("ChandlerUsers")->where("id", $member->user)->fetch())
); );
} }

View file

@ -13,7 +13,7 @@ class ChandlerUsers
public function __construct() public function __construct()
{ {
$this->context = DB::i()->getContext(); $this->context = DB::i()->getContext();
$this->users = $this->context->table("chandlerusers"); $this->users = $this->context->table("ChandlerUsers");
} }
private function toUser(?ActiveRow $ar): ?ChandlerUser private function toUser(?ActiveRow $ar): ?ChandlerUser

View file

@ -83,7 +83,7 @@ final class AdminPresenter extends OpenVKPresenter
if($user->onlineStatus() != $this->postParam("online")) $user->setOnline(intval($this->postParam("online"))); if($user->onlineStatus() != $this->postParam("online")) $user->setOnline(intval($this->postParam("online")));
$user->setVerified(empty($this->postParam("verify") ? 0 : 1)); $user->setVerified(empty($this->postParam("verify") ? 0 : 1));
if($this->postParam("add-to-group")) { if($this->postParam("add-to-group")) {
$query = "INSERT INTO `chandleraclrelations` (`user`, `group`) VALUES ('" . $user->getChandlerGUID() . "', '" . $this->postParam("add-to-group") . "')"; $query = "INSERT INTO `ChandlerACLRelations` (`user`, `group`) VALUES ('" . $user->getChandlerGUID() . "', '" . $this->postParam("add-to-group") . "')";
DatabaseConnection::i()->getConnection()->query($query); DatabaseConnection::i()->getConnection()->query($query);
} }
@ -464,7 +464,7 @@ final class AdminPresenter extends OpenVKPresenter
if($_SERVER["REQUEST_METHOD"] !== "POST") if($_SERVER["REQUEST_METHOD"] !== "POST")
return; return;
$req = "INSERT INTO `chandlergroups` (`name`) VALUES ('" . $this->postParam("name") . "')"; $req = "INSERT INTO `ChandlerGroups` (`name`) VALUES ('" . $this->postParam("name") . "')";
DatabaseConnection::i()->getConnection()->query($req); DatabaseConnection::i()->getConnection()->query($req);
} }
@ -472,7 +472,7 @@ final class AdminPresenter extends OpenVKPresenter
{ {
$DB = DatabaseConnection::i()->getConnection(); $DB = DatabaseConnection::i()->getConnection();
if(is_null($DB->query("SELECT * FROM `chandlergroups` WHERE `id` = '$UUID'")->fetch())) if(is_null($DB->query("SELECT * FROM `ChandlerGroups` WHERE `id` = '$UUID'")->fetch()))
$this->flashFail("err", tr("error"), tr("c_group_not_found")); $this->flashFail("err", tr("error"), tr("c_group_not_found"));
$this->template->group = (new ChandlerGroups)->get($UUID); $this->template->group = (new ChandlerGroups)->get($UUID);
@ -492,23 +492,23 @@ final class AdminPresenter extends OpenVKPresenter
if($this->template->mode == "removeMember") { if($this->template->mode == "removeMember") {
$where = "`user` = '" . $this->queryParam("uid") . "' AND `group` = '$UUID'"; $where = "`user` = '" . $this->queryParam("uid") . "' AND `group` = '$UUID'";
if(is_null($DB->query("SELECT * FROM `chandleraclrelations` WHERE " . $where)->fetch())) if(is_null($DB->query("SELECT * FROM `ChandlerACLRelations` WHERE " . $where)->fetch()))
$this->flashFail("err", tr("error"), tr("c_user_is_not_in_group")); $this->flashFail("err", tr("error"), tr("c_user_is_not_in_group"));
$DB->query("DELETE FROM `chandleraclrelations` WHERE " . $where); $DB->query("DELETE FROM `ChandlerACLRelations` WHERE " . $where);
$this->flashFail("succ", tr("changes_saved"), tr("c_user_removed_from_group")); $this->flashFail("succ", tr("changes_saved"), tr("c_user_removed_from_group"));
} elseif($this->template->mode == "removePermission") { } elseif($this->template->mode == "removePermission") {
$where = "`model` = '" . trim(addslashes($this->queryParam("model"))) . "' AND `permission` = '". $this->queryParam("perm") ."' AND `group` = '$UUID'"; $where = "`model` = '" . trim(addslashes($this->queryParam("model"))) . "' AND `permission` = '". $this->queryParam("perm") ."' AND `group` = '$UUID'";
if(is_null($DB->query("SELECT * FROM `chandleraclgroupspermissions WHERE $where`"))) if(is_null($DB->query("SELECT * FROM `ChandlerACLGroupsPermissions WHERE $where`")))
$this->flashFail("err", tr("error"), tr("c_permission_not_found")); $this->flashFail("err", tr("error"), tr("c_permission_not_found"));
$DB->query("DELETE FROM `chandleraclgroupspermissions` WHERE $where"); $DB->query("DELETE FROM `ChandlerACLGroupsPermissions` WHERE $where");
$this->flashFail("succ", tr("changes_saved"), tr("c_permission_removed_from_group")); $this->flashFail("succ", tr("changes_saved"), tr("c_permission_removed_from_group"));
} elseif($this->template->mode == "delete") { } elseif($this->template->mode == "delete") {
$DB->query("DELETE FROM `chandlergroups` WHERE `id` = '$UUID'"); $DB->query("DELETE FROM `ChandlerGroups` WHERE `id` = '$UUID'");
$DB->query("DELETE FROM `chandleraclgroupspermissions` WHERE `group` = '$UUID'"); $DB->query("DELETE FROM `ChandlerACLGroupsPermissions` WHERE `group` = '$UUID'");
$DB->query("DELETE FROM `chandleraclrelations` WHERE `group` = '$UUID'"); $DB->query("DELETE FROM `ChandlerACLRelations` WHERE `group` = '$UUID'");
$this->flashFail("succ", tr("changes_saved"), tr("c_group_removed")); $this->flashFail("succ", tr("changes_saved"), tr("c_group_removed"));
} }
@ -519,19 +519,19 @@ final class AdminPresenter extends OpenVKPresenter
if($this->template->mode == "main") if($this->template->mode == "main")
if($this->postParam("delete")) if($this->postParam("delete"))
$req = "DELETE FROM `chandlergroups` WHERE `id`='$UUID'"; $req = "DELETE FROM `ChandlerGroups` WHERE `id`='$UUID'";
else else
$req = "UPDATE `chandlergroups` SET `name`='". $this->postParam('name') ."' , `color`='". $this->postParam("color") ."' WHERE `id`='$UUID'"; $req = "UPDATE `ChandlerGroups` SET `name`='". $this->postParam('name') ."' , `color`='". $this->postParam("color") ."' WHERE `id`='$UUID'";
if($this->template->mode == "members") if($this->template->mode == "members")
if($this->postParam("uid")) if($this->postParam("uid"))
if(!is_null($DB->query("SELECT * FROM `chandleraclrelations` WHERE `user` = '" . $this->postParam("uid") . "'"))) if(!is_null($DB->query("SELECT * FROM `ChandlerACLRelations` WHERE `user` = '" . $this->postParam("uid") . "'")))
$this->flashFail("err", tr("error"), tr("c_user_is_already_in_group")); $this->flashFail("err", tr("error"), tr("c_user_is_already_in_group"));
$req = "INSERT INTO `chandleraclrelations` (`user`, `group`, `priority`) VALUES ('". $this->postParam("uid") ."', '$UUID', 32)"; $req = "INSERT INTO `ChandlerACLRelations` (`user`, `group`, `priority`) VALUES ('". $this->postParam("uid") ."', '$UUID', 32)";
if($this->template->mode == "permissions") if($this->template->mode == "permissions")
$req = "INSERT INTO `chandleraclgroupspermissions` (`group`, `model`, `permission`, `context`) VALUES ('$UUID', '". trim(addslashes($this->postParam("model"))) ."', '". $this->postParam("permission") ."', 0)"; $req = "INSERT INTO `ChandlerACLGroupsPermissions` (`group`, `model`, `permission`, `context`) VALUES ('$UUID', '". trim(addslashes($this->postParam("model"))) ."', '". $this->postParam("permission") ."', 0)";
$DB->query($req); $DB->query($req);
$this->flashFail("succ", tr("changes_saved")); $this->flashFail("succ", tr("changes_saved"));