Notify user by default

derieppe - October 24, 2008 - 13:35
Project:Notify
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

This is an old issue for Notify. Could it be reborn ?

When a user add on site, notify is "off" for him by default.
This code patch will made news users in the Notify "ON" by default :

function notify_user($type, &$edit, &$user, $category = NULL) {
  switch ($type) {

    case 'insert':
      if (variable_get('notify_status',0)) {
        db_query('INSERT INTO {notify} (uid, status, node, teasers, comment) VALUES(%d,%d,%d,%d,%d)', $user->uid,
                 variable_get('notify_status',0), variable_get('notify_node',0), variable_get('notify_teasers',0),
                 variable_get('notify_comment',0));
      }
      break;

    case 'delete':
      db_query('DELETE FROM {notify} WHERE uid = %d', $user->uid);
      break;
  }
}

#1

derieppe - January 17, 2009 - 22:35
Title:Nitify user by default» Notify user by default
Version:5.x-2.x-dev» 5.x-1.x-dev

Hi,
Will this issue add to Notify ?
Regards.

#2

NaX - January 19, 2009 - 14:43

I did it this way, but I am using 1.2.

<?php
   
case 'insert':
      if (
$user->uid) {
       
db_query('INSERT INTO {notify} (uid, status, node, teasers, comment) VALUES(%d,%d,%d,%d,%d)', $user->uid, 1, 1, 0, 1);
      }
      break;
?>

#3

hallman - February 22, 2009 - 21:26

I'm using 5.x-1.x-dev, v 2.1.2.2 2009/02/03. I added the code I found in the patch at http://drupal.org/node/92206 #9. I like it better than the changes recommended above because I run multiple sites from one installation and the patch code adds options to admin/content/notify so that each site can have its own default settings. The patch code adds to

function notify_admin_settings the following:

$form['notify_status'] = array('#type' => 'radios',
'#title' => t('Notify status'),
'#default_value' => variable_get('notify_status',0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('Default status setting for new users'),
);

$form['notify_node'] = array('#type' => 'radios',
'#title' => t('Notify new content'),
'#default_value' => variable_get('notify_node',0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('Include new content in the notification mail.'),
);
$form['notify_teasers'] = array('#type' => 'radios',
'#title' => t('Content'),
'#default_value' => variable_get('notify_teasers',0),
'#options' => array(t('Title only'), t('Title + Teaser'), t('Title + Body')),
'#description' => t('Select the amount of each post that you would like to see in your notification e-mails.'),
);
$form['notify_comment'] = array('#type' => 'radios',
'#title' => t('Notify new comments'),
'#default_value' => variable_get('notify_comment',0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('Include new comments in the notification mail.'),
);

and to function notify_user the following:

case 'insert':
if (variable_get('notify_status',0)) {
db_query('INSERT INTO {notify} (uid, status, node, teasers, comment) VALUES(%d,%d,%d,%d,%d)', $user->uid,
variable_get('notify_status',0), variable_get('notify_node',0), variable_get('notify_teasers',0),
variable_get('notify_comment',0));
}
break;

I'm not a php programmer, but I didn't have any trouble just pasting in these lines.

 
 

Drupal is a registered trademark of Dries Buytaert.