本文整理汇总了PHP中Setup::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Setup::get方法的具体用法?PHP Setup::get怎么用?PHP Setup::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setup
的用法示例。
在下文中一共展示了Setup::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
session_start();
$session = new Session($_SESSION);
$request = new Request($_REQUEST);
$setup = new Setup($request->query_boolean('refresh', false));
$context = new Context($session, $request, $setup);
if ($context->is_api_request()) {
(new Api($context))->apply();
} else {
if ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
require __DIR__ . '/pages/info.php';
} else {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_html = (new Fallback($context))->get_html();
require __DIR__ . '/pages/index.php';
}
}
}
示例2: getConfig
/**
* Get database config.
* load it from setup, fall back to legacy config.php constants
*
* @return array
*/
public static function getConfig()
{
$setup = Setup::get();
if (isset($setup['database'])) {
$config = $setup['database']->toArray();
} else {
// legacy: import from constants
$config = array('driver' => APP_SQL_DBTYPE, 'hostname' => APP_SQL_DBHOST, 'database' => APP_SQL_DBNAME, 'username' => APP_SQL_DBUSER, 'password' => APP_SQL_DBPASS, 'port' => APP_SQL_DBPORT, 'table_prefix' => APP_TABLE_PREFIX);
// save it back. this will effectively do the migration
Setup::save(array('database' => $config));
}
return $config;
}
示例3: loadConfig
/**
* loadConfig()
* merges the workflow's default settings with any local settings
* this function is automatically called through getConfig()
*/
private function loadConfig()
{
$defaults = $this->getConfigDefaults();
$name = $this->getWorkflowName();
$setup = Setup::get();
if (!isset($setup['workflow'])) {
$setup['workflow'] = array();
}
// create copy, this avoids the "indirect" error
$config = $setup['workflow'][$name];
// merge defaults
foreach ($defaults as $key => $value) {
if (isset($config[$key])) {
continue;
}
$config[$key] = $value;
}
// save back to config tree
$this->config = $setup['workflow'][$name] = $config;
}
示例4: acquire
/**
* Creates a lock file for the given name.
* Returns FALSE if lock couldn't be created (lock already exists)
*
* @param int $issue_id Issue Id what is being locked
* @param string $usr_id User Id who locked the issue
* @return bool
*/
public static function acquire($issue_id, $usr_id)
{
$setup = Setup::get();
$lock_ttl = $setup['issue_lock'];
$expires = time() + $lock_ttl;
if (self::isLocked($issue_id)) {
$info = self::getInfo($issue_id);
// allow lock, if locked by user himself
if ($info['usr_id'] != $usr_id) {
return false;
}
}
$lockfile = self::getLockFilename($issue_id);
$info = array('usr_id' => $usr_id, 'expires' => $expires);
$fp = fopen($lockfile, 'w');
flock($fp, LOCK_EX);
fwrite($fp, serialize($info));
flock($fp, LOCK_UN);
fclose($fp);
return true;
}
示例5: logError
/**
* Logs the error condition to a specific file and if asked and possible
* queue error in mail queue for reporting.
*
* @param mixed $error_msg The error message
* @param string $script The script name where the error happened
* @param integer $line The line number where the error happened
* @param boolean $notify_error Whether error should be notified by email.
*/
public static function logError($error_msg = 'unknown', $script = 'unknown', $line = 0, $notify_error = true)
{
$msg =& self::_createErrorReport($error_msg, $script, $line);
if (is_resource(APP_ERROR_LOG)) {
fwrite(APP_ERROR_LOG, date('[D M d H:i:s Y] '));
fwrite(APP_ERROR_LOG, $msg);
} else {
file_put_contents(APP_ERROR_LOG, array(date('[D M d H:i:s Y] '), $msg), FILE_APPEND);
}
// if there's no database connection, then we cannot possibly queue up the error emails
$dbh = DB_Helper::getInstance();
if ($notify_error === false || !$dbh) {
return;
}
$setup = Setup::get();
if (isset($setup['email_error']['status']) && $setup['email_error']['status'] == 'enabled') {
$notify_list = trim($setup['email_error']['addresses']);
if (empty($notify_list)) {
return;
}
self::_notify($msg, $setup['smtp']['from'], $notify_list);
}
}
示例6: createMailHandler
/**
* Get mail handler if configured
*
* @return \Monolog\Handler\MailHandler
*/
private static function createMailHandler()
{
$setup = Setup::get();
if ($setup['email_error']['status'] != 'enabled') {
return null;
}
$notify_list = trim($setup['email_error']['addresses']);
if (!$notify_list) {
return null;
}
// recipient list can be comma separated
$to = Misc::trim(explode(',', $notify_list));
$subject = APP_SITE_NAME . ' - Error found!';
$handler = new Monolog\Handler\NativeMailerHandler($to, $subject, $setup['smtp']['from'], Monolog\Logger::ERROR);
return $handler;
}
示例7: Template_Helper
<?php
/*
* This file is part of the Eventum (Issue Tracking System) package.
*
* @copyright (c) Eventum Team
* @license GNU General Public License, version 2 or later (GPL-2+)
*
* For the full copyright and license information,
* please see the COPYING and AUTHORS files
* that were distributed with this source code.
*/
require_once __DIR__ . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('manage/scm.tpl.html');
Auth::checkAuthentication();
$role_id = Auth::getCurrentRole();
if ($role_id < User::ROLE_REPORTER) {
Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
$tpl->displayTemplate();
exit;
}
if (@$_POST['cat'] == 'update') {
$res = Setup::save(array('scm_integration' => $_POST['scm_integration']));
$tpl->assign('result', $res);
Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the setup information was saved successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext("ERROR: The system doesn't have the appropriate permissions to create the configuration file in the setup directory (%1\$s). " . 'Please contact your local system administrator and ask for write privileges on the provided path.', APP_CONFIG_PATH), Misc::MSG_NOTE_BOX), -2 => array(ev_gettext("ERROR: The system doesn't have the appropriate permissions to update the configuration file in the setup directory (%1\$s). " . 'Please contact your local system administrator and ask for write privileges on the provided filename.', APP_SETUP_FILE), Misc::MSG_NOTE_BOX)));
}
$tpl->assign('setup', Setup::get());
$tpl->displayTemplate();
示例8: processTemplate
/**
* Processes the template and assign common variables automatically.
*
* @return $this
*/
private function processTemplate()
{
$core = array('rel_url' => APP_RELATIVE_URL, 'base_url' => APP_BASE_URL, 'app_title' => APP_NAME, 'app_version' => APP_VERSION, 'app_setup' => Setup::get(), 'messages' => Misc::getMessages(), 'roles' => User::getAssocRoleIDs(), 'auth_backend' => APP_AUTH_BACKEND, 'current_url' => $_SERVER['PHP_SELF']);
// If VCS version is present "Eventum 2.3.3-148-g78b3368", link ref to github
$vcsVersion = self::getVcsVersion();
if ($vcsVersion) {
$link = "https://github.com/eventum/eventum/commit/{$vcsVersion}";
$core['application_version_link'] = $link;
// append VCS version if not yet there
if (!preg_match('/-g[0-9a-f]+$/', APP_VERSION)) {
$core['app_version'] = "v{$core['app_version']}-g{$vcsVersion}";
}
}
$usr_id = Auth::getUserID();
if ($usr_id) {
$core['user'] = User::getDetails($usr_id);
$prj_id = Auth::getCurrentProject();
$setup = Setup::get();
if (!empty($prj_id)) {
$role_id = User::getRoleByUser($usr_id, $prj_id);
$has_crm = CRM::hasCustomerIntegration($prj_id);
$core = $core + array('project_id' => $prj_id, 'project_name' => Auth::getCurrentProjectName(), 'has_crm' => $has_crm, 'current_role' => $role_id, 'current_role_name' => User::getRole($role_id), 'feature_access' => Access::getFeatureAccessArray($usr_id));
if ($has_crm) {
$crm = CRM::getInstance($prj_id);
$core['crm_template_path'] = $crm->getTemplatePath();
if ($role_id == User::ROLE_CUSTOMER) {
try {
$contact = $crm->getContact($core['user']['usr_customer_contact_id']);
$core['allowed_customers'] = $contact->getCustomers();
$core['current_customer'] = $crm->getCustomer(Auth::getCurrentCustomerID(false));
} catch (CRMException $e) {
}
}
}
}
$info = User::getDetails($usr_id);
$raw_projects = Project::getAssocList($usr_id, false, true);
$active_projects = array();
foreach ($raw_projects as $prj_id => $prj_info) {
if ($prj_info['status'] == 'archived') {
$prj_info['prj_title'] .= ' ' . ev_gettext('(archived)');
}
$active_projects[$prj_id] = $prj_info['prj_title'];
}
$core += array('active_projects' => $active_projects, 'current_full_name' => $info['usr_full_name'], 'current_email' => $info['usr_email'], 'current_user_id' => $usr_id, 'current_user_datetime' => Date_Helper::getISO8601date('now', '', true), 'is_current_user_clocked_in' => User::isCLockedIn($usr_id), 'is_anon_user' => Auth::isAnonUser(), 'is_current_user_partner' => !empty($info['usr_par_code']), 'roles' => User::getAssocRoleIDs(), 'current_user_prefs' => Prefs::get($usr_id));
$this->assign('current_full_name', $core['user']['usr_full_name']);
$this->assign('current_email', $core['user']['usr_email']);
$this->assign('current_user_id', $usr_id);
$this->assign('handle_clock_in', $setup['handle_clock_in'] == 'enabled');
$this->assign('is_current_user_clocked_in', User::isClockedIn($usr_id));
$this->assign('roles', User::getAssocRoleIDs());
}
$this->assign('core', $core);
if (isset($role_id) && $role_id >= User::ROLE_ADMINISTRATOR) {
DebugBar::register($this->smarty);
}
return $this;
}
示例9: createUser
/**
* Create new local user.
*
* @param array $remote
* @return int usr_id
*/
private function createUser($remote)
{
$emails = $remote['emails'];
if (!$emails) {
throw new AuthException('E-mail is required');
}
// set first email as default
$data['email'] = array_shift($emails);
$data['role'] = Setup::get()->ldap->default_role;
if (!empty($data['customer_id']) && !empty($data['contact_id'])) {
foreach ($data['role'] as $prj_id => $role) {
if ($role > 0) {
$data['role'][$prj_id] = User::ROLE_CUSTOMER;
}
}
}
$usr_id = User::insert($data);
if ($usr_id > 0 && $emails) {
$this->updateAliases($usr_id, $emails);
}
return $usr_id;
}
示例10: perform
/**
* Method used to perform a specific action to an issue.
*
* @param integer $issue_id The issue ID
* @param array $reminder The reminder details
* @param array $action The action details
* @return boolean
*/
public static function perform($issue_id, $reminder, $action)
{
$type = '';
// - see which action type we're talking about here...
$action_type = self::getActionType($action['rma_rmt_id']);
// - do we also need to alert the group leader about this?
$group_leader_usr_id = 0;
if ($action['rma_alert_group_leader']) {
if (Reminder::isDebug()) {
echo ' - ' . ev_gettext('Processing Group Leader notification') . "\n";
}
$group_id = Issue::getGroupID($issue_id);
// check if there's even a group associated with this issue
if (empty($group_id)) {
if (Reminder::isDebug()) {
echo ' - ' . ev_gettext('No group associated with issue %1$s', $issue_id) . "\n";
}
} else {
$group_details = Group::getDetails($group_id);
if (!empty($group_details['grp_manager_usr_id'])) {
$group_leader_usr_id = $group_details['grp_manager_usr_id'];
}
}
}
if (Reminder::isDebug()) {
echo ' - ' . ev_gettext('Performing action %1$s for issue # %2$s', $action_type, $issue_id) . "\n";
}
switch ($action_type) {
case 'email_assignee':
$type = 'email';
$assignees = Issue::getAssignedUserIDs($issue_id);
$to = array();
foreach ($assignees as $assignee) {
$to[] = User::getFromHeader($assignee);
}
// add the group leader to the recipient list, if needed
if (!empty($group_leader_usr_id)) {
$leader_email = User::getFromHeader($group_leader_usr_id);
if (!empty($leader_email) && !in_array($leader_email, $to)) {
$to[] = $leader_email;
}
}
break;
case 'email_list':
$type = 'email';
$list = self::getUserList($action['rma_id']);
$to = array();
foreach ($list as $key => $value) {
// add the recipient to the list if it's a simple email address
if (Validation::isEmail($key)) {
$to[] = $key;
} else {
$to[] = User::getFromHeader($key);
}
}
// add the group leader to the recipient list, if needed
if (!empty($group_leader_usr_id)) {
$leader_email = User::getFromHeader($group_leader_usr_id);
if (!empty($leader_email) && !in_array($leader_email, $to)) {
$to[] = $leader_email;
}
}
break;
case 'sms_assignee':
$type = 'sms';
$assignees = Issue::getAssignedUserIDs($issue_id);
$to = array();
foreach ($assignees as $assignee) {
if (User::isClockedIn($assignee)) {
$sms_email = User::getSMS($assignee);
if (!empty($sms_email)) {
$to[] = $sms_email;
}
}
}
// add the group leader to the recipient list, if needed
if (!empty($group_leader_usr_id) && User::isClockedIn($group_leader_usr_id)) {
$leader_sms_email = User::getSMS($group_leader_usr_id);
if (!empty($leader_sms_email) && !in_array($leader_sms_email, $to)) {
$to[] = $leader_sms_email;
}
}
break;
case 'sms_list':
$type = 'sms';
$list = self::getUserList($action['rma_id']);
$to = array();
foreach ($list as $key => $value) {
// add the recipient to the list if it's a simple email address
if (Validation::isEmail($key)) {
$to[] = $key;
} else {
//.........这里部分代码省略.........
示例11: getDefaultActions
/**
* Method used to get the full list of default notification
* actions.
*
* @param integer $issue_id The ID of the issue the user is being subscribed too
* @param string $email The email address of the user to be subscribed
* @param string $source The source of this call, "add_unknown_user", "self_assign", "remote_assign", "anon_issue", "issue_update", "issue_from_email", "new_issue", "note", "add_extra_recipients"
* @return array The list of default notification actions
*/
public static function getDefaultActions($issue_id = null, $email = null, $source = null)
{
$prj_id = Auth::getCurrentProject();
$workflow = Workflow::getNotificationActions($prj_id, $issue_id, $email, $source);
if ($workflow !== null) {
return $workflow;
}
$actions = array();
$setup = Setup::get();
if ($setup['update'] == 1) {
$actions[] = 'updated';
}
if ($setup['closed'] == 1) {
$actions[] = 'closed';
}
if ($setup['files'] == 1) {
$actions[] = 'files';
}
if ($setup['emails'] == 1) {
$actions[] = 'emails';
}
return $actions;
}
示例12: createIssueFromEmail
/**
* Creates a new issue from an email if appropriate. Also returns if this message is related
* to a previous message.
*
* @param array $info An array of info about the email account.
* @param string $headers The headers of the email.
* @param string $message_body The body of the message.
* @param string $date The date this message was sent
* @param string $from The name and email address of the sender.
* @param string $subject The subject of this message.
* @param array $to An array of to addresses
* @param array $cc An array of cc addresses
* @return array An array of information about the message
*/
public function createIssueFromEmail($info, $headers, $message_body, $date, $from, $subject, $to, $cc)
{
$should_create_issue = false;
$issue_id = '';
$associate_email = '';
$type = 'email';
$parent_id = '';
$customer_id = false;
$contact_id = false;
$contract_id = false;
$severity = false;
// we can't trust the in-reply-to from the imap c-client, so let's
// try to manually parse that value from the full headers
$references = Mail_Helper::getAllReferences($headers);
$message_id = Mail_Helper::getMessageID($headers, $message_body);
$workflow = Workflow::getIssueIDforNewEmail($info['ema_prj_id'], $info, $headers, $message_body, $date, $from, $subject, $to, $cc);
if (is_array($workflow)) {
if (isset($workflow['customer_id'])) {
$customer_id = $workflow['customer_id'];
}
if (isset($workflow['contract_id'])) {
$contract_id = $workflow['contract_id'];
}
if (isset($workflow['contact_id'])) {
$contact_id = $workflow['contact_id'];
}
if (isset($workflow['severity'])) {
$severity = $workflow['severity'];
}
if (isset($workflow['should_create_issue'])) {
$should_create_issue = $workflow['should_create_issue'];
} else {
$should_create_issue = true;
}
} elseif ($workflow == 'new') {
$should_create_issue = true;
} elseif (is_numeric($workflow)) {
$issue_id = $workflow;
} else {
$setup = Setup::get();
if ($setup['subject_based_routing']['status'] == 'enabled') {
// Look for issue ID in the subject line
// look for [#XXXX] in the subject line
if (preg_match("/\\[#(\\d+)\\]( Note| BLOCKED)*/", $subject, $matches)) {
$should_create_issue = false;
$issue_id = $matches[1];
if (!Issue::exists($issue_id, false)) {
$issue_id = '';
} elseif (!empty($matches[2])) {
$type = 'note';
}
} else {
$should_create_issue = true;
}
} else {
// - if this email is a reply:
if (count($references) > 0) {
foreach ($references as $reference_msg_id) {
// -> check if the replied email exists in the database:
if (Note::exists($reference_msg_id)) {
// note exists
// get what issue it belongs too.
$issue_id = Note::getIssueByMessageID($reference_msg_id);
$should_create_issue = false;
$type = 'note';
$parent_id = Note::getIDByMessageID($reference_msg_id);
break;
} elseif (self::exists($reference_msg_id) || Issue::getIssueByRootMessageID($reference_msg_id) != false) {
// email or issue exists
$issue_id = self::getIssueByMessageID($reference_msg_id);
if (empty($issue_id)) {
$issue_id = Issue::getIssueByRootMessageID($reference_msg_id);
}
if (empty($issue_id)) {
// parent email isn't associated with issue.
// --> create new issue, associate current email and replied email to this issue
$should_create_issue = true;
$associate_email = $reference_msg_id;
} else {
// parent email is associated with issue:
// --> associate current email with existing issue
$should_create_issue = false;
}
break;
} else {
// no matching note, email or issue:
//.........这里部分代码省略.........
示例13: getMatchingIssueIDs
/**
* Check for $adresses for matches
*
* @param mixed $addresses to check
* @param string $type Type of address match to find (email, note, draft)
* @return int|bool $issue_id in case of match otherwise false
*/
public static function getMatchingIssueIDs($addresses, $type)
{
$setup = Setup::get();
$settings = $setup["{$type}_routing"];
if (!$settings) {
return false;
}
if (empty($settings['address_prefix'])) {
return false;
}
// escape plus signs so 'issue+1@example.com' becomes a valid routing address
$prefix = quotemeta($settings['address_prefix']);
if (empty($settings['address_host'])) {
return false;
}
$mail_domain = quotemeta($settings['address_host']);
if (!empty($settings['host_alias'])) {
// XXX: legacy split by '|' as well
if (strstr($settings['host_alias'], '|')) {
$host_aliases = explode('|', $settings['host_alias']);
} else {
$host_aliases = explode(' ', $settings['host_alias']);
}
$host_aliases = implode('|', array_map(function ($s) {
return quotemeta($s);
}, $host_aliases));
$mail_domain = '(?:' . $mail_domain . '|' . $host_aliases . ')';
}
// if there are multiple CC or To headers Mail_Mime creates array.
// handle both cases (strings and arrays).
if (!is_array($addresses)) {
$addresses = array($addresses);
}
// everything safely escaped and checked, try matching address
foreach ($addresses as $address) {
if (preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $address, $matches)) {
return (int) $matches[1];
}
}
return false;
}
示例14: define
*/
require_once __DIR__ . '/../init.php';
// Nagios compatible exit codes
define('STATE_OK', 0);
define('STATE_WARNING', 1);
define('STATE_CRITICAL', 2);
define('STATE_UNKNOWN', 3);
define('STATE_DEPENDENT', 4);
// the owner, group and filesize settings should be changed to match the correct permissions on your server.
$required_files = array(APP_CONFIG_PATH . '/config.php' => array('check_owner' => true, 'owner' => 'apache', 'check_group' => true, 'group' => 'apache', 'check_permission' => true, 'permission' => 640), APP_CONFIG_PATH . '/setup.php' => array('check_owner' => true, 'owner' => 'apache', 'check_group' => true, 'group' => 'apache', 'check_permission' => true, 'permission' => 660, 'check_filesize' => true, 'filesize' => 1024));
$required_directories = array(APP_PATH . '/misc/routed_emails' => array('check_permission' => true, 'permission' => 770), APP_PATH . '/misc/routed_notes' => array('check_permission' => true, 'permission' => 770));
$opt = getopt('q');
$quiet = isset($opt['q']);
$errors = 0;
// load prefs
$setup = Setup::get();
$prefs = $setup['monitor'];
$errors += Monitor::checkDatabase();
$errors += Monitor::checkMailQueue();
$errors += Monitor::checkMailAssociation();
if ($prefs['diskcheck']['status'] == 'enabled') {
$errors += Monitor::checkDiskspace($prefs['diskcheck']['partition']);
}
if ($prefs['paths']['status'] == 'enabled') {
$errors += Monitor::checkRequiredFiles($required_files);
$errors += Monitor::checkRequiredDirs($required_directories);
}
if ($prefs['ircbot']['status'] == 'enabled') {
$errors += Monitor::checkIRCBot();
}
if ($errors) {
示例15: getToolCaption
/**
* Method used to get the title given to the current installation of Eventum.
*
* @return string The installation title
*/
public static function getToolCaption()
{
$setup = Setup::get();
return !empty($setup['tool_caption']) ? $setup['tool_caption'] : APP_NAME;
}