*/ class NewAlbumController extends GalleryController { /** * @see GalleryController::handleRequest */ function handleRequest(&$form) { global $gallery; $platform =& $gallery->getPlatform(); $results = $error = $status = array(); if (isset($form['action']['newAlbum'])) { /* Now check the value of name and title */ if (empty($form['pathComponent'])) { $error[] = 'form[error][pathComponent][missing]'; } else if (!$platform->isLegalPathComponent($form['pathComponent'])) { $error[] = 'form[error][pathComponent][invalid]'; } if (empty($form['title'])) { $error[] = 'form[error][title][missing]'; } if (empty($error)) { list($ret, $newAlbum) = GalleryCoreApi::createAlbum( $form['parentId'], $form['pathComponent'], $form['title'], $form['summary'], $form['description'], null); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if (empty($error)) { /* Give the creator all permissions on the new album */ $ret = GalleryCoreApi::addUserPermission( $newAlbum->getId(), $newAlbum->getOwnerId(), 'core.all', false); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $redirect['view'] = 'publishxp.SelectAlbum'; $redirect['albumId'] = $newAlbum->getId(); } } } if (!empty($redirect)) { $results['redirect'] = $redirect; } else { $results['delegate']['view'] = 'publishxp.NewAlbum'; } $results['status'] = $status; $results['error'] = $error; return array(null, $results); } } /** * View to create a new album for the photos. * * Allows the user to create a new album underneath the parent they selected. * The user can specify the name, title, and summary for the album. The user * is redirected back to the select album page after creating the album with * the newly created album automatically selected. * * @package PublishXp * @subpackage UserInterface */ class NewAlbumView extends GalleryView { /** * @see GalleryView:loadTemplate */ function loadTemplate(&$template, &$form) { global $gallery; if ($form['formName'] != 'NewAlbum') { $form['formName'] = 'NewAlbum'; $parentId = GalleryUtilities::getRequestVariables('parentId'); if (empty($parentId)) { return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__), null); } $form['parentId'] = $parentId; $form['pathComponent'] = ''; $form['title'] = ''; $form['summary'] = ''; $form['keywords'] = ''; $form['description'] = ''; } $ret = GalleryCoreApi::assertHasItemPermission($form['parentId'], 'core.addAlbumItem'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list($ret, $parent) = GalleryCoreApi::loadEntitiesById($form['parentId']); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Load the item's parents */ list($ret, $parents) = GalleryCoreApi::fetchParents($parent, 'core.view'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } for ($i = 0; $i < sizeof($parents); $i ++) { $parents[$i] = (array)$parents[$i]; } $parents[] = (array)$parent; $NewAlbum = array(); $NewAlbum['parents'] = $parents; $template->setVariable('NewAlbum', $NewAlbum); $template->setVariable('controller', 'publishxp.NewAlbum'); $template->head('modules/publishxp/templates/Head.tpl'); return array(null, array('body' => 'modules/publishxp/templates/NewAlbum.tpl', 'useFullScreen' => true)); } } ?>