'forward', 'title' => t('forward this page'), 'callback' => 'forward_form', 'callback arguments' => array(arg(1),arg(2)), 'access' => (user_access('access content')), 'type' => MENU_CALLBACK ); $items[] = array( 'path' => 'epostcard', 'title' => t('Send an e-Postcard'), 'callback' => 'forward_form', 'callback arguments' => array(), 'access' => (user_access('access content')), 'type' => MENU_CALLBACK ); $items[] = array( 'path' => 'admin/forward', 'title' => t('forward tracking'), 'callback' => 'forward_tracking', 'callback arguments' => array(), 'access' => (user_access('administer forward')), ); return $items; } /** * Administration Page */ function forward_settings() { global $base_url; // Permission Check if (!user_access('administer forward')) { return drupal_access_denied(); } $host=parse_url($base_url); // Administrative Options $form['forward_options'] = array( '#type' => 'fieldset', '#title' => t('Administrative Options'), '#collapsible' => TRUE, '#collapsed' => FALSE ); $form['forward_options']['forward_link_type'] = array( '#type' => 'checkbox', '#title' => t('Use node type in link'), '#return_value' => 1, '#default_value' => variable_get('forward_link_type', FALSE), '#description' => t('If checked, the link will read "e-mail this node type"; if not, it will just read "e-mail this page"'), ); $form['forward_options']['forward_show_on_teasers'] = array( '#type' => 'checkbox', '#title' => t('Show link on teasers'), '#return_value' => 1, '#default_value' => variable_get('forward_show_on_teasers', FALSE), '#description' => t('If checked, the link will appear on teasers and full texts, otherwise it will appear only on full texts.'), ); $form['forward_options']['forward_form_type'] = array( '#type' => 'select', '#title' => t('Form Type'), '#default_value' => variable_get('forward_form_type', 'link'), '#options' => array('link' => t('link'), 'form' => t('form')), '#description' => t('Select link for a forward this page link or form to use a collapsible forwarding form.'), ); $form['forward_options']['forward_flood_control'] = array( '#type' => 'select', '#title' => t('Flood Control Limit'), '#default_value' => variable_get('forward_flood_control', 10), '#options' => array('1' => '1', '5' => '5', '10' => '10', '15' => '15', '20' => '20', '25' => '25', '30' => '30', '35' => '35', '40' => '40', '50' => '50'), '#description' => t("How many times a user can use the form in a one hour period. This will help prevent the forward module from being used for spamming."), ); $form['forward_options']['forward_flood_error'] = array( '#type' => 'textarea', '#title' => t('Flood Control Error'), '#default_value' => variable_get('forward_flood_error', t("You can't send more than %number messages per hour. Please try again later.")), '#cols' => 40, '#rows' => 10, '#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'), ); // Page Text Values $form['forward_text_values'] = array( '#type' => 'fieldset', '#title' => t('Page Text Values'), '#collapsible' => TRUE, '#collapsed' => FALSE ); $form['forward_text_values']['forward_instructions'] = array( '#type' => 'textarea', '#title' => t('Forward Instructions'), '#default_value' => variable_get('forward_instructions', '

'. t('Thank you for your interest in spreading the word on %site_name.', array('%site_name' => variable_get('site_name', 'drupal'))) .'

'. t('NOTE: We only request your e-mail 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 e-mail address.').'

'), '#cols' => 40, '#rows' => 10, '#description' => t('This message will be displayed above the form.'), ); $form['forward_text_values']['forward_thankyou'] = array( '#type' => 'textarea', '#title' => t('Thank You Message'), '#default_value' => variable_get('forward_thankyou', t('Thank you for your help in spreading the word about %site_name. We appreciate your help.', array('%site_name' => variable_get('site_name', 'drupal')))), '#cols' => 40, '#rows' => 10, '#description' => t('This message will be displayed after the user successfully submits the form.'), ); // Forward Form Default Values $form['forward_default_values'] = array( '#type' => 'fieldset', '#title' => t('Forward Form Default Values'), '#collapsible' => TRUE, '#collapsed' => FALSE ); $form['forward_default_values']['forward_sender_addy'] = array( '#type' => 'textfield', '#title' => t('From Address'), '#default_value' => variable_get('forward_sender_addy', "NoReply@".$host['host']), '#size' => 40, '#maxlength' => 40, '#description' => t('The address to send from. Should be a functioning e-mail address.'), ); $form['forward_default_values']['forward_header_image'] = array( '#type' => 'textfield', '#title' => t('Header Image for e-mail'), '#default_value' => variable_get('forward_header_image',''), '#size' => 40, '#maxlength' => 256, '#description' => t('Enter the URL of the image to as a logo at the top of forwarded pages.'), '#attributes' => FALSE, ); $form['forward_default_values']['forward_emailsubject'] = array( '#type' => 'textfield', '#title' => t('Forward Message subject'), '#default_value' => variable_get('forward_emailsubject', t('%name has forwarded a page to you from %site')), '#size' => 40, '#maxlength' => 256, '#description' => t("E-mail 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"), ); $form['forward_default_values']['forward_emailmessage'] = array( '#type' => 'textarea', '#title' => t('Forward Message body'), '#default_value' => variable_get('forward_emailmessage', t('%name thought you would like to see this page from the %site web site.')), '#cols' => 40, '#rows' => 10, '#description' => t("E-mail 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."), ); $form['forward_default_values']['forward_postcardsubject'] = array( '#type' => 'textfield', '#title' => t('e-Postcard Message subject'), '#default_value' => variable_get('forward_postcardsubject', t('%name has sent you an e-postcard from %site')), '#size' => 40, '#maxlength' => 256, '#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."), ); $form['forward_default_values']['forward_postcardmessage'] = array( '#type' => 'textarea', '#title' => t('e-Postcard Message body'), '#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.')), '#cols' => 40, '#rows' => 10, '#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."), ); $form['forward_default_values']['forward_ad_footer'] = array( '#type' => 'textarea', '#title' => t('Organization Ad'), '#default_value' => variable_get('forward_ad_footer', ''), '#cols' => 40, '#rows' => 10, '#description' => t('This message will be just above the footer message in the e-mail.'), ); $form['forward_default_values']['forward_footer'] = array( '#type' => 'textarea', '#title' => t('Footer Message'), '#default_value' => variable_get('forward_footer', ''), '#cols' => 40, '#rows' => 4, '#description' => t('This message will be postpended as a footer message to the e-mail.'), ); $dyn_options = array( 'node' => t('Latest Blog Articles'), 'user' => t('Latest Users'), 'comment' => t('Latest Comments'), 'popular' => t('Most Popular Content'), 'none' => t('None') ); $form['forward_default_values']['forward_dynamic_block'] = array( '#type' => 'radios', '#title' => t('Dynamic Block'), '#default_value' => variable_get('forward_dynamic_block', 'none'), '#options' => $dyn_options, '#description' => t('Choose the dynamic block to send with these e-mails.'), '#required' => TRUE, '#attributes' => NULL, ); return $form; } /** * Form */ function forward_form() { if (!user_access('access forward')) { return drupal_access_denied(); } $nid = arg(1); global $base_url, $user; $host = parse_url($base_url); if (arg(2) == 'email_ref'){ db_query("INSERT INTO {forward_log} (nid, type, timestamp) VALUES ('%d', '%s', %d)", $nid, "REF", time()); if (arg(1) == 'postcard'){ drupal_goto(); } else { drupal_goto('node/'. $nid); } } if (!flood_is_allowed('forward', variable_get('forward_flood_control', 10))) { $output = strtr(variable_get('forward_flood_error', t("You can't send more than %number messages per hour. Please try again later.")), array('%number' => variable_get('forward_flood_control', 10))); } else { $form = array(); $url = $base_url.'/node/'.$nid; $output = variable_get('forward_instructions', '

'. t('Thank you for your interest in spreading the word on %site_name.', array('%site_name' => variable_get('site_name', 'drupal'))) .'

'. t('NOTE: We only request your e-mail 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 e-mail address.').'

'); if ($nid != '') { $emailtype = 'email'; } else { $emailtype = 'postcard'; } $form['message'] = array( '#type' => 'fieldset', '#title' => t('Message to send'), '#description' => '', ); $form['message']['yemail'] = array( '#type' => 'textfield', '#title' => t('Your e-mail address'), '#default_value' => $user->mail, '#size' => 50, '#maxlength' => 256, '#description' => NULL, '#attributes' => NULL, '#required' => TRUE, ); $form['message']['yname'] = array( '#type' => 'textfield', '#title' => t('Your name'), '#default_value' => $user->name, '#size' => 50, '#maxlength' => 256, '#description' => NULL, '#attributes' => NULL, '#required' => TRUE, ); $form['message']['recipients'] = array( '#type' => 'textarea', '#title' => t('Send to'), '#default_value' => str_replace(', ', '\n', $recipients), '#cols' => 50, '#rows' => 5, '#description' => t('Enter multiple addresses on separate lines or separate them with commas.'), '#attributes' => NULL, '#required' => TRUE, ); if ($emailtype == 'email') { $form['message'][] = array( '#type' => 'item', '#title' => t('Page being sent'), '#value' => url('node/'. $nid, NULL, NULL, TRUE), ); } $form['message']['subject'] = array( '#type' => 'item', '#title' => t('Message subject'), '#value' => strtr(variable_get('forward_'.$emailtype.'subject', t('%name has sent you a message from %site')), array('%name' => '('. t('Your name') .')', '%site' => variable_get('site_name', 'drupal'))), '#description' => '', ); $form['message']['body'] = array( '#type' => 'item', '#title' => t('Message body'), '#value' => strtr(variable_get('forward_'.$emailtype.'message', t('%name thought you would like to see this page from the %site web site.')), array('%name' => '('. t('Your name') .')', '%site' => variable_get('site_name', 'drupal'))), '#description' => '', ); $form['message']['message'] = array( '#type' => 'textarea', '#title' => t('Your personal message'), '#default_value' => '', '#cols' => 50, '#rows' => 10, '#description' => '', '#attributes' => NULL, '#required' => TRUE, ); $form['message']['nid'] = array( '#type' => 'hidden', '#value' => $nid, ); $form['message']['forward_footer'] = array( '#type' => 'hidden', '#value' => variable_get('forward_footer', ''), ); $form['message'][] = array( '#type' => 'submit', '#value' => t('Send e-mail'), ); $form['#method'] = 'post'; $output .= drupal_get_form('forward_form', $form); } return $output; } /** * Generate nodeapi integration, foward signup */ function forward_nodeapi(&$node, $op, $arg = 0){ if (variable_get('forward_form_type', 'link') == "form" && !$node->in_preview && variable_get('forward_display_'. $node->type, '0') == 1){ switch ($op) { case 'view': global $user; $form['message'] = array( '#type' => 'fieldset', '#title' => t('Forward this page to a friend'), '#description' => '', '#collapsed' => TRUE, '#collapsible' => TRUE, ); $form['message']['yemail'] = array( '#type' => 'textfield', '#title' => t('Your e-mail address'), '#default_value' => $user->mail, '#size' => 45, '#maxlength' => 256, '#description' => NULL, '#attributes' => NULL, '#required' => TRUE, ); $form['message']['yname'] = array( '#type' => 'textfield', '#title' => t('Your name'), '#default_value' => $user->name, '#size' => 45, '#maxlength' => 256, '#description' => NULL, '#attributes' => NULL, '#required' => TRUE, ); $form['message']['recipients'] = array( '#type' => 'textarea', '#title' => t('Send to'), '#default_value' => str_replace(', ', '\n', $recipients), '#cols' => 50, '#rows' => 5, '#description' => t('Enter multiple addresses on separate lines or separate them with commas.'), '#attributes' => NULL, '#required' => TRUE, ); $form['message']['subject'] = array( '#type' => 'item', '#title' => t('Message subject'), '#value' => strtr(variable_get('forward_'.$emailtype.'subject', t('%name has sent you a message from %site')), array('%name' => t('(Your name)'), '%site' => variable_get('site_name', 'drupal'))), '#description' => '', ); $form['message']['body'] = array( '#type' => 'item', '#title' => t('Message body'), '#value' => strtr(variable_get('forward_'.$emailtype.'message', t('%name thought you would like to see this page from the %site web site.')), array('%name' => t('(Your name)'), '%site' => variable_get('site_name', 'drupal'))), '#description' => '', ); $form['message']['message'] = array( '#type' => 'textarea', '#title' => t('Your personal message'), '#default_value' => '', '#cols' => 50, '#rows' => 10, '#description' => '', '#attributes' => NULL, '#required' => TRUE, ); $form['message']['nid'] = array( '#type' => 'hidden', '#value' => $node->nid, ); $form['message']['forward_footer'] = array( '#type' => 'hidden', '#value' => variable_get('forward_footer', ''), ); $form['message'][] = array( '#type' => 'submit', '#value' => t('Send e-mail'), ); $form['#method'] = 'post'; $output = drupal_get_form('forward_form', $form); $node->body .= $output; break; } } } function forward_form_validate($form_id, &$form) { ### Here the global variable where form values are stored is brought into the function ### for possible editing global $form_values; ### To check values, simply access them w/ the same name with which they were declared if (!user_access('administer forward')) { if (!flood_is_allowed('forward', variable_get('forward_flood_control', 10))) { form_set_error(NULL,variable_get('forward_flood_error', t("You can't send more than %number messages per hour. Please try again later.", array('%number' => variable_get('forward_flood_control', 10))))); } } $yname = $_POST['edit']['yname']; $yemail = $_POST['edit']['yemail']; $recipients = $_POST['edit']['recipients']; $message = $_POST['edit']['message']; $nid = $_POST['edit']['nid']; $url = $base_url.'/node/'.$nid; // normalize address entries $recipients = trim($form['recipients']); $recipients = str_replace(array("\r\n", "\n", "\r"), ', ', $recipients); $recipients = str_replace(',', ', ', $recipients); $recipients = str_replace(', ', ', ', $recipients); // convert addresses to an array $recipient_addresses = explode(', ', $recipients); $arBadStr = array("Content-Type:", "MIME-Version:", "Content-Transfer-Encoding:", "bcc:", "cc:"); foreach($arBadStr as $tStr){ if (eregi($tStr, $yemail) || eregi($tStr, $subject)) { $badstr = true; } } if (strpos($form['yemail'], "\r") !== false || strpos($yemail, "\n") !== false || $badstr == true) { form_set_error('yemail', t('Header injection attempt detected. Do not enter line feed characters into the from field!')); } if (user_validate_mail($form['yemail'])){ form_set_error('yemail', t('Your e-mail address is invalid.')); } if (!$form['yname']) { form_set_error('yname', t('You must enter your name.')); } if ($recipients == '') { form_set_error('recipients', t('You did not enter any recipients.')); } else { foreach ($recipient_addresses as $address) { if ((user_validate_mail($address)) && ($address != '')) { form_set_error('recipients', t('One of your Recipient addresses is invalid:').'
'.$address); } } } if (!$form['message']) { form_set_error('message', t('You must enter a message.')); } } function forward_form_submit($form_id, $edit) { // Prepare the sender: $from = $edit['mail']; // Compose the body: ### Note how the form values are accessed the same way they were accessed in the validate ### function //If selected assemble dynamic footer block. switch (variable_get('forward_dynamic_block','')) { case 'node': $dynamic_content = '

'.t('Recent blog posts').'

'; $query = "SELECT n.nid, n.title FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"; $dynamic_content .= forward_top5_list($query, $base_url,'blog'); break; case 'user': $dynamic_content = '

'.t("Who's new").'

'; $query = 'SELECT u.uid, u.name FROM {users} u WHERE status != 0 ORDER BY uid DESC'; $dynamic_content .= forward_top5_list($query, $base_url,'user'); break; case 'comment': $dynamic_content = '

'.t('Recent comments').'

'; $query = 'SELECT c.nid, c.cid, c.subject FROM {comments} c WHERE c.status = 0 ORDER BY c.timestamp DESC'; $dynamic_content .= forward_top5_list($query, $base_url, 'comment'); break; case 'popular': $dynamic_content = '

'.t('Most popular content').'

'; $query = "SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid WHERE s.timestamp <> '0' AND n.status = 1 ORDER BY s.timestamp DESC"; $dynamic_content .= forward_top5_list($query, $base_url,'blog'); break; } if (!$edit['nid']) { $emailtype = 'postcard'; $nid = ''; $content_title = ''; $content_name = ''; $content_teaser = ''; $returnurl = ''; } else { $nid = $edit['nid']; $emailtype = 'email'; //Get article information. $content = node_load($nid); $content->teaser = check_markup($content->teaser, $content->format, FALSE); $returnurl = 'node/'. $nid; } $vars = array( 'forward_header_image' => variable_get('forward_header_image', ''), 'site_name' => variable_get('site_name', 'drupal'), 'yemail' => $edit['yemail'], 'forward_message' => strtr(variable_get('forward_'.$emailtype.'message', t('%name thought you would like to see this page from the %site web site.')), array('%name' => l($edit['yname'], 'mailto:'.$edit['yemail'],NULL,NULL,NULL,TRUE), '%site' => variable_get('site_name', 'drupal'))), 'message' => $edit['message'], 'base_url' => $base_url, 'content' => $content, 'dynamic_content' => $dynamic_content, 'forward_ad_footer' => variable_get('forward_ad_footer', ''), 'forward_footer' => variable_get('forward_footer', '') ); $body = theme('forward_'.$emailtype, $vars); $subject = strtr(variable_get('forward_'.$emailtype.'subject', t('%name has sent you a message from %site')), array('%name' => $edit['yname'], '%site' => variable_get('site_name', 'drupal'))); $headers = "From: ".$edit['yemail']."\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $recipients = trim($edit['recipients']); $recipients = str_replace(array("\r\n", "\n", "\r"), ', ', $recipients); $recipients = str_replace(',', ', ', $recipients); $recipients = str_replace(', ', ', ', $recipients); forward_mail($recipients, $subject, $body, $headers); // insert record into db to record nid, type and timestamp of send db_query("INSERT INTO {forward_log} (nid, type, timestamp) VALUES ('%d', '%s', %d)", $nid, "SENT", time()); variable_set('forward_total', variable_get('forward_total', 0) +1); variable_set('forward_recipients', variable_get('forward_recipients', 0) + substr_count($recipients, ",") + 1); flood_register_event('forward'); drupal_set_message(variable_get('forward_thankyou', t('Thank you for your help in spreading the word about %site_name. We appreciate your help.', array('%site_name' => variable_get('site_name', 'drupal')))), 'status'); drupal_goto($returnurl); } function forward_mail($mail, $subject, $message, $header) { if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) { include_once './' . variable_get('smtp_library', ''); return user_mail_wrapper($mail, $subject, $message, $header); } else { return mail($mail, $subject, $message, $header); } } /** * Generate links for pages */ function forward_link($type, $node = NULL, $teaser = FALSE) { if (user_access('access forward') && ($teaser === FALSE || variable_get('forward_show_on_teasers', FALSE)) && variable_get('forward_form_type', 'link') == 'link' && variable_get('forward_display_'. $node->type, '1')) { $links = array(); // This var is set in the settings section under the admin/modules/forward section // It shows 'email this $nodetype' or 'email this page' $forward_link_type = variable_get('forward_link_type', FALSE); if (variable_get('forward_show_on_teasers', FALSE)) { $links[] = l(t("e-mail this page"), 'forward/', array('title' => t('Forward this page to a friend'), 'class' => 'forward-page')); return $links; } elseif (!$forward_link_type) { $links[] = l(t("e-mail this page"), "forward/$node->nid", array('title' => t('Forward this page to a friend'), 'class' => 'forward-page')); return $links; } else { if ($type == 'comment') { $forward_link_type = t('comment'); $links[] = l(t("e-mail this %type", array('%type' => $forward_link_type)), "forward/$node->nid&cid=$node->cid", array('title' => t('Forward this page to a friend'), 'class' => 'forward-page')); } else { $forward_link_type = $node->type; $links[] = l(t("e-mail this %type", array('%type' => $forward_link_type)), "forward/$node->nid", array('title' => t('Forward this page to a friend'), 'class' => 'forward-page')); } return $links; } } } function forward_form_alter($form_id, &$form){ if (isset($form['type'])) { // Add the node-type settings option to activate the email this page link if ($form['type']['#value'] .'_node_settings' == $form_id) { $form['workflow']['forward_display_'. $form['type']['#value']] = array( '#type' => 'checkbox', '#title' => t('Show forwarding link/form'), '#return_value' => 1, '#default_value' => variable_get('forward_display_'. $form['type']['#value'], '1'), '#description' => t('Displays the form/link to allow visitors to forward the page to a friend. Further configuration is available on the %settings.', array('%settings' => l(t('settings page'), 'admin/settings/forward' ))), ); } } } /** * Forward Tracking Page */ function forward_tracking() { $header = array( array('data' => t('Time'), 'field' => 'f.timestamp', 'sort' => 'desc'), array('data' => t('Type'), 'field' => 'f.type'), array('data' => t('Path')), array('data' => t('Title'), 'field' => 'n.title') ); $result = pager_query('SELECT f.*, n.title FROM {forward_log} f LEFT JOIN {node} n ON f.nid = n.nid'. tablesort_sql($header), 30, 0, NULL); if (db_num_rows($result)) { while ($log = db_fetch_object($result)) { $_path = drupal_get_path_alias('node/'.$log->nid); $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), $log->type, l($_path, $_path), l(_forward_column_width($log->title), $_path)); } if ($pager = theme('pager', NULL, 30, 0)) { $rows[] = array(array('data' => $pager, 'colspan' => '4')); } $output = '

'. t('%total e-mails sent to %recipients recipients.', array('%total' => variable_get('forward_total', 0), '%recipients' => variable_get('forward_recipients', 0))) .'

'; $output .= theme('table', $header, $rows); } else { $output = '

'.t('No one has used forward yet.').'

'; } drupal_set_title(t('Forward tracking')); return $output; } /** * Implementation of hook_block(). */ function forward_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('Most e-mailed'); return $blocks; case 'configure': $block_options = array ( 'today' => t('Most e-mailed today'), 'week' => t('Most e-mailed this week'), 'allTime' => t('Most e-mailed of all time'), 'recent' => t('Most recently e-mailed') ); $form['forward_block_type'] = array( '#type' => 'radios', '#title' => t('Block Type'), '#default_value' => variable_get('forward_block_type', " "), '#options' => $block_options, '#description' => t('Choose the block type'), '#required' => NULL, '#attributes' => TRUE, ); $output = drupal_get_form('forward_block', $form); return $output; case 'save': variable_set('forward_block_type', $edit['forward_block_type']); break; case 'view': if (user_access('access content')) { switch (variable_get('forward_block_type','allTime')) { case 'today': $pastday = time()-(24 * 60 * 60); $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" AND timestamp > '.$pastday.' GROUP BY n.nid DESC'; $block['subject'] = t("Today's most e-mailed"); $block['content'] = node_title_list(db_query_range($query, 0, 5)); break; case 'week': $pastweek = time()-(7 * 24 * 60 * 60); $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" AND timestamp > '.$pastweek.' GROUP BY n.nid DESC'; $block['subject'] = t("This week's most e-mailed"); $block['content'] = node_title_list(db_query_range($query, 0, 5)); break; case 'allTime': $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" GROUP BY n.nid DESC'; $block['subject'] = t('Most e-mailed'); $block['content'] = node_title_list(db_query_range($query, 0, 5)); break; case 'recent': $query="SELECT DISTINCT n.nid, n.title FROM {node} n LEFT JOIN {forward_log} s ON s.nid = n.nid WHERE s.timestamp <> '0' AND s.type='SENT' AND n.status = 1 ORDER BY s.timestamp DESC"; $block['subject'] = t('Most recently e-mailed'); $block['content'] = node_title_list(db_query_range($query, 0, 5)); break; } return $block; } } } // this function supports the dynamic footer generation function forward_top5_list($query, $base_url, $type) { $items = '
    '; $result = db_query_range($query, 0, 5); while ($lineitem = db_fetch_array($result)) { if ($type == 'user'){ $items .= '
  1. '.l(next($lineitem),'/user/'.current($lineitem)).'
  2. '; } elseif ($type == 'comment'){ $items .= '
  3. '.l(next($lineitem),'/node/'.current($lineitem).'#comment-'.next($lineitem)).'
  4. '; } else { $items .= '
  5. '.l(next($lineitem),'/node/'.current($lineitem)).'
  6. '; } } return $items.'
'; } function _forward_column_width($column, $width = 35) { return (strlen($column) > $width ? substr($column, 0, $width) . '...' : $column); }