public function send(TBGMimemail $email) { try { TBGContext::getI18n(); } catch (Exception $e) { TBGContext::reinitializeI18n(null); } if (!$email->hasRecipients()) { throw new Exception(TBGContext::getI18n()->__('You need to add at least one recipient')); } if (!$email->hasSender()) { throw new Exception(TBGContext::getI18n()->__('You need to add a sender name and address')); } try { if ($this->type == self::MAIL_TYPE_PHP) { $retval = $this->_mail($email); } else { require_once THEBUGGENIE_CORE_PATH . 'lib' . DS . 'swift' . DS . 'lib' . DS . 'swift_required.php'; $retval = $this->_mail2($email); } } catch (Exception $e) { throw $e; } return $retval; }
public function do_execute() { if (file_exists(THEBUGGENIE_PATH . 'installed')) { $this->cliEcho("The Bug Genie seems to already be installed.\n", 'red', 'bold'); $this->cliEcho('Please remove the file '); $this->cliEcho(THEBUGGENIE_PATH . 'installed', 'white', 'bold'); $this->cliEcho(' and try again.'); $this->cliEcho("\n"); return; } $this->cliEcho("\nWelcome to the \"The Bug Genie\" installation wizard!\n", 'white', 'bold'); $this->cliEcho("This wizard will take you through the installation of The Bug Genie.\nRemember that you can also install The Bug Genie from your web-browser.\n"); $this->cliEcho("Simply point your web-browser to the The Bug Genie subdirectory on your web server,\nand the installation will start.\n\n"); $this->cliEcho("Press ENTER to continue with the installation: "); $this->pressEnterToContinue(); $this->cliEcho("\n"); $this->cliEcho("How to support future development\n", 'green', 'bold'); $this->cliEcho("Even though this software has been provided to you free of charge,\ndeveloping it would not have been possible without support from our users.\n"); $this->cliEcho("By making a donation, or buying a support contract you can help us continue development.\n\n"); $this->cliEcho("If this software is valuable to you - please consider supporting it.\n\n"); $this->cliEcho("More information about supporting The Bug Genie's development can be found here:\n"); $this->cliEcho("http://www.thebuggenie.com/giving_back.php\n\n", 'blue', 'underline'); $this->cliEcho("Press ENTER to continue: "); $this->pressEnterToContinue(); $this->cliEcho("\n"); try { $this->cliEcho("License information\n", 'green', 'bold'); $this->cliEcho("This software is Open Source Initiative approved Open Source Software.\nOpen Source Initiative Approved is a trademark of the Open Source Initiative.\n\n"); $this->cliEcho("True to the the Open Source Definition, The Bug Genie is released\nunder the MPL 1.1 only. You can read the full license here:\n"); $this->cliEcho("http://www.opensource.org/licenses/mozilla1.1.php\n\n", 'blue', 'underline'); if ($this->getProvidedArgument('accept_license') != 'yes') { $this->cliEcho("Before you can continue the installation, you need to confirm that you \nagree to be bound by the terms in this license.\n\n"); $this->cliEcho("Do you agree to be bound by the terms in the MPL 1.1 license?\n(type \"yes\" to agree, anything else aborts the installation): "); if (!$this->askToAccept()) { throw new Exception($this->cliEcho('You need to accept the license to continue', 'red', 'bold')); } } else { $this->cliEcho('You have accepted the license', 'yellow', 'bold'); $this->cliEcho("\n\n"); } $not_well = array(); if (!is_writable('core/B2DB/')) { $not_well[] = 'b2db_perm'; } if (!is_writable(THEBUGGENIE_PATH)) { $not_well[] = 'root'; } if (count($not_well) > 0) { $this->cliEcho("\n"); foreach ($not_well as $afail) { switch ($afail) { case 'b2db_perm': $this->cliEcho("Could not write to the B2DB directory\n", 'red', 'bold'); $this->cliEcho('The folder '); $this->cliEcho('include/B2DB', 'white', 'bold'); $this->cliEcho(' folder needs to be writable'); break; case 'root': $this->cliEcho("Could not write to the main directory\n", 'red', 'bold'); $this->cliEcho('The top level folder must be writable during installation'); break; } } throw new Exception("\n\nYou need to correct the above errors before the installation can continue."); } else { $this->cliEcho("Step 1 - database information\n"); if (file_exists('core/b2db_bootstrap.inc.php')) { $this->cliEcho("You seem to already have completed this step successfully.\n"); if ($this->getProvidedArgument('use_existing_db_info') == 'yes') { $this->cliEcho("\n"); $this->cliEcho("Using existing database information\n", 'yellow', 'bold'); $use_existing_db_info = true; } else { $this->cliEcho("Do you want to use the stored settings?\n", 'white', 'bold'); $this->cliEcho("\nType \"no\" to enter new settings, press ENTER to use existing: ", 'white', 'bold'); $use_existing_db_info = $this->askToDecline(); } $this->cliEcho("\n"); } else { $use_existing_db_info = false; } if (!$use_existing_db_info) { $this->cliEcho("The Bug Genie uses a database to store information. To be able to connect\nto your database, The Bug Genie needs some information, such as\ndatabase type, username, password, etc.\n\n"); $this->cliEcho("Please select what kind of database you are installing The Bug Genie on:\n"); B2DB::setHTMLException(false); $db_types = array(); foreach (B2DB::getDBtypes() as $db_type => $db_desc) { $db_types[] = $db_type; $this->cliEcho(count($db_types) . ': ' . $db_desc . "\n", 'white', 'bold'); } do { $this->cliEcho('Enter the corresponding number for the database (1-' . count($db_types) . '): '); $db_selection = $this->getInput(); if (!isset($db_types[(int) $db_selection - 1])) { throw new Exception($db_selection . ' is not a valid database type selection'); } $db_type = $db_types[(int) $db_selection - 1]; $this->cliEcho("Selected database type: "); $this->cliEcho($db_type . "\n\n"); $this->cliEcho("Please enter the database hostname: \n"); $this->cliEcho('Database hostname [localhost]: ', 'white', 'bold'); $db_hostname = $this->getInput(); $db_hostname = $db_hostname == '' ? 'localhost' : $db_hostname; $this->cliEcho("\nPlease enter the username The Bug Genie will use to connect to the database: \n"); $this->cliEcho('Database username: '******'white', 'bold'); $db_username = $this->getInput(); $this->cliEcho("Database password (press ENTER if blank): ", 'white', 'bold'); $db_password = $this->getInput(); $this->cliEcho("\nPlease enter the database The Bug Genie will use.\nIf it does not exist, The Bug Genie will create it for you.\n(the default database name is "); $this->cliEcho("thebuggenie_db", 'white', 'bold'); $this->cliEcho(" - press ENTER to use that):\n"); $this->cliEcho('Database name: ', 'white', 'bold'); $db_name = $this->getInput('thebuggenie_db'); $this->cliEcho("\n"); $this->cliEcho("The following settings will be used:\n"); $this->cliEcho("Database type: \t\t", 'white', 'bold'); $this->cliEcho($db_type . "\n"); $this->cliEcho("Database hostname: \t", 'white', 'bold'); $this->cliEcho($db_hostname . "\n"); $this->cliEcho("Database username: \t", 'white', 'bold'); $this->cliEcho($db_username . "\n"); $this->cliEcho("Database password: \t", 'white', 'bold'); $this->cliEcho($db_password . "\n"); $this->cliEcho("Database name: \t\t", 'white', 'bold'); $this->cliEcho($db_name . "\n"); $this->cliEcho("\nIf these settings are ok, press ENTER, or anything else to retry: "); $e_ok = $this->askToDecline(); } while (!$e_ok); try { B2DB::setHost($db_hostname); B2DB::setUname($db_username); B2DB::setPasswd($db_password); B2DB::setDBtype($db_type); B2DB::initialize(); $engine_path = B2DB::getEngineClassPath(); if ($engine_path !== null) { TBGContext::addClasspath($engine_path); } else { throw new Exception("Cannot initialize the B2DB engine"); } B2DB::doConnect(); B2DB::createDatabase($db_name); B2DB::setDBname($db_name); B2DB::doConnect(); } catch (Exception $e) { throw new Exception("Could not connect to the database:\n" . $e->getMessage()); } B2DB::setDBname($db_name); B2DB::doSelectDB(); $this->cliEcho("\nSuccessfully connected to the database.\n", 'green'); $this->cliEcho("Press ENTER to continue ... "); $this->pressEnterToContinue(); $this->cliEcho("\n"); $this->cliEcho("Saving database connection information ... ", 'white', 'bold'); $this->cliEcho("\n"); B2DB::saveConnectionParameters(THEBUGGENIE_CORE_PATH . 'b2db_bootstrap.inc.php'); $this->cliEcho("Successfully saved database connection information.\n", 'green'); $this->cliEcho("\n"); } else { B2DB::initialize(THEBUGGENIE_CORE_PATH . 'b2db_bootstrap.inc.php'); $this->cliEcho("Successfully connected to the database.\n", 'green'); if ($this->getProvidedArgument('use_existing_db_info') != 'yes') { $this->cliEcho("Press ENTER to continue ... "); $this->pressEnterToContinue(); } } $this->cliEcho("\nThe Bug Genie needs some server settings to function properly...\n\n"); do { $this->cliEcho("URL rewriting\n", 'cyan', 'bold'); $this->cliEcho("The Bug Genie uses a technique called \"url rewriting\" - which allows for pretty\nURLs such as ") . $this->cliEcho('/issue/1', 'white', 'bold') . $this->cliEcho(' instead of ') . $this->cliEcho("viewissue.php?issue_id=1\n", 'white', 'bold'); $this->cliEcho("Make sure you have read the URL_REWRITE document located in the root\nfolder, or at http://www.thebuggenie.com before you continue\n"); if (!$this->hasProvidedArgument('url_subdir')) { $this->cliEcho("Press ENTER to continue ... "); $this->pressEnterToContinue(); } $this->cliEcho("\n"); $this->cliEcho("The Bug Genie subdir\n", 'white', 'bold'); $this->cliEcho("This is the sub-path of the Web server where The Bug Genie will be located.\n"); if ($this->hasProvidedArgument('url_subdir')) { $this->cliEcho('The Bug Genie subdir: ', 'white', 'bold'); $url_subdir = $this->getProvidedArgument('url_subdir'); $this->cliEcho($url_subdir, 'yellow', 'bold'); $this->cliEcho("\n"); } else { $this->cliEcho('Start and end this with a forward slash', 'white', 'bold'); $this->cliEcho(". (ex: \"/thebuggenie/\")\nIf The Bug Genie is running at the root directory, just type \"/\" (without the quotes)\n\n"); $this->cliEcho('The Bug Genie subdir: ', 'white', 'bold'); $url_subdir = $this->getInput(); } $this->cliEcho("\n"); $this->cliEcho("The Bug Genie will now be accessible at\n"); $this->cliEcho("http://example.com" . $url_subdir, 'white', 'bold'); if ($this->hasProvidedArgument('url_subdir')) { $this->cliEcho("\n"); $this->cliEcho("Using existing values", 'yellow', 'bold'); $this->cliEcho("\n"); $e_ok = true; } else { $this->cliEcho("\nPress ENTER if ok, or \"no\" to try again: "); $e_ok = $this->askToDecline(); } $this->cliEcho("\n"); } while (!$e_ok); if ($this->getProvidedArgument('setup_htaccess') != 'yes') { $this->cliEcho("Setup can autoconfigure your .htaccess file (located in the thebuggenie/ subfolder), so you don't have to.\n"); $this->cliEcho('Would you like setup to auto-generate the .htaccess file for you?'); $this->cliEcho("\nPress ENTER if ok, or \"no\" to not set up the .htaccess file: "); $htaccess_ok = $this->askToDecline(); } else { $this->cliEcho('Autoconfiguring .htaccess', 'yellow', 'bold'); $this->cliEcho("\n"); $htaccess_ok = true; } $this->cliEcho("\n"); if ($htaccess_ok) { if (!is_writable(THEBUGGENIE_PATH . 'thebuggenie/') || file_exists(THEBUGGENIE_PATH . 'thebuggenie/.htaccess') && !is_writable(THEBUGGENIE_PATH . 'thebuggenie/.htaccess')) { $this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.htaccess\n", 'red', 'bold'); $this->cliEcho("You will have to set up the .htaccess file yourself. See the README file for more information.\n", 'white', 'bold'); $this->cliEcho('Please note: ', 'white', 'bold'); $this->cliEcho("The Bug Genie will not function properly until the .htaccess file is properly set up!\n"); } else { $content = str_replace('###PUT URL SUBDIRECTORY HERE###', $url_subdir, file_get_contents(THEBUGGENIE_CORE_PATH . 'templates/htaccess.template')); file_put_contents(THEBUGGENIE_PATH . 'thebuggenie/.htaccess', $content); if (file_get_contents(THEBUGGENIE_PATH . 'thebuggenie/.htaccess') != $content) { $this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.htaccess\n", 'red', 'bold'); $this->cliEcho("You will have to set up the .htaccess file yourself. See the README file for more information.\n", 'white', 'bold'); $this->cliEcho('Please note: ', 'white', 'bold'); $this->cliEcho("The Bug Genie will not function properly until the .htaccess file is properly set up!\n"); } else { $this->cliEcho("The .htaccess file was successfully set up...\n", 'green', 'bold'); } } } else { $this->cliEcho("Skipping .htaccess auto-setup."); } if ($this->getProvidedArgument('setup_htaccess') != 'yes') { $this->cliEcho("Press ENTER to continue ... "); $this->pressEnterToContinue(); $this->cliEcho("\n"); } $enable_modules = array(); if ($this->getProvidedArgument('enable_all_modules') != 'yes') { $this->cliEcho("You will now get a list of available modules.\nTo enable the module after installation, just press ENTER.\nIf you don't want to enable the module, type \"no\".\nRemember that all these modules can be disabled/uninstalled after installation.\n\n"); } $this->cliEcho("Enable incoming and outgoing email? ", 'white', 'bold') . $this->cliEcho('(yes): '); $enable_modules['mailing'] = $this->getProvidedArgument('enable_all_modules') == 'yes' ? true : $this->askToDecline(); if ($this->getProvidedArgument('enable_all_modules') == 'yes') { $this->cliEcho("Yes\n", 'yellow', 'bold'); } $this->cliEcho("Enable communication with version control systems (i.e. svn)? ", 'white', 'bold') . $this->cliEcho('(yes): '); $enable_modules['vcs_integration'] = $this->getProvidedArgument('enable_all_modules') == 'yes' ? true : $this->askToDecline(); if ($this->getProvidedArgument('enable_all_modules') == 'yes') { $this->cliEcho("Yes\n", 'yellow', 'bold'); } $enable_modules['publish'] = true; $this->cliEcho("\n"); $this->cliEcho("Creating tables ...\n", 'white', 'bold'); $tables_path = THEBUGGENIE_CORE_PATH . 'classes' . DIRECTORY_SEPARATOR . 'B2DB' . DIRECTORY_SEPARATOR; TBGContext::addClasspath($tables_path); $tables_path_handle = opendir($tables_path); $tables_created = array(); while ($table_class_file = readdir($tables_path_handle)) { if (($tablename = substr($table_class_file, 0, strpos($table_class_file, '.'))) != '') { B2DB::getTable($tablename)->create(); $this->cliEcho("Creating table {$tablename}\n", 'white', 'bold'); } } $this->cliEcho("\n"); $this->cliEcho("All tables successfully created...\n\n", 'green', 'bold'); $this->cliEcho("Setting up initial scope... \n", 'white', 'bold'); TBGContext::reinitializeI18n('en_US'); $scope = new TBGScope(); $scope->setName('The default scope'); $scope->addHostname('*'); $scope->setEnabled(); TBGContext::setScope($scope); $scope->save(); TBGSettings::saveSetting('language', 'en_US'); $this->cliEcho("Initial scope setup successfully... \n\n", 'green', 'bold'); $this->cliEcho("Setting up modules... \n", 'white', 'bold'); try { foreach ($enable_modules as $module => $install) { if ((bool) $install && file_exists(THEBUGGENIE_MODULES_PATH . $module . DS . 'module')) { $this->cliEcho("Installing {$module}... \n"); TBGModule::installModule($module); $this->cliEcho("Module {$module} installed successfully...\n", 'green'); } } $this->cliEcho("\n"); $this->cliEcho("All modules installed successfully...\n", 'green', 'bold'); $this->cliEcho("\n"); $this->cliEcho("Finishing installation... \n", 'white', 'bold'); if (!is_writable(THEBUGGENIE_PATH . 'installed')) { $this->cliEcho("\n"); $this->cliEcho("Could not create the 'installed' file.\n", 'red', 'bold'); $this->cliEcho("Please create the file "); $this->cliEcho(THEBUGGENIE_PATH . "installed\n", 'white', 'bold'); $this->cliEcho("with the following line inside:\n"); $this->cliEcho('3.0, installed ' . date('d.m.Y H:i'), 'blue', 'bold'); $this->cliEcho("\n"); $this->cliEcho("This can be done by running the following command when installation has finished:\n"); $this->cliEcho('echo "3.0, installed ' . date('d.m.Y H:i') . '" > ' . THEBUGGENIE_PATH . 'installed', 'white', 'bold'); $this->cliEcho("\n"); $this->cliEcho("Press ENTER to continue ... "); $this->pressEnterToContinue(); $this->cliEcho("\n"); $this->cliEcho("\n"); } else { file_put_contents(THEBUGGENIE_PATH . 'installed', '3.0, installed ' . date('d.m.Y H:i')); } $this->cliEcho("The installation was completed successfully!\n", 'green', 'bold'); $this->cliEcho("\nTo use The Bug Genie, access http://example.com" . $url_subdir . "index.php with a web-browser.\n"); $this->cliEcho("The default username is ") . $this->cliEcho('Administrator') . $this->cliEcho(' and the password is ') . $this->cliEcho('admin'); $this->cliEcho("\n\nFor support, please visit ") . $this->cliEcho('http://www.thebuggenie.com/', 'blue', 'underline'); $this->cliEcho("\n"); } catch (Exception $e) { throw new Exception("Could not install the {$module} module:\n" . $e->getMessage()); } } } catch (Exception $e) { $this->cliEcho("\n\nThe installation was interrupted\n", 'red'); $this->cliEcho($e->getMessage() . "\n"); var_dump($e->getTraceAsString()); die; } $this->cliEcho("\n"); }
/** * Runs the action for the fourth step of the installation * where it loads fixtures and saves settings for url * * @param TBGRequest $request The request object * * @return null */ public function runInstallStep4(TBGRequest $request) { try { TBGLogging::log('Initializing language support'); TBGContext::reinitializeI18n('en_US'); TBGLogging::log('Loading fixtures for default scope'); $scope = new TBGScope(); $scope->addHostname('*'); $scope->setName('The default scope'); $scope->setEnabled(true); TBGContext::setScope($scope); $scope->save(); TBGLogging::log('Setting up default users and groups'); TBGSettings::saveSetting('language', 'en_US', 'core', 1); $this->htaccess_error = false; $this->htaccess_ok = (bool) $request->getParameter('apache_autosetup'); if ($request->getParameter('apache_autosetup')) { if (!is_writable(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/') || file_exists(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess') && !is_writable(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess')) { $this->htaccess_error = 'Permission denied when trying to save the [main folder]/' . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess'; } else { $content = str_replace('###PUT URL SUBDIRECTORY HERE###', $request->getParameter('url_subdir'), file_get_contents(THEBUGGENIE_CORE_PATH . '/templates/htaccess.template')); file_put_contents(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess', $content); if (file_get_contents(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess') != $content) { $this->htaccess_error = true; } } } } catch (Exception $e) { $this->error = $e->getMessage(); throw $e; } }
public static function processCommit(TBGProject $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null) { $output = ''; TBGContext::setCurrentProject($project); if ($project->isArchived()) { return; } try { TBGContext::getI18n(); } catch (Exception $e) { TBGContext::reinitializeI18n(null); } // Is VCS Integration enabled? if (TBGSettings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == TBGVCSIntegration::MODE_DISABLED) { $output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n"; return $output; } // Parse the commit message, and obtain the issues and transitions for issues. $parsed_commit = TBGIssue::getIssuesFromTextByRegex($commit_msg); $issues = $parsed_commit["issues"]; $transitions = $parsed_commit["transitions"]; // If no issues exist, we may not be able to continue // if (count($issues) == 0) // { // $output .= '[VCS '.$project->getKey().'] This project only accepts commits which affect issues' . "\n"; // return $output; // } // Build list of affected files $file_lines = preg_split('/[\\n\\r]+/', $changed); $files = array(); foreach ($file_lines as $aline) { $action = mb_substr($aline, 0, 1); if ($action == "A" || $action == "U" || $action == "D" || $action == "M") { $theline = trim(mb_substr($aline, 1)); $files[] = array($action, $theline); } } // Find author of commit, fallback is guest /* * Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format * Joe Bloggs <*****@*****.**>, instead of a classic username. Therefore a user will be found via 4 queries: * a) First we extract the email if there is one, and find a user with that email * b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email) * c) the username or full name is checked against the friendly name field * d) and if we still havent found one, then we check against the username * e) and if we STILL havent found one, we use the guest user */ if (preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) { $email = $matches[0]; // a) $user = TBGUsersTable::getTable()->getByEmail($email); if (!$user instanceof TBGUser) { // Not found by email preg_match("/(?<=^)(.*)(?= <)/", $author, $matches); $author = $matches[0]; } } // b) if (!$user instanceof TBGUser) { $user = TBGUsersTable::getTable()->getByRealname($author); } // c) if (!$user instanceof TBGUser) { $user = TBGUsersTable::getTable()->getByBuddyname($author); } // d) if (!$user instanceof TBGUser) { $user = TBGUsersTable::getTable()->getByUsername($author); } // e) if (!$user instanceof TBGUser) { $user = TBGSettings::getDefaultUser(); } TBGContext::setUser($user); TBGSettings::forceSettingsReload(); TBGContext::cacheAllPermissions(); $output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n"; if ($date == null) { $date = NOW; } // Create the commit data $commit = new TBGVCSIntegrationCommit(); $commit->setAuthor($user); $commit->setDate($date); $commit->setLog($commit_msg); $commit->setPreviousRevision($old_rev); $commit->setRevision($new_rev); $commit->setProject($project); if ($branch !== null) { $data = 'branch:' . $branch; $commit->setMiscData($data); } $commit->save(); $output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n"; // Iterate over affected issues and update them. foreach ($issues as $issue) { $inst = new TBGVCSIntegrationIssueLink(); $inst->setIssue($issue); $inst->setCommit($commit); $inst->save(); // Process all commit-message transitions for an issue. foreach ($transitions[$issue->getFormattedIssueNo()] as $transition) { if (TBGSettings::get('vcs_workflow_' . $project->getID(), 'vcs_integration') == TBGVCSIntegration::WORKFLOW_ENABLED) { TBGContext::setUser($user); TBGSettings::forceSettingsReload(); TBGContext::cacheAllPermissions(); if ($issue->isWorkflowTransitionsAvailable()) { // Go through the list of possible transitions for an issue. Only // process transitions that are applicable to issue's workflow. foreach ($issue->getAvailableWorkflowTransitions() as $possible_transition) { if (mb_strtolower($possible_transition->getName()) == mb_strtolower($transition[0])) { $output .= '[VCS ' . $project->getKey() . '] Running transition ' . $transition[0] . ' on issue ' . $issue->getFormattedIssueNo() . "\n"; // String representation of parameters. Used for log message. $parameters_string = ""; // Iterate over the list of this transition's parameters, and // set them. foreach ($transition[1] as $parameter => $value) { $parameters_string .= "{$parameter}={$value} "; switch ($parameter) { case 'resolution': if (($resolution = TBGResolution::getResolutionByKeyish($value)) instanceof TBGResolution) { TBGContext::getRequest()->setParameter('resolution_id', $resolution->getID()); } break; case 'status': if (($status = TBGStatus::getStatusByKeyish($value)) instanceof TBGStatus) { TBGContext::getRequest()->setParameter('status_id', $status->getID()); } break; } } // Run the transition. $possible_transition->transitionIssueToOutgoingStepWithoutRequest($issue); // Log an informative message about the transition. $output .= '[VCS ' . $project->getKey() . '] Ran transition ' . $possible_transition->getName() . ' with parameters \'' . $parameters_string . '\' on issue ' . $issue->getFormattedIssueNo() . "\n"; } } } } } $issue->addSystemComment(TBGContext::getI18n()->__('This issue has been updated with the latest changes from the code repository.<source>%commit_msg</source>', array('%commit_msg' => $commit_msg)), $user->getID()); $output .= '[VCS ' . $project->getKey() . '] Updated issue ' . $issue->getFormattedIssueNo() . "\n"; } // Create file links foreach ($files as $afile) { // index 0 is action, index 1 is file $inst = new TBGVCSIntegrationFile(); $inst->setAction($afile[0]); $inst->setFile($afile[1]); $inst->setCommit($commit); $inst->save(); $output .= '[VCS ' . $project->getKey() . '] Added with action ' . $afile[0] . ' file ' . $afile[1] . "\n"; } TBGEvent::createNew('vcs_integration', 'new_commit')->trigger(array('commit' => $commit)); return $output; }