generate-og-d7-content-update-7001.php in Organic groups 7.2
File
scripts/generate-og-d7-content-update-7001.php
View source
#!/usr/bin/env php
<?php
$cmd = 'index.php';
$_SERVER['HTTP_HOST'] = 'default';
$_SERVER['PHP_SELF'] = '/index.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_SOFTWARE'] = NULL;
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['QUERY_STRING'] = '';
$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
$_SERVER['HTTP_USER_AGENT'] = 'console';
$modules_to_enable = array(
'og',
'entity',
);
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_enable(array(
'og',
'entity',
));
drupal_cron_run();
$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;
}
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);
$node->{OG_GROUP_FIELD}[LANGUAGE_NONE][0]['created'] = 1000000000;
entity_save('node', $node);
$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);
}