本文整理汇总了PHP中Setup::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Setup::load方法的具体用法?PHP Setup::load怎么用?PHP Setup::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setup
的用法示例。
在下文中一共展示了Setup::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _notify
/**
* Notifies site administrators of the error condition
*
* @access private
* @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
*/
function _notify($error_msg = "unknown", $script = "unknown", $line = "unknown")
{
global $HTTP_SERVER_VARS;
$setup = Setup::load();
$notify_list = trim($setup['email_error']['addresses']);
if (empty($notify_list)) {
return false;
}
$notify_list = str_replace(';', ',', $notify_list);
$notify_list = explode(',', $notify_list);
$subject = APP_SITE_NAME . " - Error found! - " . date("m/d/Y H:i:s");
$msg = "Hello,\n\n";
$msg .= "An error was found at " . date("m/d/Y H:i:s") . " (" . time() . ") on line '" . $line . "' of script " . "'{$script}'.\n\n";
$msg .= "The error message passed to us was:\n\n";
if (is_array($error_msg) && count($error_msg) > 1) {
$msg .= "'" . $error_msg[0] . "'\n\n";
$msg .= "A more detailed error message follows:\n\n";
$msg .= "'" . $error_msg[1] . "'\n\n";
} else {
$msg .= "'{$error_msg}'\n\n";
}
@($msg .= "That happened on page '" . $HTTP_SERVER_VARS["PHP_SELF"] . "' from IP Address '" . getenv("REMOTE_ADDR") . "' coming from the page (referrer) '" . getenv("HTTP_REFERER") . "'.\n\n");
@($msg .= "The user agent given was '" . $HTTP_SERVER_VARS['HTTP_USER_AGENT'] . "'.\n\n");
$msg .= "Sincerely yours,\nAutomated Error_Handler Class";
// only try to include the backtrace if we are on PHP 4.3.0 or later
if (version_compare(phpversion(), "4.3.0", ">=")) {
$msg .= "\n\nA backtrace is available:\n\n";
ob_start();
$backtrace = debug_backtrace();
// remove the two entries related to the error handling stuff itself
array_shift($backtrace);
array_shift($backtrace);
// now we can print it out
print_r($backtrace);
$contents = ob_get_contents();
$msg .= $contents;
ob_end_clean();
}
// avoid triggering an email notification about a query that
// was bigger than max_allowed_packet (usually 16 megs on 3.23
// client libraries)
if (strlen($msg) > 16777216) {
return false;
}
foreach ($notify_list as $notify_email) {
$mail = new Mail_API();
$mail->setTextBody($msg);
$mail->send($setup['smtp']['from'], $notify_email, $subject);
}
}
示例2: getConfig
/**
* Get database config.
* load it from setup, fall back to legacy config.php constants
*/
public static function getConfig()
{
$setup =& Setup::load();
if (isset($setup['database'])) {
$config = $setup['database'];
} 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['database'] = $config;
Setup::save($setup);
}
return $config;
}
示例3: 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::load();
$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;
}
示例4: 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::load();
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);
}
}
示例5: route_drafts
/**
* Routes a draft to the correct issue.
*
* @param string $full_message The complete draft.
*/
function route_drafts($full_message)
{
global $HTTP_POST_VARS;
// save the full message for logging purposes
Draft::saveRoutedMessage($full_message);
if (preg_match("/^(boundary=).*/m", $full_message)) {
$pattern = "/(Content-Type: multipart\\/)(.+); ?\r?\n(boundary=)(.*)\$/im";
$replacement = '$1$2; $3$4';
$full_message = preg_replace($pattern, $replacement, $full_message);
}
// need some validation here
if (empty($full_message)) {
return array(66, "Error: The email message was empty.\n");
}
//
// DON'T EDIT ANYTHING BELOW THIS LINE
//
// remove the reply-to: header
if (preg_match("/^(reply-to:).*/im", $full_message)) {
$full_message = preg_replace("/^(reply-to:).*\n/im", '', $full_message, 1);
}
// check if the draft interface is even supposed to be enabled
$setup = Setup::load();
if (@$setup['draft_routing']['status'] != 'enabled') {
return array(78, "Error: The email draft interface is disabled.\n");
}
$prefix = $setup['draft_routing']['address_prefix'];
// escape plus signs so 'draft+1@example.com' becomes a valid address
$prefix = str_replace('+', '\\+', $prefix);
$mail_domain = quotemeta($setup['draft_routing']['address_host']);
if (empty($prefix)) {
return array(78, "Error: Please configure the email address prefix.\n");
}
if (empty($mail_domain)) {
return array(78, "Error: Please configure the email address domain.\n");
}
$structure = Mime_Helper::decode($full_message, true, false);
// find which issue ID this email refers to
@preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $structure->headers['to'], $matches);
@($issue_id = $matches[1]);
// validation is always a good idea
if (empty($issue_id)) {
// we need to try the Cc header as well
@preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $structure->headers['cc'], $matches);
if (!empty($matches[1])) {
$issue_id = $matches[1];
} else {
return array(65, "Error: The routed draft had no associated Eventum issue ID or had an invalid recipient address.\n");
}
}
$prj_id = Issue::getProjectID($issue_id);
// check if the sender is allowed in this issue' project and if it is an internal user
$users = Project::getUserEmailAssocList($prj_id, 'active', User::getRoleID('Customer'));
$sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
$user_emails = array_map('strtolower', array_values($users));
if (!in_array($sender_email, $user_emails)) {
return array(77, "Error: The sender of this email is not allowed in the project associated with issue #{$issue_id}.\n");
}
Auth::createFakeCookie(User::getUserIDByEmail($sender_email), $prj_id);
$body = Mime_Helper::getMessageBody($structure);
Draft::saveEmail($issue_id, @$structure->headers['to'], @$structure->headers['cc'], @$structure->headers['subject'], $body, false, false, false);
// XXX: need to handle attachments coming from drafts as well?
History::add($issue_id, Auth::getUserID(), History::getTypeID('draft_routed'), "Draft routed from " . $structure->headers['from']);
return true;
}
示例6: isClockedIn
/**
* Returns true if a user is clocked in.
*
* @param integer $usr_id The id of the user to clock out.
* @return boolean True if the user is logged in, false otherwise
*/
public static function isClockedIn($usr_id)
{
$setup = Setup::load();
// If clock in handling is disabled, say that we are always clocked in
if ($setup['handle_clock_in'] == 'disabled') {
return true;
}
$stmt = 'SELECT
usr_clocked_in
FROM
{{%user}}
WHERE
usr_id = ?';
try {
$res = DB_Helper::getInstance()->getOne($stmt, array($usr_id));
} catch (DbException $e) {
return -1;
}
if ($res == 1) {
return true;
} else {
return false;
}
}
示例7: Template_API
include_once APP_INC_PATH . "class.priority.php";
include_once APP_INC_PATH . "class.misc.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.setup.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "anonymous");
@($prj_id = $HTTP_POST_VARS["prj_id"] ? $HTTP_POST_VARS["prj_id"] : $HTTP_GET_VARS["prj_id"]);
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
if ($role_id == User::getRoleID('administrator')) {
$tpl->assign("show_setup_links", true);
}
if (@$HTTP_POST_VARS["cat"] == "update") {
$tpl->assign("result", Project::updateAnonymousPost($prj_id));
}
// load the form fields
$tpl->assign("project", Project::getDetails($prj_id));
$tpl->assign("cats", Category::getAssocList($prj_id));
$tpl->assign("priorities", Priority::getList($prj_id));
$tpl->assign("users", Project::getUserAssocList($prj_id, 'active'));
$tpl->assign("options", Project::getAnonymousPostOptions($prj_id));
$tpl->assign("prj_id", $prj_id);
$setup = Setup::load();
$tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]);
} else {
$tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
示例8:
$setup["allow_unassigned_issues"] = $HTTP_POST_VARS["allow_unassigned_issues"];
@($setup["update"] = $HTTP_POST_VARS["update"]);
@($setup["closed"] = $HTTP_POST_VARS["closed"]);
@($setup["notes"] = $HTTP_POST_VARS["notes"]);
@($setup["emails"] = $HTTP_POST_VARS["emails"]);
@($setup["files"] = $HTTP_POST_VARS["files"]);
@($setup["smtp"] = $HTTP_POST_VARS["smtp"]);
@($setup["scm_integration"] = $HTTP_POST_VARS["scm_integration"]);
@($setup["checkout_url"] = $HTTP_POST_VARS["checkout_url"]);
@($setup["diff_url"] = $HTTP_POST_VARS["diff_url"]);
@($setup["open_signup"] = $HTTP_POST_VARS["open_signup"]);
@($setup["accounts_projects"] = $HTTP_POST_VARS["accounts_projects"]);
@($setup["accounts_role"] = $HTTP_POST_VARS["accounts_role"]);
@($setup['subject_based_routing'] = $HTTP_POST_VARS['subject_based_routing']);
@($setup['email_routing'] = $HTTP_POST_VARS['email_routing']);
@($setup['note_routing'] = $HTTP_POST_VARS['note_routing']);
@($setup['draft_routing'] = $HTTP_POST_VARS['draft_routing']);
@($setup['email_error'] = $HTTP_POST_VARS['email_error']);
@($setup['email_reminder'] = $HTTP_POST_VARS['email_reminder']);
$options = Setup::load();
@($setup['downloading_emails'] = $options['downloading_emails']);
$res = Setup::save($setup);
$tpl->assign("result", $res);
}
$options = Setup::load(true);
$tpl->assign("setup", $options);
$tpl->assign("user_roles", User::getRoles(array('Customer')));
} else {
$tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
示例9: 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::load(), '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::load();
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::getRoleID('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(Auth::getUserID(), 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 = $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(Auth::getUserID()));
$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);
return $this;
}
示例10: checkTags
/**
* Check if the current setup are compatible with testcase tags
*
* @return Boolean
*/
function checkTags()
{
$setupManager = new Setup();
$setup = $setupManager->load();
$tags = $this->getTags();
// TODO: Check tags compatibility
return true;
}
示例11: getCheckinList
/**
* Method used to get the full list of checkins associated with an issue.
*
* @access public
* @param integer $issue_id The issue ID
* @return array The list of checkins
*/
function getCheckinList($issue_id)
{
$setup = Setup::load();
$stmt = "SELECT\n *\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_checkin\n WHERE\n isc_iss_id=" . Misc::escapeInteger($issue_id) . "\n ORDER BY\n isc_created_date ASC";
$res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
return "";
} else {
if (empty($res)) {
return "";
} else {
for ($i = 0; $i < count($res); $i++) {
$res[$i]["isc_commit_msg"] = Link_Filter::processText(Issue::getProjectID($issue_id), nl2br(htmlspecialchars($res[$i]["isc_commit_msg"])));
@($res[$i]["checkout_url"] = SCM::parseURL($setup["checkout_url"], $res[$i]));
@($res[$i]["diff_url"] = SCM::parseURL($setup["diff_url"], $res[$i]));
$res[$i]["isc_created_date"] = Date_API::getFormattedDate($res[$i]["isc_created_date"]);
}
return $res;
}
}
}
示例12: sendPasswordConfirmationEmail
/**
* Method used to send a confirmation email to the user that is associated
* to the email address.
*
* @access public
* @param string $usr_id The user ID
* @return void
*/
function sendPasswordConfirmationEmail($usr_id)
{
$info = User::getDetails($usr_id);
// send confirmation email to user
$hash = md5($info["usr_full_name"] . md5($info["usr_email"]) . $GLOBALS["private_key"]);
$msg = "Hello,\n\n";
$msg .= "We just received a request to create a new random password for your account in our issue tracking system. ";
$msg .= "For security reasons we need you to confirm this request so we can finish the password creation process.\n\n";
$msg .= "If this is not a real request from you, or if you don't need a new password anymore, ";
$msg .= "please disregard this email.\n\n";
$msg .= "However, if you would like to confirm this request, please do so by visiting the URL below:\n\n";
$msg .= APP_BASE_URL . "confirm.php?cat=password&email=" . $info["usr_email"] . "&hash=" . $hash . "\n\n";
$setup = Setup::load();
$mail = new Mail_API();
// need to make this message MIME based
$mail->setTextBody($msg);
$mail->send($setup["smtp"]["from"], $info["usr_email"], APP_SHORT_NAME . ": New Password - Confirmation Required");
}
示例13: getDefaultActions
/**
* Method used to get the full list of default notification
* actions.
*
* @access public
* @return array The list of default notification actions
*/
function getDefaultActions()
{
$actions = array();
$setup = Setup::load();
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;
}
示例14: 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::load();
$settings = $setup["{$type}_routing"];
if (!is_array($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 (strchr($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;
}
示例15: 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::load();
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;
}