Remove "edit permissions" when user add subAlbum

nanodreams

Joined: 2007-10-29
Posts: 3
Posted: Mon, 2007-10-29 19:01

Hello

I would like to remove the "edit permissions" options when a user add a new Album.

Anybody know how make it,

Thanks,

 
25PSi

Joined: 2004-11-28
Posts: 16
Posted: Wed, 2007-10-31 22:39

I am in the same boat. I REALLY wish users had no such ability to edit their albums as it seems to be confusing to "Average Joe". I'd much rather prefer that newly created albums by users would inherit permissions and settings of "Parent" album. Kind of "Dumb Out" regular default user and save them from themselves.

Can anyone shine some light on this for us? Pls?

Thanks

Eugene

 
25PSi

Joined: 2004-11-28
Posts: 16
Posted: Tue, 2007-11-06 16:22

c'mon guys! Please!!!! Someone HAS to know!!! Plz? Pretty please?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-11-06 17:05

please google the question, it has been discussed before.

i guess you'll need the "jens permissions" module or your own module to dynamically set permissions of new albums as they are created.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
nanodreams

Joined: 2007-10-29
Posts: 3
Posted: Wed, 2007-11-07 15:37

Hello finally I find the code to make it.

Open and edit <install dir>/modules/core/ItemAddAlbum.inc
Find
$ret = GalleryCoreApi::addUserPermission($instance->getId(),
$instance->getOwnerId($
'core.all', false);
Append after
$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.changePermissions',false);

This code remove de "Edit Permissions" only in the album, but if you view a photo y can change the permissions, to remove this option,
Open and edit <install dir>/modules/core/ItemAdd.inc
Find
$ret = GalleryCoreApi::addUserPermission($album->getId(), $album->getOwnerId(),
'core.all', false);
Append after
$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.changePermissions',false);

It's all.

 
25PSi

Joined: 2004-11-28
Posts: 16
Posted: Thu, 2007-11-08 23:56

DUDE!!!! U AWESOME! This IS DA SHIZLE!!! I am just really excited that it worked out. Works great!
Thanks so very much!

Now, think you can figure out how to lock them out of Album Edit/Picture Edit once new album/picture had been created?
THAT would make my life perfect LOL

Eugene

 
nanodreams

Joined: 2007-10-29
Posts: 3
Posted: Mon, 2007-11-12 08:15

Hello 25PSi
If you want to remove other options of de sideBar y only add another line like the example modify de options. For example if you want to remove de posibility that the user can remove his own photos, you must add this code.

$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.delete',false);

If you want to remove the option "Edit", you must add this code

$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.edit',false);

 
steve27

Joined: 2007-11-16
Posts: 1
Posted: Wed, 2007-12-12 13:23

Hello nanodreams,

I would like to remove the 'Edit Album' feature in the 'Side Bar' so that the Album User is restricted from editing his Album. Can you tell me what file I need to add your line of code to? You noted the required line of code in your earlier posts (discussions) with 25PSi? Please see below, i.e.,

$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.edit',false);

I was successful editing the ItemAdd.inc , and the ItemAddAlbum.inc files concerning the 'Edit Permissions' and the 'change permissions' modifications.

Your code modifications worked perfectly!!

Thanks so much for your assistance.

Steve

nanodreams wrote:
Hello 25PSi
If you want to remove other options of de sideBar y only add another line like the example modify de options. For example if you want to remove de posibility that the user can remove his own photos, you must add this code.

$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.delete',false);

If you want to remove the option "Edit", you must add this code

$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.edit',false);

 
marcap

Joined: 2007-12-06
Posts: 14
Posted: Wed, 2007-12-12 14:16

Hello nanodreams,
everything fine with the ItemAdd.inc , and the ItemAddAlbum.inc, but I noticed something: I loged into my site as an usual user and created an Album with Items inside it before and after pasting your code.
What's happen is this: after your code is in, the "edit permission" is not anymore visible, and it is OK
but in the album I created first your code in, the "edit permission" is still there.
Is it normal? How come it affects only the new albums and items and not the old ones?

 
CoolDreamZ

Joined: 2007-12-21
Posts: 1
Posted: Fri, 2007-12-21 10:47

Thanks :-)

 
Nuckes

Joined: 2008-01-22
Posts: 7
Posted: Wed, 2008-01-23 23:12

that works fine

Thanks a lot

Can i do that also with the move album and move photo permission?

 
trumpy81

Joined: 2004-12-19
Posts: 15
Posted: Sun, 2008-02-03 11:46

GDay All,

I added the following to ItemAddAlbum.inc and whenever a user adds an album instead of going to the Edit Album page, he/she gets a security violation message.

The album is created and one can add files etc, but there is no option to edit the album either in the dropdown box or the sidebar which is exactly what I wanted.

I would simply like to skip the security violation message. Anyone know how I could do that?

Added Code (ItemAddAlbum.inc):

$ret = GalleryCoreApi::removeUserPermission($instance->getId(),
$instance->getOwnerId(),
'core.edit',false);

TIA

Regards
trumpy81

 
Pishare

Joined: 2008-12-15
Posts: 25
Posted: Wed, 2008-12-17 06:57

<install dir>/modules/core/ItemAdd.inc
<install dir>/modules/core/ItemAddAlbum.inc

Hi,in G2 2.3,i can't find the code in the two files.

