Support from Acquia helps fund testing for Drupal Acquia logo

Comments

salvis’s picture

Possible yes, planned no.

I don't do OG, but I'm sure there'd be interest in a subscriptions_og.module add-on. If we find someone who wants to develop and maintain it (either as a contrib to Subscriptions or a separate module), then I will support the effort.

Traverus’s picture

I have a need for this and am willing to contribute. Could OP and/or salvis give some input on functionality that would be nice? The thoughts I have are the following:

If contrib module is enabled and subscription block is put in to a group node, then the following occurs:

  • Generate subscription link by author (already functioning)
  • Generate subscription link by content type (already functioning)
  • Generate subscription link for group content change (if group content is created/updated/deleted that has this group node in the audience field, notification sent)
  • Generate subscription link for group node change (If someone edits the group node itself and makes a change)

Could anyone suggest other implementation criterion that could/should be added before I start work?

Salvis, should I make feature request issues for multiple parts of what this may entail, or just keep it all in this issue? Thanks and look forward to working with you.

salvis’s picture

I have close to zero experience with OG and can't really help with requirements.

There exists a subscriptions_og project for D5 that is abandoned. This may be a source of inspiration for requirements, design, and even how-to-code.

A few years back there was some talk about whether to integrate OG with Notifications or Subscriptions. The result was that OG for D6 provided a neutral interface and Notifications picked up the ball. You should be able to find these discussions in the OG and Notifications queues.

Subscriptions has a modular architecture and I think you should be able to implement most everything in a Subscriptions add-on module. Ideally, you do this in your own sandbox, then you have full control, you can freely commit code and use your own issue queue to (hopefully) get feedback from other interested parties.

I would keep this issue open to track progress and to point to your sandbox, and if you need something specific from Subscriptions, then create a dedicated issue here that we can close when it's done.

mwallenberg’s picture

Status: Active » Needs review
FileSize
2.79 KB
0 bytes

I have written a module which integrates OG (7.x-1.x) with Subscriptions. Complete module is attached, both as a patch to current 7.x-1.x branch and as a compressed archive to be used as a standalone module.

The module is tested with OG 7.x-1.4 and working on the site I wrote it for, though I would recommend testing it out a bit before putting it in production. From the functionality listed by Traverus in #2, this module implements the following:

"Generate subscription link for group content change (if group content is created/updated/deleted that has this group node in the audience field, notification sent)"

I am not sure I can devote time to maintaining a contrib module, so if anyone wants to pick up this for use or base a project on it, you are more than welcome. Salvis, is there any chance of getting this into Subscriptions?

salvis’s picture

Status: Needs review » Needs work

Thank you for posting this.

Salvis, is there any chance of getting this into Subscriptions?

If we can gather some positive reviews here then I'm willing to put it under a contrib\subscriptions_og directory (make your patch accordingly!), but because we're unable to support or maintain it ourselves, I'd prefer it to be a separate module.

From http://drupal.org/node/add/project-issue/subscriptions (which you haven't seen because you posted a reply):

PLEASE DO NOT POST ANY ZIP FILES — append '.txt' to file extensions that aren't accepted (.module, .inc, .php).
Post one multi-file patch rather than several single-file patches (see http://drupal.org/patch/create for details).

Your patch file is empty, and no one looks inside zip files, so your chances for getting any review feedback are severely diminished.

mwallenberg’s picture

Ok, let's give that another try. I'm new to git, as you can probably guess :)

mwallenberg’s picture

Status: Needs work » Needs review
salvis’s picture

Status: Needs review » Active

There's a very useful Firefox add-in called Dreditor. It adds a [Review] button to patches and in your case it shows lots of erratic white space errors.

Please set your editor to convert tabs to two spaces and to remove trailing spaces. This does not make any difference in functionality, but the Drupal community spends a lot of effort to keep a uniform coding style, because that eliminates a lot of useless friction.

So, OG users, please try this out! And mwallenberg, please eliminate the white space errors for the next iteration.

Let's see if we can wake up the testbot...

salvis’s picture

Status: Active » Needs review

We don't have any automated tests at this point, but the "PASSED" confirms that the patch applies just fine.

mwallenberg’s picture

There was more to patching than I thought :) Salvis, thanks for all your help. Here's another version, which hopefully has correct whitespaces.

salvis’s picture

That looks much better, thank you! It may seem nit-picky, but it makes sense to embrace the http://drupal.org/coding-standards from the beginning — this gives you a head start in the community.

Some more formal comments. After that, your code will be pretty close to formally perfect.

The folks interested in OG will need to take over from here.

 

+++ b/contrib/subscriptions_og/subscriptions_og.info
@@ -0,0 +1,10 @@
+package = "Organic groups"

