
Op Jochus.be maakte ik vroeger gebruik van JEvents als agenda (in combinatie met Joomla!). Zo kan ik gemakkelijk overal zien wat ik komende dagen/maanden/... gepland heb. Op de dag van vandaag gebruik ik de GUI van Google Agenda itself. De Google Agenda is trouwens perfect synchroniseerbaar met elk device (computer, smartphone, ...).
Bij het publishen van een nieuw "event" bij JEvents, wordt er een mail verstuurd. Deze mail kan echter maar naar één gebruiker gestuurd worden, de admin. Bovendien was de opmaak van de mail alles behalve deftig. Daarom heb ik besloten de code te herschrijven. Opmerkingen zijn altijd welkom, ik heb niet alles aangepast om de Joomla! standaarden wat te behouden, but feel free to copy :-).
Originele code
function sendAdminMail( $adminName, $adminEmail, $subject='', $title='', $content='', $author='', $live_site, $modifylink ) {
if (!$adminEmail) return;
$htmlmail = true;
$lf = ($htmlmail === true) ? '<br />' : '\r\n';
$content = 'Title: ' . $title . $lf.$lf . $content;
$content .= $lf.$lf. sprintf( _CAL_LANG_MAIL_TO_ADMIN, $live_site, $author );
$content .= $lf . 'Edit : ' . $modifylink;
// mail function
//mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $subject, $msg );
mosMail( $adminEmail, $adminName, $adminEmail, $subject, $content, $htmlmail );
}
Aangepaste code
function sendAdminMail( $adminName, $adminEmail, $subject='', $title='', $content='', $author='', $live_site, $modifylink, $publishtime, $location, $catid, $db ) {
// SETUP MAIL
if (!$adminEmail) {
return;
}
$htmlmail = true;
$lf = ($htmlmail === true) ? '<br/>' : '\r\n';
// CHECK FOR SQL INJECTION
$catid_checked = do_sql_injection($catid);
// PREPARING DATA
$query = "SELECT title FROM mos_categories WHERE id = '$catid_checked'";
$db->setQuery($query);
$resultset = $db->query();
$data = mysql_fetch_array($resultset);
// SET CONTENT
$content = '<b>Title:</b> ' . $title;
$content .= $lf . '<b>From: </b>' . $author ;
$content .= $lf . '<b>Date: </b>' . $publishtime;
$content .= $lf . '<b>Location : </b>' . $location;
$content .= $lf . '<b>Category : </b>' . $data['title'];
$content .= $lf . '<b>Edit : </b>' . $modifylink;
// SET EMAIL ACCOUNTS
$listEmails = array();
$listEmails[0] = $adminEmail;
$listEmails[1] = "<a href="mailto:some@mail.com">some@mail.com</a>";
$subject = "[Jochus.be] New submission: " . $title;
// JOOMLA MAIL FUNCTION
mosMail( $adminEmail, $adminName, $listEmails, $subject, $content, $htmlmail );
}