updated mailgun, mailsystem, honeypot, googleanalitycs, features, content_taxonomy

This commit is contained in:
2019-05-13 17:55:28 +02:00
parent 2ffad14939
commit e08a2639c6
54 changed files with 1911 additions and 423 deletions

View File

@@ -132,15 +132,23 @@ function mailsystem_create_class($classes) {
}
$class_name = implode('__', $classes);
// Ensure that the mailsystem directory exists.
$class_dir = file_build_uri('mailsystem');
if (!file_prepare_directory($class_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
// First we try the private filesystem.
$private_files = variable_get('file_private_path', '');
$private_files_full = $private_files . '/mailsystem';
$public_files = variable_get('file_public_path', conf_path() . '/files');
$public_files_full = $public_files . '/mailsystem';
if ($private_files && file_prepare_directory($private_files_full, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$class_dir = $private_files . '/mailsystem';
}
// If private filesystem is not defined or writable, we use the public filesystem.
elseif (file_prepare_directory($public_files_full, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$class_dir = $public_files . '/mailsystem';
}
else {
return FALSE;
}
// Build the class filename.
$class_file = drupal_realpath($class_dir) . DIRECTORY_SEPARATOR . "$class_name.mail.inc";
// Strip DRUPAL_ROOT.
$drupal_root = drupal_realpath(DRUPAL_ROOT) . DIRECTORY_SEPARATOR;
$class_file = preg_replace('#^' . preg_quote($drupal_root, '#') . '#', '', $class_file);
$class_file = $class_dir . DIRECTORY_SEPARATOR . "$class_name.mail.inc";
// Build the class implementation as a string.
$class_contents = '<?php
class ' . $class_name . ' implements MailSystemInterface {';
@@ -181,17 +189,19 @@ class ' . $class_name . ' implements MailSystemInterface {';
$file_condition = db_and()
->condition('filename', $class_file);
db_delete('registry_file')
->condition($file_condition);
->condition($file_condition)
->execute();
db_delete('registry')->condition(
db_or()->condition($class_condition)
->condition($file_condition)
);
)->execute();
// Make sure that registry functions are available.
require_once 'includes/registry.inc';
// Parse the newly-created class file and add it to the registry.
_registry_parse_file($class_file, $class_contents, 'mailsystem');
// Clear the mailsystem cache so that it will pick up the new class.
// Clear the mailsystem caches so that it will pick up the new class.
drupal_static_reset('mailsystem_get_classes');
cache_clear_all('mailsystem_get_classes', 'cache');
drupal_set_message(
t('Class <code>%class</code> written to <code>%file</code>.',
array('%class' => $class_name, '%file' => $class_file)
@@ -257,7 +267,13 @@ function mailsystem_clear(array $setting) {
* Returns a list of classes which implement MailSystemInterface.
*/
function &mailsystem_get_classes() {
// Load static cache.
$mailsystem_classes = &drupal_static(__FUNCTION__);
// Check persistent cache if necessary.
if (!isset($mailsystem_classes) && $cache = cache_get('mailsystem_get_classes')) {
$mailsystem_classes = $cache->data;
}
// Load from db if no cache was hit.
if (!isset($mailsystem_classes)) {
$mailsystem_classes = array();
// @todo Is there a better way to find all mail-related classes?
@@ -282,14 +298,14 @@ function &mailsystem_get_classes() {
->execute()
->fetchAllKeyed();
foreach ($mail_classes as $classname => $classfile) {
if ( file_exists($classfile)
if (file_exists($classfile)
&& drupal_autoload_class($classname)
) {
$all_classes[$classname] = 1;
}
}
foreach ($all_classes as $classname => $autoload) {
if ( ($autoload || preg_match('/MailSystem/', $classname))
if (($autoload || preg_match('/MailSystem/', $classname))
&& ($object = new $classname)
&& ($object instanceof MailSystemInterface)
) {
@@ -311,6 +327,8 @@ function &mailsystem_get_classes() {
}
}
ksort($mailsystem_classes);
// Store in persistent cache.
cache_set('mailsystem_get_classes', $mailsystem_classes, 'cache', CACHE_TEMPORARY);
}
return $mailsystem_classes;
}
@@ -324,10 +342,10 @@ function mailsystem_theme_registry_alter(&$theme_registry) {
}
/**
* Retrieves the key of the theme used to render the emails.
*
* @todo Add some kind of hook to let other modules alter this behavior.
*/
* Retrieves the key of the theme used to render the emails.
*
* @todo Add some kind of hook to let other modules alter this behavior.
*/
function mailsystem_get_mail_theme() {
global $theme_key;
$theme = variable_get('mailsystem_theme', 'current');
@@ -335,9 +353,11 @@ function mailsystem_get_mail_theme() {
case 'default':
$theme = variable_get('theme_default', NULL);
break;
case 'current':
$theme = $theme_key;
break;
case 'domain':
// Fetch the theme for the current domain.
if (module_exists('domain_theme')) {