Author: david
Date: 2008-11-05 12:28:06 -0800 (Wed, 05 Nov 2008)
New Revision: 1521

Modified:
   trunk/qubit/lib/model/QubitInformationObject.php
Log:
Add QubitInformationObject::getCollections() method to retrieve all information 
objects that (1) are a child of the root node and (2) have child nodes.

Modified: trunk/qubit/lib/model/QubitInformationObject.php
===================================================================
--- trunk/qubit/lib/model/QubitInformationObject.php    2008-11-05 11:15:00 UTC 
(rev 1520)
+++ trunk/qubit/lib/model/QubitInformationObject.php    2008-11-05 20:28:06 UTC 
(rev 1521)
@@ -119,6 +119,7 @@
 
     return $label;
   }
+
   /**
    * Get a paginated hitlist information objects
    *
@@ -198,6 +199,26 @@
     return $pager;
   }
 
+  /**
+   * Get all info objects that have the root node as a parent, and have 
children
+   * (not orphans)
+   *
+   * @return QubitQuery collection of QubitInformationObjects
+   */
+  public static function getCollections()
+  {
+    $criteria = new Criteria;
+    $criteria->addAlias('parent', QubitInformationObject::TABLE_NAME);
+    $criteria->addJoin(QubitInformationObject::PARENT_ID, 'parent.id');
+
+    // For a node with no children: rgt = (lft+1); therefore search for nodes
+    // with: rgt > (lft+1)
+    $criteria->add(QubitInformationObject::RGT, QubitInformationObject::RGT.' 
> ('.QubitInformationObject::LFT.' + 1)', Criteria::CUSTOM);
+    $criteria->add('parent.lft', 1, Criteria::EQUAL);
+
+    return QubitInformationObject::get($criteria);
+  }
+
   public function getCollectionRoot()
   {
     return $this->getAncestors()->orderBy('lft')->offsetGet(1, 
array('defaultValue' => $this));


--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to