DrupalBin
Submit Code
About
Recent Posts
ad
35 sec
ago
Example of your custom template variable
2 min 15 sec
ago
Code
1 hour 56 min
ago
Fix for double entries
2 hours 13 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for my module is showing bug .. not sure why ..
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
/* * warning: array_fill() [function.array-fill]: Number of elements must be positive in /c/projects/click_to_call/trunk/control_interface/includes/database.inc on line 235. * warning: implode() [function.implode]: Bad arguments. in /c/projects/click_to_call/trunk/control_interface/includes/database.inc on line 235. * warning: array_keys() [function.array-keys]: The first argument should be an array in /c/projects/click_to_call/trunk/control_interface/modules/user/user.module on line 500. * 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 ')' at line 1 query: SELECT p.perm FROM web_role r INNER JOIN web_permission p ON p.rid = r.rid WHERE r.rid IN () in /c/projects/click_to_call/trunk/control_interface/modules/user/user.module on line 500. */ <?php # vim: set filetype=php expandtab tabstop=2 shiftwidth=2 autoindent smartindent: /* TODO: add user billing address. User card information or other things may be .. */ /* TODO: may be a block showing billing information and last transaction .. */ function user_balance_perm() { return array("has balance"); } function user_balance_help($path, $arg) { switch($path) { case "user/%user/balance" : return "User Balance and billing details."; } } function user_balance_menu() { $items[] = array( "user/%user/balance" => array( "title" => "Balance Information" ,"description" => "Billing information as well as billing log view" ,"page callback" => "drupal_get_form" ,"page arguments" => array("user_balance_details", 1) ,"access callback" => "user_balance_has_balance" ,"access arguments" => array(1) ,"file" => "user_balance.pages.inc" ,"type" => MENU_LOCAL_ITEM ) ); return $items; } function user_balance_has_balance($account) { global $user; if($account->uid == 1) { return FALSE; /* forbid the admin user.. */ } if(!user_access("has balance", $account)) { return FALSE; } if($account->uid == $user->uid || user_access("administer users", $user)) { return TRUE; } return FALSE; } function user_balance_user($op, &$edit, &$account, $category = NULL) { if(!user_access("has balance", $account)) { return; } if($op == "categories") { return array( array( "name" => "balance" ,"title" => t("Balance Information") ,"weight" => 7 //,'access callback' => 'user_balance_has_balance' //,'access arguments' => array ( // 1 //) ) ); } if($op == "view") { /* TODO: show last transaction .. */ $account->content["balance"] = array( '#type' => 'user_profile_category' ,'#title' => "Balance Information" ,'current balance' => array( '#type' => 'user_profile_item' ,'#title' => "Current Balance" ,'#value' => theme("balance", $account->amount, variable_get("balance default currency", 0)) ) ); return; } if($op == "load") { $account->amount = db_result(db_query("SELECT amount FROM {user_balance} AS ub JOIN {balance} AS b ON (ub.bid = b.bid) WHERE ub.uid = %d", $account->uid)); /* see if we have balance entry .. */ return; } $add_balance_entry = FALSE; if($op == "insert") { $add_balance_entry = TRUE; } if($op == "update") { $bid = db_result(db_query("SELECT bid FROM {user_balance} WHERE uid = %d", $account->uid)); /* see if we have balance entry .. */ if(!$bid) { $add_balance_entry = TRUE; } } if($add_balance_entry) { /* when user is inserted we add balance information to his/her account .. */ db_query("INSERT INTO {balance} SET amount = 0, module = 'user_balance'"); $bid = db_last_insert_id("balance", "bid"); db_query("INSERT INTO {user_balance} SET bid = %d AND uid = %d", $bid, $account->uid); } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.