Commit ccce3d0b authored by Penny Leach's avatar Penny Leach
Browse files

beginnings (not finished and almost certainly broken) of emaildigest

plugin
parent 0094bc24
......@@ -9,7 +9,7 @@
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="type" TYPE="char" LENGTH="50" NOTNULL="true" />
<FIELD NAME="user" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="usr" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="message" TYPE="text" NOTNULL="true" />
<FIELD NAME="url" TYPE="text" NOTNULL="false" />
......@@ -17,7 +17,7 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="typefk" TYPE="foreign" FIELDS="type" REFTABLE="activity_type" REFFIELDS="name" />
<KEY NAME="userfk" TYPE="foreign" FIELDS="user" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="usrfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
......
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage notification-emaildigest
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['emailsubject'] = 'Message from Mahara: Daily digest';
$string['emailbodynoreply'] = "This is an auto generated notification from Mahara. Following is the daily digest of all your notifications\n\n--------------------------------------------------\n\n";
?>
\ No newline at end of file
......@@ -31,7 +31,62 @@ require_once(get_config('docroot') . 'notification/lib.php');
class PluginNotificationEmaildigest extends PluginNotification {
public static function notify_user($user, $data) {
// @todo
$toinsert = new StdClass;
$toinsert->type = $data->type;
$toinsert->usr = $user->id;
$toinsert->message = $data->message;
$toinsert->ctime = db_format_timestamp(time());
if (!empty($data->url)) {
$toinsert->url = $data->url;
}
insert_record('notification_emaildigest_queue', $toinsert);
}
public static function get_cron() {
$emaildigest = new StdClass;
$emaildigest->callfunction = 'send_digest';
$emaildigest->hour = '6';
return array($emaildigest);
}
public static function send_digest() {
$users = array();
$sql = 'SELECT u.firstname,u.lastname,u.prefname,u.email,q.*,' . db_format_tsfield('ctime').'
FROM ' . get_config('dbprefix') . 'usr u
JOIN ' . get_config('dbprefix') . 'notification_emaildigest_queue q
ON q.usr = u.id
ORDER BY usr,type,ctime';
if ($tosend = get_records_sql($sql);
foreach ($tosend as $queue) {
if (!isset($users[$queue->usr])) {
$users[$queue->usr] = new StdClass;
$users[$queue->usr]->user = new StdClass;
$users[$queue->usr]->user->firstname = $queue->firstname;
$users[$queue->usr]->user->lastname = $queue->lastname;
$users[$queue->usr]->user->prefname = $queue->prefname;
$users[$queue->usr]->user->email = $queue->email;
$users[$queue->usr]->user->id = $queue->usr;
$users[$queue->usr]->entries = array();
}
$queue->nicetype = get_string('type' . $queue->type, 'activity');
$users[$queue->usr]->entries[$queue->id] = $queue;
}
}
foreach ($users as $user) {
//delete_records_select('notification_emaildigest_queue', 'ctime <= ');
}
}
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2006102700;
$config->version = 2006110700;
$config->release = '0.1';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment