* @author Jess Martin */ /** * ItemEditOption for hiding an item * * @package Hidden * @subpackage UserInterface */ class HiddenItemOption extends ItemEditOption { /** * @see ItemEditOption::isAppropriate */ function isAppropriate($item, $thumbnail) { list ($ret, $canHide) = GalleryCoreApi::hasItemPermission($item->getId(), 'core.changePermissions'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } return array(null, $canHide); } /** * @see ItemEditOption::loadTemplate */ function loadTemplate(&$template, &$form, $item, $thumbnail) { $form['HiddenItemOption']['isHidden'] = $item->hasOnLoadHandler('Hidden'); $form['HiddenItemOption']['isAlbum'] = $item->getCanContainChildren(); list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'hidden'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null, null); } /* Specific translations: _('Hide Album') _('Hide Photo') _('Hide Movie') */ $itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false)); $form['HiddenItemOption']['heading'] = $module->_translate( array('text' => 'Hide %s', 'arg1' => $itemTypeNames[0]), $itemTypeNames[2]); return array(null, 'modules/hidden/templates/HiddenItemOption.tpl', 'modules_hidden'); } /** * @see ItemEditOption::handleRequestAfterEdit */ function handleRequestAfterEdit($form, &$item, &$preferred) { GalleryCoreApi::requireOnce('modules/hidden/classes/HiddenHelper.class'); $error = $warning = array(); $ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.changePermissions'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null, null); } if (isset($form['HiddenItemOption']['setHidden']) && $form['HiddenItemOption']['setHidden']) { $ret = HiddenHelper::hideItem($item); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null, null); } } else { $ret = HiddenHelper::unHideItem($item); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null, null); } } return array(null, $error, $warning); } } ?>