module .'_form')) { $items[] = array( 'path' => 'node/add/'. str_replace('_', '-', $type->type), 'title' => drupal_ucfirst($type->name), 'callback' => 'drupal_get_form', 'callback arguments' => array( 'userpoints_nodelimit_creation_forbidden' ), 'access' => node_access('create', $type->type), ); } } } } return $items; } /** * Implementation of hook_userpoints(). */ function userpoints_nodelimit_userpoints($op, $points = 0, $uid = 0, $operation = NULL, $description = NULL) { $translation = userpoints_translation(); switch ($op) { case 'setting': $form = array(); $form['userpoints_nodelimit'] = array( '#type' => 'fieldset', '#title' => t('Userpoints Nodelimit settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['userpoints_nodelimit']['description'] = array( '#value' => t( 'This module uses the settings of !userpoints_basic
. It assumes the !points assigned for the creation of a node are negative; this works, i.e., when the user gets !points he can use to contribute by creating nodes until he has sufficient !points.', array('!userpoints_basic' => 'userpoints_basic.module') + $translation ), '#prefix' => '
', '#suffix' => '
', ); $form['userpoints_nodelimit']['userpoints_nodelimit_points_limit'] = array( '#type' => 'textfield', '#title' => t('Node creation !points limit', $translation), '#default_value' => variable_get('userpoints_nodelimit_points_limit', 0), '#size' => 3, '#maxlength' => 3, '#description' => t('The !points required to create a new node.', $translation), ); return $form; break; } } /*********************************************************************** * Menu callbacks **********************************************************************/ function userpoints_nodelimit_creation_forbidden() { $form = array(); $form['userpoints_nodelimit']['warning'] = array( '#value' => '
', ); return $form; } /*********************************************************************** * Module pubblic functions **********************************************************************/ /** * Check if user has sufficient points to create a node of a certain type */ function userpoints_nodelimit_check() { global $user; $current_points = userpoints_get_current_points($user->uid); $limit = (integer)variable_get('userpoints_nodelimit_points_limit', 0); return ($current_points >= $limit); }