Ansel_Gallery::getChildren PHP Method

getChildren() public method

Get all children of this share.
public getChildren ( string $user, integer $perm = Horde_Perms::SHOW, boolean $allLevels = true ) : array
$user string The user to use for checking perms
$perm integer Horde_Perms::* constant. If NULL will return all shares regardless of permissions.
$allLevels boolean Return all levels.
return array An array of Ansel_Gallery objects
    public function getChildren($user, $perm = Horde_Perms::SHOW, $allLevels = true)
    {
        try {
            return $GLOBALS['injector']->getInstance('Ansel_Storage')->buildGalleries($this->_share->getChildren($user, $perm, $allLevels));
        } catch (Horde_Share_Exception $e) {
            throw new Ansel_Exception($e);
        }
    }

Usage Example

示例#1
0
 /**
  * Removes an Ansel_Gallery.
  *
  * @param Ansel_Gallery $gallery  The gallery to delete
  *
  * @throws Ansel_Exception
  */
 public function removeGallery(Ansel_Gallery $gallery)
 {
     // Get any children and empty them
     $children = $gallery->getChildren(null, null, true);
     foreach ($children as $child) {
         $this->emptyGallery($child);
         $child->setTags(array());
     }
     // Now empty the selected gallery of images
     $this->emptyGallery($gallery);
     // Clear all the tags.
     $gallery->setTags(array());
     // Get the parent, if it exists, before we delete the gallery.
     $parent = $gallery->getParent();
     $id = $gallery->id;
     // Delete the gallery from storage
     try {
         $this->_shares->removeShare($gallery->getShare());
     } catch (Horde_Share_Exception $e) {
         throw new Ansel_Exception($e);
     } catch (Horde_Exception_NotFound $e) {
         throw new Ansel_Exception($e);
     }
     // Expire the cache
     if ($GLOBALS['conf']['ansel_cache']['usecache']) {
         $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $id);
     }
     // See if we need to clear the has_subgalleries field
     if ($parent instanceof Ansel_Gallery) {
         if (!$parent->countChildren($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, false)) {
             $parent->set('has_subgalleries', 0, true);
             if ($GLOBALS['conf']['ansel_cache']['usecache']) {
                 $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $parent->id);
             }
         }
     }
 }