This feature doesn't work properly, at least for me it doesn't. If I go to edit account page I have to hit save twice to get the random avatar assigned. After some debugging I find out that at the first save I get only the filename of the avatar and not the full path so my guess is the problem is in avatar_selection_get_random_image that returns just the name and not the path or further "down" in _avatar_selection_image_list. Either this or I did something extremely wrong.

Files: 
CommentFileSizeAuthor
#3 avatar_selection_289481.patch3.52 KBstella

Comments

stella’s picture

Any chance you could try the latest dev version? It may fix your problem.

Cheers,
Stella

tic2000’s picture

    * warning: array_fill() [function.array-fill]: Number of elements must be positive in /home/redluk/public_html/kankand6/includes/database.inc on line 240.
    * warning: implode() [function.implode]: Invalid arguments passed in /home/redluk/public_html/kankand6/includes/database.inc on line 240.
    * 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 ')) ORDER BY weight, name, avatar' at line 1 query: SELECT count(*) FROM avatar_selection avs LEFT JOIN avatar_selection_roles avsr ON avs.aid = avsr.aid LEFT JOIN avatar_selection_og avso ON avs.aid = avso.aid WHERE (avsr.rid IS NULL OR avsr.rid IN (2)) AND (avso.ogid IS NULL OR avso.ogid IN ()) ORDER BY weight, name, avatar in /home/redluk/public_html/kankand6/sites/all/modules/avatar_selection/avatar_selection.module on line 446.
    * warning: array_fill() [function.array-fill]: Number of elements must be positive in /home/redluk/public_html/kankand6/includes/database.inc on line 240.
    * warning: implode() [function.implode]: Invalid arguments passed in /home/redluk/public_html/kankand6/includes/database.inc on line 240.
    * 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 ')) ORDER BY weight, name, avatar LIMIT 0, 999' at line 1 query: SELECT DISTINCT avatar, name, weight FROM avatar_selection avs LEFT JOIN avatar_selection_roles avsr ON avs.aid = avsr.aid LEFT JOIN avatar_selection_og avso ON avs.aid = avso.aid WHERE (avsr.rid IS NULL OR avsr.rid IN (2)) AND (avso.ogid IS NULL OR avso.ogid IN ()) ORDER BY weight, name, avatar LIMIT 0, 999 in /home/redluk/public_html/kankand6/sites/all/modules/avatar_selection/avatar_selection.module on line 448.

This is what I get with the latest dev. Maybe it doesn't like that I have no OG :)

stella’s picture

Status:Active» Fixed
StatusFileSize
new3.52 KB

Fixed in the latest dev release, available later today. The attached patch should fix it.

Cheers,
Stella

tic2000’s picture

Version:6.x-1.4» 6.x-1.x-dev
Status:Fixed» Active

I downloaded today the latest dev. It fixed the problem but I still have one related to assigning a random avatar. If a user has a custom image set as avatar and wants to delete it instead of a new random avatar he gets just a path to the avatar_selection folder.
To fix the problem, in avatar_selection.module from line 339 I changed

<?php
   
if ($user->picture) {
     
$form_state['values']['picture'] = $user->picture;
    }
    else {
     
$form_state['values']['picture'] = avatar_selection_get_random_image($user);
    }
?>

to

<?php
   
if ($user->picture && $form_state['values']['picture_delete'] != '1') {
     
$form_state['values']['picture'] = $user->picture;
    }
    else {
      unset(
$form_state['values']['picture_delete']);
     
$form_state['values']['picture'] = avatar_selection_get_random_image($user);
    }
?>
stella’s picture

Status:Active» Fixed

That's great, thanks! I've committed it to CVS so it should be available in the next dev release later today.

Oh, see http://drupal.org/patch for the next time you need to create a patch for a Drupal module.

Cheers,
Stella

stella’s picture

Released in Avatar Selection 6.x-1.5 and 5.x-2.7.

Cheers,
Stella

tic2000’s picture

good to hear

Anonymous’s picture

Status:Fixed» Closed (fixed)

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