/[drupal]/contributions/profiles/hostmaster/hostmaster.forms.inc
ViewVC logotype

Contents of /contributions/profiles/hostmaster/hostmaster.forms.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Fri Oct 23 09:29:02 2009 UTC (5 weeks, 1 day ago) by adrian
Branch: MAIN
Changes since 1.10: +3 -4 lines
File MIME type: text/x-php
#611976 - change default blocks in hostmaster
1 <?php
2 // $Id: hostmaster.forms.inc,v 1.10 2009/10/01 15:56:45 mig5 Exp $
3
4 function hostmaster_task_intro($current) {
5 drupal_set_title(t("Welcome to the Aegir hosting system."));
6
7 $form['introduction']['#value'] =
8 t("<p>I am a configuration wizard designed to help you through configuring the Aegir provisioning system.</p>
9 <p>Once properly configured, this system will help you manage your Drupal sites.
10 It will even be able to manage them across multiple versions of Drupal and across multiple servers.</p>
11 <p>Before we get started with the configuration, please make sure that your system meets the following requirements:</p>");
12 $form['drupal'] = hostmaster_requirement_help('basic_drupal');
13 $form['unix'] = hostmaster_requirement_help('basic_unix');
14 $form['server'] = hostmaster_requirement_help('basic_server');
15
16 return hostmaster_form($form, $current);
17 }
18
19 //====================================================================
20 //====================================================================
21 //====================================================================
22
23 /**
24 * Configures web_server_node_form minus almost all the forms.
25 */
26 function hostmaster_task_webserver() {
27
28 drupal_set_title(st("Configure your web server"));
29 $form = node_form($form_state, node_load(HOSTING_OWN_WEB_SERVER));
30
31 _hostmaster_clean_node_form($form);
32
33 $own_link = _hosting_node_link(HOSTING_OWN_WEB_SERVER);
34
35 $form['title']['#type'] = 'value';
36 $form['ip_address']['#type'] = 'value';
37 $form['backup_path']['#type'] = 'value';
38 $form['config_path']['#type'] = 'value';
39 $form['drush_path']['#type'] = 'value';
40 $form['drush_path']['#required'] = FALSE;
41
42 $form['user_help'] = hostmaster_requirement_help('user', array(
43 '#weight' => 0,
44 '#summary' => HOSTING_HELP_ENABLED,
45 '#configuration' => HOSTING_HELP_COLLAPSED
46 ));
47 $form['script_user']['#weight'] = 1;
48
49
50 $form['group_help'] = hostmaster_requirement_help('group', array(
51 '#weight' => 10,
52 '#summary' => HOSTING_HELP_ENABLED,
53 '#configuration' => HOSTING_HELP_COLLAPSED
54 ));
55 $form['web_group']['#weight'] = 11;
56
57 $form['restart_cmd_help'] = hostmaster_requirement_help('visudo', array(
58 '#weight' => 19,
59 '#summary' => HOSTING_HELP_ENABLED,
60 '#configuration' => HOSTING_HELP_COLLAPSED
61 ));
62 $form['restart_cmd']['#weight'] = 20;
63 // remove all the things i don't want from the node form.
64 return hostmaster_form($form);
65 }
66
67 //====================================================================
68 //====================================================================
69 //====================================================================
70
71
72 /**
73 * Configures web_server_node_form paths.
74 *
75 * @todo pull changes in the form upstream
76 */
77 function hostmaster_task_filesystem() {
78 drupal_set_title(st("Configure where to store your data"));
79 /* TODO drupal_retrieve_form() now accepts a form_state parameter. */
80 $form = node_form($form_state, node_load(HOSTING_OWN_WEB_SERVER));
81 _hostmaster_clean_node_form($form);
82
83 $own_link = _hosting_node_link(HOSTING_OWN_WEB_SERVER);
84
85 $form['ports']['#type'] = 'value';
86 $form['script_user']['#type'] = 'value';
87 $form['web_group']['#type'] = 'value';
88
89 $form['title']['#type'] = 'value';
90 $form['ip_address']['#type'] = 'value';
91 $form['restart_cmd']['#type'] = 'value';
92
93 // drush path field
94 $form['drush_path_help'] = hostmaster_requirement_help('drush_path', array(
95 '#weight' => 4,
96 '#summary' => HOSTING_HELP_ENABLED,
97 '#configuration' => HOSTING_HELP_DISABLED
98 ));
99 $form['drush_path']['#weight'] = 5;
100
101 // config path field
102 $form['config_path_help'] = hostmaster_requirement_help('config_path', array(
103 '#weight' => 9,
104 '#summary' => HOSTING_HELP_ENABLED,
105 '#configuration' => HOSTING_HELP_COLLAPSED
106 ));
107 $form['config_path']['#weight'] = 10;
108
109 // backup path field
110 $form['backup_path_help'] = hostmaster_requirement_help('backup_path', array(
111 '#weight' => 14,
112 '#summary' => HOSTING_HELP_ENABLED,
113 '#configuration' => HOSTING_HELP_COLLAPSED
114 ));
115 $form['backup_path']['#weight'] = 15;
116
117 // httpd.conf description
118 $form['httpd_conf'] = hostmaster_requirement_help('httpd_conf', array(
119 '#weight' => 20,
120 '#summary' => HOSTING_HELP_ENABLED,
121 '#configuration' => HOSTING_HELP_ENABLED,
122 ));
123
124
125 // remove all the things i don't want from the node form.
126 return hostmaster_form($form);
127 }
128
129 //====================================================================
130 //====================================================================
131 //====================================================================
132
133
134 /**
135 * Database configuration form
136 *
137 * Inherits the db_server_node_form, and shifts some things around.
138 * Perhaps those changes need to go in upstream?
139 */
140 function hostmaster_task_dbserver() {
141 drupal_set_title(st('Configure your database server'));
142 /* TODO drupal_retrieve_form() now accepts a form_state parameter. */
143 $form = node_form($form_state, node_load(HOSTING_OWN_DB_SERVER));
144 _hostmaster_clean_node_form($form);
145
146 $own_link = _hosting_node_link(HOSTING_OWN_DB_SERVER);
147
148 $form['introduction']['#weight'] = -9;
149 $form['introduction']['#value'] =
150 t('<p>You need at least one fully functional database server to be able to manage sites.
151 Luckily, if you can read this, you are already most of the way there.</p>
152 <p> <strong>If the user you specified when first configuring the Drupal can create databases, you probably do not need to change anything here. Otherwise, create an "aegir_root" superuser per the example offered below.</strong></p>
153 <p>This configuration form is actually the !edit_page for the !own_server database server node.
154 It has however been heavily annotated and slightly simplified for this installation wizard. And while
155 the wizard can be run multiple times, it won\'t be able to edit any database servers other than the database
156 this site is running on.</p>',
157 array('!own_server' => $own_link, '!edit_page' => l(t("edit page"), 'node/' . HOSTING_OWN_DB_SERVER . '/edit' )));
158
159
160 $form['title']['#type'] = 'value';
161
162 $form['db_details'] = array(
163 '#type' => 'fieldset',
164 '#collapsed' => false,
165 '#title' => t('Database account details'),
166 );
167 $form['db_details']['help'] = hostmaster_requirement_help('mysql_user', array('#configuration' => HOSTING_HELP_COLLAPSED, '#summary' => HOSTING_HELP_COLLAPSED));
168
169 $form['db_details']['db_user'] = $form['db_user'];
170 unset($form['db_user']);
171 $form['db_details']['db_passwd'] = $form['db_passwd'];
172 unset($form['db_passwd']);
173
174 return hostmaster_form($form);
175 }
176
177
178 //====================================================================
179 //====================================================================
180 //====================================================================
181
182 function hostmaster_task_features() {
183 drupal_set_title(st('Enable hosting features'));
184 $form = drupal_retrieve_form('hosting_features_form', $form_state);
185 unset($form['buttons']);
186 return hostmaster_form($form);
187 }
188
189 function hostmaster_task_features_submit($form, &$form_state) {
190 hosting_features_form_submit($form_state['values']['form_id'], $values);
191 }
192
193 //====================================================================
194 //====================================================================
195 //====================================================================
196
197
198 /**
199 * Form that confirms that cron is running, and that the platform has been successfuly verified
200 *
201 * This page is essentially one huge page of contextual help, to ensure that everything is up and running.
202 */
203 function hostmaster_task_init() {
204 drupal_set_title(st('Initialize the hosting system'));
205 // @ TODO: make this coherent, and add error reporting about what went wrong, and how it needs to be fixed.
206 $form = array();
207 $form['intro']['#value'] = t('<p>The hosting framework provides the user interface used to administer your sites.
208 All components of the managed sites from the database and web servers, to the packages installed
209 on them, to the sites themselves are represented by the hosting framework as nodes.
210 This step is going to ensure that it is correctly initialized.</p>');
211
212 $options = array('#configuration' => HOSTING_HELP_COLLAPSIBLE);
213
214 if (!variable_get('hosting_dispatch_enabled', FALSE)) {
215 $options['#status'] = HOSTING_STATUS_WARNING;
216 $options['#message'] = t('Please follow the configuration help below to initialize the system.');
217 }
218 elseif (!variable_get('hosting_dispatch_last_run', false)) {
219 $options['#status'] = HOSTING_STATUS_ERROR;
220 $options['#message'] = t('The dispatch process has not been run. Please follow the instructions below.');
221 }
222 else {
223 $options['#status'] = HOSTING_STATUS_SUCCESS;
224 $options['#message'] = t('The dispatch process has been successfully executed');
225 }
226
227 $form['cron'] = hostmaster_requirement_help('hosting_setup', $options);
228 return hostmaster_form($form);
229 }
230
231 function hostmaster_task_init_validate($form, &$form_state) {
232 if (!variable_get('hosting_dispatch_last_run', false)) {
233 form_set_error("submit");
234 }
235 }
236
237 //====================================================================
238 //====================================================================
239 //====================================================================
240
241
242
243 function hostmaster_task_verify() {
244 drupal_set_title(st('Verify your configuration'));
245 $form = array();
246 $node = hosting_get_most_recent_task(HOSTING_OWN_PLATFORM, 'verify');
247 $form['provision'] = array('#type' => 'requirement_help', '#requirement' => 'platform');
248 if ($node->task_status == HOSTING_TASK_SUCCESS) {
249 $form['provision']['#status'] = HOSTING_STATUS_SUCCESS;
250 $form['provision']['#message'] = t('Your platform has been successfully configured. You can now create sites.');
251
252 $form['import']['#value'] = t('On the next page we will import any existing sites on this platform.');
253 }
254 else {
255 $form['provision']['#status'] = HOSTING_STATUS_ERROR;
256 $form['provision']['#message'] = t('One or more errors have occurred during platform verification.');
257 $form['retry_id'] = array('#type' => 'hidden', '#value' => $node->nid);
258 $form['log_tip']['#value'] = t('Underneath is the log output and status of your verification task.
259 Check your settings on the previous pages of the wizard, and follow the applicable examples from the configuration
260 tips.');
261 $view = hosting_task_view($node);
262 $form['task_status'] = $view->content['status'];
263 $form['task_status']['#title'] = t('Errors');
264 $form['last_attempt'] = array('#type' => 'item', '#title' => t('Last attempt'), '#value' => hosting_format_interval($node->changed));
265 $form['log'] = $view->content['hosting_log'];
266 $next = t('Check again');
267 }
268 return hostmaster_form($form, $next);
269 }
270
271 function hostmaster_task_verify_validate($form, &$form_state) {
272 $node = hosting_get_most_recent_task(HOSTING_OWN_PLATFORM, 'verify');
273 if (!($node->task_status == HOSTING_TASK_SUCCESS)) {
274 form_set_error("submit");
275 }
276 }
277
278 //====================================================================
279 //====================================================================
280 //====================================================================
281
282
283 function hostmaster_task_import() {
284 drupal_set_title(st('Import your existing sites'));
285 $form = array();
286
287 $sites = hosting_get_sites_by_status(HOSTING_OWN_PLATFORM, HOSTING_SITE_IMPORTED);
288 if ($list = hosting_site_list('platform', HOSTING_OWN_PLATFORM)) {
289 $form['intro']['#value'] = t('<p>Below is a list of sites which were imported into the Hosting framework. Each of these pre-existing sites have had an import task created for them, and will be imported by the task queue.</p>');
290 $form['list']['#value'] = $list;
291 }
292 else {
293 $form['intro']['#value'] = t('<p>Hosting has not found any sites to import.</p>')
294 . t('<p>In the future, any additional platforms you create will also automatically have existing sites imported, and at any time you can request an verify task on any existing platform to find and import any sites that may have been added manually.</p>');
295 }
296 return hostmaster_form($form);
297 }
298
299 function hostmaster_task_import_submit() {
300 drupal_set_message(conf_path() , conf_path());
301 }
302
303 function hostmaster_task_finalize() {
304 variable_set('install_profile', 'hostmaster');
305 drupal_set_title(st("Configuring roles, blocks and theme"));
306
307 // enable the eldir theme, if present
308 $themes = system_theme_data();
309 if ($themes['eldir'] || file_exists("profiles/hostmaster/themes/eldir/eldir.info")) {
310 drupal_set_message(st("Enabling optional Eldir theme"));
311 install_disable_theme('garland');
312 install_default_theme('eldir');
313 $theme = 'eldir';
314 } else {
315 $theme = 'garland';
316 drupal_set_message(st("Could not find optional Eldir theme"));
317 }
318 // not sure this is necessary
319 system_theme_data();
320 db_query("DELETE FROM {cache}");
321
322 drupal_set_message(st('Adding default blocks'));
323 install_add_block('hosting', 'hosting_queues', $theme, 1, 5, 'right', 1);
324 install_add_block('hosting', 'hosting_summary', $theme, 1, 10, 'right', 1);
325
326 drupal_set_message(st('Setting up roles'));
327 install_add_permissions(install_get_rid('anonymous user'), array('access content', 'access all views'));
328 install_add_permissions(install_get_rid('authenticated user'), array('access content', 'access all views'));
329 install_add_role('aegir client');
330 // @todo we may need to have a hook here to consider plugins
331 install_add_permissions(install_get_rid('aegir client'), array('access content', 'access all views', 'edit own client', 'view client', 'create site', 'delete site', 'view site', 'create backup task', 'create delete task', 'create disable task', 'create enable task', 'create restore task', 'view own tasks', 'view task'));
332 install_add_role('aegir account manager');
333 install_add_permissions(install_get_rid('aegir account manager'), array('create client', 'edit client users', 'view client'));
334
335 drupal_set_message(st('Enabling optional, yet recommended modules'));
336 hostmaster_setup_optional_modules();
337
338 node_access_rebuild();
339
340 variable_set('install_profile_task', 'profile-finished');
341 return hostmaster_form(array());
342 }

  ViewVC Help
Powered by ViewVC 1.1.2