/** * 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); } }
/** * 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; }
/** * 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; }
/** * 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); } }
/** * 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 '*****@*****.**' 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; }
/** * 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; } }
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();
$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();
/** * 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; }
/** * 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; }
/** * 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; } } }
/** * 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"); }
/** * 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; }
/** * 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 '*****@*****.**' 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; }
/** * 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; }
/** * Method used to get the list of email addresses to use * to send diagnostic information about the reminder system. * * @access private * @return array The list of alert email addresses */ function _getReminderAlertAddresses() { $emails = array(); $setup = Setup::load(); if (@$setup['email_reminder']['status'] == 'enabled' && !empty($setup['email_reminder']['addresses'])) { $addresses = $setup['email_reminder']['addresses']; $emails = explode(',', $addresses); } $emails = array_map('trim', $emails); return $emails; }
/** * Method used to perform a specific action to an issue. * * @access public * @param integer $issue_id The issue ID * @param array $reminder The reminder details * @param array $action The action details * @return boolean */ function perform($issue_id, $reminder, $action) { $type = ''; // - see which action type we're talking about here... $action_type = Reminder_Action::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 " - 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 " - No group associated with issue {$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 " - Performing action '{$action_type}' for issue #{$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 = Reminder_Action::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 = Reminder_Action::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 { // otherwise, check for the clocked-in status if (User::isClockedIn($key)) { $sms_email = User::getSMS($key); 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; } $data = Notification::getIssueDetails($issue_id); $conditions = Reminder_Condition::getAdminList($action['rma_id']); // alert IRC if needed if ($action['rma_alert_irc']) { if (Reminder::isDebug()) { echo " - Processing IRC notification\n"; } $irc_notice = "Issue #{$issue_id} (Priority: " . $data['pri_title']; // also add information about the assignee, if any $assignment = Issue::getAssignedUsers($issue_id); if (count($assignment) > 0) { $irc_notice .= "; Assignment: " . implode(', ', $assignment); } if (!empty($data['iss_grp_id'])) { $irc_notice .= "; Group: " . Group::getName($data['iss_grp_id']); } $irc_notice .= "), Reminder action '" . $action['rma_title'] . "' was just triggered"; Notification::notifyIRC(Issue::getProjectID($issue_id), $irc_notice, $issue_id); } $setup = Setup::load(); // if there are no recipients, then just skip to the next action if (count($to) == 0) { if (Reminder::isDebug()) { echo " - No recipients could be found\n"; } // if not even an irc alert was sent, then save // a notice about this on reminder_sent@, if needed if (!$action['rma_alert_irc']) { if (@$setup['email_reminder']['status'] == 'enabled') { Reminder_Action::_recordNoRecipientError($issue_id, $type, $reminder, $action); } return false; } } // - save a history entry about this action Reminder_Action::saveHistory($issue_id, $action['rma_id']); // - save this action as the latest triggered one for the given issue ID Reminder_Action::recordLastTriggered($issue_id, $action['rma_id']); // - perform the action if (count($to) > 0) { // send a copy of this reminder to reminder_sent@, if needed if (@$setup['email_reminder']['status'] == 'enabled' && !empty($setup['email_reminder']['addresses'])) { $addresses = Reminder::_getReminderAlertAddresses(); if (count($addresses) > 0) { $to = array_merge($to, $addresses); } } $tpl = new Template_API(); $tpl->setTemplate('reminders/' . $type . '_alert.tpl.text'); $tpl->bulkAssign(array("data" => $data, "reminder" => $reminder, "action" => $action, "conditions" => $conditions, "has_customer_integration" => Customer::hasCustomerIntegration(Issue::getProjectID($issue_id)))); $text_message = $tpl->getTemplateContents(); foreach ($to as $address) { // send email (use PEAR's classes) $mail = new Mail_API(); $mail->setTextBody($text_message); $setup = $mail->getSMTPSettings(); $mail->send($setup["from"], $address, "[#{$issue_id}] Reminder: " . $action['rma_title'], 0, $issue_id, 'reminder'); } } // - eventum saves the day once again return true; }
/** * Get ScmCheckin based on SCM name * * @param string $scm_name * @return ScmCheckin * @throws Exception */ private static function getScmCheckinByName($scm_name) { static $instances; if (isset($instances[$scm_name])) { return $instances[$scm_name]; } $setup =& Setup::load(); // handle legacy setup, convert existing config to be known under name 'default' if (!isset($setup['scm'])) { $scm = array('name' => 'default', 'checkout_url' => $setup['checkout_url'], 'diff_url' => $setup['diff_url'], 'log_url' => $setup['scm_log_url']); $setup['scm'][$scm['name']] = $scm; Setup::save($setup); } if (!isset($setup['scm'][$scm_name])) { throw new Exception("SCM '{$scm_name}' not defined"); } return $instances[$scm_name] = new ScmCheckin($setup['scm'][$scm_name]); }
$param[1] = false; } $parameters[str_replace("-", "", $param[0])] = $param[1]; } else { // Unknown parameter exit("Unknown parameter: \"" . $argv[$i] . "\"\n"); } } if (!empty($function)) { switch ($function) { case 'setup': if ($displayHelp) { echo "setup: Display setup.\nParameters:\n --help or -h: Display this help\n"; } else { $setup = new Setup(); $set = $setup->load(); foreach ($set as $name => $entry) { if ($entry['type'] == 'password') { echo " * " . $name . ": ******** (" . $entry['description'] . ")\n"; } else { echo " * " . $name . ": " . $entry['value'] . " (" . $entry['description'] . ")\n"; } } } break; case 'testsuites': if ($displayHelp) { echo "testsuites: Display testsuites.\nParameters:\n --help or -h: Display this help\n"; } else { $testSuiteManager = new TestSuiteManager(); $testsuites = $testSuiteManager->searchTestsuites();
/** * return error message as string, or true indicating success * requires setup to be written first. */ function setup_database() { $conn = DB_Helper::getInstance(false); $db_exists = checkDatabaseExists($conn, $_POST['db_name']); if (!$db_exists) { if (@$_POST['create_db'] == 'yes') { try { $conn->query("CREATE DATABASE {{{$_POST['db_name']}}}"); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('create_db', $e->getMessage())); } } else { throw new RuntimeException('The provided database name could not be found. Review your information or specify that the database should be created in the form below.'); } } // create the new user, if needed if (@$_POST['alternate_user'] == 'yes') { $user_list = getUserList($conn); if ($user_list) { $user_exists = in_array(strtolower(@$_POST['eventum_user']), $user_list); if (@$_POST['create_user'] == 'yes') { if (!$user_exists) { $stmt = "GRANT SELECT, UPDATE, DELETE, INSERT, ALTER, DROP, CREATE, INDEX ON {{{$_POST['db_name']}}}.* TO ?@'%' IDENTIFIED BY ?"; try { $conn->query($stmt, array($_POST['eventum_user'], $_POST['eventum_password'])); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('create_user', $e->getMessage())); } } } else { if (!$user_exists) { throw new RuntimeException('The provided MySQL username could not be found. Review your information or specify that the username should be created in the form below.'); } } } } // check if we can use the database try { $conn->query("USE {{{$_POST['db_name']}}}"); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('select_db', $e->getMessage())); } // set sql mode (sad that we rely on old bad mysql defaults) $conn->query("SET SQL_MODE = ''"); // check the CREATE and DROP privileges by trying to create and drop a test table $table_list = getTableList($conn); if (!in_array('eventum_test', $table_list)) { try { $conn->query('CREATE TABLE eventum_test (test char(1))'); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('create_test', $e->getMessage())); } } try { $conn->query('DROP TABLE eventum_test'); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('drop_test', $e->getMessage())); } // if requested. drop tables first if (@$_POST['drop_tables'] == 'yes') { $queries = get_queries(APP_PATH . '/upgrade/drop.sql'); foreach ($queries as $stmt) { try { $conn->query($stmt); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('drop_table', $e->getMessage())); } } } // setup database with upgrade script $upgrade_script = APP_PATH . '/upgrade/update-database.php'; // use ob_ to strip out hashbang ob_start(); try { define('IN_SETUP', true); require $upgrade_script; $out = ob_get_clean(); $e = false; } catch (Exception $e) { $out = ob_get_clean(); } global $tpl; $tpl->assign('db_result', strip_hashbang($out)); if ($e) { throw new RuntimeException("Database setup failed on upgrade:<br/><tt>{$e->getMessage()}</tt><br/><br/>You may want run update script <tt>{$upgrade_script}</tt> manually"); } $setup = Setup::load(); // write db name now that it has been created $setup['database']['database'] = $_POST['db_name']; // substitute the appropriate values in config.php!!! if (@$_POST['alternate_user'] == 'yes') { $setup['database']['username'] = $_POST['eventum_user']; $setup['database']['password'] = $_POST['eventum_password']; } Setup::save($setup); }
/** * Method used to get the title given to the current installation of Eventum. * * @return string The installation title */ public static function getToolCaption() { $setup = Setup::load(); return !empty($setup['tool_caption']) ? $setup['tool_caption'] : APP_NAME; }
/** * Method used to save a copy of the given email to a configurable address. * * @param array $email The email to save. */ public static function saveOutgoingEmailCopy(&$email) { // check early: do we really want to save every outgoing email? $setup = Setup::load(); $save_outgoing_email = !empty($setup['smtp']['save_outgoing_email']) && $setup['smtp']['save_outgoing_email'] == 'yes'; if (!$save_outgoing_email || empty($setup['smtp']['save_address'])) { return false; } static $subjects = array(); $hdrs =& $email['headers']; $body =& $email['body']; $issue_id = $email['maq_iss_id']; $sender_usr_id = $email['maq_usr_id']; // ok, now parse the headers text and build the assoc array $full_email = $hdrs . "\n\n" . $body; $structure = Mime_Helper::decode($full_email, false, false); $_headers =& $structure->headers; $header_names = Mime_Helper::getHeaderNames($hdrs); $headers = array(); foreach ($_headers as $lowercase_name => $value) { // need to remove the quotes to avoid a parsing problem // on senders that have extended characters in the first // or last words in their sender name if ($lowercase_name == 'from') { $value = Mime_Helper::removeQuotes($value); } $value = Mime_Helper::encode($value); // add the quotes back if ($lowercase_name == 'from') { $value = Mime_Helper::quoteSender($value); } $headers[$header_names[$lowercase_name]] = $value; } // remove any Reply-To:/Return-Path: values from outgoing messages unset($headers['Reply-To']); unset($headers['Return-Path']); // prevent duplicate emails from being sent out... $subject = @$headers['Subject']; if (@in_array($subject, $subjects)) { return false; } // replace the To: header with the requested address $address = $setup['smtp']['save_address']; $headers['To'] = $address; // add specialized headers if they are not already added if (empty($headers['X-Eventum-Type'])) { $headers += self::getSpecializedHeaders($issue_id, $email['maq_type'], $headers, $sender_usr_id); } $params = self::getSMTPSettings($address); $mail = Mail::factory('smtp', $params); $res = $mail->send($address, $headers, $body); if (Misc::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); } $subjects[] = $subject; }
/** * Creates a new issue from an email if appropriate. Also returns if this message is related * to a previous message. * * @access private * @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. * @return array An array of information about the message */ function createIssueFromEmail($info, $headers, $message_body, $date, $from, $subject) { $should_create_issue = false; $issue_id = ''; $associate_email = ''; $type = 'email'; $parent_id = ''; // 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_API::getAllReferences($headers); $message_id = Mail_API::getMessageID($headers, $message_body); $setup = Setup::load(); if (@$setup['subject_based_routing']['status'] == 'enabled' && 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 { // - 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 (Support::exists($reference_msg_id) || Issue::getIssueByRootMessageID($reference_msg_id) != false) { // email or issue exists $issue_id = Support::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: // => create new issue and associate current email with it $should_create_issue = true; } } } else { // - if this email is not a reply: // -> create new issue and associate current email with it $should_create_issue = true; } if (empty($issue_id)) { $issue_id = Issue::getIssueBy($subject, 'iss_summary'); if (!empty($issue_id)) { $should_create_issue = false; } } } $sender_email = Mail_API::getEmailAddress($from); // only create a new issue if this email is coming from a known customer if ($should_create_issue && $info['ema_issue_auto_creation_options']['only_known_customers'] == 'yes' && Customer::hasCustomerIntegration($info['ema_prj_id'])) { list($customer_id, ) = Customer::getCustomerIDByEmails($info['ema_prj_id'], array($sender_email)); if (empty($customer_id)) { $should_create_issue = false; } } // check whether we need to create a new issue or not if ($info['ema_issue_auto_creation'] == 'enabled' && $should_create_issue) { $options = Email_Account::getIssueAutoCreationOptions($info['ema_id']); Auth::createFakeCookie(APP_SYSTEM_USER_ID, $info['ema_prj_id']); $issue_id = Issue::createFromEmail($info['ema_prj_id'], APP_SYSTEM_USER_ID, $from, Mime_Helper::fixEncoding($subject), $message_body, @$options['category'], $options['priority'], @$options['users'], $date, $message_id); // associate any existing replied-to email with this new issue if (!empty($associate_email) && !empty($reference_issue_id)) { $reference_sup_id = Support::getIDByMessageID($associate_email); Support::associate(APP_SYSTEM_USER_ID, $issue_id, array($reference_sup_id)); } } // need to check crm for customer association if (!empty($from)) { $details = Email_Account::getDetails($info['ema_id']); if (Customer::hasCustomerIntegration($info['ema_prj_id'])) { // check for any customer contact association @(list($customer_id, ) = Customer::getCustomerIDByEmails($info['ema_prj_id'], array($sender_email))); } } return array('should_create_issue' => $should_create_issue, 'associate_email' => $associate_email, 'issue_id' => $issue_id, 'customer_id' => @$customer_id, 'type' => $type, 'parent_id' => $parent_id); }
/** * @param int $issue_id * @return array * @access protected */ public function getEmailListing($issue_id) { $real_emails = Support::getEmailsByIssue($issue_id); if (is_array($real_emails)) { foreach ($real_emails as $i => &$email) { $email['id'] = $i + 1; unset($email['seb_body']); } } $setup = Setup::load(); if (isset($setup['description_email_0']) && $setup['description_email_0'] == 'enabled') { $issue = Issue::getDetails($issue_id); $email = array('id' => 0, 'sup_date' => $issue['iss_created_date'], 'sup_from' => $issue['reporter'], 'sup_to' => '', 'sup_cc' => '', 'sup_subject' => $issue['iss_summary']); if ($real_emails != '') { $emails = array_merge(array($email), $real_emails); } else { $emails[] = $email; } } else { $emails = $real_emails; } return $emails; }
/** * Processes the template and assigns common variables automatically. * * @access private */ function processTemplate() { global $HTTP_SERVER_VARS; // determine the correct CSS file to use if (ereg('MSIE ([0-9].[0-9]{1,2})', @$HTTP_SERVER_VARS["HTTP_USER_AGENT"], $log_version)) { $user_agent = 'ie'; } else { $user_agent = 'other'; } $this->assign("user_agent", $user_agent); // create the list of projects $usr_id = Auth::getUserID(); if ($usr_id != '') { $prj_id = Auth::getCurrentProject(); if (!empty($prj_id)) { $role_id = User::getRoleByUser($usr_id, $prj_id); $this->assign("current_project", $prj_id); $this->assign("current_project_name", Auth::getCurrentProjectName()); $has_customer_integration = Customer::hasCustomerIntegration($prj_id); $this->assign("has_customer_integration", $has_customer_integration); if ($has_customer_integration) { $this->assign("customer_backend_name", Customer::getBackendImplementationName($prj_id)); } if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) { $this->assign("show_admin_link", true); } if ($role_id > 0) { $this->assign("current_role", (int) $role_id); $this->assign("current_role_name", User::getRole($role_id)); } } $info = User::getNameEmail($usr_id); $this->assign("active_projects", Project::getAssocList($usr_id)); $this->assign("current_full_name", $info["usr_full_name"]); $this->assign("current_email", $info["usr_email"]); $this->assign("current_user_id", $usr_id); $this->assign("is_current_user_clocked_in", User::isClockedIn($usr_id)); $this->assign("roles", User::getAssocRoleIDs()); } $this->assign("app_setup", Setup::load()); $this->assign("app_setup_path", APP_SETUP_PATH); $this->assign("app_setup_file", APP_SETUP_FILE); $this->assign("application_version", APP_VERSION); $this->assign("application_title", APP_NAME); $this->assign("app_base_url", APP_BASE_URL); $this->assign("rel_url", APP_RELATIVE_URL); $this->assign("lang", APP_CURRENT_LANG); $this->assign("SID", SID); // now for the browser detection stuff Net_UserAgent_Detect::detect(); $this->assign("browser", Net_UserAgent_Detect::_getStaticProperty('browser')); $this->assign("os", Net_UserAgent_Detect::_getStaticProperty('os')); // this is only used by the textarea resize script $js_script_name = str_replace('/', '_', str_replace('.php', '', $HTTP_SERVER_VARS['PHP_SELF'])); $this->assign("js_script_name", $js_script_name); $this->assign("total_queries", $GLOBALS['TOTAL_QUERIES']); $this->assign(array("cell_color" => APP_CELL_COLOR, "light_color" => APP_LIGHT_COLOR, "middle_color" => APP_MIDDLE_COLOR, "dark_color" => APP_DARK_COLOR, "cycle" => APP_CYCLE_COLORS, "internal_color" => APP_INTERNAL_COLOR)); }
/** * Method used to save a copy of the given email to a configurable address. * * @access public * @param array $email The email to save. */ function saveEmailInformation($email) { static $subjects; $hdrs = $email['headers']; $body = $email['body']; $issue_id = $email['maq_iss_id']; $sender_usr_id = $email['maq_usr_id']; // do we really want to save every outgoing email? $setup = Setup::load(); if (@$setup['smtp']['save_outgoing_email'] != 'yes' || empty($setup['smtp']['save_address'])) { return false; } // ok, now parse the headers text and build the assoc array $full_email = $hdrs . "\n\n" . $body; $structure = Mime_Helper::decode($full_email, FALSE, FALSE); $_headers =& $structure->headers; $header_names = Mime_Helper::getHeaderNames($hdrs); $headers = array(); foreach ($_headers as $lowercase_name => $value) { $headers[$header_names[$lowercase_name]] = $value; } // remove any Reply-To:/Return-Path: values from outgoing messages unset($headers['Reply-To']); unset($headers['Return-Path']); // prevent duplicate emails from being sent out... $subject = @$headers['Subject']; if (@in_array($subject, $subjects)) { return false; } // replace the To: header with the requested address $address = $setup['smtp']['save_address']; $headers['To'] = $address; // add specialized headers if they are not already added if (empty($headers['X-Eventum-Type'])) { $headers += Mail_API::getSpecializedHeaders($issue_id, $email['maq_type'], $headers, $sender_usr_id); } $params = Mail_API::getSMTPSettings($address); $mail =& Mail::factory('smtp', $params); $res = $mail->send($address, $headers, $body); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); } $subjects[] = $subject; }
/** * 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::load(); 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: // => create new issue and associate current email with it $should_create_issue = true; } } } else { // - if this email is not a reply: // -> create new issue and associate current email with it $should_create_issue = true; } } } $sender_email = Mail_Helper::getEmailAddress($from); if (Misc::isError($sender_email)) { $sender_email = 'Error Parsing Email <>'; } // only create a new issue if this email is coming from a known customer if ($should_create_issue && $info['ema_issue_auto_creation_options']['only_known_customers'] == 'yes' && CRM::hasCustomerIntegration($info['ema_prj_id']) && !$customer_id) { try { $crm = CRM::getInstance($info['ema_prj_id']); $should_create_issue = true; } catch (CRMException $e) { $should_create_issue = false; } } // check whether we need to create a new issue or not if ($info['ema_issue_auto_creation'] == 'enabled' && $should_create_issue && !Notification::isBounceMessage($sender_email)) { $options = Email_Account::getIssueAutoCreationOptions($info['ema_id']); Auth::createFakeCookie(APP_SYSTEM_USER_ID, $info['ema_prj_id']); $issue_id = Issue::createFromEmail($info['ema_prj_id'], APP_SYSTEM_USER_ID, $from, Mime_Helper::decodeQuotedPrintable($subject), $message_body, @$options['category'], @$options['priority'], @$options['users'], $date, $message_id, $severity, $customer_id, $contact_id, $contract_id); // add sender to authorized repliers list if they are not a real user $sender_usr_id = User::getUserIDByEmail($sender_email, true); if (empty($sender_usr_id)) { Authorized_Replier::manualInsert($issue_id, $sender_email, false); } // associate any existing replied-to email with this new issue if (!empty($associate_email) && !empty($reference_issue_id)) { $reference_sup_id = self::getIDByMessageID($associate_email); self::associate(APP_SYSTEM_USER_ID, $issue_id, array($reference_sup_id)); } } // need to check crm for customer association if (!empty($from)) { if (CRM::hasCustomerIntegration($info['ema_prj_id']) && !$customer_id) { // check for any customer contact association try { $crm = CRM::getInstance($info['ema_prj_id']); $contact = $crm->getContactByEmail($sender_email); $contact_id = $contact->getContactID(); $contracts = $contact->getContracts(array(CRM_EXCLUDE_EXPIRED)); $contract = $contracts[0]; $customer_id = $contract->getCustomerID(); } catch (CRMException $e) { $customer_id = null; $contact_id = null; } } } return array('should_create_issue' => $should_create_issue, 'associate_email' => $associate_email, 'issue_id' => $issue_id, 'customer_id' => $customer_id, 'contact_id' => $contact_id, 'type' => $type, 'parent_id' => $parent_id); }
include_once APP_INC_PATH . "class.setup.php"; include_once APP_INC_PATH . "class.date.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("preferences.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $usr_id = Auth::getUserID(); if (@$HTTP_POST_VARS["cat"] == "update_account") { $res = Prefs::set($usr_id); $tpl->assign('update_account_result', $res); User::updateSMS($usr_id, @$HTTP_POST_VARS['sms_email']); } elseif (@$HTTP_POST_VARS["cat"] == "update_name") { $res = User::updateFullName($usr_id); $tpl->assign('update_name_result', $res); } elseif (@$HTTP_POST_VARS["cat"] == "update_email") { $res = User::updateEmail($usr_id); $tpl->assign('update_email_result', $res); } elseif (@$HTTP_POST_VARS["cat"] == "update_password") { $res = User::updatePassword($usr_id); $tpl->assign('update_password_result', $res); } $prefs = Prefs::get($usr_id); $prefs['sms_email'] = User::getSMS($usr_id); // if the user has no preferences set yet, get it from the system-wide options if (empty($prefs)) { $prefs = Setup::load(); } $tpl->assign("user_prefs", $prefs); $tpl->assign("assigned_projects", Project::getAssocList($usr_id, false, true)); $tpl->assign("zones", Date_API::getTimezoneList()); $tpl->displayTemplate();
/** * Method used to get the title given to the current installation of Eventum. * * @access public * @return string The installation title */ function getToolCaption() { $setup = Setup::load(); return @$setup['tool_caption'] ? $setup['tool_caption'] : APP_NAME; }
/** * 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::load(); $this->config_setup_copy =& $setup; foreach ($defaults as $key => $value) { if (isset($setup['workflow'][$name][$key])) { continue; } $setup['workflow'][$name][$key] = $value; } $this->configLoaded = true; $this->config =& $setup['workflow'][$name]; }