X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffilter-functions.php;h=accd0c9475fa66feb6446ac8ea3ad754267a4e92;hb=ed91696103e27286d50d5dcd9e6b6a6184dd3f16;hp=d7479b1af35d28eae779b8342dde774362458d7a;hpb=63f159414369b5ea19a8ca75d8cd8033c45d8341;p=mailer.git diff --git a/inc/filter-functions.php b/inc/filter-functions.php index d7479b1af3..accd0c9475 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -48,13 +48,13 @@ function initFilterSystem () { reportBug(__FUNCTION__, __LINE__, 'Filter system already initialized.'); } // END - if - // Load all saved filers if sql_patches is updated + // Load all saved filers if ext-sql_patches is updated if ((isset($GLOBALS['cache_array']['filter']['filter_name'])) && (!isset($GLOBALS['cache_array']['filter']['chains']))) { // Prepare filter array prepareFilterArray(); // Mark it as initialized - $GLOBALS['filter_init'] = true; + $GLOBALS['filter_init'] = TRUE; } elseif ((!isInstallationPhase()) && (isExtensionInstalledAndNewer('sql_patches', '0.5.9'))) { // Init add $add = ''; @@ -85,7 +85,7 @@ ORDER BY $GLOBALS['cache_array']['filter']['counter'][$filterName][$filterFunction] = '0'; // Mark this filter as loaded (from database) - $GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction] = true; + $GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction] = TRUE; // Set this filter $GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction] = $filterArray['filter_active']; @@ -107,6 +107,7 @@ ORDER BY registerFilter(__FUNCTION__, __LINE__, 'init', 'INIT_RANDOMIZER'); registerFilter(__FUNCTION__, __LINE__, 'init', 'LOAD_RUNTIME_INCLUDES'); registerFilter(__FUNCTION__, __LINE__, 'init', 'INIT_EXTENSIONS'); + registerFilter(__FUNCTION__, __LINE__, 'init', 'INIT_SESSION'); registerFilter(__FUNCTION__, __LINE__, 'init', 'SET_CURRENT_DATE'); registerFilter(__FUNCTION__, __LINE__, 'init', 'INIT_RANDOM_NUMBER'); registerFilter(__FUNCTION__, __LINE__, 'init', 'CHECK_REPOSITORY_REVISION'); @@ -194,10 +195,17 @@ ORDER BY // Admin mail links registerFilter(__FUNCTION__, __LINE__, 'generate_admin_mail_links', 'GENERATE_POOL_MAIL_LINKS'); + + // Build mails + registerFilter(__FUNCTION__, __LINE__, 'send_build_mail', 'SEND_BUILD_MAIL'); + + // Handle referral banner click/view + registerFilter(__FUNCTION__, __LINE__, 'handle_click_php', 'HANDLE_REFERRER_BANNER_CLICK'); + registerFilter(__FUNCTION__, __LINE__, 'handle_view_php', 'HANDLE_REFERRER_BANNER_VIEW'); } // "Registers" a new filter function -function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = true, $force = false, $dry_run = false) { +function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = TRUE, $force = FALSE, $isDryRun = FALSE) { // Extend the filter function name $filterFunction = 'FILTER_' . strtoupper($filterFunction); @@ -205,24 +213,24 @@ function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = tr //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',F=' . basename($F) . ',L=' . $L . ' - ENTERED!'); // Is that filter already there? - if ((isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === false)) { + if ((isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === FALSE)) { // In installation phase we always want to abort - if (($silentAbort === false) || (isInstallationPhase())) { + if (($silentAbort === FALSE) || (isInstallationPhase())) { // Add fatal message reportBug(__FUNCTION__, __LINE__, sprintf("Filter chain %s has already filter function %s registered! F=%s,L=%s,force=%d", $filterName, $filterFunction, basename($F), $L, intval($force))); } // END - if // Abort here - return false; + return FALSE; } // END - if // Shall we add it? - if ($dry_run === false) { + if ($isDryRun === FALSE) { // Is the function there? if (!function_exists($filterFunction)) { // Then abort here addFatalMessage(__FUNCTION__, __LINE__, sprintf("Filter function %s could not be added to filter chain %s. F=%s,L=%s,force=%d", $filterFunction, $filterName, basename($F), $L, intval($force))); - return false; + return FALSE; } // END - if // Simply add it to the array @@ -235,8 +243,8 @@ function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = tr } // "Unregisters" a filter from the given chain -function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = false, $dry_run = false) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - ENTERED!'); +function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = FALSE, $isDryRun = FALSE) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',isDryRun=' . intval($isDryRun) . ' - ENTERED!'); // Extend the filter function name only if not loaded from database if (!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) { @@ -244,20 +252,20 @@ function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = false, } // END - if // Is that filter there? - if ((!isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === false)) { + if ((!isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === FALSE)) { // Not found, so abort here addFatalMessage(__FUNCTION__, __LINE__, sprintf(getMessage('FILTER_FAILED_NOT_REMOVED'), $filterFunction, $filterName)); - return false; + return FALSE; } // END - if // Shall we remove? (default, not while just showing an extension removal) - if ($dry_run === false) { + if ($isDryRun === FALSE) { // Mark for filter removal //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ' - REMOVE!'); $GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction] = 'R'; } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',isDryRun=' . intval($isDryRun) . ' - EXIT!'); } // "Runs" the given filters, filterData is optional and can be any type of data @@ -327,7 +335,7 @@ function prepareFilterArray () { // Abort here if array is absend (e.g. not cached) if (!isset($GLOBALS['cache_array']['filter']['filter_name'])) { // Abort silently - return false; + return FALSE; } // END - if // Init dummy array @@ -344,7 +352,7 @@ function prepareFilterArray () { // Add the element with mapped index $filterArray['counter'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_counter'][$idx]; - $filterArray['loaded'][$filterName][$filterFunction] = true; + $filterArray['loaded'][$filterName][$filterFunction] = TRUE; $filterArray['chains'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_active'][$idx]; } // END - foreach @@ -352,13 +360,21 @@ function prepareFilterArray () { $GLOBALS['cache_array']['filter'] = $filterArray; } -// Loads filter for given extension if present. This function will silently -// ignore absent filter files. +/** + * Loads filter for given extension if present. This function will silently + * ignore absent filter files. + * + * @param $ext_name Name of extension + * @return void + */ function loadExtensionFilters ($ext_name) { - // Do we have cache entry? + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - ENTERED!'); + + // Is there a cache entry? if (!isset($GLOBALS[__FUNCTION__][$ext_name])) { // Default is not found - $GLOBALS[__FUNCTION__][$ext_name] = false; + $GLOBALS[__FUNCTION__][$ext_name] = FALSE; // Construct include file name $incFileName = sprintf("inc/filter/%s_filter.php", $ext_name); @@ -369,12 +385,15 @@ function loadExtensionFilters ($ext_name) { loadIncludeOnce($incFileName); // Mark the file as loaded - $GLOBALS[__FUNCTION__][$ext_name] = true; + $GLOBALS[__FUNCTION__][$ext_name] = TRUE; } elseif (isDebugModeEnabled()) { // Log missing file - logDebugMessage(__FUNCTION__, __LINE__, 'Filter include file ' . $incFileName . ' for extension ' . $ext_name . ' is missing.'); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Filter include file ' . $incFileName . ' for extension ' . $ext_name . ' is missing.'); } } // END - if + + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',result=' . intval($GLOBALS[__FUNCTION__][$ext_name]) . ' - EXIT!'); } // [EOF]