Compare commits
10 Commits
1.0.0-alph
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
a73477c9f2 | |
|
|
625c27878f | |
|
|
8d1863c4eb | |
|
|
6a5cb00131 | |
|
|
9beb8136fe | |
|
|
e8df834277 | |
|
|
d4cfd0a173 | |
|
|
4972a5dbc1 | |
|
|
79c278170f | |
|
|
38c378cc80 |
|
|
@ -17,12 +17,23 @@ class CRM_Civiproxy_Mailer {
|
|||
* this is the orginal, wrapped mailer
|
||||
*/
|
||||
protected $mailer = NULL;
|
||||
/**
|
||||
* @var Mail Driver
|
||||
*/
|
||||
protected $driver = NULL;
|
||||
|
||||
/**
|
||||
* @var array Mail Params, currently not used
|
||||
*/
|
||||
protected $params = [];
|
||||
|
||||
/**
|
||||
* construct this mailer wrapping another one
|
||||
*/
|
||||
public function __construct($mailer) {
|
||||
public function __construct($mailer, $driver, $params) {
|
||||
$this->mailer = $mailer;
|
||||
$this->driver = $driver;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,4 +92,11 @@ class CRM_Civiproxy_Mailer {
|
|||
$value = preg_replace("#{$system_base}civicrm/mailing/{$function}#i", $new_url, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Mail|null
|
||||
*/
|
||||
public function getDriver() {
|
||||
return $this->driver;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,44 +75,27 @@ class CRM_Civiproxy_ExtensionUtil {
|
|||
return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
use CRM_Civiproxy_ExtensionUtil as E;
|
||||
|
||||
function _civiproxy_civix_mixin_polyfill() {
|
||||
if (!class_exists('CRM_Extension_MixInfo')) {
|
||||
$polyfill = __DIR__ . '/mixin/polyfill.php';
|
||||
(require $polyfill)(E::LONG_NAME, E::SHORT_NAME, E::path());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (Delegated) Implements hook_civicrm_config().
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_config(&$config = NULL) {
|
||||
function _civiproxy_civix_civicrm_config($config = NULL) {
|
||||
static $configured = FALSE;
|
||||
if ($configured) {
|
||||
return;
|
||||
}
|
||||
$configured = TRUE;
|
||||
|
||||
$template = CRM_Core_Smarty::singleton();
|
||||
|
||||
$extRoot = __DIR__ . DIRECTORY_SEPARATOR;
|
||||
$extDir = $extRoot . 'templates';
|
||||
|
||||
if (is_array($template->template_dir)) {
|
||||
array_unshift($template->template_dir, $extDir);
|
||||
}
|
||||
else {
|
||||
$template->template_dir = [$extDir, $template->template_dir];
|
||||
}
|
||||
|
||||
$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
|
||||
set_include_path($include_path);
|
||||
_civiproxy_civix_mixin_polyfill();
|
||||
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -122,36 +105,7 @@ function _civiproxy_civix_civicrm_config(&$config = NULL) {
|
|||
*/
|
||||
function _civiproxy_civix_civicrm_install() {
|
||||
_civiproxy_civix_civicrm_config();
|
||||
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||
$upgrader->onInstall();
|
||||
}
|
||||
_civiproxy_civix_mixin_polyfill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_postInstall().
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_postInstall() {
|
||||
_civiproxy_civix_civicrm_config();
|
||||
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||
if (is_callable([$upgrader, 'onPostInstall'])) {
|
||||
$upgrader->onPostInstall();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_uninstall().
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_uninstall() {
|
||||
_civiproxy_civix_civicrm_config();
|
||||
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||
$upgrader->onUninstall();
|
||||
}
|
||||
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -159,59 +113,9 @@ function _civiproxy_civix_civicrm_uninstall() {
|
|||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_enable() {
|
||||
function _civiproxy_civix_civicrm_enable(): void {
|
||||
_civiproxy_civix_civicrm_config();
|
||||
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||
if (is_callable([$upgrader, 'onEnable'])) {
|
||||
$upgrader->onEnable();
|
||||
}
|
||||
}
|
||||
_civiproxy_civix_mixin_polyfill();
|
||||
}
|
||||
|
||||
/**
|
||||
* (Delegated) Implements hook_civicrm_disable().
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
|
||||
* @return mixed
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_disable() {
|
||||
_civiproxy_civix_civicrm_config();
|
||||
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||
if (is_callable([$upgrader, 'onDisable'])) {
|
||||
$upgrader->onDisable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (Delegated) Implements hook_civicrm_upgrade().
|
||||
*
|
||||
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
|
||||
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
|
||||
*
|
||||
* @return mixed
|
||||
* based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
|
||||
* for 'enqueue', returns void
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
|
||||
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||
return $upgrader->onUpgrade($op, $queue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CRM_Civiproxy_Upgrader
|
||||
*/
|
||||
function _civiproxy_civix_upgrader() {
|
||||
if (!file_exists(__DIR__ . '/CRM/Civiproxy/Upgrader.php')) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
return CRM_Civiproxy_Upgrader_Base::instance();
|
||||
}
|
||||
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -230,8 +134,8 @@ function _civiproxy_civix_insert_navigation_menu(&$menu, $path, $item) {
|
|||
if (empty($path)) {
|
||||
$menu[] = [
|
||||
'attributes' => array_merge([
|
||||
'label' => CRM_Utils_Array::value('name', $item),
|
||||
'active' => 1,
|
||||
'label' => $item['name'] ?? NULL,
|
||||
'active' => 1,
|
||||
], $item),
|
||||
];
|
||||
return TRUE;
|
||||
|
|
@ -295,14 +199,3 @@ function _civiproxy_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $parentID)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (Delegated) Implements hook_civicrm_entityTypes().
|
||||
*
|
||||
* Find any *.entityType.php files, merge their content, and return.
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
|
||||
*/
|
||||
function _civiproxy_civix_civicrm_entityTypes(&$entityTypes) {
|
||||
$entityTypes = array_merge($entityTypes, []);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ require_once 'civiproxy.civix.php';
|
|||
* so we can mend all the URLs in outgoing emails
|
||||
*/
|
||||
function civiproxy_civicrm_alterMailer(&$mailer, $driver, $params) {
|
||||
$mailer = new CRM_Civiproxy_Mailer($mailer);
|
||||
$mailer = new CRM_Civiproxy_Mailer($mailer, $driver, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -32,13 +32,6 @@ function civiproxy_civicrm_install() {
|
|||
return _civiproxy_civix_civicrm_install();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_civicrm_uninstall
|
||||
*/
|
||||
function civiproxy_civicrm_uninstall() {
|
||||
return _civiproxy_civix_civicrm_uninstall();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_civicrm_enable
|
||||
*/
|
||||
|
|
@ -46,47 +39,9 @@ function civiproxy_civicrm_enable() {
|
|||
return _civiproxy_civix_civicrm_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_civicrm_disable
|
||||
*/
|
||||
function civiproxy_civicrm_disable() {
|
||||
return _civiproxy_civix_civicrm_disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_civicrm_upgrade
|
||||
*
|
||||
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
|
||||
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
|
||||
*
|
||||
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
|
||||
* for 'enqueue', returns void
|
||||
*/
|
||||
function civiproxy_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
|
||||
return _civiproxy_civix_civicrm_upgrade($op, $queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_civicrm_alterSettingsFolders
|
||||
*
|
||||
* Scan for settings in custom folder and import them
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_postInstall().
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
|
||||
*/
|
||||
function civiproxy_civicrm_postInstall() {
|
||||
_civiproxy_civix_civicrm_postInstall();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_entityTypes().
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
|
||||
*/
|
||||
function civiproxy_civicrm_entityTypes(&$entityTypes) {
|
||||
_civiproxy_civix_civicrm_entityTypes($entityTypes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,19 +14,25 @@
|
|||
<url desc="Support">https://github.com/systopia/CiviProxy/issues</url>
|
||||
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
|
||||
</urls>
|
||||
<releaseDate>2024-08-21</releaseDate>
|
||||
<version>1.0.0-alpha</version>
|
||||
<develStage>dev</develStage>
|
||||
<releaseDate>2024-01-07</releaseDate>
|
||||
<version>1.0.0-beta</version>
|
||||
<develStage>beta</develStage>
|
||||
<compatibility>
|
||||
<ver>5.0</ver>
|
||||
<ver>5.45</ver>
|
||||
</compatibility>
|
||||
<comments>This is the companion extension to SYSTOPIA's CiviProxy security system</comments>
|
||||
<civix>
|
||||
<namespace>CRM/Civiproxy</namespace>
|
||||
<format>22.05.2</format>
|
||||
<format>24.09.1</format>
|
||||
</civix>
|
||||
<mixins>
|
||||
<mixin>menu-xml@1.0.0</mixin>
|
||||
<mixin>setting-php@1.0.0</mixin>
|
||||
<mixin>smarty-v2@1.0.3</mixin>
|
||||
<mixin>entity-types-php@2.0.0</mixin>
|
||||
</mixins>
|
||||
<classloader>
|
||||
<psr0 prefix="CRM_" path="."/>
|
||||
<psr4 prefix="Civi\" path="Civi"/>
|
||||
</classloader>
|
||||
</extension>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Auto-register entity declarations from `schema/*.entityType.php`.
|
||||
*
|
||||
* @mixinName entity-types-php
|
||||
* @mixinVersion 2.0.0
|
||||
* @since 5.73
|
||||
*
|
||||
* Changelog:
|
||||
* - v2.0 scans /schema directory instead of /xml/schema/*
|
||||
* - v2.0 supports only one entity per file
|
||||
* - v2.0 adds 'module' key to each entity
|
||||
*
|
||||
* @param CRM_Extension_MixInfo $mixInfo
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
* @param \CRM_Extension_BootCache $bootCache
|
||||
* On newer deployments, this will be an instance of BootCache. On older deployments, Civix may polyfill with a work-a-like.
|
||||
*/
|
||||
return function ($mixInfo, $bootCache) {
|
||||
|
||||
/**
|
||||
* @param \Civi\Core\Event\GenericHookEvent $e
|
||||
* @see CRM_Utils_Hook::entityTypes()
|
||||
*/
|
||||
Civi::dispatcher()->addListener('hook_civicrm_entityTypes', function ($e) use ($mixInfo) {
|
||||
// When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically.
|
||||
if (!$mixInfo->isActive() || !is_dir($mixInfo->getPath('schema'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$files = (array) glob($mixInfo->getPath('schema/*.entityType.php'));
|
||||
foreach ($files as $file) {
|
||||
$entity = include $file;
|
||||
$entity['module'] = $mixInfo->longName;
|
||||
$e->entityTypes[$entity['name']] = $entity;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Auto-register "xml/Menu/*.xml" files.
|
||||
*
|
||||
* @mixinName menu-xml
|
||||
* @mixinVersion 1.0.0
|
||||
*
|
||||
* @param CRM_Extension_MixInfo $mixInfo
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
* @param \CRM_Extension_BootCache $bootCache
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
*/
|
||||
return function ($mixInfo, $bootCache) {
|
||||
|
||||
/**
|
||||
* @param \Civi\Core\Event\GenericHookEvent $e
|
||||
* @see CRM_Utils_Hook::xmlMenu()
|
||||
*/
|
||||
Civi::dispatcher()->addListener('hook_civicrm_xmlMenu', function ($e) use ($mixInfo) {
|
||||
if (!$mixInfo->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$files = (array) glob($mixInfo->getPath('xml/Menu/*.xml'));
|
||||
foreach ($files as $file) {
|
||||
$e->files[] = $file;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* When deploying on systems that lack mixin support, fake it.
|
||||
*
|
||||
* @mixinFile polyfill.php
|
||||
*
|
||||
* This polyfill does some (persnickity) deduplication, but it doesn't allow upgrades or shipping replacements in core.
|
||||
*
|
||||
* Note: The polyfill.php is designed to be copied into extensions for interoperability. Consequently, this file is
|
||||
* not used 'live' by `civicrm-core`. However, the file does need a canonical home, and it's convenient to keep it
|
||||
* adjacent to the actual mixin files.
|
||||
*
|
||||
* @param string $longName
|
||||
* @param string $shortName
|
||||
* @param string $basePath
|
||||
*/
|
||||
return function ($longName, $shortName, $basePath) {
|
||||
// Construct imitations of the mixin services. These cannot work as well (e.g. with respect to
|
||||
// number of file-reads, deduping, upgrading)... but they should be OK for a few months while
|
||||
// the mixin services become available.
|
||||
|
||||
// List of active mixins; deduped by version
|
||||
$mixinVers = [];
|
||||
foreach ((array) glob($basePath . '/mixin/*.mixin.php') as $f) {
|
||||
[$name, $ver] = explode('@', substr(basename($f), 0, -10));
|
||||
if (!isset($mixinVers[$name]) || version_compare($ver, $mixinVers[$name], '>')) {
|
||||
$mixinVers[$name] = $ver;
|
||||
}
|
||||
}
|
||||
$mixins = [];
|
||||
foreach ($mixinVers as $name => $ver) {
|
||||
$mixins[] = "$name@$ver";
|
||||
}
|
||||
|
||||
// Imitate CRM_Extension_MixInfo.
|
||||
$mixInfo = new class() {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $longName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $shortName;
|
||||
|
||||
public $_basePath;
|
||||
|
||||
public function getPath($file = NULL) {
|
||||
return $this->_basePath . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file));
|
||||
}
|
||||
|
||||
public function isActive() {
|
||||
return \CRM_Extension_System::singleton()->getMapper()->isActiveModule($this->shortName);
|
||||
}
|
||||
|
||||
};
|
||||
$mixInfo->longName = $longName;
|
||||
$mixInfo->shortName = $shortName;
|
||||
$mixInfo->_basePath = $basePath;
|
||||
|
||||
// Imitate CRM_Extension_BootCache.
|
||||
$bootCache = new class() {
|
||||
|
||||
public function define($name, $callback) {
|
||||
$envId = \CRM_Core_Config_Runtime::getId();
|
||||
$oldExtCachePath = \Civi::paths()->getPath("[civicrm.compile]/CachedExtLoader.{$envId}.php");
|
||||
$stat = stat($oldExtCachePath);
|
||||
$file = Civi::paths()->getPath('[civicrm.compile]/CachedMixin.' . md5($name . ($stat['mtime'] ?? 0)) . '.php');
|
||||
if (file_exists($file)) {
|
||||
return include $file;
|
||||
}
|
||||
else {
|
||||
$data = $callback();
|
||||
file_put_contents($file, '<' . "?php\nreturn " . var_export($data, 1) . ';');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Imitate CRM_Extension_MixinLoader::run()
|
||||
// Parse all live mixins before trying to scan any classes.
|
||||
global $_CIVIX_MIXIN_POLYFILL;
|
||||
foreach ($mixins as $mixin) {
|
||||
// If the exact same mixin is defined by multiple exts, just use the first one.
|
||||
if (!isset($_CIVIX_MIXIN_POLYFILL[$mixin])) {
|
||||
$_CIVIX_MIXIN_POLYFILL[$mixin] = include_once $basePath . '/mixin/' . $mixin . '.mixin.php';
|
||||
}
|
||||
}
|
||||
foreach ($mixins as $mixin) {
|
||||
// If there's trickery about installs/uninstalls/resets, then we may need to register a second time.
|
||||
if (!isset(\Civi::$statics[__FUNCTION__][$mixin])) {
|
||||
\Civi::$statics[__FUNCTION__][$mixin] = 1;
|
||||
$func = $_CIVIX_MIXIN_POLYFILL[$mixin];
|
||||
$func($mixInfo, $bootCache);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Auto-register "settings/*.setting.php" files.
|
||||
*
|
||||
* @mixinName setting-php
|
||||
* @mixinVersion 1.0.0
|
||||
*
|
||||
* @param CRM_Extension_MixInfo $mixInfo
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
* @param \CRM_Extension_BootCache $bootCache
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
*/
|
||||
return function ($mixInfo, $bootCache) {
|
||||
|
||||
/**
|
||||
* @param \Civi\Core\Event\GenericHookEvent $e
|
||||
* @see CRM_Utils_Hook::alterSettingsFolders()
|
||||
*/
|
||||
Civi::dispatcher()->addListener('hook_civicrm_alterSettingsFolders', function ($e) use ($mixInfo) {
|
||||
// When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically.
|
||||
if (!$mixInfo->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settingsDir = $mixInfo->getPath('settings');
|
||||
if (!in_array($settingsDir, $e->settingsFolders) && is_dir($settingsDir)) {
|
||||
$e->settingsFolders[] = $settingsDir;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Auto-register "templates/" folder.
|
||||
*
|
||||
* @mixinName smarty-v2
|
||||
* @mixinVersion 1.0.3
|
||||
* @since 5.59
|
||||
*
|
||||
* @deprecated - it turns out that the mixin is not version specific so the 'smarty'
|
||||
* mixin is preferred over smarty-v2 (they are the same but not having the version
|
||||
* in the name is less misleading.)
|
||||
*
|
||||
* @param CRM_Extension_MixInfo $mixInfo
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
* @param \CRM_Extension_BootCache $bootCache
|
||||
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
|
||||
*/
|
||||
return function ($mixInfo, $bootCache) {
|
||||
$dir = $mixInfo->getPath('templates');
|
||||
if (!file_exists($dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$register = function($newDirs) {
|
||||
$smarty = CRM_Core_Smarty::singleton();
|
||||
$v2 = isset($smarty->_version) && version_compare($smarty->_version, 3, '<');
|
||||
$templateDirs = (array) ($v2 ? $smarty->template_dir : $smarty->getTemplateDir());
|
||||
$templateDirs = array_merge($newDirs, $templateDirs);
|
||||
$templateDirs = array_unique(array_map(function($v) {
|
||||
$v = str_replace(DIRECTORY_SEPARATOR, '/', $v);
|
||||
$v = rtrim($v, '/') . '/';
|
||||
return $v;
|
||||
}, $templateDirs));
|
||||
if ($v2) {
|
||||
$smarty->template_dir = $templateDirs;
|
||||
}
|
||||
else {
|
||||
$smarty->setTemplateDir($templateDirs);
|
||||
}
|
||||
};
|
||||
|
||||
// Let's figure out what environment we're in -- so that we know the best way to call $register().
|
||||
|
||||
if (!empty($GLOBALS['_CIVIX_MIXIN_POLYFILL'])) {
|
||||
// Polyfill Loader (v<=5.45): We're already in the middle of firing `hook_config`.
|
||||
if ($mixInfo->isActive()) {
|
||||
$register([$dir]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (CRM_Extension_System::singleton()->getManager()->extensionIsBeingInstalledOrEnabled($mixInfo->longName)) {
|
||||
// New Install, Standard Loader: The extension has just been enabled, and we're now setting it up.
|
||||
// System has already booted. New templates may be needed for upcoming installation steps.
|
||||
$register([$dir]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Typical Pageview, Standard Loader: Defer the actual registration for a moment -- to ensure that Smarty is online.
|
||||
// We need to bundle-up all dirs -- Smarty 3/4/5 is inefficient with processing repeated calls to `getTemplateDir()`+`setTemplateDir()`
|
||||
if (!isset(Civi::$statics[__FILE__]['event'])) {
|
||||
Civi::$statics[__FILE__]['event'] = 'civi.smarty-v2.addPaths.' . md5(__FILE__);
|
||||
Civi::dispatcher()->addListener('hook_civicrm_config', function() use ($register) {
|
||||
$dirs = [];
|
||||
$event = \Civi\Core\Event\GenericHookEvent::create(['dirs' => &$dirs]);
|
||||
Civi::dispatcher()->dispatch(Civi::$statics[__FILE__]['event'], $event);
|
||||
$register($dirs);
|
||||
});
|
||||
}
|
||||
|
||||
Civi::dispatcher()->addListener(Civi::$statics[__FILE__]['event'], function($event) use ($mixInfo, $dir) {
|
||||
if ($mixInfo->isActive()) {
|
||||
array_unshift($event->dirs, $dir);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
|
@ -19,7 +19,7 @@ civiproxy_security_check('mail-confirm');
|
|||
// basic restraints
|
||||
$valid_parameters = array( 'sid' => 'int',
|
||||
'cid' => 'int',
|
||||
'h' => 'hex');
|
||||
'h' => 'string');
|
||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||
|
||||
// check if parameters specified
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ civiproxy_security_check('mail-resubscribe');
|
|||
// basic restraints
|
||||
$valid_parameters = array( 'jid' => 'int',
|
||||
'qid' => 'int',
|
||||
'h' => 'hex');
|
||||
'h' => 'string');
|
||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||
|
||||
// check if parameters specified
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ civiproxy_security_check('mail-unsubscribe');
|
|||
// basic restraints
|
||||
$valid_parameters = array( 'jid' => 'int',
|
||||
'qid' => 'int',
|
||||
'h' => 'hex');
|
||||
'h' => 'string');
|
||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||
|
||||
// check if parameters specified
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "config.php";
|
||||
$civiproxy_version = '1.0.0-alpha';
|
||||
$civiproxy_version = '1.0.0-beta';
|
||||
|
||||
/**
|
||||
* this will redirect the request to another URL,
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ function webhook2api_processConfiguration($configuration, $post_input) {
|
|||
}
|
||||
if (!empty($result['values']['http_code'])) {
|
||||
$http_code = $result['values']['http_code'];
|
||||
} else {
|
||||
$http_code = 403;
|
||||
} elseif ($result['is_error'] != 0) {
|
||||
$http_code = 403;
|
||||
}
|
||||
}
|
||||
if ($http_code != '200') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue