The current bug is that any user with "create acidfree photos" (for example) can specify any album as the parent, whether they created the album or not. However, if a user is browsing an album that he has not created, he is not presented with the option to add nodes to that album. This is inconsistent behavior.

The patch I am providing will define a new permission: 'can upload to any album'

_acidfree_parent_select() has also been modified to use this permission to filter out albums the user did not create (unless they have been granted the proper permission, of course).

There is a third change necessary in the class_album.inc file, but that must be listed separately. It is one-line change that will allow the "add a img", etc. links to display if the user has been granted the 'can upload to any album' permission, and not only to the creator of the album.

Overall, I see this as a great feature for Acidfree: the ability to restrict users to their own albums, while at the same time granting others broader privileges.

Comments, anyone?

Comments

a.k.karthikeyan’s picture

gr8 patch thanx

Lityi’s picture

This is more than a brilliant idea! I just need this feature!

Could you please provide us a patched module?

Secondly: it is possible to show only the user's albums' list in the Albums: pulldown when they want to upload images?

coreyp_1’s picture

Yes, this patch will filter the "Parent" listbox so as to only show albums created by the user (if the option is selected, that is).

As for the patch, it is attached to the first post. Now, we're just waiting for others to review it, post their comments, and make any modifications.

I'll be out of town for a few days, so this is my last post until Saturday.

-Corey

jgavin’s picture

Sorry for the lame question, but how do i install the patch? (where does it go, etc.?) The idea sounds great and is exactly what im looking for.

Lityi’s picture

after taking out the C:\... windows paths from the patch I tried to use it:

patch -p0 < acidfree.module.patch.01
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- acidfree.module.bak Tue Apr 25 10:01:04 2006
|+++ acidfree.module Tue May 30 15:29:51 2006
--------------------------
Patching file acidfree.module using Plan A...
Hunk #1 failed at 495.
Hunk #2 failed at 1778.
2 out of 2 hunks failed--saving rejects to acidfree.module.rej
done

any ideas are appreciated :/

Lityi’s picture

eh, sorry:

#patch < acidfree.module.patch.01     
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- acidfree.module.bak        Tue Apr 25 10:01:04 2006
|+++ acidfree.module    Tue May 30 15:29:51 2006
--------------------------
Patching file acidfree.module using Plan A...
Hunk #1 failed at 495.
Hunk #2 failed at 1778.
2 out of 2 hunks failed--saving rejects to acidfree.module.rej
done
coreyp_1’s picture

StatusFileSize
new101.4 KB

OK, here is a patched module. Maybe someone else who has more experience making patches can provide an "official" working patch.

For everyone else, you can see the end result here.

sanduhrs’s picture

Your patch applied fine for me.
That is exactly the funcionality I've been searching for, thanks.

Did you post this third change necessary in the class_album.inc file anywhere?
vg

coreyp_1’s picture

The change necessary in class_album.inc is on line 162, in the theme_acidfree_print_full_album($node) function.

Replace

    $show_box = node_access('update', $node);

With this (comment included to show my logic):

    $galtype = variable_get('acidfree_galtype', 0);
    global $user;
    // show the box if: 1. galtype is "collective", and user can upload to any album
    //                  2. user has update privilege, and user is node creator
    $show_box = (!$galtype && user_access('can upload to any album'))
      || (node_access('update', $node) && ($node->uid == $user->uid));

I hope that makes sense...

-Corey

vhmauery’s picture

StatusFileSize
new25.42 KB

After many hours of coding, I have incorporated this patch into a larger patch of my own. The resulting patch is available for testing now. Note that the patch is not fully functional and will not be committed to CVS yet, but I would like some feedback before spending more time in this area.

The patch adds some features:

  • Per-album settings. This is not fully implemented yet, but you can see the world of possibilities opening up here.
  • My albums. If enabled in the admin/settings/acidfree page, each user will automatically get their own root album.
  • Post to any album capability. Now a user group can be assigned the capability to be able to post to any album.
  • Shared albums. A user can decide whether or not to let others post to an album he owns.

Try the patch out on a developement machine and tell me what you think.

Mojah’s picture

Title: Turn a bug into a feature » Certain hunks fail on patch
StatusFileSize
new4.53 KB

Thank you for the patch. I tried applying it on cygwin and got the message that 5 out of 33 hunks failed.

I've attached the failed hunks.

Mojah’s picture

Title: Certain hunks fail on patch » Feedback

From searching the forums and reading user submitted comments, it appears that your patch will be very much appreciated by the community. We are currently working on a student social networking site which allows users to have their own user gallery and cannot find a clear cut way to achieve this within Drupal.

I noticed you have shared albums...it would be cool to include the following as well..

* Allow user to mark the album accessible by anonymous or authenticated users and other role types
* Turn off comments on a photo

vhmauery’s picture

