| 1 |
<?php |
<?php |
| 2 |
/* $Id: forward.module,v 1.92 2009/07/06 21:42:05 seanr Exp $ */ |
/* $Id: forward.module,v 1.91 2009/06/24 14:58:29 seanr Exp $ */ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 95 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 96 |
'#title' => t('Administrative Options'), |
'#title' => t('Administrative Options'), |
| 97 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 98 |
'#collapsed' => TRUE |
'#collapsed' => FALSE |
| 99 |
); |
); |
| 100 |
$form['forward_options']['forward_link_style'] = array( |
$form['forward_options']['forward_link_style'] = array( |
| 101 |
'#type' => 'radios', |
'#type' => 'radios', |
| 118 |
'#default_value' => variable_get('forward_link_title', 'Email this !type'), |
'#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.'), |
'#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'), |
| 226 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 227 |
'#title' => t('Page Text Values'), |
'#title' => t('Page Text Values'), |
| 228 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 229 |
'#collapsed' => TRUE |
'#collapsed' => FALSE |
| 230 |
); |
); |
| 231 |
$form['forward_text_values']['forward_instructions'] = array( |
$form['forward_text_values']['forward_instructions'] = array( |
| 232 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 250 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 251 |
'#title' => t('Default Values for Email This Page'), |
'#title' => t('Default Values for Email This Page'), |
| 252 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 253 |
'#collapsed' => TRUE, |
'#collapsed' => FALSE, |
| 254 |
'#description' => t('These options will set the default values for the "email this page" form.') |
'#description' => t('These options will set the default values for the "email this page" form.') |
| 255 |
); |
); |
| 256 |
$form['forward_page_defaults']['forward_header_image'] = array( |
$form['forward_page_defaults']['forward_header_image'] = array( |
| 299 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 300 |
'#title' => t('Default Values for e-Postcard'), |
'#title' => t('Default Values for e-Postcard'), |
| 301 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 302 |
'#collapsed' => TRUE, |
'#collapsed' => FALSE, |
| 303 |
'#description' => t('These options will set the default values for the "Send an e-Postcard" form.') |
'#description' => t('These options will set the default values for the "Send an e-Postcard" form.') |
| 304 |
); |
); |
| 305 |
$form['forward_epostcard_defaults']['forward_epostcard_title'] = array( |
$form['forward_epostcard_defaults']['forward_epostcard_title'] = array( |
| 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(variable_get('forward_link_title', 'Email this !type'), array('!type' => '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' |
| 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', $edit['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 |
} |
} |