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

Organics groups module problem

Hello,

I am experiencing difficulty in understanding how we control whether a "delete" button is shown on a group edit page
which is published by an ordinary group subscriber and viewed by a moderator because of a mysterious call to node_access() ....

When a moderator loads the group "page" for editing we first call node_access('update', $node) and this works fine with access to the page being denied from page_access but then allowed because of records in the {node_access} table

node.module
640
/**
* Implementation of hook_menu().
*/
function node_menu($may_cache) {
$items = array();
..
691
$items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
'callback' => 'node_page',
'access' => node_access('update', $node),
'weight' => 1,
'type' => MENU_LOCAL_TASK);

Later when we render the delete button in the page ...

1275
/**
* Generate the node editing form.
*/
function node_form($edit) {
..
1364
if ($edit->nid && node_access('delete', $edit)) {
$output .= form_submit(t('Delete'));
}

...we make the second call to node_access which returns TRUE firstly because of what is in the
{node_access} table and then again later because of a none NULL return from page_access (called from node_access) because
the node has somehow been assigned to the moderator requesting the page and it is this
second call which has the final word on whether the "delete" button is rendered on the page

Organics groups module

Hello ,

I am currently looking to understand how the organic groups module works so that i contribute to its development but i am having difficulty understanding from the code how a "delete" button is showing on a group "page" published by an ordinary group subscriber when viewed by a moderator. I can't see how this should be after treading through the code , here's what i have found..

The delete button on the group "page" is rendered here

node.module
1275
/**
* Generate the node editing form.
*/
function node_form($edit) {
..
1364
if ($edit->nid && node_access('delete', $edit)) {
$output .= form_submit(t('Delete'));
}

so node_access() ultimately determines whether this button is rendered on the "page"

821
...
function node_access($op, $node = NULL, $uid = NULL) {

1856 calling og_access or page_access ?
$access = module_invoke(node_get_module_name($node), 'access', $op, $node);
if (!is_null($access)) {
return $access; // returning from here
}

from within node access i know that node_access returns here to node_form
after calling the hook page_access with $op and $node as arguments

page.module

35

function page_access($op, $node) {
global $user;

if ($op == 'create') {
return user_access('create pages');
}

if ($op == 'update' || $op == 'delete') {
if (user_access('edit own pages') && ($user->uid == $node->uid)) {

Redefine the "author" input form for a new node type

Hello,

I have created a new node type: "article".
I (the editor in chief) am the only person with the power of creating new articles. When I do so, I would like to "pick" a user from the ones who have "magazine_author" as a role.

Is it possible to change the way the input for the node's author is handled, so that it gives me a list?
Right now, my node_article_form function looks like this:

I need a DATE! Ok ok - I need dates to work!

Hi

I am stuck with dates. I have a node form where the user can enter a date - and I cna even store it correctly! But when I try to edit the node all comes crashing down around me :(

Details:
In my form I generate the date field like this:

<?php
  $form['startdate'] = array(
  '#type' => 'date',
  '#title' => t('Start Date'),
  '#default_value' => $node->startdate,
  '#description' => "The date on the competition will be open to entries.",
  '#required' => TRUE,
  );
?>

It shows up fine on the page and I can enter the date fine.
I store it in my database in a field " startdate int(11) NOT NULL " using this code in my insert hook:

<?php
    db_query("INSERT INTO fhsstadmin_competition (nid,startdate,enddate) VALUES (%d,%d, %d)",
        $node->nid,
        mktime(12,0,0,$node->startdate['month'],$node->startdate['day'],$node->startdate['year'])- $user->timezone,
        mktime(0,0,0,$node->enddate['month'],$node->enddate['day'],$node->enddate['year'])- $user->timezone
        );
?>

And when I view it using:

<?php
format_date($node->startdate,'short')
?>

It looks fine when I do this. So far so good. But when I try to edit the node I get an error

Fatal error: Cannot create references to/from string offsets nor overloaded objects in /var/www/FHSST2/includes/form.inc on line 310

How do I... enable CSS for a homegrown module

Hi, question from a noobie.

I have created a new module for my own use. I have uploaded it to my installation and it's working fine.

Now I've created a CSS file for the module, but I'm not sure how to get drupal to use it. Does drupal 'automagically detect' this CSS file or do I need to code something somewhere?

I have searched the docs but can't find the answer.

Yours naively, Lucy C

Q: Is there a module that links certain keywords on a page?

I was wondering if there was a module that would be able to take certain keywords from the page and then parse them as links to a certain location. This way, all the pages on a site would all interlink with each other much better. Does this make sense? Do you think something like this exists or would be a good idea?

Thanks!

Pages

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