| 1 |
<?php |
<?php |
| 2 |
/* $Id: forward.module,v 1.82 2009/05/27 21:02:11 seanr Exp $ */ |
/* $Id: forward.module,v 1.94 2009/09/01 19:10:49 seanr Exp $ */ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 25 |
* Permissions |
* Permissions |
| 26 |
*/ |
*/ |
| 27 |
function forward_perm() { |
function forward_perm() { |
| 28 |
return array('access forward', 'access epostcard', 'override email address', 'administer forward'); |
return array('access forward', 'access epostcard', 'override email address', 'administer forward', 'override flood control'); |
| 29 |
} |
} |
| 30 |
|
|
| 31 |
/** |
/** |
| 111 |
'#default_value' => variable_get('forward_link_type', FALSE), |
'#default_value' => variable_get('forward_link_type', FALSE), |
| 112 |
'#description' => t('If checked, the link will read "email this <em>nodetype</em>"; if not, it will just read "email this page"'), |
'#description' => t('If checked, the link will read "email this <em>nodetype</em>"; if not, it will just read "email this page"'), |
| 113 |
); |
); |
| 114 |
|
$form['forward_options']['forward_link_title'] = array( |
| 115 |
|
'#type' => 'textfield', |
| 116 |
|
'#title' => t('Link title'), |
| 117 |
|
'#size' => 40, |
| 118 |
|
'#default_value' => variable_get('forward_link_title', 'Email this !type'), |
| 119 |
|
'#description' => t('Set the text of the link. Use !type as a place holder for the node\'s content type or \'page\' depending on the setting above.'), |
| 120 |
|
); |
| 121 |
|
$form['forward_options']['forward_display_nodes'] = array( |
| 122 |
|
'#type' => 'checkbox', |
| 123 |
|
'#title' => t('Show Forward on nodes'), |
| 124 |
|
'#return_value' => 1, |
| 125 |
|
'#default_value' => variable_get('forward_display_nodes', TRUE), |
| 126 |
|
'#description' => t('If checked, the link/form will appear on nodes'), |
| 127 |
|
); |
| 128 |
$form['forward_options']['forward_display_teasers'] = array( |
$form['forward_options']['forward_display_teasers'] = array( |
| 129 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 130 |
'#title' => t('Show Forward on teasers'), |
'#title' => t('Show Forward on teasers'), |
| 203 |
'#maxlength' => 40, |
'#maxlength' => 40, |
| 204 |
'#description' => t('If left blank, the from address entered in the form will be used as the from address for the email. Enter a valid email address here to override that. The sender\'s email will still appear in the body of the message.'), |
'#description' => t('If left blank, the from address entered in the form will be used as the from address for the email. Enter a valid email address here to override that. The sender\'s email will still appear in the body of the message.'), |
| 205 |
); |
); |
| 206 |
|
|
| 207 |
|
$types = node_get_types(); |
| 208 |
|
$options = array(); |
| 209 |
|
$defaults = array(); |
| 210 |
|
foreach ($types as $type => $info) { |
| 211 |
|
$options[$type] = $info->name; |
| 212 |
|
if (variable_get('forward_display_'.$type, TRUE)) { |
| 213 |
|
$defaults[] = $type; |
| 214 |
|
} |
| 215 |
|
} |
| 216 |
|
$form['forward_options']['forward_display_types'] = array( |
| 217 |
|
'#type' => 'checkboxes', |
| 218 |
|
'#title' => t('Content types'), |
| 219 |
|
'#options' => $options, |
| 220 |
|
'#default_value' => $defaults, |
| 221 |
|
'#description' => t('Choose which content types to display the Forward link on.'), |
| 222 |
|
); |
| 223 |
|
|
| 224 |
// Page Text Values |
// Page Text Values |
| 225 |
$form['forward_text_values'] = array( |
$form['forward_text_values'] = array( |
| 231 |
$form['forward_text_values']['forward_instructions'] = array( |
$form['forward_text_values']['forward_instructions'] = array( |
| 232 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 233 |
'#title' => t('Forward Instructions'), |
'#title' => t('Forward Instructions'), |
| 234 |
'#default_value' => variable_get('forward_instructions', '<p>'. t('Thank you for your interest in spreading the word on') .' '. variable_get('site_name', 'drupal') .'.</p><p>'. t('NOTE: We only request your email address so that the person you are recommending the page to knows that you wanted them to see it, and that it is not junk mail. We do not capture any email address.') .'</p>'), |
'#default_value' => variable_get('forward_instructions', '<p>Thank you for your interest in spreading the word about !site.</p><p>NOTE: We only request your email address so that the person you are recommending the page to knows that you wanted them to see it, and that it is not junk mail. We do not capture any email address.</p>'), |
| 235 |
'#cols' => 40, |
'#cols' => 40, |
| 236 |
'#rows' => 10, |
'#rows' => 10, |
| 237 |
'#description' => t('This message will be displayed above the form.'), |
'#description' => t('This message will be displayed above the form. The token !site will be replaced with the site name.'), |
| 238 |
); |
); |
| 239 |
$form['forward_text_values']['forward_thankyou'] = array( |
$form['forward_text_values']['forward_thankyou'] = array( |
| 240 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 241 |
'#title' => t('Thank You Message'), |
'#title' => t('Thank You Message'), |
| 242 |
'#default_value' => variable_get('forward_thankyou', t('Thank you for your help in spreading the word about') .' '. variable_get('site_name', 'drupal') .'. '. t('We appreciate your help.')), |
'#default_value' => variable_get('forward_thankyou', 'Thank you for your help in spreading the word about !site. We appreciate your help.'), |
| 243 |
'#cols' => 40, |
'#cols' => 40, |
| 244 |
'#rows' => 10, |
'#rows' => 10, |
| 245 |
'#description' => t('This message will be displayed after the user successfully submits the form.'), |
'#description' => t('This message will be displayed after the user successfully submits the form. The token !site will be replaced with the site name.'), |
| 246 |
); |
); |
| 247 |
|
|
| 248 |
// Forward Form Default Values |
// Forward Form Default Values |
| 270 |
'#maxlength' => 256, |
'#maxlength' => 256, |
| 271 |
'#description' => t('Title to display above the Forward page form'), |
'#description' => t('Title to display above the Forward page form'), |
| 272 |
); |
); |
| 273 |
$form['forward_page_defaults']['forward_emailsubject'] = array( |
$form['forward_page_defaults']['forward_page_subject'] = array( |
| 274 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 275 |
'#title' => t('Forward Message Subject'), |
'#title' => t('Forward Message Subject'), |
| 276 |
'#default_value' => variable_get('forward_emailsubject', t('!name has forwarded a page to you from !site')), |
'#default_value' => variable_get('forward_page_subject', t('!name has forwarded a page to you from !site')), |
| 277 |
'#size' => 40, |
'#size' => 40, |
| 278 |
'#maxlength' => 256, |
'#maxlength' => 256, |
| 279 |
'#description' => t('Email subject line. The sender\'s name will appear in place of !name in the subject. The web site name will be inserted in place of !site.'), |
'#description' => t('Email subject line. The sender\'s name will appear in place of !name in the subject. The web site name will be inserted in place of !site.'), |
| 280 |
); |
); |
| 281 |
$form['forward_page_defaults']['forward_emailmessage'] = array( |
$form['forward_page_defaults']['forward_page_message'] = array( |
| 282 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 283 |
'#title' => t('Forward Message Body'), |
'#title' => t('Forward Message Body'), |
| 284 |
'#default_value' => variable_get('forward_emailmessage', t('!name thought you would like to see this page from the !site web site.')), |
'#default_value' => variable_get('forward_page_message', t('!name thought you would like to see this page from the !site web site.')), |
| 285 |
'#cols' => 40, |
'#cols' => 40, |
| 286 |
'#rows' => 10, |
'#rows' => 10, |
| 287 |
'#description' => t('Email message body. The sender\'s name will appear in place of !name in the message body. The web site name will be inserted in place of !site. The sender will be able to add their own message after this.'), |
'#description' => t('Email message body. The sender\'s name will appear in place of !name in the message body. The web site name will be inserted in place of !site. The sender will be able to add their own message after this.'), |
| 310 |
'#maxlength' => 256, |
'#maxlength' => 256, |
| 311 |
'#description' => t('Title to display above the Forward page form'), |
'#description' => t('Title to display above the Forward page form'), |
| 312 |
); |
); |
| 313 |
$form['forward_epostcard_defaults']['forward_postcardsubject'] = array( |
$form['forward_epostcard_defaults']['forward_epostcard_subject'] = array( |
| 314 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 315 |
'#title' => t('e-Postcard Message Subject'), |
'#title' => t('e-Postcard Message Subject'), |
| 316 |
'#default_value' => variable_get('forward_postcardsubject', t('!name has sent you an e-postcard from !site')), |
'#default_value' => variable_get('forward_epostcard_subject', t('!name has sent you an e-postcard from !site')), |
| 317 |
'#size' => 40, |
'#size' => 40, |
| 318 |
'#maxlength' => 256, |
'#maxlength' => 256, |
| 319 |
'#description' => t('Postcard subject line. The sender\'s name will appear in place of !name in the subject. The web site name will be inserted in place of !site.'), |
'#description' => t('Postcard subject line. The sender\'s name will appear in place of !name in the subject. The web site name will be inserted in place of !site.'), |
| 320 |
); |
); |
| 321 |
$form['forward_epostcard_defaults']['forward_postcardmessage'] = array( |
$form['forward_epostcard_defaults']['forward_epostcard_message'] = array( |
| 322 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 323 |
'#title' => t('e-Postcard Message Body'), |
'#title' => t('e-Postcard Message Body'), |
| 324 |
'#default_value' => variable_get('forward_postcardmessage', t('!name has sent you an e-postcard from the !site web site. Please take a moment to visit our web site.')), |
'#default_value' => variable_get('forward_epostcard_message', t('!name has sent you an e-postcard from the !site web site. Please take a moment to visit our web site.')), |
| 325 |
'#cols' => 40, |
'#cols' => 40, |
| 326 |
'#rows' => 10, |
'#rows' => 10, |
| 327 |
'#description' => t('Postcard message body. The sender\'s name will appear in place of !name in the message body. The web site name will be inserted in place of !site. The sender will be able to add their own message after this. You can use HTML in this field to add a special postcard image to the email above the sender\'s message.'), |
'#description' => t('Postcard message body. The sender\'s name will appear in place of !name in the message body. The web site name will be inserted in place of !site. The sender will be able to add their own message after this. You can use HTML in this field to add a special postcard image to the email above the sender\'s message.'), |
| 358 |
'#required' => TRUE, |
'#required' => TRUE, |
| 359 |
'#attributes' => NULL, |
'#attributes' => NULL, |
| 360 |
); |
); |
| 361 |
|
$form['forward_epostcard_defaults']['forward_epostcard_return'] = array( |
| 362 |
|
'#type' => 'textfield', |
| 363 |
|
'#title' => t('e-Postcard Return URL'), |
| 364 |
|
'#default_value' => variable_get('forward_epostcard_return', ''), |
| 365 |
|
'#size' => 40, |
| 366 |
|
'#description' => t('URL of path to redirect users to after submitting the epostcard form.'), |
| 367 |
|
); |
| 368 |
|
$form['#submit'][] = 'forward_admin_settings_submit'; |
| 369 |
|
|
| 370 |
return system_settings_form($form); |
return system_settings_form($form); |
| 371 |
} |
} |
| 372 |
|
|
| 373 |
|
function forward_admin_settings_submit($form, &$form_state) { |
| 374 |
|
$types = node_get_types(); |
| 375 |
|
foreach ($types as $type => $info) { |
| 376 |
|
if (!empty($form_state['values']['forward_display_types'][$type])) { |
| 377 |
|
variable_set('forward_display_'.$type, TRUE); |
| 378 |
|
} |
| 379 |
|
else { |
| 380 |
|
variable_set('forward_display_'.$type, FALSE); |
| 381 |
|
} |
| 382 |
|
} |
| 383 |
|
unset($form_state['values']['forward_display_types']); |
| 384 |
|
system_settings_form_submit($form, $form_state); |
| 385 |
|
} |
| 386 |
|
|
| 387 |
|
|
| 388 |
/** |
/** |
| 389 |
* Email Tracker |
* Email Tracker |
| 390 |
*/ |
*/ |
| 411 |
* Page |
* Page |
| 412 |
*/ |
*/ |
| 413 |
function forward_page() { |
function forward_page() { |
| 414 |
|
drupal_set_html_head('<meta name="robots" content="noindex, nofollow" />'); |
| 415 |
$nid = NULL; |
$nid = NULL; |
| 416 |
if (empty($_GET['path']) || ($_GET['path'] == 'node/0')) { |
if (empty($_GET['path']) || ($_GET['path'] == 'node/0')) { |
| 417 |
return t('No path was selected to forward'); |
return t('No path was selected to forward'); |
| 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'])) { |
| 446 |
|
$cid = '?cid='.$_GET['cid']; |
| 447 |
|
} |
| 448 |
|
$form_state['values']['path'] .= $cid; |
| 449 |
//print "$form_state['values']['path'] - $nid - $node->title"; exit; |
//print "$form_state['values']['path'] - $nid - $node->title"; exit; |
| 450 |
return drupal_get_form('forward_form', $form_state['values']['path'], $node->title); |
return drupal_get_form('forward_form', $form_state['values']['path'], $node->title); |
| 451 |
} |
} |
| 457 |
global $base_url, $user; |
global $base_url, $user; |
| 458 |
|
|
| 459 |
$form = array(); |
$form = array(); |
| 460 |
|
$cid = array(); |
| 461 |
|
|
| 462 |
if ($path == 'epostcard') { |
if ($path == 'epostcard') { |
| 463 |
$emailtype = 'postcard'; |
$emailtype = 'postcard'; |
| 465 |
} |
} |
| 466 |
else { |
else { |
| 467 |
$emailtype = 'email'; |
$emailtype = 'email'; |
| 468 |
|
if (preg_match("/\?cid=/i", $path) == 1) { |
| 469 |
|
$paths = explode('?cid=', $path); |
| 470 |
|
$cid = array('fragment' => 'comment-'.$paths[1]); |
| 471 |
|
$path = $paths[0]; |
| 472 |
|
} |
| 473 |
} |
} |
| 474 |
|
|
| 475 |
if ($nodeapi == TRUE) { |
if ($nodeapi == TRUE) { |
| 476 |
$form['message'] = array( |
$form['message'] = array( |
| 477 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 478 |
'#title' => t('Forward this page to a friend'), |
'#title' => t(variable_get('forward_link_title', 'Email this !type'), array('!type' => 'page')), |
| 479 |
'#description' => '', |
'#description' => '', |
| 480 |
'#collapsed' => TRUE, |
'#collapsed' => TRUE, |
| 481 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 482 |
); |
); |
| 483 |
} |
} |
| 484 |
|
$form['message']['instructions'] = array( |
| 485 |
|
'#type' => 'item', |
| 486 |
|
'#value' => t(variable_get('forward_instructions', '<p>Thank you for your interest in spreading the word on !site.</p><p>NOTE: We only request your email address so that the person you are recommending the page to knows that you wanted them to see it, and that it is not junk mail. We do not capture any email address.</p>'), array('!site' => variable_get('site_name', 'drupal'))), |
| 487 |
|
); |
| 488 |
$form['message']['yemail'] = array( |
$form['message']['yemail'] = array( |
| 489 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 490 |
'#title' => t('Your Email'), |
'#title' => t('Your Email'), |
| 512 |
$form['message']['page'] = array( |
$form['message']['page'] = array( |
| 513 |
'#type' => 'item', |
'#type' => 'item', |
| 514 |
'#title' => t('You are going to email the following'), |
'#title' => t('You are going to email the following'), |
| 515 |
'#value' => l($title, $path), |
'#value' => l($title, $path, $cid), |
| 516 |
); |
); |
| 517 |
} |
} |
| 518 |
$form['message']['subject'] = array( |
$form['message']['subject'] = array( |
| 542 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 543 |
'#value' => $path, |
'#value' => $path, |
| 544 |
); |
); |
| 545 |
|
$form['message']['path_cid'] = array( |
| 546 |
|
'#type' => 'hidden', |
| 547 |
|
'#value' => (!empty($cid['fragment'])) ? '#'.$cid['fragment'] : '', |
| 548 |
|
); |
| 549 |
$form['message']['forward_footer'] = array( |
$form['message']['forward_footer'] = array( |
| 550 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 551 |
'#value' => variable_get('forward_footer', ''), |
'#value' => variable_get('forward_footer', ''), |
| 629 |
} |
} |
| 630 |
} |
} |
| 631 |
} |
} |
| 632 |
if (!user_access('administer forward')) { |
if (!user_access('override flood control')) { |
| 633 |
// Check if it looks like we are going to exceed the flood limit. |
// Check if it looks like we are going to exceed the flood limit. |
| 634 |
// It is important to ensure that the number of e-mails to be sent count against the threshold. |
// It is important to ensure that the number of e-mails to be sent count against the threshold. |
| 635 |
if (!flood_is_allowed('forward', variable_get('forward_flood_control', 10) - count($recipient_addresses) + 1)) { |
if (!flood_is_allowed('forward', variable_get('forward_flood_control', 10) - count($recipient_addresses) + 1)) { |
| 672 |
$dynamic_content .= forward_top5_list($query, $base_url, 'blog'); |
$dynamic_content .= forward_top5_list($query, $base_url, 'blog'); |
| 673 |
break; |
break; |
| 674 |
} |
} |
| 675 |
|
|
| 676 |
if ((!$form_state['values']['path']) || ($form_state['values']['path'] == 'epostcard')) { |
if ((!$form_state['values']['path']) || ($form_state['values']['path'] == 'epostcard')) { |
| 677 |
$emailtype = 'postcard'; |
$emailtype = 'epostcard'; |
| 678 |
$content = ''; |
$content = ''; |
| 679 |
$returnurl = ''; |
$returnurl = ''; |
| 680 |
} |
} |
| 720 |
$content->body = ''; |
$content->body = ''; |
| 721 |
} |
} |
| 722 |
} |
} |
| 723 |
|
|
| 724 |
if (variable_get('forward_allow_message', TRUE)) { |
if (variable_get('forward_allow_message', TRUE)) { |
| 725 |
$message = variable_get('forward_filter_html', FALSE) ? nl2br(filter_xss($form_state['values']['message'], explode(',', variable_get('forward_filter_tags', 'p,br,em,strong,cite,code,ul,ol,li,dl,dt,dd')))) : nl2br(check_plain($form_state['values']['message'])); |
$message = variable_get('forward_filter_html', FALSE) ? nl2br(filter_xss($form_state['values']['message'], explode(',', variable_get('forward_filter_tags', 'p,br,em,strong,cite,code,ul,ol,li,dl,dt,dd')))) : nl2br(check_plain($form_state['values']['message'])); |
| 726 |
} |
} |
| 727 |
else { |
else { |
| 728 |
$message = FALSE; |
$message = FALSE; |
| 729 |
} |
} |
| 730 |
|
|
| 731 |
global $theme_key; |
global $theme_key; |
| 732 |
$theme_key = variable_get('theme_default', ''); |
$theme_key = variable_get('theme_default', ''); |
| 733 |
$logo = (variable_get('forward_header_image', '') == '') ? theme_get_setting('logo') : variable_get('forward_header_image', ''); |
$logo = (variable_get('forward_header_image', '') == '') ? theme_get_setting('logo') : variable_get('forward_header_image', ''); |
| 735 |
$vars = array( |
$vars = array( |
| 736 |
'type' => $emailtype, |
'type' => $emailtype, |
| 737 |
'site_name' => check_plain(variable_get('site_name', 'Drupal')), |
'site_name' => check_plain(variable_get('site_name', 'Drupal')), |
| 738 |
'yemail' => $form_state['values']['yemail'], |
'yname' => check_plain($form_state['values']['yname']), |
| 739 |
'forward_message' => t(variable_get('forward_'. $emailtype .'message', '!name thought you would like to see the !site web site.'), array('!name' => l($form_state['values']['yname'], 'mailto:'. $form_state['values']['yemail'], array('absolute' => TRUE)), '!site' => variable_get('site_name', 'drupal'))), |
'yemail' => check_plain($form_state['values']['yemail']), |
| 740 |
|
'forward_message' => t(variable_get('forward_'. $emailtype .'_message', '!name thought you would like to see the !site web site.'), array('!name' => l($form_state['values']['yname'], 'mailto:'. $form_state['values']['yemail'], array('absolute' => TRUE)), '!site' => variable_get('site_name', 'drupal'))), |
| 741 |
'message' => $message, |
'message' => $message, |
| 742 |
'base_url' => $base_url, |
'base_url' => $base_url, |
| 743 |
'content' => $content, |
'content' => $content, |
| 744 |
'path' => $returnurl, |
'path' => $returnurl.$form_state['values']['path_cid'], |
| 745 |
'dynamic_content' => $dynamic_content, |
'dynamic_content' => $dynamic_content, |
| 746 |
'forward_ad_footer' => variable_get('forward_ad_footer', ''), |
'forward_ad_footer' => variable_get('forward_ad_footer', ''), |
| 747 |
'forward_footer' => variable_get('forward_footer', ''), |
'forward_footer' => variable_get('forward_footer', ''), |
| 748 |
|
|
| 749 |
// New values for forward.tpl.php |
// New values for forward.tpl.php |
| 750 |
'site_url' => url('forward/emailref', array('absolute' => TRUE, 'query' => 'path='.$returnurl)), |
'site_url' => url('forward/emailref', array('absolute' => TRUE, 'query' => 'path='.$returnurl.$form_state['values']['path_cid'])), |
| 751 |
'logo' => '<img src="'.url($logo, array('absolute' => TRUE)).'" alt="" />', |
'logo' => '<img src="'.url($logo, array('absolute' => TRUE)).'" alt="" />', |
| 752 |
'title' => ($emailtype == 'page') ? l($content->title, 'forward/emailref', array('absolute' => TRUE, 'query' => 'path='.$returnurl)) : FALSE, |
'title' => ($emailtype == 'page') ? l($content->title, 'forward/emailref', array('absolute' => TRUE, 'query' => 'path='.$returnurl)) : FALSE, |
| 753 |
'submitted' => (theme_get_setting('toggle_node_info_'.$content->type)) ? t('by %author', array('%author' => $content->name)) : FALSE, |
'submitted' => (theme_get_setting('toggle_node_info_'.$content->type)) ? t('by %author', array('%author' => $content->name)) : FALSE, |
| 754 |
'node' => ($emailtype == 'page') ? $content->teaser : FALSE, |
'node' => ($emailtype == 'page') ? $content->teaser : FALSE, |
| 755 |
'link' => ($emailtype == 'page') ? l(t('Click here to read more on our site'), 'forward/emailref', array('absolute' => TRUE, 'query' => 'path='.$returnurl)) : FALSE, |
'link' => ($emailtype == 'page') ? l(t('Click here to read more on our site'), 'forward/emailref', array('absolute' => TRUE, 'query' => 'path='.$returnurl.$form_state['values']['path_cid'])) : FALSE, |
| 756 |
); |
); |
| 757 |
|
|
| 758 |
if (variable_get('forward_theme_template', 0)) { |
if (variable_get('forward_theme_template', 0)) { |
| 763 |
// Old forward_*_theme functions |
// Old forward_*_theme functions |
| 764 |
$params['body'] = theme('forward_'. $emailtype, $vars); |
$params['body'] = theme('forward_'. $emailtype, $vars); |
| 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', FALSE)) ? variable_get('forward_sender_address', FALSE) : $form_state['values']['yemail']; |
$params['from'] = (variable_get('forward_sender_address', '') != '') ? variable_get('forward_sender_address', '') : $form_state['values']['yemail']; |
| 769 |
|
|
| 770 |
$recipients = trim($form_state['values']['recipients']); |
$recipients = trim($form_state['values']['recipients']); |
| 771 |
$recipients = str_replace(array("\r\n", "\n", "\r"), ',', $recipients); |
$recipients = str_replace(array("\r\n", "\n", "\r"), ',', $recipients); |
| 786 |
variable_set('forward_total', variable_get('forward_total', 0) +1); |
variable_set('forward_total', variable_get('forward_total', 0) +1); |
| 787 |
variable_set('forward_recipients', variable_get('forward_recipients', 0) + count($recipients)); |
variable_set('forward_recipients', variable_get('forward_recipients', 0) + count($recipients)); |
| 788 |
|
|
| 789 |
drupal_set_message(variable_get('forward_thankyou', t('Thank you for your help in spreading the word about') .' '. variable_get('site_name', 'drupal') .'. '. t('We appreciate your help.')), 'status'); |
drupal_set_message(t(variable_get('forward_thankyou', 'Thank you for your help in spreading the word about !site. We appreciate your help.'), array('!site' => variable_get('site_name', 'drupal'))), 'status'); |
| 790 |
$form_state['redirect'] = $returnurl; |
|
| 791 |
|
$form_state['redirect'] = ($returnurl != '') ? $returnurl : variable_get('forward_epostcard_return', ''); |
| 792 |
|
|
| 793 |
// CRMAPI hook - saves data to default enabled CRM |
// CRMAPI hook - saves data to default enabled CRM |
| 794 |
if (module_exists('crmapi')) { |
if (module_exists('crmapi')) { |
| 795 |
if (!empty($user->crmapi_contact) && is_numeric($user->crmapi_contact)) { |
if (!empty($user->crmapi_contact) && is_numeric($user->crmapi_contact)) { |
| 806 |
} |
} |
| 807 |
|
|
| 808 |
$activity_params = array( |
$activity_params = array( |
| 809 |
'contact_id' => $contact_id, |
'contact_id' => $contact_id, |
| 810 |
'activity_id' => 'OLForward', |
'activity_id' => 'OLForward', |
| 811 |
'activity_type' => 'F', |
'activity_type' => 'F', |
| 812 |
'level' => '', |
'level' => '', |
| 813 |
'flag' => '', |
'flag' => '', |
| 854 |
function forward_help($path, $arg) { |
function forward_help($path, $arg) { |
| 855 |
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) && (variable_get('forward_display_nonnode', FALSE))) { |
| 856 |
drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css'); |
drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css'); |
| 857 |
$title = t('Email this page'); |
$title = t(variable_get('forward_link_title', 'Email this !type'), array('!type' => 'page')); |
| 858 |
$img = drupal_get_path('module', 'forward') .'/forward.gif'; |
$img = drupal_get_path('module', 'forward') .'/forward.gif'; |
| 859 |
$html = FALSE; |
$html = FALSE; |
| 860 |
switch (variable_get('forward_link_style', 0)) { |
switch (variable_get('forward_link_style', 0)) { |
| 878 |
* Generate links for pages |
* Generate links for pages |
| 879 |
*/ |
*/ |
| 880 |
function forward_link($type, $node=0, $teaser=0) { |
function forward_link($type, $node=0, $teaser=0) { |
| 881 |
if ('comment' == $type && !variable_get('forward_display_comments', FALSE)) { |
if (('comment' == $type && !variable_get('forward_display_comments', FALSE)) |
| 882 |
|
||('node' == $type && (!variable_get('forward_display_nodes', TRUE) && !$teaser))) { |
| 883 |
return; |
return; |
| 884 |
} |
} |
| 885 |
|
|
| 886 |
if (($type == 'node' || $type == 'comment') && user_access('access forward') && (variable_get('forward_form_type', 'link') == 'link') && variable_get('forward_display_'. $node->type, '1')) { |
if ((($type == 'node' && variable_get('forward_display_'. $node->type, '1')) || $type == 'comment') |
| 887 |
$links=array(); |
&& user_access('access forward') && variable_get('forward_form_type', 'link') == 'link') { |
| 888 |
if (($type == 'system')) { |
$links = array(); |
| 889 |
// URL, page title, func called for page content, arg, 1 = don't disp menu |
// FIXME $type could not be 'system' due to condition above |
| 890 |
menu('forward', t('Email this page'), 'forward_page', 1, 1); |
// if (($type == 'system')) { |
| 891 |
} |
// // URL, page title, func called for page content, arg, 1 = don't disp menu |
| 892 |
|
// menu('forward', t('Email this page'), 'forward_page', 1, 1); |
| 893 |
|
// } |
| 894 |
|
|
| 895 |
// This var is set in the settings section under the admin/modules/forward section |
// This var is set in the settings section under the admin/modules/forward section |
| 896 |
// It shows 'email this $nodetype' or 'email this page' |
// It shows 'email this $nodetype' or 'email this page' |
| 903 |
|
|
| 904 |
if (!$teaser || variable_get('forward_display_teasers', 0)) { |
if (!$teaser || variable_get('forward_display_teasers', 0)) { |
| 905 |
drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css'); |
drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css'); |
| 906 |
$title = t('Email this !type', array('!type' => $forward_link_type)); |
$title = t(variable_get('forward_link_title', 'Email this !type'), array('!type' => $forward_link_type)); |
| 907 |
$img = drupal_get_path('module', 'forward') .'/forward.gif'; |
$img = drupal_get_path('module', 'forward') .'/forward.gif'; |
| 908 |
$html = FALSE; |
$html = FALSE; |
| 909 |
switch (variable_get('forward_link_style', 0)) { |
switch (variable_get('forward_link_style', 0)) { |
| 1097 |
switch ($op) { |
switch ($op) { |
| 1098 |
case 'list': |
case 'list': |
| 1099 |
$blocks[0]['info'] = t('Most Emailed'); |
$blocks[0]['info'] = t('Most Emailed'); |
| 1100 |
|
$blocks[1]['info'] = t('Forward'); |
| 1101 |
return $blocks; |
return $blocks; |
| 1102 |
case 'configure': |
case 'configure': |
| 1103 |
$block_options = array( |
switch ($delta) { |
| 1104 |
/*'today' => t('Most Emailed Today'), |
case 0: |
| 1105 |
'week' => t('Most Emailed This Week'),*/ |
$block_options = array( |
| 1106 |
'allTime' => t('Most Emailed of All Time'), |
/*'today' => t('Most Emailed Today'), |
| 1107 |
'recent' => t('Most Recently Emailed') |
'week' => t('Most Emailed This Week'),*/ |
| 1108 |
); |
'allTime' => t('Most Emailed of All Time'), |
| 1109 |
$output = forward_block_formbody($block_options); |
'recent' => t('Most Recently Emailed') |
| 1110 |
return $output; |
); |
| 1111 |
|
$output = forward_block_formbody($block_options); |
| 1112 |
|
return $output; |
| 1113 |
|
} |
| 1114 |
|
break; |
| 1115 |
case 'save': |
case 'save': |
| 1116 |
variable_set('forward_block_type', $form_state['values']['forward_block_type']); |
switch ($delta) { |
| 1117 |
|
case 0: |
| 1118 |
|
variable_set('forward_block_type', $form_state['values']['forward_block_type']); |
| 1119 |
|
break; |
| 1120 |
|
} |
| 1121 |
break; |
break; |
| 1122 |
case 'view': |
case 'view': |
| 1123 |
if (user_access('access content')) { |
switch ($delta) { |
| 1124 |
switch (variable_get('forward_block_type', 'allTime')) { |
case 0: |
| 1125 |
/*case 'today': |
if (user_access('access content')) { |
| 1126 |
$pastday = time()-(24 * 60 * 60); |
switch (variable_get('forward_block_type', 'allTime')) { |
| 1127 |
$query="SELECT n.nid, n.title, count(*) AS cnt FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type='sent' AND n.status=1 AND timestamp > ". $pastday .' GROUP BY n.nid, n.title ORDER BY cnt DESC'; |
/*case 'today': |
| 1128 |
$block['subject'] = t("Today's Most Emailed"); |
$pastday = time()-(24 * 60 * 60); |
| 1129 |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
$query="SELECT n.nid, n.title, count(*) AS cnt FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type='sent' AND n.status=1 AND timestamp > ". $pastday .' GROUP BY n.nid, n.title ORDER BY cnt DESC'; |
| 1130 |
break; |
$block['subject'] = t("Today's Most Emailed"); |
| 1131 |
case 'week': |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
| 1132 |
$pastweek = time()-(7 * 24 * 60 * 60); |
break; |
| 1133 |
$query="SELECT n.nid, n.title, count(*) AS cnt FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type='sent' AND n.status=1 AND timestamp > ". $pastweek .' GROUP BY n.nid, n.title ORDER BY cnt DESC'; |
case 'week': |
| 1134 |
$block['subject'] = t("This Week's Most Emailed"); |
$pastweek = time()-(7 * 24 * 60 * 60); |
| 1135 |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
$query="SELECT n.nid, n.title, count(*) AS cnt FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type='sent' AND n.status=1 AND timestamp > ". $pastweek .' GROUP BY n.nid, n.title ORDER BY cnt DESC'; |
| 1136 |
break;*/ |
$block['subject'] = t("This Week's Most Emailed"); |
| 1137 |
case 'allTime': |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
| 1138 |
$query="SELECT n.nid, n.title, f.* FROM {forward_statistics} f LEFT JOIN {node} n ON f.nid = n.nid WHERE forward_count > 0 ORDER BY f.forward_count DESC"; |
break;*/ |
| 1139 |
$block['subject'] = t("Most Emailed"); |
case 'allTime': |
| 1140 |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
$query="SELECT n.nid, n.title, f.* FROM {forward_statistics} f LEFT JOIN {node} n ON f.nid = n.nid WHERE forward_count > 0 ORDER BY f.forward_count DESC"; |
| 1141 |
break; |
$block['subject'] = t("Most Emailed"); |
| 1142 |
case 'recent': |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
| 1143 |
$query="SELECT n.nid, n.title, f.* FROM {forward_statistics} f LEFT JOIN {node} n ON f.nid = n.nid ORDER BY f.last_forward_timestamp DESC"; |
break; |
| 1144 |
$block['subject'] = t("Most Recently Emailed"); |
case 'recent': |
| 1145 |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
$query="SELECT n.nid, n.title, f.* FROM {forward_statistics} f LEFT JOIN {node} n ON f.nid = n.nid ORDER BY f.last_forward_timestamp DESC"; |
| 1146 |
break; |
$block['subject'] = t("Most Recently Emailed"); |
| 1147 |
} |
$block['content'] = node_title_list(db_query_range($query, 0, 5)); |
| 1148 |
return $block; |
break; |
| 1149 |
|
} |
| 1150 |
|
return $block; |
| 1151 |
|
} |
| 1152 |
|
break; |
| 1153 |
|
case 1: |
| 1154 |
|
if (user_access('access forward')) { |
| 1155 |
|
drupal_add_css(drupal_get_path('module', 'forward') .'/forward.css'); |
| 1156 |
|
$title = t(variable_get('forward_link_title', 'Email this !type'), array('!type' => t('page'))); |
| 1157 |
|
$html = FALSE; |
| 1158 |
|
switch (variable_get('forward_link_style', 0)) { |
| 1159 |
|
case 1: |
| 1160 |
|
$img = drupal_get_path('module', 'forward') .'/forward.gif'; |
| 1161 |
|
$title = theme('image', $img, $title, '', array('class' => 'forward-icon')); |
| 1162 |
|
$html = TRUE; |
| 1163 |
|
break; |
| 1164 |
|
case 2: |
| 1165 |
|
$img = drupal_get_path('module', 'forward') .'/forward.gif'; |
| 1166 |
|
$title = theme('image', $img, $title, '', array('class' => 'forward-icon forward-icon-margin')) . $title; |
| 1167 |
|
$html = TRUE; |
| 1168 |
|
break; |
| 1169 |
|
} |
| 1170 |
|
$path = $_GET['q']; |
| 1171 |
|
$link = l($title, 'forward', array( |
| 1172 |
|
'title' => $title, |
| 1173 |
|
'html' => $html, |
| 1174 |
|
'attributes' => array('title' => t('Forward this page to a friend'), 'class' => 'forward-page'), |
| 1175 |
|
'query' => 'path='. $path, |
| 1176 |
|
)); |
| 1177 |
|
return array( |
| 1178 |
|
'subject' => t('Forward'), |
| 1179 |
|
'content' => $link, |
| 1180 |
|
); |
| 1181 |
|
} |
| 1182 |
} |
} |
| 1183 |
} |
} |
| 1184 |
} |
} |