diff --git a/include/class.queue.php b/include/class.queue.php index 510b4c466f578fbaaa343dcd597f65601ac34827..c17e8e91e3851369e3e889910b4c6b50d5d194f7 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -19,6 +19,7 @@ require_once INCLUDE_DIR . 'class.search.php'; class CustomQueue extends SavedSearch { static $meta = array( 'select_related' => array('parent'), + 'ordering' => array('title', 'path'), 'joins' => array( 'columns' => array( 'reverse' => 'QueueColumn.queue', @@ -143,6 +144,28 @@ class CustomQueue extends SavedSearch { )); } + function getPath() { + return $this->path ?: $this->buildPath(); + } + + function buildPath() { + if (!$this->id) + return; + + $path = $this->id; + if ($this->parent) { + $path = sprintf('%s/%d', $this->parent->getPath(), $path); + } + return $path; + } + + function getFullName() { + $base = $this->getName(); + if ($this->parent) + $base = sprintf("%s / %s", $this->parent->getFullName(), $base); + return $base; + } + function getHref() { // TODO: Get base page from getRoot(); $root = $this->getRoot(); @@ -225,6 +248,7 @@ class CustomQueue extends SavedSearch { $this->title = $vars['name']; $this->parent_id = $vars['parent_id']; $this->filter = $vars['filter']; + $this->path = $this->buildPath(); $this->setFlag(self::FLAG_INHERIT_CRITERIA, isset($vars['inherit'])); // Update queue columns (but without save) @@ -246,9 +270,14 @@ class CustomQueue extends SavedSearch { } function save($refetch=false) { + $wasnew = !isset($this->id); if (!($rv = parent::save($refetch))) return $rv; + if ($wasnew) { + $this->path = $this->buildPath(); + $this->save(); + } return $this->columns->saveAll(); } diff --git a/include/staff/queues-ticket.inc.php b/include/staff/queues-ticket.inc.php index 620ae915897a20a35f690179942bbbb06ee283c2..c4b43397a1c8c39f831e60a1443b78981d6a6977 100644 --- a/include/staff/queues-ticket.inc.php +++ b/include/staff/queues-ticket.inc.php @@ -53,7 +53,7 @@ require_once INCLUDE_DIR . 'class.queue.php'; <tr> <td><input type="checkbox" class="checkbox" name="ckb[]"></td> <td><a href="queues.php?id=<?php echo $q->getId(); ?>"><?php - echo Format::htmlchars($q->getName()); ?></a></td> + echo Format::htmlchars($q->getFullName()); ?></a></td> <td><?php echo Format::htmlchars($q->staff->getName()); ?></td> <td><?php echo Format::htmlchars($q->getStatus()); ?></td> <td><?php echo Format::date($q->created); ?></td>