Need to "hide" an album

huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Wed, 2005-11-30 13:05

OK, I need to "hide" an album from viewing.... unless someone knows the exact URL to the album.

1. Is this possible with the standard gallery software? (I'm using the latest nightly build as of yesterday).

2. If not, can someone please instruct me as to where the SQL query is that pulls the albums and shows them on the main page? I just need to add a WHERE clause to the query, if possible.

Thanks!

Jenn

 
notgoddess
notgoddess's picture

Joined: 2005-04-03
Posts: 178
Posted: Wed, 2005-11-30 13:39

Why don't you use Gallery's permission system to hide the album and create a user that view that album?

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Wed, 2005-11-30 15:09

Well, here's the deal.... NO ONE should be able to view it directly from www.newdawncustoms.com/coverage/ (it's the very last album....). EVERYONE should only be able to view it from the direct URL. (Coverage is our events coverage section, but I'm using the gallery to double as a "Member's Vehicles" section as well.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 15:35

you'll have this feature in G 2.1, but it's not yet part of g2.

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Wed, 2005-11-30 15:39

Can you tell me where to find the SQL query? I can make it do what I want if I could find it.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 16:00

modules/core/classes/helpers/GalleryChildEntityHelper_simple.class function _fetchChildItemIds

but this function is pretty much the most unreadable method of g2...

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Wed, 2005-11-30 16:22

Yes, I see that.... you guys don't make anything easy do you?? :D

I see no SQL queries there in that function, by the way....

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 16:26

$gallery->search(sql query here)
is used in g2.

our SQL is slightly different from the mysql / postgresql / oracle / .. .SQL
- we use the names of our classes instead of tables, e.g. [GalleryEntity] instead of g2_Entity. the db layer of g2 replaces the class names with the table names
- we use class member names instead of column names, e.g. [GalleryEntity::id] instead of g2_Entity.g_id
that's about it.
special things as LIMIT, bit operations etc. are also abstracted since they are not implemented the same way in all databases

in this fetchChildItemIds function, we're assembling the SQL query. thus it's very, very unreadable. we even marked the function as unreadable, we need to refactor it.

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Wed, 2005-11-30 18:35

So, basically unless I spend the time to de-code the coding structure, I'm SOL....

Is there a way I can modify the Siriux theme to NOT show galleries prior to 2003?? Does this sound feasible?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 23:19

in theme.inc of siriux, function showAlbumPage, you can check the children's creationTimestamp and remove them from the list...

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Thu, 2005-12-01 12:22
    function showAlbumPage(&$template, $item, $params, $childIds) {
	$ret = $this->loadCommonTemplateData(
	    $template, $item, $params,
	    array('owner', 'viewCount', 'childCount', 'descendentCount', 'parents',
		  'systemLinks', 'itemLinks', 'itemSummaries', 'permissions',
		  'thumbnails', 'pageNavigator', 'jumpRange'),
	     $childIds);
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}

	/* Override some navigator settings */
	$theme =& $template->getVariableByReference('theme');
	if (isset($theme['navigator']['first'])) {
	    unset($theme['navigator']['first']);
	}
	if (isset($theme['navigator']['last'])) {
	    unset($theme['navigator']['last']);
	}
	$theme['params']['groupByYear'] = !$item->getParentId();

	/* Find the thumbnail size for this album */
	$theme['params']['thumbnailSize'] = 150;
	list ($ret, $preferences) =
	    GalleryCoreApi::fetchDerivativePreferencesForItem($item->getId());
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}
	foreach ($preferences as $preference) {
	    if ($preference['derivativeType'] == DERIVATIVE_TYPE_IMAGE_THUMBNAIL &&
		  preg_match('/thumbnail\|(\d+)/', $preference['derivativeOperations'], $matches)) {
		$theme['params']['thumbnailSize'] =  $matches[1];
		break;
	    }
	}

	return array(GalleryStatus::success(), 'theme.tpl');
    }

I'm so sorry that I'm being so difficult.... but I honestly don't see how to do that.... I really could just put if($item_id != "126875") { around the code that shows the albums.... but unfortunately I'm not entirely sure which code shows them....

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 12:39
foreach ($theme['children'] as $id => $child) {
    if ($id == ...) {
        unset($theme['children'][$id]);
    }
}

of course you can also check for other child properties

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Thu, 2005-12-01 12:56

OK, now the function looks like this:

    function showAlbumPage(&$template, $item, $params, $childIds) {
	$ret = $this->loadCommonTemplateData(
	    $template, $item, $params,
	    array('owner', 'viewCount', 'childCount', 'descendentCount', 'parents',
		  'systemLinks', 'itemLinks', 'itemSummaries', 'permissions',
		  'thumbnails', 'pageNavigator', 'jumpRange'),
	     $childIds);
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}

	/* Override some navigator settings */
	$theme =& $template->getVariableByReference('theme');
	if (isset($theme['navigator']['first'])) {
	    unset($theme['navigator']['first']);
	}
	if (isset($theme['navigator']['last'])) {
	    unset($theme['navigator']['last']);
	}
	$theme['params']['groupByYear'] = !$item->getParentId();

	/* Find the thumbnail size for this album */
	$theme['params']['thumbnailSize'] = 150;
	list ($ret, $preferences) =
	    GalleryCoreApi::fetchDerivativePreferencesForItem($item->getId());
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}
	foreach ($preferences as $preference) {
	    if ($preference['derivativeType'] == DERIVATIVE_TYPE_IMAGE_THUMBNAIL &&
		  preg_match('/thumbnail\|(\d+)/', $preference['derivativeOperations'], $matches)) {
		$theme['params']['thumbnailSize'] =  $matches[1];
		break;
	    }
	}
