本文整理汇总了PHP中FreePBX::Database方法的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX::Database方法的具体用法?PHP FreePBX::Database怎么用?PHP FreePBX::Database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreePBX
的用法示例。
在下文中一共展示了FreePBX::Database方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxHandler
public function ajaxHandler()
{
$request = $_REQUEST;
if (!empty($_REQUEST['oldval']) && $_REQUEST['command'] == 'add') {
$_REQUEST['command'] = 'edit';
}
switch ($_REQUEST['command']) {
case 'add':
$this->numberAdd($request);
return array('status' => true);
break;
case 'edit':
$this->numberDel($request['oldval']);
$this->numberAdd($request);
return array('status' => true);
break;
case 'bulkdelete':
$numbers = isset($_REQUEST['numbers']) ? $_REQUEST['numbers'] : array();
$numbers = json_decode($numbers, true);
foreach ($numbers as $number) {
$this->numberDel($number);
}
return array('status' => 'true', 'message' => _("Numbers Deleted"));
break;
case 'del':
$ret = $this->numberDel($request['number']);
return array('status' => $ret);
break;
case 'calllog':
$number = $request['number'];
$sql = 'SELECT calldate FROM asteriskcdrdb.cdr WHERE src = ?';
$stmt = \FreePBX::Database()->prepare($sql);
$stmt->execute(array($number));
$ret = $stmt->fetchAll(\PDO::FETCH_ASSOC);
return $ret;
break;
case 'getJSON':
switch ($request['jdata']) {
case 'grid':
$ret = array();
$blacklist = $this->getBlacklist();
foreach ($blacklist as $item) {
$number = $item['number'];
$description = $item['description'];
if ($number == 'dest' || $number == 'blocked') {
continue;
} else {
$ret[] = array('number' => $number, 'description' => $description);
}
}
return $ret;
break;
}
break;
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('question');
$output->write(_("Connecting to the Database..."));
try {
$db = \FreePBX::Database();
} catch (\Exception $e) {
$output->writeln("<error>" . _("Unable to connect to database!") . "</error>");
return;
}
$output->writeln(_("Connected"));
$driver = $db->getAttribute(\PDO::ATTR_DRIVER_NAME);
$bundles = array();
while (true) {
$question = new Question($driver . '>', '');
$question->setAutocompleterValues($bundles);
$answer = $helper->ask($input, $output, $question);
if (preg_match("/^exit/i", $answer)) {
exit;
}
$bundles[] = $answer;
try {
$time_start = microtime(true);
$ob = $db->query($answer);
$time_end = microtime(true);
} catch (\Exception $e) {
$output->writeln("<error>" . $e->getMessage() . "</error>");
continue;
}
if (!$ob) {
$output->writeln("<error>" . $db->errorInfo() . "</error>");
continue;
}
//if we get rows back from a query fetch them
if ($ob->rowCount()) {
$gotRows = $ob->fetchAll(\PDO::FETCH_ASSOC);
} else {
$gotRows = array();
}
if (!empty($gotRows)) {
$rows = array();
foreach ($gotRows as $row) {
$rows[] = array_values($row);
}
$table = new Table($output);
$table->setHeaders(array_keys($gotRows[0]))->setRows($rows);
$table->render();
$output->writeln(sprintf(_("%s rows in set (%s sec)"), $ob->rowCount(), round($time_end - $time_start, 2)));
} else {
$output->writeln(_("Successfully executed"));
}
}
}
示例3: __construct
public function __construct()
{
$db = FreePBX::Database();
$dash = FreePBX::Dashboard();
if (!is_object($db)) {
throw new Exception("DB isn't a Database?");
}
if (!is_object($dash)) {
throw new Exception("Dash isn't an Object?");
}
$this->db = $db;
$this->dash = $dash;
// Generate a temporary 'what's next' array for lookups.
foreach ($this->periods as $p => $i) {
if ($this->last) {
$this->pnext[$this->last] = $p;
$this->last = $p;
} else {
$this->last = $p;
}
}
}
示例4: catch
FreePBX::Config()->define_conf_setting('AMPUSERMANEMAILFROM', $set, true);
//Quick check to see if we are previously installed
//this lets us know if we need to create a default group
$sql = "SELECT * FROM userman_groups";
$sth = FreePBX::Database()->prepare($sql);
try {
$sth->execute();
$grps = $sth->fetchAll();
} catch (\Exception $e) {
$grps = array();
}
if (empty($grps)) {
$sql = "INSERT INTO userman_groups (`groupname`, `description`, `users`) VALUES (?, ?, ?)";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute(array(_("All Users"), _("This group was created on install and is automatically assigned to new users. This can be disabled in User Manager Settings"), "[]"));
$id = FreePBX::Database()->lastInsertId();
$config = array("default-groups" => array($id));
FreePBX::Userman()->setConfig("authFREEPBXSettings", $config);
//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);
示例5: foreach
foreach ($files as $file) {
//move all custom files to the default language first
if (preg_match("/^custom\\/(.*)/", $file, $matches)) {
foreach (glob($dir . "/custom/" . $matches[1] . ".*") as $f) {
$ff = basename($f);
rename($f, $dir . "/" . $default . "/custom/" . $ff);
}
$filenames[] = $file;
//if any files are using languages then remove the language since Asterisk does this for us
} elseif (preg_match("/^(?:\\w{2}\\_\\w{2}|\\w{2}\\/)/", $file)) {
$filenames[] = preg_replace("/^(?:\\w{2}\\_\\w{2}|\\w{2}\\/)/", "", $file);
//Else just use the file as is
} else {
$filenames[] = $file;
}
}
$sql = "UPDATE recordings SET filename = ? WHERE id = ?";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute(array(implode('&', $filenames), $recording['id']));
}
if (file_exists($dir . "/custom")) {
$files = glob($dir . "/custom/*");
foreach ($files as $file) {
$parts = pathinfo($file);
FreePBX::Recordings()->addRecording($parts['filename'], "Migrated file", $file);
}
$files = glob($dir . "/custom/*");
if (empty($files)) {
rmdir($dir . "/custom");
}
}
示例6: paging_get_config
//.........这里部分代码省略.........
$ext->add($context, $code, '', new ext_busy());
$ext->add($context, $code, '', new ext_macro('hangupcall'));
$ext->add($context, $code, 'nointercom', new ext_noop('Intercom disallowed by ${dialnumber}'));
$ext->add($context, $code, '', new ext_execif('$[${INTERCOM_RETURN}]', 'Return'));
$ext->add($context, $code, '', new ext_gosub('1', 'lang-playback', $context, 'hook_0'));
$ext->add($context, $code, '', new ext_congestion());
if ($amp_conf['ASTCONFAPP'] == 'app_confbridge') {
$sub = 'page';
$ext->add($context, $sub, '', new ext_set('PAGE_CONF', '${EPOCH}${RAND(100,999)}'));
$ext->add($context, $sub, '', new ext_set('PAGEMODE', 'PAGE'));
$ext->add($context, $sub, '', new ext_set('PAGE_MEMBERS', '${ARG1}'));
$ext->add($context, $sub, '', new ext_set('PAGE_CONF_OPTS', 'duplex'));
$ext->add($context, $sub, '', new ext_agi('page.agi'));
$ext->add($context, $sub, '', new ext_set('CONFBRIDGE(user,template)', 'page_user_duplex'));
$ext->add($context, $sub, '', new ext_set('CONFBRIDGE(user,admin)', 'yes'));
$ext->add($context, $sub, '', new ext_set('CONFBRIDGE(user,marked)', 'yes'));
$ext->add($context, $sub, '', new ext_meetme('${PAGE_CONF}', ',', 'admin_menu'));
$ext->add($context, $sub, '', new ext_hangup());
}
$lang = 'en';
// English
$ext->add($context, $lang, 'hook_0', new ext_playback('intercom&for&extension'));
$ext->add($context, $lang, '', new ext_saydigits('${dialnumber}'));
$ext->add($context, $lang, '', new ext_playback('is&disabled'));
$ext->add($context, $lang, '', new ext_return());
$lang = 'ja';
// Japanese
$ext->add($context, $lang, 'hook_0', new ext_playback('extension'));
$ext->add($context, $lang, '', new ext_saydigits('${dialnumber}'));
$ext->add($context, $lang, '', new ext_playback('jp-no&intercom&jp-wa&disabled-2'));
$ext->add($context, $lang, '', new ext_return());
$extintercomusers = 'ext-intercom-users';
$sql = "SELECT LENGTH(id) as len FROM devices GROUP BY len";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
foreach ($rows as $row) {
$ext->add($extintercomusers, '_' . $intercom_code . str_repeat('X', $row['len']), '', new ext_goto($context . ',${EXTEN},1'));
}
$context = $extintercomusers;
// for language handling which is done on a per context basis
$ext->add($context, 'lang-playback', '', new ext_gosubif('$[${DIALPLAN_EXISTS(' . $context . ',${CHANNEL(language)})}]', $context . ',${CHANNEL(language)},${ARG1}', $context . ',en,${ARG1}'));
$ext->add($context, 'lang-playback', '', new ext_return());
$ext->addInclude('from-internal-additional', $context);
}
$fcc = new featurecode('paging', 'intercom-on');
$oncode = $fcc->getCodeActive();
unset($fcc);
if ($oncode) {
$ext->add($context, $oncode, '', new ext_macro('user-callerid'));
$ext->add($context, $oncode, '', new ext_set('CONNECTEDLINE(name-charset,i)', 'utf8'));
$ext->add($context, $oncode, '', new ext_set('CONNECTEDLINE(name,i)', _("Intercom: Enabled")));
$ext->add($context, $oncode, '', new ext_set('CONNECTEDLINE(num,i)', '${AMPUSER}'));
$ext->add($context, $oncode, '', new ext_answer(''));
$ext->add($context, $oncode, '', new ext_wait('1'));
$ext->add($context, $oncode, '', new ext_setvar('DB(AMPUSER/${AMPUSER}/intercom)', 'enabled'));
$ext->add($context, $oncode, '', new ext_playback('intercom&enabled'));
$ext->add($context, $oncode, '', new ext_macro('hangupcall'));
$target = '${EXTEN:' . strlen($oncode) . '}';
$oncode = "_" . $oncode . ".";
$ext->add($context, $oncode, '', new ext_macro('user-callerid'));
$ext->add($context, $oncode, '', new ext_set('CONNECTEDLINE(name-charset,i)', 'utf8'));
$ext->add($context, $oncode, '', new ext_set('CONNECTEDLINE(name,i)', sprintf(_("Intercom from %s: Enabled"), $target)));
$ext->add($context, $oncode, '', new ext_set('CONNECTEDLINE(num,i)', '${AMPUSER}'));
$ext->add($context, $oncode, '', new ext_setvar('dialnumber', '${EVAL(${EXTEN:' . strlen(substr($oncode, 1, -1)) . '})}'));
// Asterisk variable for saydigits languages
示例7: isFrameworkOOBENeeded
private function isFrameworkOOBENeeded()
{
$db = FreePBX::Database();
$count = (int) $db->query("SELECT COUNT(`username`) FROM `ampusers`")->fetchColumn();
if ($count !== 0) {
return false;
}
return true;
}
示例8: queues_get_config
//.........这里部分代码省略.........
$ext->add($id, 's', 'end1', new ext_setvar('ITER', '$[${ITER} + 1]'));
$ext->add($id, 's', '', new ext_gotoif('$[${ITER} <= ${LOOPCNT}]', 'begin1'));
$ext->add($id, 's', '', new ext_saynumber('${COUNT}'));
$ext->add($id, 's', '', new ext_playback('queue-quantity2'));
$ext->add($id, 's', '', new ext_return());
}
// We need to have a hangup here, if call is ended by the caller during Playback it will end in the
// h context and do a proper hangup and clean the blkvm if set, see #4671
$ext->add($c, 'h', '', new ext_macro('hangupcall'));
// NODEST will be the queue that this came from, so we will vector though an entry to determine the context the
// agent should be delivered to. All queue calls come here, this decides if the should go direct to from-internal
// or indirectly through from-queue-exten-only to trap extension calls and avoid their follow-me, etc.
//
$ext->add('from-queue', '_.', '', new ext_setvar('QAGENT', '${EXTEN}'));
$ext->add('from-queue', '_.', '', new ext_setvar('__FROMQ', 'true'));
//see below comments
$ext->add('from-queue', '_.', '', new ext_goto('1', '${NODEST}'));
//http://issues.freepbx.org/browse/FREEPBX-11871
//Because of local channel changes in Asterisk 12+ we end up losing track of our recording file
//This effectively "gives" back the recording file to the channel that answered the queue
if ($ast_ge_12) {
$ext->splice('macro-auto-blkvm', 's', 1, new ext_execif('$["${FROMQ}" = "true" & "${CALLFILENAME}" != "" & "${CDR(recordingfile)}" = ""]', 'Set', 'CDR(recordingfile)=${CALLFILENAME}.${MON_FMT}'));
}
$ext->addInclude($from_queue_exten_only . '-x', 'from-internal');
$ext->add($from_queue_exten_only . '-x', 'foo', '', new ext_noop('bar'));
$ext->addInclude($from_queue_exten_internal, $from_queue_exten_only);
$ext->addInclude($from_queue_exten_internal, $from_queue_exten_only . '-x');
$ext->addInclude($from_queue_exten_internal, 'from-internal');
$ext->add($from_queue_exten_internal, 'foo', '', new ext_noop('bar'));
/* create a context, from-queue-exten-only, that can be used for queues that want behavir similar to
* ringgroup where only the agent's phone will be rung, no follow-me will be pursued.
*/
$sql = "SELECT LENGTH(extension) as len FROM users GROUP BY len";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
foreach ($rows as $row) {
//make sure exten exists
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_gotoif('$[${DB_EXISTS(AMPUSER/${EXTEN}/cidnum)} = 0]', $from_queue_exten_only . '-x,${EXTEN},1'));
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_set('RingGroupMethod', 'none'));
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_set('QDOPTS', '${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))}'));
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), 'checkrecord', new ext_set('CALLTYPE_OVERRIDE', 'external'));
// Make sure the call is tagged as external
// This means:
// If (!$fromexten) { if (!$nodest) { $fromexten = 'external' } else { $fromexten = $nodest } }
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_execif('$[!${LEN(${FROMEXTEN})}]', 'Set', 'FROMEXTEN=${IF(${LEN(${NODEST})}?${NODEST}:external)}'));
// Make sure the call is tagged as external
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_gosub('1', 's', 'sub-record-check', 'exten,${EXTEN},'));
if ($has_extension_state) {
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_macro('dial-one', ',${DIAL_OPTIONS}${QDOPTS},${EXTEN}'));
} else {
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_macro('dial', ',${DIAL_OPTIONS}${QDOPTS},${EXTEN}'));
}
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_gotoif('$["${CALLER_DEST}"!=""&&"${DIALSTATUS}"="ANSWER"]', '${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)}'));
$ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_hangup());
}
if (!empty($rows)) {
$ext->add($from_queue_exten_only, 'h', '', new ext_macro('hangupcall'));
}
/*
* Adds a dynamic agent/member to a Queue
* Prompts for call-back number - in not entered, uses CIDNum
*/
if ($amp_conf['GENERATE_LEGACY_QUEUE_CODES']) {
$c = 'macro-agent-add';
// for i18n playback in multiple languages
示例9: updateChanSipSettings
public function updateChanSipSettings($key, $val = false, $type = SELF::SIP_NORMAL, $seq = 10)
{
$db = \FreePBX::Database();
// Delete the key we want to change
$del = $db->prepare('DELETE FROM `sipsettings` WHERE `keyword`=? AND `type`=?');
$del->execute(array($key, $type));
// If val is not EXACTLY false, add it back in
if ($val !== false) {
$ins = $db->prepare('INSERT INTO `sipsettings` (`keyword`, `data`, `type`, `seq`) VALUES (?, ?, ?, ?)');
$ins->execute(array($key, $val, $type, $seq));
}
}
示例10: tts_del
function tts_del($p_id)
{
$dbh = \FreePBX::Database();
$sql = 'DELETE FROM tts WHERE id = ?';
$stmt = $dbh->prepare($sql);
return $stmt->execute(array($p_id));
}
示例11: enableTrunk
private function enableTrunk($id)
{
$db = \FreePBX::Database();
$sql = "UPDATE trunks set disabled = 'off' WHERE trunkid = ?";
$ob = $db->prepare($sql);
return $ob->execute(array($id));
}
示例12: updateAllGroups
/**
* Update All Groups
* Runs through the directory to update all settings (users and naming)
*/
private function updateAllGroups()
{
if (!empty($this->gcache)) {
return true;
}
if (php_sapi_name() !== 'cli') {
throw new \Exception("Can only update groups over CLI");
}
$this->connect();
$this->out("Retrieving all groups...", false);
$sr = ldap_search($this->ldap, $this->dn, "(objectCategory=Group)", array("distinguishedname", "primarygrouptoken", "objectsid", "description", "cn"));
if ($sr === false) {
return false;
}
$groups = ldap_get_entries($this->ldap, $sr);
$this->out("Got " . $groups['count'] . " groups");
unset($groups['count']);
$sql = "DROP TABLE IF EXISTS msad_procs_temp";
$sth = $this->FreePBX->Database->prepare($sql);
$sth->execute();
$tempsql = "CREATE TABLE msad_procs_temp (\n\t\t\t`pid` int NOT NULL,\n\t\t\t`udata` varchar(255),\n\t\t\t`gdata` varchar(255),\n\t\t\tPRIMARY KEY(pid)\n\t\t) ENGINE = MEMORY";
$sth = $this->FreePBX->Database->prepare($tempsql);
$sth->execute();
$this->out("Forking child processes");
$tpath = __DIR__ . "/tmp";
if (!file_exists($tpath)) {
mkdir($tpath, 0777, true);
}
foreach ($groups as $i => $group) {
$pid = pcntl_fork();
if (!$pid) {
$iid = getmypid();
\FreePBX::Database()->__construct();
$db = new \DB();
$this->connect(true);
//http://www.rlmueller.net/CharactersEscaped.htm
$group['distinguishedname'][0] = ldap_escape($group['distinguishedname'][0]);
$this->out("\tGetting users from " . $group['cn'][0] . "...");
$gs = ldap_search($this->ldap, $this->dn, "(&(objectCategory=Person)(sAMAccountName=*)(memberof=" . $group['distinguishedname'][0] . "))");
if ($gs !== false) {
$users = ldap_get_entries($this->ldap, $gs);
$susers = serialize($users);
file_put_contents($tpath . "/" . $iid . "-users", $susers);
$sgroup = serialize($group);
file_put_contents($tpath . "/" . $iid . "-group", $sgroup);
$sql = "INSERT INTO msad_procs_temp (`pid`,`udata`,`gdata`) VALUES (?,?,?)";
$sth = $this->FreePBX->Database->prepare($sql);
$sth->execute(array($i, $iid . "-users", $iid . "-group"));
}
$this->out("\tFinished Getting users from " . $group['cn'][0]);
exit($i);
}
}
\FreePBX::Database()->__construct();
$db = new \DB();
while (pcntl_waitpid(0, $status) != -1) {
$status = pcntl_wexitstatus($status);
}
$this->out("Child processes have finished");
$sql = "SELECT * FROM msad_procs_temp";
$sth = $this->FreePBX->Database->prepare($sql);
$sth->execute();
$children = $sth->fetchAll(\PDO::FETCH_ASSOC);
$this->out("Adding Users from non-primary groups...");
foreach ($children as $child) {
if (!file_exists($tpath . "/" . $child['udata']) || !file_exists($tpath . "/" . $child['gdata'])) {
continue;
}
$udata = file_get_contents($tpath . "/" . $child['udata']);
unlink($tpath . "/" . $child['udata']);
$users = unserialize($udata);
$gdata = file_get_contents($tpath . "/" . $child['gdata']);
unlink($tpath . "/" . $child['gdata']);
$group = unserialize($gdata);
$this->out("\tFound " . $users['count'] . " users in " . $group['cn'][0]);
unset($users['count']);
$members = array();
foreach ($users as $user) {
$usid = $this->binToStrSid($user['objectsid'][0]);
$u = $this->getUserByAuthID($usid);
$members[] = $u['id'];
}
$sid = $this->binToStrSid($group['objectsid'][0]);
$this->gcache[$sid] = $group;
$um = $this->linkGroup($group['cn'][0], 'msad', $sid);
if ($um['status']) {
$this->updateGroupData($um['id'], array("description" => !empty($group['description'][0]) ? $group['description'][0] : '', "users" => $members));
if ($um['new']) {
$this->groupHooks['add'][$um['id']] = array($um['id'], $group['cn'][0], !empty($group['description'][0]) ? $group['description'][0] : '', $members);
} else {
$this->groupHooks['update'][$um['id']] = array($um['id'], $um['prevGroupname'], $group['cn'][0], !empty($group['description'][0]) ? $group['description'][0] : '', $members);
}
}
}
//remove users
$fgroups = $this->getAllGroups();
//.........这里部分代码省略.........
示例13: 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;
}
}
示例14: convertDestDatabase
public function convertDestDatabase()
{
$db = \FreePBX::Database();
$res = $db->query("SELECT * FROM `custom_destinations`")->fetchAll(\PDO::FETCH_ASSOC);
foreach ($res as $row) {
$tmparr = array("target" => $row['custom_dest'], "notes" => $row['notes'], "description" => $row['description'], "destret" => false);
$this->addCustomDest($tmparr);
}
// We're done. Delete it, now!
$res = $db->query("DROP TABLE `custom_destinations`");
}
示例15: superfecta_hookProcess_core
function superfecta_hookProcess_core($viewing_itemid, $request)
{
$db = \FreePBX::Database();
// TODO: move sql to functions superfecta_did_(add, del, edit)
if (!isset($request['action'])) {
return;
}
$result = '';
switch ($request['action']) {
case 'addIncoming':
if ($request['enable_superfecta'] == 'yes') {
$sql = "REPLACE INTO superfecta_to_incoming (extension, cidnum, scheme) values (:extension, :cidnum,:superfecta_scheme)";
$q = $db->prepare($sql);
$q->bindParam(':extension', $request['extension'], \PDO::PARAM_STR);
$q->bindParam(':cidnum', $request['cidnum'], \PDO::PARAM_STR);
$q->bindParam(':superfecta_scheme', $request['superfecta_scheme'], \PDO::PARAM_STR);
$q->execute();
$result = $db->lastInsertId();
}
break;
case 'delIncoming':
$extarray = explode('/', $request['extdisplay'], 2);
if (count($extarray) == 2) {
$sql = "DELETE FROM superfecta_to_incoming WHERE extension = :extension AND cidnum = :cidnum";
$q = $db->prepare($sql);
$q->bindParam(':extension', $extarray[0], \PDO::PARAM_STR);
$q->bindParam(':cidnum', $extarray[1], \PDO::PARAM_STR);
$q->execute();
$result = $db->lastInsertId();
}
break;
case 'edtIncoming':
// deleting and adding as in core module
$extarray = explode('/', $request['extdisplay'], 2);
if (count($extarray) == 2) {
$sql = "DELETE FROM superfecta_to_incoming WHERE extension = :extension AND cidnum = :cidnum";
$q = $db->prepare($sql);
$q->bindParam(':extension', $extarray[0], \PDO::PARAM_STR);
$q->bindParam(':cidnum', $extarray[1], \PDO::PARAM_STR);
$q->execute();
}
if ($request['enable_superfecta'] == 'yes') {
$sql = "REPLACE INTO superfecta_to_incoming (extension, cidnum, scheme) values (:extension, :cidnum,:superfecta_scheme)";
$q = $db->prepare($sql);
$q->bindParam(':extension', $request['extension'], \PDO::PARAM_STR);
$q->bindParam(':cidnum', $request['cidnum'], \PDO::PARAM_STR);
$q->bindParam(':superfecta_scheme', $request['superfecta_scheme'], \PDO::PARAM_STR);
$q->execute();
$result = $db->lastInsertId();
}
break;
}
return $result;
}