Newer
Older
* @file
* Presents users with an option to create another node of the same type after a
* node is added.
*/
*/
function addanother_help($path, $arg) {
$output = '';
switch ($path) {
case "admin/help#addanother":
$output = '<p>'. t("Presents users with an option to create another node of the same type after a node is added.") .'</p>';
return $output;
case 'admin/settings/addanother':
$output = 'Here you can select the content types for which an <em>"Add another..."</em> message will be displayed. After creating a new content node, users with the <a href="@addanother_perm">use add another</a> permission will receive a message allowing them to add another content node of the same type.';
return '<p>'. t($output, array(
'@addanother_perm' => url('admin/user/permissions', array('fragment' => 'module-addanother')),
)) .'</p>';
return array('administer add another', 'use add another');
*/
function addanother_menu() {
$items = array();
$items['admin/settings/addanother'] = array(
'title' => 'Add Another',
'description' => 'Modify which node types display the Add Another message.',
'page callback' => 'drupal_get_form',
'page arguments' => array('addanother_admin'),
'access arguments' => array('administer add another'),
* This function sets up the admin/settings/addanother settings page.
$form['addanother_nodetypes'] = array(
'#type' => 'checkboxes',
'#title' => t('Enable Add Another for these content types'),
'#options' => node_get_types('names'),
'#default_value' => variable_get('addanother_nodetypes', array()),
'#description' => 'An <em>Add Another</em> message will be shown after creating these content types',
);
return system_settings_form($form);
}
* Implementation of hook_nodeapi().
*/
function addanother_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'insert':
// This prevents AddAnother's message from clashing with Submit Again.
return;
}
$allowed_nodetypes = variable_get('addanother_nodetypes', array());
if (user_access('use add another') && isset($allowed_nodetypes[$node->type]) && $allowed_nodetypes[$node->type]) {
global $_addanother_message;
$_addanother_message = t('Add another <a href="@typeurl">%type</a>.', array(
'@typeurl' => url('node/add/'. str_replace('_', '-', $node->type)),
'%type' => node_get_types('name', $node)
function addanother_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
$form['buttons']['submit']['#submit'][] = '_addanother_message';
}
}
/**
* Display the Add Another message if set by addanother_nodeapi().
function _addanother_message($form, &$form_state) {
global $_addanother_message;
if (isset($_addanother_message)) {
drupal_set_message($_addanother_message, 'status', FALSE);
}
}