No quotes.

+++ b/contrib/subscriptions_og/subscriptions_og.info
@@ -0,0 +1,10 @@
+version = 7.x-1.x-beta

No version -- this is added by the packaging script.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+ * Implementation of hook_permission()

"Implements" -- "Implementation" is D6 style. And always put a full stop at the end.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+   return array(

Indent by 2.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+  // Queue: Define parameters used by Subscriptions to query which subscriptions should be

Wrap columns at 80. Dreditor marks column 81.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+  if ($op == "queue") {

Single quotes are preferred if no processing is required.
Maybe use switch().

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+  // Load all active subscriptions for this user, and allow

Full stop at the end of comments, but the end seems to be missing here.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+    // add the active subscriptions

Start comments with a capital letter and end with a full stop (everywhere).

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+ * @return int

Empty line before @return.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+  db_delete('subscriptions_queue')
+  ->condition('module', 'node')

Indent subsequent lines.

+++ b/contrib/subscriptions_og/subscriptions_og.module
@@ -0,0 +1,220 @@
+ * Callable function to compare the lexicographical order of two OG groups. Use
+ * together with usort to sort an array of groups.

Try to start with a verb in the third person singular, e.g. "Compares..." and to keep it to one line. This line goes into the Description column on pages like http://api.drupal.org/api/drupal/modules!system!system.module/7 (you'll see that core is not perfect...). Follow with an empty line and then as much text as you want.

Functions are always "callable". This type of function is often called "Helper function", e.g.
_system_sort_requirements   Helper function to sort requirements.

mwallenberg’s picture

Here we go: functionally identical to the previous patches, but fixed to better follow coding standards.

lhubbert’s picture

I've installed this, and it would be very helpful, but it doesn't seem to be respecting private groups. My test account, which is only a member of one group, has access to all groups (and gets all group notifications). Do I have something configured incorrectly?

mwallenberg’s picture

Nope, that's a coding error rather than a configuration error. That was not in the requirements for the site I originally wrote the module for, so it slipped my mind :) I won't have time to fix it at the moment, but if you (or anyone else) have the time to look into it, I think the place to start is where the groups are loaded for the subscription overview page (line 163 in subscriptions_og.module).

salvis’s picture

Status: Needs review » Needs work
Traverus’s picture

Putting this code starting at line 166 right after the foreach loop in subscriptions_og.module fixes the public/private issue. If someone could please apply this to their installation and re-create the patch I would be thankful, I'm not sure how to do this myself.

if(!node_access('view', node_load($group->etid))){
  continue;
}
mwallenberg’s picture

Status: Needs work » Needs review
FileSize
7.3 KB

Thanks Traverus! Here's the updated patch.

EDIT: I've tested the update (not with og_access, but rather with published/unpublished nodes) and it works as intended for me.

Traverus’s picture

Just as a heads up og_access module hooks in to the node_access system to implement its show/hide capabilities so the node_access calls respect og_access.

Tested and works fine for me too.

drupalycious’s picture

any chance you do the same for OG (7.x-2.x) ?
I would like to test it.

Thank you

mwallenberg’s picture

I'm afraid not. I developed this because a site I built at the time needed it, and I unfortunately can't commit time to update it to 7.x-2.x. Anyone who wants to is welcome to take the code and update it, though. Also, if I remember correctly OG 7.x-2.x is integrated with Message Notify, which could solve your problem.

http://drupal.org/project/message_notify

drupalycious’s picture

Thanks for the answer, I know message notify, it is a really good module, but I am not yet fully understanding how to correctly build the code for what I would like to do. So I was trying something easier like subscriptions module ;)

torrance123’s picture

FileSize
6.81 KB

I made a rough port of the code in comment 17 to work with OG2.x, for those interested.

Patribus’s picture

Hello!

I have installed the module with the latest patch, but I get the following error opening a node which is group

Fatal error: Call to undefined function og_get_group() in /home/www/web48/html/drupal7/sites/all/modules/subscriptions_og/subscriptions_og.module on line 119

Some ideas?

I'm using the OG 7.x-2.x branch.

Thanks

torrance123’s picture

@osmanedosbatuque: it looks like you're using the patch from comment 17 (which has a called to og_get_group() on line 119). Please try my patch from comment 22 — this should be OG2 compatible (and has no mention of a call to og_get_group()).

Patribus’s picture

Hello again,

I found an additional error, namely when creating new content. After submitting the create form, I get the following error.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'usr_web48_12.field_data_group_audience' doesn't exist: INSERT INTO {subscriptions_queue} (uid, name, language, module, field, value, author_uid, send_interval, digest, suspended, last_sent, load_function, load_args, is_new) SELECT u.uid AS uid, u.name AS name, u.language AS language, s.module AS module, s.field AS field, s.value AS value, s.author_uid AS author_uid, s.send_interval AS send_interval, su.digest AS digest, su.suspended AS suspended, COALESCE(sls.last_sent, 0) AS last_sent, 'subscriptions_content_load_node' AS load_function, '425' AS load_args, 1 AS is_new FROM {subscriptions} s INNER JOIN {subscriptions_user} su ON s.recipient_uid = su.uid INNER JOIN {users} u ON su.uid = u.uid LEFT OUTER JOIN {subscriptions_last_sent} sls ON su.uid = sls.uid AND s.send_interval = sls.send_interval INNER JOIN {field_data_group_audience} ga ON s.value = ga.group_audience_gid WHERE (s.module = :db_condition_placeholder_0) AND (s.field = :db_condition_placeholder_1) AND (s.author_uid IN (:db_condition_placeholder_2, :db_condition_placeholder_3)) AND (ga.entity_id = :db_condition_placeholder_4) GROUP BY u.uid, ga.entity_id; Array ( [:db_condition_placeholder_0] => node [:db_condition_placeholder_1] => group_audience [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => -1 [:db_condition_placeholder_4] => 425 ) in subscriptions_queue() (Zeile 536 von /home/www/web48/html/drupal7/sites/all/modules/subscriptions/subscriptions.module).

Patribus’s picture

Hello torrence123,

I did download your patch.

Is there some mismatch? What could it be?

Or I did not apply it correctly... Mmmm will repeat the process.

EDIT1: Just to be sure: The idea is to patch the module in comment #4 ?!

Patribus’s picture

OK, I found my problem.

The patch generates the drupal directory tree for modules. I did not see that and used the unpatched files.

Seems to work fine know.

PS: A question which does not belong here: Is the subscription link as it appears on a normal node available as a block or something similar in order to integrate it in panels?

Patribus’s picture

Sorry for all these comments, I did find some other error.

Starting from my user account subscription page

/user/%/subscriptions

Using the group-tab I navigate to

/user/%/subscriptions/og

and get the error

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'usr_web48_12.og' doesn't exist: SELECT s.value AS value, s.send_interval AS send_interval, s.author_uid AS author_uid, s.send_comments AS send_comments, s.send_updates AS send_updates, og.label AS label FROM {subscriptions} s INNER JOIN {og} og ON s.value = og.etid AND og.entity_type = 'node' WHERE (s.module = :db_condition_placeholder_0) AND (s.field = :db_condition_placeholder_1) AND (s.recipient_uid = :db_condition_placeholder_2) ORDER BY s.author_uid ASC; Array ( [:db_condition_placeholder_0] => node [:db_condition_placeholder_1] => group_audience [:db_condition_placeholder_2] => 1 ) in subscriptions_og_page() (Zeile 115 von /home/www/web48/html/drupal7/sites/all/modules/subscriptions_og/subscriptions_og.module).

some idea?

Patribus’s picture

Someone an idea?

salvis’s picture

You have no {og} table? Do you have OG installed at all?

Yes, the node subscriptions UI can be exposed as a block (see the Subscriptions settings). I don't know whether that works with Panels or not. Please try it out and let us know.

Patribus’s picture

hehehe, yes I have og installed, thats why the error irritates me.

can I deliver some more info in order to track the error origin?

Patribus’s picture

Is there someone else having this problem?

torrance123’s picture

@osmanedosbatuque: You're right, og2.x no longer uses the {og} table anymore. In my case, I've upgraded and I still have the old table, but it's no longer being updated. You must have a clean installation and therefore no {og} table at all.

I'll have a look at fixing this on Monday, and I'll upload a new patch if I can make this work.

Patribus’s picture

that are nice news.

Just a question about the functionality of this module.

In case of subscriptions, the subscription link on nodes shows different subscription possibilities like: subscribe to this node with or without edits and/or comments, subscribe to this node type, with or without edits and/or comments, etc. Will there be also an option at this point for the respective group subscription? I.e, the subscription link will than show the option to subscribe to the group content? Because for the moment I do not see this anywhere. In order words, where is the link to subscribe to the group content of a node?

Thanks

torrance123’s picture

Updated 2.x version is here: https://github.com/fuzionnz/subscriptions_og

This no longer relies on the {og} table.

Will there be also an option at this point for the respective group subscription?

There already is this option: if you look at a group node you'll see an option to "[Subscribe] To content posted in [node title]". I'm not sure why you aren't seeing this.

Patribus’s picture

Hello, the link is not working! Can correct it please?

Thanks

torrance123’s picture

Sorry, try again — I'd accidentally set the repo to private.

https://github.com/fuzionnz/subscriptions_og

Patribus’s picture

just perfect!

everything seems to be running correctly now. Will keep you informed about possible bugs or strange behaviors.

Cheers

salvis’s picture

Status: Needs review » Needs work

The patch in #22 seems to be outdated.

torrance123’s picture

FileSize
9.54 KB

The patch in #22 has been superseded by the github repo here: https://github.com/fuzionnz/subscriptions_og

For your convenience, I've attached the latest diff of this repo.

torrance123’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

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

salvis’s picture

I think #40 is missing a newline at the end of the patch file. This keeps the testbot from applying the patch.

Please put your module into subscriptions/contrib/subscriptions_og and create the patch from the subscriptions directory.

timwood’s picture

Issue summary: View changes

I don't see a contrib subdirectory in subscriptions module, not in any release/packaged version nor any D.O. Git branch. Were you referring to some other version of subscriptions where sub-modules have been moved to a contrib subdirectory?

salvis’s picture

You need to create the contrib directory.

The idea is not to move the submodules there but to make a clear separation between the submodules that I maintain (which remain where they are) and those that have been contributed by others and that I will not maintain.

The ideal way of handling this would be to make a separate d.o project.
If this is not possible, but there's a consensus that a submodule warrants inclusion in Subscriptions, then we can put it into the new contrib directory. Support will need to come from those that have contributed it (or are interested in it), and if there are issues that cannot be resolved, then I will take the liberty to remove it.

timwood’s picture

Status: Needs work » Needs review
FileSize
9.74 KB

I've recreated the patch per salvis' suggestion to include it as a sub-module under a "contrib" folder inside the Subscriptions module. Same exact code as in the Github repo linked from comment #40 (which is slightly different than the patch in #40) with a new line at the end of the file for the bot's consideration.

salvis’s picture

Thank you, timwood!

OG users: Please review and test!

herved’s picture

Thanks a lot everyone for this patch.

Here's a new patch with some small improvements:
- Fixes some phpcs issues
- Creates an .install file (move the hook_disable() inside and add hook_uninstall() to delete the subscriptions_og_autosubscribe variable)
- Send subscriptions for active OG members only (had to patch subscriptions.module to achieve this as it doesn't accept more than 1 JOIN initially).
- Allows a user to view and subscribe to any/all groups if he has the "administer group" permission (at user/%user/subscriptions/og).

Also we might want to unsubscribe automatically a user when he leaves a group or adapt subscriptions_og_page().
If a user unsubscribes with subscriptions_og_autosubscribe set to FALSE he's currently unable to leave the group as the group won't show up any more in subscriptions_og_page().
For now I'll just use this with subscriptions_og_autosubscribe set to TRUE.

Hervé

vistree’s picture

Sorry for reopening an old task, but is the patch in #48 supposed to work with OG 7.2 or only with OG 7.1. @herved - can you please clarify?

herved’s picture

Hello @vistree,
The last release of OG 7.x-1.x dates back from 26 September 2012 which is very old.
The project I was working on was using OG 7.x-2.x when I updated the patch. And it still is AFAIK.

vistree’s picture

Great, than I will better try your patch from #48 and not the github module referenced in #40 for my OG 7.2 implementation, correct?

herved’s picture

Correct.
The patch of timwood in #46 contains the same code as the github repo from #40.
My patch in #48 contains some improvements to patch #46.

vistree’s picture

Thank you herved: will test and report back ;-)

vistree’s picture

Patch from #48 worked well. I did some modifications, as I need to be able to subscribe to all public groups + the private groups a user is assigned to. Works well ;-)
Now I need to implement one more thing: we use og_subgroups and therefor I need to implement some inheritance for the subscriptions also. What would be the best way? I thought, that I could do a bulk subscribe to all child groups if a user subscribes to the parent group. And if he unsubscribes from the parent group I need to also unsubscribe him from the child groups.
Is there somehow a possibility to react on subscribe/unsubscribe action?

salvis’s picture

Is there somehow a possibility to react on subscribe/unsubscribe action?

Adding a hook for this might make sense.

vuil’s picture

Status: Needs review » Reviewed & tested by the community

The patch #48 is ready to be deployed in 7.x-1.x-dev branch. Thanks to everyone!

  • salvis committed 71ed093 on 7.x-1.x
    Issue #1456560 by herved, mwallenberg, torrance123, timwood, salvis:...
salvis’s picture

Status: Reviewed & tested by the community » Fixed

Ok, thank you all for your efforts and patience!

@vistree (#54): Please open a new issue if more work is needed.

Status: Fixed » Closed (fixed)

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