Posted by krishmuralieswar on October 7, 2007 at 9:23am
4 followers
Jump to:
| Project: | Taxonomy Access Control |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
How do we redirect the denied users to be automatically redirected to Register / login page?
Presently, we have some taxonomy terms that cannot be accessed by anonymous users. When an anonymous user clicks the terms the message says, 'There are currently no posts in this category'. We don't want that. We want the users to be redirected to the login/register page. How do we do that?
thanks & regards,
murali.
Comments
#1
I'm having the same problem
I have a 'members' taxonomy term and I have set view to deny for anonymous users. When they click on the taxonomy term I want them to get a login page, not a 'page not found'. Is this a taxonomy_access issue, or a Drupal ACL issue?
#2
We have implemented a fix by altering the taxonomy module. The problem is that when the taxonomy module is asked for a listing page it first checks to see if the term exists AND you have view access to it. If you don't have access to it then it treats it as not found.
We added the following code to the end of taxonomy_term_page() in taxonomy.module
<?php
else {
/**
* If taxonomy term exists you get Access Denied , otherwise Not Found
* Looks for the terms in the term table
* 02.11.2007
*/
$result = db_query('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (%s)', implode(',', $terms['tids']));
if (db_num_rows($result)) {
drupal_access_denied();
} else {
drupal_not_found();
}
?>
#3
could you specify exactly where and how you add the code ? i tried adding it but results in blank page
#4
Firstly this is in 5.1
In modules/taxonomy/taxonomy.module around line 1317 in function taxonomy_term_page() there is an if statement starting
<?phpif ($names) {
$title = check_plain(implode(', ', $names));
drupal_set_title($title);
...
?>
At the end of this if, around line 1413 add the code given above after the ending }
Hope that helps
#5
thanks unfortunately it still results in blank page in 5.5
this is what i have
function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
$terms = taxonomy_terms_parse_string($str_tids);
if ($terms['operator'] != 'and' && $terms['operator'] != 'or') {
drupal_not_found();
}
if ($terms['tids']) {
$placeholders = implode(',', array_fill(0, count($terms['tids']), '%d'));
$result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN ('. $placeholders .')', 't', 'tid'), $terms['tids']);
$tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
$names = array();
while ($term = db_fetch_object($result)) {
$tids[] = $term->tid;
$names[] = $term->name;
}
if ($names) {
$title = check_plain(implode(', ', $names));
drupal_set_title($title);
else {
$result = db_query('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (%s)', implode(',', $terms['tids']));
if (db_num_rows($result)) {
drupal_access_denied();
} else {
drupal_not_found();
}
#6
There's two parts to this: TAC's handling of what should be 403s, and the redirects.
The latter is beyond the scope of TAC, I think; but the former is related to #573674: Deny access to term page? and #311649: "Page Not Found" error for all non-accessible term pages. Marking duplicate.