Compare commits
No commits in common. "master" and "0.7.0" have entirely different histories.
|
|
@ -17,23 +17,12 @@ class CRM_Civiproxy_Mailer {
|
||||||
* this is the orginal, wrapped mailer
|
* this is the orginal, wrapped mailer
|
||||||
*/
|
*/
|
||||||
protected $mailer = NULL;
|
protected $mailer = NULL;
|
||||||
/**
|
|
||||||
* @var Mail Driver
|
|
||||||
*/
|
|
||||||
protected $driver = NULL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Mail Params, currently not used
|
|
||||||
*/
|
|
||||||
protected $params = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construct this mailer wrapping another one
|
* construct this mailer wrapping another one
|
||||||
*/
|
*/
|
||||||
public function __construct($mailer, $driver, $params) {
|
public function __construct($mailer) {
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
$this->driver = $driver;
|
|
||||||
$this->params = $params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,11 +81,4 @@ class CRM_Civiproxy_Mailer {
|
||||||
$value = preg_replace("#{$system_base}civicrm/mailing/{$function}#i", $new_url, $value);
|
$value = preg_replace("#{$system_base}civicrm/mailing/{$function}#i", $new_url, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Mail|null
|
|
||||||
*/
|
|
||||||
public function getDriver() {
|
|
||||||
return $this->driver;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
* extension.
|
* extension.
|
||||||
*/
|
*/
|
||||||
class CRM_Civiproxy_ExtensionUtil {
|
class CRM_Civiproxy_ExtensionUtil {
|
||||||
const SHORT_NAME = 'civiproxy';
|
const SHORT_NAME = "civiproxy";
|
||||||
const LONG_NAME = 'de.systopia.civiproxy';
|
const LONG_NAME = "de.systopia.civiproxy";
|
||||||
const CLASS_PREFIX = 'CRM_Civiproxy';
|
const CLASS_PREFIX = "CRM_Civiproxy";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a string using the extension's domain.
|
* Translate a string using the extension's domain.
|
||||||
|
|
@ -24,7 +24,7 @@ class CRM_Civiproxy_ExtensionUtil {
|
||||||
* Translated text.
|
* Translated text.
|
||||||
* @see ts
|
* @see ts
|
||||||
*/
|
*/
|
||||||
public static function ts($text, $params = []): string {
|
public static function ts($text, $params = []) {
|
||||||
if (!array_key_exists('domain', $params)) {
|
if (!array_key_exists('domain', $params)) {
|
||||||
$params['domain'] = [self::LONG_NAME, NULL];
|
$params['domain'] = [self::LONG_NAME, NULL];
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ class CRM_Civiproxy_ExtensionUtil {
|
||||||
* Ex: 'http://example.org/sites/default/ext/org.example.foo'.
|
* Ex: 'http://example.org/sites/default/ext/org.example.foo'.
|
||||||
* Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
|
* Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
|
||||||
*/
|
*/
|
||||||
public static function url($file = NULL): string {
|
public static function url($file = NULL) {
|
||||||
if ($file === NULL) {
|
if ($file === NULL) {
|
||||||
return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/');
|
return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/');
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +75,6 @@ class CRM_Civiproxy_ExtensionUtil {
|
||||||
return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
|
return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use CRM_Civiproxy_ExtensionUtil as E;
|
use CRM_Civiproxy_ExtensionUtil as E;
|
||||||
|
|
@ -85,17 +84,40 @@ use CRM_Civiproxy_ExtensionUtil as E;
|
||||||
*
|
*
|
||||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/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;
|
static $configured = FALSE;
|
||||||
if ($configured) {
|
if ($configured) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$configured = TRUE;
|
$configured = TRUE;
|
||||||
|
|
||||||
$extRoot = __DIR__ . DIRECTORY_SEPARATOR;
|
$template =& CRM_Core_Smarty::singleton();
|
||||||
|
|
||||||
|
$extRoot = dirname(__FILE__) . 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();
|
$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
|
||||||
set_include_path($include_path);
|
set_include_path($include_path);
|
||||||
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Delegated) Implements hook_civicrm_xmlMenu().
|
||||||
|
*
|
||||||
|
* @param $files array(string)
|
||||||
|
*
|
||||||
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_civicrm_xmlMenu(&$files) {
|
||||||
|
foreach (_civiproxy_civix_glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
|
||||||
|
$files[] = $file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,7 +127,35 @@ function _civiproxy_civix_civicrm_config($config = NULL) {
|
||||||
*/
|
*/
|
||||||
function _civiproxy_civix_civicrm_install() {
|
function _civiproxy_civix_civicrm_install() {
|
||||||
_civiproxy_civix_civicrm_config();
|
_civiproxy_civix_civicrm_config();
|
||||||
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
|
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||||
|
$upgrader->onInstall();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -113,9 +163,212 @@ function _civiproxy_civix_civicrm_install() {
|
||||||
*
|
*
|
||||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
|
||||||
*/
|
*/
|
||||||
function _civiproxy_civix_civicrm_enable(): void {
|
function _civiproxy_civix_civicrm_enable() {
|
||||||
_civiproxy_civix_civicrm_config();
|
_civiproxy_civix_civicrm_config();
|
||||||
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
|
if ($upgrader = _civiproxy_civix_upgrader()) {
|
||||||
|
if (is_callable([$upgrader, 'onEnable'])) {
|
||||||
|
$upgrader->onEnable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search directory tree for files which match a glob pattern.
|
||||||
|
*
|
||||||
|
* Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
|
||||||
|
* Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
|
||||||
|
*
|
||||||
|
* @param string $dir base dir
|
||||||
|
* @param string $pattern , glob pattern, eg "*.txt"
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_find_files($dir, $pattern) {
|
||||||
|
if (is_callable(['CRM_Utils_File', 'findFiles'])) {
|
||||||
|
return CRM_Utils_File::findFiles($dir, $pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
$todos = [$dir];
|
||||||
|
$result = [];
|
||||||
|
while (!empty($todos)) {
|
||||||
|
$subdir = array_shift($todos);
|
||||||
|
foreach (_civiproxy_civix_glob("$subdir/$pattern") as $match) {
|
||||||
|
if (!is_dir($match)) {
|
||||||
|
$result[] = $match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($dh = opendir($subdir)) {
|
||||||
|
while (FALSE !== ($entry = readdir($dh))) {
|
||||||
|
$path = $subdir . DIRECTORY_SEPARATOR . $entry;
|
||||||
|
if ($entry[0] == '.') {
|
||||||
|
}
|
||||||
|
elseif (is_dir($path)) {
|
||||||
|
$todos[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Delegated) Implements hook_civicrm_managed().
|
||||||
|
*
|
||||||
|
* Find any *.mgd.php files, merge their content, and return.
|
||||||
|
*
|
||||||
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_civicrm_managed(&$entities) {
|
||||||
|
$mgdFiles = _civiproxy_civix_find_files(__DIR__, '*.mgd.php');
|
||||||
|
sort($mgdFiles);
|
||||||
|
foreach ($mgdFiles as $file) {
|
||||||
|
$es = include $file;
|
||||||
|
foreach ($es as $e) {
|
||||||
|
if (empty($e['module'])) {
|
||||||
|
$e['module'] = E::LONG_NAME;
|
||||||
|
}
|
||||||
|
if (empty($e['params']['version'])) {
|
||||||
|
$e['params']['version'] = '3';
|
||||||
|
}
|
||||||
|
$entities[] = $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Delegated) Implements hook_civicrm_caseTypes().
|
||||||
|
*
|
||||||
|
* Find any and return any files matching "xml/case/*.xml"
|
||||||
|
*
|
||||||
|
* Note: This hook only runs in CiviCRM 4.4+.
|
||||||
|
*
|
||||||
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_civicrm_caseTypes(&$caseTypes) {
|
||||||
|
if (!is_dir(__DIR__ . '/xml/case')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (_civiproxy_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) {
|
||||||
|
$name = preg_replace('/\.xml$/', '', basename($file));
|
||||||
|
if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) {
|
||||||
|
$errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name));
|
||||||
|
throw new CRM_Core_Exception($errorMessage);
|
||||||
|
}
|
||||||
|
$caseTypes[$name] = [
|
||||||
|
'module' => E::LONG_NAME,
|
||||||
|
'name' => $name,
|
||||||
|
'file' => $file,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Delegated) Implements hook_civicrm_angularModules().
|
||||||
|
*
|
||||||
|
* Find any and return any files matching "ang/*.ang.php"
|
||||||
|
*
|
||||||
|
* Note: This hook only runs in CiviCRM 4.5+.
|
||||||
|
*
|
||||||
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_civicrm_angularModules(&$angularModules) {
|
||||||
|
if (!is_dir(__DIR__ . '/ang')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = _civiproxy_civix_glob(__DIR__ . '/ang/*.ang.php');
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$name = preg_replace(':\.ang\.php$:', '', basename($file));
|
||||||
|
$module = include $file;
|
||||||
|
if (empty($module['ext'])) {
|
||||||
|
$module['ext'] = E::LONG_NAME;
|
||||||
|
}
|
||||||
|
$angularModules[$name] = $module;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Delegated) Implements hook_civicrm_themes().
|
||||||
|
*
|
||||||
|
* Find any and return any files matching "*.theme.php"
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_civicrm_themes(&$themes) {
|
||||||
|
$files = _civiproxy_civix_glob(__DIR__ . '/*.theme.php');
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$themeMeta = include $file;
|
||||||
|
if (empty($themeMeta['name'])) {
|
||||||
|
$themeMeta['name'] = preg_replace(':\.theme\.php$:', '', basename($file));
|
||||||
|
}
|
||||||
|
if (empty($themeMeta['ext'])) {
|
||||||
|
$themeMeta['ext'] = E::LONG_NAME;
|
||||||
|
}
|
||||||
|
$themes[$themeMeta['name']] = $themeMeta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Glob wrapper which is guaranteed to return an array.
|
||||||
|
*
|
||||||
|
* The documentation for glob() says, "On some systems it is impossible to
|
||||||
|
* distinguish between empty match and an error." Anecdotally, the return
|
||||||
|
* result for an empty match is sometimes array() and sometimes FALSE.
|
||||||
|
* This wrapper provides consistency.
|
||||||
|
*
|
||||||
|
* @link http://php.net/glob
|
||||||
|
* @param string $pattern
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_glob($pattern) {
|
||||||
|
$result = glob($pattern);
|
||||||
|
return is_array($result) ? $result : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,7 +387,7 @@ function _civiproxy_civix_insert_navigation_menu(&$menu, $path, $item) {
|
||||||
if (empty($path)) {
|
if (empty($path)) {
|
||||||
$menu[] = [
|
$menu[] = [
|
||||||
'attributes' => array_merge([
|
'attributes' => array_merge([
|
||||||
'label' => $item['name'] ?? NULL,
|
'label' => CRM_Utils_Array::value('name', $item),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
], $item),
|
], $item),
|
||||||
];
|
];
|
||||||
|
|
@ -199,3 +452,26 @@ function _civiproxy_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $parentID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Delegated) Implements hook_civicrm_alterSettingsFolders().
|
||||||
|
*
|
||||||
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
|
||||||
|
*/
|
||||||
|
function _civiproxy_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
|
||||||
|
$settingsDir = __DIR__ . DIRECTORY_SEPARATOR . 'settings';
|
||||||
|
if (!in_array($settingsDir, $metaDataFolders) && is_dir($settingsDir)) {
|
||||||
|
$metaDataFolders[] = $settingsDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (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
|
* so we can mend all the URLs in outgoing emails
|
||||||
*/
|
*/
|
||||||
function civiproxy_civicrm_alterMailer(&$mailer, $driver, $params) {
|
function civiproxy_civicrm_alterMailer(&$mailer, $driver, $params) {
|
||||||
$mailer = new CRM_Civiproxy_Mailer($mailer, $driver, $params);
|
$mailer = new CRM_Civiproxy_Mailer($mailer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,6 +25,15 @@ function civiproxy_civicrm_config(&$config) {
|
||||||
_civiproxy_civix_civicrm_config($config);
|
_civiproxy_civix_civicrm_config($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_civicrm_xmlMenu
|
||||||
|
*
|
||||||
|
* @param $files array(string)
|
||||||
|
*/
|
||||||
|
function civiproxy_civicrm_xmlMenu(&$files) {
|
||||||
|
_civiproxy_civix_civicrm_xmlMenu($files);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_civicrm_install
|
* Implementation of hook_civicrm_install
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,6 +41,13 @@ function civiproxy_civicrm_install() {
|
||||||
return _civiproxy_civix_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
|
* Implementation of hook_civicrm_enable
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,9 +55,61 @@ function civiproxy_civicrm_enable() {
|
||||||
return _civiproxy_civix_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_managed
|
||||||
|
*
|
||||||
|
* Generate a list of entities to create/deactivate/delete when this module
|
||||||
|
* is installed, disabled, uninstalled.
|
||||||
|
*/
|
||||||
|
function civiproxy_civicrm_managed(&$entities) {
|
||||||
|
return _civiproxy_civix_civicrm_managed($entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_civicrm_caseTypes
|
||||||
|
*
|
||||||
|
* Generate a list of case-types
|
||||||
|
*
|
||||||
|
* Note: This hook only runs in CiviCRM 4.4+.
|
||||||
|
*/
|
||||||
|
function civiproxy_civicrm_caseTypes(&$caseTypes) {
|
||||||
|
_civiproxy_civix_civicrm_caseTypes($caseTypes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_civicrm_alterSettingsFolders
|
* Implementation of hook_civicrm_alterSettingsFolders
|
||||||
*
|
*
|
||||||
* Scan for settings in custom folder and import them
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,25 +14,14 @@
|
||||||
<url desc="Support">https://github.com/systopia/CiviProxy/issues</url>
|
<url desc="Support">https://github.com/systopia/CiviProxy/issues</url>
|
||||||
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
|
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
|
||||||
</urls>
|
</urls>
|
||||||
<releaseDate>2024-01-07</releaseDate>
|
<releaseDate>2024-06-18</releaseDate>
|
||||||
<version>1.0.0-beta</version>
|
<version>0.7.0</version>
|
||||||
<develStage>beta</develStage>
|
<develStage>stable</develStage>
|
||||||
<compatibility>
|
<compatibility>
|
||||||
<ver>5.45</ver>
|
<ver>5.0</ver>
|
||||||
</compatibility>
|
</compatibility>
|
||||||
<comments>This is the companion extension to SYSTOPIA's CiviProxy security system</comments>
|
<comments>This is the companion extension to SYSTOPIA's CiviProxy security system</comments>
|
||||||
<civix>
|
<civix>
|
||||||
<namespace>CRM/Civiproxy</namespace>
|
<namespace>CRM/Civiproxy</namespace>
|
||||||
<format>24.09.1</format>
|
|
||||||
</civix>
|
</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>
|
</extension>
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
<?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,78 +0,0 @@
|
||||||
<?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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
@ -51,8 +51,9 @@ $target_url = $target_civicrm . '/civicrm/mailing/url';
|
||||||
$target_open = $target_civicrm . '/civicrm/mailing/open';
|
$target_open = $target_civicrm . '/civicrm/mailing/open';
|
||||||
|
|
||||||
// CAUTION: use the following for CiviCRM < 5.27 or "Extern URL Style" = "Standalone Scripts"
|
// CAUTION: use the following for CiviCRM < 5.27 or "Extern URL Style" = "Standalone Scripts"
|
||||||
//$target_url = $target_civicrm . '/sites/all/modules/civicrm/extern/url.php';
|
#$target_url = $target_civicrm . '/sites/all/modules/civicrm/extern/url.php';
|
||||||
//$target_open = $target_civicrm . '/sites/all/modules/civicrm/extern/open.php';
|
#$target_open = $target_civicrm . '/sites/all/modules/civicrm/extern/open.php';
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
** GENERAL OPTIONS **
|
** GENERAL OPTIONS **
|
||||||
|
|
@ -96,23 +97,6 @@ if (file_exists(dirname(__FILE__)."/secrets.php")) {
|
||||||
require "secrets.php";
|
require "secrets.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parameter whitelisting for open tracking and URL tracking
|
|
||||||
// basic civicrm URL/open parameter are u, q and qid (as int)
|
|
||||||
// If additional parameters are needed, best practise would be to whitelist each one as needed in
|
|
||||||
// $valid_url_parameters and/or $valid_open_parameters.
|
|
||||||
// Alternatively it is also possible to allow all parameters with the wildcard parameter '*' => 'string'
|
|
||||||
$valid_url_parameters = [
|
|
||||||
'u' => 'int',
|
|
||||||
'q' => 'int',
|
|
||||||
'qid' => 'int',
|
|
||||||
// '*' => 'string' // whildcard, whitelist all url parameters
|
|
||||||
];
|
|
||||||
$valid_open_parameters = [
|
|
||||||
'u' => 'int',
|
|
||||||
'q' => 'int',
|
|
||||||
'qid' => 'int',
|
|
||||||
// '*' => 'string' // wildcard, whitelist *all* open parameters
|
|
||||||
];
|
|
||||||
// CiviCRM's API can authenticate with different flows
|
// CiviCRM's API can authenticate with different flows
|
||||||
// https://docs.civicrm.org/dev/en/latest/framework/authx/#flows
|
// https://docs.civicrm.org/dev/en/latest/framework/authx/#flows
|
||||||
// CiviProxy supports 'header', 'xheader', 'legacyrest', and 'param'.
|
// CiviProxy supports 'header', 'xheader', 'legacyrest', and 'param'.
|
||||||
|
|
|
||||||
|
|
@ -564,7 +564,7 @@ class Cache_Lite
|
||||||
*/
|
*/
|
||||||
function raiseError($msg, $code)
|
function raiseError($msg, $code)
|
||||||
{
|
{
|
||||||
return PEAR::raiseError($msg, $code, $this->_pearErrorMode);
|
error_log("[code] $msg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -638,7 +638,7 @@ class Cache_Lite
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!($dh = @opendir($dir))) {
|
if (!($dh = opendir($dir))) {
|
||||||
return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
|
return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
|
||||||
}
|
}
|
||||||
$result = true;
|
$result = true;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ civiproxy_security_check('mail-confirm');
|
||||||
// basic restraints
|
// basic restraints
|
||||||
$valid_parameters = array( 'sid' => 'int',
|
$valid_parameters = array( 'sid' => 'int',
|
||||||
'cid' => 'int',
|
'cid' => 'int',
|
||||||
'h' => 'string');
|
'h' => 'hex');
|
||||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||||
|
|
||||||
// check if parameters specified
|
// check if parameters specified
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ civiproxy_security_check('mail-resubscribe');
|
||||||
// basic restraints
|
// basic restraints
|
||||||
$valid_parameters = array( 'jid' => 'int',
|
$valid_parameters = array( 'jid' => 'int',
|
||||||
'qid' => 'int',
|
'qid' => 'int',
|
||||||
'h' => 'string');
|
'h' => 'hex');
|
||||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||||
|
|
||||||
// check if parameters specified
|
// check if parameters specified
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ civiproxy_security_check('mail-unsubscribe');
|
||||||
// basic restraints
|
// basic restraints
|
||||||
$valid_parameters = array( 'jid' => 'int',
|
$valid_parameters = array( 'jid' => 'int',
|
||||||
'qid' => 'int',
|
'qid' => 'int',
|
||||||
'h' => 'string');
|
'h' => 'hex');
|
||||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||||
|
|
||||||
// check if parameters specified
|
// check if parameters specified
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,11 @@ if (!$target_open) civiproxy_http_error("Feature disabled", 405);
|
||||||
// basic check
|
// basic check
|
||||||
civiproxy_security_check('open');
|
civiproxy_security_check('open');
|
||||||
|
|
||||||
$parameters = civiproxy_get_parameters($valid_open_parameters);
|
// basic restraints
|
||||||
|
$valid_parameters = [
|
||||||
|
'q' => 'int',
|
||||||
|
'qid' => 'int',
|
||||||
|
];
|
||||||
|
|
||||||
|
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||||
civiproxy_redirect($target_open, $parameters);
|
civiproxy_redirect($target_open, $parameters);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
+---------------------------------------------------------*/
|
+---------------------------------------------------------*/
|
||||||
|
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
$civiproxy_version = '1.0.0-beta';
|
$civiproxy_version = '0.7.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this will redirect the request to another URL,
|
* this will redirect the request to another URL,
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,10 @@ if (!$target_url) civiproxy_http_error("Feature disabled", 405);
|
||||||
// basic check
|
// basic check
|
||||||
civiproxy_security_check('url');
|
civiproxy_security_check('url');
|
||||||
|
|
||||||
$parameters = civiproxy_get_parameters($valid_url_parameters);
|
// basic restraints
|
||||||
|
$valid_parameters = array( 'u' => 'int',
|
||||||
|
'q' => 'int',
|
||||||
|
'qid' => 'int');
|
||||||
|
|
||||||
|
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||||
civiproxy_redirect($target_url, $parameters);
|
civiproxy_redirect($target_url, $parameters);
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ function webhook2api_processConfiguration($configuration, $post_input) {
|
||||||
}
|
}
|
||||||
if (!empty($result['values']['http_code'])) {
|
if (!empty($result['values']['http_code'])) {
|
||||||
$http_code = $result['values']['http_code'];
|
$http_code = $result['values']['http_code'];
|
||||||
} elseif ($result['is_error'] != 0) {
|
} else {
|
||||||
$http_code = 403;
|
$http_code = 403;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue