Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Untested.

git checkout -b 1421422

zualas’s picture

Wondering if Rules integration is in the dev release. Right now looks like the rules for OG don't work, for example "OG group members" returns empty values.

g089h515r806’s picture

FileSize
8.97 KB

I have upload a patch at http://drupal.org/node/1502956 ,
Which fixed all the issues of rules integration that i could find.
I upload the latest patch at here.

amitaibu’s picture

Status: Active » Needs work
+++ b/og.rules.incundefined
@@ -215,21 +212,20 @@ function og_rules_get_members($group_content) {
+    // Get the group members the group content belongs to.

You should use entityFieldQuery here.

+++ b/og.rules.incundefined
@@ -243,30 +239,23 @@ function og_rules_get_managers($group_content) {
+  //remove duplicate items

Start with capital, and finish with dot.

+++ b/og.rules_defaults.incundefined
@@ -14,18 +14,26 @@ function og_default_rules_configuration() {
+      { "entity_is_of_type" : { "entity" : [ "og-membership:group" ], "type" : "node" } }	

Remove space.

g089h515r806’s picture

Using db_select is much easier than entityFieldQuery at here.

If we use entityFieldQuery,
1,then we get the membership ids first,
2,we need write a foreach function,
3,then we need load all the membership objects through ids,
4,then get the etid.

It is much complex than using db_select.
Instead of using db_select,which could get all current members in one step. we write less code, and the speed is quick than using entityFieldQuery.

There are a lot place in drupal core, which could use entityFieldQuery also coudl use db_select. at most case, they use
db_select instead of entityFieldQuery. for example

/**
 * Implements hook_user_cancel().
 */
function node_user_cancel($edit, $account, $method) {
  switch ($method) {
    case 'user_cancel_block_unpublish':
      // Unpublish nodes (current revisions).
      module_load_include('inc', 'node', 'node.admin');
      $nodes = db_select('node', 'n')
        ->fields('n', array('nid'))
        ->condition('uid', $account->uid)
        ->execute()
        ->fetchCol();
      node_mass_update($nodes, array('status' => 0));
      break;

At here using entityFieldQuery also works, but if we use db_select, it is much short, concise, quick.

So I think we do not need to use entityFieldQuery instead of db_select at here.

g089h515r806’s picture

FileSize
8.97 KB

here is the latest patch, fixed "Start with capital, and finish with dot.", and "Remove space.".

mradcliffe’s picture

Status: Needs work » Needs review

I tested the patch last week, and it does work fairly well for the standard use cases. The rules are now restricted to group nodes, but could possibly be used for other group entities like user or anything that has a uid column.

I played around with the rules integration some more and was able to come up with more complex things.

Is there a base set of rules functionality we need to test manually for this task?

Changing status to run latest patch through automated tests (hopefully).

g089h515r806’s picture

I have spend my three days vocation to port it to 2.x. and did not earn 1 commit to OG.

amitaibu’s picture

> I have spend my three days vocation to port it to 2.x. and did not earn 1 commit to OG.

I'm waiting (hoping) for community review, as I don't user Rules myself, I prefer someone more familiar to go over it.

mradcliffe’s picture

I think the patch is a good start, but we will only find out the more edge cases in further issues.

amitaibu’s picture

Status: Needs review » Fixed

Thanks guys, committed -- and of course credited g089h515r806 :)

g089h515r806’s picture

Thanks Amitaibu, i earn another commit to OG. I have 2 commits now.

amitaibu’s picture

g089h515r806, keep the patches coming, and you'll get more commits! :)

Status: Fixed » Closed (fixed)

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

modctek’s picture

I saw that this was committed over a month ago, but still not a part of alpha-3? I see it in the patch notes, but I don't see any triggers for OG. Have I configured something incorrectly? Never mind, I was confusing D7's triggers with Rules but then I finally sobered up. :)