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

HT Make node viewable only to user who created it?

I made a node module.

I would like:

1. A user who created the node can only view nodes he created.

2. An editor can view all nodes.

3. Nodes should not be searchable by anyone except 'view all nodes' roles.

In conjunction with an access control module, you can make 2 and 3 happen, but not seemingly 1. The view switch in hook access doesn;t really seem capable to make that happen either...

How does "Show block only for specific content type" this section of code use in Drupal5.0?

How does "Show block only for specific content type" this section of code use in Drupal5.0?

Show block only for specific content type:

$match = FALSE;
$types = array('story' => 1, 'page' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = TRUE;
  }
}
return $match;

Waits for your reply,Thanks!

Organic Groups invite customization

So what my friend and I want is a customization of the OG Invite module that allows the user to search through the database of users and based on whatever criterion present in their profiles, select the users to receive the invite to their group.

There is already a way to search through user profiles that is exactly what we want, and a way to do invitations, I'd just like to be able to combine the two of these together.

Has anyone already solved this problem?

Dave

version 5.x upgrade for smtp.module

I wanted to use LukeLast's smtp module with version 5.x. Here is what I did to get it working:

CONVERSION OF SMTP.MODULE TO 5.X

1) create directory sites/all/modules
2) create directory sites/all/modules/smtp
3) place smtp.module in sites/all/modules/smtp
4) create the file smtp.info in sites/all/modules/smtp
5) paste the following text into smtp.info

; $Id$
name = SMTP
description = Provides SMTP

6) in smtp.module insert the following just prior to the Settings Hook function:

/**
* smtp_menu
*/
function smtp_menu() {

$items = array();

$items[] = array(
'path' => 'admin/settings/smtp',
'title' => t('SMTP module settings'),
'callback' => 'drupal_get_form',
'callback arguments' => 'smtp_settings',
'access' => user_access('access administration pages'),
'type' => MENU_NORMAL_ITEM,
);

return $items;
}

7) in smtp.module, at the end of smtp_settings function change:

return $form;

to

return system_settings_form($form);

8) in smtp.module replace user_mail() with drupal_mail() in smtp_settings function as follows:

drupal_mail(t('mailkey', $test_address, t('Drupal test email'), t('If you receive this message it means your site is capable of sending email.'), variable_get('site_mail', 'test@example.com'), 'From: ' . variable_get('site_mail', 'test@example.com'));

DELETE query does not work ???

Im having a weird problem while developing a custom module and was wondering if anyone might have come across it before...

Core is 4.7.4 and im using an exiting contributed module as a template - modying it to suit my needs. Im a competent PHP and MYSQL developer.

Views - Sort Criteria Random Error

Im trying to create a block that randomly swaps iamges from a specific image gallery. I have the views module installed as per documentation and I'm getting a really weird error. If I create a custom block view it works fine. when i try and randomize it I get the followuing error:

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 '(), node.nid AS node_nid FROM node node LEFT JOIN term_node term_node ON node.n' at line 1 query: SELECT node.nid, rand() AS _rand(), node.nid AS node_nid FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid WHERE (node.status = '1') AND (node.type IN ('image')) AND (term_node.tid IN ('8')) ORDER BY _rand() ASC, node_nid ASC LIMIT 0, 1 in...

when i disable the random sort criteria it works fine.

here is an exported view of my query:
$view = new stdClass();
$view->name = 'Random_People';
$view->description = '';
$view->access = array (
);
$view->view_args_php = '';
$view->block = TRUE;
$view->block_title = 'Random Image';
$view->block_header = '';
$view->block_header_format = '1';
$view->block_footer = '';
$view->block_footer_format = '1';
$view->block_empty = '';
$view->block_empty_format = '1';
$view->block_type = 'table';
$view->nodes_per_block = '1';
$view->block_more = FALSE;

Pages

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