function createEmailFromTemplate($templateName, $user, $data = null) { global $APP_DIR; $email_config = getConfig("_email"); if (!$email_config || !$templateName || !$user) { return null; } $templateDir = $email_config["templates"]; $template = readTextFile("{$APP_DIR}/{$templateDir}/{$templateName}.html"); if (!$template) { return null; } $name = is_string($user) ? substringBefore($user, "@") : $user["first_name"] . " " . $user["last_name"]; $to_email = is_string($user) ? $user : $user["email"]; if (isset($email_config["to"])) { $to_email = $email_config["to"]; } $logo = combine($email_config["baseUrl"], getConfig("app.logo")); $cfg = array("site" => getConfig("defaultTitle"), "baseUrl" => $email_config["baseUrl"], "logo" => $logo, "name" => $name, "to" => $to_email); $template = replaceVariables($template, $cfg); $template = replaceVariables($template, $user); $template = replaceVariables($template, $data); $subject = substringBefore($template, "\n"); $body = substringAfter($template, "\n"); //replace classes with inlineStyles $styles = readConfigFile("{$APP_DIR}/{$templateDir}/inline.css"); if ($styles) { $body = "<div class=\"fp-email\">{$body}</div>"; $body = inlineStyles($body, $styles); } debug("createEmail subject", $subject); debug("createEmail body", $body); return createEmail($to_email, $subject, $body, true); }
function showlist($directory) { // this function can display sorted list of dirs and files if ($handle = opendir($directory)) { $countfile = "0"; while (false !== ($file = readdir($handle))) { $ext = strrchr($file, "."); if ($ext == ".csv" || $ext == ".CSV") { $filename[$countfile] = $file; $countfile++; //} } } closedir($handle); } if ($countfile != "0") { sort($filename); createEmail($filename, $countfile); } }
$nabStats[$level] = array(); } $nabStats[$level][] = $userId; } } //now check patrol foreach ($patrolLevels as $level) { if (checkLevel($level, $oldStats[$userId]['patrol'], $newStats[$userId]['patrol'])) { if ($patrolStats[$level] == null) { $patrolStats[$level] = array(); } $patrolStats[$level][] = $userId; } } } createEmail($editedStats, $createdStats, $nabStats, $patrolStats, $newStats, $startDate, $now); echo "\n\nFINISHED UPDATE\n\n"; return; } } } function createEmail(&$editedStats, &$createdStats, &$nabStats, &$patrolStats, &$stats, $startDate, $endDate) { $users = array(); $email = ""; $email = "Editor data from " . date("n/j/Y", wfTimestamp(TS_UNIX, $startDate)) . " to " . date("n/j/Y", wfTimestamp(TS_UNIX, $endDate)) . "<br /><br />"; ksort($editedStats); foreach ($editedStats as $level => $levelData) { $email .= "Edited - " . $level; $email .= "<ol>"; foreach ($levelData as $userId) {