*/ /** * @package NewItems * @subpackage UserInterface */ class NewItemsSiteAdminController extends GalleryController { /** * @see GalleryController::handleRequest */ function handleRequest($form) { $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $status = $error = array(); if (isset($form['action']['save'])) { if (!isset($form['days']['new']) || !is_numeric($form['days']['new'])) { $error[] = 'form[error][new]'; } if (!isset($form['days']['updated']) || !is_numeric($form['days']['updated'])) { $error[] = 'form[error][updated]'; } if (empty($error)) { foreach (array('days.new', 'days.updated') as $key) { $keys = explode('.', $key); $ret = GalleryCoreApi::setPluginParameter( 'module', 'newitems', $key, $form[$keys[0]][$keys[1]]); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } $status['saved'] = 1; } } else if(isset($form['action']['reset'])) { list ($ret, $default) = GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if (strpos($default, 'NewItems') !== false) { $ret = GalleryCoreApi::setPluginParameter( 'module', 'core', 'default.orderBy', 'orderWeight'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } GalleryCoreApi::requireOnce('modules/newitems/classes/NewItemsHelper.class'); $ret = NewItemsHelper::resetNewItemSorts(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $status['reset'] = 1; } /* else $form['action']['reset'] */ /* Figure out where to redirect upon success */ $method = empty($error) ? 'redirect' : 'delegate'; $results[$method]['view'] = 'core.SiteAdmin'; $results[$method]['subView'] = 'newitems.NewItemsSiteAdmin'; $results['status'] = $status; $results['error'] = $error; return array(null, $results); } } /** * @package NewItems * @subpackage UserInterface */ class NewItemsSiteAdminView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { GalleryCoreApi::requireOnce('modules/newitems/classes/NewItemsHelper.class'); $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if ($form['formName'] != 'NewItemsSiteAdmin') { $form['formName'] = 'NewItemsSiteAdmin'; foreach (array('days.new', 'days.updated') as $key) { list ($ret, $value) = GalleryCoreApi::getPluginParameter('module', 'newitems', $key); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $key = explode('.', $key); $form[$key[0]][$key[1]] = $value; } } list ($ret, $form['count']) = NewItemsHelper::fetchAlbumCount(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $default) = GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $form['isDefault'] = strpos($default, 'NewItems') !== false; $template->setVariable('controller', 'newitems.NewItemsSiteAdmin'); return array(null, array('body' => 'modules/newitems/templates/NewItemsSiteAdmin.tpl')); } } ?>