Title: Feedback » Turn a bug into a feature

The patch probably won't apply unless you grab the latest and greatest Acidfree tarball. I committed some changes yesterday that would make the patch not apply. So grab the latest and try it out. (really it should work even with those five chunks not applied.)

Mojah,
As for your feedback, your two feature requests are both already available in drupal. The first is done with a node_access module (e.g. simple access, or organic groups). The second is done by allowing the user the appropriate access right in admin/access.

Mojah’s picture

Title: Turn a bug into a feature » correction

Hi, the patch you made updated perfectly without any failed hunks (just like you said) when I used the cvs web interface to download the acidfree.module file. The tarbell on the modules download page for cvs version does not contain the latest acidfree.module file (I think it takes 24-48hrs to update) and strangely the web cvs viewer shows that the the module file was updated 3 weeks ago. Yet when I click to view the module, the comments indicate that it was updated 17hrs ago. Weird.

I'll test it out and let you know how it goes. Thanks.

Mojah’s picture

Title: correction » Follow up on patch

Hi,

I patched the module files and uploaded. Ran update.php and found that no database updates were requried.

...replaced line 1399 with this from the previous version...

$class_debug = $acidfree_base.DIRECTORY_SEPARATOR.'class_debug.inc';
if (file_exists($class_debug))
require_once($class_debug);

...logged in as an authenticated user and created an album. Worked fine. Uploaded a picture which worked fine except for the following error...

user warning: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' CHAR), 10, '0')) < '55555555559999999903'' at line 1 query: SELECT COUNT(nid) FROM node n INNER JOIN acidfree ON acidfree.aid = n.nid INNER JOIN acidfree_hierarchy ON child = aid WHERE (n.moderate = 0 AND n.status = 1) AND class <> 'album' AND parent=94 AND CONCAT(LPAD(CONVERT(5555555555 + acidfree.weight, CHAR), 10, '0'), LPAD(CONVERT(9999999999 - .aid, CHAR), 10, '0')) < '55555555559999999903' in /hsphere/local/home/studyrom/test.studyromania.com/includes/database.mysql.inc on line 120.

Is this something to do with my mysql version or php version?

The pic was uploaded to the correct album and it worked fine except for the above....

Are there anyplans for the the ajax functionality like the file attachments on nodes?
Multiple photo upload for users...maybe it could work just like the node attachments and automatically assign each picture to a node which the user could then edit or add description to.

One Love

vhmauery’s picture

Title: Follow up on patch » Turn a bug into a feature
vhmauery’s picture

Status: Needs review » Needs work

thanks for finding the sql error -- looks like a bit of legacy code from my original patch that sneaked in the back door.

I am still working to test that all the features promised actually do work (this includes figuring out how the database updates work.)

It still might be a while since work is a little crazy at the moment.

vhmauery’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new26.13 KB

Here is what I think is the final version of the patch. I figured out the database updates stuff. All the features promised are working.

I need some people to test this out. Until this gets tested, I don't feel good releasing it. Please note that this patch was made against the latest and greatest acidfree from my svn tree -- it should apply cleanly to the latest 4.7 branch of CVS. Please test it out!

muddy’s picture

Hi,

Having patched the acidfree module, I'm getting this error when I try to create acidfree content.

* user warning: Unknown column 'share' in 'field list' query: SELECT class,large,small,thumb,weight,visited,votes,share FROM acidfree WHERE aid = 166 in E:\apache2triad\htdocs\drupal\includes\database.mysql.inc on line 120.
* user warning: Unknown column 'share' in 'field list' query: SELECT class,large,small,thumb,weight,visited,votes,share FROM acidfree WHERE aid = 209 in E:\apache2triad\htdocs\drupal\includes\database.mysql.inc on line 120.
* user warning: Unknown column 'a.share' in 'where clause' query: SELECT n.nid FROM node n LEFT JOIN acidfree a ON n.nid = a.aid WHERE a.class='album' AND n.uid!=8 AND a.share=0 in E:\apache2triad\htdocs\drupal\includes\database.mysql.inc on line 120.
* warning: in_array(): Wrong datatype for second argument in E:\apache2triad\htdocs\drupal\modules\acidfree\acidfree.module on line 1975.
* warning: in_array(): Wrong datatype for second argument in E:\apache2triad\htdocs\drupal\modules\acidfree\acidfree.module on line 1975.

Of course, I could be doing many things wrong. I'm new to this.

drupal 4.7.3
acidfree.module (August 10, 2006 - 19:46)
patch: album_options-r347.patch.txt

thanks.
-michael miller (michael@muddys.net)

vhmauery’s picture

muddy,

You need to run update.php after patching acidfree -- in the patch are some changes to the database's acidfree table.

Thanks for testing this out.

muddy’s picture

After running the update.php script, here's the error message I get:

