Making <add comments> permission default for new album

crazyknicksfan
crazyknicksfan's picture

Joined: 2003-01-09
Posts: 32
Posted: Fri, 2005-04-22 15:19

Hi everyone,

I was wondering if it is possible to make the <add comments> and <view comments> permissions for Everyone the default for new albums. Currently, if a user registers and a new album is made for them, only the <view all> permission is available. The admin needs to add the <add comment> permission over again for Everyone in order for the option to appear in new albums. Will I have to edit the layout.inc or something in config?? Thanks for any info or help.

-Andrew

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-04-22 16:11

permissions for new albums inherit from the parent album.. if your user albums are created in the top level album then add add/view comment permission on the top level album.

 
crazyknicksfan
crazyknicksfan's picture

Joined: 2003-01-09
Posts: 32
Posted: Fri, 2005-04-22 17:47

I understand the permissions get inherited from the parent album, but that seems to occur only if you manually create the album. When a user registers, I chose the option so that it automatically creates an album for them. These albums do not have the same permissions as the parent album it seems. That's why I had to manually delete and then readd the permissions to the parent album in order for all the newly created albums to have the same permissions. I don't know how to make it so that the automatically created albums will also share the parent's permissions.

-Andrew

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-04-22 22:46

ah, right.. useralbum module clears the permissions so it can put it what was selected in user album site admin (who can view photos, etc..).. the settings there don't have anything about comments. not sure what the right solution is here.. you can certainly modify modules/useralbum/classes/UserAlbumHelper.class to add comment permissions, or make your own module that adds those permissions on any newly created album. But maybe we can modify useralbums slightly so it clears only view permissions to put in place the site admin preference, but inherits other things.

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Fri, 2007-03-02 11:58

Have you manage to change the permission of the useralbum module?

I have the same need.
tks
Florian

 
RWaters
RWaters's picture

Joined: 2007-03-02
Posts: 7
Posted: Fri, 2007-03-02 23:56

I am not sure why, but the User Albums module deletes all permissions when albums are created, rather than inheriting them from the parent album. It would be great to have the option to just inherit permissions from the module admin settings...

