Skip to content

remove generic group / perms code #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 0 additions & 131 deletions resources/lib/UnityPerms.php

This file was deleted.

71 changes: 0 additions & 71 deletions resources/lib/UnitySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class UnitySQL
private const TABLE_AUDIT_LOG = "audit_log";
private const TABLE_ACCOUNT_DELETION_REQUESTS = "account_deletion_requests";
private const TABLE_SITEVARS = "sitevars";
private const TABLE_GROUP_ROLES = "groupRoles";
private const TABLE_GROUP_TYPES = "groupTypes";
private const TABLE_GROUP_ROLE_ASSIGNMENTS = "groupRoleAssignments";
private const TABLE_GROUP_REQUESTS = "groupRequests";
private const TABLE_GROUP_JOIN_REQUESTS = "groupJoinRequests";


private const REQUEST_ADMIN = "admin";
Expand Down Expand Up @@ -305,70 +300,4 @@ public function updateSiteVar($name, $value)

$stmt->execute();
}

public function getRole($uid, $group)
{
$stmt = $this->conn->prepare(
"SELECT * FROM " . self::TABLE_GROUP_ROLE_ASSIGNMENTS . " WHERE user=:uid AND `group`=:group"
);
$stmt->bindParam(":uid", $uid);
$stmt->bindParam(":group", $group);

$stmt->execute();

return $stmt->fetchAll()[0]['role'];
}

public function hasPerm($role, $perm)
{
$stmt = $this->conn->prepare(
"SELECT * FROM " . self::TABLE_GROUP_ROLES . " WHERE slug=:role"
);
$stmt->bindParam(":role", $role);

$stmt->execute();

$row = $stmt->fetchAll()[0];
$perms = explode(",", $row['perms']);
return in_array($perm, $perms);
}

public function getPriority($role)
{
$stmt = $this->conn->prepare(
"SELECT * FROM " . self::TABLE_GROUP_ROLES . " WHERE slug=:role"
);
$stmt->bindParam(":role", $role);

$stmt->execute();

$row = $stmt->fetchAll()[0];
return $row['priority'];
}

public function roleAvailableInGroup($uid, $group, $role)
{
$stmt = $this->conn->prepare(
"SELECT * FROM " . self::TABLE_GROUP_ROLE_ASSIGNMENTS . " WHERE user=:uid AND `group`=:group"
);
$stmt->bindParam(":uid", $uid);
$stmt->bindParam(":group", $group);

$stmt->execute();
$row = $stmt->fetchAll()[0];

$group_slug = $row['group'];

$stmt = $this->conn->prepare(
"SELECT * FROM " . self::TABLE_GROUP_TYPES . " WHERE slug=:slug"
);

$stmt->bindParam(":slug", $group_slug);
$stmt->execute();

$row = $stmt->fetchAll()[0];
$roles = explode(",", $row['roles']);

return in_array($role, $roles);
}
}
25 changes: 0 additions & 25 deletions resources/lib/UnityUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,29 +671,4 @@ public function hasRequestedAccountDeletion()
{
return $this->SQL->accDeletionRequestExists($this->getUID());
}

/**
* Checks whether a user is in a group or not
* @param string $uid uid of the user
* @param string or object $group group to check
* @return boolean true if user is in group, false if not
*/

public function isInGroup($uid, $group)
{
if (gettype($group) == "string") {
$group_checked = new UnityGroup(
$group,
$this->LDAP,
$this->SQL,
$this->MAILER,
$this->REDIS,
$this->WEBHOOK
);
} else {
$group_checked = $group;
}

return in_array($uid, $group_checked->getGroupMemberUIDs());
}
}
134 changes: 0 additions & 134 deletions tools/docker-dev/sql/bootstrap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,80 +65,6 @@ CREATE TABLE `events` (

-- --------------------------------------------------------

--
-- Table structure for table `groupJoinRequests`
--

CREATE TABLE `groupJoinRequests` (
`id` int(11) NOT NULL,
`group_name` varchar(768) NOT NULL,
`requestor` varchar(768) NOT NULL,
`requested_on` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `groupRequests`
--

CREATE TABLE `groupRequests` (
`id` int(11) NOT NULL,
`group_type` varchar(768) NOT NULL,
`group_name` varchar(768) NOT NULL,
`requestor` varchar(128) NOT NULL,
`requested_on` timestamp NOT NULL DEFAULT current_timestamp(),
`start_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`end_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `groupRoleAssignments`
--

CREATE TABLE `groupRoleAssignments` (
`id` int(11) NOT NULL,
`user` varchar(128) NOT NULL,
`role` varchar(768) NOT NULL,
`group` varchar(768) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `groupRoles`
--

CREATE TABLE `groupRoles` (
`id` int(11) NOT NULL,
`name` varchar(768) NOT NULL,
`slug` varchar(768) NOT NULL,
`priority` int(11) NOT NULL,
`color` varchar(768) NOT NULL,
`perms` varchar(768) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `groupTypes`
--

CREATE TABLE `groupTypes` (
`id` int(11) NOT NULL,
`name` varchar(768) NOT NULL,
`slug` varchar(768) NOT NULL,
`color` varchar(768) NOT NULL,
`time_limited` tinyint(1) NOT NULL,
`def_role` varchar(768) NOT NULL,
`av_roles` varchar(768) NOT NULL,
`can_request` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `notices`
--
Expand Down Expand Up @@ -240,36 +166,6 @@ ALTER TABLE `audit_log`
ALTER TABLE `events`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `groupJoinRequests`
--
ALTER TABLE `groupJoinRequests`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `groupRequests`
--
ALTER TABLE `groupRequests`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `groupRoleAssignments`
--
ALTER TABLE `groupRoleAssignments`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `groupRoles`
--
ALTER TABLE `groupRoles`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `groupTypes`
--
ALTER TABLE `groupTypes`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `notices`
--
Expand Down Expand Up @@ -322,36 +218,6 @@ ALTER TABLE `audit_log`
ALTER TABLE `events`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `groupJoinRequests`
--
ALTER TABLE `groupJoinRequests`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `groupRequests`
--
ALTER TABLE `groupRequests`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `groupRoleAssignments`
--
ALTER TABLE `groupRoleAssignments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `groupRoles`
--
ALTER TABLE `groupRoles`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `groupTypes`
--
ALTER TABLE `groupTypes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `notices`
--
Expand Down
Loading