Skip to content

Commit

Permalink
Fixed pgsql issue
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Sep 25, 2023
1 parent b153e29 commit c7c0e33
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 50 deletions.
2 changes: 1 addition & 1 deletion actions/notification/amd/build/chaptersource.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actions/notification/amd/build/chaptersource.min.js.map

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions actions/notification/amd/src/chaptersource.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,24 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/modal_factory', 'core/
}

var dynamicparams = {};
var formData;

if (document.querySelector('[name=pulsenotification_dynamiccontent]') !== null) {
dynamicparams = {
contentdynamic: document.querySelector('[name=pulsenotification_dynamiccontent]').value,
contenttype: document.querySelector('[name=pulsenotification_contenttype]').value,
chapterid: document.querySelector('[name=pulsenotification_chapterid]').value,
contentlength: document.querySelector('[name=pulsenotification_contentlength]').value,
};

// Get the form data.
var form = document.forms['pulse-automation-template'];
var formdata = new FormData(form);
formdata = new URLSearchParams(formdata).toString();
formData = {
formdata: formdata
};
}
// Get the form data.
var formData;
var form = document.forms['pulse-automation-template'];
var formdata = new FormData(form);
formdata = new URLSearchParams(formdata).toString();
formData = {
formdata: formdata
};

var finalParams = {...params, ...dynamicparams, ...formData};

