123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- function html_email_handler_email_hook($hook, $type, $return_value, $params) {
- static $plugin_setting;
-
- if (!isset($plugin_setting)) {
- $plugin_setting = false;
-
-
- if (elgg_get_plugin_setting("notifications", "html_email_handler") == "yes") {
- $plugin_setting = true;
- }
- }
-
- if (!$plugin_setting) {
- return $return_value;
- }
-
-
- if (empty($return_value) || !is_array($return_value)) {
- return $return_value;
- }
-
- $additional_params = elgg_extract("params", $return_value);
- if (is_array($additional_params)) {
- $return_value = array_merge($return_value, $additional_params);
- }
-
- return html_email_handler_send_email($return_value);
- }
- function html_email_handler_daily_cron_hook($hook, $type, $return, $params) {
-
- if (empty($params) || !is_array($params)) {
- return $return;
- }
-
- $cache_dir = elgg_get_config("dataroot") . "html_email_handler/image_cache/";
- if (!is_dir($cache_dir)) {
- return $return;
- }
-
- $dh = opendir($cache_dir);
- if (empty($dh)) {
- return $return;
- }
-
- $max_lifetime = elgg_extract("time", $params, time()) - (24 * 60 * 60);
-
- while (($filename = readdir($dh)) !== false) {
-
- if (!is_file($cache_dir . $filename)) {
- continue;
- }
-
- $modified_time = filemtime($cache_dir . $filename);
- if ($modified_time > $max_lifetime) {
- continue;
- }
-
-
- unlink($cache_dir . $filename);
- }
-
- closedir($dh);
-
- return $return;
- }
|