DrupalBin
Submit Code
About
Recent Posts
Fix for Code
Code
add_to_cart_by_sku_contents()
Fix for page.tpl.php
Page.tpl
foreach is beeing disregarded dispite variable is array. Please help. Outside Drupal it works as standalone.php file
foreach is beeing disregarded dispite variable is array inside drupal. Please help. Outside Drupal it works as standalone.php
Fix for filefield implementation in an admin page. "An HTTP error 0 occurred. /drupal/?q=filefield/ahah///"
PHP Code custom.module
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
›
Fix for my module is showing bug .. not sure why ..
Fix for Fix for my module is showing bug .. not sure why ..
View
Fix
Fixes are not 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).
Show summary in full view
<?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_perma() { return array("has balance"); } function user_balance_helpa($path, $arg) { switch($path) { case "user/%user/balance" : return "User Balance and billing details."; } } function user_balance_menua() { return 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_TASK ) ); } function user_balance_has_balancea($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) { watchdog('godebug', var_export($account, TRUE)); if(!$account || !user_access("has balance", $account)) { return; } 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 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.