BobRay/notify

some improvements for the next edition?

jolichter opened this issue · 11 comments

Hi Bob, is it possible that you build this ideas into your next edition?

  1. allowedGroups
    I add a group "Manager" (has fewer rights as an Admin) and set in the Snippet Notify the Property "allowedGroups: Administrator, Manager".
    This works only if I add the group Manager in the Plugin: "Notify":
/* Act only when user is a member of the Administrator or Manager group */
if (!$modx->user->isMember(array('Administrator','Manager'))) {
    return '';
}

(btw: This Manager group needs ACL entriy "view_user")

  1. If an User unsubscribe and get a message, he can still continue select checkboxes and save it. Due that I change the snippet SubscribeForm and add an session_destroy (I'm not sure if that's the best way):
            if ($modx->user->save()) {
                $modx->setPlaceholder('sbs_success_message', $modx->lexicon('sbs_unsubscribe_success_message'));
                session_destroy();
            } else {

Best Regards
Jo

Thanks, I added an allowedGroups System setting for use in the plugin. I'll look into the other fix for subscribe.

Hello Bob, unfortunately this doesn't work.
In the snippet property I set the allowedGroups: Administrator, Manager
It seems that the plugin doesn't read the properties from the notify snippet?

With that test, I read the array $allowedGroups, but I get only the default value 'Administrator':

$modx->lexicon->load('notify:default');
/* Act only when user is a member of an allowed group */
$allowedGroups = $modx->getOption('allowedGroups', $scriptProperties, 'Administrator', true);
$allowedGroups = array_map('trim', explode(',', $allowedGroups));

  #test
  $showAllowedGroups = implode(',', $allowedGroups);
  $modx->log(modX::LOG_LEVEL_ERROR, 'show allowed groups: ' .$showAllowedGroups);

if (!$modx->user->isMember($allowedGroups)) {
    $modx->log(modX::LOG_LEVEL_ERROR, '[Notify] ' .
        $modx->lexicon('nf_bad_group')
    );
    return '';
}

At the moment, only that works:
$allowedGroups = $modx->getOption('allowedGroups', $scriptProperties, 'Administrator, Manager', true);

Did you set the new System Setting and the snippet property, then clear the cache fully?

Sorry, correct, it's a "System Setting". Now it works, Thanks!

Hello Bob,
In case a user is in more than just the group 'Subscriber':
After using the sbsManagePrefsFormTpl, he will be removed from all other groups.
Did you mean that with "I'll look into the other fix for subscribe"?

Hello Jo,

I'm not sure what you're asking. On my site, there's only one group, "Subscribers" so none of the group options are shown and I'm not used to thinking about groups.

"Unsubscribe" means don't send me any more messages, hence the removal from all groups. To alter which messages are sent, the user can change groups and/or preferences (if that option is provided by the admin).

In #2 above, you mentioned a concern that after unsubscribing, users could still alter and submit the preferences/groups form. I planned to look into preventing that.

BTW, this discussion should really be an issue for the Subscribe extra, not Notify. Though it does affect both, the relevant code is in the Subscribe extra.

Hello Bob, yes #2 concern the Subscribe extra, Thanks!

On my homepage, I have a User in the group "Subscribers" and "Manager". As Editor he can write some articles in a limited range. However, he would like to have also a subscription. Maybe I have to find another solution for my group problem?

Sorry, I was wrong about the groups (hazard of speculating on an extra I wrote seven years ago). I think unsubscribing just marks the user as inactive. If you edit the user and make him active, you may be able to have what you want, though I'm probably misunderstanding what that is.

When you send a message with Notify, you can specify which user groups and which selected preferences get the message, so it's pretty flexible.

You can always create another group to control Manager rights that has nothing to do with Notify and put the user in it.

Hello Bob,
Sorry maybe my question was not very clear.

Yes unsubscribing marks the user as inactive. But this is not my problem. The problem is, if the User change his settings, the sbsManagePrefsFormTpl removed the User from all other groups, except the "Subscribers".

Now I will check Users, who are in more groups (in my case "Manager"), they should not use the sbsManagePrefsFormTpl at the front-page. They can change the settings in the Management.

Yes indeed, I think your comment is a good idea:
"When you send a message with Notify, you can specify which user groups and which selected preferences get the message, so it's pretty flexible."

Thanks!

I get it now. That could be a bug. What's in your sbsGroupListTpl chunk?

damn, my fault and no bug! I used my own sbsGroupListTpl and set it not up in the settings.
Thanks for your super support and patience!