When using the new quick links image upload link in an album using the 2-11-11 dev build, the image does not go into an album. The link shows that the image should go into the album its's intended for but does not actually do so. It seems to be uploading fine but possibly going into the new "none" category.

Comments

rhylos’s picture

This issue affects the "Add an image" link in the "Add Acidfree items" block as well.

mwheinz’s picture

Confirmed. I should have expected this, actually... the taxonomy doesn't get set up if the taxonomy selector isn't there.

mwheinz’s picture

Fixed.

I changed the code to hide the taxonomy selector, using display:none instead of removing it.

ringomassa’s picture

Actually, in the second patch i submitted this problem was handled in the code:

 function _acidfree_image_node_form_alter(&$form) {
     $vid = acidfree_get_vocab_id();
     $pm = _path_match('node', 'add', 'image', '%d');
     if ($pm[0]) $aid = $pm[0];
     if ($aid) {
       if ($tid = db_result (db_query ("SELECT tid FROM {acidfree_album} WHERE aid='$aid'"))) {
 	$term = taxonomy_get_term ($tid);
 	$form['album'] = array(
 	  '#type' => 'item',
 	  '#title' => t('Album'),
 	  '#value' => $term->name,
 	  '#weight' => -99,
 	);
        // Set the taxonomy $tid
 	$form['taxonomy'][$vid] = array(
 	  '#type' => 'value',
 	  '#value' => $tid,
 	);
       }
     }
 }
mwheinz’s picture

The main problem I have with how you did your patch, Ringo is that you're doing extra database queries that we can avoid by folding the changes into existing functions. Since acidfree_image_form_alter() is already being called anyway, we can save time by putting the code there.

But, yes, making that change would also work - and I do appreciate the work you've done. You figured out how to do it, I just tweaked it for performance.

mwheinz’s picture

Status: Active » Fixed
ringomassa’s picture

StatusFileSize
new1.88 KB
new1 KB

I see your point about the extra query, and didn't realise which existing function you were referring to. However, i don't think it's a good idea to use display CSS to hide data you don't want in the output anyway. Also, this way the taxonomy form will have to be parsed after being submitted which will also reduce performance.
So i looked at the code again and have created two patches that should both be clear and help performance.

* Oops, found that this enables bypassing the checking of permission to upload to an album. Still believe this is the right way to go so i'll look at checking this without performance impact *

ringomassa’s picture

StatusFileSize
new1.96 KB
new1.57 KB

Permission checking is now enabled. Does require some extra code but no DB queries and i suspect the performance loss of the extra code will be offset by less form validation.

mwheinz’s picture

Status: Fixed » Active

Re-opening this till I test Ringo's latest patches.

mwheinz’s picture

StatusFileSize
new2.2 KB

Ringo,

I'm getting errors with this approach on a couple of edge conditions (and I also found problems with my own patch).

If you try to create an album as user #1 (i.e., the web master), or try to edit any album as user #1, you get this error:

warning: array_key_exists() expects parameter 2 to be array, null given in /Users/mheinz/work/acidfree.current/acidfree.module on line 652.

I printed out the arguments for the function, and I got this:

    * Taxonomy: Array ( [#type] => select [#title] => Parent [#default_value] => 17 [#options] => Array ( [] => [0] => stdClass Object ( [option] => Array ( [52] => mwheinz's Acidfree album ) ) [1] => stdClass Object ( [option] => Array ( [53] => -test ) ) [2] => stdClass Object ( [option] => Array ( [17] => Sample Albums ) ) [3] => stdClass Object ( [option] => Array ( [50] => -Test Dummy ) ) ) [#description] => [#multiple] => 0 [#size] => 0 [#weight] => -15 [#theme] => taxonomy_term_select )
    * Value: 17

I have a patch for that, and some minor tweaks - your patch didn't let the user set the parent album for albums created through Create Content->Album, because Taxonomy was still setting a "default value" for those albums.

The new version parses the drupal path used the create the form. If the last part is a number, we assume that the content is being created via one of the acidfree quick links.

I think a similar problem may exist with images. I'm looking at that next.

mwheinz’s picture

StatusFileSize
new2.13 KB

Okay - there were two problems with the image handler.

1. It wasn't filtering the taxonomy when using Create Content.
2. The patch that makes the album name not required was causing a bug in acidfree.module itself.

Both are fixed.

Ringo, check these patches out and see they're good to check in.

ringomassa’s picture

Was not able to check it for a few days but i see you've checked it in. Seems to work very well.
I won't have a lot of time to assist for the next two weeks.

mwheinz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rhylos’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta4
Status: Closed (fixed) » Needs work

While no error messages are presented, on a near production system the images are no longer uploading to the album using the quick links. The image uploads but its not listed in any album, right now the images appear as standalone image nodes.

Possibly related but when Disable album selection for quick links is uncheck the album selector does not show. When checked it does show the name of the intended album but as stated the image is not associated with the album. If this portion is unrelated then it will need to be added to the issue tracker seperately.

mwheinz’s picture

Status: Needs work » Closed (cannot reproduce)

I've just double checked and quick links are working fine.

Possibly related but when Disable album selection for quick links is uncheck the album selector does not show.

You've broken the taxonomy settings for your site.