return Fragment.loadFragment('pulseaction_notification', 'preview_content', contextID, finalParams);
Expand Down
4 changes: 2 additions & 2 deletions actions/notification/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<FIELD NAME="contenttype" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="footercontent" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="footercontentformat" TYPE="int" LENGTH="9" NOTNULL="false" DEFAULT="1" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="datetime" NOTNULL="false" DEFAULT="current_timestamp()" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="11" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="templateid" TYPE="unique" FIELDS="templateid"/>
Expand Down Expand Up @@ -63,7 +63,7 @@
<FIELD NAME="contenttype" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="chapterid" TYPE="int" LENGTH="9" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="footercontent" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="datetime" NOTNULL="false" DEFAULT="current_timestamp()" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="11" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="id" TYPE="primary" FIELDS="id"/>
Expand Down
11 changes: 6 additions & 5 deletions actions/notification/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ function pulseaction_notification_output_fragment_preview_instance_content($args
function pulseaction_notification_output_fragment_preview_content($args) {
global $OUTPUT;

$coursecontext = $args['context'];

if (isset($args['contentheader'])) {
$courseid = $args['courseid'] ?? $coursecontext->instanceid;
$course = get_course($courseid ?: SITEID);

parse_str($args['formdata'], $formdata);
$courseid = $formdata['courseid'] ?? SITEID;
$course = get_course($courseid);
$coursecontext = context_course::instance($courseid);

// Get the enrolled users for this course.
$users = get_enrolled_users($coursecontext);
Expand Down Expand Up @@ -165,7 +166,7 @@ function pulseaction_notification_output_fragment_preview_content($args) {
$mod = current($modules[$modname]);
}
// Check the session condition are set for this notification. if its added then load the session data for placeholders.
parse_str($args['formdata'], $formdata);

$sessionincondition = in_array('session', (array) array_keys($formdata['condition']));
if ($sessionincondition && $formdata['condition']['session']['status']) {
$sessionconditiondata = (object) ['modules' => $formdata['condition']['session']['modules']];
Expand Down
2 changes: 1 addition & 1 deletion actions/notification/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = "pulseaction_notification";
$plugin->version = 2023080407;
$plugin->version = 2023080408;
16 changes: 11 additions & 5 deletions automation/templates/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,25 @@
// Automation template ID to edit.
$id = optional_param('id', null, PARAM_INT);

// Extend the features of admin settings.
admin_externalpage_setup('pulseautomation');

// Page values.
$url = new moodle_url('/mod/pulse/automation/templates/edit.php', ['id' => $id, 'sesskey' => sesskey()]);

// Setup page values.
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_heading(get_string('autotemplates', 'pulse'));

if (is_siteadmin()) {
// Extend the features of admin settings.
admin_externalpage_setup('pulseautomation');
$PAGE->set_heading(get_string('autotemplates', 'pulse'));
$moduleurl = new moodle_url('/admin/category.php?category=modsettings');
$PAGE->navbar->add(get_string('activity', 'core'), $moduleurl);
} else {
$moduleurl = new moodle_url('/user/profile.php');
$PAGE->navbar->add(get_string('profile', 'core'), $moduleurl);
}

// PAGE breadcrumbs.
$PAGE->navbar->add(get_string('mycourses', 'core'), new moodle_url('/course/index.php'));
$PAGE->navbar->add(get_string('autotemplates', 'pulse'), new moodle_url('/mod/pulse/automation/templates/list.php'));
$PAGE->navbar->add(get_string('edit'));

Expand Down
22 changes: 17 additions & 5 deletions automation/templates/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@
// Page values.
$context = \context_system::instance();

admin_externalpage_setup('pulseautomation');
if (is_siteadmin()) {
// Setup breadcrumps.
admin_externalpage_setup('pulseautomation');
}

// Verify the user capability.
require_capability('mod/pulse:addtemplate', $context);
require_capability('mod/pulse:viewtemplateslist', $context);

// Prepare the page.
$PAGE->set_context($context);
$PAGE->set_url(new moodle_url('/mod/pulse/automation/templates/list.php'));

// TODO: Capability checks.

// Process actions.
if ($action !== null && confirm_sesskey()) {
// Every action is based on a template, thus the template ID param has to exist.
Expand Down Expand Up @@ -101,6 +102,14 @@
// Further prepare the page.
$PAGE->set_heading(get_string('autotemplates', 'pulse'));

// Add breadcrumbs for the non admin users, has the capability to view templates.
if (!is_siteadmin()) {
// PAGE breadcrumbs.
$PAGE->navbar->add(get_string('profile', 'core'), new moodle_url('/user/profile.php'));
$PAGE->navbar->add(get_string('autotemplates', 'pulse'), new moodle_url('/mod/pulse/automation/templates/list.php'));
$PAGE->navbar->add(get_string('list'));
}

// Build automation templates table.
$filterset = new mod_pulse\table\automation_filterset;

Expand All @@ -118,7 +127,10 @@

// Start page output.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('autotemplates', 'pulse'));
// Display the heading only for admin users.
if (is_siteadmin()) {
echo $OUTPUT->heading(get_string('autotemplates', 'pulse'));
}

// Show templates description.
echo get_string('autotemplates_desc', 'pulse');
Expand Down
2 changes: 1 addition & 1 deletion classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static function convert_varstime_format(&$var) {
array_walk($var, function(&$value, $key) {
if (in_array(strtolower($key), ['timecreated', 'timemodified', 'startdate', 'enddate', 'firstaccess',
'lastaccess', 'lastlogin', 'currentlogin', 'timecreated', 'starttime', 'endtime'])) {
$value = userdate($value);
$value = $value ? userdate($value) : '';
}
// Update the status to user readable strings.
if (in_array(strtolower($key), ['visible', 'groupmode', 'groupmodeforce', 'defaultgroupingid', 'enablecompletion'])) {
Expand Down
27 changes: 12 additions & 15 deletions classes/table/auto_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,18 @@ public function col_actions($row) {
public function edit_switch($row) {
global $PAGE, $OUTPUT;

if ($PAGE->user_allowed_editing()) {

$temp = (object) [
'legacyseturl' => (new moodle_url('/mod/pulse/automation/templates/list.php', [
'id' => $row->id,
'sesskey' => sesskey()
]))->out(false),
'pagecontextid' => $PAGE->context->id,
'pageurl' => $PAGE->url,
'sesskey' => sesskey(),
'checked' => $row->status,
'id' => $row->id
];
return $OUTPUT->render_from_template('pulse/status_switch', $temp);
}
$temp = (object) [
'legacyseturl' => (new moodle_url('/mod/pulse/automation/templates/list.php', [
'id' => $row->id,
'sesskey' => sesskey()
]))->out(false),
'pagecontextid' => $PAGE->context->id,
'pageurl' => $PAGE->url,
'sesskey' => sesskey(),
'checked' => $row->status,
'id' => $row->id
];
return $OUTPUT->render_from_template('pulse/status_switch', $temp);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion lang/en/pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
$string['pulse:addtemplate'] = 'Add a new automation template';
$string['pulse:viewtemplateslist'] = 'View the automation templates list';
$string['pulse:addtemplateinstance'] = 'Add a new template instance';
$string['mod/pulse:sender'] = 'Notification sender user';
$string['pulse:sender'] = 'Notification sender user';

// ...Templates list string.
$string['autotemplates'] = 'Automation templates';
Expand Down Expand Up @@ -367,3 +367,6 @@
$string['automationinstance_help6'] = 'Duplicate the automation';
$string['automationinstance_help7'] = 'Open the automation queue (in the report builder), which provides information about all the automations that ran.';
$string['automationinstance_help8'] = 'Use this toggle to turn on or off the automation instance locally. This will override the status of the template, i.e. even if the template is turned off, it can be enabled.';

// Pulse automation template profile navigation link.
$string['pulsetemplink'] = "Pulse Automation Template";
36 changes: 36 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @copyright 2021, bdecent gmbh bdecent.de
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_user\output\myprofile\tree;

defined( 'MOODLE_INTERNAL') || die(' No direct access ');

Expand Down Expand Up @@ -668,3 +669,38 @@ function mod_pulse_extend_navigation_course(navigation_node $navigation, stdClas
$PAGE->requires->js_call_amd('mod_pulse/automation', 'instanceMenuLink', []);
}
}

/**
* Defines pulse automation template list nodes for my profile navigation tree.
*
* @param \core_user\output\myprofile\tree $tree Tree object
* @param stdClass $user user object
* @param bool $iscurrentuser is the user viewing profile, current user ?
* @param stdClass $course course object
*
* @return bool
*/
function mod_pulse_myprofile_navigation(tree $tree, $user, $iscurrentuser, $course) {
global $USER;

// Get the pulse category.
if (!array_key_exists('pulse', $tree->__get('categories'))) {
// Create the category.
$categoryname = get_string('pluginname', 'mod_pulse');
$category = new core_user\output\myprofile\category('pulse', $categoryname, 'privacyandpolicies');
$tree->add_category($category);
} else {
// Get the existing category.
$category = $tree->__get('categories')['pulse'];
}

if ($iscurrentuser) {
$systemcontext = \context_system::instance();
if (has_capability('mod/pulse:viewtemplateslist', $systemcontext)) {
$automationtemplate = new moodle_url('/mod/pulse/automation/templates/list.php');
$pulsenode = new core_user\output\myprofile\node('pulse', 'pulse',
get_string('pulsetemplink', 'mod_pulse'), null, $automationtemplate);
$tree->add_node($pulsenode);
}
}
}
Loading

0 comments on commit c7c0e33

Please sign in to comment.