function build_email_body($params) { global $_journo; $data = journo_collectData($_journo); ob_start(); extract($data); include "../templates/journo_text.tpl.php"; $profile_text = ob_get_clean(); $body = "{$params['name']} sent this to you from " . OPTION_BASE_URL . "\n\n"; if ($params['message']) { $body .= "Note from {$params['name']}:\n"; $body .= $params['message']; $body .= "\n"; } $body .= str_repeat('-', 75) . "\n\n"; $body .= $profile_text; $body .= str_repeat('-', 75) . "\n"; $body .= "If you have any questions about this email, please contact " . OPTION_TEAM_EMAIL . "\n"; return $body; }
$json_quick = json_encode($data); /* mark journo as needing their page sorted out! */ db_do("UPDATE journo SET modified=true WHERE id=?", $journo['id']); /* save the quick-n-nasty data */ db_do("INSERT INTO htmlcache (name,content) VALUES(?,?)", $cacheid, $json_quick); db_commit(); } else { /* there is cached data - yay! */ $data = json_decode($cached_json, true); if ($can_edit_page && $journo['modified'] == 't') { /* journo is logged in and the page is out of date... * update the cached data with some fresh quick-n-nasty data * (which covers most of what a journo might be editing via their profile page, say) */ $old_quick_n_nasty = $data['quick_n_nasty']; $newdata = journo_collectData($journo, true); $data = array_merge($data, $newdata); /* if there was non-quick-n-nasty data there, this makes sure it'll still be used in the template */ $data['quick_n_nasty'] = $old_quick_n_nasty; /* store it in the cache for other users to enjoy too :-) */ $updated_json = json_encode($data); db_do("DELETE FROM htmlcache WHERE name=?", $cacheid); db_do("INSERT INTO htmlcache (name,content) VALUES(?,?)", $cacheid, $updated_json); db_commit(); } } } // HACK: // fields that we've recently added, which might not be in cached versions if (!array_key_exists('num_alerts', $data)) { $data['num_alerts'] = 0;