Author: sevein
Date: Thu Aug 9 11:03:25 2012
New Revision: 12058
Log:
Reuse getTreeViewSiblings to get descendants, return 404 when any children
could be found
Modified:
trunk/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Thu Aug 9 00:02:24 2012 (r12057)
+++ trunk/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Thu Aug 9 11:03:25 2012 (r12058)
@@ -48,7 +48,7 @@
}
// Reverse array
- $this->prevSiblings = array_reverse($this->prevSiblings);
+ $this->items = array_reverse($this->items);
break;
@@ -68,13 +68,38 @@
case 'item':
default:
- // TODO: use getTreeViewSiblings or create new getTreeViewDescendants
- // also checking ACL permissions per record
+ // Find first child visible
$criteria = new Criteria;
$criteria->add(QubitInformationObject::PARENT_ID, $this->resource->id);
$criteria = QubitInformationObject::addTreeViewSortCriteria($criteria);
- $criteria->setLimit(10);
- $this->items = QubitInformationObject::get($criteria);
+ foreach (QubitInformationObject::get($criteria) as $item)
+ {
+ // ACL checks
+ if (QubitAcl::check($item, 'read'))
+ {
+ $firstChild = $item;
+
+ break;
+ }
+ }
+
+ if (isset($firstChild))
+ {
+ // Merge the first chlid found and its potential siblings
+ $this->items = array_merge(array($firstChild),
$firstChild->getTreeViewSiblings(array('limit' =>
$numberOfPreviousOrNextSiblings + 2, 'position' => 'next')));
+
+ $this->hasNextSiblings = count($this->items) >
$numberOfPreviousOrNextSiblings;
+ if ($this->hasNextSiblings)
+ {
+ array_pop($this->items);
+ }
+ }
+ else
+ {
+ // This is a rare case where a node looked expandable
+ // and then we realized that any children was visible for the user
+ $this->forward404();
+ }
break;
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.