$_SERVER['HTTP_USER_AGENT'] = 'console'; $modules_to_enable = array('og', 'entity'); // Bootstrap Drupal. include_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); module_enable(array('og', 'entity')); // Run cron after installing drupal_cron_run(); // Create users with ID 2 to 5. $uids = array(); foreach (range(2, 5) as $i) { $values = array('name' => 'og_test_user' . $i, 'mail' => 'og_test_user' . $i . '@example.com', 'pass' => user_password(5), 'status' => 1); $account = entity_create('user', $values); entity_save('user', $account); $uids[] = $account; } // Create a group node. og_create_field(OG_GROUP_FIELD, 'node', 'article'); $values = array('uid' => $uids[0]->uid, 'type' => 'article', 'title' => 'Group node'); $node = entity_create('node', $values); $node->{OG_GROUP_FIELD}[LANGUAGE_NONE][0]['value'] = 1; entity_save('node', $node); // Explicetly set the created timestamp. $node->{OG_GROUP_FIELD}[LANGUAGE_NONE][0]['created'] = 1000000000; entity_save('node', $node); // Assign users to group. $group = og_get_group('node', $node->nid); $items = array(1 => OG_STATE_ACTIVE, 2 => OG_STATE_PENDING, 3 => OG_STATE_BLOCKED); foreach ($items as $key => $state) { og_group($group->gid, 'user', $uids[$key], $state); }
function filedepot_og_get_group_entity($grpid) { if (function_exists('og_get_group')) { $entity = og_get_group('group', $grpid); $entity->title = $entity->label; } else { $entity = node_load($grpid); } return $entity; }