本文整理汇总了PHP中get_message_processor函数的典型用法代码示例。如果您正苦于以下问题:PHP get_message_processor函数的具体用法?PHP get_message_processor怎么用?PHP get_message_processor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_message_processor函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: translate_message_default_setting
/**
* Translate message default settings from binary value to the array of string
* representing the settings to be stored. Also validate the provided value and
* use default if it is malformed.
*
* @param int $plugindefault Default setting suggested by plugin
* @param string $processorname The name of processor
* @return array $settings array of strings in the order: $permitted, $loggedin, $loggedoff.
*/
function translate_message_default_setting($plugindefault, $processorname) {
// Preset translation arrays
$permittedvalues = array(
0x04 => 'disallowed',
0x08 => 'permitted',
0x0c => 'forced',
);
$loggedinstatusvalues = array(
0x00 => null, // use null if loggedin/loggedoff is not defined
0x01 => 'loggedin',
0x02 => 'loggedoff',
);
// define the default setting
$processor = get_message_processor($processorname);
$default = $processor->get_default_messaging_settings();
// Validate the value. It should not exceed the maximum size
if (!is_int($plugindefault) || ($plugindefault > 0x0f)) {
debugging(get_string('errortranslatingdefault', 'message'));
$plugindefault = $default;
}
// Use plugin default setting of 'permitted' is 0
if (!($plugindefault & MESSAGE_PERMITTED_MASK)) {
$plugindefault = $default;
}
$permitted = $permittedvalues[$plugindefault & MESSAGE_PERMITTED_MASK];
$loggedin = $loggedoff = null;
if (($plugindefault & MESSAGE_PERMITTED_MASK) == MESSAGE_PERMITTED) {
$loggedin = $loggedinstatusvalues[$plugindefault & MESSAGE_DEFAULT_LOGGEDIN];
$loggedoff = $loggedinstatusvalues[$plugindefault & MESSAGE_DEFAULT_LOGGEDOFF];
}
return array($permitted, $loggedin, $loggedoff);
}
开发者ID:nickbert77,项目名称:moodle,代码行数:47,代码来源:lib.php
示例2: message_output_fragment_processor_settings
/**
* Handles displaying processor settings in a fragment.
*
* @param array $args
* @return bool|string
* @throws moodle_exception
*/
function message_output_fragment_processor_settings($args = []) {
global $PAGE;
if (!isset($args['type'])) {
throw new moodle_exception('Must provide a processor type');
}
if (!isset($args['userid'])) {
throw new moodle_exception('Must provide a userid');
}
$type = $args['type'];
$userid = $args['userid'];
$user = core_user::get_user($userid, '*', MUST_EXIST);
$processor = get_message_processor($type);
$providers = message_get_providers_for_user($userid);
$processorwrapper = new stdClass();
$processorwrapper->object = $processor;
$preferences = \core_message\api::get_all_message_preferences([$processorwrapper], $providers, $user);
$processoroutput = new \core_message\output\preferences\processor($processor, $preferences, $user, $type);
$renderer = $PAGE->get_renderer('core', 'message');
return $renderer->render_from_template('core_message/preferences_processor', $processoroutput->export_for_template($renderer));
}
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:33,代码来源:lib.php
示例3: translate_message_default_setting
/**
* Translate message default settings from binary value to the array of string
* representing the settings to be stored. Also validate the provided value and
* use default if it is malformed.
*
* @param int $plugindefault Default setting suggested by plugin
* @param string $processorname The name of processor
* @return array $settings array of strings in the order: $permitted, $loggedin, $loggedoff.
*/
function translate_message_default_setting($plugindefault, $processorname)
{
// Preset translation arrays
$permittedvalues = array(0x4 => 'disallowed', 0x8 => 'permitted', 0xc => 'forced');
$loggedinstatusvalues = array(0x0 => null, 0x1 => 'loggedin', 0x2 => 'loggedoff');
// define the default setting
$processor = get_message_processor($processorname);
$default = $processor->get_default_messaging_settings();
// Validate the value. It should not exceed the maximum size
if (!is_int($plugindefault) || $plugindefault > 0xf) {
$OUTPUT->notification(get_string('errortranslatingdefault', 'message'), 'notifyproblem');
$plugindefault = $default;
}
// Use plugin default setting of 'permitted' is 0
if (!($plugindefault & MESSAGE_PERMITTED_MASK)) {
$plugindefault = $default;
}
$permitted = $permittedvalues[$plugindefault & MESSAGE_PERMITTED_MASK];
$loggedin = $loggedoff = null;
if (($plugindefault & MESSAGE_PERMITTED_MASK) == MESSAGE_PERMITTED) {
$loggedin = $loggedinstatusvalues[$plugindefault & MESSAGE_DEFAULT_LOGGEDIN];
$loggedoff = $loggedinstatusvalues[$plugindefault & MESSAGE_DEFAULT_LOGGEDOFF];
}
return array($permitted, $loggedin, $loggedoff);
}
开发者ID:hatone,项目名称:moodle,代码行数:34,代码来源:lib.php
示例4: get_message_processor
/**
* Get a message processor.
*
* @param int $userid
* @param string $name the name of the processor
* @return external_description
* @throws moodle_exception
* @since 3.2
*/
public static function get_message_processor($userid = 0, $name)
{
global $USER, $PAGE, $CFG;
// Check if messaging is enabled.
if (empty($CFG->messaging)) {
throw new moodle_exception('disabled', 'message');
}
$params = self::validate_parameters(self::get_message_processor_parameters(), array('userid' => $userid, 'name' => $name));
if (empty($params['userid'])) {
$params['userid'] = $USER->id;
}
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
self::validate_context(context_user::instance($params['userid']));
$processor = get_message_processor($name);
$processoroutput = new \core_message\output\processor($processor, $user);
$renderer = $PAGE->get_renderer('core_message');
return $processoroutput->export_for_template($renderer);
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:28,代码来源:externallib.php
注:本文中的get_message_processor函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论