Quote:
$ret = GalleryCoreApi::addUserPermission($instance->getId(),$instance->getOwnerId($'core.all', false);

and

Quote:
$ret = GalleryCoreApi::addUserPermission($album->getId(), $album->getOwnerId(),'core.all', false);

where can find it?

 
solei

Joined: 2009-02-13
Posts: 2
Posted: Fri, 2009-02-13 21:05

I've been banging my head against this for the last 4-5 hours, but I've got a working solution for Gallery 2.3.

In file %installdir%/modules/core/ItemAddAlbum.inc:
Look for:

/* Figure out where to redirect upon success */
$redirect['view'] = 'core.ShowItem';
$redirect['itemId'] = $instance->getId();

And add this under it:

// Adding these lines to change permissions on album creation.
	// Get the newly created album's id
	$TheItemID = $instance->getId(); 		
	// Get the ownerid of the newly created album
	$TheUserID = $instance->getOwnerId(); 	

	// Remove the "All Access" permission from the owner
		GalleryCoreApi::removeUserPermission($TheItemID, $TheUserID, 'core.all');
	
	// Don't forget to remove any permissions from the owner's groups!
		// (this one specifically denies new albums in this album for group '49')
		GalleryCoreApi::removeUserPermission($TheItemID, '49', 'core.addAlbumItem');  

	// Add the permissions you want the user to have!
		// Allow the user to delete this album
		GalleryCoreApi::addUserPermission($TheItemID, $TheUserID, 'core.delete');

		// Allow the user to add items to this album
		GalleryCoreApi::addUserPermission($TheItemID, $TheUserID, 'core.addDataItem');

Once you've done this, you'll need to change the code directly below it:

		if (empty($ret)) {		   
		   $redirect['view'] = 'core.ItemAdmin';
		   $redirect['subView'] = 'core.ItemEdit';
		   $redirect['editPlugin'] = 'ItemEditItem';
		}

Replace it with this:

		if (empty($ret)) {
			$redirect['view'] = 'core.ShowItem';
			$redirect['itemId'] = $instance->getId();
		
		   // Commenting these out, since after changing permissions, 
		   // the owner doesn't have access to the edit page these 
		   // forward you to. D:
		   // $redirect['view'] = 'core.ItemAdmin';
		   // $redirect['subView'] = 'core.ItemEdit';
		   // $redirect['editPlugin'] = 'ItemEditItem';
		}

Good luck everyone!

 
smilem

Joined: 2009-02-25
Posts: 118
Posted: Sun, 2009-03-01 18:12

Hi, just tried this on gallery-2.3-typical-en.

My file ItemAddAlbum.inc has different lines in it:

/* Figure out where to redirect upon success */
$redirect['itemId'] = $instance->getId();
$ret = GalleryCoreApi::assertHasItemPermission($instance->getId(), 'core.edit');
if (empty($ret)) {
$redirect['view'] = 'core.ItemAdmin';
$redirect['subView'] = 'core.ItemEdit';
$redirect['editPlugin'] = 'ItemEditAlbum';
}

Trie to make it like above but "edit permissions" link is still there in album, in photos on left side bar.
HELP.

 
solei

Joined: 2009-02-13
Posts: 2
Posted: Mon, 2009-03-02 06:47
smilem wrote:
Hi, just tried this on gallery-2.3-typical-en.

My file ItemAddAlbum.inc has different lines in it:

/* Figure out where to redirect upon success */
$redirect['itemId'] = $instance->getId();
$ret = GalleryCoreApi::assertHasItemPermission($instance->getId(), 'core.edit');
if (empty($ret)) {
$redirect['view'] = 'core.ItemAdmin';
$redirect['subView'] = 'core.ItemEdit';
$redirect['editPlugin'] = 'ItemEditAlbum';
}

Trie to make it like above but "edit permissions" link is still there in album, in photos on left side bar.
HELP.

You have the lines there.

First edit

		/* Figure out where to redirect upon success */
		$redirect['itemId'] = $instance->getId();
		$ret = GalleryCoreApi::assertHasItemPermission($instance->getId(), 'core.edit');

Second edit:

		if (empty($ret)) {
		    $redirect['view'] = 'core.ItemAdmin';
		    $redirect['subView'] = 'core.ItemEdit';
		    $redirect['editPlugin'] = 'ItemEditAlbum';
		}

Keep in mind, this will only apply permissions to items created after you've made the mod- you have to manually set permissions on all other items and galleries.

 
smilem

Joined: 2009-02-25
Posts: 118
Posted: Fri, 2009-10-23 19:40

How do I make the selection:

"Add photo to Cart"

To appear under albums too? I would like that it would be possible to add entire album to cart.

I have checked the "Treat Albums as collections of contained images?" checkbox

And I think this is because I use this modification that users can't see another user galleries.
I use edited ItemAddAlbum.inc from Core module and UserAlbumHelper.class from useralbum module

I use Checkout module 0.4.3
Checkout by Email 0.4.0

see my thread here http://gallery.menalto.com/node/91975

 
drjay

Joined: 2010-05-10
Posts: 1
Posted: Mon, 2010-05-10 17:39

Bit of an old one, but I couldn't find a clear answer to this anywhere. I was looking for a way to remove the 'edit permissions' section for all new members using the user albums plugin. bharat on the IRC channel was gracious enough to help. So here's the simple fix for 2.3.1:

Edit /modules/useralbum/classes/UserAlbumHelper.class
Find:

Quote:
/* Make sure the album owner has core.all permissions */
$ret = GalleryCoreApi::addUserPermission($albumId, $user->getId(), 'core.all');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}

Add just under it:

Quote:
GalleryCoreApi::removeUserPermission($albumId, $user->getId(), 'core.changePermissions');