diff --git a/include/class.list.php b/include/class.list.php index 479b4b8b7b0f0d76a9aaff884593397e9ff43f5d..e10209df37dc396a80ba31433db773ec485062c8 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -488,6 +488,10 @@ class DynamicListItem extends VerySimpleModel implements CustomListItem { return true; } + function isDisableable() { + return !$this->isInternal(); + } + function isDeletable() { return !$this->isInternal(); } @@ -652,8 +656,15 @@ class TicketStatusList extends CustomListHandler { return TicketStatus::objects()->count(); } - function getAllItems() { - return TicketStatus::objects()->order_by($this->getListOrderBy()); + function getAllItems($states=array()) { + if ($states) + $items = TicketStatus::objects()->filter( + array('state__in' => $states)) + ->order_by($this->getListOrderBy()); + else + $items = TicketStatus::objects()->order_by($this->getListOrderBy()); + + return $items; } function getItems($criteria) { @@ -693,6 +704,16 @@ class TicketStatusList extends CustomListHandler { return $item; } + static function getAll($states=array()) { + + $statuses = array(); + if (($list = DynamicList::lookup( + array('type' => 'ticket-status')))) + $statuses = $list->getAllItems($states); + + return $statuses; + } + static function __load() { require_once(INCLUDE_DIR.'class.i18n.php'); @@ -787,15 +808,28 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { function disable() { return (!$this->isInternal() + && !$this->isDefault() && $this->clearFlag('mode', self::ENABLED)); } + function isDefault() { + global $cfg; + + return ($cfg + && $cfg->getDefaultTicketStatusId() == $this->getId()); + } + function isEnableable() { return $this->hasProperties(); } + function isDisableable() { + return !($this->isInternal() || $this->isDefault()); + } + function isDeletable() { - return !$this->isInternal(); + + return !($this->isInternal() || $this->isDefault()); } function isInternal() { @@ -810,6 +844,10 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { return $this->get('name'); } + function getState() { + return $this->get('state'); + } + function getValue() { return $this->getName(); } diff --git a/include/i18n/en_US/ticket_status.yaml b/include/i18n/en_US/ticket_status.yaml index 3c41d326f8a5e4aa8151f62f1dc89a2ae806bcb6..9a5f4d3b229e3949a656d62dbe1263d96b3a3ecb 100644 --- a/include/i18n/en_US/ticket_status.yaml +++ b/include/i18n/en_US/ticket_status.yaml @@ -24,7 +24,7 @@ - id: 2 name: Resolved - state: closed + state: resolved mode: 3 sort: 2 flags: 0 diff --git a/include/staff/dynamic-list.inc.php b/include/staff/dynamic-list.inc.php index f67e5d8ea9c2d3a92861aca0d309b8d4a31354c2..248018ee26639bc6874ec6781de306e683e87f66 100644 --- a/include/staff/dynamic-list.inc.php +++ b/include/staff/dynamic-list.inc.php @@ -279,7 +279,7 @@ $info=Format::htmlchars(($errors && $_POST) ? array_merge($info,$_POST) : $info) } ?> <td> <?php - if ($i->isInternal()) + if (!$i->isDisableable()) echo '<i class="icon-ban-circle"></i>'; else echo sprintf('<input type="checkbox" name="disable-%s" diff --git a/include/upgrader/streams/core/8f99b8bf-cbf8c933.patch.sql b/include/upgrader/streams/core/8f99b8bf-00000000.patch.sql similarity index 100% rename from include/upgrader/streams/core/8f99b8bf-cbf8c933.patch.sql rename to include/upgrader/streams/core/8f99b8bf-00000000.patch.sql