本文整理汇总了PHP中manager::is_enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP manager::is_enabled方法的具体用法?PHP manager::is_enabled怎么用?PHP manager::is_enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类manager
的用法示例。
在下文中一共展示了manager::is_enabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate an e-mail address for the Inbound Message handler, storing a private
* key for the data object if one was not specified.
*
* @param int $userid The ID of the user to generated an address for.
* @param string $userkey The unique key for this user. If not specified this will be retrieved using
* get_user_key(). This key must have been created using get_user_key(). This parameter is provided as a performance
* optimisation for when generating multiple addresses for the same user.
* @return string|null The generated address, or null if an address could not be generated.
*/
public function generate($userid, $userkey = null)
{
global $CFG;
// Ensure that Inbound Message is enabled and that there is enough information to proceed.
if (!manager::is_enabled()) {
return null;
}
if ($userkey == null) {
$userkey = get_user_key('messageinbound_handler', $userid);
}
// Ensure that the minimum requirements are in place.
if (!isset($this->handler) || !$this->handler) {
throw new \coding_exception('Inbound Message handler not specified.');
}
// Ensure that the requested handler is actually enabled.
if (!$this->handler->enabled) {
return null;
}
if (!isset($this->datavalue)) {
throw new \coding_exception('Inbound Message data item has not been specified.');
}
$data = array(self::pack_int($this->handler->id), self::pack_int($userid), self::pack_int($this->datavalue), pack('H*', substr(md5($this->fetch_data_key() . $userkey), 0, self::HASHSIZE)));
$subaddress = base64_encode(implode($data));
return $CFG->messageinbound_mailbox . '+' . $subaddress . '@' . $CFG->messageinbound_domain;
}