If you enable all the modules fresh, and only enable the Subscribe OG flag the view doesn't work. As far as I can see it looks at the relationship on the subscribe_node view but that relationship points at the subscribe_node flag, rather than the subscribe_og one. I'm not sure how this was intended to work.

I've formatted a patch which adds in a new Subscribe OG view. I've also marked all the views as disabled initially, it will enable them automatically if they are used.

I fixed a few typos and coding standards errors too.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Paul Lomax’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, subscribe_og_fix.patch, failed testing.

amitaibu’s picture

+++ b/modules/message_subscribe/message_subscribe_ui/message_subscribe_ui.module
@@ -136,15 +136,27 @@ function message_subscribe_ui_tab($account, $flag_name = NULL) {
+  // Exception for OG as its not a content type.
+  $type = $flag->name == 'subscribe_og' ? 'og' : $flag->content_type;

The flag name isn't per content -- it's per a certain logic you want. You can have 10 different flags for nodes (i.e. the "node" in the name doesn't imply the logic).

+++ b/modules/message_subscribe/message_subscribe_ui/message_subscribe_ui.module
@@ -136,15 +136,27 @@ function message_subscribe_ui_tab($account, $flag_name = NULL) {
+  // If the required view is disabled enable it.
+  $views_status = variable_get('views_defaults', array());
+  if ($views_status[$view_name] !== FALSE) {
+    $views_status[$view_name] = FALSE;
+    variable_set('views_defaults', $views_status);
+    views_invalidate_cache();

I think it's better to throw an exception. Enabling a view is something the admin should do.

Paul Lomax’s picture

Yeah i'd probably ignore this patch, i'll see if I can do another.

I do feel if you are going to provide a default OG flag, then it does need a corresponding view. Currently if you enable just the subscribe_og flag the Subscriptions tab on the user page will throw an error.

So two things need to happen when enabling a default flag,

  1. It needs a default Subscriptions view assigning to it. Which you can do through the settings, but it defaults to $prefix . $flag->content_type. This ends up as subscribe_node
  2. It needs to enable the associated view.

This could be done by extending flag_flag->enable()?

wuh’s picture

Just wanted to chime in and say that I agree with Paul, I think the default OG flag needs a corresponding view. It's just confusing not to have it when the others are provided.

Great module :)

amitaibu’s picture

@Paul Lomax,
Are you going to re-roll this? I'd like to roll a new release soon.

dalinian’s picture

I concur with this assessment, though I think there are other non-intuitive aspects to this module, like requiring the email_node flag to be set. Nonetheless, I thought I would take a stab at fixing this particular issue. I think, I've managed to do it with a relatively simple additions.

  • I created two og views ('subscribe_og' and 'subscribe_og_email') that mirror the subscribe_node and subscribe_node_email views.
  • I modified the value of the variable 'message_subscribe_og' to be 'subscribe_og_email:default'

As far as I can tell, this achieves what we want. I did not disable the views automatically, but I did do an og module check against them, so they will not be visible unless the og module exists. I'm attaching a patch with these changes.

amitaibu’s picture

+++ b/message_subscribe_email/message_subscribe_email.install
@@ -16,7 +16,7 @@ function message_subscribe_email_install() {
+    'message_subscribe_og' => 'subscribe_og_email:default',

The reason we use subscribe_node_email and not subscribe_og_email, is that OG can work with any fieldable entity, so the name OG would be a bit confusing here.

dalinian’s picture

I actually do not think it's confusing at all since the variable refers to a view that refers to entities to which og has been applied, but I'm happy to change the variable value and the view name. Do you have a better suggestion? It must be different from the default subscription value in order to call the correct view.

amitaibu’s picture

I think I might have mistaken in my previous comment. I'll need to re-review the code.

Minor:

+++ b/message_subscribe_email/message_subscribe_email.views_default.inc
@@ -266,5 +266,100 @@ function message_subscribe_email_views_default_views() {
+  if(module_exists('og')) {

if( => if (

k_zoltan’s picture

Fixed minor issue refered by @Amitaibu

k_zoltan’s picture

Status: Needs work » Needs review

Let's test the latest patch

The last submitted patch, 7: message_subscribe-subscribe_og_fix-1983226-7.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 11: message_subscribe-subscribe_og_fix-1983226-11.patch, failed testing.

RKopacz’s picture

Just gently checking in to see if there is any news on this? I will try to look at it myself, but my PHP skills are not that advanced and this seems to be a complex module. I have a current use case to which I would like to apply it.

sadashiv’s picture

Status: Needs work » Needs review

Hi,

Would be nice if anyone can test https://www.drupal.org/node/2406413#comment-9513319 and update.

Hth,
Sadashiv.

Status: Needs review » Needs work

The last submitted patch, 11: message_subscribe-subscribe_og_fix-1983226-11.patch, failed testing.

bluegeek9’s picture

Status: Needs work » Closed (outdated)