added a settings page
This commit is contained in:
parent
466b636b81
commit
3ec288dfdf
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'CRM/Admin/Form/Setting.php';
|
||||||
|
require_once 'CRM/Core/BAO/CustomField.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
CiviProxy Settings Form
|
||||||
|
*/
|
||||||
|
class CRM_Admin_Form_Setting_ProxySettings extends CRM_Admin_Form_Setting
|
||||||
|
{
|
||||||
|
function buildQuickForm( ) {
|
||||||
|
CRM_Utils_System::setTitle(ts('CiviProxy - Settings'));
|
||||||
|
|
||||||
|
// add all required elements
|
||||||
|
$this->addElement('checkbox','proxy_enabled');
|
||||||
|
$this->addElement('checkbox','image_cache_enabled');
|
||||||
|
$this->addElement('text', 'proxy_url', ts('Proxy URL'));
|
||||||
|
|
||||||
|
$this->addButtons(array(
|
||||||
|
array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE),
|
||||||
|
array('type' => 'cancel', 'name' => ts('Cancel')),
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->registerRule('onlyValidURL', 'callback', 'validateURL', 'CRM_Admin_Form_Setting_ProxySettings');
|
||||||
|
}
|
||||||
|
|
||||||
|
function addRules() {
|
||||||
|
$this->addRule('proxy_url', ts('This may only contain a valid URL'), 'onlyValidURL');
|
||||||
|
}
|
||||||
|
|
||||||
|
function preProcess() {
|
||||||
|
$this->assign('proxy_enabled', CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'proxy_enabled'));
|
||||||
|
$this->assign('image_cache_enabled', CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'image_cache_enabled'));
|
||||||
|
$this->setDefaults(array(
|
||||||
|
'proxy_url' => CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'proxy_url'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function postProcess() {
|
||||||
|
// process all form values and save valid settings
|
||||||
|
$values = $this->exportValues();
|
||||||
|
|
||||||
|
// checkboxes
|
||||||
|
CRM_Core_BAO_Setting::setItem(!empty($values['proxy_enabled']),'CiviProxy Settings', 'proxy_enabled');
|
||||||
|
CRM_Core_BAO_Setting::setItem(!empty($values['image_cache_enabled']),'CiviProxy Settings', 'image_cache_enabled');
|
||||||
|
|
||||||
|
// text
|
||||||
|
if ($values['proxy_url']){
|
||||||
|
CRM_Core_BAO_Setting::setItem($values['proxy_url'],'CiviProxy Settings', 'proxy_url');
|
||||||
|
}
|
||||||
|
|
||||||
|
// give feedback to user
|
||||||
|
$session = CRM_Core_Session::singleton();
|
||||||
|
$session->setStatus(ts("Settings successfully saved"), ts('Settings'), 'success');
|
||||||
|
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/setting/civiproxy'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static function validateURL($value) {
|
||||||
|
return preg_match("/^(http(s?):\/\/)?(((www\.)?+[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,6})+)|(localhost)|(\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b))(:[0-9]{1,5})?(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/",$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -93,3 +93,21 @@ function civiproxy_civicrm_managed(&$entities) {
|
||||||
function civiproxy_civicrm_caseTypes(&$caseTypes) {
|
function civiproxy_civicrm_caseTypes(&$caseTypes) {
|
||||||
_civiproxy_civix_civicrm_caseTypes($caseTypes);
|
_civiproxy_civix_civicrm_caseTypes($caseTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_civicrm_alterSettingsFolders
|
||||||
|
*
|
||||||
|
* Scan for settings in custom folder and import them
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function civiproxy_civicrm_alterSettingsFolders(&$metaDataFolders = NULL){
|
||||||
|
static $configured = FALSE;
|
||||||
|
if ($configured) return;
|
||||||
|
$configured = TRUE;
|
||||||
|
|
||||||
|
$extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
|
||||||
|
$extDir = $extRoot . 'settings';
|
||||||
|
if(!in_array($extDir, $metaDataFolders)){
|
||||||
|
$metaDataFolders[] = $extDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Settings metadata file
|
||||||
|
*/
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'proxy_enabled' => array(
|
||||||
|
'group_name' => 'CiviProxy Settings',
|
||||||
|
'group' => 'de.systopia',
|
||||||
|
'name' => 'proxy_enabled',
|
||||||
|
'type' => 'Integer',
|
||||||
|
'html_type' => 'Select',
|
||||||
|
'default' => 0,
|
||||||
|
'add' => '4.3',
|
||||||
|
'is_domain' => 1,
|
||||||
|
'is_contact' => 0,
|
||||||
|
'description' => 'Enables or disables the proxy',
|
||||||
|
'help_text' => 'TODO',
|
||||||
|
),
|
||||||
|
'image_cache_enabled' => array(
|
||||||
|
'group_name' => 'CiviProxy Settings',
|
||||||
|
'group' => 'de.systopia',
|
||||||
|
'name' => 'image_cache_enabled',
|
||||||
|
'type' => 'Integer',
|
||||||
|
'html_type' => 'Select',
|
||||||
|
'default' => 0,
|
||||||
|
'add' => '4.3',
|
||||||
|
'is_domain' => 1,
|
||||||
|
'is_contact' => 0,
|
||||||
|
'description' => 'Enables or disables image cache',
|
||||||
|
'help_text' => 'TODO',
|
||||||
|
),
|
||||||
|
'proxy_url' => array(
|
||||||
|
'group_name' => 'CiviProxy Settings',
|
||||||
|
'group' => 'de.systopia',
|
||||||
|
'name' => 'proxy_url',
|
||||||
|
'type' => 'String',
|
||||||
|
'default' => "",
|
||||||
|
'add' => '4.3',
|
||||||
|
'is_domain' => 1,
|
||||||
|
'is_contact' => 0,
|
||||||
|
'description' => 'The URL from which the proxy will be available for requests',
|
||||||
|
'help_text' => 'TODO',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{htxt id='id-proxy-enabled'}
|
||||||
|
<p>{ts}TODO #1{/ts}</p>
|
||||||
|
{/htxt}
|
||||||
|
|
||||||
|
{htxt id='id-image-cache-enabled'}
|
||||||
|
<p>{ts}TODO #2{/ts}</p>
|
||||||
|
{/htxt}
|
||||||
|
|
||||||
|
{htxt id='id-proxy-url'}
|
||||||
|
<p>{ts}TODO #3{/ts}</p>
|
||||||
|
{/htxt}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<div class="crm-block crm-form-block">
|
||||||
|
<div>
|
||||||
|
<h3>{ts}Core Settings{/ts}</h3>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<table id="core_settings">
|
||||||
|
<tr>
|
||||||
|
<td class="label"><label for="proxy_enabled"> {ts}Enable proxy{/ts} <a onclick='CRM.help("{ts}Enable Proxy{/ts}", {literal}{"id":"id-proxy-enabled","file":"CRM\/Admin\/Form\/Setting\/ProxySettings"}{/literal}); return false;' href="#" title="{ts}Help{/ts}" class="helpicon"> </a></label></td>
|
||||||
|
<td><input value="1" type="checkbox" id="proxy_enabled" name="proxy_enabled" {if $proxy_enabled}checked="checked"{/if} class="form-checkbox"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label"><label for="image_cache_enabled"> {ts}Enable image cache{/ts} <a onclick='CRM.help("{ts}Enable Image Cache{/ts}", {literal}{"id":"id-image-cache-enabled","file":"CRM\/Admin\/Form\/Setting\/ProxySettings"}{/literal}); return false;' href="#" title="{ts}Help{/ts}" class="helpicon"> </a></label></td>
|
||||||
|
<td><input value="1" type="checkbox" id="image_cache_enabled" name="image_cache_enabled" {if $image_cache_enabled}checked="checked"{/if} class="form-checkbox"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">{$form.proxy_url.label} <a onclick='CRM.help("{ts}Proxy URL{/ts}", {literal}{"id":"id-proxy-url","file":"CRM\/Admin\/Form\/Setting\/ProxySettings"}{/literal}); return false;' href="#" title="{ts}Help{/ts}" class="helpicon"> </a></td>
|
||||||
|
<td>{$form.proxy_url.html}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{literal}
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function(cj) {
|
||||||
|
|
||||||
|
})(cj);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
#proxy_url {
|
||||||
|
width: 220px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{/literal}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<menu>
|
||||||
|
<item>
|
||||||
|
<path>civicrm/admin/setting/civiproxy</path>
|
||||||
|
<page_callback>CRM_Admin_Form_Setting_ProxySettings</page_callback>
|
||||||
|
<title>CiviProxy Settings</title>
|
||||||
|
<desc>TODO</desc>
|
||||||
|
<access_arguments>administer CiviCRM</access_arguments>
|
||||||
|
<adminGroup>System Settings</adminGroup>
|
||||||
|
<icon>admin/small/online_contribution_pages.png</icon>
|
||||||
|
<weight>100</weight>
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
Loading…
Reference in New Issue