Hello,
I'm the author of the Facebook-style Statuses module (FBSS). FBSS allows users to have a "status" like on Facebook or Twitter. Users can also write messages on other users' profiles.
I've had Activity integration for awhile now, but recently a user brought up a concern in the issue queue. Essentially, right now FBSS integration with Activity shows four fields on the Activity publisher template: one for the user on whose profile the status was posted (if the status was not a self-update); one for the user who posted the status (if the status was not a self-update); one for the user who posted the status (if the status was a self-update); and one for "everyone else."
This user's problem was that they wanted different templates shown to "everyone" depending on whether the status was a self-update or not. For example, if User A posts "I am happy" as their status, then the public message should be "User A says I am happy". But if User A writes "Hello" on User B's profile, then the public message should be "User A said Hello to User B."
I've altered the Activity publishing form to add an extra "everyone" field, and I'm saving the templates into a system variable. However, as far as I can tell, there's no convenient way to change the template for the message text before it gets processed and stored in the {activity_messages} table. In order to do that, I have to wait until hook_activity_message_recorded() gets called, look up the {activity_targets} table, and then change the contents of the {activity_messages} table. That's slow and difficult, although I've worked out the code to do it if necessary.
Is there an easier way to do this? Doing a str_replace() over the message in hook_activity_messages_alter() is impossible because (A) the template is entirely different and (B) there is no way to tell the language or the $context.
Thanks,
Ice
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | fbss_activity.png | 51.38 KB | icecreamyou |
Comments
Comment #1
Scott Reynolds commentedInstead you should make two triggers. One for when a user updates there status an one for when a user writes on another profile. Then you are able to craft messages properly.
These two 'actions' are VERY distinct with a different actors in play (posting your own status is just one actor, You. Posting on someones profile, there are two actor's Author and Profile user)
Comment #2
Scott Reynolds commentedThat was someone of an incomplete statement, I should have completed it.
Its more then just a problem with the Everyone message. For instance, your example, the message for User A when he writes on User B's wall will be different as well. Basically, you will have to alter ALL message templates.
1.) Message for User A (You wrote on User B's profile)
2.) Add a message for User B (User A wrote on your profile)
3.) Change the Public message (User A wrote on User B's profile)
Thus, the motivation to create a new trigger and expose that as well to Activity.
This is different from the Comment problem #565748: Add comment activity message field for when comment author and node author is the same user as only one message template would need to be altered depending on the Actors involved.
Comment #3
yelvington commentedChanging this to the appropriate project, which is not fbstatus.
Comment #4
Scott Reynolds commentedPreserving my title and Component. Sry for the confusion.
Comment #5
icecreamyou commentedNope, everything works with one trigger, and it's been working great for the past few months. It's impractical and counter-intuitive to have multiple triggers for the same event (submission of the status update form). The only issue at hand is determining the template to use for a second message to everyone.
(Part of the reason it works is because the system treats a self-update as having two actors, it's just that they both refer to the same object.)
The attached image shows what the Activity publisher template looks like. Below are the scenarios for different events that can happen and the messages that are shown to various users.
In terms of interaction, these may seem like slightly different events, but in terms of code, they are exactly the same.
The structure described above is how everything is currently working, and also exactly how I want it to work. There are no acrobatics required to make it happen this way; the code is straightforward except when it comes to having different templates for the Public message. My question was simply if there is a way to more easily access additional information in the hooks that Activity offers, and if there is not that's okay as well since my existing code is working.
Comment #6
Scott Reynolds commentedWell I will point out that you have made, in my estimation, a bad design decision. As then the FBSS module will have to keep track of the different values for the messages itself.
But to answer your original question, there is this and only this
Please note, that it isn't [everyone-pattern] but [everyone-pattern-{$language_id}]
Comment #7
Scott Reynolds commented...
Wow, I passed over this before. Just because the form has the same $form_id doesn't mean that for a user its counter-intuitive....
Anyways, my solution, you would just have to create another op and your there. Thats it
And if you don't want to go that far...
And with different ops you can have different Activity templates. So this is not an issue at all with Activity.
Comment #8
icecreamyou commentedI'm aware of the language part, I have it working for every language across multiple $ops.
If I split the trigger, where does it stop? Does there have to be a different trigger for editing and deleting too? Doesn't that seem awkward?
I will think about this a little more. Thanks for your help thus far.
Comment #9
Scott Reynolds commentedIs editing and deleting put through exactly the same trigger and action? This makes me worry, as you are the only maintainer thus far that has written Activity2 integration by yourself. And this is disheartening..
What was the point of making Actions and Triggers the basis of Activity if people were just going to ignore it....
And how is that awkward? The messages should clearly be different. Should node edit and delete have the same messages as node insert? Please back up your assertions that it is awkward or counter-intuitive.
And the reality is, the form alter you did for the everyone message is probably more work then exposing more $op's to Activity2. This whole conversation is completely surreal to me and it is very disheartening. I think these things are obvious and clearly they are not and puts all the assumptions of Activity2 into a bad light...
edit: I hope this is where the confusion lies, I really do. But what Im sugguesting is not a completly new hook_trigger_name() and all that, but a new $op. That is all. I try to make this clear in #7
Comment #10
icecreamyou commentedNo, editing and deleting are separate actions! That would certainly be ridiculous to combine them. I'm saying that I may also have to split editing and deleting statuses based on whether the status in question was posted to one's own profile or to another's profile.
I completely understand the purpose of different Triggers and Actions and how they relate to Activity. My concern is unique to FBSS in that something I thought of as one action -- submitting the status form -- could involve either one or two actors. The question at stake here is simply which method will create the most intuitive UI for users.
Let me try to be a little clearer.
The part that felt unintuitive to me was that if I as a site administrator to go the Activity templates page, I think "I'm going to add a template for when a user edits a status." It doesn't immediately occur to me that there could be two different kinds of editing a status based on where the status was posted.
On the other hand, once I go to the template creation screen and it shows me a list of triggers with descriptions, the distinction may become clear. So I'm currently leaning towards your suggestion of splitting each of the three existing triggers (status submission, status editing, and status deletion). (The result will be six triggers.)
Comment #11
icecreamyou commentedI think I should also point out that part of the reason I opened this issue is that I think the Activity 2 API is relatively clear and useful (at the very least compared to Activity 1) so I was encouraged by this fact to explore some of the flexibility it offered. FBSS has unusual circumstances that occasionally make it necessary to stretch the limits of some APIs in ways that they weren't originally envisioned to be used, and this is simply a case where I tried to find a way to make the interface as clear to site administrators as possible at the potential expense of clarity of code.
Comment #12
sirkitree commentedhrm. maybe it's time to bundle activity_user status into activity2 so that users can have a great example of how to use the API's we offer. It does sort of duplicate some of FBSS, but it serves as a really good example of how a module can accomplish something solely upon Activity2's APIs.
Comment #13
icecreamyou commentedDoes it not seem ridiculous to you to duplicate functionality just to demonstrate how an API can be used? I understand how it can be used, and I've used it correctly in FBSS for months. The documentation is reasonably clear, and there are already fine examples of how the API is used within the existing Activity package. It's not even Activity's API that you're talking about, it's the Actions API in core!
Comment #14
icecreamyou commentedAlso, writing *anything* for the sole purpose of demonstrating an API is in dubious territory. Attempting to duplicate the functionality of a very powerful and stable module with thousands of hours of development work, in a way that could not possibly be maintained anywhere near as well as FBSS is, is simply absurd. It's the equivalent of me building an Activity system in FBSS just to demonstrate how statuses could be displayed. If you want to build a good example of how the Activity API should be used, write a patch for FBSS, don't waste time and effort on duplicated functionality that could never approach FBSS's flexibility anyway, please!
By the way, Mr. Reynolds, you helped a bit with the original Activity 2 integration way back in early June.
Comment #15
Scott Reynolds commentedI would point out that are two projects are used in conjunction a lot. and if you were to stop maintaining yours, this project would suffer.
Plus its already built, we needed something leaner for a project then FBSS and we need a little more functionality. Sirkitree and I happen to be very proud of what we created.
Thats not true either. It doesn't touch the level of complexity, activity_user_status is a simple module and it will always remain simple...
But regardless, this is way off topic. This issue is closed, my concerns were understood and a direction has been chosen.
Comment #16
icecreamyou commentedI didn't mean to imply that Activity isn't well-maintained; Activity and FBSS are used together and if Activity stopped being maintained then FBSS would suffer as well. I use Activity 2 on several sites and I like it a lot. I just meant that, as part of a larger project, it's unlikely that activity_user_status would get the same kind of focus that I can give to a dedicated project like FBSS.