diff --git a/assets/default/css/theme.css b/assets/default/css/theme.css index 97703547a176d6d917ed56dac636fc5d67feca49..f3b1290f8b37598070791de2f7dc3fd4c42d548d 100644 --- a/assets/default/css/theme.css +++ b/assets/default/css/theme.css @@ -414,7 +414,7 @@ body { .front-page-button { } .main-content { - width: 560px; + width: 565px; } #landing_page #new_ticket { margin-top: 40px; diff --git a/include/class.dept.php b/include/class.dept.php index 8343d6f6690c9917a8fbe8f4e145d7a5f08e03bd..4e42d9335fca4fe40f339266012c8f400868100e 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -159,6 +159,7 @@ implements TemplateVariable { if (!$this->_members || $criteria) { $members = Staff::objects() + ->distinct('staff_id') ->filter(Q::any(array( 'dept_id' => $this->getId(), new Q(array( diff --git a/include/class.orm.php b/include/class.orm.php index 818d33be9e8fbe474a588ec0b1660678a816a4e7..8c149318a3e82920f4a14d1cfe5fe929422def22 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -47,10 +47,10 @@ class ModelMeta implements ArrayAccess { if (!$meta['table']) throw new OrmConfigurationException( - __('Model does not define meta.table'), $model); + sprintf(__('%s: Model does not define meta.table'), $model)); elseif (!$meta['pk']) throw new OrmConfigurationException( - __('Model does not define meta.pk'), $model); + sprintf(__('%s: Model does not define meta.pk'), $model)); // Ensure other supported fields are set and are arrays foreach (array('pk', 'ordering', 'defer') as $f) { @@ -185,10 +185,17 @@ class VerySimpleModel { $j = static::$meta['joins'][$field]; // Support instrumented lists and such if (isset($j['list']) && $j['list']) { - $fkey = $j['fkey']; + $class = $j['fkey'][0]; + $fkey = array(); + // Localize the foreign key constraint + foreach ($j['constraint'] as $local=>$foreign) { + list($_klas,$F) = $foreign; + $fkey[$F ?: $_klas] = ($local[0] == "'") + ? trim($local, "'") : $this->ht[$local]; + } $v = $this->ht[$field] = new InstrumentedList( - // Send Model, Foriegn-Field, Local-Id - array($fkey[0], $fkey[1], $this->get($j['local'])) + // Send Model, [Foriegn-Field => Local-Id] + array($class, $fkey) ); return $v; } @@ -1362,24 +1369,22 @@ class HashArrayIterator extends ResultSet { class InstrumentedList extends ModelInstanceManager { var $key; - var $id; var $model; function __construct($fkey, $queryset=false) { - list($model, $this->key, $this->id) = $fkey; + list($model, $this->key) = $fkey; if (!$queryset) - $queryset = $model::objects()->filter(array($this->key=>$this->id)); + $queryset = $model::objects()->filter($this->key); parent::__construct($queryset); $this->model = $model; - if (!$this->id) - $this->resource = null; } function add($object, $at=false) { if (!$object || !$object instanceof $this->model) throw new Exception(__('Attempting to add invalid object to list')); - $object->set($this->key, $this->id); + foreach ($this->key as $field=>$value) + $object->set($field, $value); if (!$object->__new__) $object->save(); @@ -1388,6 +1393,8 @@ class InstrumentedList extends ModelInstanceManager { $this->cache[$at] = $object; else $this->cache[] = $object; + + return $object; } function remove($object, $delete=true) { if ($delete)