function mail_pp($row, $cn, $pp, $action) { global $AUTH_uid; $uid = $AUTH_uid ? $AUTH_uid : core_getConfig("robotUID"); $tit = $action == "Reminder" ? "Preprint {$row['Status']} " . long_date_and_time_string((int) $row["Tm"]) . " (" . core_deltaTime(time(), (int) $row["Tm"]) . " ago) but has not being completed yet.\n\n" . "URL: " . mail_ppURL($row["RowId"]) : "Preprint {$action} " . long_date_and_time_string((int) $row["Tm"]); return join("\n", array($tit, "Number: {$pp}", "Field: " . $GLOBALS["NOR_fields"][$row["Field"]], "Owner: {$cn}", "Title: " . $row["Title"], "Authors: " . $row["Authors"], "{$action} by " . uid2gecos($uid))); }
function sendReminder() { global $dbClass, $row; $action = "reminder"; if ($_SESSION[$action][$action]++) { return; } $remindingPeriod = core_getConfig("remindingPeriod", 7 * 24 * 3600); // a week if ($q = getPendingPreprints("Tm < " . (time() - $remindingPeriod))) { while ($row = $dbClass->next_record($q)) { $pp = pp_preprintID($row["Year"], $row["Report"]); $gecos = uid2gecos($row["Id"]); if (core_getoption("CLI")) { print sprintf("%-15s %-25s %-15s %s \n", $pp, uid2login($row["Id"]), $gecos, long_date_and_time_string($row["Tm"])); } $l = $dbClass->query("SELECT * FROM " . PP_LOGTABLE . " WHERE text REGEXP '" . $pp . " ' " . "AND type = '" . $action . "' ORDER BY time DESC"); $tobeSent = !$dbClass->num_rows($l); while ($log = $dbClass->next_record($l)) { if ((int) $log["time"] > time() - $remindingPeriod) { break; } $tobeSent = True; } if ($tobeSent) { logIt($action, $pp, $gecos); mailReminder(); } } } }