Item (album/image/???) access(permission) by servername?

galmoid

Joined: 2005-11-07
Posts: 364
Posted: Fri, 2005-12-16 02:20

Is it/would it be possible to assign permissions on a servername
or domainname basis (like group or user)? I'm asking this
prior to going the multi-site route, which seems to be the
only way I can see to achieve something like this.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-16 10:30

what exactly do you mean?
that visitors that come from domain name X have other permissions than visitors that come from Y?

or that your G2 is accessible with 2 different domain names, and if accessed with domain name X you have different guest/registered user permissions than when accessed with domain name Y?

the answer in both cases is: no, that's not possible, not yet. you'd have to hack it somehow.

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Fri, 2005-12-16 15:11

Thank You for your time . . . and Gallery.
Webserver serves domain name X as well as domain name Y.
Single G2 installed with permissions 'Everybody [core] View all versions'.
My interest is to have visiblity/access of albums/items governed by the
domain name (servername) that a visitor is using to access G2 such that
Album One is visible to domain name X; but, not to domain name Y.
Album 2 is visible to domain name Y; but, not domain name X.
Switching which domain name has access to which album could be achieved by
simply changing the permissions.

I'll try and figure out where, in the G2 code, to begin experimenting.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-16 15:40

i'd add a new user, e.g. guestForDomainY then add view permissions to this user.

in init.inc GalleryInitSecondPass(), if user == guest && domain name == Y, then GalleryCoreApi::getUserByUsername('guestForDomainY'); $gallery->setActiveUser($guestUserY);
or something like that

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Fri, 2005-12-16 16:33

valiant,
Thank You for the suggestion. I'll attempt it and report back.

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Fri, 2005-12-16 19:41

valiant,
Maybe just my lameness, but . . . I get:

...Call to undefined function getuserbyusername() in init.inc

I put this in init.inc just after the comment in GalleryInitSecondPass()

if ($serverName == "www.domainY.com") {
 GalleryCoreApi::getUserByUsername('domainYguest');
 $gallery->setActiveUser($domainYguest);
}
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-16 20:16

1. of course you need something like
$serverName = GalleryUtilities::getServerVar('HTTP_HOST');

2. it's fetchUserByUserName and not getUserByUsername
use it like:
list ($ret, $user) = GalleryCoreApi::fetchUserByUserName('domainYguest');
if ($ret->isError) {
return $ret->wrap(__FILE__, __LINE__);
}

$gallery->setActiveUser($user);

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Fri, 2005-12-16 20:33
valiant wrote:
1. of course you need something like
$serverName = GalleryUtilities::getServerVar('HTTP_HOST');
2. it's fetchUserByUserName and not getUserByUsername
use it like:
list ($ret, $user) = GalleryCoreApi::fetchUserByUserName('domainYguest');
if ($ret->isError) {
return $ret->wrap(__FILE__, __LINE__);
}

$gallery->setActiveUser($user);

valiant,
1. Yes, I knew (and did) this; but, Thank You for pointing it out.
2. This worked brilliantly. Performs just as I had hoped.

Thank You for your expertise, time and prompt responses.