/[drupal]/contributions/modules/forward/forward.module
ViewVC logotype

Diff of /contributions/modules/forward/forward.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.94, Tue Sep 1 19:10:49 2009 UTC revision 1.95, Tue Nov 3 22:51:13 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: forward.module,v 1.91 2009/06/24 14:58:29 seanr Exp $ */  /* $Id: forward.module,v 1.94 2009/09/01 19:10:49 seanr Exp $ */
3    
4  /**  /**
5   * @file   * @file
# Line 174  function forward_admin_settings() { Line 174  function forward_admin_settings() {
174      '#rows' => 10,      '#rows' => 10,
175      '#description' => t('This text appears if a user exceeds the flood control limit.  The value of the flood control limit setting will appear in place of %number in the message presented to users'),      '#description' => t('This text appears if a user exceeds the flood control limit.  The value of the flood control limit setting will appear in place of %number in the message presented to users'),
176    );    );
177    $form['forward_options']['forward_allow_message'] = array(    $form['forward_options']['forward_message'] = array(
178      '#type' => 'checkbox',      '#type' => 'select',
179      '#title' => t('Allow personal messages'),      '#title' => t('Personal messages'),
180      '#return_value' => 1,      '#options' => array(0 => 'Disabled', 1 => 'Optional', 2 => 'Required'),
181      '#default_value' => variable_get('forward_allow_message', TRUE),      '#default_value' => variable_get('forward_message', 1),
182      '#description' => t('If checked, the user will be allowed to include a personal message in the body of the email'),      '#description' => t('Choose whether the personal message field will be disabled, optional, or required.'),
183    );    );
184    $form['forward_options']['forward_filter_html'] = array(    $form['forward_options']['forward_filter_html'] = array(
185      '#type' => 'checkbox',      '#type' => 'checkbox',
# Line 441  function forward_page() { Line 441  function forward_page() {
441      $node = new stdClass();      $node = new stdClass();
442      $node->title = $form_state['values']['path'];      $node->title = $form_state['values']['path'];
443    }    }
444    $cid = '';  
445    if (!empty($_GET['cid'])) {    if ($form_state['values']['path'] == 'epostcard') {
446      $cid = '?cid='.$_GET['cid'];      $emailtype = 'postcard';
447        drupal_set_title(variable_get('forward_epostcard_title', 'Send an e-Postcard'));
448      }
449      else {
450        $emailtype = 'email';
451        if (!empty($_GET['cid'])) {
452          $cid = '?cid='.$_GET['cid'];
453        }
454        $form_state['values']['path'] .= $cid;
455        drupal_set_title(variable_get('forward_page_title', 'Forward this page'));
456    }    }
457    $form_state['values']['path'] .= $cid;  
   //print "$form_state['values']['path'] - $nid - $node->title"; exit;  
458    return drupal_get_form('forward_form', $form_state['values']['path'], $node->title);    return drupal_get_form('forward_form', $form_state['values']['path'], $node->title);
459  }  }
460    
# Line 459  function forward_form(&$form_state, $pat Line 467  function forward_form(&$form_state, $pat
467    $form = array();    $form = array();
468    $cid = array();    $cid = array();
469    
470    if ($path == 'epostcard') {    if (preg_match("/\?cid=/i", $path) == 1) {
471      $emailtype = 'postcard';      $paths = explode('?cid=', $path);
472      drupal_set_title(variable_get('forward_epostcard_title', 'Send an e-Postcard'));      $cid = array('fragment' => 'comment-'.$paths[1]);
473    }      $path = $paths[0];
   else {  
     $emailtype = 'email';  
     if (preg_match("/\?cid=/i", $path) == 1) {  
       $paths = explode('?cid=', $path);  
       $cid = array('fragment' => 'comment-'.$paths[1]);  
       $path = $paths[0];  
     }  
474    }    }
475    
476    if ($nodeapi == TRUE) {    if ($nodeapi == TRUE) {
# Line 518  function forward_form(&$form_state, $pat Line 519  function forward_form(&$form_state, $pat
519    $form['message']['subject'] = array(    $form['message']['subject'] = array(
520      '#type' => 'item',      '#type' => 'item',
521      '#title' => t('Message Subject'),      '#title' => t('Message Subject'),
522      '#value' => t(variable_get('forward_'. $emailtype .'subject', '!name has sent you a message from !site'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))),      '#value' => t(variable_get('forward_'. $emailtype .'_subject', '!name has sent you a message from !site'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))),
523      '#description' => '',      '#description' => '',
524    );    );
525    $form['message']['body'] = array(    $form['message']['body'] = array(
526      '#type' => 'item',      '#type' => 'item',
527      '#title' => t('Message Body'),      '#title' => t('Message Body'),
528      '#value' => t(variable_get('forward_'. $emailtype .'message', '!name thought you would like to see the !site web site.'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))),      '#value' => t(variable_get('forward_'. $emailtype .'_message', '!name thought you would like to see the !site web site.'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))),
529      '#description' => '',      '#description' => '',
530    );    );
531    if (variable_get('forward_allow_message', TRUE)) {    if (variable_get('forward_message', 1) != 0) {
532      $form['message']['message'] = array(      $form['message']['message'] = array(
533        '#type' => 'textarea',        '#type' => 'textarea',
534        '#title' => t('Your Personal Message'),        '#title' => t('Your Personal Message'),
# Line 535  function forward_form(&$form_state, $pat Line 536  function forward_form(&$form_state, $pat
536        '#cols' => 50,        '#cols' => 50,
537        '#rows' => 10,        '#rows' => 10,
538        '#description' => '',        '#description' => '',
539        '#required' => TRUE,        '#required' => (variable_get('forward_message', 1) == 2) ? TRUE : FALSE,
540      );      );
541    }    }
542    $form['message']['path'] = array(    $form['message']['path'] = array(
# Line 636  function forward_form_validate($form, &$ Line 637  function forward_form_validate($form, &$
637        form_set_error('recipients', t(variable_get('forward_flood_error', 'You can\'t send more than %number messages per hour. Please try again later.'), array('%number' => variable_get('forward_flood_control', 10))));        form_set_error('recipients', t(variable_get('forward_flood_error', 'You can\'t send more than %number messages per hour. Please try again later.'), array('%number' => variable_get('forward_flood_control', 10))));
638      }      }
639    }    }
640    if ((variable_get('forward_allow_message', TRUE)) && (empty($form_state['values']['message']))) {    if ((variable_get('forward_message', 1) == 2) && (empty($form_state['values']['message']))) {
641      form_set_error('message', t('You must enter a message.'));      form_set_error('message', t('You must enter a message.'));
642    }    }
643  }  }
# Line 644  function forward_form_validate($form, &$ Line 645  function forward_form_validate($form, &$
645  function forward_form_submit($form, &$form_state) {  function forward_form_submit($form, &$form_state) {
646    global $base_url, $user;    global $base_url, $user;
647    $dynamic_content = "";    $dynamic_content = "";
648    // Prepare the sender:  
   $from = $form_state['values']['yemail'];  
649    // Compose the body:    // Compose the body:
650    // Note how the form values are accessed the same way they were accessed in the validate function    // Note how the form values are accessed the same way they were accessed in the validate function
651    
# Line 679  function forward_form_submit($form, &$fo Line 679  function forward_form_submit($form, &$fo
679      $returnurl = '';      $returnurl = '';
680    }    }
681    else {    else {
682      $emailtype = 'page';      $emailtype = 'email';
683      $returnurl = $form_state['values']['path'];      $returnurl = $form_state['values']['path'];
684      $form_state['values']['path'] = explode('/', $form_state['values']['path']);      $path_array = explode('/', $form_state['values']['path']);
685      if (($form_state['values']['path'][0] == 'node') && (!empty($form_state['values']['path'][1])) && (is_numeric($form_state['values']['path'][1]))) {      if (($path_array[0] == 'node') && (!empty($path_array[1])) && (is_numeric($path_array[1]))) {
686        $nid = $form_state['values']['path'][1];        $nid = $path_array[1];
687        // we have a node        // we have a node
688        $content = node_load($nid);        $content = node_load($nid);
689        if (!node_access('view', $content)) {        if (!node_access('view', $content)) {
# Line 765  function forward_form_submit($form, &$fo Line 765  function forward_form_submit($form, &$fo
765    }    }
766    
767    $params['subject'] = t(variable_get('forward_'. $emailtype .'_subject', '!name has sent you a message from !site'), array('!name' => $form_state['values']['yname'], '!site' => variable_get('site_name', 'drupal')));    $params['subject'] = t(variable_get('forward_'. $emailtype .'_subject', '!name has sent you a message from !site'), array('!name' => $form_state['values']['yname'], '!site' => variable_get('site_name', 'drupal')));
768    $params['from'] = (variable_get('forward_sender_address', '') != '') ? variable_get('forward_sender_address', '') : $form_state['values']['yemail'];  
769      $params['from'] = trim($form_state['values']['yname'] .' <'. variable_get('forward_sender_address', variable_get('site_mail','')) .'>');
770      $params['headers']['Reply-To'] = trim($form_state['values']['yname'] .' <'. $form_state['values']['yemail'] .'>');
771    
772    $recipients = trim($form_state['values']['recipients']);    $recipients = trim($form_state['values']['recipients']);
773    $recipients = str_replace(array("\r\n", "\n", "\r"), ',', $recipients);    $recipients = str_replace(array("\r\n", "\n", "\r"), ',', $recipients);
# Line 843  function template_preprocess_forward(&$v Line 845  function template_preprocess_forward(&$v
845  function forward_mail($key, &$message, $params) {  function forward_mail($key, &$message, $params) {
846    $message['subject'] .= $params['subject'];    $message['subject'] .= $params['subject'];
847    $message['body'][] = $params['body'];    $message['body'][] = $params['body'];
848    
849      $message['headers']['Reply-To'] = $params['headers']['Reply-To'];
850    $message['headers']['MIME-Version'] = '1.0';    $message['headers']['MIME-Version'] = '1.0';
851    $message['headers']['Content-Type'] = 'text/html; charset=utf-8';    $message['headers']['Content-Type'] = 'text/html; charset=utf-8';
852  }  }
# Line 852  function forward_mail($key, &$message, $ Line 856  function forward_mail($key, &$message, $
856   * Implementation of hook_help - adds link to non-node pages   * Implementation of hook_help - adds link to non-node pages
857   */   */
858  function forward_help($path, $arg) {  function forward_help($path, $arg) {
859    if (user_access('access forward') && (preg_match("/^node\//i", $path) == 0) && (variable_get('forward_display_nonnode', FALSE))) {    if (user_access('access forward') && (preg_match("/^node\//i", $path) == 0) && ($path != 'epostcard') && ($path != 'forward') && (variable_get('forward_display_nonnode', FALSE))) {
860      drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css');      drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css');
861      $title = t(variable_get('forward_link_title', 'Email this !type'), array('!type' => 'page'));      $title = t(variable_get('forward_link_title', 'Email this !type'), array('!type' => 'page'));
862      $img = drupal_get_path('module', 'forward') .'/forward.gif';      $img = drupal_get_path('module', 'forward') .'/forward.gif';
# Line 922  function forward_link($type, $node=0, $t Line 926  function forward_link($type, $node=0, $t
926          'title'      => $title,          'title'      => $title,
927          'href'       => 'forward',          'href'       => 'forward',
928          'html'       => $html,          'html'       => $html,
929          'attributes' => array('title' => t('Forward this page to a friend'), 'class' => 'forward-page'),          'attributes' => array('title' => variable_get('forward_page_title', t('Forward this page to a friend')), 'class' => 'forward-page'),
930          'query'      => 'path='. $form_state['values']['path'] . $cid,          'query'      => array('path' => $form_state['values']['path'] . $cid),
931        );        );
932        return $links;        return $links;
933      }      }
# Line 940  function forward_theme() { Line 944  function forward_theme() {
944        'template' => 'forward'        'template' => 'forward'
945      ),      ),
946      'forward_page' => array(      'forward_page' => array(
947          'arguments' => array('vars' => NULL, 'node' => NULL),
948        ),
949        'forward_email' => array(
950        'arguments' => array('vars' => NULL),        'arguments' => array('vars' => NULL),
951      ),      ),
952      'forward_postcard' => array(      'forward_postcard' => array(

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.95

  ViewVC Help
Powered by ViewVC 1.1.2