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

Retire %task.sla_id, %team.isenabled, %team.noalerts

parent 387540fa
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,9 @@ implements TemplateVariable {
),
);
const FLAG_ENABLED = 0x0001;
const FLAG_NOALERTS = 0x0002;
var $_members;
function asVar() {
......@@ -101,6 +104,8 @@ implements TemplateVariable {
function getHashtable() {
$base = $this->ht;
$base['isenabled'] = $this->isEnabled();
$base['noalerts'] = !$this->alertsEnabled();
unset($base['staffmembers']);
return $base;
}
......@@ -110,7 +115,7 @@ implements TemplateVariable {
}
function isEnabled() {
return $this->isenabled;
return $this->flags & self::FLAG_ENABLED;
}
function isActive() {
......@@ -118,7 +123,7 @@ implements TemplateVariable {
}
function alertsEnabled() {
return !$this->noalerts;
return ($this->flags & self::FLAG_NOALERTS) == 0;
}
function getTranslateTag($subtag) {
......@@ -153,8 +158,9 @@ implements TemplateVariable {
&& in_array($this->lead_id, $vars['remove']))
$vars['lead_id'] =0 ;
$this->isenabled = $vars['isenabled'];
$this->noalerts = isset($vars['noalerts']) ? $vars['noalerts'] : 0;
$this->flags =
($vars['isenabled'] ? self::FLAG_ENABLED : 0)
| (isset($vars['noalerts']) ? self::FLAG_NOALERTS : 0);
$this->lead_id = $vars['lead_id'] ?: 0;
$this->name = $vars['name'];
$this->notes = Format::sanitize($vars['notes']);
......@@ -225,13 +231,13 @@ implements TemplateVariable {
if (!$teams || $criteria) {
$teams = array();
$query = static::objects()
->values_flat('team_id', 'name', 'isenabled')
->values_flat('team_id', 'name', 'flags')
->order_by('name');
if (isset($criteria['active']) && $criteria['active']) {
$query->annotate(array('members_count'=>SqlAggregate::COUNT('members')))
->filter(array(
'isenabled'=>1,
'flags__hasbit'=>self::FLAG_ENABLED,
'members__staff__isactive'=>1,
'members__staff__onvacation'=>0,
'members__staff__group__flags__hasbit'=>Group::FLAG_ENABLED,
......@@ -242,7 +248,8 @@ implements TemplateVariable {
$items = array();
foreach ($query as $row) {
//TODO: Fix enabled - flags is a bit field.
list($id, $name, $enabled) = $row;
list($id, $name, $flags) = $row;
$enabled = $flags & self::FLAG_ENABLED;
$items[$id] = sprintf('%s%s',
self::getLocalById($id, 'name', $name),
($enabled || isset($criteria['active']))
......
......@@ -26,3 +26,21 @@ SET @s = (SELECT IF(
));
PREPARE stmt FROM @s;
EXECUTE stmt;
-- DROP IF EXISTS `%task.sla_id`
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '%TABLE_PREFIX%task'
AND table_schema = DATABASE()
AND column_name = 'sla_id'
) > 0,
"SELECT 1",
"ALTER TABLE `%TABLE_PREFIX%task` DROP `sla_id`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
ALTER TABLE `%TABLE_PREFIX%team`
DROP `isenabled`,
DROP `noalerts`;
......@@ -47,6 +47,13 @@ ALTER TABLE `%TABLE_PREFIX%form`
UPDATE `%TABLE_PREFIX%form`
SET `flags` = 0 WHERE `type` IN ('T','U','C','O','A');
ALTER TABLE `%TABLE_PREFIX%team`
ADD `flags` int(10) unsigned NOTN ULL default 1 AFTER `lead_id`;
UPDATE `%TABLE_PREFIX%team`
SET `flags` = CASE WHEN `isenabled` THEN 1 ELSE 0 END
+ CASE WHEN `noalerts` THEN 2 ELSE 0 END;
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
SET `value` = '00000000000000000000000000000000'
......
......@@ -590,8 +590,7 @@ DROP TABLE IF EXISTS `%TABLE_PREFIX%team`;
CREATE TABLE `%TABLE_PREFIX%team` (
`team_id` int(10) unsigned NOT NULL auto_increment,
`lead_id` int(10) unsigned NOT NULL default '0',
`isenabled` tinyint(1) unsigned NOT NULL default '1',
`noalerts` tinyint(1) unsigned NOT NULL default '0',
`flags` int(10) unsigned NOTN ULL default 1,
`name` varchar(125) NOT NULL default '',
`notes` text,
`created` datetime NOT NULL,
......@@ -781,7 +780,6 @@ CREATE TABLE `%TABLE_PREFIX%task` (
`object_type` char(1) NOT NULL,
`number` varchar(20) DEFAULT NULL,
`dept_id` int(10) unsigned NOT NULL DEFAULT '0',
`sla_id` int(10) unsigned NOT NULL DEFAULT '0',
`staff_id` int(10) unsigned NOT NULL DEFAULT '0',
`team_id` int(10) unsigned NOT NULL DEFAULT '0',
`lock_id` int(11) unsigned NOT NULL DEFAULT '0',
......
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