3

In my case a user with the role ("team member") flags a node created by normal user. I want to display "@team member_id flagged @node_id created by @user_id". Maybe later on I would like to add profile pics of both user/team member or the email or any information in the view about them.

Is this possible?

Here is an export of the Message type (created with the Message module):

{
  "name" : "utilisateur_finalise_intervention",
  "description" : "Utilisateur finalise intervention",
  "argument_keys" : [ "@utilisateur", "@equipier" ],
  "argument" : [],
  "category" : "message_type",
  "data" : {
    "token options" : { "clear" : 0 },
    "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" }
  },
  "language" : "fr",
  "arguments" : null,
  "message_text" : { "fr" : [
      {
        "value" : "@utilisateur a finalis\u00e9 une intervention avec @equipier",
        "format" : "filtered_html"
      }
    ]
  },
  "rdf_mapping" : []
}

And the rule I created looks like so:

Rule-finaliser_intervention

{ "rules_link_set_finaliser_une_intervention" : {
    "LABEL" : "Rules link: Finaliser une intervention rules set",
    "PLUGIN" : "rule set",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag", "rules" ],
    "USES VARIABLES" : {
      "user" : { "label" : "user", "type" : "user" },
      "node_id" : { "label" : "node_id", "type" : "node" }
    },
    "RULES" : [
      { "RULE" : {
          "PROVIDE" : { "entity_created" : { "log_fin_intervention" : "log_fin_intervention" } },
          "DO" : [
            { "flag_unflagnode" : {
                "flag" : "accepter_invitation",
                "node" : [ "node-id" ],
                "flagging_user" : [ "user" ],
                "permission_check" : "1"
              }
            },
            { "flag_flagnode" : {
                "flag" : "fin_intervention",
                "node" : [ "node-id" ],
                "flagging_user" : [ "user" ],
                "permission_check" : "1"
              }
            },
            { "entity_create" : {
                "USING" : {
                  "type" : "message",
                  "param_type" : "utilisateur_finalise_intervention",
                  "param_user" : [ "node-id:author" ]
                },
                "PROVIDE" : { "entity_created" : { "log_fin_intervention" : "log_fin_intervention" } }
              }
            },
            { "data_set" : {
                "data" : [ "log-fin-intervention:arguments:utilisateur" ],
                "value" : [ "node-id:author:uid" ]
              }
            },
            { "data_set" : {
                "data" : [ "log-fin-intervention:arguments:equipier" ],
                "value" : [ "user:uid" ]
              }
            },
            { "mail" : {
                "to" : [ "user:mail" ],
                "subject" : "Votre collaboration sur [node-id:title] est termin\u00e9e",
                "message" : "Votre collaboration avec [node-id:author:field-prenom] [node-id:author:field-nom] sur le projet  [node-id:title] est maintenant termin\u00e9e",
                "from" : [ "" ],
                "language" : [ "" ]
              }
            },
            { "drupal_message" : { "message" : "Votre collaboration avec  [user:field-prenom] [user:field-nom]  est maintenant termin\u00e9e" } },
            { "redirect" : { "url" : [ "node-id:url" ] } }
          ],
          "LABEL" : "Finaliser intervention"
        }
      }
    ]
  }
}

And also the view I created:

enter image description here

I also have an error displayed above the view

Notice : Undefined variable: table dans ViewsUiBaseViewsWizard->default_display_filters_user()
  • i've updated my first post and the errod does not disappear – Yassin Siouda Aug 3 '17 at 13:39
  • Can you also include in your question an export of the "Message Type" with machine name "utilisateur_finalise_intervention" (which is the Message Type you're referring to in your custom rule). Pretty sure there is something there that you have not yet configured as it should. BTW: chapeau for the interesting use case of the message module you seem to be creating! – Pierre.Vriens Aug 3 '17 at 14:43
  • Haha thanks :) Updated with the "Message type" export – Yassin Siouda Aug 3 '17 at 15:01
3

"To add profile pics of both user/team member or the email or any information in the view ..." (as in your question), you cannot use the replacement tokens (= @utilisateur and @equipier in your case). These tokens can only be used as part of your Message Text (as you are already doing), as indicated also via ... which the message text makes use of ... on the Message Types form where you enter those tokens.

However, Messages are fieldable entities. So what you can do is like detailed in the steps below ...

Step 1:

Define a field in your Message Type corresponding to each of those tokens. As an example, add fields similar to these (for equipier and for utilisateur), with machine names like so:

  • field_equipier_user_name.
  • field_equipier_user_id.
  • field_utilisateur_user_name.
  • field_utilisateur_user_id.

Your replacement tokens appear to be uid values, note that I'm using a similar uid, but also the name as an alternative (it could as well be an eMail field, etc).

Step 2:

Extend your rule to also perform a Rules Action like "Set a data value" (for each of your fields you added in the previous step). To continue the example, add these actions in your existing rule:

 ,
{ "data_set" : {
    "data" : [ "log-fin-intervention:field-equipier-user-name" ],
    "value" : [ "user:name" ]
  }
},
{ "data_set" : {
    "data" : [ "log-fin-intervention:field-equipier-user-id" ],
    "value" : [ "user:uid" ]
  },
{ "data_set" : {
    "data" : [ "log-fin-intervention:field-utilisateur-user-name" ],
    "value" : [ "user:name" ]
  }
},
{ "data_set" : {
    "data" : [ "log-fin-intervention:field-utilisateur-user-id" ],
    "value" : [ "user:uid" ]
  }

Step 3:

Extend your view to also add those extra Message Type fields to your view (as extra fields of your view. Be aware: if later on you add more fields to your Message Type (and rule and view afterwards also), you'll only have actual values in the corresponding columns of the Views results for message that were created after you added those extra fields.

BTW, the Views error near the end of your question seems like a different question (not addressed in this answer ...).

PS: this answer applies to D7 ...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.