I just used a suggestion from this thread ( http://gallery.menalto.com/node/48321 ) and commented out the code that deletes permissions on album creation, seems to work for me. You just have to set your proper permissions in the parent album, and user albums should inherit them:

/* Set permissions.. */
/*
$ret = GalleryCoreApi::removeItemPermissions($albumId);
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret->wrap(__FILE__, __LINE__);
}
*/

______________________
http://www.speedguide.net

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Sat, 2007-03-03 17:21

Could you tell me exactly which line to delete and which lines I have to add?

Or can you copy paste the entire "UserAlbumHelper.class" file. I am unsing Gallery 2.2 RC2

thanks

Florian

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2007-03-04 06:53
Quote:
Have you manage to change the permission of the useralbum module?

yes, what i mentioned in my comment above from april 2005 has in fact been implemented. useralbum sets the view permissions as selected in site admin, but inherits other permissions from the parent album. this is in G2.2.

 
RWaters
RWaters's picture

Joined: 2007-03-02
Posts: 7
Posted: Sun, 2007-03-04 15:11

I'm using G2.2RC1, and the "add comment" and "view comments" permissions I had set were not inheritted - most permissions were just deleted by default. Is that something that was fixed in RC2 ?

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Wed, 2007-03-07 09:19

Could you tell me where to integrate those line?

thanks in advance!

Florian

RWaters wrote:
I am not sure why, but the User Albums module deletes all permissions when albums are created, rather than inheriting them from the parent album. It would be great to have the option to just inherit permissions from the module admin settings...

I just used a suggestion from this thread ( http://gallery.menalto.com/node/48321 ) and commented out the code that deletes permissions on album creation, seems to work for me. You just have to set your proper permissions in the parent album, and user albums should inherit them:

/* Set permissions.. */
/*
$ret = GalleryCoreApi::removeItemPermissions($albumId);
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret->wrap(__FILE__, __LINE__);
}
*/

______________________
http://www.speedguide.net

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2007-03-08 21:25

RWaters, no.. the fix was in RC1 too. It only applies to newly created user albums, not ones that were created before using G2.2. If it is not working, please describe your setup, the steps you are performing and the expected and actual results.

 
RWaters
RWaters's picture

Joined: 2007-03-02
Posts: 7
Posted: Sun, 2007-03-11 20:49

mindless... I initially installed a typical 2.1.2, then added modules (including User Albums), then upgraded to 2.2 RC1.

The only notable settings that I've changed are that I added a couple of new groups, and I assigned them different comments permissions: 2 groups with view/add permissions, and one group with all comments permissions.

I have a number of people visiting the gallery and albums created for them, but I had to go dig into the class file and remove those lines in order to have the permissions inherited for some reason. I believe that the albums created in G2.2 RC1 did not have the permissions inherited either, although you are right, some of the albums may have been created in 2.1.2, I can't be 100% certain.

______________________
http://www.speedguide.net

 
RWaters
RWaters's picture

Joined: 2007-03-02
Posts: 7
Posted: Sun, 2007-03-11 20:50
tomsawyer123 wrote:
Could you tell me where to integrate those line?

thanks in advance!

Florian

In this class file: modules/useralbum/classes/UserAlbumHelper.class

______________________
http://www.speedguide.net

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Mon, 2007-03-12 09:42
RWaters wrote:
tomsawyer123 wrote:
Could you tell me where to integrate those line?

thanks in advance!

Florian

In this class file: modules/useralbum/classes/UserAlbumHelper.class

______________________
http://www.speedguide.net

I am using the latest version of the useralbum module and I can't find the line above:

here is my file (modules/useralbum/classes/UserAlbumHelper.class)

Quote:
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2007 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/

/**
* A helper class for user albums
* @package UserAlbum
* @subpackage Classes
* @author Alan Harder <alan.harder@sun.com>
* @version $Revision: 15513 $
* @static
*/
class UserAlbumHelper {

/**
* Create a new user album
*
* @param object GalleryUser $user new user
* @return object GalleryStatus a status code
*/
function createUserAlbum($user) {
list ($ret, $core) = GalleryCoreApi::fetchAllPluginParameters('module', 'core');
if ($ret) {
return $ret;
}
list ($ret, $module) = GalleryCoreApi::fetchAllPluginParameters('module', 'useralbum');
if ($ret) {
return $ret;
}

/* Create album.. */
$albumTitle = trim($user->getFullName());
if (empty($albumTitle)) {
$albumTitle = $user->getUserName();
}
$albumName = $user->getUserName();
while (true) {
list ($ret, $album) = GalleryCoreApi::createAlbum(
$module['targetLocation'], $albumName, $albumTitle, '', '', '');
if (!$ret) {
break;
}
if ($ret->getErrorCode() & ERROR_COLLISION) {
$albumName .= '_';
} else {
return $ret;
}
}

list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($album->getId());
if ($ret) {
return $ret;
}

/* Set owner.. */
$album->setOwnerId($user->getId());
$ret = $album->save();
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}
$albumId = $album->getId();

/* Set permissions.. */
list ($ret, $permissions) = GalleryCoreApi::fetchAllPermissionsForItem($albumId, true);
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}
$visited = array();
foreach ($permissions as $permission) {
/* don't bother for administrator group */
if (empty($permission['groupId']) || $permission['groupId'] != $core['id.adminGroup']) {
/* remove all view permissions at once */
if (strstr($permission['permission'], 'core.view') ||
($permission['permission'] == 'core.all')) {
if (!empty($permission['groupId']) && empty($visited[$permission['groupId']])) {
$ret = GalleryCoreApi::removeGroupPermission($albumId,
$permission['groupId'], 'core.viewAll');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}
$visited[$permission['groupId']] = 1;
} else if (!empty($permission['userId'])
&& empty($visited[$permission['userId']])) {
$ret = GalleryCoreApi::removeUserPermission($albumId,
$permission['userId'], 'core.viewAll');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}
$visited[$permission['userId']] = 1;
}
}
}
}
$ret = GalleryCoreApi::addUserPermission($albumId, $user->getId(), 'core.all');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}

$viewPermissions = $module['fullSize'] ? array('core.viewAll')
: array('core.view', 'core.viewResizes');
switch ($module['view']) {
case 'everybody':
$groupId = $core['id.everybodyGroup'];
break;
case 'allusers':
$groupId = $core['id.allUserGroup'];
break;
}
if (isset($groupId)) {
foreach ($viewPermissions as $permission) {
$ret = GalleryCoreApi::addGroupPermission($albumId, $groupId, $permission);
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}
}
}

