Basically what i want to do with appbar is a facebook like behaviour.

I want users to get noticed for new comments on every conversation they are incolved with. That means if i create a node and someone comments i want to see that in the appbar. Also when i comment on someone elses node i want to see every following comment in the appbar.
my own comments and node creations should not generate alerts.

is that even possible?

CommentFileSizeAuthor
#11 appbar-with-profile-type.zip23.83 KBvertazzar

Comments

icecreamyou’s picture

Status: Active » Fixed

That's what the module is for. Just enable the alerts you want to see at admin/settings/appbar/display and the module does everything else for you.

Anonymous’s picture

Hello IceCreamYou

i tried it but from what i experienced it is not possible with the display settings to get what i'm looking for. it can only send notifications to the author of the node or the admin (user1), right?

This is what i'm trying to achieve

Situation

node written by TOM
1st comment written by JACK
2nd comment written by BOB
3rd comment written by SARAH

i want JACK to get notifications of BOB and SARAH's comments.

Maybe rules with some php is the way to go here or a custom module?

Happy new year btw. Thank you for contributing all these awesome modules, i have implemented the facebook style status module for a customer the other day. it's really very valuable work you do for the drupal project.

icecreamyou’s picture

Title: Need help with a rather complicated but yet simple use of appbar / activity /views » Alert other commenters of new comment
Component: User interface » Code
Category: support » feature
Status: Fixed » Postponed

Well thank you. Happy new year to you as well.

Looks like you're right--that functionality is not built in by default, although it probably should be. In the mean time, Appbar integrates with the Rules and Activity modules as well as the core Trigger module, and you may be able to use one or more of these to get the result you want. (Rules is probably your best bet.)

Postponing until I get some time to work on this.

vertazzar’s picture

And rules integration doesn't work as intend, so if the bara.munchies had problems even with the 'built in' settings for notifying other users of their nodes being commented, something is definitely wrong with Appbar API (it wont work with database inserts when other ID than global $user is set)

I've already discussed with you about the rules integration and I have no idea how it could be the problem with rules when tons of other modules are integrated with rules and have 0 problems.

Maybe you should review your code for possible errors, than this module could be useful at last. Without rules integration, it is a waste.

BTW - bara.munchies, that feature can be done by rules with setting proper conditions and truth check values.

icecreamyou’s picture

@vertazzar, for goodness' sake, there's nothing wrong with Rules integration or the Appbar API. There's something wrong with your installation. If you read the thread instead of looking for something wrong to criticize, you would see that it's not that Appbar isn't working, but that there isn't an option for what bara.munchies wants without using Rules. And you even admit that it will work with Rules. Please take your unfounded and irrelevant diatribe elsewhere, as it doesn't belong in this thread. If you don't like the way Appbar works, instead of berating the free work I've done with my little spare time, offer a patch to improve it.

Anonymous’s picture

@vertazzar don't know whats wrong with you. you are being very rude.

@IceCreamYou

i ended up writing a small module hooking into comment publishing, checking for involved users and then just sending each one a alert via api. some conditions not to send twice or to comment creator. i like your module. the api is simple and clear. can use for any purpose. next i will write a private message hook. will clean up the code and then post it here.
but it's a seperate module and not a patch.

vertazzar’s picture

I just say that rules could do the job because I know what rules have to offer, I don't "admit" anything I just stated the facts of appbar while I was testing it. Ive tested Appbar about month ago and found no solution with it, and for me - it is bugged. ANYWAYS I didn't want to flame you or your work. It's your thinking that defined my opinion unfounded and irrelevant. My intention of posting that comment was only to help the author of this topic.

If you cannot understand my English well, sorry I don't live in USA, or England, I'm from Bosnia.

icecreamyou’s picture

@bara.munchies

I'm glad you found the API easy to use. I would much appreciate if you would attach your code here as it would greatly simplify adding this feature to Appbar even if it's not in patch form. I've already written Privatemsg integration but the Privatemsg maintainer declined to include it in the module and instead posted it in the handbook here.

vertazzar’s picture

