* @param string $action view, edit, post (often but not always the same as the file.php)
* @param string $url the file and parameters used to see the results of the action
* @param string $info additional description information
+* @param string $user optional, if log regards $user other than $USER
*/
-function add_to_log($courseid, $module, $action, $url="", $info="") {
+function add_to_log($courseid, $module, $action, $url="", $info="", $user="") {
global $db, $CFG, $USER, $REMOTE_ADDR;
- if (isset($USER->realuser)) { // Don't log
- return;
+ if ($user) {
+ $userid = $user;
+ } else {
+ if (isset($USER->realuser)) { // Don't log
+ return;
+ }
+ $userid = empty($USER->id) ? "" : $USER->id;
}
- $userid = empty($USER->id) ? "" : $USER->id;
-
$timenow = time();
$info = addslashes($info);
if (!$result and ($CFG->debug > 7)) {
echo "<P>Error: Could not insert a new entry to the Moodle log</P>"; // Don't throw an error
}
+ if (!$user) {
+ if (isstudent($courseid)) {
+ $db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
+ "WHERE course = '$courseid' AND userid = '$userid'");
+ }
- if (isstudent($courseid)) {
- $db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
- "WHERE course = '$courseid' AND userid = '$userid'");
- }
-
- if (isteacher($courseid, false, false)) {
- $db->Execute("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$timenow' ".
- "WHERE course = '$courseid' AND userid = '$userid'");
- }
+ if (isteacher($courseid, false, false)) {
+ $db->Execute("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$timenow' ".
+ "WHERE course = '$courseid' AND userid = '$userid'");
+ }
+ }
}
if ($oldversion < 2004012900) {
table_column("config", "value", "value", "text", "", "", "");
}
+
+ if ($oldversion < 2004013000) {
+ table_column("forum_posts", "mailed", "mailed", "tinyint", "2");
+ }
return $result;
if ($oldversion < 2004012900) {
table_column("config", "value", "value", "text", "", "", "");
}
-
+
+ if ($oldversion < 2004013000) {
+ table_column("forum_posts", "mailed", "mailed", "tinyint", "2");
+ }
+
return $result;
}
$canunsubscribe = ! forum_is_forcesubscribed($forum->id);
$mailcount=0;
+ $errorcount=0;
foreach ($users as $userto) {
if ($groupmode) { // Look for a reason not to send this email
if (!isteacheredit($course->id, $userto->id)) {
if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml)) {
echo "Error: mod/forum/cron.php: Could not send out mail for id $post->id to user $userto->id ($userto->email) .. not trying again.\n";
+ add_to_log($course->id, 'forum', 'mail error', "discuss.php?d=$discussion->id#$post->id", substr($post->subject,0,15), $userto->id);
+ $errorcount++;
} else {
$mailcount++;
}
}
echo ".... mailed to $mailcount users.\n";
+ if ($errorcount) {
+ set_field("forum_posts", "mailed", "2", "id", "$post->id");
+ }
}
}
}
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2004012900; // The current version is a date (YYYYMMDDXX)
+$version = 2004013000; // The current version is a date (YYYYMMDDXX)
$release = "1.2 development"; // User-friendly version number