diff --git a/include/class.orm.php b/include/class.orm.php index 6b343982c5cb114e186502497a4d5fcb5e5dc648..e22b09e72fa655a84e96662ec07feb5a062edbd8 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -901,7 +901,7 @@ class SqlExpr extends SqlFunction { $O = array(); foreach ($this->args as $field=>$value) { if ($value instanceof Q) { - $ex = $compiler->compileQ($value, $model); + $ex = $compiler->compileQ($value, $model, false); $O[] = $ex->text; } else { @@ -923,13 +923,11 @@ class SqlExpression extends SqlFunction { function toSql($compiler, $model=false, $alias=false) { $O = array(); foreach ($this->args as $operand) { - if ($operand instanceof SqlFunction) - $O[] = $operand->toSql($compiler, $model); - else - $O[] = $compiler->input($operand); + $O[] = $this->input($operand, $compiler, $model); } - return implode(' '.$this->func.' ', $O) - . ($alias ? ' AS '.$compiler->quote($alias) : ''); + return '('.implode(' '.$this->func.' ', $O) + . ($alias ? ' AS '.$compiler->quote($alias) : '') + . ')'; } static function __callStatic($operator, $operands) { @@ -952,7 +950,7 @@ class SqlExpression extends SqlFunction { function __call($operator, $operands) { array_unshift($operands, $this); - return static::__callStatic($operator, $operands); + return SqlExpression::__callStatic($operator, $operands); } } @@ -979,7 +977,7 @@ class SqlInterval extends SqlFunction { } } -class SqlField extends SqlFunction { +class SqlField extends SqlExpression { var $level; function __construct($field, $level=0) { @@ -2477,7 +2475,10 @@ class SqlCompiler { $constraints = array(); $prev = $parens = false; foreach ($where as $Q) { - $parens = $parens || !($prev && $prev->isCompatibleWith($Q)); + if ($prev && !$prev->isCompatibleWith($Q)) { + $parens = true; + break; + } $prev = $Q; } foreach ($where as $Q) { diff --git a/include/class.queue.php b/include/class.queue.php index 7fc7df986805a774e6a25821cb23090d70f039f9..0acca703c642a6ce689dd9ada06b3e8ef6db54d2 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -43,12 +43,10 @@ class CustomQueue extends SavedSearch { ) { return $this->parent->getColumns(); } - - if (!count($this->columns)) { - foreach (parent::getColumns() as $c) - $this->addColumn($c); + elseif (count($this->columns)) { + return $this->columns; } - return $this->columns; + return parent::getColumns(); } function addColumn(QueueColumn $col) { @@ -956,16 +954,6 @@ extends VerySimpleModel { return $this->_conditions; } - /** - * Create a CustomQueueColumn from vars (_POST) received from an - * update request. - */ - static function create($vars=array()) { - $inst = parent::create($vars); - // TODO: Convert annotations and conditions - return $inst; - } - static function __create($vars) { $c = static::create($vars); $c->save(); diff --git a/include/class.search.php b/include/class.search.php index 7fd631ffe9fa3d7a74ddf4dd268497778c761283..59fff7df7ade48a0d0b1d6eb7dda052a3c05e445 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -1070,28 +1070,22 @@ class SavedSearch extends VerySimpleModel { return $this->parent->getColumns(); } - if (isset($this->columns)) - return $this->columns; - // Last resort — use standard columns - $this->columns = array( + return array( QueueColumn::create(array( - "id" => 1, "heading" => "Number", "primary" => 'number', - "width" => 100, + "width" => 85, "filter" => "link:ticketP", "annotations" => '[{"c":"TicketSourceDecoration","p":"b"}]', "conditions" => '[{"crit":["isanswered","set",null],"prop":{"font-weight":"bold"}}]', )), QueueColumn::create(array( - "id" => 2, "heading" => "Created", "primary" => 'created', "width" => 100, )), QueueColumn::create(array( - "id" => 3, "heading" => "Subject", "primary" => 'cdata__subject', "width" => 250, @@ -1100,30 +1094,21 @@ class SavedSearch extends VerySimpleModel { "truncate" => 'ellipsis', )), QueueColumn::create(array( - "id" => 4, "heading" => "From", "primary" => 'user__name', "width" => 150, )), QueueColumn::create(array( - "id" => 5, "heading" => "Priority", "primary" => 'cdata__priority', "width" => 120, )), QueueColumn::create(array( - "id" => 6, "heading" => "Assignee", "primary" => 'assignee', - "secondary" => 'team__name', "width" => 100, )), ); - - foreach ($this->columns as $c) - $c->queue = $this; - - return $this->columns; } /** diff --git a/include/staff/templates/queue-tickets.tmpl.php b/include/staff/templates/queue-tickets.tmpl.php index 80e3f51dd47f455555f8ad0459aa07c64cc3502c..dff0083d79af0fe0667c8e808f7f8e088ec51403 100644 --- a/include/staff/templates/queue-tickets.tmpl.php +++ b/include/staff/templates/queue-tickets.tmpl.php @@ -160,7 +160,7 @@ foreach ($columns as $C) { $C->getWidth(), $C->id, $heading); // Sort by this column ? - if ($sort['col'] == $C->id) { + if (isset($sort['col']) && $sort['col'] == $C->id) { $col = SavedSearch::getOrmPath($C->primary, $query); if ($sort['dir']) $col = '-' . $col;