cms/drupal/profiles/drustack/drustack.install
changeset 541 e756a8c72c3d
equal deleted inserted replaced
540:07239de796bb 541:e756a8c72c3d
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * @file
       
     5  * Install, update and uninstall functions for the drustack installation profile.
       
     6  */
       
     7 
       
     8 /**
       
     9  * Implements hook_install().
       
    10  *
       
    11  * Perform actions to set up the site for this profile.
       
    12  */
       
    13 function drustack_install() {
       
    14   // We only execute once for initial installation.
       
    15   if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE !== 'install') {
       
    16     return;
       
    17   }
       
    18 
       
    19   // Enable the default theme.
       
    20   theme_enable(array('responsive_bartik', 'seven'));
       
    21   variable_set('theme_default', 'responsive_bartik');
       
    22   variable_set('admin_theme', 'seven');
       
    23 
       
    24   // Additional setting about themes.
       
    25   theme_disable(array('bartik', 'seven'));
       
    26   variable_set('node_admin_theme', '1');
       
    27 
       
    28   // Enable some standard blocks.
       
    29   $default_theme = variable_get('theme_default', 'bartik');
       
    30   $admin_theme = variable_get('admin_theme', 0);
       
    31   $blocks = array(
       
    32     array(
       
    33       'module' => 'system',
       
    34       'delta' => 'main',
       
    35       'theme' => $default_theme,
       
    36       'status' => 1,
       
    37       'weight' => 0,
       
    38       'region' => 'content',
       
    39       'pages' => '',
       
    40       'cache' => -1,
       
    41     ),
       
    42     array(
       
    43       'module' => 'search',
       
    44       'delta' => 'form',
       
    45       'theme' => $default_theme,
       
    46       'status' => 1,
       
    47       'weight' => -1,
       
    48       'region' => 'sidebar_first',
       
    49       'pages' => '',
       
    50       'cache' => -1,
       
    51     ),
       
    52     array(
       
    53       'module' => 'user',
       
    54       'delta' => 'login',
       
    55       'theme' => $default_theme,
       
    56       'status' => 1,
       
    57       'weight' => 0,
       
    58       'region' => 'sidebar_first',
       
    59       'pages' => '',
       
    60       'cache' => -1,
       
    61     ),
       
    62     array(
       
    63       'module' => 'system',
       
    64       'delta' => 'navigation',
       
    65       'theme' => $default_theme,
       
    66       'status' => 1,
       
    67       'weight' => 0,
       
    68       'region' => 'sidebar_first',
       
    69       'pages' => '',
       
    70       'cache' => -1,
       
    71     ),
       
    72     array(
       
    73       'module' => 'system',
       
    74       'delta' => 'powered-by',
       
    75       'theme' => $default_theme,
       
    76       'status' => 1,
       
    77       'weight' => 10,
       
    78       'region' => 'footer',
       
    79       'pages' => '',
       
    80       'cache' => -1,
       
    81     ),
       
    82     array(
       
    83       'module' => 'system',
       
    84       'delta' => 'help',
       
    85       'theme' => $default_theme,
       
    86       'status' => 1,
       
    87       'weight' => 0,
       
    88       'region' => 'help',
       
    89       'pages' => '',
       
    90       'cache' => -1,
       
    91     ),
       
    92     array(
       
    93       'module' => 'system',
       
    94       'delta' => 'main',
       
    95       'theme' => $admin_theme,
       
    96       'status' => 1,
       
    97       'weight' => 0,
       
    98       'region' => 'content',
       
    99       'pages' => '',
       
   100       'cache' => -1,
       
   101     ),
       
   102     array(
       
   103       'module' => 'system',
       
   104       'delta' => 'help',
       
   105       'theme' => $admin_theme,
       
   106       'status' => 1,
       
   107       'weight' => 0,
       
   108       'region' => 'help',
       
   109       'pages' => '',
       
   110       'cache' => -1,
       
   111     ),
       
   112   );
       
   113 
       
   114   db_update('block')
       
   115     ->fields(array(
       
   116       'status' => 0,
       
   117     ))
       
   118     ->condition('theme', $admin_theme)
       
   119     ->execute();
       
   120   foreach ($blocks as $block) {
       
   121     db_merge('block')
       
   122       ->key(array(
       
   123         'module' => $block['module'],
       
   124         'delta' => $block['delta'],
       
   125         'theme' => $block['theme'],
       
   126       ))
       
   127       ->fields(array(
       
   128         'status' => $block['status'],
       
   129         'weight' => $block['weight'],
       
   130         'region' => $block['region'],
       
   131         'pages' => $block['pages'],
       
   132         'cache' => $block['cache'],
       
   133       ))
       
   134       ->execute();
       
   135   }
       
   136 
       
   137   // Allow visitor account creation, but with administrative approval.
       
   138   variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
       
   139 
       
   140   // Enable default permissions for system roles.
       
   141   user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
       
   142   user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
       
   143 
       
   144   // Create a Home link in the main menu.
       
   145   $item = array(
       
   146     'link_title' => st('Home'),
       
   147     'link_path' => '<front>',
       
   148     'menu_name' => 'main-menu',
       
   149   );
       
   150   menu_link_save($item);
       
   151 
       
   152   // Update the menu router information.
       
   153   menu_rebuild();
       
   154 }
       
   155 
       
   156 /**
       
   157  * Update with new drustack core structure + mobile ready admin.
       
   158  */
       
   159 function drustack_update_7000() {
       
   160   // Enable the admin theme and responsive Bartik theme.
       
   161   theme_enable(array('responsive_bartik', 'ember'));
       
   162   variable_set('admin_theme', 'seven');
       
   163   variable_set('node_admin_theme', '1');
       
   164 
       
   165   // Enable/disable with some new modules.
       
   166   module_disable(array(
       
   167     'toolbar',
       
   168     'overlay',
       
   169   ));
       
   170   module_enable(array(
       
   171     'drustack_core',
       
   172     'navbar',
       
   173   ));
       
   174 
       
   175   // Rebuild node access database.
       
   176   node_access_rebuild();
       
   177 
       
   178   // Rebuild node types.
       
   179   node_types_rebuild();
       
   180 
       
   181   // Rebuild the menu.
       
   182   menu_rebuild();
       
   183 
       
   184   // Clear drupal message queue for non-warning/errors.
       
   185   drupal_get_messages('status', TRUE);
       
   186 
       
   187   // Clear out caches.
       
   188   drupal_flush_all_caches();
       
   189 
       
   190   // Clear out JS and CSS caches.
       
   191   drupal_clear_css_cache();
       
   192   drupal_clear_js_cache();
       
   193 }