TF Learn (Tech Fry) + techfry library 1.3.4; login-gated, no repo -> deployed files. Signed-off-by: LÁZÁR Imre <imre@illusion.hu> Assisted-by: claude-code@claude-opus-4-8
70 lines
1.4 KiB
PHP
70 lines
1.4 KiB
PHP
<?php
|
|
/*
|
|
* @package Tech Fry Library
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
*/
|
|
|
|
namespace TechFry\Library;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
class TfNotify
|
|
{
|
|
// 1. Send emmail notification to admin
|
|
public static function notify_admin($subject, $body, $options = array())
|
|
{
|
|
// $body can be string, array or object
|
|
|
|
if (is_object($body))
|
|
{
|
|
$body = (array) $body;
|
|
}
|
|
|
|
$mailer = Factory::getMailer();
|
|
|
|
// Recipient
|
|
if (isset($options['to_address']))
|
|
{
|
|
$mailer->addRecipient($options['to_address']);
|
|
}
|
|
else
|
|
{
|
|
$config = Factory::getConfig();
|
|
$to_name = $config->get('fromname');
|
|
$to_address = $config->get('mailfrom');
|
|
$mailer->addRecipient($to_address);
|
|
}
|
|
|
|
// Subject
|
|
$mailer->setSubject($subject);
|
|
|
|
// Reply to email
|
|
if (isset($options['reply_to']))
|
|
{
|
|
$mailer->addReplyTo($options['reply_to']);
|
|
}
|
|
|
|
// Body
|
|
$email_body = '';
|
|
if (is_array($body))
|
|
{
|
|
foreach ($body as $k => $v)
|
|
{
|
|
$email_body .= '<p><strong>' . $k . '</strong>: ' . $v . '</p>';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$email_body = $body;
|
|
}
|
|
|
|
$mailer->setBody($email_body);
|
|
|
|
$mailer->isHtml(true);
|
|
$mailer->Encoding = 'base64';
|
|
|
|
$mailer->send();
|
|
}
|
|
} |