From: Pierre-Luc P. <pa...@us...> - 2006-02-27 19:27:35
|
Update of /cvsroot/gallery/gallery2/modules/rss In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30847/modules/rss Modified Files: Render.inc SimpleRender.inc module.inc Log Message: - made item links translatable - made render errors translatable - added permissions check for comments feeds - minor visual change in admin UI Index: SimpleRender.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/rss/SimpleRender.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SimpleRender.inc 23 Feb 2006 04:37:56 -0000 1.3 +++ SimpleRender.inc 27 Feb 2006 19:27:30 -0000 1.4 @@ -52,9 +52,7 @@ } if ($params['allowSimpleFeed'] != 1) { - header('HTTP/1.0 500 Internal Server Error'); - header('Status: 500'); - print('Feeds of that type are not allowed!'); + $this->handleError($gallery->i18n('Feeds of that type are not allowed!')); return null; } @@ -63,11 +61,6 @@ return $ret->wrap(__FILE__, __LINE__); } - $ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.view'); - if ($ret) { - return $ret->wrap(__FILE__, __LINE__); - } - $params['itemId'] = $item->getId(); /* set feed type */ Index: Render.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/rss/Render.inc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Render.inc 25 Feb 2006 23:13:25 -0000 1.4 +++ Render.inc 27 Feb 2006 19:27:29 -0000 1.5 @@ -63,26 +63,19 @@ /* we're a configurable feed, load the parameters */ list ($ret, $params1) = RssMapHelper::fetchFeed($name); if ($ret) { - header('HTTP/1.0 500 Internal Server Error'); - print('This feed no longer exists!'); + $this->handleError($gallery->i18n('This feed no longer exists!')); return null; } $params = array_merge($params, $params1); $feedType = $params['feedType']; - $ret = GalleryCoreApi::assertHasItemPermission($params['itemId'], 'core.view'); - if ($ret) { - return $ret->wrap(__FILE__, __LINE__); - } - if (($feedType == 'album' && $params['allowAlbums'] != 1) || ($feedType == 'photos' && $params['allowPhotos'] != 1) || ($feedType == 'photosRecurse' && $params['allowPhotosRecurse'] != 1) || ($feedType == 'commentsAlbum' && $params['allowCommentsAlbum'] != 1) || ($feedType == 'commentsPhoto' && $params['allowCommentsPhoto'] != 1)) { - header('HTTP/1.0 500 Internal Server Error'); - print('Feeds of that type are not allowed!'); + $this->handleError($gallery->i18n('Feeds of that type are not allowed!')); return null; } @@ -97,12 +90,22 @@ function continueRender($params) { global $gallery; + /* check permissions */ + list ($ret, $perm) = GalleryCoreApi::hasItemPermission($params['itemId'], 'core.view'); + if ($ret) { + return $ret->wrap(__FILE__, __LINE__); + } + + if (!$perm) { + $this->handleError($gallery->i18n('Not permitted to view this item')); + return null; + } + /* check render type */ $feedType = $params['feedType']; if ($feedType != 'album' && $feedType != 'photos' && $feedType != 'photosRecurse' && $feedType != 'commentsAlbum' && $feedType != 'commentsPhoto') { - header('HTTP/1.0 500 Internal Server Error'); - print('Incorrect feed type!'); + $this->handleError($gallery->i18n('Incorrect feed type!')); return null; } @@ -113,9 +116,21 @@ if ($ret) { return $ret->wrap(__FILE__, __LINE__); } - if($modulestatus['comment']['active'] != '1') { - header('HTTP/1.0 500 Internal Server Error'); - print('Comments module is not active or comments in photo feeds are not allowed!'); + + if ($modulestatus['comment']['active'] != '1') { + $this->handleError($gallery->i18n( + 'Comments module is not active or comment feeds are not allowed!')); + return null; + } + + /* check the permissions */ + list ($ret, $perm) = GalleryCoreApi::hasItemPermission($params['itemId'], 'comment.view'); + if ($ret) { + return $ret->wrap(__FILE__, __LINE__); + } + + if (!$perm) { + $this->handleError($gallery->i18n('Not permitted to view comments for this item')); return null; } } @@ -148,5 +163,17 @@ print($generator->generate($params['version'])); return null; } + + function handleError($message) { + header('HTTP/1.0 500 Internal Server Error'); + + list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'rss'); + if ($ret) { + /* swallow the error and just print the untranslated message */ + print($message); + } else { + print($module->translate($message)); + } + } } ?> Index: module.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/rss/module.inc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- module.inc 23 Feb 2006 04:37:56 -0000 1.4 +++ module.inc 27 Feb 2006 19:27:30 -0000 1.5 @@ -74,8 +74,14 @@ if ($param['allowSimpleFeed'] == 1) { $itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false)); + /* + * Specific translations: + * _('RSS Feed for this Album') + * _('RSS Feed for this Photo') + * _('RSS Feed for this Movie') + */ $links[$itemId][] = array( - 'text' => $this->translate(array( + 'text' => $this->_translate(array( 'text' => 'RSS Feed for this %s', 'arg1' => $itemTypeNames[0]), $itemTypeNames[2]), 'params' => array( |