public function message($changelist, $course) { global $CFG; $charmax = 160; $events = report_eventlist_list_generator::get_all_events_list(); $smsbody = ''; foreach ($changelist as $item) { $smsbody .= preg_replace('/\\\\.*$/', '', $events[$item->event]['raweventname']) . ': '; $smsbody .= $item->name . "\r\n"; } return $smsbody; }
function content_unlock_generate_events_list($showeventname = false) { global $DB; $eventsarray = array(); $eventsarray['\\block_game_content_unlock\\event\\content_unlocked'] = $showeventname === true ? \block_game_content_unlock\event\content_unlocked::get_name() . " (\\block_game_content_unlockvent\\content_unlocked)" : \block_game_content_unlock\event\content_unlocked::get_name(); $game_achievements_installed = $DB->record_exists('block', array('name' => 'game_achievements')); if ($game_achievements_installed) { $eventsarray['\\block_game_achievements\\event\\achievement_reached'] = $showeventname === true ? \block_game_achievements\event\achievement_reached::get_name() . " (\\block_game_achievementsvent\\achievement_reached)" : \block_game_achievements\event\achievement_reached::get_name(); } $game_points_installed = $DB->record_exists('block', array('name' => 'game_points')); if ($game_points_installed) { $eventsarray['\\block_game_points\\event\\points_earned'] = $showeventname === true ? \block_game_points\event\points_earned::get_name() . " (\\block_game_pointsvent\\points_earned)" : \block_game_points\event\points_earned::get_name(); } $eventslist = report_eventlist_list_generator::get_non_core_event_list(); foreach ($eventslist as $value) { $description = explode("\\", explode(".", strip_tags($value['fulleventname']))[0]); $eventsarray[$value['eventname']] = $showeventname === true ? $description[0] . " (" . $value['eventname'] . ")" : $description[0]; } return $eventsarray; }
// 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/>. /** * Event documentation. * * @package report_eventlist * @copyright 2014 Adrian Greeve <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once __DIR__ . '/../../config.php'; require_once $CFG->libdir . '/adminlib.php'; admin_externalpage_setup('reporteventlists'); // Retrieve all events in a list. $completelist = report_eventlist_list_generator::get_all_events_list(); $tabledata = array(); $components = array('0' => get_string('all', 'report_eventlist')); $edulevel = array('0' => get_string('all', 'report_eventlist')); $crud = array('0' => get_string('all', 'report_eventlist')); foreach ($completelist as $value) { $components[] = $value['component']; $edulevel[] = $value['edulevel']; $crud[] = $value['crud']; $tabledata[] = (object) $value; } $components = array_unique($components); $edulevel = array_unique($edulevel); $crud = array_unique($crud); // Create the filter form for the table. $filtersection = new report_eventlist_filter_form(null, array('components' => $components, 'edulevel' => $edulevel, 'crud' => $crud));
$eventinformation['typeparameter'] = array(); foreach ($typeparams[2] as $typeparameter) { $eventinformation['typeparameter'][] = $typeparameter; } } // Retrieving the 'other' event field information. $otherpattern = "/(\\*\\s{5}-([\\w|\\s]*\\:[\\w|\\s|\\(|\\)|.]*))/"; $typeparams = array(); preg_match_all($otherpattern, $eventcontents, $typeparams); if (!empty($typeparams[2])) { $eventinformation['otherparameter'] = array(); foreach ($typeparams[2] as $typeparameter) { $eventinformation['otherparameter'][] = $typeparameter; } } // Get parent class information. if ($parentclass = get_parent_class($eventname)) { $eventinformation['parentclass'] = '\\' . $parentclass; } // Fetch all the observers to be matched with this event. $allobserverslist = report_eventlist_list_generator::get_observer_list(); $observers = array(); if (isset($allobserverslist['\\core\\event\\base'])) { $observers = $allobserverslist['\\core\\event\\base']; } if (isset($allobserverslist[$eventname])) { $observers = array_merge($observers, $allobserverslist[$eventname]); } // OUTPUT. $renderer = $PAGE->get_renderer('report_eventlist'); echo $renderer->render_event_detail($observers, $eventinformation);
///////////////////////////////////////////////////// // GLOBAL SETTINGS //////////////////////////////////////////////////// use block_notifications\SupportedEvents; include_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . "common.php"; defined('MOODLE_INTERNAL') || die; global $CFG; if ($ADMIN->fulltree) { $settings->add(new admin_setting_heading('block_notifications_settings', '', get_string('global_configuration_comment', 'block_notifications'))); $settings->add(new admin_setting_configcheckbox('block_notifications/email_channel', get_string('email', 'block_notifications'), '', 1)); if (class_exists('block_notifications\\SMS')) { $settings->add(new admin_setting_configcheckbox('block_notifications/sms_channel', get_string('sms', 'block_notifications'), '', 1)); } else { $settings->add(new admin_setting_configcheckbox('block_notifications/sms_channel', get_string('sms', 'block_notifications'), get_string('sms_class_not_implemented', 'block_notifications'), 0)); } $settings->add(new admin_setting_configcheckbox('block_notifications/rss_channel', get_string('rss', 'block_notifications'), '', 1)); $settings->add(new admin_setting_configcheckbox('block_notifications/rss_shortname_url_param', get_string('rss_by_shortname', 'block_notifications'), '', 0)); $settings->add(new admin_setting_heading('block_notifications_presets', '', get_string('global_configuration_presets_comment', 'block_notifications'))); $settings->add(new admin_setting_configcheckbox('block_notifications/email_notification_preset', get_string('email_notification_preset', 'block_notifications'), get_string('email_notification_preset_explanation', 'block_notifications'), 1)); $settings->add(new admin_setting_configcheckbox('block_notifications/sms_notification_preset', get_string('sms_notification_preset', 'block_notifications'), get_string('sms_notification_preset_explanation', 'block_notifications'), 1)); $settings->add(new admin_setting_configtext('block_notifications/history_length', get_string('history_length', 'block_notifications'), get_string('history_length_explanation', 'block_notifications'), 30, PARAM_INT)); $settings->add(new admin_setting_heading('block_notifications_actions', '', get_string('global_events_explanation', 'block_notifications'))); $events = report_eventlist_list_generator::get_all_events_list(); // the default values are in the SupportedEvents class foreach (SupportedEvents::getStandardNames() as $name => $enabled) { $eventname = preg_replace('/\\\\/', '_', $name); $eventname = preg_replace('/^_/', '', $eventname); $description = preg_replace('/href="/', 'href="../report/eventlist/', $events[$name]['fulleventname']); $settings->add(new admin_setting_configcheckbox("block_notifications/{$eventname}", $description, '', $enabled)); } }
protected function specific_definition($mform) { global $CFG; global $COURSE; $global_config = get_config('block_notifications'); $Course = new \block_notifications\Course(); $course_notification_setting = $Course->get_registration($COURSE->id); // Fields for editing HTML block title and contents. $mform->addElement('header', 'notificationsheader', get_string('blocksettings', 'block')); $attributes = array(); $attributes['disabled'] = 'disabled'; $attributes['group'] = 'notifications_settings'; if ($global_config->email_channel == 1) { $mform->addElement('checkbox', 'notify_by_email', get_string('notify_by_email', 'block_notifications')); } else { $mform->addElement('advcheckbox', 'notify_by_email', get_string('notify_by_email', 'block_notifications'), null, $attributes); } if (isset($course_notification_setting->notify_by_email) and $course_notification_setting->notify_by_email == 1) { $mform->setDefault('notify_by_email', 1); } if ($global_config->sms_channel == 1 and class_exists('block_notifications\\SMS')) { $mform->addElement('checkbox', 'notify_by_sms', get_string('notify_by_sms', 'block_notifications')); } else { $mform->addElement('advcheckbox', 'notify_by_sms', get_string('notify_by_sms', 'block_notifications'), null, $attributes); } if (isset($course_notification_setting->notify_by_sms) and $course_notification_setting->notify_by_sms == 1) { $mform->setDefault('notify_by_sms', 1); } if ($global_config->rss_channel == 1) { $mform->addElement('checkbox', 'notify_by_rss', get_string('notify_by_rss', 'block_notifications')); $mform->addElement('checkbox', 'rss_shortname_url_param', get_string('rss_by_shortname', 'block_notifications')); } else { $mform->addElement('advcheckbox', 'notify_by_rss', get_string('notify_by_rss', 'block_notifications'), null, $attributes); $mform->addElement('advcheckbox', 'rss_shortname_url_param', get_string('rss_by_shortname', 'block_notifications'), null, $attributes); } if (isset($course_notification_setting->notify_by_rss) and $course_notification_setting->notify_by_rss == 1) { $mform->setDefault('notify_by_rss', 1); } if (isset($course_notification_setting->rss_shortname_url_param) and $course_notification_setting->rss_shortname_url_param == 1) { $mform->setDefault('rss_shortname_url_param', 1); } $mform->addElement('html', '<div class="qheader" style="margin-top: 20px">' . get_string('course_configuration_presets_comment', 'block_notifications') . '</div>'); $mform->addElement('checkbox', 'email_notification_preset', get_string('email_notification_preset', 'block_notifications')); if (isset($course_notification_setting->email_notification_preset) and $course_notification_setting->email_notification_preset == 1) { $mform->setDefault('email_notification_preset', 1); } else { $mform->setDefault('email_notification_preset', 0); } $mform->addElement('checkbox', 'sms_notification_preset', get_string('sms_notification_preset', 'block_notifications')); if (isset($course_notification_setting->sms_notification_preset) and $course_notification_setting->sms_notification_preset == 1) { $mform->setDefault('sms_notification_preset', 1); } else { $mform->setDefault('sms_notification_preset', 0); } $mform->addElement('html', '<div class="qheader" style="margin-top: 20px;">' . get_string('events_explanation', 'block_notifications') . '</div>'); $events = report_eventlist_list_generator::get_all_events_list(); foreach (\block_notifications\SupportedEvents::getShortNames() as $block_instance_setting => $platform_event_name) { $global_setting = preg_replace('/\\\\/', '_', $platform_event_name); $global_setting = preg_replace('/^_/', '', $global_setting); $description = preg_replace('/href="/', 'href="../report/eventlist/', $events[$platform_event_name]['fulleventname']); if ($global_config->{$global_setting} == 1) { $mform->addElement('checkbox', $block_instance_setting, $description); if (isset($course_notification_setting->{$block_instance_setting}) and $course_notification_setting->{$block_instance_setting} == 1) { $mform->setDefault($block_instance_setting, 1); } else { $mform->setDefault($block_instance_setting, 0); } } else { $mform->addElement('checkbox', $block_instance_setting, $description, null, $attributes); $mform->setDefault($block_instance_setting, 0); } } }
protected function specific_definition($mform) { global $COURSE, $DB, $USER; $context = context_course::instance($COURSE->id); if (has_capability('block/game_content_unlock:addunlocksystem', $context)) { $mform->addElement('header', 'configheader', get_string('unlocksystemeditpage', 'block_game_content_unlock')); $mform->addElement('text', 'config_title', 'Título do bloco'); $mform->setType('config_title', PARAM_TEXT); $mform->addElement('select', 'config_lastunlocksnumber', 'Número de últimos desbloqueios exibidos', array(0, 1, 2, 3, 4, 5, 6), null); $mform->addRule('config_lastunlocksnumber', null, 'required', null, 'client'); $mform->setDefault('config_lastunlocksnumber', 1); $mform->setType('config_lastunlocksnumber', PARAM_TEXT); $eventslist = report_eventlist_list_generator::get_non_core_event_list(); $eventsarray = array(); foreach ($eventslist as $value) { $description = explode("\\", explode(".", strip_tags($value['fulleventname']))[0]); $eventsarray[$value['eventname']] = $description[0] . " (" . $value['eventname'] . ")"; } $course = $DB->get_record('course', array('id' => $COURSE->id)); $info = get_fast_modinfo($course); $sql = "SELECT *\n\t\t\t\tFROM {content_unlock_system} s\n\t\t\t\t\tINNER JOIN {content_unlock_processor} p ON s.id = p.unlocksystemid\n\t\t\t\tWHERE p.processorid = :processorid\n\t\t\t\t\tAND s.blockinstanceid = :blockinstanceid\n\t\t\t\t\tAND s.deleted = 0"; $params['processorid'] = $USER->id; $params['blockinstanceid'] = $this->block->instance->id; $unlock_systems = $DB->get_records_sql($sql, $params); $html = '<table> <tr> <th>ID</th> <th>Condições</th> <th>Módulo</th> <th>Visibilidade</th> <th>Descrição</th> <th>Gerenciar condições</th> <th>Editar</th> <th>Remover</th> </tr>'; foreach ($unlock_systems as $value) { $condition_manage_url = new moodle_url('/blocks/game_content_unlock/conditionmanage.php', array('courseid' => $COURSE->id, 'unlocksystemid' => $value->id)); $urledit = new moodle_url('/blocks/game_content_unlock/unlocksystemedit.php', array('courseid' => $COURSE->id, 'unlocksystemid' => $value->id)); $urlremove = new moodle_url('/blocks/game_content_unlock/unlocksystemdelete.php', array('courseid' => $COURSE->id, 'unlocksystemid' => $value->id)); // Evitar que sistemas de outros cursos sejam exibidos - mudar? $ccm = get_course_and_cm_from_cmid($value->coursemoduleid); if ($COURSE->id != $ccm[0]->id) { continue; } $cm = $info->get_cm($value->coursemoduleid); $html = $html . '<tr> <td>' . $value->id . '</td> <td>' . $eventsarray[$value->conditions] . '</td> <td>' . $cm->name . '</td> <td>' . $value->coursemodulevisibility . '</td> <td>' . $value->eventdescription . '</td> <td>' . html_writer::link($condition_manage_url, 'Gerenciar condições') . '</td> <td>' . html_writer::link($urledit, 'Editar') . '</td> <td>' . html_writer::link($urlremove, 'Remover') . '</td> </tr>'; } $url = new moodle_url('/blocks/game_content_unlock/unlocksystemadd.php', array('blockid' => $this->block->instance->id, 'courseid' => $COURSE->id)); $html = $html . '</table>' . html_writer::link($url, get_string('unlocksystemaddpage', 'block_game_content_unlock')); $mform->addElement('html', $html); } }