Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
[code:1]<?xml version="1.0" encoding="utf-8"?>
<install version="1.5.2" type="plugin" group="system">
<name>System-Send Email</name>
<author>name</author>
<creationDate>December 2009</creationDate>
<copyright>Copyright (C) 2009 Holder. All rights reserved.</copyright>
<license>GNU General Public License</license>
<authorEmail>email</authorEmail>
<authorUrl>url</authorUrl>
<version>1.0.1</version>
<description>Provides email functionality</description>
<files>
<filename plugin="email">sendemail.php</filename>
</files>
<params>
</params>
</install>[/code:1]
[code:1]<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
//$mainframe->registerEvent( 'sendEmail', 'plgContentSendEmail' );
/**
* Example system plugin
*/
class plgSystemSendEmail extends JPlugin
{
/**
* Constructor
*
* For php4 compatibility we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
/**
* Do something onAfterInitialise
*/
function plgSystemSendEmail(& $subject, $config) {
parent::__construct($subject, $config);
}
function onAfterInitialise()
{
global $mainframe;
$user = &JFactory::getUser();
$days_before = '7';
$days_after = '1';
$query= 'SELECT `id` AS `id`, `name` AS `name`, `cb_birthday` AS `birthday`,u.email as email FROM `#__users` b WHERE b.`cb_birthday` <> '' AND b.`cb_birthday` IS NOT NULL AND b.`cb_birthday` <> 0 AND b.block = 0';
$db->setQuery($query);
$rows = $db->loadAssocList();
if ($db->getErrorMsg())
{
JError::handleLog(JError::raiseWarning($db->getErrorNum(), $db->getErrorMsg()) , null);
return null;
}
$day=date(D);
list = array();
foreach ($rows as $row) {
$birthday = &JFactory::getDate($row);
$age = (int)round(($today->toUnix() - $birthday->toUnix()) / (365 * 24 * 60 * 60));
$birthday_details = getdate($birthday->toUnix());
$new_birthday = &JFactory::getDate(mktime(0, 0, 0, $birthday_details, $birthday_details, $birthday_details + $age));
$days_left = (int)round(($new_birthday->toUnix() - $today->toUnix()) / (24 * 60 *60));
if (($days_left <= $days_before) && ($days_left >= -$days_after)) {
$list[(200 + $days_left).'_'.$row['name']] = array('id' => $row, 'name' => $row, 'birthday' => $birthday, 'new_birthday' => $new_birthday, 'age' => $age, 'days_left' => $days_left);
$to.=$row.",";
}
//print_r($user);
if($day=='Sat')
{
echo $to;
$header="\r\n";
$from='';
$subject="Happy Birthday";
$body="Happy Birthday";
if($bcc!=""«»)
{
$header="Bcc: ".$bcc." ". "\r\n";
}
$header.='MIME-Version: 1.0' . "\r\n".'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $body, "From:".$from.$header);
}
// Perform some action
}
}
?>[/code:1]
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.