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

$account->roles in user_access function

I am so close to resolving this. I could really, really use some help.

The $account->roles basically returns an array of roles that the user has.

I am trying to augment this array with additional roles that I add according to the group the user belongs to. Let's assume, for the moment, that I can return the array of roles I desire. In what format should they be in in order to slot into this user_access function command to replace $account->roles?:

$result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys($account->roles)));

If, for example, my function to return roles is user_all_roles($user), how should the return array be formatted in order to work, i.e.:

$result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys(user_all_roles($account))));
<./code>
This isn't working because, I assume, of the way I'm formatting the resulting array. Right now, I just return a basic array with two values:

0 = anonymous user role
4 = my custom role (this is the correct rid and it is in the roles and permissions tables)

However, my tests of user_access('permission') reveal that the roles, in the array format I am supplying, aren't being recognized. Any suggestions whatsoever? Thanks!

form api woes?

After several hours of messing around looking through the API's i'm exhausted - so apologies if i could have found the answer by browsing for another few hours!

I'm converting some old (and quite bad) code to use Drupals form API, which sets up the forms quite nicely - but it's setting their "names" as edit[name] as opposed to just "name".

I'm wondering if there's an API to pick these variables up after the submission 'cause i sure as heck can't get 'em via $variable = $_POST[name]; etc.

Cheers!

roo.

Event module problems

I'm having trouble with my Events module, perhaps I am doing something wrong. If you'll visit my test site:

http://www.valleyview.dreamhosters.com/events

You can see where things just didn't go swimmingly. My problems:

1) Even when I change the default overview settings in administer/settings/event, the changes do not appear to take effect on the site. I'm looking for something like what you'll find here:

how to disable user deletions

Is it possible through a module or manually editiing certain files, to disable the ability of users to delete uploaded files?

I would like to know exactly which files were uploaded on my site, and if users can upload and delete them at will then I lose that ability.

form's default value does not show

can anybody tell me what's wrong with the following code?

the form's default value is not displaying although it works well when used as this: '#defaultvalue' => t('asdf')

<?php
function classes_form(){
$arg = arg(3);
if($arg == 'add'){
$form['classname'] = array(
'#type' => 'textfield',
'#required' => true,
'#title' => t('Text Number One'),
'#size' => 30,
'#maxlength' => 50,
'#weight' => -1,
);
$form['weight'] = array(
'#type' => 'textfield',
'#required' => true,
'#title' => t('Text Number Two'),
'#size' => 2,
'#maxlength' => 2,
'#weight' => -2,
);
}elseif($arg == 'edit'){
$classID = arg(4);
$result = db_query("SELECT className, weight FROM grades_classes WHERE classID = %s LIMIT 0,1", $classID);
$row_result = db_fetch_object($result);
$form['classname'] = array(
'#type' => 'textfield',
'#required' => true,
'#title' => t('Text Number One'),
'#size' => 30,
'#maxlength' => 50,
'#weight' => -1,
'#defaultvalue' => $row_result->className
);
$form['weight'] = array(
'#type' => 'textfield',
'#required' => true,
'#title' => t('Text Number Two'),
'#size' => 2,
'#maxlength' => 2,
'#weight' => -2,
'#defaultvalue' => $row_result->weight
);
}
return system_settings_form('classes_form', $form);

Flexinode Front_page promote to frontpage

I've a problem with the the modules flexinode and front_page.
I've added a new flexinode -> node/flexinode-1 and the frontpage module. If I add a new article and the checkbox "promote to frontpage" is selected, the teaser of the article will shown on my flexinode-1 page.

Is it possible to change the default frontpage?

thx
dominik

Pages

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