Skip to content
Snippets Groups Projects
Commit d0f93002 authored by Jared Hancock's avatar Jared Hancock
Browse files

upgrade: Properly set role_id for staff_dept_access

parent ed2412ca
No related branches found
No related tags found
No related merge requests found
......@@ -15,11 +15,16 @@ CREATE TABLE `%TABLE_PREFIX%staff_dept_access` (
KEY `dept_id` (`dept_id`)
) DEFAULT CHARSET=utf8;
-- Expand staff -> group -> dept_access to staff -> dept_access
-- At the same time, drop primary department from staff_dept_access
INSERT INTO `%TABLE_PREFIX%staff_dept_access`
(`staff_id`, `dept_id`, `role_id`)
SELECT A1.`staff_id`, A2.`dept_id`, A2.`role_id`
SELECT A1.`staff_id`, A2.`dept_id`,
CASE WHEN A2.`role_id` = 0 THEN A3.`role_id` ELSE A2.`role_id` END
FROM `%TABLE_PREFIX%staff` A1
JOIN `%TABLE_PREFIX%group_dept_access` A2 ON (A1.`group_id` = A2.`group_id`);
JOIN `%TABLE_PREFIX%group_dept_access` A2 ON (A1.`group_id` = A2.`group_id`)
JOIN `%TABLE_PREFIX%group` A3 ON (A3.`id` = A1.`group_id`)
WHERE A2.`dept_id` != A1.`dept_id`;
ALTER TABLE `%TABLE_PREFIX%staff`
DROP `group_id`,
......
-- drop old permissions from group table
ALTER TABLE `%TABLE_PREFIX%group`
DROP `group_enabled`,
DROP `can_create_tickets`,
DROP `can_edit_tickets`,
DROP `can_post_ticket_reply`,
DROP `can_delete_tickets`,
DROP `can_close_tickets`,
DROP `can_assign_tickets`,
DROP `can_transfer_tickets`,
DROP `can_ban_emails`,
DROP `can_manage_premade`,
DROP `can_manage_faq`,
DROP `can_view_staff_stats`;
-- drop useless updated column
ALTER TABLE `%TABLE_PREFIX%team_member` DROP `updated`;
......@@ -27,12 +27,7 @@ ALTER TABLE `%TABLE_PREFIX%staff`
ALTER TABLE `%TABLE_PREFIX%groups`
CHANGE `group_id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
CHANGE `group_name` `name` VARCHAR(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
ADD `role_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `id` ,
ADD `flags` INT UNSIGNED NOT NULL DEFAULT '1' AFTER `role_id`,
ADD INDEX (`role_id`);
RENAME TABLE `%TABLE_PREFIX%groups` TO `%TABLE_PREFIX%group`;
ADD `role_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `id`;
-- department changes
ALTER TABLE `%TABLE_PREFIX%department`
......
<?php
define('GROUP_TABLE', TABLE_PREFIX.'group');
define('GROUP_TABLE', TABLE_PREFIX.'groups');
define('GROUP_DEPT_TABLE', TABLE_PREFIX.'group_dept_access');
class Group extends VerySimpleModel {
static $meta = array(
'table' => GROUP_TABLE,
......@@ -8,7 +9,10 @@ class Group extends VerySimpleModel {
const FLAG_ENABLED = 0x0001;
function getName() {
return $this->name;
return $this->group_name;
}
function getId() {
return $this->id;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment