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

Retire config[key=assign_members_only] for depts

parent 040e11be
Branches
Tags
No related merge requests found
...@@ -62,11 +62,7 @@ implements TemplateVariable { ...@@ -62,11 +62,7 @@ implements TemplateVariable {
const ALERTS_DEPT_AND_GROUPS = 1; const ALERTS_DEPT_AND_GROUPS = 1;
const ALERTS_DEPT_ONLY = 0; const ALERTS_DEPT_ONLY = 0;
function getConfig() { const FLAG_ASSIGN_MEMBERS_ONLY = 0x0001;
if (!isset($this->config))
$this->config = new Config('dept.'. $this->getId());
return $this->config;
}
function asVar() { function asVar() {
return $this->getName(); return $this->getName();
...@@ -301,7 +297,7 @@ implements TemplateVariable { ...@@ -301,7 +297,7 @@ implements TemplateVariable {
} }
function assignMembersOnly() { function assignMembersOnly() {
return $this->getConfig()->get('assign_members_only', 0); return $this->flags & self::FLAG_ASSIGN_MEMBERS_ONLY;
} }
function isGroupMembershipEnabled() { function isGroupMembershipEnabled() {
...@@ -314,11 +310,12 @@ implements TemplateVariable { ...@@ -314,11 +310,12 @@ implements TemplateVariable {
foreach (static::$meta['joins'] as $k => $v) foreach (static::$meta['joins'] as $k => $v)
unset($ht[$k]); unset($ht[$k]);
$ht['assign_members_only'] = $this->flags & self::FLAG_ASSIGN_MEMBERS_ONLY;
return $ht; return $ht;
} }
function getInfo() { function getInfo() {
return $this->getConfig()->getInfo() + $this->getHashtable(); return $this->getHashtable();
} }
function getAllowedGroups() { function getAllowedGroups() {
...@@ -368,7 +365,6 @@ implements TemplateVariable { ...@@ -368,7 +365,6 @@ implements TemplateVariable {
function updateSettings($vars) { function updateSettings($vars) {
$this->updateGroups($vars['groups'] ?: array(), $vars); $this->updateGroups($vars['groups'] ?: array(), $vars);
$this->getConfig()->set('assign_members_only', $vars['assign_members_only']);
$this->path = $this->getFullPath(); $this->path = $this->getFullPath();
$this->save(); $this->save();
return true; return true;
...@@ -386,10 +382,8 @@ implements TemplateVariable { ...@@ -386,10 +382,8 @@ implements TemplateVariable {
return 0; return 0;
} }
parent::delete();
$id = $this->getId(); $id = $this->getId();
$sql='DELETE FROM '.DEPT_TABLE.' WHERE id='.db_input($id).' LIMIT 1'; if (parent::delete()) {
if(db_query($sql) && ($num=db_affected_rows())) {
// DO SOME HOUSE CLEANING // DO SOME HOUSE CLEANING
//Move tickets to default Dept. TODO: Move one ticket at a time and send alerts + log notes. //Move tickets to default Dept. TODO: Move one ticket at a time and send alerts + log notes.
db_query('UPDATE '.TICKET_TABLE.' SET dept_id='.db_input($cfg->getDefaultDeptId()).' WHERE dept_id='.db_input($id)); db_query('UPDATE '.TICKET_TABLE.' SET dept_id='.db_input($cfg->getDefaultDeptId()).' WHERE dept_id='.db_input($id));
...@@ -403,9 +397,6 @@ implements TemplateVariable { ...@@ -403,9 +397,6 @@ implements TemplateVariable {
//Delete group access //Delete group access
db_query('DELETE FROM '.GROUP_DEPT_TABLE.' WHERE dept_id='.db_input($id)); db_query('DELETE FROM '.GROUP_DEPT_TABLE.' WHERE dept_id='.db_input($id));
// Destrory config settings
$this->getConfig()->destroy();
} }
return $num; return $num;
...@@ -602,6 +593,7 @@ implements TemplateVariable { ...@@ -602,6 +593,7 @@ implements TemplateVariable {
$this->group_membership = $vars['group_membership']; $this->group_membership = $vars['group_membership'];
$this->ticket_auto_response = isset($vars['ticket_auto_response'])?$vars['ticket_auto_response']:1; $this->ticket_auto_response = isset($vars['ticket_auto_response'])?$vars['ticket_auto_response']:1;
$this->message_auto_response = isset($vars['message_auto_response'])?$vars['message_auto_response']:1; $this->message_auto_response = isset($vars['message_auto_response'])?$vars['message_auto_response']:1;
$this->flags = isset($vars['assign_members_only']) ? self::FLAG_ASSIGN_MEMBERS_ONLY : 0;
if ($this->save()) if ($this->save())
return $this->updateSettings($vars); return $this->updateSettings($vars);
......
...@@ -44,3 +44,6 @@ EXECUTE stmt; ...@@ -44,3 +44,6 @@ EXECUTE stmt;
ALTER TABLE `%TABLE_PREFIX%team` ALTER TABLE `%TABLE_PREFIX%team`
DROP `isenabled`, DROP `isenabled`,
DROP `noalerts`; DROP `noalerts`;
DELETE FROM `%TABLE_PREFIX%config`
WHERE `key`='assign_members_only' AND `namespace` LIKE 'dept.%';
...@@ -54,6 +54,15 @@ UPDATE `%TABLE_PREFIX%team` ...@@ -54,6 +54,15 @@ UPDATE `%TABLE_PREFIX%team`
SET `flags` = CASE WHEN `isenabled` THEN 1 ELSE 0 END SET `flags` = CASE WHEN `isenabled` THEN 1 ELSE 0 END
+ CASE WHEN `noalerts` THEN 2 ELSE 0 END; + CASE WHEN `noalerts` THEN 2 ELSE 0 END;
-- Migrate %config[namespace=dept.x, key=alert_members_only]
ALTER TABLE `%TABLE_PREFIX%department`
ADD `flags` int(10) unsigned NOT NULL default 0 AFTER `manager_id`;
UPDATE `%TABLE_PREFIX%department` A1
JOIN (SELECT `value` FROM `%TABLE_PREFIX%config`) `config`
ON (`config`.`namespace` = CONCAT('dept.', A1.`id`) AND `config`.`key` = 'assign_members_only')
SET A1.`flags` = 1 WHERE `config`.`value` != '';
-- Finished with patch -- Finished with patch
UPDATE `%TABLE_PREFIX%config` UPDATE `%TABLE_PREFIX%config`
SET `value` = '00000000000000000000000000000000' SET `value` = '00000000000000000000000000000000'
......
...@@ -206,6 +206,7 @@ CREATE TABLE `%TABLE_PREFIX%department` ( ...@@ -206,6 +206,7 @@ CREATE TABLE `%TABLE_PREFIX%department` (
`email_id` int(10) unsigned NOT NULL default '0', `email_id` int(10) unsigned NOT NULL default '0',
`autoresp_email_id` int(10) unsigned NOT NULL default '0', `autoresp_email_id` int(10) unsigned NOT NULL default '0',
`manager_id` int(10) unsigned NOT NULL default '0', `manager_id` int(10) unsigned NOT NULL default '0',
`flags` int(10) unsigned NOT NULL default 0,
`name` varchar(128) NOT NULL default '', `name` varchar(128) NOT NULL default '',
`signature` text NOT NULL, `signature` text NOT NULL,
`ispublic` tinyint(1) unsigned NOT NULL default '1', `ispublic` tinyint(1) unsigned NOT NULL default '1',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment