Drupal Execute progrmatically

  1.  // Insert default user-defined node types into the database.
  2.   // For a complete list of available node type attributes, refer to the node
  3.   // type API documentation at:
  4.   // http://api.drupal.org/api/HEAD/function/hook_node_info
  5.   $types = array(
  6.     array(
  7.       'type' => 'page',
  8.       'name' => st('Page'),
  9.       'module' => 'node',
  10.       'description' => st('If you want to add a static page, like a contact page or an about page, use a page.'),
  11.       'custom' => TRUE,
  12.       'modified' => TRUE,
  13.       'locked' => FALSE,
  14.       'og_content_type_usage' => 'omitted',
  15.     ),
  16.     array(
  17.       'type' => 'story',
  18.       'name' => st('Story'),
  19.       'module' => 'node',
  20.       'description' => st('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'),
  21.       'custom' => TRUE,
  22.       'modified' => TRUE,
  23.       'locked' => FALSE,
  24.       'og_content_type_usage' => 'group_post_standard_mail',
  25.     ),
  26.     array(
  27.       'type' => 'school_community',
  28.       'name' => st('School Community'),
  29.       'module' => 'node',
  30.       'description' => st('This is a system community that is created for a specific school.'),
  31.       'custom' => TRUE,
  32.       'modified' => TRUE,
  33.       'locked' => TRUE,
  34.       'og_content_type_usage' => 'group',
  35.     ),
  36.     array(
  37.       'type' => 'user_community',
  38.       'name' => st('User Community'),
  39.       'module' => 'node',
  40.       'description' => st('A community that anyone can create.'),
  41.       'custom' => TRUE,
  42.       'modified' => TRUE,
  43.       'locked' => TRUE,
  44.       'og_content_type_usage' => 'group',
  45.     ),
  46.     array(
  47.       'type' => 'wiki_page_public',
  48.       'name' => st('Public Wiki Page'),
  49.       'module' => 'node',
  50.       'description' => st('A Public Wiki page that anyone can edit.'),
  51.       'custom' => TRUE,
  52.       'modified' => TRUE,
  53.       'locked' => TRUE,
  54.       'og_content_type_usage' => 'omitted',
  55.     ),
  56.     array(
  57.       'type' => 'wiki_page_private',
  58.       'name' => st('Private Wiki Page'),
  59.       'module' => 'node',
  60.       'description' => st('A Private Wiki page that only the group members in the group the page is posted to can view and/or edit it.'),
  61.       'custom' => TRUE,
  62.       'modified' => TRUE,
  63.       'locked' => TRUE,
  64.       'og_content_type_usage' => 'group_post_wiki_mail',
  65.     ),
  66.   );
  67.  
  68.   foreach ($types as $type) {
  69.     $type = (object) _node_type_set_defaults($type);
  70.     node_type_save($type);
  71.     if(isset($type->og_content_type_usage)) {
  72.       variable_set('og_content_type_usage_' . $type->type, $type->og_content_type_usage);
  73.     }
  74.   }
  75.  
  76.   // Default page to not be promoted and have comments disabled.
  77.   variable_set('node_options_page', array('status'));
  78.   variable_set('comment_page', COMMENT_NODE_DISABLED);