You are here

function og_devel_generate in Organic groups 6

Same name and namespace in other branches
  1. 6.2 og.module \og_devel_generate()
  2. 7 og.devel_generate.inc \og_devel_generate()
1 call to og_devel_generate()
og_presave_group in ./og.module

File

./og.module, line 1504

Code

function og_devel_generate(&$node) {
  if (og_is_group_type($node->type)) {

    // Don't let anon own a group. They can edit all group nodes, and more. Could potentially be fixed by devel respecting
    // content type create permissions.
    if ($node->uid == 0) {
      $node->uid = 1;
    }
    $node->og_selective = rand(0, 3);
    $can_join = $node->og_selective <= OG_MODERATED;
    $open_join = $node->og_selective < OG_MODERATED;
    $node->og_register = $can_join ? rand(0, 1) : FALSE;
    $node->og_directory = $can_join ? rand(0, 1) : FALSE;
    $node->og_private = !$open_join ? rand(0, 1) : FALSE;

    // Ignored if og_access not installed.
    $node->og_description = devel_create_greeking(rand(1, 20), TRUE);
    $node->og_notification = rand(0, 1);
    $node->og_language = NULL;
    if (module_exists('locale') && ($languages = locale_language_list())) {
      if (count($languages) > 1) {
        $node->og_language = array_rand($languages);
      }
    }
  }
  elseif (og_is_group_post_type($node->type)) {
    $types = og_get_types('group');
    $placeholders = db_placeholders($types, 'varchar');
    $sql = "SELECT nid FROM {node} WHERE type IN ({$placeholders}) AND status = 1 ORDER BY RAND()";
    $result = db_query_range($sql, $types, 0, rand(1, 4));
    while ($row = db_fetch_object($result)) {
      $node->og_groups[] = $row->nid;
    }
    $node->og_public = rand(0, 1);

    // Ignored if og_access not installed.
  }
}