*/ /** * This controller locates (and creates if needed) a user album * and jumps to its view. * * @package UserAlbum */ class UserAlbumController extends GalleryController { /** * @see GalleryController::handleRequest */ function handleRequest($form) { global $gallery; $activeUserId = $gallery->getActiveUserId(); $userId = GalleryUtilities::getRequestVariables('userId'); if (empty($userId)) { $userId = $activeUserId; } list ($ret, $anonymousUserId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if ($userId == $anonymousUserId) { return array(GalleryCoreApi::error(ERROR_PERMISSION_DENIED, __FILE__, __LINE__), null); } list ($ret, $albumId) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $userId); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $createMode) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'create'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if (!empty($albumId)) { list ($ret, $album) = GalleryCoreApi::loadEntitiesById($albumId); if ($ret && !($ret->getErrorCode() & ERROR_MISSING_OBJECT)) { return array($ret->wrap(__FILE__, __LINE__), null); } } if (!isset($album) && $createMode == 'access') { /* If userId matches active user then create the user album */ if ($userId != $activeUserId) { return array(GalleryCoreApi::error(ERROR_PERMISSION_DENIED, __FILE__, __LINE__), null); } GalleryCoreApi::requireOnce('modules/useralbum/classes/UserAlbumHelper.class'); $ret = UserAlbumHelper::createUserAlbum($gallery->getActiveUser()); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $albumId) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $userId); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } $results = array('delegate' => array('view' => 'core.ShowItem', 'itemId' => $albumId), 'status' => array(), 'error' => array()); return array(null, $results); } } ?>