<?php
array (
  'rules' => 
  array (
    'rules_14' => 
    array (
      '#type' => 'rule',
      '#set' => 'event_comment_insert',
      '#label' => 'A-new-comment-is-added-to-your-content',
      '#active' => 1,
      '#weight' => '0',
      '#categories' => 
      array (
      ),
      '#status' => 'custom',
      '#conditions' => 
      array (
        0 => 
        array (
          '#weight' => 0,
          '#negate' => 1,
          '#info' => 
          array (
            'label' => 'Numeric comparison',
            'arguments' => 
            array (
              'number1' => 
              array (
                'label' => 'Number 1',
                'type' => 'number',
              ),
              'number2' => 
              array (
                'label' => 'Number 2',
                'type' => 'number',
              ),
            ),
            'module' => 'Rules',
          ),
          '#name' => 'rules_condition_number_compare',
          '#type' => 'condition',
          '#settings' => 
          array (
            'number1' => '<?php echo $comment_author->uid; ?>',
            'number2' => '<?php echo $node_author->uid; ?>',
            'operation' => 'equal',
            '#eval input' => 
            array (
              'rules_input_evaluator_php' => 
              array (
                'number1' => 
                array (
                  0 => 'comment',
                  1 => 'comment_author',
                ),
                'number2' => 
                array (
                  0 => 'node',
                  1 => 'node_author',
                ),
              ),
            ),
          ),
        ),
      ),
      '#actions' => 
      array (
        0 => 
        array (
          '#weight' => 0,
          '#type' => 'action',
          '#settings' => 
          array (
            'message' => '<span class="new-comm-auth"><?php echo $node_author->name; ?>, <a href="[user:site-url]/user/<?php echo $comment_author->uid; ?>"><?php echo $comment_author->name; ?></a> commented your <a href="[user:site-url]/node/<?php echo $node->nid;?>/#comment-<?php echo $comment->cid;?>">content</a></span>',
            'account' => '<?php echo $node_author->uid; ?>',
            '#eval input' => 
            array (
              'token_rules_input_evaluator' => 
              array (
                'message' => 
                array (
                  0 => 'user',
                ),
              ),
              'rules_input_evaluator_php' => 
              array (
                'message' => 
                array (
                  0 => 'comment',
                  1 => 'comment_author',
                  2 => 'node',
                  3 => 'node_author',
                ),
                'account' => 
                array (
                  0 => 'node',
                  1 => 'node_author',
                ),
              ),
            ),
          ),
          '#name' => 'appbar_action_set_message',
          '#info' => 
          array (
            'label' => 'Set an alert in the Application Toolbar',
            'module' => 'Application Toolbar',
            'eval input' => 
            array (
              0 => 'message',
              1 => 'account',
            ),
          ),
        ),
      ),
      '#version' => 6003,
    ),
  ),
)
?>

I created rule that sends alert to node author when someone adds a comment, but was unable to make facebook-like behavior.
(Btw IceCreamYou, i made the rules work when using echo $node,user,bla bla vars at PHP Evaluation. The token usage was the problem that I've encountered...

So did anyone made the facebook-like behavior ?

vertazzar’s picture

I have suggestion for rules integration...

<?php

/**
 * Sets an alert from Rules.
 */
function appbar_action_set_message($settings) {
  if ($settings['account'] == 'user') {
    $settings['account'] = $GLOBALS['user']->uid;
  }
/* we change here "misc" into $settings['identifier'] */
  appbar_set_message($settings['message'], $settings['identifier'], $settings['account']);
}

/**
 * Configuration form for the Rules action to set an alert.
 */
function appbar_action_set_message_form($settings, &$form) {
  $settings += array('message' => '', 'account' => 'user');
  $form['settings']['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#required' => TRUE,
    '#rows' => 5,
    '#default_value' => $settings['message'],
  );
/* I added the field which tells the category of alert sent, this allows you to create 2 views, the one that filters the unread messages for appbar (with filter = misc), and the one that is embedded on profile which filters "activity like" with view filter (filter=profile), so  the rules integration gives all needed control over API. */
  $form['settings']['identifier'] = array(
    '#type' => 'textfield',
    '#title' => t('Which category'),
    '#description' => t('The alert will be put in the following category. '.
      'misc is the one that is default, the one that goes to appbar, the "profile" one goes on profile, as activity.'),
    '#required' => TRUE,
    '#default_value' => $settings['account'],
  );
  $form['settings']['account'] = array(
    '#type' => 'textfield',
    '#title' => t('Show message to (User ID)'),
    '#description' => t('The alert will be registered for the person specified above. '.
      'Type "all" (without the quotes) for the message to go to all users, or "user" (without the quotes) for the message to go to the current user.'),
    '#required' => TRUE,
    '#default_value' => $settings['account'],
  );
}

/**
 * Implementation of hook_action_info().
 */
function appbar_action_info() {
  return array(
    'appbar_set_message_action' => array(
      'description' => t('Set an alert in the Application Toolbar.'),
      'type' => 'appbar',
      'configurable' => TRUE,
      'hooks' => array('any' => TRUE),
    ),
  );
}
?>
vertazzar’s picture

StatusFileSize
new23.83 KB

here is the version of it which contains misc and profile type, including the rules suggestion.

I don't know how to submit a patch, so im just going to attach .zip file.

Btw you can see the little demo here:

http://pokit.etf.ba/upload/pokit634b9206656831123c8782279320a0a5.png

icecreamyou’s picture

@vertazzar I originally excluded the identifier field because any identifier that is not explicitly defined by a module is ignored. However, your point is well-taken, and I could potentially build a select-list. I will not be able to commit anything for about two weeks but once I get some time I will probably implement something based on your suggestion.

vertazzar’s picture

aha, i manually added the identifier - i saw that you created the function that prevents any other identifiers inserted than the ones defined - which is good.

thank you anyways, i created what i wanted with this module and ill be glad to assist you in further dev at least with ideas. (cuz im not so good with php)

icecreamyou’s picture

Status: Postponed » Fixed

I just committed support for alerting all commenters in a thread, as well as specifying a category in a Rule.

Status: Fixed » Closed (fixed)

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

ilw’s picture

Thank you all for the effort!

I think its much better to utilize the PrivetMSG and I'm waiting for any ready-made module to handle this.

Anyway, thank you again.