本文整理汇总了PHP中manager::get_handler_from_id方法的典型用法代码示例。如果您正苦于以下问题:PHP manager::get_handler_from_id方法的具体用法?PHP manager::get_handler_from_id怎么用?PHP manager::get_handler_from_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类manager
的用法示例。
在下文中一共展示了manager::get_handler_from_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process an inbound address to obtain the data stored within it.
*
* @param string $address The fully formed e-mail address to process.
*/
protected function process($address)
{
global $DB;
if (!self::is_correct_format($address)) {
// This address does not contain a subaddress to parse.
return;
}
// Ensure that the instance record is empty.
$this->record = null;
$record = new \stdClass();
$record->address = $address;
list($localpart) = explode('@', $address, 2);
list($record->mailbox, $encodeddata) = explode('+', $localpart, 2);
$data = base64_decode($encodeddata, true);
if (!$data) {
// This address has no valid data.
return;
}
$content = @unpack('N2handlerid/N2userid/N2datavalue/H*datakey', $data);
if (!$content) {
// This address has no data.
return;
}
if (PHP_INT_SIZE === 8) {
// 64-bit machine.
$content['handlerid'] = $content['handlerid1'] << 32 | $content['handlerid2'];
$content['userid'] = $content['userid1'] << 32 | $content['userid2'];
$content['datavalue'] = $content['datavalue1'] << 32 | $content['datavalue2'];
} else {
if ($content['handlerid1'] > 0 || $content['userid1'] > 0 || $content['datavalue1'] > 0) {
// Any 64-bit integer which is greater than the 32-bit integer size will have a non-zero value in the first
// half of the integer.
throw new \moodle_exception('Mixed environment.' . ' Key generated with a 64-bit machine but received into a 32-bit machine.');
}
$content['handlerid'] = $content['handlerid2'];
$content['userid'] = $content['userid2'];
$content['datavalue'] = $content['datavalue2'];
}
// Clear the 32-bit to 64-bit variables away.
unset($content['handlerid1']);
unset($content['handlerid2']);
unset($content['userid1']);
unset($content['userid2']);
unset($content['datavalue1']);
unset($content['datavalue2']);
$record = (object) array_merge((array) $record, $content);
// Fetch the user record.
$record->user = $DB->get_record('user', array('id' => $record->userid));
// Fetch and set the handler.
if ($handler = manager::get_handler_from_id($record->handlerid)) {
$this->handler = $handler;
// Retrieve the record for the data key.
$record->data = $DB->get_record('messageinbound_datakeys', array('handler' => $handler->id, 'datavalue' => $record->datavalue));
}
$this->record = $record;
}