Closed (fixed)
Project:
Spaces
Version:
6.x-3.2
Component:
Code
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Dec 2011 at 19:41 UTC
Updated:
8 Dec 2011 at 10:04 UTC
I am trying to do a couple of adjustments to an organic group using the following (simplified) code:
$groupnode = node_load($groupnid);
$groupnode->title = $mytitle;
$groupnode->og_selective = $mynewlevel;
node_save($groupnode);
The title gets saved ok, but the og_selective value first gets saved, then gets re-saved with a default value by spaces_og, thus reverting my changes! The responsible code seems to be this snippet from spaces_og_nodeapi():
case 'update':
$space = spaces_load('og', $node->nid, TRUE);
if ($space) {
// Save preset values.
if (!empty($node->spaces_preset_og)) {
$space->controllers->variable->set('spaces_preset_og', $node->spaces_preset_og);
}
// Configure OG directly from space object as node_save() may be
// called from outside of actual group space.
$selective = $space->controllers->variable->get('spaces_og_selective');
$node->og_selective = $selective === NULL ? OG_OPEN : $selective;
$register = $space->controllers->variable->get('spaces_og_register');
$node->og_register = $register === NULL ? TRUE : $register;
$directory = $space->controllers->variable->get('spaces_og_directory');
$node->og_directory = $directory === NULL ? TRUE : $directory;
$private = $space->controllers->variable->get('spaces_og_private');
if ($op == 'update' && $private != $node->og_private) {
// Privacy has changed, update og_public flags, and queue a rebuid.
db_query("UPDATE {og_access_post} og_p
INNER JOIN {og_ancestry} og_a ON og_p.nid = og_a.nid
INNER JOIN {node} n ON og_p.nid = n.nid
SET og_public = %d WHERE og_a.group_nid = %d",
!$private, $node->nid);
node_access_needs_rebuild(TRUE);
}
$node->og_private = $private === NULL ? FALSE : $private;
og_update_group($node);
}
Am I doing something I am not supposed to be doing? As far as I can tell from the code above, it will always overwrite the values set for the node.
Comments
Comment #1
Grayside commentedSpaces OG takes over OG values like selective. Based on the current hook_nodeapi() implementation, all you can do is fork the code. In theory, this is expected, indeed, desired functionality in Spaces OG.
I've been pushing for Spaces 4.x to separate out OG integration from some of the use case enforcement we see here. See #1203046: Spaces 7.x-4.x Architecture
I'm marking this Works as Designed, because every Spaces maintainer I've ever dealt with has not been willing to address this issue without it being part of a major new version of the project.
Comment #2
fuzzy76 commentedSo with spaces_og there is no way to change the group behaviour in already created groups?
Comment #3
fuzzy76 commentedFor others arriving here, the way I got this working was changing the spaces preset for the group before saving. Like so: