Пример #1
0
 public function _addNotifications()
 {
     $parser = new TextParser($this->_log);
     $parser->setOption('plain', true);
     $parser->doParse();
     foreach ($parser->getMentions() as $user) {
         if (!$this->getAuthor() || $user->getID() == $this->getAuthor()) {
             continue;
         }
         $notification = new \thebuggenie\core\entities\Notification();
         $notification->setTarget($this);
         $notification->setTriggeredByUser($this->getAuthor());
         $notification->setUser($user);
         $notification->setNotificationType(Vcs_integration::NOTIFICATION_COMMIT_MENTIONED);
         $notification->setModuleName('vcs_integration');
         $notification->save();
     }
 }
Пример #2
0
 protected function _install($scope)
 {
     framework\Context::setPermission('article_management', 0, 'publish', 0, 1, 0, true, $scope);
     framework\Context::setPermission('publish_postonglobalbillboard', 0, 'publish', 0, 1, 0, true, $scope);
     framework\Context::setPermission('publish_postonteambillboard', 0, 'publish', 0, 1, 0, true, $scope);
     framework\Context::setPermission('manage_billboard', 0, 'publish', 0, 1, 0, true, $scope);
     $this->saveSetting('allow_camelcase_links', 1);
     $this->saveSetting('require_change_reason', 1);
     framework\Context::getRouting()->addRoute('publish_article', '/wiki/:article_name', 'publish', 'showArticle');
     TextParser::addRegex('/(?<![\\!|\\"|\\[|\\>|\\/\\:])\\b[A-Z]+[a-z]+[A-Z][A-Za-z]*\\b/', array($this, 'getArticleLinkTag'));
     TextParser::addRegex('/(?<!")\\![A-Z]+[a-z]+[A-Z][A-Za-z]*\\b/', array($this, 'stripExclamationMark'));
 }
Пример #3
0
 public function hasQuickfoundIssues()
 {
     if ($this->_quickfound_issues === null) {
         $this->_quickfound_issues = array();
         if ($this->getSearchterm()) {
             preg_replace_callback(\thebuggenie\core\helpers\TextParser::getIssueRegex(), array('\\thebuggenie\\core\\entities\\SavedSearch', 'extractIssues'), $this->getSearchterm());
         }
     }
     if (!count($this->_quickfound_issues)) {
         $issue = Issue::getIssueFromLink($this->getSearchterm());
         if ($issue instanceof Issue) {
             $this->_quickfound_issues[] = $issue;
         }
     }
     return (bool) count($this->_quickfound_issues);
 }
 protected function _parse_issuelink($matches)
 {
     return \thebuggenie\core\helpers\TextParser::parseIssuelink($matches, true);
 }
Пример #5
0
 /**
  * Runs one or more regular expressions against a supplied text, extracts
  * issue numbers from it, and then obtains corresponding issues. The
  * function will also obtain information about transitions (if this was
  * specified in the text). This data can be used for transitioning the
  * issues through a workflow.
  *
  * Once the function finishes processing, it will return an array of format:
  *
  * array('issues' => tbg_issues, 'transitions' => transitions).
  *
  * tbgissues is an array consisting of \thebuggenie\core\entities\Issue instances.
  *
  * transitions is an array containing transition arrays. The transition
  * arrays are accessed with issue numbers as keys (e.g. 'PREFIX-1',
  * 'PREFIX-5' or '2', '3' etc). Each transition array has the following
  * format:
  *
  * array(0 => command, 1 => parameters)
  *
  * command is a string representing the transision command (for example
  * 'Resolve issue') from the workflow definition. parameters is an array
  * that contains parameters and their values that should be passed to the
  * transition step:
  *
  * array( 'PARAM1' => 'VALUE1', 'PARAM2' => 'VALUE2', ...)
  *
  *
  * @param string $text Text that should be parsed for issue numbers and transitions.
  *
  * @return An array with two elements, one denoting the matched issues, one
  * denoting the transitions for issues. These elements can be accessed using
  * keys 'issues', and 'transitions'. The key 'issues' can be used for
  * accessing an array made-up of \thebuggenie\core\entities\Issue instances. The key 'transitions'
  * can be used for accessing an array containing transition information
  * about each issue. The 'transitions' array uses issue numbers as keys,
  * and contains ordered transition information (see above for detailed
  * description of format).
  */
 public static function getIssuesFromTextByRegex($text)
 {
     $issue_match_regexes = \thebuggenie\core\helpers\TextParser::getIssueRegex();
     $issue_numbers = array();
     // Issue numbers
     $issues = array();
     // Issue objects
     $transitions = array();
     // Transition information
     // Iterate over all regular expressions that should be used for
     // issue/transition matching in commit message.
     foreach ($issue_match_regexes as $issue_match_regex) {
         $matched_issue_data = array();
         // All data from regexp
         // If any match is found using the current regular expression, extract
         // the information.
         if (preg_match_all($issue_match_regex, $text, $matched_issue_data)) {
             // Identified issues are kept inside of named regex group.
             foreach ($matched_issue_data["issues"] as $key => $issue_number) {
                 // Get the matched transitions for the issue.
                 $matched_issue_transitions = $matched_issue_data["transitions"][$key];
                 // Create an empty array to store transitions for an issue. Don't
                 // overwrite it. Use issue number as key for transitions.
                 if (!array_key_exists($issue_number, $transitions)) {
                     $transitions[$issue_number] = array();
                 }
                 // Add the transition information (if any) for an issue.
                 if ($matched_issue_transitions) {
                     // Parse the transition information. Each transition string is in
                     // format:
                     // 'TRANSITION1: PARAM1_1=VALUE1_1 PARAM1_2=VALUE1_2; TRANSITION2: PARAM2_1=VALUE2_1 PARAM2_2=VALUE2_2'
                     foreach (explode("; ", $matched_issue_transitions) as $transition) {
                         // Split command from its parameters.
                         $transition_data = explode(": ", $transition);
                         $transition_command = $transition_data[0];
                         // Set-up array that will contain parameters
                         $transition_parameters = array();
                         // Process parameters if they were present.
                         if (count($transition_data) == 2) {
                             // Split into induvidual parameters.
                             foreach (explode(" ", $transition_data[1]) as $parameter) {
                                 // Only process proper parameters (of format 'PARAM=VALUE')
                                 if (mb_strpos($parameter, '=')) {
                                     list($param_key, $param_value) = explode('=', $parameter);
                                     $transition_parameters[$param_key] = $param_value;
                                 }
                             }
                         }
                         // Append the transition information for the current issue number.
                         $transitions[$issue_number][] = array($transition_command, $transition_parameters);
                     }
                 }
                 // Add the issue number to the list.
                 $issue_numbers[] = $issue_number;
             }
         }
     }
     // Make sure that each issue gets procssed only once for a single commit
     // (avoid duplication of commits).
     $unique_issue_numbers = array_unique($issue_numbers);
     // Fetch all issues affected by the commit.
     foreach ($unique_issue_numbers as $issue_no) {
         $issue = Issue::getIssueFromLink($issue_no);
         if ($issue instanceof \thebuggenie\core\entities\Issue) {
             $issues[] = $issue;
         }
     }
     // Return array consisting out of two arrays - one with \thebuggenie\core\entities\Issue
     // instances, and the second one with transition information for those
     // issues.
     return array("issues" => $issues, "transitions" => $transitions);
 }