This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Get node information object by nid

Exists a function to get node info (object) passing the nid to a parameter?

Check module is installed

Exist a function to check if module is installed?

RTF/PDF Conversor Module

Is there any module that processes a RTF format into a PDF format?

RTF/PDF Module

Is there any module that processes a RTF format into a PDF format?

Theming hook_form

I'm working on a module to implement a d20 character sheet and I'd like to pretty up the input form. For some reason, I can't seem to figure out how to apply a theme to the form. The base name of my module is "characters." Here's what I think is the relevant code

<?php
function characters_form(&$node) {

... // snip

// str
$form['attributes']['STR']['permstr'] = array(
'#type' => 'textfield',
//'#title' => t('STR'),
'#required' => TRUE,
'#default_value' => $node->str,
'#size' => 3
);
$form['attributes']['STR']['tempstr'] = array(
'#type' => 'textfield',
//'#title' => t('Temp STR'),
'#required' => FALSE,
'#default_value' => $node->tempstr,
'#size' => 3
);

// dex
$form['attributes']['DEX']['permdex'] = array(
'#type' => 'textfield',
//'#title' => t('DEX'),
'#required' => TRUE,
'#default_value' => $node->dex,
'#size' => 3
);
$form['attributes']['DEX']['tempdex'] = array(
'#type' => 'textfield',
//'#title' => t('Temp DEX'),
'#required' => FALSE,
'#default_value' => $node->tempdex,
'#size' => 3
);

// con
$form['attributes']['CON']['permcon'] = array(
'#type' => 'textfield',
//'#title' => t('CON'),
'#required' => TRUE,

How to avoid user warning: Query was empty query?

I am working on a module that will allow multiple users to have superuser access (uid 1 access).

Eventually, this code will be moved to a module, but for now I am modifying the core to make sure my code is right. PLEASE DO NOT POST HERE TELLING ME THAT CORE HACKING IS A BAD IDEA... I know that... this is temporary.

I added a few lines to user_access() which is in modules/user/user.module. The SQL query there will return a single column and single row with the value "superuser" if the user id in question has been assigned the role "superuser." If not, the SQL query should return an empty set. After adding this code in, I am getting a ton of errors that all say: user warning: Query was empty query: [snip/]. Can anyone tell me how to avoid this error?

function user_access($string, $account = NULL) {
global $user;
static $perm = array();

if (is_null($account)) {
$account = $user;
}

// User #1 has all privileges:
if ($account->uid == 1) {
return TRUE;
}

/********** START MY CODE **********/
// Users with role 'superuser' have all privileges
$is_superuser_query = "SELECT DISTINCT(sr.name) FROM {users_roles} ur, {shared_role} sr WHERE ur.uid=$account->uid and ur.rid = sr.rid and sr.name = 'superuser';";
$is_superuser = db_query($check_if_superuser_query);
if ($is_superuser) {
return TRUE;
}

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions