--- userpoints.module 2009-11-04 22:36:30.000000000 -0800 +++ userpoints.module.newish 2009-11-04 22:36:16.000000000 -0800 @@ -40,6 +40,7 @@ define('USERPOINTS_CATEGORY_DEFAULT_TID' define('USERPOINTS_CATEGORY_PROFILE_DISPLAY_TID', 'userpoints_category_profile_display_tid'); define('USERPOINTS_TRANSACTION_TIMESTAMP', 'userpoints_transaction_timestamp'); +define('USERPOINTS_USERS_POINTS_BLOCK_CACHE', 'userpoints_users_points_block_cache'); /** * Purpose: Returns an array of common translation placeholders @@ -1511,14 +1512,15 @@ function userpoints_block($op = 'list', global $user; switch ($op) { + case 'list': $blocks[-1]['info'] = t('User\'s !points', userpoints_translation()); + $blocks[-1]['cache'] = variable_get(USERPOINTS_USERS_POINTS_BLOCK_CACHE, 1); //Grab a list of the available terms $terms = userpoints_get_categories(); foreach ($terms as $key => $value) { - $blocks[$key]['info'] = t("Highest $value !points", userpoints_translation());; - } //foreach - + $blocks[$key]['info'] = t("Highest $value !points", userpoints_translation()); + } //foreach return $blocks; case 'view': @@ -1565,7 +1567,23 @@ function userpoints_block($op = 'list', $block['content'] = $content; return $block; + case 'configure': + if ($delta == -1) { + $form['up_block_cache'] = array( + '#type' => 'select', + '#title' => t('Cache Type'), + '#default_value' => variable_get(USERPOINTS_USERS_POINTS_BLOCK_CACHE, 1), + '#options' => array( + 1 => 'BLOCK_CACHE_PER_ROLE', + 2 => 'BLOCK_CACHE_PER_USER', + 4 => 'BLOCK_CACHE_PER_PAGE', + 8 => 'BLOCK_CACHE_GLOBAL', + -1 => 'BLOCK_NO_CACHE', + ), + '#description' => t('Choose the type of caching for this block. For more information on caching types please visit: http://api.drupal.org/api/function/hook_block/6'), + ); + } else { $form['up_records'] = array( '#type' => 'select', '#title' => t('Number of users to display'), @@ -1577,13 +1595,22 @@ function userpoints_block($op = 'list', ), '#description' => t('Limit the number of users displayed to this value'), ); + } return $form; break; + case 'save': - variable_set('userpoints_block_up_records_'. $delta, $edit['up_records']); + if ($delta == -1) { + variable_set(USERPOINTS_USERS_POINTS_BLOCK_CACHE, $edit['up_block_cache']); + db_query("UPDATE {blocks} SET cache= %s WHERE module= %d AND delta= %d", $edit['up_block_cache'], 'userpoints', -1); + break; + } else { + variable_set('userpoints_block_up_records_'. $delta, $edit['up_records']); break; + } } //switch $op } + /* * returns an array of possible expiry times * to the administrative settings page