In user_roles.action.inc, if the view doesn't include group_type and gid as the first and second arg, you get a unsupported operand error. It makes more sense to rely on og_context() to get the group_type and gid.

Change includes/user_roles.action.inc line 12:

  // Get the group type and group ID from the Views arguments.
  list($group_type, $gid) = $context['view']->args;

To:

  // Get the group type and group ID from the group context.
  $og_context = og_context();

  $group_type = $og_context['group_type'];
  $gid = $og_context['gid'];
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

It makes more sense to rely on og_context() to get the group_type and gid.

This can be a fallback in case $context['view']->args doesn't have what we want. Patches are welcome.

weekbeforenext’s picture

Status: Active » Needs review
FileSize
1.34 KB

The attached patch identifies the gid and group_type arguments, if they exist, and uses them first. If both arguments are not found, it uses og_context. However, when I called og_context(), it didn't work so I used $_SESSION['og_context'] instead.

amitaibu’s picture

+++ b/includes/actions/user_roles.action.incundefined
@@ -10,7 +10,28 @@ function og_user_roles_action_info() {
+	$gid_key = array_search('gid', $arguments);
+	$group_type_key = array_search('group_type', $arguments);
+	if($gid_key !== FALSE && $group_type_key !== FALSE){
+	  $gid = $context['view']->args[$gid_key];	¶
+	  $group_type = $context['view']->args[$group_type_key];	¶

Wrong indentation and trailing space.

+++ b/includes/actions/user_roles.action.incundefined
@@ -10,7 +10,28 @@ function og_user_roles_action_info() {
+    //$og_context = og_context();// This method did not work.
+	$og_context = $_SESSION['og_context'];

Well, we need to figure out why og_context() didn't work, instead of hacking it ;)

weekbeforenext’s picture

Okay, I think I fixed the spacing and indentation. Thanks for the tip!

I know it's a little hack, but I need to implement now so I want it to work until we can find a better fix :)

RoySegall’s picture

I made a total fix the patch: First the we check that the og context module is exists, if so we get the og type and og ID from the context. If not, check that we have the og type and og ID from the $context['view']->args.

@weekbeforenex, you include in comment #4 the patch with the white spaces. You should check that in the future that you posted the correct patch.

amitaibu’s picture

Status: Needs review » Needs work
+++ b/includes/actions/user_roles.action.incundefined
@@ -9,10 +9,26 @@ function og_user_roles_action_info() {
+  if (module_exists('og_context')) {
+    $og_context = og_context();

you should if (module_exists('og_context') && $og_context = og_context()) { in one line, or you will get a notice.

+++ b/includes/actions/user_roles.action.incundefined
@@ -9,10 +9,26 @@ function og_user_roles_action_info() {
+  if (empty($gid) || empty($group_type)) {

if => elseif

+++ b/includes/actions/user_roles.action.incundefined
@@ -9,10 +9,26 @@ function og_user_roles_action_info() {
+    if (!empty($group_type) && !empty($gid)) {

if it's empty, you can return here, no need for the same check below.

amitaibu’s picture

btw, this change should apply to all VBO actions

RoySegall’s picture

RoySegall’s picture

Status: Needs work » Needs review
amitaibu’s picture

Status: Needs review » Needs work
+++ b/includes/actions/user_roles.action.incundefined
@@ -9,11 +9,24 @@ function og_user_roles_action_info() {
+    if (!empty($group_type) && !empty($gid)) {
+      $gid = $gid;
+      $group_type = $group_type;
+    }
+    else {
+      return;

This looks strange...

RoySegall’s picture

Status: Needs work » Needs review
FileSize
1.02 KB
amitaibu’s picture

Status: Needs review » Fixed

Fixed else if => elseif and committed, thanks.

Status: Fixed » Closed (fixed)

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