Gallery 2.0b3 - Remove Album Level Comments

shmuel

Joined: 2005-07-03
Posts: 6
Posted: Sun, 2005-07-03 01:41

Ok, I know this was a popular feature and lots of people asked for it but ... I prefer to have comments only on individual items. How can I get this behavior? I've been searching the forums and dinking with the code but can't quite figure it out. Thanks.

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Sun, 2005-07-03 03:02

G2 issues go to the G2 forums :)

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-07-03 06:09

modify modules/comment/module.inc so it doesn't return the "add comment" item link for album items..

 
shmuel

Joined: 2005-07-03
Posts: 6
Posted: Sun, 2005-07-03 12:57

Sorry FryFrog - I didn't notice that.

Thank you mindless. And for whoever else would like to know here's some more specifics:

At around line 131 until about line 150 you should see a block that looks like this:

	    if (isset($permissions['comment.add'])) {
		$params['view'] = 'core:ItemAdmin';
		$params['subView'] = 'comment:AddComment';
		$params['itemId'] = $item->getId();
		$params['return'] = 1;
		$links[$item->getId()][] =
		    array('text' => $this->translate('add comment'),
			  'params' => $params);
	    }

	    if (isset($permissions['comment.view'])) {
		$params['view'] = 'core:ItemAdmin';
		$params['subView'] = 'comment:ShowComments';
		$params['itemId'] = $item->getId();
		$params['return'] = 1;
		$links[$item->getId()][] =
		    array('text' => $this->translate('view comment'),
			  'params' => $params);
	    }

change that block to this:

	if (GalleryUtilities::isA($item, 'GalleryPhotoItem')) {
	    if (isset($permissions['comment.add'])) {
		$params['view'] = 'core:ItemAdmin';
		$params['subView'] = 'comment:AddComment';
		$params['itemId'] = $item->getId();
		$params['return'] = 1;
		$links[$item->getId()][] =
		    array('text' => $this->translate('add comment'),
			  'params' => $params);
	    }

	    if (isset($permissions['comment.view'])) {
		$params['view'] = 'core:ItemAdmin';
		$params['subView'] = 'comment:ShowComments';
		$params['itemId'] = $item->getId();
		$params['return'] = 1;
		$links[$item->getId()][] =
		    array('text' => $this->translate('view comment'),
			  'params' => $params);
	    }
	}

You're basically adding this if block around the item links:

	if (GalleryUtilities::isA($item, 'GalleryPhotoItem')) {
       }

And commenting will only be available on individual items again.

I would love to see this as an option for the comment module.

 
underbiteman

Joined: 2006-03-30
Posts: 6
Posted: Wed, 2007-01-10 16:28

Can someone help me with an updated version of this hack for comment module 1.1.2?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2007-01-10 18:59

the code in module.inc still looks vaguely like that.. put the "if (GalleryUtilities::isA....." line just above:

if (isset($permissions[$itemId]['comment.add'])) {

put the closing } after the next }

you might also want

if (!$item->getCanContainChildren()) {

instead of the check for GalleryPhotoItem.. this will omit the link for albums only. the previous code would omit the link for movies, etc and show it only for photos.

 
underbiteman

Joined: 2006-03-30
Posts: 6
Posted: Wed, 2007-01-10 20:40

Excellent! Thanks.