本文整理汇总了PHP中notifications::create方法的典型用法代码示例。如果您正苦于以下问题:PHP notifications::create方法的具体用法?PHP notifications::create怎么用?PHP notifications::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifications
的用法示例。
在下文中一共展示了notifications::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSupportedHTML5Formats
/**
* Get supported HTML5 formats
* @return array Return array of formats
*/
public function getSupportedHTML5Formats()
{
$browser = $this->detectSupportedFormats();
$formats = $this->getSupportedFormats();
$html5 = array("oga", "mp3", "m4a", "wav");
$final = array();
$missing = array();
$unsupported = array();
foreach ($html5 as $i) {
if (in_array($i, $browser) && in_array($i, $formats['out'])) {
$final[] = $i;
} elseif (in_array($i, $browser) && !in_array($i, $formats['out'])) {
$missing[] = $i;
} else {
$unsupported[] = $i;
}
}
$nt = notifications::create();
$mmm = $this->getConfig('mediamissingmessage');
if (!empty($missing) && empty($mmm)) {
$brand = $this->FreePBX->Config->get("DASHBOARD_FREEPBX_BRAND");
$nt->add_notice("framework", "missing_html5", _("Missing HTML5 format converters"), sprintf(_("You are missing support for the following HTML5 codecs: %s. To fully support HTML5 browser playback you will need to install programs that can not be distributed with %s. If you'd like to install the binaries needed for these conversions click 'Resolve' in the lower left corner of this message. You can also safely ignore this message but browser playback might not work in your browser."), implode(",", $missing), $brand), "http://wiki.freepbx.org/display/FOP/Installing+Media+Conversion+Libraries", true, true);
$this->setConfig('mediamissingmessage', true);
} elseif (empty($missing) && !empty($mmm)) {
$nt->delete("framework", "missing_html5");
$this->setConfig('mediamissingmessage', false);
}
return !empty($final[0]) ? array($final[0]) : array();
}
示例2: set_language
function set_language()
{
global $amp_conf, $db;
$nt = notifications::create($db);
if (extension_loaded('gettext')) {
$nt->delete('core', 'GETTEXT');
if (php_sapi_name() !== 'cli') {
if (empty($_COOKIE['lang']) || !preg_match('/^[\\w\\._@-]+$/', $_COOKIE['lang'], $matches)) {
$lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
if (empty($_COOKIE['lang'])) {
setcookie("lang", $lang);
}
} else {
preg_match('/^([\\w\\._@-]+)$/', $_COOKIE['lang'], $matches);
$lang = !empty($matches[1]) ? $matches[1] : 'en_US';
}
$_COOKIE['lang'] = $lang;
} else {
$lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
}
putenv('LC_ALL=' . $lang);
putenv('LANG=' . $lang);
putenv('LANGUAGE=' . $lang);
setlocale(LC_ALL, $lang);
bindtextdomain('amp', $amp_conf['AMPWEBROOT'] . '/admin/i18n');
bind_textdomain_codeset('amp', 'utf8');
textdomain('amp');
return $lang;
}
$nt->add_warning('core', 'GETTEXT', _("Gettext is not installed"), _("Please install gettext so that the PBX can properly translate itself"), 'https://www.gnu.org/software/gettext/');
return 'en_US';
}
示例3: weakpasswords_get_config
function weakpasswords_get_config($engine)
{
switch ($engine) {
case "asterisk":
// Clear all weak password notifications
$nt = notifications::create($db);
$security_notifications = $nt->list_security();
foreach ($security_notifications as $notification) {
if ($notification['module'] == "weakpasswords") {
$nt->delete($notification['module'], $notification['id']);
}
}
// Generate new notifications
$weak = weakpasswords_get_users();
if (sizeof($weak) > 0) {
$extended_text = _("Warning: The use of weak SIP/IAX passwords can compromise this system resulting in toll theft of your telephony service. You should change the reported devices and trunks to use strong secrets.") . "<br /><br />";
$count = 0;
foreach ($weak as $details) {
$extended_text .= sprintf(_("%s: %s / %s<br>"), $details['deviceortrunk'], $details['name'], $details['message']);
$count++;
}
if ($count == 1) {
$nt->add_security("weakpasswords", "all", $count . " " . _("extension/trunk has weak secret"), $extended_text);
} else {
$nt->add_security("weakpasswords", "all", $count . " " . _("extensions/trunks have weak secrets"), $extended_text);
}
}
break;
}
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$args = $input->getArgument('args');
$nt = \notifications::create();
if ($input->getOption('list')) {
$notifications = array();
foreach ($nt->list_all() as $notif) {
$notifications[] = array($notif['module'], $notif['id'], $notif['display_text']);
}
if ($input->getOption('json')) {
$output->writeln(json_encode($notifications));
} else {
$table = new Table($output);
$table->setHeaders(array('Module', 'ID', 'Text'))->setRows($notifications);
$table->render();
}
}
if ($input->getOption('delete')) {
if (!isset($args[1])) {
$output->writeln("Usage: fwconsole notifications --delete module id");
}
if ($nt->exists($args[0], $args[1])) {
$output->writeln("Deleting notification");
$nt->delete($args[0], $args[1]);
if (!$nt->exists($args[0], $args[1])) {
$output->writeln("Notification Deleted");
} else {
$output->writeln("Notification did not delete");
}
} else {
$output->writeln("Specified notification does not exist");
}
}
}
示例5: __construct
function __construct($mode = 'local')
{
if ($mode == 'local') {
//Setup our objects for use
//FreePBX is the FreePBX Object
$this->FreePBX = \FreePBX::create();
//UCP is the UCP Specific Object from BMO
$this->Ucp = $this->FreePBX->Ucp;
//System Notifications Class
//TODO: pull this from BMO
$this->notifications = \notifications::create();
//database subsystem
$this->db = $this->FreePBX->Database;
//This causes crazy errors later on. Dont use it
//$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
}
$this->emoji = new Client(new Ruleset());
$this->emoji->imagePathPNG = 'assets/images/emoji/png/';
// defaults to jsdelivr's free CDN
$this->emoji->imagePathSVG = 'assets/images/emoji/svg/';
// defaults to jsdelivr's free CDN
$this->detect = new \Mobile_Detect();
// Ensure the local object is available
self::$uobj = $this;
}
示例6: fatal
function fatal($text, $extended_text = "", $type = "FATAL")
{
global $db;
echo "[{$type}] " . $text . " " . $extended_text . "\n";
if (!DB::isError($db)) {
$nt = notifications::create($db);
$nt->add_critical('cron_manager', $type, $text, $extended_text);
}
exit(1);
}
示例7: installed
public static function installed()
{
$loc = fpbx_which("sox");
$process = new Process($loc . ' --version');
$process->run();
// executes after the command finishes
$nt = \notifications::create();
if (!$process->isSuccessful()) {
$nt->add_warning("FRAMEWORK", "MISSING_SOX", _("System is missing SOX"), _("To perform the minimal amount of file conversions for HTML5 support and conversion support you need to at least install SOX"), "http://wiki.freepbx.org/display/FOP/Installing+Media+Conversion+Libraries");
return false;
} else {
$nt->delete("FRAMEWORK", "MISSING_SOX");
}
return true;
}
示例8: frameworkPasswordCheck
function frameworkPasswordCheck()
{
global $amp_conf, $db;
$nt = notifications::create($db);
// Moved most of the other checks to retrieve_conf to avoid running every page load. These have been left
// here becuase both of these settings could be affected differently in the php apache related settings vs.
// what retrieve_conf would see running the CLI version of php
//
// send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not
//
if (get_magic_quotes_gpc()) {
$nt->add_error('core', 'MQGPC', _("Magic Quotes GPC"), _("You have magic_quotes_gpc enabled in your php.ini, http or .htaccess file which will cause errors in some modules. FreePBX expects this to be off and runs under that assumption"));
} else {
$nt->delete('core', 'MQGPC');
}
}
示例9: __construct
function __construct($mode = 'local')
{
if ($mode == 'local') {
//Setup our objects for use
//FreePBX is the FreePBX Object
$this->FreePBX = \FreePBX::create();
//UCP is the UCP Specific Object from BMO
$this->Ucp = $this->FreePBX->Ucp;
//System Notifications Class
//TODO: pull this from BMO
$this->notifications = \notifications::create();
//database subsystem
$this->db = $this->FreePBX->Database;
//This causes crazy errors later on. Dont use it
//$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
}
$this->detect = new \Mobile_Detect();
// Ensure the local object is available
self::$obj = $this;
}
示例10: fax_get_destinations
function fax_get_destinations()
{
global $db;
$sql = "SELECT fax_users.user,fax_users.faxemail,fax_users.faxattachformat FROM fax_users where fax_users.faxenabled = 'true' ORDER BY fax_users.user";
$results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
if (DB::IsError($results)) {
die_freepbx($results->getMessage() . "<br><br>Error selecting from fax");
}
$final = array();
$warning = array();
foreach ($results as $res) {
$o = \FreePBX::Userman()->getUserByID($res['user']);
if (!empty($o)) {
if (empty($o['email'])) {
$warning[] = $o['username'];
continue;
}
$res['uname'] = $o['username'];
$res['name'] = !empty($o['displayname']) ? $o['displayname'] : $o['fname'] . " " . $o['lname'];
$res['name'] = trim($res['name']);
$res['name'] = !empty($res['name']) ? $res['name'] : $o['username'];
$final[] = $res;
}
}
$nt = \notifications::create();
if (!empty($warning)) {
$nt->add_warning("fax", "invalid_email", _("Invalid Email for Inbound Fax"), sprintf(_("User Manager users '%s' have the ability to receive faxes but have no email address defined so they will not be able to receive faxes."), implode(",", $warning)), "", true, true);
} else {
$nt->delete("fax", "invalid_email");
}
return $final;
}
示例11: do_syslog_delete
function do_syslog_delete()
{
global $db;
$notify =& notifications::create($db);
if (isset($_REQUEST['module']) && $_REQUEST['id']) {
var_dump($_REQUEST);
$notify->safe_delete($_REQUEST['module'], $_REQUEST['id']);
}
}
示例12: generate_queues_additional
//.........这里部分代码省略.........
$results2 = queues_get($result[0], true);
// memebers is an array of members so we set it asside and remove it
// and then generate each later
//
$members = $results2['member'];
unset($results2['member']);
foreach ($results2 as $keyword => $data) {
if ($ver12) {
switch ($keyword) {
case 'ringinuse':
case 'autofill':
break;
case 'retry':
if ($data == 'none') {
$data = 0;
}
// no break, fallthrough to default
// no break, fallthrough to default
default:
$output .= $keyword . "=" . $data . "\n";
break;
}
} else {
switch ($keyword) {
case trim($data) == '':
case 'monitor-join':
break;
case 'monitor-format':
if (strtolower($data) != 'no') {
$output .= "monitor-type=mixmonitor\n";
$output .= $keyword . "=" . $data . "\n";
}
break;
case 'announce-position':
if ($ver16) {
$output .= $keyword . "=" . $data . "\n";
}
break;
case 'retry':
if ($data == 'none') {
$data = 0;
}
// no break, fallthrough to default
// no break, fallthrough to default
default:
$output .= $keyword . "=" . $data . "\n";
break;
}
}
}
// Now pull out all the memebers, one line for each
//
if ($amp_conf['USEQUEUESTATE']) {
foreach ($members as $member) {
preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
if (isset($matches[1]) && isset($users[$matches[1]])) {
$name = $users[$matches[1]];
str_replace(',', '\\,', $name);
$output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
} else {
$output .= "member=" . $member . "\n";
}
}
} else {
if ($ast_ge_14_25) {
foreach ($members as $member) {
preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
if (isset($matches[1]) && isset($devices[$matches[1]])) {
$name = $users[$matches[1]];
str_replace(',', '\\,', $name);
$output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
} else {
$output .= "member=" . $member . "\n";
}
}
} else {
foreach ($members as $member) {
$output .= "member=" . $member . "\n";
}
}
}
$output .= $additional . "\n";
}
// Before returning the results, do an integrity check to see
// if there are any truncated compound recrodings and if so
// crate a noticication.
//
$nt = notifications::create($db);
$compound_recordings = queues_check_compoundrecordings();
if (empty($compound_recordings)) {
$nt->delete('queues', 'COMPOUNDREC');
} else {
$str = _("Warning, there are compound recordings configured in one or more Queue configurations. Queues can not play these so they have been truncated to the first sound file. You should correct this problem.<br />Details:<br /><br />");
foreach ($compound_recordings as $item) {
$str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
}
$nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
}
return $output;
}
示例13: run_jobs
/** run_jobs()
* select all entries that need to be run now and run them, then update the times.
*
* 1. select all entries
* 2. foreach entry, if its paramters indicate it should be run, then run it and
* update it was run in the time stamp.
*/
function run_jobs()
{
$errors = 0;
$error_arr = array();
$now = time();
$jobs = sql("SELECT * FROM cronmanager", "getAll", DB_FETCHMODE_ASSOC);
foreach ($jobs as $job) {
$nexttime = $job['lasttime'] + $job['freq'] * 3600;
if ($nexttime <= $now) {
if ($job['time'] >= 0 && $job['time'] < 24) {
$date_arr = getdate($now);
// Now if lasttime is 0, then we want this kicked off at the proper hour
// after wich the frequencey will set the pace for same time each night
//
if ($date_arr['hours'] != $job['time'] && !$job['lasttime']) {
continue;
}
}
} else {
// no need to run job, time is not up yet
continue;
}
// run the job
exec($job['command'], $job_out, $ret);
if ($ret) {
$errors++;
$error_arr[] = array($job['command'], $ret);
// If there where errors, let's print them out in case the script is being debugged or running
// from cron which will then put the errors out through the cron system.
//
foreach ($job_out as $line) {
echo $line . "\n";
}
} else {
$module = $job['module'];
$id = $job['id'];
$sql = "UPDATE cronmanager SET lasttime = {$now} WHERE module = '{$module}' AND id = '{$id}'";
sql($sql);
}
}
if ($errors) {
$nt =& notifications::create($db);
$text = sprintf(_("Cronmanager encountered %s Errors"), $errors);
$extext = _("The following commands failed with the listed error");
foreach ($error_arr as $item) {
$extext .= "<br />" . $item[0] . " (" . $item[1] . ")";
}
$nt->add_error('cron_manager', 'EXECFAIL', $text, $extext, '', true, true);
}
}
示例14: voicemail_mailbox_remove
function voicemail_mailbox_remove($mbox)
{
global $amp_conf;
$uservm = voicemail_getVoicemail();
$vmcontexts = array_keys($uservm);
$return = true;
foreach ($vmcontexts as $vmcontext) {
if (isset($uservm[$vmcontext][$mbox])) {
$vm_dir = $amp_conf['ASTSPOOLDIR'] . "/voicemail/{$vmcontext}/{$mbox}";
exec("rm -rf {$vm_dir}", $output, $ret);
if ($ret) {
$return = false;
$text = sprintf(_("Failed to delete vmbox: %s@%s"), $mbox, $vmcontext);
$etext = sprintf(_("failed with retcode %s while removing %s:"), $ret, $vm_dir) . "<br>";
$etext .= implode("<br>", $output);
$nt =& notifications::create($db);
$nt->add_error('voicemail', 'MBOXREMOVE', $text, $etext, '', true, true);
//
// TODO: this does not work but we should give some sort of feedback that id did not work
//
// echo "<script>javascript:alert('$text\n"._("See notification panel for details")."')</script>";
}
}
}
return $return;
}
示例15: fpbx_ami_update
/**
* Update AMI credentials in manager.conf
*
* @author Philippe Lindheimer
* @pram mixed $user false means don't change
* @pram mixed $pass password false means don't change
* @pram mixed $writetimeout false means don't change
* @returns boolean
*
* allows FreePBX to update the manager credentials primarily used by Advanced Settings and Backup and Restore.
*/
function fpbx_ami_update($user = false, $pass = false, $writetimeout = false)
{
global $amp_conf, $astman, $db, $bootstrap_settings;
$conf_file = $amp_conf['ASTETCDIR'] . '/manager.conf';
$ret = $ret2 = $ret3 = 0;
$output = array();
if (strpos($amp_conf['ASTETCDIR'], "..") === false && !file_exists($conf_file)) {
return;
}
if ($user !== false && $user != '') {
$sed_arg = escapeshellarg('s/\\s*\\[general\\].*$/TEMPCONTEXT/;s/\\[.*\\]/\\[' . $amp_conf['AMPMGRUSER'] . '\\]/;s/^TEMPCONTEXT$/\\[general\\]/');
exec("sed -i.bak {$sed_arg} {$conf_file}", $output, $ret);
if ($ret) {
freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI user to [%s], internal failure details follow:"), $amp_conf['AMPMGRUSER']));
foreach ($output as $line) {
freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
}
}
}
if ($pass !== false && $pass != '') {
unset($output);
$sed_arg = escapeshellarg('s/secret\\s*=.*$/secret = ' . $amp_conf['AMPMGRPASS'] . '/');
exec("sed -i.bak {$sed_arg} {$conf_file}", $output2, $ret2);
if ($ret2) {
freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI password to [%s], internal failure details follow:"), $amp_conf['AMPMGRPASS']));
foreach ($output as $line) {
freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
}
}
// We've changed the password, let's update the notification
//
$nt = notifications::create($db);
$freepbx_conf =& freepbx_conf::create();
if ($amp_conf['AMPMGRPASS'] == $freepbx_conf->get_conf_default_setting('AMPMGRPASS')) {
if (!$nt->exists('core', 'AMPMGRPASS')) {
$nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password"));
}
} else {
$nt->delete('core', 'AMPMGRPASS');
}
}
//attempt to set writetimeout
unset($output);
if ($writetimeout) {
$sed_arg = escapeshellarg('s/writetimeout\\s*=.*$/writetimeout = ' . $amp_conf['ASTMGRWRITETIMEOUT'] . '/');
exec("sed -i.bak {$sed_arg} {$conf_file}", $output3, $ret3);
if ($ret3) {
freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI writetimout to [%s], internal failure details follow:"), $amp_conf['ASTMGRWRITETIMEOUT']));
foreach ($output as $line) {
freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
}
}
}
if ($ret || $ret2 || $ret3) {
dbug("aborting early because previous errors");
return false;
}
if (is_object($astman) && method_exists($astman, "connected") && $astman->connected()) {
$ast_ret = $astman->Command('module reload manager');
} else {
unset($output);
dbug("no astman connection so trying to force through linux command line");
exec(fpbx_which('asterisk') . " -rx 'module reload manager'", $output, $ret2);
if ($ret2) {
freepbx_log(FPBX_LOG_ERROR, _("Failed to reload AMI, manual reload will be necessary, try: [asterisk -rx 'module reload manager']"));
}
}
if (is_object($astman) && method_exists($astman, "connected") && $astman->connected()) {
$astman->disconnect();
}
if (!is_object($astman) || !method_exists($astman, "connected")) {
//astman isn't initiated so escape
return true;
}
if (!($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) {
// couldn't connect at all
freepbx_log(FPBX_LOG_CRITICAL, "Connection attmempt to AMI failed");
} else {
$bmo = FreePBX::create();
$bmo->astman = $astman;
}
return true;
}