drd_server_svn.module in Drupal Remote Dashboard Server 7.2
Same filename and directory in other branches
Provides subversion functionality as an addition to drd_server.
File
drd_server_svn.moduleView source
<?php
/**
* @file
* Provides subversion functionality as an addition to drd_server.
*/
/** ======================================================================
*
* Hooks
*/
/**
* Implementation of hook_xmlrpc().
*
* This function provides Drupal with an array to map XML-RPC callbacks to the
* functions implemented by this module.
*
* @return array
* An array of key/value pairs where key is the action name and value the corresponding function.
*/
function drd_server_svn_xmlrpc() {
return array(
'drd.config.svn.read' => 'drd_server_svn_config_read',
);
}
/**
* Implements hook_drd_server_actions().
*
* @return array
* An array of keyed action definitions.
*/
function drd_server_svn_drd_server_actions() {
$options = array();
foreach (module_implements('drd_svn_module') as $module) {
foreach (module_invoke($module, 'drd_svn_module') as $key => $def) {
$options[$module . ':' . $key] = $def['label'];
}
}
return array(
'drd.server.svn.status' => array(
'category' => t('Subversion'),
'label' => t('Status'),
'callback' => 'drd_vcs_svn_status',
'file' => 'drd.vcs.inc',
'mode' => 'server',
'remote' => FALSE,
'queue' => TRUE,
'fields' => array(
'svn_status_modules' => array(
'#type' => 'select',
'#title' => t('Modules'),
'#options' => $options,
'#multiple' => TRUE,
'#default_value' => array(),
),
),
),
'drd.server.svn.update' => array(
'category' => t('Subversion'),
'label' => t('Update'),
'callback' => 'drd_vcs_svn_update',
'file' => 'drd.vcs.inc',
'mode' => 'server',
'remote' => FALSE,
'queue' => TRUE,
'fields' => array(
'svn_status_modules' => array(
'#type' => 'select',
'#title' => t('Modules'),
'#options' => $options,
'#multiple' => TRUE,
'#default_value' => array(),
),
),
),
);
}
/**
* Implements hook_drd_svn_module().
*
* @return array
* An array of directories that are available for subversion actions.
*/
function drd_server_svn_drd_svn_module() {
return array(
'drupal' => array(
'label' => t('Drupal Core'),
'paths' => array(
DRUPAL_ROOT,
),
),
'drd' => array(
'label' => t('Module DRD_Server'),
'paths' => array(
DRUPAL_ROOT . '/' . drupal_get_path('module', 'drd_server'),
),
),
);
}
/**
* Implements hook_drd_config_server().
*
* @return array
* Form definition for server settings.
*/
function drd_server_svn_drd_config_server() {
$form = array();
$form['drd_server_svn'] = array(
'#type' => 'fieldset',
'#title' => 'SVN Support',
);
$form['drd_server_svn']['drd_server_svn_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('SVN enabled'),
'#default_value' => variable_get('drd_server_svn_enabled', FALSE),
);
$form['drd_server_svn']['drd_server_svn_settings'] = array(
'#type' => 'fieldset',
'#title' => 'SVN Support',
'#states' => array(
'invisible' => array(
'input[name="drd_server_svn_enabled"]' => array(
'checked' => FALSE,
),
),
),
);
$form['drd_server_svn']['drd_server_svn_settings']['drd_server_svn_username'] = array(
'#type' => 'textfield',
'#title' => t('SVN username'),
'#default_value' => variable_get('drd_server_svn_username', ''),
);
$form['drd_server_svn']['drd_server_svn_settings']['drd_server_svn_password'] = array(
'#type' => 'textfield',
'#title' => t('SVN password'),
'#default_value' => variable_get('drd_server_svn_password', ''),
);
return $form;
}
/**
* Extra parameter: $options
* @return string
*/
function drd_server_svn_config_read() {
$args = func_get_args();
$valid = _drd_server_validate_request($args);
if ($valid !== TRUE) {
return $valid;
}
$options = drupal_json_decode(array_shift($args));
$directories = array();
foreach ($options as $option) {
$parts = explode(':', $option);
$svn_modules = module_invoke($parts[0], 'drd_svn_module');
if (empty($svn_modules[$parts[1]])) {
return drd_server_error(t('No SVN definition available.'));
}
$directories[] = $svn_modules[$parts[1]];
}
$result = array(
'directories' => $directories,
'credentials' => array(
'enabled' => variable_get('drd_server_svn_enabled', FALSE),
'username' => variable_get('drd_server_svn_username', ''),
'password' => variable_get('drd_server_svn_password', ''),
),
);
return drd_server_result('drd.config.svn.read', $result);
}
Functions
Name | Description |
---|---|
drd_server_svn_config_read | Extra parameter: $options |
drd_server_svn_drd_config_server | Implements hook_drd_config_server(). |
drd_server_svn_drd_server_actions | Implements hook_drd_server_actions(). |
drd_server_svn_drd_svn_module | Implements hook_drd_svn_module(). |
drd_server_svn_xmlrpc | Implementation of hook_xmlrpc(). |