diff --git a/print.admin.inc b/print.admin.inc index a3f9a770738740de0486ebcde7ee2579522d2177..e793cc5068d0cb030230a086233ae717a0d2187b 100644 --- a/print.admin.inc +++ b/print.admin.inc @@ -262,6 +262,17 @@ function print_html_settings() { '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')), ); + $access = user_access('use PHP for link visibility'); + + if ($form['settings']['adv_link']['print_html_node_link_visibility']['#default_value'] == 2 && !$access) { + $form['settings']['adv_link']['print_html_node_link_visibility'] = array('#type' => 'value', '#value' => 2); + $form['settings']['adv_link']['print_html_node_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_html_node_link_pages']['#default_value']); + } + elseif ($access) { + $form['settings']['adv_link']['print_html_node_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); + $form['settings']['adv_link']['print_html_node_link_pages']['#description'] .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); + } + $form['settings']['adv_link']['print_html_sys_link_visibility'] = array( '#type' => 'radios', '#title' => t('Show link in system (non-content) pages'), @@ -277,6 +288,15 @@ function print_html_settings() { t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')), ); + if ($form['settings']['adv_link']['print_html_sys_link_visibility']['#default_value'] == 2 && !$access) { + $form['settings']['adv_link']['print_html_sys_link_visibility'] = array('#type' => 'value', '#value' => 2); + $form['settings']['adv_link']['print_html_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_html_sys_link_pages']['#default_value']); + } + elseif ($access) { + $form['settings']['adv_link']['print_html_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); + $form['settings']['adv_link']['print_html_sys_link_pages']['#description'] .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); + } + $form['settings']['print_html_book_link'] = array( '#type' => 'radios', '#title' => t('Link in book hierarchy nodes'), diff --git a/print.module b/print.module index f895962cff1af89fda8b6544d69bc19876affa24..3f3d74d87d9523ce9916ae856afc9c717c8e419b 100644 --- a/print.module +++ b/print.module @@ -53,7 +53,7 @@ define('PRINT_ALLOW_BOOK_LINK', 2); * Implementation of hook_perm(). */ function print_perm() { - return array('access print', 'administer print'); + return array('access print', 'administer print', 'use PHP for link visibility'); } /** @@ -576,6 +576,9 @@ function print_insert_link($path = NULL, $node = NULL) { */ function _print_page_match($visibility, $pages) { if ($pages) { + if ($visibility == 2) { + return drupal_eval($pages); + } $path = drupal_get_path_alias($_GET['q']); $page_match = drupal_match_path($path, $pages); if ($path != $_GET['q']) { diff --git a/print_mail/print_mail.admin.inc b/print_mail/print_mail.admin.inc index 58d4e5ebcd89efc2979e3ec3af2eaa8768499f1a..d2f25b93115c9ade2b4ffc636aa7688c31d30185 100644 --- a/print_mail/print_mail.admin.inc +++ b/print_mail/print_mail.admin.inc @@ -80,6 +80,17 @@ function print_mail_settings() { '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')), ); + $access = user_access('use PHP for link visibility'); + + if ($form['settings']['adv_link']['print_mail_node_link_visibility']['#default_value'] == 2 && !$access) { + $form['settings']['adv_link']['print_mail_node_link_visibility'] = array('#type' => 'value', '#value' => 2); + $form['settings']['adv_link']['print_mail_node_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_mail_node_link_pages']['#default_value']); + } + elseif ($access) { + $form['settings']['adv_link']['print_mail_node_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); + $form['settings']['adv_link']['print_mail_node_link_pages']['#description'] .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); + } + $form['settings']['adv_link']['print_mail_sys_link_visibility'] = array( '#type' => 'radios', '#title' => t('Show link in system (non-content) pages'), @@ -95,6 +106,15 @@ function print_mail_settings() { t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')), ); + if ($form['settings']['adv_link']['print_mail_sys_link_visibility']['#default_value'] == 2 && !$access) { + $form['settings']['adv_link']['print_mail_sys_link_visibility'] = array('#type' => 'value', '#value' => 2); + $form['settings']['adv_link']['print_mail_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_mail_sys_link_pages']['#default_value']); + } + elseif ($access) { + $form['settings']['adv_link']['print_mail_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); + $form['settings']['adv_link']['print_mail_sys_link_pages']['#description'] .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); + } + $form['settings']['print_mail_book_link'] = array( '#type' => 'radios', '#title' => t('Link in book hierarchy nodes'), diff --git a/print_pdf/print_pdf.admin.inc b/print_pdf/print_pdf.admin.inc index bbc4c2f95c7ed218d029c68b0bc41bc43b7047a4..a464676edacac5a4894cc42030a39aed10290699 100644 --- a/print_pdf/print_pdf.admin.inc +++ b/print_pdf/print_pdf.admin.inc @@ -92,6 +92,17 @@ function print_pdf_settings() { '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')), ); + $access = user_access('use PHP for link visibility'); + + if ($form['settings']['adv_link']['print_pdf_node_link_visibility']['#default_value'] == 2 && !$access) { + $form['settings']['adv_link']['print_pdf_node_link_visibility'] = array('#type' => 'value', '#value' => 2); + $form['settings']['adv_link']['print_pdf_node_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_pdf_node_link_pages']['#default_value']); + } + elseif ($access) { + $form['settings']['adv_link']['print_pdf_node_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); + $form['settings']['adv_link']['print_pdf_node_link_pages']['#description'] .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); + } + $form['settings']['adv_link']['print_pdf_sys_link_visibility'] = array( '#type' => 'radios', '#title' => t('Show link in system (non-content) pages'), @@ -107,6 +118,15 @@ function print_pdf_settings() { t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')), ); + if ($form['settings']['adv_link']['print_pdf_sys_link_visibility']['#default_value'] == 2 && !$access) { + $form['settings']['adv_link']['print_pdf_sys_link_visibility'] = array('#type' => 'value', '#value' => 2); + $form['settings']['adv_link']['print_pdf_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_pdf_sys_link_pages']['#default_value']); + } + elseif ($access) { + $form['settings']['adv_link']['print_pdf_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); + $form['settings']['adv_link']['print_pdf_sys_link_pages']['#description'] .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); + } + $form['settings']['print_pdf_book_link'] = array( '#type' => 'radios', '#title' => t('Link in book hierarchy nodes'),