$ret = GalleryCoreApi::releaseLocks($lockId);
if ($ret) {
return $ret;
}

/* Record id of album */
$ret = GalleryCoreApi::setPluginParameter(
'module', 'useralbum', 'albumId', $albumId, $user->getId());
if ($ret) {
return $ret;
}

return null;
}
}
?>

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2007-03-12 19:33

RWaters, maybe the 2.2 package you got did not include the useralbum module, and you're still using the G2.1 version of useralbum?

 
RWaters
RWaters's picture

Joined: 2007-03-02
Posts: 7
Posted: Tue, 2007-03-13 12:54

Seems that way... I have version 1.0.3 of User Albums installed for some reason, maybe I downloaded it from the 2.1.2 modules list initially... And it never got upgraded (since I downloaded the "typical" 2.2 version)

I suppose I should try the 1.0.4 version, I'm just a bit uneasy after the time I had to spend with 1.0.3 to make it work for me.

______________________
http://www.speedguide.net

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Tue, 2007-03-13 18:14

Could you make me a ZIP of the module you use so that I can have the correct behaviour for permission.

tks

Florian

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Fri, 2007-03-16 16:48

I have found a version of the useralbum version 1.0.3 and I have removed those line.

Quote:
/* Set permissions.. */
/*
$ret = GalleryCoreApi::removeItemPermissions($albumId);
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret->wrap(__FILE__, __LINE__);
}
*/

And when the useralbum is created is still ave all the right.

any idea why?

RWaters,
would you mind sharing your useralbum module?

I really need to solve this problem quikly.
Thanks in advance for your help.

Florian

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2007-03-17 14:37

maybe try gallery 2.2?

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Sun, 2007-03-18 21:21
mindless wrote:
maybe try gallery 2.2?

Does not make any difference, the useralbum have all the permission.

I have also try the solution describe here
using "simple.basic" to add, upload and delete command for the simple module.

but it does not work. it gives me a blank page when I click on "Your album".

Please help me.

Florian

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2007-03-19 19:32

what steps did you try, what happened, and what did you expect to happen?

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Mon, 2007-03-19 23:31
mindless wrote:
what steps did you try, what happened, and what did you expect to happen?

what did you expect to happen?
I would like the album created with useralbum module to give album owners only simple module permissions (create album; edit : edit all; delete) + for registered users to have the following permission : Add comments , view comments.

What did I have achieve
I have activate the useralbum module 1.0.5, the simple module 0.2.0 and the JensPermsModule so that when I create an album it only gives simple module permissions and It worked.

My problem
When the album is created by the useralbum module, it gives the owner all the core permissions.

what steps did you try

Test 1: modules actives: useralbum + simple module
Try to autocreate useralbum in an parent with restricted permission set to all the simple module permission: create album; edit : edit all; delete
Result: album created with all the permission

Test 2: modules actives: useralbum + simple module + JensPermsModule
Try to create an album in a parent album with restricted permission set to all the simple module permission: create album; edit : edit all; delete
Result: ok ; album is created with simple module permissions

Test 3: modules actives: useralbum + simple module + JensPermsModule
Try to autocreate (using useralbum module) an album in a parent album with restricted permission set to all the simple module permission: create album; edit : edit all; delete
Result: KO ; album is created with all core permissions

Test 4: modules actives: useralbum + simple module + JensPermsModule
Same as test 3 with modifying useralbum/classes/UserAlbumHelper.class by supressing

Quote:
$ret = GalleryCoreApi::addUserPermission($albumId, $user->getId(), 'core.all');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}

Result: useralbum is created with restricted permissions of the simple module (create album; edit : edit all; delete) but all registred user can also add album and item in the created album. How can i allow only the useralbum creator to add picture and album in his album?

thanks

Florian

 
tomsawyer123
tomsawyer123's picture

Joined: 2002-07-24
Posts: 81
Posted: Wed, 2007-03-21 11:05

I manage to solve (test4) by changing useralbum/classes/UserAlbumHelper.class

Quote:
$ret = GalleryCoreApi::addUserPermission($albumId, $user->getId(), 'core.all');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}

to

Quote:
$ret = GalleryCoreApi::addUserPermission($albumId, $user->getId(), 'simple.create');
if ($ret) {
GalleryCoreApi::releaseLocks($lockId);
return $ret;
}