/[drupal]/contributions/modules/avatar_blocks/avatar_blocks.module
ViewVC logotype

Diff of /contributions/modules/avatar_blocks/avatar_blocks.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Thu Jul 24 01:53:14 2008 UTC revision 1.2, Tue Sep 9 20:42:08 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id:$  // $Id: avatar_blocks.module,v 1.1.2.2 2008/08/04 21:59:34 roopletheme Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 8  Line 8 
8    
9  define('AVATAR_BLOCKS_WHOS_ONLINE', 0);  define('AVATAR_BLOCKS_WHOS_ONLINE', 0);
10  define('AVATAR_BLOCKS_WHOS_NEW', 1);  define('AVATAR_BLOCKS_WHOS_NEW', 1);
11  define('AVATAR_BLOCKS_MY_BUDDYLIST', 2);  define('AVATAR_BLOCKS_USER_ROLES', 2);
12    define('AVATAR_BLOCKS_MY_BUDDYLIST', 3);
13    
14    function avatar_blocks_admin() {
15      $instructions = 'To configure the invididual blocks, visit the '. l( 'Blocks Page', 'admin/build/block'). '.';
16      $form['avatar_blocks_instruct'] = array(
17        '#value' => $instructions,
18      );
19      if (module_exists('imagecache') && imagecache_presets()) {
20        $preset_options = array(t('None'));
21        foreach (imagecache_presets() as $preset) {
22          $preset_options[] = $preset['presetname'];
23        }
24        $preset_index = array_search(variable_get('avatar_blocks_default_icpreset',  ''), $preset_options);
25        $form['avatar_blocks_default_icpreset'] = array(
26          '#type' => 'select',
27          '#title' => t('Default Imagecache Preset'),
28          '#description' => t("Select the default Imagecache preset to apply to the avatars. You can override this on a per-block basis."),
29          '#options' => $preset_options,
30          '#default_value' => $preset_index,
31        );
32      }
33    
34      $form['avatar_blocks_role_block'] = array(
35        '#type' => 'checkbox',
36        '#title' => t('Enable Avatars by Role block'),
37        '#default_value' => variable_get('avatar_blocks_role_block', 1),
38      );
39      if (module_exists('buddylist')) {
40        $form['avatar_blocks_buddylist_block'] = array(
41          '#type' => 'checkbox',
42          '#title' => t('Enable Buddylist Avatars block'),
43          '#default_value' => variable_get('avatar_blocks_buddylist_block', 1),
44        );
45      }
46    // add an additional submit handler to the #submit array.
47    // use array_merge to make sure the new handler is the first one in the array
48      if (is_array($form['#submit'])) {
49        $form['#submit'] = array_merge(array("avatar_blocks_admin_submit" => array()), $form['#submit']);
50      }
51      else {
52        $form['#submit'] = array("avatar_blocks_admin_submit" => array());
53      }
54      return system_settings_form($form);
55    }
56    
57    function avatar_blocks_admin_submit($form_id, &$form_values) {
58      if (module_exists('imagecache') && imagecache_presets()) {
59        if ($form_values['avatar_blocks_default_icpreset']) {
60          $preset_options = array(t('None'));
61          foreach (imagecache_presets() as $preset) {
62            $preset_options[] = $preset['presetname'];
63          }
64          variable_set('avatar_blocks_default_icpreset', $preset_options[$form_values['avatar_blocks_default_icpreset']]);
65        }
66        else {
67          variable_del('avatar_blocks_default_icpreset');
68        }
69      }
70      variable_set('avatar_blocks_role_block', $form_values['avatar_blocks_role_block']);
71      variable_set('avatar_blocks_buddylist_block', $form_values['avatar_blocks_buddylist_block']);
72    }
73    
74  /**  /**
75   * Implementation of hook_menu().   * Implementation of hook_menu().
76   */   */
77  function avatar_blocks_menu($may_cache) {  function avatar_blocks_menu($may_cache) {
78      $items = array();
79    if ($may_cache) {    if ($may_cache) {
80    }      $items[] = array(
81          'path' => 'admin/settings/avatarblocks',
82          'title' => t('Avatar Blocks'),
83          'description' => t('This page provides settings for the Avatar Blocks module.'),
84          'callback' => 'drupal_get_form',
85          'callback arguments' => array('avatar_blocks_admin'),
86          'access' => user_access('access administration pages'),
87        );
88      }
89    else {    else {
90      drupal_add_css('./'. drupal_get_path('module', 'avatar_blocks') .'/avatar_blocks.css');      drupal_add_css('./'. drupal_get_path('module', 'avatar_blocks') .'/avatar_blocks.css');
91    }    }
92      return $items;
93  }  }
94    
95  /**  /**
# Line 27  function avatar_blocks_menu($may_cache) Line 98  function avatar_blocks_menu($may_cache)
98  function avatar_blocks_block($op = 'list', $delta = 0, $edit = array()) {  function avatar_blocks_block($op = 'list', $delta = 0, $edit = array()) {
99    switch ($op) {    switch ($op) {
100      case 'list':      case 'list':
101        $blocks[AVATAR_BLOCKS_WHOS_ONLINE]['info'] = t("Who's Online Avatars");        $blocks[AVATAR_BLOCKS_WHOS_ONLINE]['info'] = t("AvatarBlocks Who's Online ");
102        $blocks[AVATAR_BLOCKS_WHOS_NEW]['info'] = t("Who's New Avatars");        $blocks[AVATAR_BLOCKS_WHOS_NEW]['info'] = t("AvatarBlocks Who's New");
103        if (module_exists('buddylist')) {        if (variable_get('avatar_blocks_role_block', 1)) {
104          $blocks[AVATAR_BLOCKS_MY_BUDDYLIST]['info'] = t("My Buddylist Avatars");          $blocks[AVATAR_BLOCKS_USER_ROLES]['info'] = t("AvatarBlocks User Role");
105      }        }
106          if (module_exists('buddylist') && variable_get('avatar_blocks_buddylist_block', 1)) {
107            $blocks[AVATAR_BLOCKS_MY_BUDDYLIST]['info'] = t("AvatarBlocks My Buddylist");
108          }
109        return $blocks;        return $blocks;
110      case 'configure':      case 'configure':
111        $form = array();        $form = array();
# Line 53  function avatar_blocks_block($op = 'list Line 127  function avatar_blocks_block($op = 'list
127            '#validate' => array('avatar_blocks_validate_olcount' => array()),            '#validate' => array('avatar_blocks_validate_olcount' => array()),
128          );          );
129          if (module_exists('imagecache') && imagecache_presets()) {          if (module_exists('imagecache') && imagecache_presets()) {
130            $preset_options = array(t('None'));            $preset_options = array(t('Default'));
131            foreach (imagecache_presets() as $preset) {            foreach (imagecache_presets() as $preset) {
132              $preset_options[] = $preset['presetname'];              $preset_options[] = $preset['presetname'];
133            }            }
# Line 89  function avatar_blocks_block($op = 'list Line 163  function avatar_blocks_block($op = 'list
163            '#validate' => array('avatar_blocks_validate_nucount' => array()),            '#validate' => array('avatar_blocks_validate_nucount' => array()),
164          );          );
165          if (module_exists('imagecache') && imagecache_presets()) {          if (module_exists('imagecache') && imagecache_presets()) {
166            $preset_options = array(t('None'));            $preset_options = array(t('Default'));
167            foreach (imagecache_presets() as $preset) {            foreach (imagecache_presets() as $preset) {
168              $preset_options[] = $preset['presetname'];              $preset_options[] = $preset['presetname'];
169            }            }
# Line 109  function avatar_blocks_block($op = 'list Line 183  function avatar_blocks_block($op = 'list
183            '#description' => t("Enable this option to display the default avatar for users without pictures. You must configure a default picture."),            '#description' => t("Enable this option to display the default avatar for users without pictures. You must configure a default picture."),
184          );          );
185        }        }
186          elseif ($delta == AVATAR_BLOCKS_USER_ROLES) {
187            $form['avatar_blocks_ur_count'] = array(
188              '#type' => 'textfield',
189              '#title' => t('Number of users to display'),
190              '#default_value' => variable_get('avatar_blocks_ur_count', 10),
191              '#description' => t('Maximum number of users to display.'),
192              '#size' => 5,
193              '#validate' => array('avatar_blocks_validate_urcount' => array()),
194            );
195            $role_options = array(t('None'));
196            foreach (user_roles(TRUE) as $rid => $name) {
197              $role_options[] = $name;
198            }
199            $role_index = array_search(variable_get('avatar_blocks_ur_role',  ''), $role_options);
200            $form['avatar_blocks_ur_role'] = array(
201              '#type' => 'select',
202              '#title' => t('Role'),
203              '#description' => t("This block will display the Avatars of Users who have the selected role."),
204              '#options' => $role_options,
205              '#default_value' => $role_index,
206            );
207            if (module_exists('imagecache') && imagecache_presets()) {
208              $preset_options = array(t('Default'));
209              foreach (imagecache_presets() as $preset) {
210                $preset_options[] = $preset['presetname'];
211              }
212              $preset_index = array_search(variable_get('avatar_blocks_ur_icpreset',  ''), $preset_options);
213              $form['avatar_blocks_ur_icpreset'] = array(
214                '#type' => 'select',
215                '#title' => t('Imagecache Preset'),
216                '#description' => t("Select an Imagecache preset to apply to the avatars."),
217                '#options' => $preset_options,
218                '#default_value' => $preset_index,
219              );
220            }
221            $form['avatar_blocks_ur_display_noavatar'] = array(
222              '#type' => 'checkbox',
223              '#title' => t('Display users without avatars'),
224              '#default_value' => variable_get('avatar_blocks_ur_display_noavatar', 1),
225              '#description' => t("Enable this option to display the default avatar for users without pictures. You must configure a default picture."),
226            );
227          }
228        elseif ($delta == AVATAR_BLOCKS_MY_BUDDYLIST) {        elseif ($delta == AVATAR_BLOCKS_MY_BUDDYLIST) {
229          $form['avatar_blocks_bl_count'] = array(          $form['avatar_blocks_bl_count'] = array(
230            '#type' => 'textfield',            '#type' => 'textfield',
# Line 119  function avatar_blocks_block($op = 'list Line 235  function avatar_blocks_block($op = 'list
235            '#validate' => array('avatar_blocks_validate_blcount' => array()),            '#validate' => array('avatar_blocks_validate_blcount' => array()),
236          );          );
237          if (module_exists('imagecache') && imagecache_presets()) {          if (module_exists('imagecache') && imagecache_presets()) {
238            $preset_options = array(t('None'));            $preset_options = array(t('Default'));
239            foreach (imagecache_presets() as $preset) {            foreach (imagecache_presets() as $preset) {
240              $preset_options[] = $preset['presetname'];              $preset_options[] = $preset['presetname'];
241            }            }
# Line 144  function avatar_blocks_block($op = 'list Line 260  function avatar_blocks_block($op = 'list
260        if ($delta == AVATAR_BLOCKS_WHOS_ONLINE) {        if ($delta == AVATAR_BLOCKS_WHOS_ONLINE) {
261          // save our block-specific settings.          // save our block-specific settings.
262          if ($edit['avatar_blocks_ol_icpreset']) {          if ($edit['avatar_blocks_ol_icpreset']) {
263            $preset_options = array(t('None'));            $preset_options = array(t('Default'));
264            foreach (imagecache_presets() as $preset) {            foreach (imagecache_presets() as $preset) {
265              $preset_options[] = $preset['presetname'];              $preset_options[] = $preset['presetname'];
266            }            }
# Line 161  function avatar_blocks_block($op = 'list Line 277  function avatar_blocks_block($op = 'list
277        elseif ($delta == AVATAR_BLOCKS_WHOS_NEW) {        elseif ($delta == AVATAR_BLOCKS_WHOS_NEW) {
278          // save our block-specific settings.          // save our block-specific settings.
279          if ($edit['avatar_blocks_nu_icpreset']) {          if ($edit['avatar_blocks_nu_icpreset']) {
280            $preset_options = array(t('None'));            $preset_options = array(t('Default'));
281            foreach (imagecache_presets() as $preset) {            foreach (imagecache_presets() as $preset) {
282              $preset_options[] = $preset['presetname'];              $preset_options[] = $preset['presetname'];
283            }            }
# Line 173  function avatar_blocks_block($op = 'list Line 289  function avatar_blocks_block($op = 'list
289          variable_set('avatar_blocks_nu_count', $edit['avatar_blocks_nu_count']);          variable_set('avatar_blocks_nu_count', $edit['avatar_blocks_nu_count']);
290          variable_set('avatar_blocks_nu_display_noavatar', $edit['avatar_blocks_nu_display_noavatar']);          variable_set('avatar_blocks_nu_display_noavatar', $edit['avatar_blocks_nu_display_noavatar']);
291        }        }
292          elseif ($delta == AVATAR_BLOCKS_USER_ROLES) {
293            // save our block-specific settings.
294            if ($edit['avatar_blocks_ur_role']) {
295              $role_options = array(t('None'));
296              foreach (user_roles(TRUE) as $rid => $name) {
297                $role_options[] = $name;
298              }
299              variable_set('avatar_blocks_ur_role', $role_options[$edit['avatar_blocks_ur_role']]);
300            }
301            else {
302              variable_del('avatar_blocks_ur_role');
303            }
304    
305            if ($edit['avatar_blocks_ur_icpreset']) {
306              $preset_options = array(t('Default'));
307              foreach (imagecache_presets() as $preset) {
308                $preset_options[] = $preset['presetname'];
309              }
310              variable_set('avatar_blocks_ur_icpreset', $preset_options[$edit['avatar_blocks_ur_icpreset']]);
311            }
312            else {
313              variable_del('avatar_blocks_ur_icpreset');
314            }
315            variable_set('avatar_blocks_ur_count', $edit['avatar_blocks_ur_count']);
316            variable_set('avatar_blocks_ur_display_noavatar', $edit['avatar_blocks_ur_display_noavatar']);
317          }
318        elseif ($delta == AVATAR_BLOCKS_MY_BUDDYLIST) {        elseif ($delta == AVATAR_BLOCKS_MY_BUDDYLIST) {
319          // save our block-specific settings.          // save our block-specific settings.
320          if ($edit['avatar_blocks_bl_icpreset']) {          if ($edit['avatar_blocks_bl_icpreset']) {
321            $preset_options = array(t('None'));            $preset_options = array(t('Default'));
322            foreach (imagecache_presets() as $preset) {            foreach (imagecache_presets() as $preset) {
323              $preset_options[] = $preset['presetname'];              $preset_options[] = $preset['presetname'];
324            }            }
# Line 203  function avatar_blocks_block($op = 'list Line 345  function avatar_blocks_block($op = 'list
345              $block['content'] = avatar_blocks_newest_members();              $block['content'] = avatar_blocks_newest_members();
346            }            }
347            break;            break;
348            case AVATAR_BLOCKS_USER_ROLES:
349              if (variable_get('avatar_blocks_role_block', 1)) {
350                if (user_access('access content')) {
351                  $block['subject'] = t("Users by role");
352                  $block['content'] = avatar_blocks_by_role();
353                }
354              }
355              break;
356          case AVATAR_BLOCKS_MY_BUDDYLIST:          case AVATAR_BLOCKS_MY_BUDDYLIST:
357            if (user_access('access content')) {            if (variable_get('avatar_blocks_buddylist_block', 1)) {
358              $block['subject'] = t("My Buddylist");              if (user_access('access content')) {
359              $block['content'] = avatar_blocks_my_buddylist();                $block['subject'] = t("My Buddylist");
360                  $block['content'] = avatar_blocks_my_buddylist();
361                }
362            }            }
363            break;            break;
364        }        }
# Line 233  function avatar_blocks_validate_nucount( Line 385  function avatar_blocks_validate_nucount(
385  }  }
386    
387  /**  /**
388    * validate the user role config block form.
389    */
390    function avatar_blocks_validate_urcount($element) {
391      if (($element['#value'] != '') && (!is_numeric($element['#value']))) {
392        form_set_error('avatar_blocks_ur_count', t('Number of users must be a number'));
393      }
394    }
395    
396    /**
397  * validate the my buddylist config block form.  * validate the my buddylist config block form.
398  */  */
399  function avatar_blocks_validate_blcount($element) {  function avatar_blocks_validate_blcount($element) {
# Line 268  function avatar_blocks_getavatar($online Line 429  function avatar_blocks_getavatar($online
429        $preset_options[] = $preset['presetname'];        $preset_options[] = $preset['presetname'];
430      }      }
431      // does the specified preset exist?      // does the specified preset exist?
432      if (array_search($imagecache_preset, $preset_options)) {      if (!(array_search($imagecache_preset, $preset_options) === FALSE)) {
433        if ($online_member->picture) {        if ($online_member->picture) {
434          // process the user's picture with imagecache          // process the user's picture with imagecache
435          $output .= l(theme("imagecache", $imagecache_preset, $online_member->picture, $online_member->name, $online_member->name), "user/".$online_member->uid, array('title' => $online_member->name), NULL, NULL, FALSE, TRUE);          $output .= l(theme("imagecache", $imagecache_preset, $online_member->picture, $online_member->name, $online_member->name), "user/".$online_member->uid, array('title' => $online_member->name), NULL, NULL, FALSE, TRUE);
# Line 298  function avatar_blocks_getavatar($online Line 459  function avatar_blocks_getavatar($online
459  function avatar_blocks_whos_online() {  function avatar_blocks_whos_online() {
460    $interval = time() - variable_get('user_block_seconds_online', 900);    $interval = time() - variable_get('user_block_seconds_online', 900);
461    $imagecache_preset = variable_get('avatar_blocks_ol_icpreset',  '');    $imagecache_preset = variable_get('avatar_blocks_ol_icpreset',  '');
462      if ($imagecache_preset == '') {
463        $imagecache_preset = variable_get('avatar_blocks_default_icpreset',  '');
464      }
465    $anonymous_count = sess_count($interval);    $anonymous_count = sess_count($interval);
466    $display_count = variable_get('avatar_blocks_ol_count',  10);    $display_count = variable_get('avatar_blocks_ol_count',  10);
467    if (!is_numeric($display_count)) {    if (!is_numeric($display_count)) {
468      $display_count = 10;      $display_count = 10;
469    }    }
470    $sql = 'SELECT DISTINCT u.uid, u.name, u.picture, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC';    $sql = 'SELECT DISTINCT u.uid, u.name, u.picture, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC';
471    $authenticated_users = db_query_range(db_rewrite_sql($sql), $interval, 0, $display_count);    $authenticated_users = db_query_range($sql, $interval, 0, $display_count);
472    $authenticated_count = db_num_rows($authenticated_users);    $authenticated_count = db_num_rows($authenticated_users);
473    if (variable_get('avatar_blocks_ol_display_noavatar', 1) == 0) {    if (variable_get('avatar_blocks_ol_display_noavatar', 1) == 0) {
474      $sql = 'SELECT DISTINCT u.uid, u.name, u.picture, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 AND u.picture <> "" ORDER BY s.timestamp DESC';      $sql = 'SELECT DISTINCT u.uid, u.name, u.picture, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 AND u.picture <> "" ORDER BY s.timestamp DESC';
475      $display_users = db_query_range(db_rewrite_sql($sql), $interval, 0, $display_count);      $display_users = db_query_range($sql, $interval, 0, $display_count);
476    }    }
477    else {    else {
478      $display_users = $authenticated_users;      $display_users = $authenticated_users;
479    }    }
480    $display_count = db_num_rows($display_users);    $display_count = db_num_rows($display_users);
481      $online_members = array();
482    if ($display_count) {    if ($display_count) {
     $online_members = array();  
483      while ($next_member = db_fetch_object($display_users)) {      while ($next_member = db_fetch_object($display_users)) {
484        $online_members[] = $next_member;        $online_members[] = $next_member;
485      }      }
   $output = theme_avatar_blocks_block($online_members, $imagecache_preset);  
486    }    }
487    
488      $output = theme_avatar_blocks_block($online_members, $imagecache_preset);
489    
490    
491    if (variable_get('avatar_blocks_ol_include_text', 0)) {    if (variable_get('avatar_blocks_ol_include_text', 0)) {
492      // Format the output with proper grammar.      // Format the output with proper grammar.
493      if ($anonymous_count == 1 && $authenticated_count == 1) {      if ($anonymous_count == 1 && $authenticated_count == 1) {
# Line 340  function avatar_blocks_whos_online() { Line 507  function avatar_blocks_whos_online() {
507  */  */
508  function avatar_blocks_newest_members() {  function avatar_blocks_newest_members() {
509    $imagecache_preset = variable_get('avatar_blocks_nu_icpreset',  '');    $imagecache_preset = variable_get('avatar_blocks_nu_icpreset',  '');
510      if ($imagecache_preset == '') {
511        $imagecache_preset = variable_get('avatar_blocks_default_icpreset',  '');
512      }
513    $display_count = variable_get('avatar_blocks_nu_count',  10);    $display_count = variable_get('avatar_blocks_nu_count',  10);
514    if (!is_numeric($display_count)) {    if (!is_numeric($display_count)) {
515      $display_count = 10;      $display_count = 10;
# Line 350  function avatar_blocks_newest_members() Line 520  function avatar_blocks_newest_members()
520    else {    else {
521      $sql = 'SELECT uid,name,picture FROM {users} WHERE uid > 0 AND access > 0 AND picture <> "" ORDER BY created DESC';      $sql = 'SELECT uid,name,picture FROM {users} WHERE uid > 0 AND access > 0 AND picture <> "" ORDER BY created DESC';
522    }    }
523    $new_member_list = db_query_range(db_rewrite_sql($sql), 0, $display_count);    $new_member_list = db_query_range($sql, 0, $display_count);
524    
525    $new_members = array();    $new_members = array();
526    while ($next_member = db_fetch_object($new_member_list)) {    while ($next_member = db_fetch_object($new_member_list)) {
# Line 367  function avatar_blocks_newest_members() Line 537  function avatar_blocks_newest_members()
537  */  */
538  function avatar_blocks_my_buddylist() {  function avatar_blocks_my_buddylist() {
539    $imagecache_preset = variable_get('avatar_blocks_bl_icpreset',  '');    $imagecache_preset = variable_get('avatar_blocks_bl_icpreset',  '');
540      if ($imagecache_preset == '') {
541        $imagecache_preset = variable_get('avatar_blocks_default_icpreset',  '');
542      }
543    $default_picture = variable_get('user_picture_default',  '');    $default_picture = variable_get('user_picture_default',  '');
544    $display_count = variable_get('avatar_blocks_bl_count',  10);    $display_count = variable_get('avatar_blocks_bl_count',  10);
545    if (!is_numeric($display_count)) {    if (!is_numeric($display_count)) {
# Line 382  function avatar_blocks_my_buddylist() { Line 555  function avatar_blocks_my_buddylist() {
555        else {        else {
556          $sql = 'SELECT uid,name,picture FROM {users} WHERE uid > 0 AND access > 0 AND uid IN %s AND picture <> "" ORDER BY created DESC';          $sql = 'SELECT uid,name,picture FROM {users} WHERE uid > 0 AND access > 0 AND uid IN %s AND picture <> "" ORDER BY created DESC';
557        }        }
558        $my_buddylist_list = db_query_range(db_rewrite_sql($sql), $buddy_ids_str, 0, $display_count);        $my_buddylist_list = db_query_range($sql, $buddy_ids_str, 0, $display_count);
559    
560        $buddies = array();        $buddies = array();
561        while ($next_buddy = db_fetch_object($my_buddylist_list)) {        while ($next_buddy = db_fetch_object($my_buddylist_list)) {
# Line 395  function avatar_blocks_my_buddylist() { Line 568  function avatar_blocks_my_buddylist() {
568  }  }
569    
570  /**  /**
571    * role display.
572    *
573    * Displays the pictures users who are a member of a specific role.
574    */
575    function avatar_blocks_by_role() {
576      $imagecache_preset = variable_get('avatar_blocks_ur_icpreset',  '');
577      if ($imagecache_preset == '') {
578        $imagecache_preset = variable_get('avatar_blocks_default_icpreset',  '');
579      }
580      $display_count = variable_get('avatar_blocks_ur_count',  10);
581      if (!is_numeric($display_count)) {
582        $display_count = 10;
583      }
584      // retrieve list of roles
585      $roles = user_roles(TRUE);
586      $rid = array_search(variable_get('avatar_blocks_ur_role',  ''), $roles);
587      // does specified role exist ?
588      if (!($rid === FALSE)) {
589        if (variable_get('avatar_blocks_ur_display_noavatar', 1)) {
590          $sql = 'SELECT u.uid,u.name,u.picture FROM {users} u INNER JOIN {users_roles} r ON r.rid = %d AND u.uid = r.uid WHERE u.uid > 0 AND u.access > 0 ORDER BY u.created DESC';
591        }
592        else {
593          $sql = 'SELECT u.uid,u.name,u.picture FROM {users} u INNER JOIN {users_roles} r ON r.rid = %d AND u.uid = r.uid WHERE u.uid > 0 AND u.access > 0 AND u.picture <> "" ORDER BY u.created DESC';
594        }
595        $role_member_list = db_query_range($sql, $rid, 0, $display_count);
596        $role_members = array();
597        while ($next_member = db_fetch_object($role_member_list)) {
598          $role_members[] = $next_member;
599        }
600        $output = theme_avatar_blocks_block($role_members, $imagecache_preset);
601      }
602      else {
603        // specificed role not found
604      }
605      return $output;
606    }
607    
608    /**
609  *  *
610  */  */
611  function theme_avatar_blocks_block($online_members, $imagecache_preset) {  function theme_avatar_blocks_block($online_members, $imagecache_preset) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2