Ansel_Api::removeImage PHP Method

removeImage() public method

Removes an image from a gallery.
public removeImage ( integer $gallery_id, string $image_id, array $params = [] )
$gallery_id integer The id of gallery.
$image_id string The id of image to remove.
$params array Additional parameters:
  (string)scope  The scope to use, if not the default.
    public function removeImage($gallery_id, $image_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."));
        }
        // Set a custom scope, if needed
        if (!empty($params['scope'])) {
            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $params['scope']);
        }
        $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id);
        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
        if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
            throw new Horde_Exception_PermissionDenied(_("Access denied deleting photos from this gallery."));
        }
        $gallery->removeImage($image);
    }