user warning: Unknown column 'share' in 'field list' query: SELECT class,large,small,thumb,weight,visited,votes,share FROM acidfree WHERE aid = 166 in E:\apache2triad\htdocs\drupal\includes\database.mysql.inc on line 120.

Thanks for your attention!

vhmauery’s picture

muddy,

On the update.php page, there is a link to 'run the database upgrade script', which you should click on. Then, it will give you a form that has a collapsed 'Select Versions' fieldset. Make sure '2' is selected in the Acidfree Module selector. Hit the Update button and it should take you to the results page. On results page, it should tell you it successfully executed this query:

ALTER TABLE {acidfree} ADD share TINYINT(1) NOT NULL DEFAULT '0'
muddy’s picture

vhmauery,

that did resolve the issue. the upgrade script ran well - after i edited my file permissions.

thank you for your patient support.

Mojah’s picture

Quick report on patch...

Hi Vernon,

Thank you for the gr8 work. I downloaded your latest and gr8est from the web cvs directory (cvs tarbell appears outdated) and updated all the 4.7 branch files then applied your patch.

I'm getting this error when trying to create an acid free photo.

Running 4.73 on mysql 4.1x

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' CHAR), 10, '0')) < '55555555559999999994'' at line 1 query: SELECT COUNT(nid) FROM node n INNER JOIN acidfree ON acidfree.aid = n.nid INNER JOIN acidfree_hierarchy ON child = aid WHERE (n.moderate = 0 AND n.status = 1) AND class <> 'album' AND parent=1 AND CONCAT(LPAD(CONVERT(5555555555 + acidfree.weight, CHAR), 10, '0'), LPAD(CONVERT(9999999999 - .aid, CHAR), 10, '0')) < '55555555559999999994' in /home/khanyi/domains/intstudent.net/public_html/test/includes/database.mysql.inc on line 120.

One Love

vhmauery’s picture

Mojah, contrary to popular belief, the HEAD branch of CVS is not the latest and greatest. Eventually, I will merge my changes and fixes into HEAD and then do the necessary 4.8 updates before I branch it again. The 4.7 tarball is what you want to be running. If you want to use CVS, make sure you are using the DRUPAL-4-7 branch (that is what the 4.7 tarball is generated from every 12 hours or so).

Mojah’s picture

Thanks for explanation on HEAD and CVS. 4.7 tarbell works. Patch applied without any errors. I have installed category module and views with the aim of presenting user galleries and allowing users to tag their pics and albums.

So far I noticed these while testing...

in_array(): Wrong datatype for second argument in /home/khanyi/domains/mydomain.net/public_html/test/modules/acidfree/acidfree.module on line 1998

I remember seeing something related to Missing argument 1 for _acidfree_content_sort_clause() in /home/khanyi/domains/mydomain.net/public_html/test/modules/acidfree/acidfree.module on line 2702. error. I'll list it here just in case it's not been mentioned elsewhere, but will post back if I find anything.

user warning: Unknown column 'a.share' in 'where clause' query: SELECT n.nid FROM node n LEFT JOIN acidfree a ON n.nid = a.aid WHERE a.class='album' AND n.uid!=2 AND a.share=0 in /home/khanyi/domains/intstudent.net/public_html/test/includes/database.mysql.inc on line 120. 

The above appeared when creating an album as an authenticated user.

May not be related to the acidfree module, but I found it strange, when submitting an image with file size of 500kb I got insufficient memory errors. I reset php.ini to 25M and seem to get this error every now then. Could be related to my vps account.

vhmauery’s picture

I seem to forever be plagued with the in_array/array_keys errors. I can't seem to get acidfree_types initialized correctly, it seems.

As for the unknown column 'share', error, that is caused because you haven't run the drupal update.php script. This patch adds a new column to the acidfree table.

A 500KB image very well may be too big. Jpeg compression makes the image small on disk, but when doing the actualy image manipulation, the image has to be decompressed into something like 3 or 4 bytes per pixel (depending on various parameters). This makes a 1600x1200 image a cool 7.5MB in memory. And this doesn't take into account that usually with image manipulation, we end up with several different images as stages in memory before finally writing out the final image to disk. That same 1600x1200 image might be 128kB on disk. The file size is not what is important, it is the image resolution.

And finally, I have heard reports that the Drupal GD image toolkit uses more memory per image than the Imagick image toolkit that I have supplied with the Acidfree distribution. However, this requires the php-imagick php extension to work, which not everyone has access to (I use debian and found someone that had already built it into a package, while others might have to build it from source.)

vhmauery’s picture

Status: Reviewed & tested by the community » Fixed

I have committed this patch to CVS DRUPAL-4-7 branch. Make sure that after you download the latest version of acidfree, you run the database update script. This should be available in 12 hours or so as version 1.62.2.43.

vhmauery’s picture

Status: Fixed » Closed (fixed)