/* Override the Member Vehicles Album so it doesn't show */
foreach ($theme['children'] as $id => $child) {
    if ($id == '12867') {
        unset($theme['children'][$id]);
    }
}
	return array(GalleryStatus::success(), 'theme.tpl');
    }

And it's not working..... :(

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 13:08

as far as i understand you, you want that the album with id 12876 is not listed when you browse the parent album of album 12867. correct?

what exactly does it still show? the thumbnail for 12867?

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Thu, 2005-12-01 13:15

Please see http://www.newdawncustoms.com/coverage/

Click to page 3. The last album (Member Vehicles) I do not want to show on the main page. It's ID is 12867. Or, I set the year to 2002, so if we could not show any albums with the "creationdate" as anything in 2002.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 13:22

hmm, let's debug.
in your foreach loop, do a print "$id, "; and after the foreach call exit;
then browse to http://www.newdawncustoms.com/coverage/main.php?g2_view=core.ShowItem&g2_itemId=7&g2_page=3 and check what ids are printed.

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Thu, 2005-12-01 13:36

On page one, it lists 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 etc..... up to as many album that show.... on page three it says 0, 1 (since there are only two albums listed).

I added print "$id <br />"; underneath the foreach() function.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 13:51

aha, the keys of the children array aren't the child ids...

use this instead:

foreach ($theme['children'] as $id => $child) {
if ($child['id'] == '12867') {
unset($theme['children'][$id]);
}
}

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Thu, 2005-12-01 13:59

PERFECT! Thank you SOOOOO much! I'll try and remember all this for next time I need to change something..... lol.

You're fantastic. :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 14:04

np :)
glad it works for you. of course it's far from perfect and the official hide feature will be much better.

 
huskysgrl

Joined: 2005-05-23
Posts: 40
Posted: Thu, 2005-12-01 14:21

Yes, as soon as 2.1 is released I'm certain I will upgrade and use the real feature, but for now this is good!

 
HaveFun
HaveFun's picture

Joined: 2003-10-21
Posts: 23
Posted: Sat, 2006-01-21 18:29
huskysgrl wrote:
Yes, as soon as 2.1 is released I'm certain I will upgrade and use the real feature

Has anyone an idea, when Gallery 2.1 will be released?
I'm waiting for the hide-feature, too ... and still stay on Gallery 1.x to have this.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2006-01-21 22:45

the hide feature is already available in nightly snapshots of g2. go get it...
g2.1 will be released on march 1st (tentative release date).

 
athertop

Joined: 2003-08-06
Posts: 38
Posted: Fri, 2006-02-03 11:57

Unless I am reading the original request wrong, I already do exactly what the original request was asking for, by just using permissions.

In my own gallery2 implementation http://www.pjamedia.com/gallery2 even if you are logged in (as a regular user, not admin) or not , there is one hidden album, which you have to enter the exact URL to access. The exact URL is: http://www.pjamedia.com/gallery2/v/hidden/rawresults/

The way I did it was to create a root level album for which only the Admin user has permission - so no one else can see this. This is called Hidden (surprisingly enough!) I then create a sub-album under this which has everybody View Items permissions assigned.

Isn't that what was being asked for, or did I read it wrong?

Cheers,
Paul

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2006-02-03 20:15

it's not quite the same.
of course you can hide something behind a "door / mountain". but if you don't want to use a non-public album just as obstacle to hide things behind it (e.g. because you don't want longer URLs), then the hidden items module is what you want.

 
dzm

Joined: 2004-08-11
Posts: 53
Posted: Tue, 2006-02-07 08:25
valiant wrote:
the hide feature is already available in nightly snapshots of g2. go get it...
g2.1 will be released on march 1st (tentative release date).

I bumped from G2.0 to G2.1 20060206 today and am trying to get the Hidden module to work. I've activated and isntalled it, but I can't find any interface for it on the item pages.

Can any give me an idea where I would actually hide something? I suspect that it should be the actions drop-down below the item (near "Edit Permissions"?) but I see no menu item.

I've now officially spent hours trying to chase this down.

Help?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2006-02-07 11:51

install and activate the module.
then go to a album, click edit album and there set the password at the bottom.

 
dzm

Joined: 2004-08-11
Posts: 53
Posted: Tue, 2006-02-07 17:26

Aha! Found the check-box.

This seems kinda ... well ... buried. Wouldn't it make sense to have "Hide/Unhide Item" available as a menu selection in the << item actions >> menu beneath the albums/photos?

Also - is there a way view thumbnails for all the contents of an album, check box the items I want, and hide them en masse? Seems this would also be much faster than individually editing each item.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2006-02-07 18:42

obviously there's no such mass hide option. just hide the whole album..
you can of course file feature requests on http://sf.net/projects/gallery/ -> RFE

 
dzm

Joined: 2004-08-11
Posts: 53
Posted: Tue, 2006-02-07 18:49

Consider it filed: 1426690