summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Ventura2008-12-17 15:04:25 (GMT)
committer Joao Ventura2008-12-17 15:04:25 (GMT)
commitc30cd623b7a146c73eeb03f9419534f54a271d3f (patch)
tree3bcbe3a29a67e21bf590e69366b40385133e8e92
parent0d61e0d651729b081d6b96186b749ac49e837fc0 (diff)
Add PHP visibility option
-rw-r--r--print.admin.inc20
-rw-r--r--print.module5
-rw-r--r--print_mail/print_mail.admin.inc20
-rw-r--r--print_pdf/print_pdf.admin.inc20
4 files changed, 64 insertions, 1 deletions
diff --git a/print.admin.inc b/print.admin.inc
index a3f9a77..e793cc5 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' => '<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 <code>TRUE</code> (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' => '<?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' => '<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 <code>TRUE</code> (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' => '<?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 f895962..3f3d74d 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 58d4e5e..d2f25b9 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' => '<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 <code>TRUE</code> (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' => '<?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' => '<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 <code>TRUE</code> (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' => '<?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 bbc4c2f..a464676 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' => '<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 <code>TRUE</code> (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' => '<?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' => '<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 <code>TRUE</code> (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' => '<?php ?>'));
+ }
+
$form['settings']['print_pdf_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),