'provision-status-none', PROVISION_STATUS_SUCCESS => 'provision-status-success', PROVISION_STATUS_WARNING => 'provision-status-warning', PROVISION_STATUS_ERROR => 'provision-status-error', ); } return $map[$status]; } /** * Constants used to configure contextual hosting help */ /** Display component of help **/ define('PROVISION_HELP_ENABLED', 1); /** Don't show help component **/ define('PROVISION_HELP_DISABLED', ~PROVISION_HELP_ENABLED); /** These are internally used to test against. Use the COLLAPSIBLE AND COLLAPSED instead **/ define('_PROVISION_HELP_CAN_COLLAPSE', 2); define('_PROVISION_HELP_HAS_COLLAPSED', 4); /** * Show help with the ability to collapse to save space. * This automatically enables the help component **/ define('PROVISION_HELP_COLLAPSIBLE', PROVISION_HELP_ENABLED | _PROVISION_HELP_CAN_COLLAPSE); /** * Display help component with an initial collapsed state. * This automatically enables and sets the help component to be collapsible */ define('PROVISION_HELP_COLLAPSED', PROVISION_HELP_COLLAPSIBLE | _PROVISION_HELP_HAS_COLLAPSED); /** * Returns a class name for the output of the form elementG */ function _provision_help_class($state) { static $map; if (!sizeof($map)) { $map = array( PROVISION_HELP_ENABLED => 'provision-help', PROVISION_HELP_COLLAPSIBLE => 'provision-help-collapsible', PROVISION_HELP_COLLAPSED => 'provision-help-collapsed' ); } return $map[$state]; } /** * Implementation of hook_help() */ function provision_help($section) { switch ($section) { case 'admin/help#provision': $output .= t('

The Provision framework is a powerful set of modules that lets you to accomplish a lot of maintenance tasks through the unix command line such as installing new sites, backing them up, rolling back to previous backups and facilitating upgrades.

'); $output .= t('

Additionally, the Provision framework is one component of the distributed hosting infrastructure provided by the hostmaster install profile. The Hostmaster profile is capable of driving several provision backends, in a distributed manner, and provides an interface for the functionality of provision.

'); $output .= t('

It is not required to run the hosting front end to use the Provision framework, but the system does not provide much in the way of a web accessible front end, by design.

'); $output .= '

' . t('Requirements') . '

'; $output .= t('

For a more detailed breakdown of steps that need to be taken to configure Provisioning to run with your system, please read the in depth requirement documentation

', array('@url' => url('admin/help/provision/requirements'))); $output .= '

' . t('Commands') . '

'; $commands = module_invoke_all('drush_command'); $output .= "
"; foreach ($commands as $command => $info) { if (preg_match('/^provision/', $command)) { if (sizeof($info['arguments'])) { $command .= ' ' . implode(' ', (array) key($info['arguments'])); } if (sizeof($info['optional arguments'])) { $command .= ' [' . implode('] [', (array) key($info['optional arguments'])) . ']'; } $output .= '
' . "drush.php $command" . '
'; $output .= '
' . $info["description"] . '
'; } } $output .= "
"; $output .= '

' . t('Options') . '

'; $options = module_invoke_all('value_list'); $output .= "
"; foreach ($options as $option => $description) { $output .= '
' . "--$option" . '
'; $output .= '
' . $description . '
'; } $output .= "
"; return $output; case 'admin/help/provision#requirements' : $output .= _provision_requirements('group'); $output .= _provision_requirements('backup_path'); return $output; } } /** * Page callback with in depth requirement documentation */ function provision_help_requirements() { $output .= _provision_requirements("basic_drupal"); $output .= _provision_requirements("basic_unix"); $output .= _provision_requirements("basic_server"); $modules = module_implements('provision_service'); foreach ($modules as $module) { $service = module_invoke($module, 'provision_service'); $name = current($service); $help = module_invoke($module, 'help', 'admin/help/provision#requirements'); if ($name && $help) { $output .= "

" . t($name) . '

'; $output .= $help; } } return $output; } /** * Helper function for displaying contextual help when not used in a form. */ function _provision_requirements($req, $section = 'all') { $item = _element_info('requirement_help'); $item['#requirement'] = $req; $item['#type'] = 'requirement_help'; /* foreach (array('#heading', '#summary', '#suggestion', '#configuration') as $key) { if (in_array($section, array('all', $key))) { $item['#' . $key] = PROVISION_HELP_ENABLED; } elseif ($section != 'all') { $item['#' . $key] = ($section == $key) ? PROVISION_HELP_ENABLED : PROVISION_HELP_DISABLED; } } */ $item = provision_requirement_process($item); return theme("requirement_help", $item); } function provision_get_requirement($req) { $func = '_provision_' . $req . '_requirements'; if (function_exists($func)) { $help = $func(); } return $help; } function _provision_backup_path_requirements() { $username = PROVISION_SCRIPT_USER; $group = PROVISION_WEB_GROUP; $backup_path = PROVISION_BACKUP_PATH; $mkdir_cmd['@backup_path'] = $backup_path; $mkdir_cmd['@provision_link'] = url('admin/settings/provision'); $mkdir_cmd['@mkdir_cmd'] = <<@backup_path, but you can change this in the provisioning section.', $mkdir_cmd); $help['configuration'] = t('Please enter the following commands :
@mkdir_cmd
', $mkdir_cmd); return $help; } function _provision_group_requirements() { $username = PROVISION_SCRIPT_USER; $group = PROVISION_WEB_GROUP; $vigr_cmd = <<@username" and the group to "@group", but you can change these in the provisioning section.', array("@username" => $username, "@group" => $group, "@provision_link" => url('admin/settings/provision'))); $help['configuration'] =t('If your user is not a member of the web group, you can add them by using the vigr command:
@vigr_cmd
Once you have run the vigr command, find the line that says :
@vigr1
Then add the username to the end of the line, so that it looks like :
@vigr2
If there were already users in the group, add your user to the group using a comma as separator :
@vigr3
', array('@vigr_cmd' => $vigr_cmd, '@vigr1' => $vigr1, '@vigr2' => $vigr2, '@vigr3' => $vigr3)); return $help; } /** * Implementation of hook_elements. * * Defines a number of form elements that are used for formatting the contextual help * in forms. */ function provision_elements() { $type['requirement_help'] = array( '#requirement' => null, '#status' => PROVISION_STATUS_NONE, '#heading' => PROVISION_HELP_ENABLED, '#summary' => PROVISION_HELP_ENABLED, '#summary_prefix' => t("What is this?"), '#configuration' => PROVISION_HELP_COLLAPSED, '#configuration_prefix' => t("How do I configure this?"), '#default_messages' => array( PROVISION_STATUS_SUCCESS => t("You have met this requirement."), PROVISION_STATUS_WARNING => t("This requirement has a non critical error."), PROVISION_STATUS_ERROR => t("This requirement has a critical error. This system will not operate until it has been fixed")), '#process' => array('provision_requirement_process' => array()), ); return $type; } /** * Places the various help components info the $element array */ function provision_requirement_process(&$element) { if (!$element['#requirement']) { return element; } $element['#help'] = provision_get_requirement($element['#requirement']); return $element; } /** * Theme function for displaying contextual help. * * Can control individual components of the help, for display in various places. */ function theme_requirement_help(&$element) { drupal_add_js(drupal_get_path('module', 'provision') . '/provision.js'); drupal_add_css(drupal_get_path('module', 'provision') . '/provision.css'); $req = $element['#requirement']; $help = $element['#help']; // this is just to make it easier to work with. //place anchor so user can be directed to right page. $output .= ""; $output .= '
'; if ($element['#status'] != PROVISION_STATUS_NONE) { $output .= "
" . (($element['#message']) ? $element['#message'] : $element['#default_messages'][$element['#status']]) . "
"; } $components = array('summary', 'suggestion', 'configuration'); foreach ($components as $key) { if (($element["#$key"] & PROVISION_HELP_ENABLED) && !is_null($help[$key])) { $display_type = _provision_help_class($element["#$key"]); $output .= "
"; if (!is_array($help[$key])) { // it is simpler if there's only one way to print the component $help[$key] = array($help[$key]); } if ($element["#$key" . '_prefix'] && ($element["#$key"] & _PROVISION_HELP_CAN_COLLAPSE)) { $output .= '' . $element["#$key" . '_prefix'] . ''; } $output .= "

" . implode("

", $help[$key]) . "

"; $output .= '
'; } } $output .= '
'; if (($element['#heading'] & PROVISION_HELP_ENABLED) && $help['title'] && !$element['#title']) { $element['#title'] = $help['title']; } $element['#value'] = $output; return theme('item', $element); } /** * @TODO: handle element children for requirement help function _provision_basic_requirements() { $help['drupal'] = _provision_basic_drupal_requirements(); $help['unix'] = _provision_basic_unix_requirements(); $help['server'] = _provision_basic_server_requirements(); return $help; } */ function _provision_basic_drupal_requirements() { $help['title'] = t('A system capable of running Drupal'); $help['summary'] = t('If you are reading this via the inline help, this would be kind of obvious. This system is entirely Drupal based, and has the same base requirements that Drupal does.'); return $help; } function _provision_basic_server_requirements() { $help['title'] = t('Your own server'); $help['summary'] = t('The level of access required to be able to configure this system is very far beyond what is commonly available to users with shared hosting.'); return $help; } function _provision_basic_unix_requirements() { $help['title'] = t('A unix based operating system'); $help['summary'] = t('The majority of functionality in this system occurs in the back-end, through system level programming. There are several features (such as symlinks), that are not available to users on Windows. There are no plans currently to add windows support.

'); return $help; }