On drupal.org we now use the honeypot module, which has a permission that allows users to bypass it. Other antispam modules (mollom, spam) have a similar role.

It would be convenient if admins could assign/remove that specific role using fasttoggle.

This should have a different permission from "administer users" and should only work for a specifically chosen role.

CommentFileSizeAuthor
#13 1776878.patch24 KBkilles@www.drop.org
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

"should only work for a specifically chosen role." - specifically chosen in fasttoggle interface, right? It seems useful to be able to enable multiple roles for this feature and show a fasttoggle link for each one.

killes@www.drop.org’s picture

I won't complain about multiple roles. I am looking at the module to figure things out. Not sure it supports two parameters (uid, rid) out of the box.

killes@www.drop.org’s picture

a single role would probably be easier to do.

Nigel Cunningham’s picture

Sounds to me like the best way to implement this would be adding a permission per role named something like fasttoggle_role_rolename. Sound good?

To make sure I understand what you're thinking correctly, you're imagining extra links alongside the block/unblock link on user/view page? How about also in admin/user/user?

greggles’s picture

I think it would be most useful in this case as a Views field, but yes, putting it alongside the user/view page would be nice. I don't think it's required on admin/user/user - that table is already huge and someone who needs more control of it should build their own view.

killes@www.drop.org’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Moving this to D7 as it looks d.o will soonish convert to that.

Nigel Cunningham’s picture

Thanks. Work is underway; just not complete yet.

Nigel Cunningham’s picture

Status: Active » Closed (fixed)

Implemented in the latest commit to 6.x; now I'm going to port it to 7.x before working on a cleanup patch for both versions. This has required reworking things a bit, but I think it should give us cleaner, more generic code in the end (less duplication too!)

Nigel Cunningham’s picture

Status: Closed (fixed) » Active

Oh. Sorry. Forgot the 6.x->7.x change so it's not fixed yet.

greggles’s picture

Status: Active » Patch (to be ported)
Nigel Cunningham’s picture

Status: Patch (to be ported) » Needs review

Port to D7 committed to git. I've tested it, but wouldn't mind others checking it over too.

greggles’s picture

Status: Needs review » Needs work

I think role names should be passed through check_plain in the permission names.

killes@www.drop.org’s picture

FileSize
24 KB

Hi Nigel,

thank you for working on this!

Unfortunately, I totally missed the commit and instead fixed all role assignments manually. I could kick myself!

I've tried the D6 version and in addition to what Greg said, I've found a few bugs. Uploading your patch so I can dredit it.

killes@www.drop.org’s picture

+++ b/fasttoggle.admin.inc
@@ -92,6 +94,15 @@ function fasttoggle_settings_form() {
+          'status' => t('Status <small>(unblocked/blocked)</small>'),

The role options are missing

+++ b/fasttoggle.admin.inc
@@ -92,6 +94,15 @@ function fasttoggle_settings_form() {
+      '#default_value' => array_keys(array_filter(variable_get('fasttoggle_user_settings', array('status' => TRUE)))),

I guess this is a typo in the variable name, needs to be _role_ not _user_

+++ b/fasttoggle.module
@@ -69,8 +71,13 @@ function fasttoggle_menu() {
+  $available_roles = fasttoggle_potential_toggleable_roles();

Shouldn't this take the admin setting into account?

+++ b/fasttoggle.module
@@ -69,8 +71,13 @@ function fasttoggle_menu() {
+    $roles[] = 'toggle role \'' . $available_roles[$key] . '\'';

Here you use "toggle role 'foo'"

+++ b/fasttoggle.module
@@ -181,6 +207,29 @@ function fasttoggle_get_options($type) {
+  if (isset($user->roles[$role]))
+    unset($result['roles'][$role]);
+  else
+    $result['roles'][$role] = TRUE;

Coding style! ;)

+++ b/fasttoggle.module
@@ -195,32 +244,48 @@ function fasttoggle_fasttoggle_options($type, $obj = NULL) {
+        if (user_access('fasttoggle role ' . $rolename)) {

Here you use "fasttoggle role foo" for the permission. obviously you need to standardize.

+++ b/fasttoggle.module
@@ -318,6 +400,7 @@ function fasttoggle_fasttoggle_labels($style) {
+        'role' => array(0 => t('add role '), 1 => t('revoke role ')),

I think this need to be reversed, it is not working exactly opposite: "add role" takes is away and "revoke" adds it.

Nigel Cunningham’s picture

Thanks for the feedback. I'll seek to apply it asap.

Nigel Cunningham’s picture

Assigned: Unassigned » Nigel Cunningham
Status: Needs work » Fixed

Thanks for the feedback.

I believe this issue is now fixed in current 7.x dev. Please give it a whirl if you have time.

greggles’s picture

any chance you could fix 6x too? it's likely d.o will be on it for a while longer.

Nigel Cunningham’s picture

Title: Allow toggling of roles » Allow toggling of roles (6.x backport)
Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Active

Ok.

Nigel Cunningham’s picture

Status: Active » Fixed

Done.

killes@www.drop.org’s picture

Nigel, thanks for your help! THis is now live on d.o and will make maintenance lot easier.

Status: Fixed » Closed (fixed)

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

  • Commit 995f019 on master, 7.x-1.x by NigelCunningham:
    Fix labels on role links.
    
    Thanks to killes for pointing out this issue...