Allow comments only for photos

joemonster
joemonster's picture

Joined: 2006-04-12
Posts: 236
Posted: Tue, 2006-06-20 22:29

I didn't found a option in Gallery2 to allow people to comment only photos. I know that i can set permissions for albums/photos to restrict/allow people to write comments, but that's too much work if you create a lot of albums.
It shouldn't be hard to add an option for the comments module to allow only comments for photos.

 
korpdata

Joined: 2006-05-25
Posts: 43
Posted: Sun, 2006-07-02 16:56

Hello,

You can edit the following file:
/your gallerydirectory/modules/comment/module.inc

And change the function getItemLinks:

function getItemLinks($items, $wantsDetailedLinks, $permissions) {
list ($ret, $showAll) = $this->getParameter('comments.latest');
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
$links = array();
foreach ($items as $item) {
$itemId = $item->getId();
if (isset($wantsDetailedLinks[$itemId])) {
if (isset($permissions[$itemId]['comment.add'])) {
$links[$itemId][] = array(
'text' => $this->translate('Add comment'),
'params' => array('view' => 'comment.AddComment',
'itemId' => $itemId, 'return' => 1));
}

if ($showAll && isset($permissions[$itemId]['comment.view'])) {
$links[$itemId][] = array(
'text' => $this->translate('View last comments'),
'params' => array('view' => 'comment.ShowAllComments',
'itemId' => $itemId, 'return' => 1));
}
}
}

return array(null, $links);
}

like this:

function getItemLinks($items, $wantsDetailedLinks, $permissions) {
list ($ret, $showAll) = $this->getParameter('comments.latest');
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
$links = array();
foreach ($items as $item) {
$itemId = $item->getId();
$isAlbum = $item->getCanContainChildren();

if (!$isAlbum && isset($wantsDetailedLinks[$itemId])) {
if (isset($permissions[$itemId]['comment.add'])) {
$links[$itemId][] = array(
'text' => $this->translate('Add comment'),
'params' => array('view' => 'comment.AddComment',
'itemId' => $itemId, 'return' => 1));
}

if ($showAll && isset($permissions[$itemId]['comment.view'])) {
$links[$itemId][] = array(
'text' => $this->translate('View last comments'),
'params' => array('view' => 'comment.ShowAllComments',
'itemId' => $itemId, 'return' => 1));
}
}
}

return array(null, $links);
}

[ KORPDATA ] Innovando Soluciones Empresariales

 
Dinictis

Joined: 2006-10-07
Posts: 4
Posted: Tue, 2006-10-31 09:25

Thanks, it works. But after I published the comment, the page didn't go back to the photo page. How to solve this problem.

Website - http://www.dinictismedia.com
Fotopages - http://dinictis.fotopages.com
Flickr - http://www.flickr.com/photos/dinictis

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2006-10-31 09:44