本文整理汇总了PHP中FreePBX::Userman方法的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX::Userman方法的具体用法?PHP FreePBX::Userman怎么用?PHP FreePBX::Userman使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreePBX
的用法示例。
在下文中一共展示了FreePBX::Userman方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: presence_user_extensions
function presence_user_extensions()
{
$userman = FreePBX::Userman();
$extensions = array();
$xmpp_users = FreePBX::Xmpp()->getAllUsers();
foreach ($xmpp_users as $user_to) {
$user = $userman->getUserByID($user_to['user']);
if ($user['default_extension'] == 'none') {
$default = array();
} else {
$default = array($user['default_extension']);
}
$assigned = $userman->getAssignedDevices($user_to['user']);
if (!$assigned) {
$assigned = array();
}
$extensions[$user_to['username']] = array_unique(array_merge($default, $assigned), SORT_NUMERIC);
}
return $extensions;
}
示例2: array
//Default Group Settings
FreePBX::Userman()->setModuleSettingByGID($id, 'contactmanager', 'show', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'contactmanager', 'groups', array($id));
FreePBX::Userman()->setModuleSettingByGID($id, 'fax', 'enabled', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'fax', 'attachformat', "pdf");
FreePBX::Userman()->setModuleSettingByGID($id, 'faxpro', 'localstore', "true");
FreePBX::Userman()->setModuleSettingByGID($id, 'restapi', 'restapi_token_status', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'restapi', 'restapi_users', array("self"));
FreePBX::Userman()->setModuleSettingByGID($id, 'restapi', 'restapi_modules', array("*"));
FreePBX::Userman()->setModuleSettingByGID($id, 'restapi', 'restapi_rate', "1000");
FreePBX::Userman()->setModuleSettingByGID($id, 'xmpp', 'enable', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Global', 'allowLogin', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Global', 'originate', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Settings', 'assigned', array("self"));
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cdr', 'enable', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cdr', 'assigned', array("self"));
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cdr', 'download', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cdr', 'playback', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cel', 'enable', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cel', 'assigned', array("self"));
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cel', 'download', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Cel', 'playback', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Presencestate', 'enabled', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Voicemail', 'enable', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Voicemail', 'assigned', array("self"));
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Voicemail', 'download', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Voicemail', 'playback', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Voicemail', 'settings', true);
FreePBX::Userman()->setModuleSettingByGID($id, 'ucp|Voicemail', 'greetings', true);
FreePBX::Userman()->setConfig("autoGroup", $id);
}
示例3: fax_get_user
function fax_get_user($faxext = '')
{
global $db;
if ($faxext) {
$sql = "SELECT * FROM fax_users WHERE user = ?";
$settings = $db->getRow($sql, array($faxext), DB_FETCHMODE_ASSOC);
db_e($settings);
if (is_array($settings)) {
$o = \FreePBX::Userman()->getUserByID($settings['user']);
if (empty($o)) {
return array();
}
} else {
return array();
}
} else {
$sql = "SELECT * FROM fax_users";
$settings = $db->getAll($sql, DB_FETCHMODE_ASSOC);
db_e($settings);
$final = array();
if (is_array($settings)) {
foreach ($settings as $setting) {
if (!empty($setting)) {
$o = \FreePBX::Userman()->getUserByID($setting['user']);
if (!empty($o)) {
$final[] = $setting;
}
}
}
$settings = $final;
} else {
return array();
}
}
return $settings;
}
示例4: date
$displayvars['dashboard_content'] = $dashboard_content;
$displayvars['year'] = date('Y', time());
$dbfc = FreePBX::Config()->get('VIEW_UCP_FOOTER_CONTENT');
$displayvars['dashboard_footer_content'] = $ucp->View->load_view(__DIR__ . "/" . $dbfc, array("year" => date('Y', time())));
$modules = $ucp->Modules->getActiveModules();
$displayvars['navItems'] = array();
foreach ($ucp->Modules->getModulesByMethod('getNavItems') as $m) {
$mc = ucfirst(strtolower($m));
$item = $ucp->Modules->{$mc}->getNavItems();
if (!empty($item)) {
foreach ($item as $i) {
$displayvars['navItems'][] = $i;
}
}
}
$o = FreePBX::Userman()->getCombinedModuleSettingByID($user['id'], 'ucp|Global', 'originate');
$originate = !empty($o) ? '<a class="originate">' . _("Originate Call") . '</a>' : '';
$displayvars['navItems']['settings'] = array("rawname" => "settings", "badge" => false, "icon" => "fa-cog", "menu" => array("html" => '<li>' . $originate . '</li><li><a data-pjax href="?display=settings">' . _('User Settings') . '</a></li><li><a class="logout" href="?logout=1">' . _('Logout') . '</a></li>'));
$ucp->View->show_view(__DIR__ . '/views/dashboard.php', $displayvars);
break;
case "forgot":
$displayvars['token'] = $ucp->Session->generateToken('login');
$user = $ucp->User->validateResetToken($_REQUEST['forgot']);
if (!empty($user)) {
$displayvars['username'] = $user['username'];
$displayvars['ftoken'] = $_REQUEST['forgot'];
$ucp->View->show_view(__DIR__ . '/views/forgot.php', $displayvars);
} else {
$displayvars['error_danger'] = _("Invalid Token");
$ucp->View->show_view(__DIR__ . '/views/login.php', $displayvars);
}
示例5: ampuser
// Unsurprisingly, it didn't. Let's load it.
// We need to manually load it, as the autoloader WON'T.
$hint = FreePBX::Config()->get("AMPWEBROOT") . "/admin/modules/userman/Userman.class.php";
try {
FreePBX::create()->injectClass("Userman", $hint);
if (method_exists(FreePBX::Userman(), "getCombinedGlobalSettingByID")) {
$_SESSION['AMP_user'] = new ampuser($username, "usermanager");
if (!$_SESSION['AMP_user']->checkPassword($password)) {
unset($_SESSION['AMP_user']);
//Fall through to database only
//$no_auth = true;
//if(!empty($username)) {
//freepbx_log_security('Authentication failure for '.(!empty($username) ? $username : 'unknown').' from '.$_SERVER['REMOTE_ADDR']);
//}
} else {
if (FreePBX::Userman()->getCombinedGlobalSettingByID($_SESSION['AMP_user']->id, 'pbx_admin')) {
$_SESSION['AMP_user']->setAdmin();
}
//We are logged in. Stop processing
break;
}
}
} catch (Exception $e) {
}
}
//no break here so that we can fall back to database if userman is broken
//no break here so that we can fall back to database if userman is broken
case 'database':
default:
// not logged in, and have provided a user/pass
$_SESSION['AMP_user'] = new ampuser($username);
示例6: catch
$sql = "DELETE FROM fax_users WHERE user = ?";
$sth = \FreePBX::Database()->prepare($sql);
$sth->execute(array($res['user']));
continue;
}
} catch (\Exception $e) {
out(sprintf(_("Unable to migrate %s, because [%s]. Please check your 'Fax Recipients' destinations"), $res['user'], $e->getMessage()));
$sql = "DELETE FROM fax_users WHERE user = ?";
$sth = \FreePBX::Database()->prepare($sql);
$sth->execute(array($res['user']));
continue;
}
$o = $user;
} elseif (empty($o['email'])) {
//no email set for this user so now update user with the fax email
\FreePBX::Userman()->updateUserExtraData($o['id'], array("email" => $res['faxemail']));
} elseif ($o['email'] != $res['faxemail']) {
//email was set in userman and it's different than this extension so we keep the usermanager email
out(sprintf(_("Migrated user %s but unable to set email address to %s because an email [%s] was already set for User Manager User %s"), $res['user'], $res['faxemail'], $o['email'], $o['username']));
}
$sql = "UPDATE fax_users SET user = ? WHERE user = ?";
$sth = \FreePBX::Database()->prepare($sql);
try {
$sth->execute(array("a" . $o['id'], $res['user']));
} catch (\Exception $e) {
out(sprintf(_("Unable to migrate %s, because [%s]. Please check your 'Fax Recipients' destinations"), $res['user'], $e->getMessage()));
continue;
}
$ma[$res['user']] = $o['id'];
$sql = "UPDATE fax_incoming SET destination = ? WHERE destination = ?";
$sth = \FreePBX::Database()->prepare($sql);
示例7: die_freepbx
die_freepbx($results->getMessage() . "<br><br>Error selecting from fax");
}
$ma = array();
if (!empty($results)) {
out(_("Migrating all fax users to usermanager"));
}
foreach ($results as $res) {
$o = \FreePBX::Userman()->getUserByDefaultExtension($res['user']);
if (empty($o)) {
//migrate and add for upgrades
try {
$user = \FreePBX::Userman()->addUser($res['user'], bin2hex(openssl_random_pseudo_bytes(4)), $res['user'], _("Auto generated migrated user for Fax"), array("email" => $res['faxemail']));
if ($user['status']) {
\FreePBX::Userman()->setModuleSettingByID($user['id'], 'fax', 'enabled', $res['faxenabled'] == "true");
\FreePBX::Userman()->setModuleSettingByID($user['id'], 'fax', 'attachformat', $res['faxattachformat']);
\FreePBX::Userman()->setModuleSettingByID($user['id'], 'fax', 'migrate', true);
} else {
out(sprintf(_("Unable to migrate %s, because [%s]. Please check your 'Fax Recipients' destinations"), $res['user'], $user['message']));
$sql = "DELETE FROM fax_users WHERE user = ?";
$sth = \FreePBX::Database()->prepare($sql);
$sth->execute(array($res['user']));
continue;
}
} catch (\Exception $e) {
out(sprintf(_("Unable to migrate %s, because [%s]. Please check your 'Fax Recipients' destinations"), $res['user'], $e->getMessage()));
$sql = "DELETE FROM fax_users WHERE user = ?";
$sth = \FreePBX::Database()->prepare($sql);
$sth->execute(array($res['user']));
continue;
}
$o = $user;
示例8: sprintf
if ($var['exten']) {
$msg .= 'For extension: ' . $var['exten'] . "\n";
}
} else {
$callerid = !empty($var['callerid']) && !preg_match('/""\\s*<>/', $var['callerid']) ? $var['callerid'] : $var['remotestationid'];
if (!empty($callerid)) {
$msg = sprintf(_('Enclosed, please find a new fax from: %s'), $callerid);
} else {
$msg = _('Enclosed, please find a new fax');
}
$msg .= "\n";
$msg .= sprintf(_('Received & processed: %s'), date('r')) . "\n";
$msg .= _('On') . ': ' . $var['hostname'] . "\n";
$msg .= _('Via') . ': ' . $var['dest'] . "\n";
if ($var['exten']) {
$user = \FreePBX::Userman()->getUserByID($var['exten']);
if (!empty($user)) {
$name = !empty($user['displayname']) ? $user['displayname'] : trim($user['fname'] . " " . $user['lname']);
$name = !empty($name) ? $name : $user['username'];
} else {
$name = $var['exten'];
}
$msg .= _('For User') . ': ' . $name . "\n";
}
}
$tif = $var['file'];
if (!empty($var['to'])) {
//build email
$email = new CI_Email();
$email->from($var['from']);
$email->to($var['to']);
示例9: getAmpUser
/**
* Get the AMP User from the username
* @param string $username the username
* @return mixed False is false otherwise array of user
*/
public function getAmpUser($username)
{
switch ($this->mode) {
case "usermanager":
try {
$um = FreePBX::Userman()->getUserByUsername($username);
$user = array();
$user['id'] = $um['id'];
$user["username"] = $um['username'];
$user["password_sha1"] = $um['password'];
$pbl = FreePBX::Userman()->getCombinedGlobalSettingByID($um['id'], 'pbx_low');
$user["extension_low"] = trim($pbl) !== "" ? $pbl : "";
$pbh = FreePBX::Userman()->getCombinedGlobalSettingByID($um['id'], 'pbx_high');
$user["extension_high"] = trim($pbh) !== "" ? $pbh : "";
$sections = FreePBX::Userman()->getCombinedGlobalSettingByID($um['id'], 'pbx_modules');
$user["sections"] = !empty($sections) && is_array($sections) ? $sections : array();
$user["opmode"] = FreePBX::Userman()->getCombinedGlobalSettingByID($um['id'], 'opmode');
return $user;
} catch (Exception $e) {
}
//fail-through
//fail-through
case "database":
default:
$sql = "SELECT username, password_sha1, extension_low, extension_high, deptname, sections FROM ampusers WHERE username = ?";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute(array($username));
$results = $sth->fetchAll(\PDO::FETCH_ASSOC);
if (count($results) > 0) {
$user = array();
$user["username"] = $results[0]['username'];
$user["password_sha1"] = $results[0]['password_sha1'];
$user["extension_low"] = $results[0]['extension_low'];
$user["extension_high"] = $results[0]['extension_high'];
$user["sections"] = explode(";", $results[0]['sections']);
return $user;
} else {
return false;
}
break;
}
}
示例10: foreach
$set['defaultval'] = false;
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 3;
$set['module'] = 'cdr';
$set['category'] = 'CDR Report Module';
$set['emptyok'] = 0;
$set['sortorder'] = 10;
$set['name'] = 'Enable CEL Reporting';
$set['description'] = 'Setting this true will enable the CDR module to drill down on CEL data for each CDR. Although the CDR module will assure there is a CEL table available, the reporting functionality in Asterisk and associated ODBC database and CEL configuration must be done outside of FreePBX either by the user or at the Distro level.';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('CEL_ENABLED', $set, true);
}
$info = FreePBX::Modules()->getInfo("cdr");
if (version_compare_freepbx($info['cdr']['dbversion'], "12.0.13", "<=")) {
if (FreePBX::Modules()->checkStatus('ucp') && FreePBX::Modules()->checkStatus('userman')) {
$users = FreePBX::Userman()->getAllUsers();
foreach ($users as $user) {
$exts = FreePBX::Ucp()->getSetting($user['username'], 'Settings', 'assigned');
if (!empty($exts)) {
FreePBX::Ucp()->setSetting($user['username'], 'Cdr', 'assigned', $exts);
}
}
} elseif (FreePBX::Modules()->checkStatus('ucp', MODULE_STATUS_NEEDUPGRADE)) {
out(_("Please upgrade UCP before this module so that settings can be properly migrated"));
return false;
} elseif (FreePBX::Modules()->checkStatus('userman', MODULE_STATUS_NEEDUPGRADE)) {
out(_("Please upgrade Usermanager before this module so that settings can be properly migrated"));
return false;
}
}