Is there way force users to register to view inside album?

neo314

Joined: 2005-07-31
Posts: 28
Posted: Sun, 2006-03-26 02:02

Numpty, i dropped a bracket it off the config.php while putting it in maintenance mode. please ignore above post

 
neo314

Joined: 2005-07-31
Posts: 28
Posted: Sun, 2006-03-26 02:07

is there any reason why when you go to log in on blackjack code, it no longer takes you back to where you came from but leaves you at the login on screen.

e.g you click on gallery, its takes you to login, you login, it leaves you at login rather than returning you to the gallery from where you came

 
mambocreed

Joined: 2005-08-26
Posts: 19
Posted: Sun, 2006-03-26 02:13

mindless,

for whatever reason, it never worked for me until I dropped in that duplicate.

you're the guru, though - I mentioned the situation in the thread earlier on with that.

if it's wrong, please tell me - I'd hate for people to snag that edit and have problems.

I haven't upgraded yet, just prepping everything for tomorrow.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-03-26 16:30

This is the patch for 2.1:

        /* Make sure we have permission to view this item */
        $ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.view');
+       if (!$ret && $item->getCanContainChildren()) {
+           /* We also need viewSource permission to see the contents of an album */
+           $ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.viewSource');
+       }
        if ($ret) {
            if ($ret->getErrorCode() & ERROR_PERMISSION_DENIED) {
                list ($ret2, $anonymousId) = GalleryCoreApi::getPluginParameter(

'loginRedirect' in modules/core/classes/GalleryCapabilities.class has 'return' => true, so it should return you to the album after you login.

 
jadmanx
jadmanx's picture

Joined: 2005-09-06
Posts: 83
Posted: Tue, 2006-04-11 18:46

it downt worke on the new version :-(((

http://www.blubbs.com is my page

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-04-11 19:04

sure it does.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2006-04-15 15:26

yes, in your config.php put:

require_once(dirname(__FILE__) . '/modules/core/classes/GalleryCapabilities.class');
GalleryCapabilities::set('loginRedirect', array('href' => '/mambo/url.php'));

(or put this in your embedded code just after the init() call.. you don't need the require_once if you put it there)

 
selfxplanatory

Joined: 2006-04-15
Posts: 4
Posted: Tue, 2006-04-18 02:03

sweet!! thanks mindless, you ROCK!!

 
da95649

Joined: 2004-04-13
Posts: 60
Posted: Tue, 2006-04-18 11:24

Im trying to do something similar, I want all of my albums in the root to have Everyone > View Item however I do not want the permissions to propagate to all the picutres, hence guests will be able to view the albums front cover(highlight) but get a login box when they click onto the album......when I goto the gallery root, I click edit permissions, and have everybody (core) view item and deselect the sub-items box, but its not working, any idea on what Im doing wrong?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-04-18 14:42

there's plenty of information in this topic about how the permissions should be setup. try adding "view all" for everyone to the album (not to subitems), then remove view all from the album (apply to subitems), now add just "view" to the album (not to subitems). also add "view all" for registered users group to all subitems.

 
da95649

Joined: 2004-04-13
Posts: 60
Posted: Tue, 2006-04-18 15:44

now Im really confused, I think I understand the reasoning behind removing and adding the permission due to propagation, however I did this step by step and still my guests cannot see the photos:

Gallery version = 2.1.1 core 1.1.0.1
PHP version = 4.4.2 apache
Webserver = Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 PHP/4.4.2 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a
Database = mysql 4.1.18-standard, lock.system=flock
Toolkits = ArchiveUpload, Exif, ImageMagick, NetPBM, Gd
Acceleration = none, none
Operating system = Linux mars.svr6-speedyservers.com 2.4.21-32.0.1.ELsmp #1 SMP Wed May 25 14:26:33 EDT 2005 i686
Default theme = matrix
Locale = en_GB
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; HbTools 4.7.1)

Does this help?

Please note I have read the whole threads, and I have made no changes to my code, its the latest version...

 
selfxplanatory

Joined: 2006-04-15
Posts: 4
Posted: Tue, 2006-04-18 21:35
Quote:
I did this step by step and still my guests cannot see the photos:

I thought you didn't want your guests to view the photos, just "Registered Users"?

Please read my post above and follow permission settings where I mention "For albums containing images"

 
jadmanx
jadmanx's picture

Joined: 2005-09-06
Posts: 83
Posted: Tue, 2006-05-09 16:52

and someone find an answer ?
http://www.blubbs.com is my page

 
jadmanx
jadmanx's picture

Joined: 2005-09-06
Posts: 83
Posted: Wed, 2006-05-10 06:12

Please can someon help ?
i hade worke this for the old version but on this it downt work :-(
and the help you give downt work

http://www.blubbs.com is my page

 
selfxplanatory

Joined: 2006-04-15
Posts: 4
Posted: Wed, 2006-05-10 11:15
jadmanx wrote:
Please can someon help ?
i hade worke this for the old version but on this it downt work :-(
and the help you give downt work

http://www.blubbs.com is my page

jadmanx,

Please fully describe what your problem is, what your question is refering too, and read the posting instructions sticky. Cause, no one can help you until you post a fully qualified question.

If you are refering to the permissions (of having guest only seeing the thumbnails, or album thumbnail), my first post summaries what mindless' instructions are.

If you are refering to automatically redirecting them to a login page (when they click on the thumbnail), mindless' response to my second post answers that as well. Anything... iono what you're talking about.

 
da95649

Joined: 2004-04-13
Posts: 60
Posted: Thu, 2006-05-11 14:02

Hi all,

I understand the process, however please note Im not making any changes to the code, I do not mind the screen that says this album has no items.

However what I didnt make clear is that I have 20 albums, once I get to this stage:

For albums containing images:
--- Everyone: [core] View item
--- Registered Users: [core] View all versions

Isnt there an easier way so I can apply these perms to the all the albums in the root rather then do each album one by one, its taking me ages.

I basically want to apply Everyone: [core] View item without subfolders/items, so I can do it in one hit?

Does this make sense or am I confused?

 
computerwiz5

Joined: 2004-10-16
Posts: 18
Posted: Mon, 2006-07-10 15:49

Hi all, i have the most recent gallery version. But this patch does not work? any clues?

Thanks

 
jdlh199

Joined: 2005-10-05
Posts: 17
Posted: Mon, 2006-11-20 19:40

I installed this on the most recent gallery version and it works great. I have just one question though. On the main page, guests can view albums and highlighted images but when they click on an album they are prompted to log in. However, they can still see the random image block which they can then click and browse through all the thumbnails.

Is there a way to disable the random image block until a user logs in?

Thanks

 
liquidmojophoto

Joined: 2007-01-09
Posts: 1
Posted: Wed, 2007-01-10 18:21

Is there a way to apply this same type of patch so that only specific images within the album re-direct as opposed to the entire album itself?

(I have it working successfully from with albums.)

Thanks!

EDIT:

Nevermind, I figured it out myself. I simply edited the 'if' statement so that it wouldn't only check for folder, but checks the permissions on all items.

Changed:

Quote:
if (!$ret && $item->getCanContainChildren())

To:

Quote:
if (!$ret )

 
neo314

Joined: 2005-07-31
Posts: 28
Posted: Sun, 2007-06-03 16:29

Hi All,

Had been happiy using this patch on gallery 2.1 now have upgraded to the latest and greatest it does not seem to work
The showitem.inc seems very different and it looks like most of the functionality is already in there, however i cant get it to do what i am after

i want to still have the original feature of all the albums (viewed from the main album) being available as a thumbnail but when a user clicks on one of these galleries if they are not logged in, they should be directed to the login page. So to sum up, i want my gallery to show the parent albums but if they click on it, they get the login page.

Any help would be great as i have had to take the gallery down til i sort this

Thanks again

 
neo314

Joined: 2005-07-31
Posts: 28
Posted: Wed, 2007-06-06 09:46

Anyone have any ideas?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2007-06-06 14:35

please give more information about what you tried and what happened.
The current code still has the "/* Make sure we have permission to view this item */" block of code in ShowItem.inc...

 
carnold5

Joined: 2006-02-27
Posts: 62
Posted: Fri, 2007-06-08 02:37

I want to be able to force users to enter a password/register to view the items in an album.
I want the user to see the albums but then if they click into the album, a message will appear that says they must enter a password/register to view photos or comments.

Is there an easy good way to do this?

 
neo314

Joined: 2005-07-31
Posts: 28
Posted: Tue, 2007-06-19 17:39

Sorry mindless for the delay,

I applied the patch as mentioned further up this forum by yourself (version for 2.1) but when i included this code and set the galleries to Everyone: [core] View item but only other groups can view all and original items then i simply get a message saying gallery is empty

if i then log in as an account it will show me the galleries, but it does not show me the thumbnail view like it used to where you can click it and be prompted to enter your username and password to enter that gallery

What i used to have on the 2.1 version was the root gallery would contain the thumbnail of the galleries, and once you clicked on this, it would tell you you were not logged in and prompt for username and password,once entered, then divert you back into the gallery

Let me know if you need any more info

 
neo314

Joined: 2005-07-31
Posts: 28
Posted: Mon, 2007-06-25 20:06

any updates on this guys?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2007-07-05 18:19

from your description, it sounds like the album itself has core.viewSource permission for guests, in addition to core.view. This would show you an empty album (since the contents of the album have no permission for guests) instead of redirecting to the login page.

 
micdabe

Joined: 2007-07-04
Posts: 7
Posted: Fri, 2007-07-06 01:33
mindless wrote:
yes, in your config.php put:

require_once(dirname(__FILE__) . '/modules/core/classes/GalleryCapabilities.class');
GalleryCapabilities::set('loginRedirect', array('href' => '/mambo/url.php'));

(or put this in your embedded code just after the init() call.. you don't need the require_once if you put it there)

How about the same for wpg2?
I've got the same effect: In gallery standalone, it redirects to login! BUT in the wpg2 (3.0 beta) embedded it redirects to a nonexist page and wpg2 redir to the error page link configured in wpg2 admin. Others rewriting rules works perfectly.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2007-07-07 14:59

I think the above code (GalleryCapabilities) still works, but it is deprecated. The code in config.php now (gallery 2.2.x) would be:

$gallery->setConfig('loginRedirect', array('href' => '/wplogin.php'));
 
micdabe

Joined: 2007-07-04
Posts: 7
Posted: Tue, 2007-07-10 15:19

First of all, thank you for the reply.
The right piece of code is:

$gallery->setConfig('loginRedirect', array('href' => '/wp-login.php'));

But this redirects to WP login instead of desidered G2 login embedded in WP.
I think it is a rewrite problem 'cos WPG catches /v/ URLs

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2007-07-11 14:28

you should redirect to WP login. since your G2 is embedded, when you login to WP then you are logged into G2 too. if you use the G2 login then you're in a weird state of being logged into G2 but not WP.

 
micdabe

Joined: 2007-07-04
Posts: 7
Posted: Thu, 2007-07-12 09:29

I use multiroot plugin.
I've created a separate user not joined with WP. I place the login block in main Gallery page. But I don't like it.
When I'm logged as WP admin or user (G2 access granted) the login block is not present.
For guests they have to login to G2 only using the G2 login block.
When they do login, the login block indeed disappear 'cos they are logged in.
Nice will be: Guest click to protected album? -> redir to G2 login page (embedded) -> Do login -> redir to album selected.
This actually works in G2 standalone but not in the WPG2 embedded version.
Obviously it's an embedding problem, probably in wpg2embed.inc

$ret = GalleryEmbed::init( array(
	'embedUri' => $wpg2_g2path['g2_embeduri'],
	'g2Uri' => $wpg2_g2path['g2_url'],
	'loginRedirect' => $wpg2_g2path['g2_errorredirect'],
	'fullInit' => true)
);

and...

$wpg2_g2path['g2_errorredirect'] = $embedUri.'index.php';

But I'm not so skilled to find a solution...

 
jrslyrics

Joined: 2007-09-26
Posts: 3
Posted: Wed, 2007-09-26 15:25

I'm trying to accomplish this feature but i am unable to on the version 2.2.3! Has anyone accomplished this ont he latest version. When I add the code above, i just get a blank white screen. HELP!
Here is what my showItems code looks like:

/* Make sure we have permission to view this item */
	$ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.view');
	if ($ret) {
	    if ($ret->getErrorCode() & ERROR_PERMISSION_DENIED) {
		list ($ret2, $isAnonymous) = GalleryCoreApi::isAnonymousUser();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($isAnonymous) {
		    /* Redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		/* Try to redirect to default album */
		list ($ret2, $rootId) = GalleryCoreApi::getDefaultAlbumId();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($item->getId() == $rootId) {
		    /* No permission on root album; redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		return array(null, array('redirect' =>
		    array('view' => 'core.ShowItem', 'itemId' => $rootId)));
	    }
	    return array($ret, null);
	}

	/*
 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2007-09-27 02:45

if you get a blank screen there's probably a typo in your code changes... change 0 to 1 for the 'display_errors' setting in your config.php and reload.. it should now show the error from PHP to help you locate the problem.

 
jrslyrics

Joined: 2007-09-26
Posts: 3
Posted: Thu, 2007-09-27 14:44
mindless wrote:
if you get a blank screen there's probably a typo in your code changes... change 0 to 1 for the 'display_errors' setting in your config.php and reload.. it should now show the error from PHP to help you locate the problem.

I will try this. Is the code in 2.2.3 the same as the code that you developed this patch for. In you patch there is a reference to getPluginParameter
That statement doesn't exist in my code that I posted above. That is whats confusing me.

Thanks

Gary

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2007-09-29 06:34

yes, the getPluginParameter has changed to isAnonymousUser since the patch for 2.1 was posted.. the rest of the lines there are still the same, so the new lines should still work.

 
xer1314

Joined: 2007-11-28
Posts: 2
Posted: Wed, 2007-11-28 16:04

Hi,

I have setup the gallery sucessfully to force users to register to view inside album, but it doesnt work properly when i run it from the embedded gallery2 in my joomla CMS site.

Here is the standalone gallery working fine:
http://importmedia.com.au/gallery/main.php

Here is the embedded version running from the Gallery2 Bridge extension for Joomla:
http://importmedia.com.au/index.php?option=com_gallery2&Itemid=33

Anyone help would be great. Thanks

 
xer1314

Joined: 2007-11-28
Posts: 2
Posted: Wed, 2007-11-28 16:11

Hi Again,

Further from my previous post, I would like to know if it is possible to redirect to Joomla's registration page rather than Gallery2's.

That way I can centralise the user database by syncing the two from Joomla's admin (I think, am I right or wrong about this point? Is there a better way?).

Any help would be great. Thanks

 
jschmittat

Joined: 2005-08-28
Posts: 25
Posted: Fri, 2008-03-14 18:44
mindless wrote:
please give more information about what you tried and what happened.
The current code still has the "/* Make sure we have permission to view this item */" block of code in ShowItem.inc...

I just upgraded to version 2.2.4 and wanted, as always after the last updates, to include the four above mentioned lines again. But this time the "Make sure we have permission to view this item" block is missing.

I now added the whole block again:

   if (!$ret && $item->getCanContainChildren()) {
           /* We also need viewSource permission to see the contents of an album */
           $ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.viewSource');
       }
	if ($ret) {
	    if ($ret->getErrorCode() & ERROR_PERMISSION_DENIED) {
		list ($ret2, $isAnonymous) = GalleryCoreApi::isAnonymousUser();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($isAnonymous) {
		    /* Redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		/* Try to redirect to default album */
		list ($ret2, $rootId) = GalleryCoreApi::getDefaultAlbumId();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($item->getId() == $rootId) {
		    /* No permission on root album; redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		return array(null, array('redirect' =>
		    array('view' => 'core.ShowItem', 'itemId' => $rootId)));
	    }
	    return array($ret, null);
	}

Is that alright? It seems to work but I am not sure if it has some unwanted consequences...

 
kraves

Joined: 2008-06-02
Posts: 5
Posted: Mon, 2008-06-02 12:33

jschmittat (& others more masterful than me),

A quick question where in the code did you insert this snippet into ShowItem.inc
or is there now a new place for this patch.
I've got the permissions all ok, just want to do the login prompt or some other message.

Cheers,
Kraves

(G2 vers 2.2.4 core 1.2.0.6)

 
amwallace

Joined: 2008-12-16
Posts: 3
Posted: Tue, 2008-12-16 22:34

I'm actually trying to accomplish this feat using the updated Gallery 2.3. If there is someone that can help me and let me know where to actually place the code in the ShowItem.inc file that would be FANTASTIC. The file now doesn't have the "Make sure have permission..." line. Thanks for the help.

jrslyrics wrote:
I'm trying to accomplish this feature but i am unable to on the version 2.2.3! Has anyone accomplished this ont he latest version. When I add the code above, i just get a blank white screen. HELP!
Here is what my showItems code looks like:

/* Make sure we have permission to view this item */
	$ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.view');
	if ($ret) {
	    if ($ret->getErrorCode() & ERROR_PERMISSION_DENIED) {
		list ($ret2, $isAnonymous) = GalleryCoreApi::isAnonymousUser();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($isAnonymous) {
		    /* Redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		/* Try to redirect to default album */
		list ($ret2, $rootId) = GalleryCoreApi::getDefaultAlbumId();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($item->getId() == $rootId) {
		    /* No permission on root album; redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		return array(null, array('redirect' =>
		    array('view' => 'core.ShowItem', 'itemId' => $rootId)));
	    }
	    return array($ret, null);
	}

	/*

 
amwallace

Joined: 2008-12-16
Posts: 3
Posted: Wed, 2008-12-31 22:08

Is there anyone out there that can help me with the past post?

 
DJSigma

Joined: 2008-12-31
Posts: 2
Posted: Wed, 2008-12-31 23:06

I'm a new user of Gallery 2.3 and want the same functionality originally described at the beginning of the post: Album thumbnails to be visible to guests, but when clicked by a guest prompt them to register.
I read through this thread and the mentioned patch doesn't seem like it will work in 2.3, the showitem.inc appears to have been drastically modified from previous versions. I don't even see references to core.view or core.showitem in the file, so either they have been removed in favor of another method, or they have been buried in another layer.

Anyone have any insight in how to get this to work in 2.3? Or maybe where else to dig around if things have been moved out of showitem.inc?

 
DJSigma

Joined: 2008-12-31
Posts: 2
Posted: Thu, 2009-01-01 19:02

Ok, I was successfully able to get it to work in version 2.3. I copied and pasted the chunk of code at the bottom of this post into the file /modules/core/ShowItem.inc after line 64.
Here is what is on lines 62, 63, 64.

Line 62	if ($ret) {
Line 63	    return array($ret, null);
Line 64	}

Here is the code to copy and paste AFTER line 64:

	   if (!$ret && $item->getCanContainChildren()) {
           /* We also need viewSource permission to see the contents of an album */
           $ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.viewSource');
       }
	if ($ret) {
	    if ($ret->getErrorCode() & ERROR_PERMISSION_DENIED) {
		list ($ret2, $isAnonymous) = GalleryCoreApi::isAnonymousUser();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($isAnonymous) {
		    /* Redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		/* Try to redirect to default album */
		list ($ret2, $rootId) = GalleryCoreApi::getDefaultAlbumId();
		if ($ret2) {
		    return array($ret, null);
		}
		if ($item->getId() == $rootId) {
		    /* No permission on root album; redirect to login view */
		    return array(null, array('redirect' => $gallery->getConfig('loginRedirect')));
		}
		return array(null, array('redirect' =>
		    array('view' => 'core.ShowItem', 'itemId' => $rootId)));
	    }
	    return array($ret, null);
	}

I then set my root album permission's to Guest -> Core View All Versions
I then have 2 sub-albums. I set one of them to Guest -> Core View All Versions and the other to Guest -> Core View Item.

Now when a guest goes to my site they see thumbnails for both albums. When they click on the one with Core View All Versions they are able to view the pictures. When they click on the one with Guest -> Core View Item they are prompted to login/create new account.

 
amwallace

Joined: 2008-12-16
Posts: 3
Posted: Sun, 2009-01-04 00:51

DJSigma.....you're the best

 
budinsky

Joined: 2008-11-20
Posts: 28
Posted: Thu, 2009-12-24 16:16

I would like Everybody to see the Thumbnails so:
How do I get this to work so that the log in screen appears on Item view instead of Album view?

 
budinsky

Joined: 2008-11-20
Posts: 28
Posted: Fri, 2009-12-25 02:14

My gallery is integrated with phpbb3 so I need google to have the ability to view the picture so that the page gets indexed.
Also I noticed that instead of just displaying the login box the page is redirected to the login url.