summaryrefslogtreecommitdiffstats
path: root/print_mail
diff options
context:
space:
mode:
authorJoao Ventura2012-05-09 01:08:52 +0000
committerJoao Ventura2012-05-09 01:08:52 +0000
commit2831322ba0b17bd4ceadf2761e0393cffc1fbcf4 (patch)
treed32404a2288e23afc11d5ddebea1b7561f3f8021 /print_mail
parent2bc194e36f48be105c2a3f53d1e81b17a4830fc6 (diff)
Refine link functions
Create upgrade functions to delete old variables and to rename the print_display_type vars to print_html_display_type
Diffstat (limited to 'print_mail')
-rw-r--r--print_mail/print_mail.admin.inc28
-rw-r--r--print_mail/print_mail.inc22
-rw-r--r--print_mail/print_mail.install50
-rw-r--r--print_mail/print_mail.module12
4 files changed, 70 insertions, 42 deletions
diff --git a/print_mail/print_mail.admin.inc b/print_mail/print_mail.admin.inc
index c0cd198..5ade85e 100644
--- a/print_mail/print_mail.admin.inc
+++ b/print_mail/print_mail.admin.inc
@@ -19,18 +19,13 @@
* @ingroup forms
*/
function print_mail_settings() {
+ $link = print_mail_print_link();
+
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Send by email options'),
);
- $form['settings']['print_mail_link_text'] = array(
- '#type' => 'textfield',
- '#title' => t('Link text'),
- '#default_value' => variable_get('print_mail_link_text', t('Send by email')),
- '#description' => t('Text used in the link to the send by-email form.'),
- );
-
$form['settings']['print_mail_hourly_threshold'] = array(
'#type' => 'select',
'#title' => t('Hourly threshold'),
@@ -83,5 +78,24 @@ function print_mail_settings() {
'#description' => t('Enabling this option will display a list of printer-friendly destination URLs at the bottom of the page.'),
);
+ $form['settings']['link_text'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Custom link text'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $form['settings']['link_text']['print_mail_link_text_enabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable custom link text'),
+ '#default_value' => variable_get('print_mail_link_text_enabled', PRINT_TYPE_LINK_TEXT_ENABLED_DEFAULT),
+ );
+
+ $form['settings']['link_text']['print_mail_link_text'] = array(
+ '#type' => 'textfield',
+ '#default_value' => variable_get('print_mail_link_text', $link['text']),
+ '#description' => t('Text used in the link to the send by email form.'),
+ );
+
return system_settings_form($form);
}
diff --git a/print_mail/print_mail.inc b/print_mail/print_mail.inc
index 2ca75a3..5c58c23 100644
--- a/print_mail/print_mail.inc
+++ b/print_mail/print_mail.inc
@@ -30,13 +30,14 @@ function print_mail_form($form, &$form_state) {
if (empty($path)) {
// If no path was provided, let's try to generate a page for the referer
global $base_url;
+ $link = print_mail_print_link();
$ref = $_SERVER['HTTP_REFERER'];
$path = preg_replace("!^$base_url/!", '', $ref);
if (($path === $ref) || empty($path)) {
$path = variable_get('site_frontpage', 'node');
}
- drupal_goto(PRINTMAIL_PATH . '/' . $path);
+ drupal_goto($link['path'] . '/' . $path);
}
elseif (ctype_digit($path_arr[1])) {
if (drupal_lookup_path('source', $path)) {
@@ -165,10 +166,8 @@ function print_mail_form($form, &$form_state) {
$user_name = t('Someone');
}
$site_name = variable_get('site_name', t('an interesting site'));
- $print_mail_text_subject = filter_xss(variable_get('print_mail_text_subject', t('!user has sent you a message from !site')));
- $form['fld_subject']['#default_value'] = t($print_mail_text_subject, array('!user' => $user_name, '!site' => $site_name, '!title' => $title));
- $print_mail_text_content = filter_xss(variable_get('print_mail_text_content', ''));
- $form['txt_message']['#default_value'] = t($print_mail_text_content);
+ $form['fld_subject']['#default_value'] = t('!user has sent you a message from !site', array('!user' => $user_name, '!site' => $site_name, '!title' => $title));
+ $form['txt_message']['#default_value'] = t('');
return $form;
}
@@ -262,10 +261,13 @@ function print_mail_form_validate($form, &$form_state) {
/**
* Process the send by-email form submission.
*
+ * @see print_controller()
* @ingroup forms
*/
function print_mail_form_submit($form, &$form_state) {
if (!array_key_exists('cancel', $form_state['values'])) {
+ $link = print_mail_print_link();
+
if (!empty($form_state['values']['fld_from_name'])) {
$from = '"' . mime_header_encode($form_state['values']['fld_from_name']) . '" <' . $form_state['values']['fld_from_addr'] . '>';
}
@@ -274,10 +276,9 @@ function print_mail_form_submit($form, &$form_state) {
}
$cid = isset($form_state['values']['cid']) ? $form_state['values']['cid'] : NULL;
- $print_mail_text_message = filter_xss_admin(variable_get('print_mail_text_message', t('Message from sender')));
- $sender_message = $print_mail_text_message . ':<br /><br /><em>' . nl2br(check_plain($form_state['values']['txt_message'])) . '</em>';
+ $sender_message = t('Message from sender') . ':<br /><br /><em>' . nl2br(check_plain($form_state['values']['txt_message'])) . '</em>';
- $print = print_controller($form_state['values']['path'], $cid, PRINT_MAIL_FORMAT, $form_state['values']['chk_teaser'], $sender_message);
+ $print = print_controller($form_state['values']['path'], $link['format'], $cid, $form_state['values']['chk_teaser'], $sender_message);
// Spaces in img URLs must be replaced with %20
$pattern = '!<(img\s[^>]*?)>!is';
@@ -293,7 +294,7 @@ function print_mail_form_submit($form, &$form_state) {
$params['title'] = $form_state['values']['title'];
$node = $print['node'];
- $params['body'] = theme('print', array('print' => $print, 'type' => PRINT_MAIL_FORMAT, 'node' => $node));
+ $params['body'] = theme('print', array('print' => $print, 'type' => $link['format'], 'node' => $node));
$ok = FALSE;
if (function_exists('job_queue_add') && variable_get('print_mail_job_queue', PRINT_MAIL_JOB_QUEUE_DEFAULT)) {
@@ -331,8 +332,7 @@ function print_mail_form_submit($form, &$form_state) {
if ($ok) {
watchdog('print_mail', '%name [%from] sent %page to [%to]', array('%name' => $form_state['values']['fld_from_name'], '%from' => $form_state['values']['fld_from_addr'], '%page' => $form_state['values']['path'], '%to' => $form_state['values']['txt_to_addrs']));
$site_name = variable_get('site_name', t('us'));
- $print_mail_text_confirmation = variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.'));
- drupal_set_message(check_plain(t($print_mail_text_confirmation, array('!site' => $site_name))));
+ drupal_set_message(check_plain(t('Thank you for spreading the word about !site.', array('!site' => $site_name))));
$nodepath = drupal_get_normal_path($form_state['values']['path']);
db_update('print_mail_page_counter')
diff --git a/print_mail/print_mail.install b/print_mail/print_mail.install
index 62cbc64..67082cb 100644
--- a/print_mail/print_mail.install
+++ b/print_mail/print_mail.install
@@ -31,28 +31,24 @@ function print_mail_enable() {
* Implements hook_uninstall().
*/
function print_mail_uninstall() {
- variable_del('print_mail_settings');
- variable_del('print_mail_show_link');
- variable_del('print_mail_link_pos');
- variable_del('print_mail_link_teaser');
- variable_del('print_mail_node_link_visibility');
- variable_del('print_mail_node_link_pages');
- variable_del('print_mail_link_class');
- variable_del('print_mail_sys_link_visibility');
- variable_del('print_mail_sys_link_pages');
- variable_del('print_mail_book_link');
+ variable_del('print_mail_display_sys_urllist');
variable_del('print_mail_hourly_threshold');
- variable_del('print_mail_teaser_default');
- variable_del('print_mail_teaser_choice');
+ variable_del('print_mail_job_queue');
variable_del('print_mail_link_text');
+ variable_del('print_mail_link_text_enabled');
+ variable_del('print_mail_send_option_default');
+ variable_del('print_mail_teaser_choice');
+ variable_del('print_mail_teaser_default');
+
+ variable_del('print_mail_book_link');
+ variable_del('print_mail_link_class');
+ variable_del('print_mail_link_pos');
+ variable_del('print_mail_link_teaser');
variable_del('print_mail_link_use_alias');
- variable_del('print_mail_text_title');
- variable_del('print_mail_text_confirmation');
- variable_del('print_mail_text_message');
- variable_del('print_mail_text_subject');
- variable_del('print_mail_text_content');
- variable_del('print_mail_job_queue');
- variable_del('print_mail_display_sys_urllist');
+ variable_del('print_mail_show_link');
+ variable_del('print_mail_sys_link_pages');
+ variable_del('print_mail_sys_link_visibility');
+
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_mail\_display\_%'");
foreach ($settings as $variable) {
variable_del($variable->name);
@@ -181,3 +177,19 @@ function print_mail_update_7101(&$sandbox) {
->condition('permission', 'send unlimited e-mails')
->execute();
}
+
+/**
+ * Delete old variables
+ */
+function print_mail_update_7200(&$sandbox) {
+ variable_del('print_mail_settings');
+
+ variable_del('print_mail_node_link_pages');
+ variable_del('print_mail_node_link_visibility');
+
+ variable_del('print_mail_text_title');
+ variable_del('print_mail_text_confirmation');
+ variable_del('print_mail_text_message');
+ variable_del('print_mail_text_subject');
+ variable_del('print_mail_text_content');
+}
diff --git a/print_mail/print_mail.module b/print_mail/print_mail.module
index d25c42b..e390c1f 100644
--- a/print_mail/print_mail.module
+++ b/print_mail/print_mail.module
@@ -64,10 +64,11 @@ function print_mail_theme() {
* Implements hook_menu().
*/
function print_mail_menu() {
+ $link = print_mail_print_link();
$items = array();
- $items[PRINTMAIL_PATH] = array(
- 'title' => variable_get('print_mail_text_title', 'Send page by email'),
+ $items[$link['path']] = array(
+ 'title' => 'Send by email',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_mail_form'),
'access callback' => '_print_mail_access',
@@ -75,7 +76,7 @@ function print_mail_menu() {
'type' => MENU_CALLBACK,
'file' => 'print_mail.inc',
);
- $items[PRINTMAIL_PATH . '/' . PRINTMAIL_PATH] = array(
+ $items[$link['path'] . '/' . $link['path']] = array(
'access callback' => FALSE,
);
$items['admin/config/user-interface/print/email'] = array(
@@ -151,9 +152,10 @@ function print_mail_job_queue_functions() {
* TRUE if the user has permission to view the page, FALSE otherwise
*/
function _print_mail_access($permission) {
+ $link = print_mail_print_link();
$page_access = TRUE;
$parts = explode('/', $_GET['q']);
- if ($parts[0] == PRINTMAIL_PATH) {
+ if ($parts[0] == $link['path']) {
if (count($parts) > 1) {
unset($parts[0]);
$path = implode('/', $parts);
@@ -209,7 +211,7 @@ function print_mail_insert_link($path = NULL, $node = NULL) {
*/
function print_mail_mollom_form_list() {
$forms['print_mail_form'] = array(
- 'title' => t('Send page form'),
+ 'title' => t('Send by email form'),
'entity' => 'print_mail',
);
return $forms;