• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_message_output_default_preferences函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:messagelib_test.php


示例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');
    }
}
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:71,代码来源:messagelib.php


示例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();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:edit.php


示例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;
 }
开发者ID:dg711,项目名称:moodle,代码行数:34,代码来源:notification_list_component.php


示例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;
 }
开发者ID:dg711,项目名称:moodle,代码行数:24,代码来源:notification_list_processor.php



注:本文中的get_message_output_default_preferences函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_message_processor函数代码示例发布时间:2022-05-15
下一篇:
PHP get_message_list函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap