*/ /** * @package Watermark * @subpackage UserInterface */ class ConfirmDeleteController extends GalleryController { /** * @see GalleryController::handleRequest */ function handleRequest($form) { /* Make sure we have permission to edit this item */ $ret = GalleryCoreApi::assertHasItemPermission($form['watermarkId'], 'core.edit'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $status = array(); if (isset($form['action']['delete'])) { GalleryCoreApi::requireOnce('modules/watermark/classes/WatermarkHelper.class'); list ($ret) = WatermarkHelper::deleteWatermarkImageById($form['watermarkId'], true); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $status['delete'] = 1; } /* else $form['action']['cancel'] */ $results['redirect'] = isset($form['fromAdmin']) ? array('view' => 'core.SiteAdmin', 'subView' => 'watermark.WatermarkSiteAdmin') : array('view' => 'core.UserAdmin', 'subView' => 'watermark.UserWatermarks'); $results['status'] = $status; $results['error'] = array(); return array(null, $results); } } /** * @package Watermark * @subpackage UserInterface */ class ConfirmDeleteView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { GalleryCoreApi::requireOnce('modules/watermark/classes/WatermarkHelper.class'); if ($form['formName'] != 'ConfirmDelete') { $form['formName'] = 'ConfirmDelete'; list ($form['watermarkId'], $form['fromAdmin']) = GalleryUtilities::getRequestVariables('watermarkId', 'fromAdmin'); } list ($ret, $item) = GalleryCoreApi::loadEntitiesById($form['watermarkId']); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $itemIds) = WatermarkHelper::fetchWatermarkedItemIds($item); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $template->setVariable('ConfirmDelete', array('item' => (array)$item, 'count' => count($itemIds))); $template->setVariable('controller', 'watermark.ConfirmDelete'); return array(null, array('body' => 'modules/watermark/templates/ConfirmDelete.tpl')); } } ?>