admin_content_notification.module in Admin Content Notification 7
Same filename and directory in other branches
Module admin_content_notification file.
File
admin_content_notification.moduleView source
<?php
/**
* @file
* Module admin_content_notification file.
*/
/**
* Implements hook_menu().
*/
function admin_content_notification_menu() {
$items['admin/content/admin-content-notification'] = array(
'title' => 'Admin Content Notification Configuration Form',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'admin_content_notification_settings_form',
),
'access arguments' => array(
'administer content',
),
'file' => 'includes/admin_content_notification.admin.inc',
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Implements hook_help().
*/
function admin_content_notification_help($path, $arg) {
switch ($path) {
case 'admin/help#admin_content_notification':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('It is very simple module which can be used to send email to admin or on any specific email id when a contnet has been posted on Drupal site.') . '</p>';
return $output;
}
}
/**
* Implements hook_node_insert().
*/
function admin_content_notification_node_insert($node) {
if (in_array($node->type, variable_get('admin_content_notification_node_types', array()), TRUE)) {
drupal_mail('admin_content_notification', 'notification', admin_content_notification_get_admin_email(), language_default(), array(
'message' => admin_content_notification_get_email_body($node),
'subject' => admin_content_notification_get_email_subject($node),
));
}
}
/**
* Get Email subject.
*
* @return string
* Email subject.
*/
function admin_content_notification_get_email_subject() {
return variable_get('admin_content_notification_email_subject', 'A New Content is Submitted');
}
/**
* Get Email Body.
*
* @param Object $node
* Node Object.
*
* @return string
* Email body.
*/
function admin_content_notification_get_email_body($node) {
global $base_url;
$user = user_load($node->uid);
$variables = array(
'%posted_by' => $user->name,
'%content_link' => l($node->title, $base_url . '/node/' . $node->nid),
);
return t(variable_get('admin_content_notification_email_body', 'A new content has been submitted on your site. <br/> Submitted by : %posted_by <br/> New content link : %content_link'), $variables);
}
/**
* Get admin email.
*
* @return string
* Admin Email.
*/
function admin_content_notification_get_admin_email() {
return variable_get('admin_content_notification_email', variable_get('site_mail', ini_get('sendmail_from')));
}
/**
* Implements hook_mail().
*/
function admin_content_notification_mail($key, &$message, $params) {
switch ($key) {
case 'notification':
$message['subject'] = $params['subject'];
$message['body'] = explode('<br/>', $params['message']);
break;
}
}
Functions
Name | Description |
---|---|
admin_content_notification_get_admin_email | Get admin email. |
admin_content_notification_get_email_body | Get Email Body. |
admin_content_notification_get_email_subject | Get Email subject. |
admin_content_notification_help | Implements hook_help(). |
admin_content_notification_mail | Implements hook_mail(). |
admin_content_notification_menu | Implements hook_menu(). |
admin_content_notification_node_insert | Implements hook_node_insert(). |