Commit e646a8df authored by jcnventura's avatar jcnventura

Fix #715800: type-specific settings act as default settings only, not as a...

Fix #715800: type-specific settings act as default settings only, not as a type-wide configuration switch
parent a6a6896f
......@@ -27,14 +27,14 @@ CONFIGURATION
Administer > Site building > Modules (admin/build/modules)
Enable or disable the module. (default: disabled)
Administer > User management > Permissions (admin/user/permissions)
Administer > People > Permissions (admin/people/permissions)
Under print module:
access print: Enable access to the PF page and display of the PF link in
other pages. (default: disabled)
administer print: Enable access to the module settings page. (default:
disabled)
Administer > Content management > Content types (admin/content/types)
Administer > Structure > Content types (admin/structure/types)
For each content type it is possible to enable or disable the PF link
via the "Show printer-friendly version link" checkbox. (default:
enabled)
......@@ -42,7 +42,7 @@ CONFIGURATION
comments via the "Show printer-friendly version link in individual
comments" checkbox. (default: disabled)
Administer > Site configuration > Printer-friendly (admin/settings/print)
Administer > Configuration > Printer, e-mail and PDF versions (admin/config/print)
This is where all the module-specific configuration options can be set.
- To modify the template of printer friendly pages, simply edit the
......
......@@ -39,7 +39,7 @@ function print_main_settings() {
'#title' => t('Printer-friendly URLs list'),
'#default_value' => variable_get('print_urls', PRINT_URLS_DEFAULT),
'#description' => t('If set, a list of the destination URLs for the page links will be displayed at the bottom of the page.') . '<br />' .
t('Note that you can enable/disable the URL list for each content type individually from the !url.', array('!url' => l(t('Content Types page'), 'admin/build/types'))),
t('Note that you can enable/disable the URL list for each content type individually from the !url.', array('!url' => l(t('Content Types page'), 'admin/structure/types'))),
);
$form['settings']['print_urls_anchors'] = array(
......
......@@ -470,14 +470,12 @@ function print_form_alter(&$form, &$form_state, $form_id) {
$form['print']['print_display']['#default_value'] = variable_get('print_display_' . $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_display_comment']['#default_value'] = variable_get('print_display_comment_' . $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_display_urllist']['#default_value'] = variable_get('print_display_urllist_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
$form['print']['label']['#markup'] = '<p><em>' . t('The settings below only apply when some of the corresponding module-wide link settings are enabled.') . '</em></p>' . $form['print']['label']['#markup'];
}
else {
$node = $form['#node'];
$form['print']['print_display']['#default_value'] = isset($node->print_display) ? $node->print_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
$form['print']['print_display_comment']['#default_value'] = isset($node->print_display_comment) ? $node->print_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$form['print']['print_display_urllist']['#default_value'] = isset($node->print_display_urllist) ? $node->print_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
$form['print']['label']['#markup'] = '<p><em>' . t('The settings below only apply in case the corresponding type-specific setting is also enabled (except for the "Show link in individual comments").') . '</em></p>' . $form['print']['label']['#markup'];
$form['print']['print_display']['#default_value'] = isset($node->print_display) ? $node->print_display : variable_get('print_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_display_comment']['#default_value'] = isset($node->print_display_comment) ? $node->print_display_comment : variable_get('print_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_display_urllist']['#default_value'] = isset($node->print_display_urllist) ? $node->print_display_urllist : variable_get('print_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
}
}
}
......@@ -525,9 +523,9 @@ function _print_set_node_fields(&$node) {
else {
$res = FALSE;
}
$node->print_display = $res ? intval($res->link) : PRINT_TYPE_SHOW_LINK_DEFAULT;
$node->print_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$node->print_display_urllist = $res ? intval($res->url_list) : PRINT_TYPE_URLLIST_DEFAULT;
$node->print_display = $res ? intval($res->link) : variable_get('print_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$node->print_display_comment = $res ? intval($res->comments) : variable_get('print_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$node->print_display_urllist = $res ? intval($res->url_list) : variable_get('print_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
}
/**
......@@ -566,13 +564,6 @@ function _print_get_title($path) {
* value of the url_list field (0 or 1)
*/
function _print_node_conf_modify($nid, $link, $comments, $url_list) {
if (($link == PRINT_TYPE_SHOW_LINK_DEFAULT) && ($comments == PRINT_TYPE_COMMENT_LINK_DEFAULT) &&
($url_list == PRINT_TYPE_URLLIST_DEFAULT)) {
db_delete('print_node_conf')
->condition('nid', $nid)
->execute();
}
else {
db_merge('print_node_conf')
->key(array('nid' => $nid))
->fields(array(
......@@ -581,7 +572,6 @@ function _print_node_conf_modify($nid, $link, $comments, $url_list) {
'url_list' => $url_list,
))
->execute();
}
}
/**
......@@ -821,17 +811,15 @@ function print_link_allowed($args) {
// Link is for a comment, return the configured setting
$res = db_query("SELECT comments FROM {print_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
$print_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
if (($print_display_comment) ||
variable_get('print_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
$print_display_comment = $res ? intval($res->comments) : variable_get('print_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
if ($print_display_comment) {
return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
// Node link
if ((!$node->print_display) || (isset($node_type) &&
!variable_get('print_display_' . $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
// Link for this node type is disabled
if (!$node->print_display) {
// Link for this node is disabled
return FALSE;
}
elseif (isset($node->book)) {
......
......@@ -469,23 +469,22 @@ function _print_friendly_urls($url = 0) {
function _print_url_list_enabled($node, $format = PRINT_HTML_FORMAT) {
switch ($format) {
case PRINT_HTML_FORMAT:
$node_urllist = isset($node->print_display_urllist) ? $node->print_display_urllist : TRUE;
$node_urllist = isset($node->print_display_urllist) ? $node->print_display_urllist : variable_get('print_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
$fmt = '';
break;
case PRINT_MAIL_FORMAT:
$node_urllist = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : TRUE;
$node_urllist = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : variable_get('print_mail_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
$fmt = $format . '_';
break;
case PRINT_PDF_FORMAT:
$node_urllist = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : TRUE;
$node_urllist = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : variable_get('print_pdf_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
$fmt = $format . '_';
break;
}
if (!isset($node_urllist)) $node_urllist = TRUE;
if (!isset($node_urllist)) $node_urllist = PRINT_TYPE_URLLIST_DEFAULT;
// Get value of Printer-friendly URLs setting
return (variable_get('print_urls', PRINT_URLS_DEFAULT) && ($node_urllist) &&
(isset($node->type) ? variable_get('print_' . $fmt . 'display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT) : PRINT_TYPE_URLLIST_DEFAULT));
return (variable_get('print_urls', PRINT_URLS_DEFAULT) && ($node_urllist));
}
/**
......
......@@ -275,9 +275,9 @@ function print_mail_form_alter(&$form, &$form_state, $form_id) {
}
else {
$node = $form['#node'];
$form['print']['print_mail_display']['#default_value'] = isset($node->print_mail_display) ? $node->print_mail_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
$form['print']['print_mail_display_comment']['#default_value'] = isset($node->print_mail_display_comment) ? $node->print_mail_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$form['print']['print_mail_display_urllist']['#default_value'] = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
$form['print']['print_mail_display']['#default_value'] = isset($node->print_mail_display) ? $node->print_mail_display : variable_get('print_mail_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_mail_display_comment']['#default_value'] = isset($node->print_mail_display_comment) ? $node->print_mail_display_comment : variable_get('print_mail_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_mail_display_urllist']['#default_value'] = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : variable_get('print_mail_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
}
}
}
......@@ -332,9 +332,9 @@ function _print_mail_set_node_fields(&$node) {
else {
$res = FALSE;
}
$node->print_mail_display = $res ? intval($res->link) : PRINT_TYPE_SHOW_LINK_DEFAULT;
$node->print_mail_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$node->print_mail_display_urllist = $res ? intval($res->url_list) : PRINT_TYPE_URLLIST_DEFAULT;
$node->print_mail_display = $res ? intval($res->link) : variable_get('print_mail_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$node->print_mail_display_comment = $res ? intval($res->comments) : variable_get('print_mail_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$node->print_mail_display_urllist = $res ? intval($res->url_list) : variable_get('print_mail_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
}
/**
......@@ -351,13 +351,6 @@ function _print_mail_set_node_fields(&$node) {
* value of the url_list field (0 or 1)
*/
function _print_mail_node_conf_modify($nid, $link, $comments, $url_list) {
if (($link == PRINT_TYPE_SHOW_LINK_DEFAULT) && ($comments == PRINT_TYPE_COMMENT_LINK_DEFAULT) &&
($url_list == PRINT_TYPE_URLLIST_DEFAULT)) {
db_delete('print_mail_node_conf')
->condition('nid', $nid)
->execute();
}
else {
db_merge('print_mail_node_conf')
->key(array('nid' => $nid))
->fields(array(
......@@ -366,7 +359,6 @@ function _print_mail_node_conf_modify($nid, $link, $comments, $url_list) {
'url_list' => $url_list,
))
->execute();
}
}
/**
......@@ -498,17 +490,15 @@ function print_mail_link_allowed($args) {
// Link is for a comment, return the configured setting
$res = db_query("SELECT comments FROM {print_mail_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
$print_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
if (($print_display_comment) ||
variable_get('print_mail_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
$print_display_comment = $res ? intval($res->comments) : variable_get('print_mail_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
if ($print_display_comment) {
return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
// Node link
if ((!$node->print_mail_display) || (isset($node_type) &&
!variable_get('print_mail_display_' . $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
// Link for this node type is disabled
if (!$node->print_mail_display) {
// Link for this node is disabled
return FALSE;
}
elseif (isset($node->book)) {
......
......@@ -323,9 +323,9 @@ function print_pdf_form_alter(&$form, &$form_state, $form_id) {
}
else {
$node = $form['#node'];
$form['print']['print_pdf_display']['#default_value'] = isset($node->print_pdf_display) ? $node->print_pdf_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
$form['print']['print_pdf_display_comment']['#default_value'] = isset($node->print_pdf_display_comment) ? $node->print_pdf_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$form['print']['print_pdf_display_urllist']['#default_value'] = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
$form['print']['print_pdf_display']['#default_value'] = isset($node->print_pdf_display) ? $node->print_pdf_display : variable_get('print_pdf_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_pdf_display_comment']['#default_value'] = isset($node->print_pdf_display_comment) ? $node->print_pdf_display_comment : variable_get('print_pdf_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_pdf_display_urllist']['#default_value'] = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : variable_get('print_pdf_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
}
}
}
......@@ -344,9 +344,9 @@ function _print_pdf_set_node_fields(&$node) {
else {
$res = FALSE;
}
$node->print_pdf_display = $res ? intval($res->link) : PRINT_TYPE_SHOW_LINK_DEFAULT;
$node->print_pdf_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$node->print_pdf_display_urllist = $res ? intval($res->url_list) : PRINT_TYPE_URLLIST_DEFAULT;
$node->print_pdf_display = $res ? intval($res->link) : variable_get('print_pdf_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$node->print_pdf_display_comment = $res ? intval($res->comments) : variable_get('print_pdf_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$node->print_pdf_display_urllist = $res ? intval($res->url_list) : variable_get('print_pdf_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
}
/**
......@@ -363,13 +363,6 @@ function _print_pdf_set_node_fields(&$node) {
* value of the url_list field (0 or 1)
*/
function _print_pdf_node_conf_modify($nid, $link, $comments, $url_list) {
if (($link == PRINT_TYPE_SHOW_LINK_DEFAULT) && ($comments == PRINT_TYPE_COMMENT_LINK_DEFAULT) &&
($url_list == PRINT_TYPE_URLLIST_DEFAULT)) {
db_delete('print_pdf_node_conf')
->condition('nid', $nid)
->execute();
}
else {
db_merge('print_pdf_node_conf')
->key(array('nid' => $nid))
->fields(array(
......@@ -378,7 +371,6 @@ function _print_pdf_node_conf_modify($nid, $link, $comments, $url_list) {
'url_list' => $url_list,
))
->execute();
}
}
/**
......@@ -504,7 +496,7 @@ function print_pdf_link_allowed($args) {
$print_pdf_node_link_visibility = variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT);
$print_pdf_node_link_pages = variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT);
if (!_print_page_match($print_pdf_node_link_visibility, "node/". $node->nid, $print_pdf_node_link_pages)) {
if (!_print_page_match($print_pdf_node_link_visibility, "node/" . $node->nid, $print_pdf_node_link_pages)) {
// Page not in visibility list
return FALSE;
}
......@@ -512,17 +504,15 @@ function print_pdf_link_allowed($args) {
// Link is for a comment, return the configured setting
$res = db_query("SELECT comments FROM {print_pdf_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
$print_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
if (($print_display_comment) ||
variable_get('print_pdf_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
$print_display_comment = $res ? intval($res->comments) : variable_get('print_pdf_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
if ($print_display_comment) {
return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
// Node link
if ((!$node->print_pdf_display) || (isset($node_type) &&
!variable_get('print_pdf_display_' . $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
// Link for this node type is disabled
if (!$node->print_pdf_display) {
// Link for this node is disabled
return FALSE;
}
elseif (isset($node->book)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment