本文整理匯總了PHP中FreePBX::Sysadmin方法的典型用法代碼示例。如果您正苦於以下問題:PHP FreePBX::Sysadmin方法的具體用法?PHP FreePBX::Sysadmin怎麽用?PHP FreePBX::Sysadmin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FreePBX
的用法示例。
在下文中一共展示了FreePBX::Sysadmin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendPassResetEmail
/**
* Sends a password reset email
* @param {int} $id The userid
*/
public function sendPassResetEmail($id)
{
global $amp_conf;
$user = $this->getUserByID($id);
if (empty($user) || empty($user['email'])) {
return false;
}
$token = $this->Userman->generatePasswordResetToken($id);
if (empty($token)) {
return false;
}
$user['token'] = $token['token'];
$user['brand'] = $this->brand;
$user['host'] = 'http://' . $_SERVER["SERVER_NAME"];
$user['link'] = $user['host'] . "/ucp/?forgot=" . $user['token'];
$user['valid'] = date("h:i:s A", $token['valid']);
$ports = array();
if ($this->FreePBX->Modules->moduleHasMethod("sysadmin", "getPorts")) {
$ports = \FreePBX::Sysadmin()->getPorts();
} else {
if (!function_exists('sysadmin_get_portmgmt') && $this->FreePBX->Modules->checkStatus('sysadmin') && file_exists($this->FreePBX->Config()->get('AMPWEBROOT') . '/admin/modules/sysadmin/functions.inc.php')) {
include $this->FreePBX->Config()->get('AMPWEBROOT') . '/admin/modules/sysadmin/functions.inc.php';
}
if (function_exists('sysadmin_get_portmgmt')) {
$ports = sysadmin_get_portmgmt();
}
}
if (!empty($ports['ucp'])) {
$user['host'] = $user['host'] . ":" . $ports['ucp'];
$user['link'] = $user['host'] . "/?forgot=" . $user['token'];
}
$template = file_get_contents(__DIR__ . '/views/emails/reset_text.tpl');
preg_match_all('/%([\\w|\\d]*)%/', $template, $matches);
foreach ($matches[1] as $match) {
$replacement = !empty($user[$match]) ? $user[$match] : '';
$template = str_replace('%' . $match . '%', $replacement, $template);
}
$this->Userman->sendEmail($user['id'], $this->brand . " password reset", $template);
}
示例2: getSvc_restapps
private function getSvc_restapps()
{
$retarr = array("name" => _("REST Apps"), "defzones" => array("internal"), "descr" => _("Text for REST Apps not done..."), "fw" => array(array("protocol" => "tcp", "port" => 85)));
// TODO: This is not portable for machines that don't have sysadmin.
// Ask sysadmin for the REAL port of the admin interface
try {
$ports = \FreePBX::Sysadmin()->getPorts();
$retarr['fw'][0]['port'] = $ports['restapps'];
} catch (\Exception $e) {
// ignore
}
return $retarr;
}