本文整理汇总了PHP中get_message_output_default_preferences函数的典型用法代码示例。如果您正苦于以下问题:PHP get_message_output_default_preferences函数的具体用法?PHP get_message_output_default_preferences怎么用?PHP get_message_output_default_preferences使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_message_output_default_preferences函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_message_provider_disabled
public function test_message_provider_disabled()
{
$this->resetAfterTest();
$this->preventResetByRollback();
// Disable instantmessage provider.
$disableprovidersetting = 'moodle_instantmessage_disable';
set_config($disableprovidersetting, 1, 'message');
$preferences = get_message_output_default_preferences();
$this->assertTrue($preferences->{$disableprovidersetting} == 1);
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'instantmessage';
$message->userfrom = get_admin();
$message->userto = $this->getDataGenerator()->create_user();
$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;
// Check message is not sent.
$sink = $this->redirectEmails();
message_send($message);
$emails = $sink->get_messages();
$this->assertEmpty($emails);
// Check message is sent.
set_config($disableprovidersetting, 0, 'message');
$preferences = get_message_output_default_preferences();
$this->assertTrue($preferences->{$disableprovidersetting} == 0);
$sink = $this->redirectEmails();
message_send($message);
$emails = $sink->get_messages();
$email = reset($emails);
$this->assertEquals($email->subject, 'message subject 1');
}
示例2: message_set_default_message_preference
/**
* Setting default messaging preferences for particular message provider
*
* @param string $component The name of component (e.g. moodle, mod_forum, etc.)
* @param string $messagename The name of message provider
* @param array $fileprovider The value of $messagename key in the array defined in plugin messages.php
* @param string $processorname The optional name of message processor
*/
function message_set_default_message_preference($component, $messagename, $fileprovider, $processorname='') {
global $DB;
// Fetch message processors
$condition = null;
// If we need to process a particular processor, set the select condition
if (!empty($processorname)) {
$condition = array('name' => $processorname);
}
$processors = $DB->get_records('message_processors', $condition);
// load default messaging preferences
$defaultpreferences = get_message_output_default_preferences();
// Setting default preference
$componentproviderbase = $component.'_'.$messagename;
$loggedinpref = array();
$loggedoffpref = array();
// set 'permitted' preference first for each messaging processor
foreach ($processors as $processor) {
$preferencename = $processor->name.'_provider_'.$componentproviderbase.'_permitted';
// if we do not have this setting yet, set it
if (!isset($defaultpreferences->{$preferencename})) {
// determine plugin default settings
$plugindefault = 0;
if (isset($fileprovider['defaults'][$processor->name])) {
$plugindefault = $fileprovider['defaults'][$processor->name];
}
// get string values of the settings
list($permitted, $loggedin, $loggedoff) = translate_message_default_setting($plugindefault, $processor->name);
// store default preferences for current processor
set_config($preferencename, $permitted, 'message');
// save loggedin/loggedoff settings
if ($loggedin) {
$loggedinpref[] = $processor->name;
}
if ($loggedoff) {
$loggedoffpref[] = $processor->name;
}
}
}
// now set loggedin/loggedoff preferences
if (!empty($loggedinpref)) {
$preferencename = 'message_provider_'.$componentproviderbase.'_loggedin';
if (isset($defaultpreferences->{$preferencename})) {
// We have the default preferences for this message provider, which
// likely means that we have been adding a new processor. Add defaults
// to exisitng preferences.
$loggedinpref = array_merge($loggedinpref, explode(',', $defaultpreferences->{$preferencename}));
}
set_config($preferencename, join(',', $loggedinpref), 'message');
}
if (!empty($loggedoffpref)) {
$preferencename = 'message_provider_'.$componentproviderbase.'_loggedoff';
if (isset($defaultpreferences->{$preferencename})) {
// We have the default preferences for this message provider, which
// likely means that we have been adding a new processor. Add defaults
// to exisitng preferences.
$loggedoffpref = array_merge($loggedoffpref, explode(',', $defaultpreferences->{$preferencename}));
}
set_config($preferencename, join(',', $loggedoffpref), 'message');
}
}
示例3: explode
}
$lineprefarray = explode(',', $linepref);
$preferences->{$provider->component . '_' . $provider->name . '_' . $state} = array();
foreach ($lineprefarray as $pref) {
$preferences->{$provider->component . '_' . $provider->name . '_' . $state}[$pref] = 1;
}
}
}
// Load all processors
$processors = get_message_processors();
/// For every processors put its options on the form (need to get function from processor's lib.php)
foreach ($processors as $processor) {
$processor->object->load_data($preferences, $user->id);
}
//load general messaging preferences
$preferences->blocknoncontacts = get_user_preferences('message_blocknoncontacts', '', $user->id);
$preferences->beepnewmessage = get_user_preferences('message_beepnewmessage', '', $user->id);
$preferences->mailformat = $user->mailformat;
$preferences->mailcharset = get_user_preferences('mailcharset', '', $user->id);
/// Display page header
$strmessaging = get_string('messaging', 'message');
$PAGE->set_title($strmessaging);
$PAGE->set_heading(fullname($user));
// Grab the renderer
$renderer = $PAGE->get_renderer('core', 'message');
// Fetch default (site) preferences
$defaultpreferences = get_message_output_default_preferences();
$messagingoptions = $renderer->manage_messagingoptions($processors, $providers, $preferences, $defaultpreferences, $user->emailstop, $user->id);
echo $OUTPUT->header();
echo $messagingoptions;
echo $OUTPUT->footer();
示例4: export_for_template
public function export_for_template(\renderer_base $output)
{
$processors = $this->processors;
$providers = $this->providers;
$preferences = $this->preferences;
$component = $this->component;
$defaultpreferences = get_message_output_default_preferences();
if ($component != 'moodle') {
$componentname = get_string('pluginname', $component);
} else {
$componentname = get_string('coresystem');
}
$context = ['displayname' => $componentname, 'notifications' => []];
foreach ($providers as $provider) {
$preferencebase = $this->get_preference_base($provider);
$preferencekey = 'message_provider_' . $preferencebase;
// Hack to stop this one specific preference from showing up in the
// notification list because it belongs to the message preferences page.
if (!$this->should_show_preference_key($preferencekey)) {
continue;
}
// If provider component is not same or provider disabled then don't show.
if ($provider->component != $component || !empty($defaultpreferences->{$preferencebase . '_disable'})) {
continue;
}
$notificationcontext = ['displayname' => $this->get_provider_display_name($provider), 'preferencekey' => $preferencekey, 'processors' => []];
foreach ($processors as $processor) {
$notificationprocessor = new notification_list_processor($processor, $provider, $preferences);
$notificationcontext['processors'][] = $notificationprocessor->export_for_template($output);
}
$context['notifications'][] = $notificationcontext;
}
return $context;
}
示例5: export_for_template
public function export_for_template(\renderer_base $output)
{
$processor = $this->processor;
$preferencebase = $this->get_preference_base();
$permitted = MESSAGE_DEFAULT_PERMITTED;
$defaultpreferences = get_message_output_default_preferences();
$defaultpreference = $processor->name . '_provider_' . $preferencebase . '_permitted';
$context = ['displayname' => get_string('pluginname', 'message_' . $processor->name), 'name' => $processor->name, 'locked' => false, 'userconfigured' => $processor->object->is_user_configured(), 'loggedin' => ['name' => 'loggedin', 'displayname' => get_string('loggedindescription', 'message'), 'checked' => $this->is_preference_enabled($preferencebase . '_loggedin')], 'loggedoff' => ['name' => 'loggedoff', 'displayname' => get_string('loggedoffdescription', 'message'), 'checked' => $this->is_preference_enabled($preferencebase . '_loggedoff')]];
// Determine the default setting.
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
}
// If settings are disallowed or forced, just display the corresponding message, if not use user settings.
if ($permitted == 'disallowed') {
$context['locked'] = true;
$context['lockedmessage'] = get_string('disallowed', 'message');
} else {
if ($permitted == 'forced') {
$context['locked'] = true;
$context['lockedmessage'] = get_string('forced', 'message');
}
}
return $context;
}