--- faq-fix-hardcoded-path-7.x-1.x-2623326-6.patch 2017-02-22 14:39:34.299434582 +0530 +++ faq-fix-hardcoded-path-7.x-1.x-2623326-8.patch 2017-02-22 14:58:20.999384348 +0530 @@ -12,7 +12,7 @@ return system_settings_form($form); diff --git a/faq.module b/faq.module -index b9e0348..8cc061f 100644 +index b9e0348..2db18b4 100644 --- a/faq.module +++ b/faq.module @@ -74,7 +74,7 @@ function faq_node_access($node, $op, $account = NULL) { @@ -24,12 +24,21 @@ $items[$faq_path] = array( 'title' => 'Frequently Asked Questions', +@@ -415,7 +415,7 @@ function faq_page($tid = 0, $faq_display = '', $category_display = '') { + if (module_exists('pathauto')) { + module_load_include('inc', 'pathauto'); + } +- ++ $faqpath = _faq_path(); + // Things to provide translations for. + $default_values = array( + t('Frequently Asked Questions'), @@ -426,7 +426,7 @@ function faq_page($tid = 0, $faq_display = '', $category_display = '') { $output = $output_answers = ''; drupal_add_css(drupal_get_path('module', 'faq') . '/faq.css'); - if (arg(0) == 'faq-page') { -+ if (arg(0) == _faq_path()) { ++ if (arg(0) == $faqpath) { drupal_set_title(t(variable_get('faq_title', 'Frequently Asked Questions'))); } if (!module_exists("taxonomy")) { @@ -38,7 +47,7 @@ } } - if (drupal_match_path($_GET['q'], 'faq-page/*')) { -+ if (drupal_match_path($_GET['q'], _faq_path() . '/*')) { ++ if (drupal_match_path($_GET['q'], $faqpath . '/*')) { faq_set_breadcrumb($current_term); } } @@ -47,10 +56,19 @@ if ($term = taxonomy_term_load($tid)) { $title = t(variable_get('faq_title', 'Frequently Asked Questions')); - if (arg(0) == 'faq-page' && is_numeric(arg(1))) { -+ if (arg(0) == _faq_path() && is_numeric(arg(1))) { ++ if (arg(0) == $faqpath && is_numeric(arg(1))) { drupal_set_title($title . ($title ? ' - ' : '') . faq_tt("taxonomy:term:$term->tid:name", $term->name)); } _display_faq_by_category($faq_display, $category_display, $term, 0, $output, $output_answers); +@@ -571,7 +571,7 @@ function faq_page($tid = 0, $faq_display = '', $category_display = '') { + } + $valid_vocab = TRUE; + +- if ($category_display == "new_page") { ++ if ($category_display == 'new_page') { + $vocab_items = _get_indented_faq_terms($vid, 0); + $items = array_merge($items, $vocab_items); + } @@ -943,7 +943,7 @@ function faq_block_view($delta) { $block['subject'] = t('FAQ Categories'); $items = array(); @@ -96,12 +114,21 @@ return $objects; } +@@ -1510,7 +1510,7 @@ function faq_pathauto_bulkupdate() { + $context['sandbox']['count'] = 0; + $context['sandbox']['current'] = 0; + } +- ++ $faq_path = _faq_path(); + // Get the allowed vocabs. + $vocabularies = taxonomy_get_vocabularies('faq'); + $vocab_omit = variable_get('faq_omit_vocabulary', array()); @@ -1524,7 +1524,7 @@ function faq_pathauto_bulkupdate() { // Get tids that need aliasing. $query = db_select('taxonomy_term_data', 'td'); - $query->leftJoin('url_alias', 'ua', "CONCAT('faq-page/', td.tid) = ua.source"); -+ $query->leftJoin('url_alias', 'ua', "CONCAT(_faq_path() . '/', td.tid) = ua.source"); ++ $query->leftJoin('url_alias', 'ua', "CONCAT($faq_path . '/', td.tid) = ua.source"); $query->addField('td', 'tid'); $query->isNull('ua.source'); $query->condition('td.tid', $context['sandbox']['current'], '>'); @@ -110,7 +137,7 @@ $terms = taxonomy_term_load_multiple($tids); foreach ($terms as $term) { - pathauto_create_alias('faq', 'bulkupdate', 'faq-page/' . $term->tid, array('term' => $term)); -+ pathauto_create_alias('faq', 'bulkupdate', _faq_path() . '/' . $term->tid, array('term' => $term)); ++ pathauto_create_alias('faq', 'bulkupdate', $faq_path . '/' . $term->tid, array('term' => $term)); } $context['sandbox']['count'] += count($tids); $context['sandbox']['current'] = max($tids); @@ -141,24 +168,27 @@ } } -@@ -1619,13 +1619,13 @@ function faq_set_breadcrumb($term = NULL) { +@@ -1617,15 +1617,16 @@ function faq_taxonomy_term_delete($term) { + */ + function faq_set_breadcrumb($term = NULL) { $breadcrumb = array(); ++ $faq_path = _faq_path(); if (variable_get('faq_custom_breadcrumbs', TRUE)) { if (module_exists("taxonomy") && $term) { - $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq-page/' . $term->tid); -+ $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), _faq_path() . '/' . $term->tid); ++ $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $faq_path . '/' . $term->tid); while ($parents = taxonomy_get_parents($term->tid)) { $term = array_shift($parents); - $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq-page/' . $term->tid); -+ $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), _faq_path() . '/' . $term->tid); ++ $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $faq_path . '/' . $term->tid); } } - $breadcrumb[] = l(t(variable_get('faq_title', 'Frequently Asked Questions')), 'faq-page'); -+ $breadcrumb[] = l(t(variable_get('faq_title', 'Frequently Asked Questions')), _faq_path()); ++ $breadcrumb[] = l(t(variable_get('faq_title', 'Frequently Asked Questions')), $faq_path); $breadcrumb[] = l(t('Home'), NULL, array('attributes' => array('title' => variable_get('site_name', '')))); $breadcrumb = array_reverse($breadcrumb); return drupal_set_breadcrumb($breadcrumb); -@@ -1856,3 +1856,10 @@ function theme_faq_draggable_question_order_table($variables) { +@@ -1856,3 +1857,10 @@ function theme_faq_draggable_question_order_table($variables) { $output .= drupal_render_children($form); return $output; } @@ -170,22 +200,25 @@ + return variable_get('faq_path', 'faq-page'); +} diff --git a/faq.test b/faq.test -index ff58f66..ce50192 100644 +index ff58f66..5a16bee 100644 --- a/faq.test +++ b/faq.test -@@ -172,20 +172,20 @@ class FaqAccessTestClass extends FaqTestCase { - function testFaqAccess() { +@@ -170,22 +170,22 @@ class FaqAccessTestClass extends FaqTestCase { + } + function testFaqAccess() { +- ++ $faq_path = _faq_path(); // Verify that anonymous user has no access to the faq page - $this->faqVerifyNoAccess('faq-page'); -+ $this->faqVerifyNoAccess(_faq_path()); ++ $this->faqVerifyNoAccess($faq_path); // Create and login user $normal_user = $this->drupalCreateUser(); $this->drupalLogin($normal_user); // Verify that logged in user has no access to the faq page - $this->faqVerifyNoAccess('faq-page'); -+ $this->faqVerifyNoAccess(_faq_path()); ++ $this->faqVerifyNoAccess($faq_path); $this->drupalLogout(); $view_faq_user = $this->drupalCreateUser(array('view faq page')); @@ -193,11 +226,18 @@ // Verify that the faq page is visible and available but empty - $this->drupalGet('faq-page'); -+ $this->drupalGet(_faq_path()); ++ $this->drupalGet($faq_path); $this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.')); } -@@ -217,14 +217,14 @@ class CreateFaqTestCase extends FaqTestCase { +@@ -211,20 +211,20 @@ class CreateFaqTestCase extends FaqTestCase { + * This test creates a faq with detailed question shown and labeled questions and answers + */ + function testFaqCreate() { +- ++ $faq_path = _faq_path(); + // Create and log in user with create FAQ permissions + $this->drupalLogin($this->admin_user); // Show the detailed question $this->drupalGet('admin/config/content/faq/questions'); // Set faq to allow long question text and labeled questions and answers @@ -213,7 +253,7 @@ // Verify that the faq page is visible and available but empty - $this->drupalGet('faq-page'); -+ $this->drupalGet(_faq_path()); ++ $this->drupalGet($faq_path); $this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.')); // Fill in the Create FAQ node 1 form and post it @@ -231,13 +271,13 @@ // Verify that logged in user has no access to the faq page - $this->faqVerifyNoAccess('faq-page'); -+ $this->faqVerifyNoAccess(_faq_path()); ++ $this->faqVerifyNoAccess($faq_path); // Check that the FAQ page is available and that the correct term is listed as grouping for the new FAQ node $view_faq_user = $this->drupalCreateUser(array('view faq page')); $this->drupalLogin($view_faq_user); - $this->drupalGet('faq-page'); -+ $this->drupalGet(_faq_path()); ++ $this->drupalGet($faq_path); $this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.')); $this->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.')); $this->assertText($this->faq1[$this->instance['field_name'] . '[' . $langcode .']'], t('Term for node 1 available on FAQ page.')); @@ -255,16 +295,19 @@ $this->drupalLogin($view_faq_user); - $this->drupalGet('faq-page'); -+ $this->drupalGet(_faq_path()); ++ $this->drupalGet($faq_path); $this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.')); $this->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.')); $this->assertText($this->faq1[$this->instance['field_name'] . '[' . $langcode .']'], t('Term for node 1 not available on FAQ page.')); -@@ -323,7 +323,7 @@ class CRAUDFaqTestCase extends FaqTestCase { +@@ -321,9 +321,9 @@ class CRAUDFaqTestCase extends FaqTestCase { + * Test creating an FAQ and verify its status + */ public function testFaqCreate() { - +- ++ $faq_path = _faq_path(); // Verify that logged in user has no access to the faq page - $this->faqVerifyNoAccess('faq-page'); -+ $this->faqVerifyNoAccess(_faq_path()); ++ $this->faqVerifyNoAccess($faq_path); // Log in user with create FAQ permissions $this->drupalLogin($this->faq_user); @@ -273,78 +316,82 @@ // Verify visibility on faq page - $this->drupalGet('faq-page'); // Load faq page -+ $this->drupalGet(_faq_path()); // Load faq page ++ $this->drupalGet($faq_path); // Load faq page $this->assertText($edit['title']); // Node should be listed here $this->drupalGet('node/' . $node->nid); // It should also be possible to open the node directly diff --git a/includes/faq.hide_answer.inc b/includes/faq.hide_answer.inc -index 5b473e7..2d64b05 100644 +index 5b473e7..6190e68 100644 --- a/includes/faq.hide_answer.inc +++ b/includes/faq.hide_answer.inc -@@ -63,7 +63,7 @@ function template_preprocess_faq_category_hide_answer(&$variables) { +@@ -62,8 +62,9 @@ function template_preprocess_faq_category_hide_answer(&$variables) { + } $this_page = $_GET['q']; $get_child_terms = 0; ++ $faq_path = _faq_path() // Check if we're on a faq page. - if (arg(0) == 'faq-page') { -+ if (arg(0) == _faq_path()) { ++ if (arg(0) == $faq_path) { // Check if we're on a categorized faq page. if (is_numeric(arg(1))) { $get_child_terms = arg(1); -@@ -120,7 +120,7 @@ function template_preprocess_faq_category_hide_answer(&$variables) { +@@ -120,7 +121,7 @@ function template_preprocess_faq_category_hide_answer(&$variables) { // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); - if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq-page') || $hide_child_terms) && $category_display == 'hide_qa')) { -+ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != _faq_path()) || $hide_child_terms) && $category_display == 'hide_qa')) { ++ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != $faq_path) || $hide_child_terms) && $category_display == 'hide_qa')) { $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_hide_answer', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } diff --git a/includes/faq.new_page.inc b/includes/faq.new_page.inc -index 8c0c1fc..f940999 100644 +index 8c0c1fc..3f7e2d9 100644 --- a/includes/faq.new_page.inc +++ b/includes/faq.new_page.inc -@@ -55,7 +55,7 @@ function template_preprocess_faq_category_new_page(&$variables) { +@@ -55,7 +55,8 @@ function template_preprocess_faq_category_new_page(&$variables) { // Initialise some variables. $get_child_terms = 0; // Check if we're on a faq page. - if (arg(0) == 'faq-page') { -+ if (arg(0) == _faq_path()) { ++ $faq_path = _faq_path(); ++ if (arg(0) == $faq_path) { // Check if we're on a categorized faq page. if (is_numeric(arg(1))) { $get_child_terms = arg(1); -@@ -117,7 +117,7 @@ function template_preprocess_faq_category_new_page(&$variables) { +@@ -117,7 +118,7 @@ function template_preprocess_faq_category_new_page(&$variables) { // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); - if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq-page') || $hide_child_terms) && $category_display == 'hide_qa')) { -+ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != _faq_path()) || $hide_child_terms) && $category_display == 'hide_qa')) { ++ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != $faq_path) || $hide_child_terms) && $category_display == 'hide_qa')) { $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_new_page', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } diff --git a/includes/faq.questions_inline.inc b/includes/faq.questions_inline.inc -index 175d30f..d654b74 100644 +index 175d30f..c819118 100644 --- a/includes/faq.questions_inline.inc +++ b/includes/faq.questions_inline.inc -@@ -74,7 +74,7 @@ function template_preprocess_faq_category_questions_inline(&$variables) { +@@ -74,7 +74,8 @@ function template_preprocess_faq_category_questions_inline(&$variables) { $this_page = $_GET['q']; $get_child_terms = 0; // Check if we're on a faq page. - if (arg(0) == 'faq-page') { -+ if (arg(0) == _faq_path()) { ++ $faq_path = _faq_path(); ++ if (arg(0) == $faq_path) { // Check if we're on a categorized faq page. if (is_numeric(arg(1))) { $get_child_terms = arg(1); -@@ -141,7 +141,7 @@ function template_preprocess_faq_category_questions_inline(&$variables) { +@@ -141,7 +142,7 @@ function template_preprocess_faq_category_questions_inline(&$variables) { // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); - if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq-page') || $hide_child_terms) && $category_display == 'hide_qa')) { -+ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != _faq_path()) || $hide_child_terms) && $category_display == 'hide_qa')) { ++ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != $faq_path) || $hide_child_terms) && $category_display == 'hide_qa')) { $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_inline', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } diff --git a/includes/faq.questions_top.inc b/includes/faq.questions_top.inc -index b23d2cc..d7a7f8f 100644 +index b23d2cc..6a6fdb7 100644 --- a/includes/faq.questions_top.inc +++ b/includes/faq.questions_top.inc @@ -103,7 +103,7 @@ function template_preprocess_faq_category_questions_top(&$variables) { @@ -365,21 +412,22 @@ $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } -@@ -253,7 +253,7 @@ function template_preprocess_faq_category_questions_top_answers(&$variables) { +@@ -253,7 +253,8 @@ function template_preprocess_faq_category_questions_top_answers(&$variables) { $this_page = $_GET['q']; $get_child_terms = 0; // Check if we're on a faq page. - if (arg(0) == 'faq-page') { ++ $faq_path = _faq_path(); + if (arg(0) == _faq_path()) { // Check if we're on a categorized faq page. if (is_numeric(arg(1))) { $get_child_terms = arg(1); -@@ -277,7 +277,7 @@ function template_preprocess_faq_category_questions_top_answers(&$variables) { +@@ -277,7 +278,7 @@ function template_preprocess_faq_category_questions_top_answers(&$variables) { // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); - if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq-page') || $hide_child_terms) && $category_display == 'hide_qa')) { -+ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != _faq_path()) || $hide_child_terms) && $category_display == 'hide_qa')) { ++ if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != $faq_path) || $hide_child_terms) && $category_display == 'hide_qa')) { $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top_answers', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); }