Compare commits

..

6 Commits

3 changed files with 63 additions and 34 deletions

View File

@ -1,6 +1,8 @@
Adds a panel to quick-install certain CMSs in AlternC. This module provides support for WordPress and Drupal.
Adds a panel to quick-install certain CMSs in AlternC. This module provides
support for WordPress and Drupal.
Support for other CMSs may be added by other AlternC plugins. See "Extending" for more information.
Support for other CMSs may be added by other AlternC plugins. See "Extending"
for more information.
# Installation
@ -12,34 +14,43 @@ For [Drupal][2]: Install [Drush](https://github.com/drush-ops/drush/ "Drush on G
## Manual Install
`
```
make install
`
```
If AlternC is installed in another directory, use something like: `
ALTERNC_BASE_PATH=/your/path/alternc make install
`
If AlternC is installed in another directory, use something like:
`ALTERNC_BASE_PATH=/your/path/alternc/panel/ make install`
# Configuration
Once installed, add the Drush or WP-CLI paths to /etc/alternc/locals.sh. These need to be accessible within the basedir restrictions of the AlternC panel.
Once installed, add the Drush or WP-CLI paths to /etc/alternc/locals.sh. These
need to be accessible within the basedir restrictions of the AlternC panel.
Example: `
```
ALTERNC_DRUSH_BIN=/usr/local/bin/drush
ALTERNC_WPCLI_BIN=/usr/local/bin/wp
`
If they are not configured, the links for installation will be disabled. If no CMSs are configured, the quick links menu item will not be displayed.
# Option to limit the One-Click Installer menu to users who have 'su' on their
# account. Set to 1 to enable that restriction. Default is 0 (no restriction).
OCI_REQUIRE_SU=0
```
If they are not configured, the links for installation will be disabled. If no
CMSs are configured, the quick links menu item will not be displayed.
# Extending
A number of hooks are available to modify the install form and run the actual install. Drupal and WordPress are implemented as examples that could done in another module easily.
A number of hooks are available to modify the install form and run the actual
install. Drupal and WordPress are implemented as examples that could done in
another module easily.
# Roadmap
This module is basically at a 'proof of concept' point. For a first proper release, the following should probably be added:
This module is basically at a 'proof of concept' point. For a first proper
release, the following should probably be added:
* make sure form content and variables are properly escaped when passed between scripts
* make sure form content and variables are properly escaped when passed between
scripts
* user interface / form cleanup
* hide form elements based on choices
* sub-domain list changing based on chosen domain
@ -49,10 +60,15 @@ This module is basically at a 'proof of concept' point. For a first proper relea
Nice to haves:
* threaded install script so user feedback doesn't have to wait X minutes until the shell scripts finish
* threaded install script so user feedback doesn't have to wait X minutes until
the shell scripts finish
# Copyright & License
2018 Kienan Stewart <kienan@koumbit.org>
Licensed under the GNU General Public License version 2.0 or later. See LICENSE for the full license text.
Licensed under the GNU General Public License version 2.0 or later. See LICENSE
for the full license text.
[1]: https://wordpress.org/
[2]: https://drupal.org/

View File

@ -59,7 +59,7 @@ if (!$oci->app_is_installable($application)) {
}
// @TODO validations
$errors = $oci->oci_form_validate($oci_vars);
$errors = $oci->oci_form_validate($application, $oci_vars);
if (!empty($errors)) {
print('<div class="validation-wrapper">');
print('<h3>' . _('Validation Errors') . '</h3>');

View File

@ -21,7 +21,12 @@
class m_oci {
function hook_menu() {
global $hooks, $L_ALTERNC_WPCLI_BIN, $L_ALTERNC_DRUSH_BIN;
global $mem, $hooks, $L_OCI_REQUIRE_SU;
if ($L_OCI_REQUIRE_SU) {
if (!$mem->checkright()) {
return;
}
}
$menu = array(
'title' => _('Quick Install'),
'ico' => 'images/ocilogo.png',
@ -29,27 +34,35 @@ class m_oci {
'pos' => 11,
'links' => array(),
);
// @TODO invoke a hook to get supported applications
// need: id (eg. wordpress), weight (to order), ico, and
// optionally - a different action path.
// @TODO required binaries for installation: eg, wp-cli, drush
$links = $hooks->invokve('hook_oci_menu');
if ($links) {
$menu['links'] = $links;
}
if ($menu['links']) {
return $menu;
}
}
/**
* Implements hook_oci_menu().
*/
function hook_oci_menu() {
$links = array();
if ($this->app_is_installable('wordpress')) {
$menu['links'][] = array(
$links[] = array(
'txt' => _('WordPress'),
'url' => 'oci_install.php?app=wordpress',
'ico' => 'images/wordpress.png',
);
}
if ($this->app_is_installable('drupal')) {
$menu['links'][] = array(
$links[] = array(
'txt' => _('Drupal'),
'url' => 'oci_install.php?app=drupal',
'ico' => 'images/drupal.png',
);
}
if ($menu['links']) {
return $menu;
}
return $links;
}
/**
@ -296,7 +309,7 @@ class m_oci {
// Invoke hook to get app-specific form fields.
$extra = '';
$vals = $hooks->invoke('hook_oic_form', array($app));
$vals = $hooks->invoke('hook_oci_form', array($app));
foreach ($vals as $v) {
if ($v) {
$extra .= $v;
@ -317,13 +330,13 @@ class m_oci {
}
/**
* Implements hook_oic_form.
* Implements hook_oci_form.
*/
function hook_oic_form($app) {
function hook_oci_form($app) {
$f = '';
switch ($app) {
case 'drupal':
// These fields should be defined in hook_oic_form_fields
// These fields should be defined in hook_oci_form_fields
// Choose the install source
$f .= '<div id="drupal-install-source-wrapper">';
$f .= '<label for="drupal-install-source">' . _('Choose installation source') . '</label>';
@ -406,7 +419,7 @@ class m_oci {
* @returns array
* Array of errors eg. array(0 => array('module' => 'm_oci', 'message' => '...'), ...)
*/
function oci_form_validate($vars) {
function oci_form_validate($app, $vars) {
global $hooks, $dom, $db;
$errors = array();
if ($vars['domain'] == '*new*') {
@ -515,7 +528,7 @@ class m_oci {
);
}
}
$vals = $hooks->invoke('hook_oci_form_validate', array($vars));
$vals = $hooks->invoke('hook_oci_form_validate', array($app, $vars));
foreach ($vals as $v) {
if ($v && is_array($v) && !is_empty($v)) {
$errors = $errors + $v;
@ -527,7 +540,7 @@ class m_oci {
/**
* Implements hook_oci_form_validate.
*/
function hook_oci_form_validate($vars) {
function hook_oci_form_validate($app, $vars) {
$errors = array();
// @TODO Drupal
// @TODO Wordpress