Hi,

I didn't check at "Enforce auto logout on admin pages" but even my user 1 gets log out if he stays typing at the node/add page for more than 45min.

I mean...i don't want to keep a user logged if he's viewing a 'normal' page for more than 45min.
But if he's the admin AND is at an admin page i think he has the option to stay there as long as the work needs to be finished.

So, how can i disable auto logout at admin pages?

thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tayzlor’s picture

FileSize
498 bytes

patch to cover this - check if user ID > 1 first before doing anything.
This means the superuser would never get autologged out.

tayzlor’s picture

Status: Active » Needs review
vomitHatSteve’s picture

Ok. I know this is a fairly old issue, but I think I've got a more elegant solution.

The attached patch. Adds a checkbox to the admin page prompting the admin to consider node/*/edit, node/*/delete, and node/add/* admin pages. (I also fixed the spelling of "then" in the previous checkbox.)
Then I replaced the current "is admin page" logic with an invocation of hook_is_admin_page, which doesn't exist outside of this patch, but really should!
This patch also implements hook_is_admin_page (obviously) and performs the original check as well as the new ones needed for node modification pages.

That's not to say that the previous patch isn't a good idea. These could probably be used concurrently, but this solution solves the original, posted problem more elegantly.

vomitHatSteve’s picture

For clarification (since I forgot in my original post), the purpose of hook_is_admin_page being that other modules (specifically admin_theme) can implement it to expand the list of admin pages even further!

johnennew’s picture

Version: 6.x-4.x-dev » 7.x-4.x-dev
Assigned: Unassigned » johnennew
Status: Needs review » Needs work

I'm not sure that autologout is the place to define node pages as admin pages using hook_is_admin_page. This will affect the admin page status of node pages outside just autologout.

My preference is to include a new config option which can list path patterns that autologout does not work on. This would work like specifying which URLs a block can appear on. If the path matches any pattern specified then it will not logout when on that page.

Setting to needs work and assigning to me but should anyone want to do it sooner, please feel free to attach a patch (or tell me I'm wrong!)

Needs applying to 7.x-4.x first then backported.

rooby’s picture

A couple of things:

The hook name hook_is_admin_page() is not ideal as it is not namespaced.
If this module is to add any hooks they should be namespaced with autologout, so it should be hook_autologout_is_admin_page().

Plus, drupal core already has something like this. It is the path_is_admin() function, which uses hook_admin_paths() and hook_admin_paths_alter(), which are tied in with the node_admin_theme variable (via node_admin_paths(), which handles the case that the user has checked the box to make node pages admin pages, in the appearance section of the site administration.

So it would be something along the lines of:

<?php
  if (!variable_get('autologout_enforce_admin', FALSE) && path_is_admin(current_path())) {
    return;
  }
?>

Re the first patch, I would suggest making a user 1 exception a separate setting.

[EDIT] fixed code example.

johnennew’s picture

I like this fix since it properly captures all paths described as admin by the site.

johnennew’s picture

Status: Needs work » Needs review
FileSize
2.15 KB

Patch with tests for review

johnennew’s picture

Status: Needs review » Fixed

I don't see any reason to delay this inclusion - it;s pretty innocuous and the tests pass.

Committed to 7.x-4.x branch - I don;t think there is an equivalent for Drupal 6 so not back porting - please reopen if you know differently.

rooby’s picture

For drupal 6, this is what drupal core does in system_init():

<?php
  if (arg(0) == 'admin' || (variable_get('node_admin_theme', '0') && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit'))) {
    // Is admin page.
  }
?>
johnennew’s picture

Version: 7.x-4.x-dev » 6.x-4.x-dev
Status: Fixed » Needs review
FileSize
3.7 KB

Ah, ok. probably worth adding this.

6.x-4.x patch with tests attached.

johnennew’s picture

Status: Needs review » Fixed

Tests pass - committing to 6.x-4.x and closing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit cba3bd6 on 7.x-4.x, 8.x-1.x authored by rooby, committed by ceng:
    Issue #1255612 by rooby and ceng: use path_is_admin for determing admin...