Ansel_Api::removeGallery PHP Method

removeGallery() public method

Removes a gallery and its images.
public removeGallery ( integer $gallery_id, array $params = [] )
$gallery_id integer The id of gallery.
$params array Any additional, optional, parameters:
  (string)scope  the scope to use, if not the default
    public function removeGallery($gallery_id, array $params = array())
    {
        // Check global Ansel permissions
        if (!$GLOBALS['injector']->getInstance('Horde_Perms')->getPermissions('ansel', $GLOBALS['registry']->getAuth())) {
            throw new Horde_Exception_PermissionDenied(_("Access denied deleting galleries."));
        }
        // Custom scope, if needed
        if (!empty($params['scope'])) {
            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $params['scope']);
        }
        // Get, and check perms on the gallery
        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id);
        if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
            throw new Horde_Exception_PermissionDenied(_("Access denied deleting this gallery."));
        } else {
            $GLOBALS['injector']->getInstance('Ansel_Storage')->removeGallery($gallery);
        }
    }