本文整理汇总了PHP中get_message_processors函数的典型用法代码示例。如果您正苦于以下问题:PHP get_message_processors函数的具体用法?PHP get_message_processors怎么用?PHP get_message_processors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_message_processors函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: reset_all_data
/**
* Reset contents of all database tables to initial values, reset caches, etc.
*
* Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
*
* @static
* @param bool $detectchanges
* true - changes in global state and database are reported as errors
* false - no errors reported
* null - only critical problems are reported as errors
* @return void
*/
public static function reset_all_data($detectchanges = false)
{
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
// Stop any message redirection.
phpunit_util::stop_message_redirection();
// Stop any message redirection.
phpunit_util::stop_phpmailer_redirection();
// Stop any message redirection.
phpunit_util::stop_event_redirection();
// We used to call gc_collect_cycles here to ensure desctructors were called between tests.
// This accounted for 25% of the total time running phpunit - so we removed it.
// Show any unhandled debugging messages, the runbare() could already reset it.
self::display_debugging_messages();
self::reset_debugging();
// reset global $DB in case somebody mocked it
$DB = self::get_global_backup('DB');
if ($DB->is_transaction_started()) {
// we can not reset inside transaction
$DB->force_transaction_rollback();
}
$resetdb = self::reset_database();
$warnings = array();
if ($detectchanges === true) {
if ($resetdb) {
$warnings[] = 'Warning: unexpected database modification, resetting DB state';
}
$oldcfg = self::get_global_backup('CFG');
$oldsite = self::get_global_backup('SITE');
foreach ($CFG as $k => $v) {
if (!property_exists($oldcfg, $k)) {
$warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
} else {
if ($oldcfg->{$k} !== $CFG->{$k}) {
$warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
}
}
unset($oldcfg->{$k});
}
if ($oldcfg) {
foreach ($oldcfg as $k => $v) {
$warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
}
}
if ($USER->id != 0) {
$warnings[] = 'Warning: unexpected change of $USER';
}
if ($COURSE->id != $oldsite->id) {
$warnings[] = 'Warning: unexpected change of $COURSE';
}
}
if (ini_get('max_execution_time') != 0) {
// This is special warning for all resets because we do not want any
// libraries to mess with timeouts unintentionally.
// Our PHPUnit integration is not supposed to change it either.
if ($detectchanges !== false) {
$warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
}
set_time_limit(0);
}
// restore original globals
$_SERVER = self::get_global_backup('_SERVER');
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
$_GET = array();
$_POST = array();
$_FILES = array();
$_REQUEST = array();
$COURSE = $SITE;
// reinitialise following globals
$OUTPUT = new bootstrap_renderer();
$PAGE = new moodle_page();
$FULLME = null;
$ME = null;
$SCRIPT = null;
// Empty sessison and set fresh new not-logged-in user.
\core\session\manager::init_empty_session();
// reset all static caches
\core\event\manager::phpunit_reset();
accesslib_clear_all_caches(true);
get_string_manager()->reset_caches(true);
reset_text_filters_cache(true);
events_get_handlers('reset');
core_text::reset_caches();
get_message_processors(false, true);
filter_manager::reset_caches();
// Reset internal users.
core_user::reset_internal_users();
//TODO MDL-25290: add more resets here and probably refactor them to new core function
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:util.php
示例2: load_settings
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig)
{
global $CFG, $USER, $DB, $OUTPUT, $PAGE;
// In case settings.php wants to refer to them.
$ADMIN = $adminroot;
// May be used in settings.php.
$plugininfo = $this;
// Also can be used inside settings.php.
if (!$this->is_installed_and_upgraded()) {
return;
}
if (!$hassiteconfig) {
return;
}
$section = $this->get_settings_section_name();
$settings = null;
$processors = get_message_processors();
if (isset($processors[$this->name])) {
$processor = $processors[$this->name];
if ($processor->available && $processor->hassettings) {
$settings = new admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
include $this->full_path('settings.php');
// This may also set $settings to null.
}
}
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:29,代码来源:message.php
示例3: test_send_instant_messages
/**
* Test send_instant_messages
*/
public function test_send_instant_messages()
{
global $DB, $USER, $CFG;
$this->resetAfterTest(true);
// Transactions used in tests, tell phpunit use alternative reset method.
$this->preventResetByRollback();
// Turn off all message processors (so nothing is really sent)
require_once $CFG->dirroot . '/message/lib.php';
$messageprocessors = get_message_processors();
foreach ($messageprocessors as $messageprocessor) {
$messageprocessor->enabled = 0;
$DB->update_record('message_processors', $messageprocessor);
}
// Set the required capabilities by the external function
$contextid = context_system::instance()->id;
$roleid = $this->assignUserCapability('moodle/site:sendmessage', $contextid);
$user1 = self::getDataGenerator()->create_user();
// Create test message data.
$message1 = array();
$message1['touserid'] = $user1->id;
$message1['text'] = 'the message.';
$message1['clientmsgid'] = 4;
$messages = array($message1);
$sentmessages = core_message_external::send_instant_messages($messages);
// We need to execute the return values cleaning process to simulate the web service server.
$sentmessages = external_api::clean_returnvalue(core_message_external::send_instant_messages_returns(), $sentmessages);
$themessage = $DB->get_record('message', array('id' => $sentmessages[0]['msgid']));
// Confirm that the message was inserted correctly.
$this->assertEquals($themessage->useridfrom, $USER->id);
$this->assertEquals($themessage->useridto, $message1['touserid']);
$this->assertEquals($themessage->smallmessage, $message1['text']);
$this->assertEquals($sentmessages[0]['clientmsgid'], $message1['clientmsgid']);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:36,代码来源:externallib_test.php
示例4: test_send_instant_messages
/**
* Test send_instant_messages
*/
public function test_send_instant_messages() {
global $DB, $USER, $CFG;
$this->resetAfterTest(true);
// Turn off all message processors (so nothing is really sent)
require_once($CFG->dirroot . '/message/lib.php');
$messageprocessors = get_message_processors();
foreach($messageprocessors as $messageprocessor) {
$messageprocessor->enabled = 0;
$DB->update_record('message_processors', $messageprocessor);
}
// Set the required capabilities by the external function
$contextid = context_system::instance()->id;
$roleid = $this->assignUserCapability('moodle/site:sendmessage', $contextid);
$user1 = self::getDataGenerator()->create_user();
// Create test message data.
$message1 = array();
$message1['touserid'] = $user1->id;
$message1['text'] = 'the message.';
$message1['clientmsgid'] = 4;
$messages = array($message1);
$sentmessages = core_message_external::send_instant_messages($messages);
$themessage = $DB->get_record('message', array('id' => $sentmessages[0]['msgid']));
// Confirm that the message was inserted correctly.
$this->assertEquals($themessage->useridfrom, $USER->id);
$this->assertEquals($themessage->useridto, $message1['touserid']);
$this->assertEquals($themessage->smallmessage, $message1['text']);
$this->assertEquals($sentmessages[0]['clientmsgid'], $message1['clientmsgid']);
}
开发者ID:JP-Git,项目名称:moodle,代码行数:40,代码来源:externallib_test.php
示例5: test_message_processors_reset
public function test_message_processors_reset()
{
global $DB;
$this->resetAfterTest(true);
// Get all processors first.
$processors1 = get_message_processors();
// Add a new message processor and get all processors again.
$processor = new stdClass();
$processor->name = 'test_processor';
$processor->enabled = 1;
$DB->insert_record('message_processors', $processor);
$processors2 = get_message_processors();
// Assert that new processor still haven't been added to the list.
$this->assertSame($processors1, $processors2);
// Reset message processors data.
$processors3 = get_message_processors(false, true);
// Now, list of processors should not be the same any more,
// And we should have one more message processor in the list.
$this->assertNotSame($processors1, $processors3);
$this->assertEquals(count($processors1) + 1, count($processors3));
}
开发者ID:rushi963,项目名称:moodle,代码行数:21,代码来源:advanced_test.php
示例6: message_send
//.........这里部分代码省略.........
} else {
$savemessage->contexturlname = null;
}
$savemessage->timecreated = time();
if (PHPUNIT_TEST and class_exists('phpunit_util')) {
// Add some more tests to make sure the normal code can actually work.
$componentdir = core_component::get_component_directory($eventdata->component);
if (!$componentdir or !is_dir($componentdir)) {
throw new coding_exception('Invalid component specified in message-send(): '.$eventdata->component);
}
if (!file_exists("$componentdir/db/messages.php")) {
throw new coding_exception("$eventdata->component does not contain db/messages.php necessary for message_send()");
}
$messageproviders = null;
include("$componentdir/db/messages.php");
if (!isset($messageproviders[$eventdata->name])) {
throw new coding_exception("Missing messaging defaults for event '$eventdata->name' in '$eventdata->component' messages.php file");
}
unset($componentdir);
unset($messageproviders);
// Now ask phpunit if it wants to catch this message.
if (phpunit_util::is_redirecting_messages()) {
$savemessage->timeread = time();
$messageid = $DB->insert_record('message_read', $savemessage);
$message = $DB->get_record('message_read', array('id'=>$messageid));
phpunit_util::message_sent($message);
return $messageid;
}
}
// Fetch enabled processors
$processors = get_message_processors(true);
// Preset variables
$processorlist = array();
// Fill in the array of processors to be used based on default and user preferences
foreach ($processors as $processor) {
// Skip adding processors for internal user, if processor doesn't support sending message to internal user.
if (!$usertoisrealuser && !$processor->object->can_send_to_any_users()) {
continue;
}
// First find out permissions
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
} else {
// MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
// exist in the message_provider table (thus there is no default settings for them).
$preferrormsg = "Could not load preference $defaultpreference. Make sure the component and name you supplied
to message_send() are valid.";
throw new coding_exception($preferrormsg);
}
// Find out if user has configured this output
// Some processors cannot function without settings from the user
$userisconfigured = $processor->object->is_user_configured($eventdata->userto);
// DEBUG: notify if we are forcing unconfigured output
if ($permitted == 'forced' && !$userisconfigured) {
debugging('Attempt to force message delivery to user who has "'.$processor->name.'" output unconfigured', DEBUG_NORMAL);
}
// Populate the list of processors we will be using
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:67,代码来源:messagelib.php
示例7: message_send
//.........这里部分代码省略.........
} else {
$savemessage->contexturlname = null;
}
$savemessage->timecreated = time();
if (PHPUNIT_TEST and class_exists('phpunit_util')) {
// Add some more tests to make sure the normal code can actually work.
$componentdir = get_component_directory($eventdata->component);
if (!$componentdir or !is_dir($componentdir)) {
throw new coding_exception('Invalid component specified in message-send(): '.$eventdata->component);
}
if (!file_exists("$componentdir/db/messages.php")) {
throw new coding_exception("$eventdata->component does not contain db/messages.php necessary for message_send()");
}
$messageproviders = null;
include("$componentdir/db/messages.php");
if (!isset($messageproviders[$eventdata->name])) {
throw new coding_exception("Missing messaging defaults for event '$eventdata->name' in '$eventdata->component' messages.php file");
}
unset($componentdir);
unset($messageproviders);
// Now ask phpunit if it wants to catch this message.
if (phpunit_util::is_redirecting_messages()) {
$savemessage->timeread = time();
$messageid = $DB->insert_record('message_read', $savemessage);
$message = $DB->get_record('message_read', array('id'=>$messageid));
phpunit_util::message_sent($message);
return $messageid;
}
}
// Fetch enabled processors
$processors = get_message_processors(true);
// Fetch default (site) preferences
$defaultpreferences = get_message_output_default_preferences();
// Preset variables
$processorlist = array();
$preferencebase = $eventdata->component.'_'.$eventdata->name;
// Fill in the array of processors to be used based on default and user preferences
foreach ($processors as $processor) {
// First find out permissions
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
} else {
//MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
//exist in the message_provider table (thus there is no default settings for them)
$preferrormsg = get_string('couldnotfindpreference', 'message', $defaultpreference);
throw new coding_exception($preferrormsg,'blah');
}
// Find out if user has configured this output
// Some processors cannot function without settings from the user
$userisconfigured = $processor->object->is_user_configured($eventdata->userto);
// DEBUG: notify if we are forcing unconfigured output
if ($permitted == 'forced' && !$userisconfigured) {
debugging('Attempt to force message delivery to user who has "'.$processor->name.'" output unconfigured', DEBUG_NORMAL);
}
// Warn developers that necessary data is missing regardless of how the processors are configured
if (!isset($eventdata->userto->emailstop)) {
debugging('userto->emailstop is not set. Retrieving it from the user table');
$eventdata->userto->emailstop = $DB->get_field('user', 'emailstop', array('id'=>$eventdata->userto->id));
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:67,代码来源:messagelib.php
示例8: test_send_message
public function test_send_message()
{
global $DB, $CFG;
$this->preventResetByRollback();
$this->resetAfterTest();
unset_config('noemailever');
$user1 = $this->getDataGenerator()->create_user();
$user2 = $this->getDataGenerator()->create_user();
// Test basic email redirection.
$this->assertFileExists("{$CFG->dirroot}/message/output/email/version.php");
$this->assertFileExists("{$CFG->dirroot}/message/output/popup/version.php");
$DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email' AND name <> 'popup'");
get_message_processors(true, true);
$eventsink = $this->redirectEvents();
set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'none', $user2);
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'instantmessage';
$message->userfrom = $user1;
$message->userto = $user2;
$message->subject = 'message subject 1';
$message->fullmessage = 'message body';
$message->fullmessageformat = FORMAT_MARKDOWN;
$message->fullmessagehtml = '<p>message body</p>';
$message->smallmessage = 'small message';
$message->notification = '0';
$sink = $this->redirectEmails();
$messageid = message_send($message);
$emails = $sink->get_messages();
$this->assertCount(0, $emails);
$savedmessage = $DB->get_record('message', array('id' => $messageid), '*', MUST_EXIST);
$sink->clear();
$this->assertFalse($DB->record_exists('message_read', array()));
$DB->delete_records('message', array());
$events = $eventsink->get_events();
$this->assertCount(1, $events);
$this->assertInstanceOf('\\core\\event\\message_sent', $events[0]);
$eventsink->clear();
$CFG->messaging = 0;
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'instantmessage';
$message->userfrom = $user1;
$message->userto = $user2;
$message->subject = 'message subject 1';
$message->fullmessage = 'message body';
$message->fullmessageformat = FORMAT_MARKDOWN;
$message->fullmessagehtml = '<p>message body</p>';
$message->smallmessage = 'small message';
$message->notification = '0';
$messageid = message_send($message);
$emails = $sink->get_messages();
$this->assertCount(0, $emails);
$savedmessage = $DB->get_record('message_read', array('id' => $messageid), '*', MUST_EXIST);
$sink->clear();
$this->assertFalse($DB->record_exists('message', array()));
$DB->delete_records('message_read', array());
$events = $eventsink->get_events();
$this->assertCount(2, $events);
$this->assertInstanceOf('\\core\\event\\message_sent', $events[0]);
$this->assertInstanceOf('\\core\\event\\message_viewed', $events[1]);
$eventsink->clear();
$CFG->messaging = 1;
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'instantmessage';
$message->userfrom = $user1;
$message->userto = $user2;
$message->subject = 'message subject 1';
$message->fullmessage = 'message body';
$message->fullmessageformat = FORMAT_MARKDOWN;
$message->fullmessagehtml = '<p>message body</p>';
$message->smallmessage = 'small message';
$message->notification = '1';
$messageid = message_send($message);
$emails = $sink->get_messages();
$this->assertCount(0, $emails);
$savedmessage = $DB->get_record('message_read', array('id' => $messageid), '*', MUST_EXIST);
$sink->clear();
$this->assertFalse($DB->record_exists('message', array()));
$DB->delete_records('message_read', array());
$events = $eventsink->get_events();
$this->assertCount(2, $events);
$this->assertInstanceOf('\\core\\event\\message_sent', $events[0]);
$this->assertInstanceOf('\\core\\event\\message_viewed', $events[1]);
$eventsink->clear();
set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2);
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'instantmessage';
$message->userfrom = $user1;
$message->userto = $user2;
$message->subject = 'message subject 1';
$message->fullmessage = 'message body';
$message->fullmessageformat = FORMAT_MARKDOWN;
$message->fullmessagehtml = '<p>message body</p>';
$message->smallmessage = 'small message';
$message->notification = '0';
$user2->emailstop = '1';
$sink = $this->redirectEmails();
//.........这里部分代码省略.........
开发者ID:LepilkinaElena,项目名称:moodle,代码行数:101,代码来源:messagelib_test.php
示例9: get_uninstall_url
/**
* @see plugintype_interface::get_uninstall_url()
*/
public function get_uninstall_url() {
$processors = get_message_processors();
if (isset($processors[$this->name])) {
return new moodle_url('/admin/message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey()));
} else {
return parent::get_uninstall_url();
}
}
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:11,代码来源:pluginlib.php
示例10: is_user_enabled
/**
* Test method is_user_enabled.
*/
public function is_user_enabled()
{
$processors = get_message_processors();
if (empty($processors)) {
$this->markTestSkipped("No message processors found");
}
list($name, $testprocessor) = each($processors);
// Enable.
\core_message\api::update_processor_status($testprocessor, 1);
$status = \core_message\api::is_processor_enabled($name);
$this->assertEquals(1, $status);
// Disable.
\core_message\api::update_processor_status($testprocessor, 0);
$status = \core_message\api::is_processor_enabled($name);
$this->assertEquals(0, $status);
// Enable again.
\core_message\api::update_processor_status($testprocessor, 1);
$status = \core_message\api::is_processor_enabled($name);
$this->assertEquals(1, $status);
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:23,代码来源:api_test.php
示例11: render_badges
/**
* Render badges.
* @return string
*/
protected function render_badges()
{
$mprocs = get_message_processors(true);
if (!isset($mprocs['badge'])) {
// Badge message processor is not enabled - exit.
return null;
}
$badgerend = $this->get_badge_renderer();
$badges = '';
if ($badgerend && $badgerend instanceof \theme_snap\output\message_badge_renderer) {
$badges = '<div class="alert_stream">
' . $badgerend->messagestitle() . '
<div class="message_badge_container"></div>
</div>';
}
return $badges;
}
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:21,代码来源:core_renderer.php
示例12: message_send
/**
* Called when a message provider wants to send a message.
* This functions checks the user's processor configuration to send the given type of message,
* then tries to send it.
*
* Required parameter $eventdata structure:
* component string component name. must exist in message_providers
* name string message type name. must exist in message_providers
* userfrom object|int the user sending the message
* userto object|int the message recipient
* subject string the message subject
* fullmessage - the full message in a given format
* fullmessageformat - the format if the full message (FORMAT_MOODLE, FORMAT_HTML, ..)
* fullmessagehtml - the full version (the message processor will choose with one to use)
* smallmessage - the small version of the message
* contexturl - if this is a notification then you can specify a url to view the event. For example the forum post the user is being notified of.
* contexturlname - the display text for contexturl
*
* @param object $eventdata information about the message (component, userfrom, userto, ...)
* @return int|false the ID of the new message or false if there was a problem with a processor
*/
function message_send($eventdata) {
global $CFG, $DB;
//new message ID to return
$messageid = false;
//TODO: we need to solve problems with database transactions here somehow, for now we just prevent transactions - sorry
$DB->transactions_forbidden();
if (is_int($eventdata->userto)) {
$eventdata->userto = $DB->get_record('user', array('id' => $eventdata->userto));
}
if (is_int($eventdata->userfrom)) {
$eventdata->userfrom = $DB->get_record('user', array('id' => $eventdata->userfrom));
}
//after how long inactive should the user be considered logged off?
if (isset($CFG->block_online_users_timetosee)) {
$timetoshowusers = $CFG->block_online_users_timetosee * 60;
} else {
$timetoshowusers = 300;//5 minutes
}
// Work out if the user is logged in or not
if (!empty($eventdata->userto->lastaccess) && (time()-$timetoshowusers) < $eventdata->userto->lastaccess) {
$userstate = 'loggedin';
} else {
$userstate = 'loggedoff';
}
// Create the message object
$savemessage = new stdClass();
$savemessage->useridfrom = $eventdata->userfrom->id;
$savemessage->useridto = $eventdata->userto->id;
$savemessage->subject = $eventdata->subject;
$savemessage->fullmessage = $eventdata->fullmessage;
$savemessage->fullmessageformat = $eventdata->fullmessageformat;
$savemessage->fullmessagehtml = $eventdata->fullmessagehtml;
$savemessage->smallmessage = $eventdata->smallmessage;
if (!empty($eventdata->notification)) {
$savemessage->notification = $eventdata->notification;
} else {
$savemessage->notification = 0;
}
if (!empty($eventdata->contexturl)) {
$savemessage->contexturl = $eventdata->contexturl;
} else {
$savemessage->contexturl = null;
}
if (!empty($eventdata->contexturlname)) {
$savemessage->contexturlname = $eventdata->contexturlname;
} else {
$savemessage->contexturlname = null;
}
$savemessage->timecreated = time();
// Fetch enabled processors
$processors = get_message_processors(true);
// Fetch default (site) preferences
$defaultpreferences = get_message_output_default_preferences();
// Preset variables
$processorlist = array();
$preferencebase = $eventdata->component.'_'.$eventdata->name;
// Fill in the array of processors to be used based on default and user preferences
foreach ($processors as $processor) {
// First find out permissions
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
} else {
//MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
//exist in the message_provider table (thus there is no default settings for them)
$preferrormsg = get_string('couldnotfindpreference', 'message', $preferencename);
throw new coding_exception($preferrormsg,'blah');
//.........这里部分代码省略.........
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:messagelib.php
示例13: dirname
/**
* Default message outputs configuration page
*
* @package core_message
* @copyright 2011 Lancaster University Network Services Limited
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once dirname(__FILE__) . '/../config.php';
require_once $CFG->dirroot . '/message/lib.php';
require_once $CFG->libdir . '/adminlib.php';
// This is an admin page
admin_externalpage_setup('defaultmessageoutputs');
// Require site configuration capability
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
// Fetch processors
$processors = get_message_processors(true);
// Fetch message providers
$providers = get_message_providers();
if (($form = data_submitted()) && confirm_sesskey()) {
$preferences = array();
// Prepare default message outputs settings
foreach ($providers as $provider) {
$componentproviderbase = $provider->component . '_' . $provider->name;
foreach (array('permitted', 'loggedin', 'loggedoff') as $setting) {
$value = null;
$componentprovidersetting = $componentproviderbase . '_' . $setting;
if ($setting == 'permitted') {
// if we deal with permitted select element, we need to create individual
// setting for each possible processor. Note that this block will
// always be processed first after entring parental foreach iteration
// so we can change form values on this stage.
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:defaultoutputs.php
示例14: test_get_all_message_preferences
/**
* Tests deleting a conversation.
*/
public function test_get_all_message_preferences()
{
$user = self::getDataGenerator()->create_user();
$this->setUser($user);
// Set a couple of preferences to test.
set_user_preference('message_provider_mod_assign_assign_notification_loggedin', 'popup', $user);
set_user_preference('message_provider_mod_assign_assign_notification_loggedoff', 'email', $user);
$processors = get_message_processors();
$providers = message_get_providers_for_user($user->id);
$prefs = \core_message\api::get_all_message_preferences($processors, $providers, $user);
$this->assertEquals(1, $prefs->mod_assign_assign_notification_loggedin['popup']);
$this->assertEquals(1, $prefs->mod_assign_assign_notification_loggedoff['email']);
}
开发者ID:dg711,项目名称:moodle,代码行数:16,代码来源:api_test.php
示例15: get_user_message_preferences
/**
* Get the notification preferences for a given user.
*
* @param int $userid id of the user, 0 for current user
* @return external_description
* @throws moodle_exception
* @since 3.2
*/
public static function get_user_message_preferences($userid = 0)
{
global $PAGE;
$params = self::validate_parameters(self::get_user_message_preferences_parameters(), array('userid' => $userid));
$user = self::validate_preferences_permissions($params['userid']);
// Filter out enabled, available system_configured and user_configured processors only.
$readyprocessors = array_filter(get_message_processors(), function ($processor) {
return $processor->enabled && $processor->configured && $processor->object->is_user_configured() && $processor->object->has_message_preferences();
});
$providers = array_filter(message_get_providers_for_user($user->id), function ($provider) {
return $provider->component === 'moodle';
});
$preferences = \core_message\api::get_all_message_preferences($readyprocessors, $providers, $user);
$notificationlistoutput = new \core_message\output\preferences\message_notification_list($readyprocessors, $providers, $preferences, $user);
$renderer = $PAGE->get_renderer('core_message');
$result = array('warnings' => array(), 'preferences' => $notificationlistoutput->export_for_template($renderer), 'blocknoncontacts' => get_user_preferences('message_blocknoncontacts', '', $user->id) ? true : false);
return $result;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:26,代码来源:externallib.php
示例16: get_uninstall_url
/**
* @see plugintype_interface::get_uninstall_url()
*/
public function get_uninstall_url()
{
$processors = get_message_processors();
return new moodle_url('/admin/message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey()));
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:8,代码来源:pluginlib.php
示例17: get_string
$strblockname = get_string('pluginname', 'block_'.$blockname);
if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
$settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
if ($settings) {
$ADMIN->add('blocksettings', $settings);
}
}
}
// message outputs
$ADMIN->add('modules', new admin_category('messageoutputs', get_string('messageoutputs', 'message')));
$ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
$ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
require_once($CFG->dirroot.'/message/lib.php');
$processors = get_message_processors();
foreach ($processors as $processor) {
$processorname = $processor->name;
if (!$processor->available) {
continue;
}
if ($processor->hassettings) {
$strprocessorname = get_string('pluginname', 'message_'.$processorname);
$settings = new admin_settingpage('messagesetting'.$processorname, $strprocessorname, 'moodle/site:config', !$processor->enabled);
include($CFG->dirroot.'/message/output/'.$processor->name.'/settings.php');
if ($settings) {
$ADMIN->add('messageoutputs', $settings);
}
}
}
开发者ID:nottmoo,项目名称:moodle,代码行数:30,代码来源:plugins.php
示例18: send_message_to_processors
/**
* Send message to message processors.
*
* @param \stdClass|\core\message\message $eventdata
* @param \stdClass $savemessage
* @param array $processorlist
* @return int $messageid
*/
protected static function send_message_to_processors($eventdata, \stdClass $savemessage, array $processorlist)
{
global $CFG, $DB;
// We cannot communicate with external systems in DB transactions,
// buffer the messages if necessary.
if ($DB->is_transaction_started()) {
// We need to clone all objects so that devs may not modify it from outside later.
$eventdata = clone $eventdata;
$eventdata->userto = clone $eventdata->userto;
$eventdata->userfrom = clone $eventdata->userfrom;
// Conserve some memory the same was as $USER setup does.
unset($eventdata->userto->description);
unset($eventdata->userfrom->description);
self::$buffer[] = array($eventdata, $savemessage, $processorlist);
return $savemessage->id;
}
$processors = get_message_processors(true);
$failed = false;
foreach ($processorlist as $procname) {
// Let new messaging class add custom content based on the processor.
$proceventdata = $eventdata instanceof message ? $eventdata->get_eventobject_for_processor($procname) : $eventdata;
if (!$processors[$procname]->object->send_message($proceventdata)) {
debugging('Error calling message processor ' . $procname);
$failed = true;
// Previously the $messageid = false here was overridden
// by other processors and message_mark_message_read() below.
}
}
// Trigger event for sending a message - must be done before marking as read.
\core\event\message_sent::create_from_ids($eventdata->userfrom->id, $eventdata->userto->id, $savemessage->id)->trigger();
if (empty($CFG->messaging)) {
// If messaging is disabled and they previously had forum notifications handled by the popup processor
// or any processor that puts a row in message_working then the notification will remain forever
// unread. To prevent this mark the message read if messaging is disabled.
$messageid = message_mark_message_read($savemessage, time());
} else {
if ($failed) {
// Something failed, better keep it as unread then.
$messageid = $savemessage->id;
} else {
if ($DB->count_records('message_working', array('unreadmessageid' => $savemessage->id)) == 0) {
// If there is no more processors that want to process this we can move message to message_read.
$messageid = message_mark_message_read($savemessage, time(), true);
} else {
// Some processor is still working on the data, let's keep it unread.
$messageid = $savemessage->id;
}
}
}
return $messageid;
}
开发者ID:evltuma,项目名称:moodle,代码行数:59,代码来源:manager.php
示例19: search
/**
* Search for a specific message processor
*
* @param string $query The string to search for
* @return array
*/
public function search($query)
{
global $CFG, $DB;
if ($result = parent::search($query)) {
return $result;
}
$found = false;
if ($processors = get_message_processors()) {
$textlib = textlib_get_instance();
foreach ($processors as $processor) {
if (!$processor->available) {
continue;
}
if (strpos($processor->name, $query) !== false) {
$found = true;
break;
}
$strprocessorname = get_string('pluginname', 'message_' . $processor->name);
if (strpos($textlib->strtolower($strprocessorname), $query) !== false) {
$found = true;
break;
}
|
请发表评论