Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new logging API support. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions classes/event/notification_send.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* The EVENTNAME event.
*
* @package FULLPLUGINNAME
* @copyright 2014 YOUR NAME
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_resourcenotif\event;
defined('MOODLE_INTERNAL') || die();

class notification_send extends \core\event\base
{
protected function init()
{
$this->data['crud'] = 'w'; // c(reate), r(ead), u(pdate), d(elete)
$this->data['edulevel'] = self::LEVEL_OTHER;
}

public static function get_name()
{
return get_string('event', 'local_resourcenotif');
}

public function get_description()
{
return $this->other['message'];
}
}
1 change: 1 addition & 0 deletions lang/en/local_resourcenotif.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$string['allstudentrecipient'] = 'This message will be sent to all users enrolled to this course ({$a}).';
$string['body'] = 'Message body: ';
$string['complement'] = 'Message complement: ';
$string['event'] = 'Notification send';
$string['grouprecipient'] = 'The following message will be sent to users permitted to view <a href="{$a->linkactivity}">{$a->nameactivity}</a> ({$a->nbdest}).';
$string['nomessagesend'] = 'No sent message.';
$string['norecipient'] = 'No recipient.';
Expand Down
1 change: 1 addition & 0 deletions lang/fr/local_resourcenotif.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$string['allstudentrecipient'] = 'Le message suivant sera transmis aux utilisateurs inscrits à ce cours ({$a}).';
$string['body'] = 'Corps du message : ';
$string['complement'] = 'Complément de message : ';
$string['event'] = 'Notification envoyer';
$string['grouprecipient'] = 'Le message suivant sera transmis aux utilisateurs concernés par <a href="{$a->linkactivity}">{$a->nameactivity}</a> ({$a->nbdest}).';
$string['nomessagesend'] = 'Aucun message envoyé.';
$string['norecipient'] = 'Aucun destinataire';
Expand Down
18 changes: 16 additions & 2 deletions lib_resourcenotif.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,27 @@ function resourcenotif_send_notification($users, $msg, $infolog) {
* @return string message interface
*/
function resourcenotif_get_result_action_notification($infolog) {
global $CFG;

if ($infolog['nb'] == 0) {
return get_string('nomessagesend', 'local_resourcenotif');
}
$message = get_string('numbernotification', 'local_resourcenotif', $infolog['nb']);
//log
add_to_log($infolog['courseid'], 'resourcenotif', 'send notification_course',
$infolog['cmurl'], $message , $infolog['cmid'], $infolog['userid']);
if ($CFG->version > 2014051200) { // Moodle 2.7+
$event = \local_resourcenotif\event\notification_send::create(array(
'courseid' => $infolog['courseid'],
'userid' => $infolog['userid'],
'context' => context_module::instance( $infolog['cmid'] ),
'other' => array(
'message' => $message
)
));
$event->trigger();
}else{
add_to_log($infolog['courseid'], 'resourcenotif', 'send notification_course',
$infolog['cmurl'], $message , $infolog['cmid'], $infolog['userid']);
}
return $message;
}

Expand Down