summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php16
-rw-r--r--modules/gallery/models/item.php9
2 files changed, 18 insertions, 7 deletions
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index 1917d738..cde049cd 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -146,11 +146,15 @@ class ORM_MPTT_Core extends ORM {
* @chainable
* @param integer SQL limit
* @param integer SQL offset
+ * @param string type to return
* @param array orderby
* @return array ORM
*/
- function children($limit=null, $offset=0, $orderby=null) {
+ function children($limit=null, $offset=0, $type=null, $orderby=null) {
$this->where("parent_id", $this->id);
+ if ($type) {
+ $this->where("type", $type);
+ }
if (empty($orderby)) {
$this->orderby("id", "ASC");
} else {
@@ -163,16 +167,18 @@ class ORM_MPTT_Core extends ORM {
* Return all of the children of this node, ordered by id.
*
* @chainable
- * @param integer SQL limit
- * @param integer SQL offset
+ * @param string type to return
* @return array ORM
*/
- function children_count() {
+ function children_count($type=null) {
+ if ($type) {
+ $this->where("type", $type);
+ }
return $this->where("parent_id", $this->id)->count_all();
}
/**
- * Return all of the children of the specified type, ordered by id.
+ * Return all of the decendents of the specified type, ordered by id.
*
* @param integer SQL limit
* @param integer SQL offset
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index f3e6b8f3..3498e0db 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -526,10 +526,15 @@ class Item_Model extends ORM_MPTT {
* @chainable
* @param integer SQL limit
* @param integer SQL offset
+ * @param string type to return
+ * @param array orderby
* @return array ORM
*/
- function children($limit=null, $offset=0) {
- return parent::children($limit, $offset, array($this->sort_column => $this->sort_order));
+ function children($limit=null, $offset=0, $type=null, $orderby=null) {
+ if (empty($orderby)) {
+ $orderby = array($this->sort_column => $this->sort_order);
+ }
+ return parent::children($limit, $offset, $type, $orderby);
}
/**