Exemple #1
0
 protected function _postSave($is_new)
 {
     if ($is_new) {
         framework\Context::setPermission("canseecomponent", $this->getID(), "core", 0, framework\Context::getUser()->getGroup()->getID(), 0, true);
         \thebuggenie\core\framework\Event::createNew('core', 'Component::createNew', $this)->trigger();
     }
 }
Exemple #2
0
 public function getUnattachedFiles()
 {
     $crit = $this->getCriteria();
     $crit->addSelectionColumn(self::ID, 'id');
     $res = $this->doSelect($crit);
     $file_ids = [];
     if ($res) {
         while ($row = $res->getNextRow()) {
             $file_ids[$row['id']] = $row['id'];
         }
     }
     $file_ids = array_diff($file_ids, IssueFiles::getTable()->getLinkedFileIds($file_ids));
     $event = framework\Event::createNew('core', 'thebuggenie\\core\\entities\\tables\\Files::getUnattachedFiles', $this, ['file_ids' => $file_ids], []);
     $event->trigger();
     if ($event->isProcessed()) {
         foreach ($event->getReturnList() as $linked_file_ids) {
             $file_ids = array_diff($file_ids, $linked_file_ids);
         }
     }
     $system_file_ids = Settings::getTable()->getFileIds();
     $file_ids = array_diff($file_ids, $system_file_ids);
     $project_file_ids = Projects::getTable()->getFileIds();
     $file_ids = array_diff($file_ids, $project_file_ids);
     return $file_ids;
 }
 public function transform($text)
 {
     $this->no_markup = true;
     $this->no_entities = true;
     $text = preg_replace_callback(\thebuggenie\core\helpers\TextParser::getIssueRegex(), array($this, '_parse_issuelink'), $text);
     $text = parent::transform($text);
     $text = preg_replace_callback(\thebuggenie\core\helpers\TextParser::getMentionsRegex(), array($this, '_parse_mention'), $text);
     $text = preg_replace_callback(self::getStrikethroughRegex(), array($this, '_parse_strikethrough'), $text);
     $event = framework\Event::createNew('core', 'thebuggenie\\core\\framework\\helpers\\TextParserMarkdown::transform', $this);
     $event->trigger();
     foreach ($event->getReturnList() as $regex) {
         $text = preg_replace_callback($regex[0], $regex[1], $text);
     }
     return $text;
 }
Exemple #4
0
 public function doSave($options = array(), $reason = null)
 {
     if (tables\Articles::getTable()->doesNameConflictExist($this->_name, $this->_id, framework\Context::getScope()->getID())) {
         if (!array_key_exists('overwrite', $options) || !$options['overwrite']) {
             throw new \Exception(framework\Context::getI18n()->__('Another article with this name already exists'));
         }
     }
     $user_id = framework\Context::getUser() instanceof User ? framework\Context::getUser()->getID() : 0;
     if (!isset($options['revert']) || !$options['revert']) {
         $revision = tables\ArticleHistory::getTable()->addArticleHistory($this->_name, $this->_old_content, $this->_content, $user_id, $reason);
     } else {
         $revision = null;
     }
     tables\ArticleLinks::getTable()->deleteLinksByArticle($this->_name);
     ArticleCategories::getTable()->deleteCategoriesByArticle($this->_name);
     if ($this->getArticleType() == self::TYPE_MANUAL && isset($options['article_prev_name']) && $this->_name != $options['article_prev_name']) {
         $manual_articles = Articles::getTable()->getManualSidebarArticles(framework\Context::getCurrentProject(), $options['article_prev_name']);
         foreach ($manual_articles as $manual_article) {
             $manual_article->setName(str_replace($options['article_prev_name'], $this->_name, $manual_article->getName()));
             $manual_article->doSave();
         }
     }
     $this->save();
     $this->_old_content = $this->_content;
     if (mb_substr($this->getContent(), 0, 10) == "#REDIRECT ") {
         $content = explode("\n", $this->getContent());
         preg_match('/(\\[\\[([^\\]]*?)\\]\\])$/im', mb_substr(array_shift($content), 10), $matches);
         if (count($matches) == 3) {
             return;
         }
     }
     list($links, $categories) = $this->_retrieveLinksAndCategoriesFromContent($options);
     foreach ($links as $link => $occurrences) {
         tables\ArticleLinks::getTable()->addArticleLink($this->_name, $link);
     }
     foreach ($categories as $category => $occurrences) {
         ArticleCategories::getTable()->addArticleCategory($this->_name, $category, $this->isCategory());
     }
     $this->_history = null;
     \thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\modules\\publish\\entities\\Article::doSave', $this, compact('reason', 'revision', 'user_id'))->trigger();
     return true;
 }
                    <?php 
echo image_tag('sidebar_collapse.png', array('class' => 'collapser'));
?>
                    <?php 
echo image_tag('sidebar_expand.png', array('class' => 'expander'));
?>
                </a>
            </div>
            <div class="container_div" style="margin: 0 0 5px 10px;">
                <?php 
include_component('main/myfriends');
?>
            </div>
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'dashboard_left_bottom')->trigger();
?>
        </td>
        <td class="main_area" style="padding-right: 5px; padding-top: 0;">
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'dashboard_main_top')->trigger();
?>
            <?php 
include_component($dashboard->getLayout(), compact('dashboard'));
?>
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'dashboard_main_bottom')->trigger();
?>
        </td>
    </tr>
</table>
</span>
                <div class="hidden url"><?php 
        echo \thebuggenie\core\framework\Context::isProjectContext() ? make_url('project_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey())) : make_url('search');
        ?>
?fs[text][v]=<?php 
        echo $searchterm;
        ?>
&fs[text][o]=<?php 
        echo urlencode('=');
        ?>
</div>
            </li>
        <?php 
    }
    ?>
    <?php 
} else {
    ?>
        <li class="disabled no_issues_found">
            <?php 
    echo __('No issues found matching your query');
    ?>
        </li>
    <?php 
}
?>
    <?php 
\thebuggenie\core\framework\Event::createNew('core', 'quicksearch_dropdown_founditems', $searchterm)->trigger();
?>
</ul>
?>
                <?php 
echo $content;
?>
                <?php 
\thebuggenie\core\framework\Logging::log('done (rendering content)');
?>
            </div>
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'layout.php::footer-begins')->trigger();
?>
            <?php 
require THEBUGGENIE_CORE_PATH . 'templates/footer.inc.php';
?>
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'layout.php::footer-ends')->trigger();
?>
        </div>
        <?php 
require THEBUGGENIE_CORE_PATH . 'templates/backdrops.inc.php';
?>
        <script type="text/javascript">
            var TBG, jQuery;
            require(['domReady', 'thebuggenie/tbg', 'jquery', 'jquery.nanoscroller'], function (domReady, tbgjs, jquery, nanoscroller) {
                domReady(function () {
                    TBG = tbgjs;
                    jQuery = jquery;
                    require(['scriptaculous']);
                    var f_init = function() {TBG.initialize({ basepath: '<?php 
echo $webroot;
?>
    echo make_url('issue_log', array('project_key' => $issue->getProject()->getKey(), 'issue_id' => $issue->getID()));
    ?>
');" value="<?php 
    echo __('Show issue history');
    ?>
">
                                </div>
                            </legend>
                            <div id="viewissue_log_items"></div>
                        </fieldset>
                        <?php 
    \thebuggenie\core\framework\Event::createNew('core', 'viewissue_before_tabs', $issue)->trigger();
    ?>
                        <div id="viewissue_panes">
                            <?php 
    \thebuggenie\core\framework\Event::createNew('core', 'viewissue_after_tabs', $issue)->trigger();
    ?>
                        </div>
                    </div>
                </div>
                <div id="issue_details_container">
                    <div id="issue_details">
                        <div class="collapser_link" onclick="$('issue_details_container').toggleClassName('collapsed');$('issue_main_container').toggleClassName('uncollapsed');">
                            <a href="javascript:void(0);" class="image">
                                <?php 
    echo image_tag('sidebar_collapse.png', array('class' => 'collapser'));
    ?>
                                <?php 
    echo image_tag('sidebar_expand.png', array('class' => 'expander'));
    ?>
                            </a>
Exemple #9
0
 /**
  * Performs an action.
  *
  * @param $action
  * @param string $module Name of the action module
  * @param string $method Name of the action method to run
  *
  * @return bool
  * @throws \Exception
  */
 public static function performAction($action, $module, $method)
 {
     // Set content variable
     $content = null;
     // Set the template to be used when rendering the html (or other) output
     $templateBasePath = self::isInternalModule($module) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
     $templatePath = $templateBasePath . $module . DS . 'templates' . DS;
     $actionClassName = get_class($action);
     $actionToRunName = 'run' . ucfirst($method);
     $preActionToRunName = 'pre' . ucfirst($method);
     // Set up the response object, responsible for controlling any output
     self::getResponse()->setPage(self::getRouting()->getCurrentRouteName());
     self::getResponse()->setTemplate(mb_strtolower($method) . '.' . self::getRequest()->getRequestedFormat() . '.php');
     self::getResponse()->setupResponseContentType(self::getRequest()->getRequestedFormat());
     self::setCurrentProject(null);
     // Run the specified action method set if it exists
     if (method_exists($action, $actionToRunName)) {
         // Turning on output buffering
         ob_start('mb_output_handler');
         ob_implicit_flush(0);
         if (self::getRouting()->isCurrentRouteCSRFenabled()) {
             // If the csrf check fails, don't proceed
             if (!self::checkCSRFtoken()) {
                 return true;
             }
         }
         if (self::$_debug_mode) {
             $time = explode(' ', microtime());
             $pretime = $time[1] + $time[0];
         }
         if ($content === null) {
             Logging::log('Running main pre-execute action');
             // Running any overridden preExecute() method defined for that module
             // or the default empty one provided by \thebuggenie\core\framework\Action
             if ($pre_action_retval = $action->preExecute(self::getRequest(), $method)) {
                 $content = ob_get_clean();
                 Logging::log('preexecute method returned something, skipping further action');
                 if (self::$_debug_mode) {
                     $visited_templatename = "{$actionClassName}::preExecute()";
                 }
             }
         }
         if ($content === null) {
             $action_retval = null;
             if (self::getResponse()->getHttpStatus() == 200) {
                 // Checking for and running action-specific preExecute() function if
                 // it exists
                 if (method_exists($action, $preActionToRunName)) {
                     Logging::log('Running custom pre-execute action');
                     $action->{$preActionToRunName}(self::getRequest(), $method);
                 }
                 // Running main route action
                 Logging::log('Running route action ' . $actionToRunName . '()');
                 if (self::$_debug_mode) {
                     $time = explode(' ', microtime());
                     $action_pretime = $time[1] + $time[0];
                 }
                 $action_retval = $action->{$actionToRunName}(self::getRequest());
                 if (self::$_debug_mode) {
                     $time = explode(' ', microtime());
                     $action_posttime = $time[1] + $time[0];
                     self::visitPartial("{$actionClassName}::{$actionToRunName}()", $action_posttime - $action_pretime);
                 }
             }
             if (self::getResponse()->getHttpStatus() == 200 && $action_retval) {
                 // If the action returns *any* output, we're done, and collect the
                 // output to a variable to be outputted in context later
                 $content = ob_get_clean();
                 Logging::log('...done');
             } elseif (!$action_retval) {
                 // If the action doesn't return any output (which it usually doesn't)
                 // we continue on to rendering the template file for that specific action
                 Logging::log('...done');
                 Logging::log('Displaying template');
                 // Check to see if we have a translated version of the template
                 if ($method == 'notFound' && $module == 'main') {
                     $templateName = $templatePath . self::getResponse()->getTemplate();
                 } elseif (!self::isReadySetup() || ($templateName = self::getI18n()->hasTranslatedTemplate(self::getResponse()->getTemplate())) === false) {
                     // Check to see if any modules provide an alternate template
                     $event = Event::createNew('core', "self::performAction::renderTemplate")->triggerUntilProcessed(array('class' => $actionClassName, 'action' => $actionToRunName));
                     if ($event->isProcessed()) {
                         $templateName = $event->getReturnValue();
                     }
                     // Check to see if the template has been changed, and whether it's in a
                     // different module, specified by "module/templatename"
                     if (mb_strpos(self::getResponse()->getTemplate(), '/')) {
                         $newPath = explode('/', self::getResponse()->getTemplate());
                         $templateName = self::isInternalModule($newPath[0]) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
                         $templateName .= $newPath[0] . DS . 'templates' . DS . $newPath[1] . '.' . self::getRequest()->getRequestedFormat() . '.php';
                     } else {
                         $templateName = $templatePath . self::getResponse()->getTemplate();
                     }
                 }
                 // Check to see if the template exists and throw an exception otherwise
                 if (!isset($templateName) || !file_exists($templateName)) {
                     Logging::log('The template file for the ' . $method . ' action ("' . self::getResponse()->getTemplate() . '") does not exist', 'core', Logging::LEVEL_FATAL);
                     Logging::log('Trying to load file "' . $templateName . '"', 'core', Logging::LEVEL_FATAL);
                     throw new exceptions\TemplateNotFoundException('The template file for the ' . $method . ' action ("' . self::getResponse()->getTemplate() . '") does not exist');
                 }
                 self::loadLibrary('common');
                 // Present template for current action
                 ActionComponent::presentTemplate($templateName, $action->getParameterHolder());
                 $content = ob_get_clean();
                 Logging::log('...completed');
             }
         } elseif (self::$_debug_mode) {
             $time = explode(' ', microtime());
             $posttime = $time[1] + $time[0];
             self::visitPartial($visited_templatename, $posttime - $pretime);
         }
         Logging::log('rendering final content');
         // Set core layout path
         self::getResponse()->setLayoutPath(THEBUGGENIE_CORE_PATH . 'templates');
         // Trigger event for rendering (so layout path can be overwritten)
         \thebuggenie\core\framework\Event::createNew('core', '\\thebuggenie\\core\\framework\\Context::renderBegins')->trigger();
         if (Settings::isMaintenanceModeEnabled() && !mb_strstr(self::getRouting()->getCurrentRouteName(), 'configure')) {
             if (!file_exists(self::getResponse()->getLayoutPath() . DS . 'offline.inc.php')) {
                 throw new exceptions\TemplateNotFoundException('Can not find offline mode template');
             }
             ob_start('mb_output_handler');
             ob_implicit_flush(0);
             ActionComponent::presentTemplate(self::getResponse()->getLayoutPath() . DS . 'offline.inc.php');
             $content = ob_get_clean();
         }
         // Render output in correct order
         self::getResponse()->renderHeaders();
         if (self::getResponse()->getDecoration() == Response::DECORATE_DEFAULT && !self::getRequest()->isAjaxCall()) {
             if (!file_exists(self::getResponse()->getLayoutPath() . DS . 'layout.php')) {
                 throw new exceptions\TemplateNotFoundException('Can not find layout template');
             }
             ob_start('mb_output_handler');
             ob_implicit_flush(0);
             $layoutproperties = self::setupLayoutProperties($content);
             ActionComponent::presentTemplate(self::getResponse()->getLayoutPath() . DS . 'layout.php', $layoutproperties);
             ob_flush();
         } else {
             // Render header template if any, and store the output in a variable
             if (!self::getRequest()->isAjaxCall() && self::getResponse()->doDecorateHeader()) {
                 Logging::log('decorating with header');
                 if (!file_exists(self::getResponse()->getHeaderDecoration())) {
                     throw new exceptions\TemplateNotFoundException('Can not find header decoration: ' . self::getResponse()->getHeaderDecoration());
                 }
                 ActionComponent::presentTemplate(self::getResponse()->getHeaderDecoration());
             }
             echo $content;
             // Trigger event for ending the rendering
             \thebuggenie\core\framework\Event::createNew('core', '\\thebuggenie\\core\\framework\\Context::renderEnds')->trigger();
             Logging::log('...done (rendering content)');
             // Render footer template if any
             if (!self::getRequest()->isAjaxCall() && self::getResponse()->doDecorateFooter()) {
                 Logging::log('decorating with footer');
                 if (!file_exists(self::getResponse()->getFooterDecoration())) {
                     throw new exceptions\TemplateNotFoundException('Can not find footer decoration: ' . self::getResponse()->getFooterDecoration());
                 }
                 ActionComponent::presentTemplate(self::getResponse()->getFooterDecoration());
             }
             Logging::log('...done');
         }
         Logging::log('done (rendering final content)');
         return true;
     } else {
         Logging::log("Cannot find the method {$actionToRunName}() in class {$actionClassName}.", 'core', Logging::LEVEL_FATAL);
         throw new exceptions\ActionNotFoundException("Cannot find the method {$actionToRunName}() in class {$actionClassName}. Make sure the method exists.");
     }
 }
    }
    ?>
            </div>
            <div style="clear: both;">
                <?php 
    if (!$team->isOndemand()) {
        ?>
                    <?php 
        echo link_tag(make_url('team_dashboard', array('team_id' => $team->getID())), __('Show team dashboard'));
        ?>
<br>
                <?php 
    }
    ?>
                <?php 
    \thebuggenie\core\framework\Event::createNew('core', 'teamactions_bottom', $team)->trigger();
    ?>
            </div>
        </div>
        <div style="text-align: right; padding: 3px; font-size: 9px;"><a href="javascript:void(0);" onclick="$('team_<?php 
    echo $team->getID() . "_" . $rnd_no;
    ?>
').toggle();$('team_<?php 
    echo $team->getID() . "_" . $rnd_no;
    ?>
').previous().toggleClassName('button-pressed')"><?php 
    echo __('Close this menu');
    ?>
</a></div>
    </div>
</div>
Exemple #11
0
</span></a>
            <?php 
    }
    ?>
        </div>
    <?php 
}
?>
</div>
<?php 
if (\thebuggenie\core\framework\Settings::isOpenIDavailable()) {
    ?>
    <?php 
    include_component('main/openidbuttons');
}
\thebuggenie\core\framework\Event::createNew('core', 'login_form_pane')->trigger(array_merge(array('selected_tab' => $selected_tab), $options));
if (\thebuggenie\core\framework\Settings::isRegistrationAllowed()) {
    ?>
    <div style="text-align: center;" id="registration-button-container" class="logindiv login_button_container registration_button_container active">
        <fieldset style="border: 0; border-top: 1px dotted rgba(0, 0, 0, 0.3); padding: 5px 100px; width: 100px; margin: 5px auto 0 auto;">
            <legend style="text-align: center; width: 100%; background-color: transparent;"><?php 
    echo __('%login or %signup', array('%login' => '', '%signup' => ''));
    ?>
</legend>
        </fieldset>
        <a href="javascript:void(0);" id="create-account-button" onclick="$('register').addClassName('active');$('registration-button-container').removeClassName('active');$('regular_login_container').removeClassName('active');$('openid_container').removeClassName('active');"><?php 
    echo __('Create an account');
    ?>
</a>
    </div>
    <?php 
Exemple #12
0
 public static function getTypes()
 {
     $types = array();
     $types[self::STATUS] = '\\thebuggenie\\core\\entities\\Status';
     $types[self::PRIORITY] = '\\thebuggenie\\core\\entities\\Priority';
     $types[self::CATEGORY] = '\\thebuggenie\\core\\entities\\Category';
     $types[self::SEVERITY] = '\\thebuggenie\\core\\entities\\Severity';
     $types[self::REPRODUCABILITY] = '\\thebuggenie\\core\\entities\\Reproducability';
     $types[self::RESOLUTION] = '\\thebuggenie\\core\\entities\\Resolution';
     $types[self::ACTIVITYTYPE] = '\\thebuggenie\\core\\entities\\ActivityType';
     $types = \thebuggenie\core\framework\Event::createNew('core', 'Datatype::getTypes', null, array(), $types)->trigger()->getReturnList();
     return $types;
 }
Exemple #13
0
 public function listen_configurationAuthenticationMethod(framework\Event $event)
 {
     if (framework\Settings::getAuthenticationBackend() == $this->getName()) {
         $event->setReturnValue(framework\Action::AUTHENTICATION_METHOD_CORE);
     }
 }
            ?>
_link').show();$('<?php 
            echo $customdatatype->getKey();
            ?>
_additional_div').hide();$('<?php 
            echo $customdatatype->getKey();
            ?>
_id_additional').setValue(0);"><?php 
            echo image_tag('undo.png', array('style' => 'float: none; margin-left: 5px;'));
            ?>
</a>
                                        <?php 
        }
        ?>
                            </div>
                        </li>
                    <?php 
    }
    ?>
                    <?php 
    \thebuggenie\core\framework\Event::createNew('core', 'reportissue.listfields')->trigger();
    ?>
                </ul>
                <div style="clear: both;"> </div>
            </div>
        </div>
    <?php 
}
?>
</form>
Exemple #15
0
 public function componentDashboardViewUserProjects()
 {
     $routing = $this->getRouting();
     $i18n = $this->getI18n();
     $links = array(array('url' => $routing->generate('project_open_issues', array('project_key' => '%project_key%')), 'text' => $i18n->__('Issues')), array('url' => $routing->generate('project_roadmap', array('project_key' => '%project_key%')), 'text' => $i18n->__('Roadmap')));
     $event = \thebuggenie\core\framework\Event::createNew('core', 'main\\Components::DashboardViewUserProjects::links', null, array(), $links);
     $event->trigger();
     $this->links = $event->getReturnList();
 }
 public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null)
 {
     $output = '';
     framework\Context::setCurrentProject($project);
     if ($project->isArchived()) {
         return;
     }
     if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) {
         return;
     }
     try {
         framework\Context::getI18n();
     } catch (\Exception $e) {
         framework\Context::reinitializeI18n(null);
     }
     // Is VCS Integration enabled?
     if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::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 = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg);
     $issues = $parsed_commit["issues"];
     $transitions = $parsed_commit["transitions"];
     // 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
      */
     // a)
     $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author);
     if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
         $email = $matches[0];
         // a2)
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email);
         if (!$user instanceof \thebuggenie\core\entities\User) {
             // Not found by email
             preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
             $author = $matches[0];
         }
     }
     // b)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author);
     }
     // c)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author);
     }
     // d)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author);
     }
     // e)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = framework\Settings::getDefaultUser();
     }
     framework\Context::setUser($user);
     framework\Settings::forceSettingsReload();
     framework\Context::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 Commit();
     $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);
     }
     if ($callback !== null) {
         $commit = $callback($commit);
     }
     $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 IssueLink();
         $inst->setIssue($issue);
         $inst->setCommit($commit);
         $inst->save();
         // Process all commit-message transitions for an issue.
         foreach ($transitions[$issue->getFormattedIssueNo()] as $transition) {
             if (framework\Settings::get('vcs_workflow_' . $project->getID(), 'vcs_integration') == self::WORKFLOW_ENABLED) {
                 framework\Context::setUser($user);
                 framework\Settings::forceSettingsReload();
                 framework\Context::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 = \thebuggenie\core\entities\Resolution::getByKeyish($value)) instanceof \thebuggenie\core\entities\Resolution) {
                                             framework\Context::getRequest()->setParameter('resolution_id', $resolution->getID());
                                         }
                                         break;
                                     case 'status':
                                         if (($status = \thebuggenie\core\entities\Status::getByKeyish($value)) instanceof \thebuggenie\core\entities\Status) {
                                             framework\Context::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(framework\Context::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 File();
         $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";
     }
     framework\Event::createNew('vcs_integration', 'new_commit')->trigger(array('commit' => $commit));
     return $output;
 }
Exemple #17
0
 /**
  * File access listener
  *
  * @param \thebuggenie\core\framework\Event $event
  */
 public static function listen_thebuggenie_core_entities_File_hasAccess(Event $event)
 {
     $file = $event->getSubject();
     if ($file->getID() == self::getHeaderIconID() || $file->getID() == self::getFaviconID()) {
         $event->setReturnValue(true);
         $event->setProcessed();
     }
 }
        } else {
            ?>
                <li><?php 
            echo link_tag(make_url('switch_back_user'), __('Switch back to original user'));
            ?>
</li>
            <?php 
        }
        ?>
        <?php 
    }
    ?>
        <li>
            <a href="javascript:void(0);" onclick="TBG.Main.Helpers.Backdrop.show('<?php 
    echo make_url('get_partial_for_backdrop', array('key' => 'usercard', 'user_id' => $user->getID()));
    ?>
');$('bud_<?php 
    echo $user->getUsername() . "_" . $rnd_no;
    ?>
').hide();"><?php 
    echo __('Show user details');
    ?>
</a>
        </li>
        <?php 
    \thebuggenie\core\framework\Event::createNew('core', 'useractions_bottom', $user)->trigger();
    ?>
    </ul>
</div>
<?php 
}
Exemple #19
0
 /**
  * @covers \thebuggenie\core\framework\Event::listen
  * @covers \thebuggenie\core\framework\Event::trigger
  * @covers \thebuggenie\core\framework\Event::triggerUntilProcessed
  * @depends testListening
  */
 public function testTriggeringAndProcessing(\thebuggenie\core\framework\Event $event)
 {
     $this->wastriggered = false;
     \thebuggenie\core\framework\Event::clearListeners('modulename', 'identifier');
     \thebuggenie\core\framework\Event::listen('modulename', 'identifier', array($this, 'listenerCallback'));
     $event->trigger();
     $this->assertAttributeEquals(true, 'wastriggered', $this);
     \thebuggenie\core\framework\Event::clearListeners('modulename', 'identifier');
     \thebuggenie\core\framework\Event::listen('modulename', 'identifier', array($this, 'listenerCallbackNonProcessingFirst'));
     \thebuggenie\core\framework\Event::listen('modulename', 'identifier', array($this, 'listenerCallbackNonProcessingSecond'));
     \thebuggenie\core\framework\Event::listen('modulename', 'identifier', array($this, 'listenerCallbackProcessing'));
     $this->wasprocessed = array();
     $event->triggerUntilProcessed();
     $this->assertAttributeNotEmpty('wasprocessed', $this);
     $this->assertAttributeContains(1, 'wasprocessed', $this);
     $this->assertAttributeContains(2, 'wasprocessed', $this);
     $this->assertAttributeNotContains(3, 'wasprocessed', $this);
 }
            ?>
                                </span>
                            </li>
                        <?php 
        }
        ?>
                        </ul>
                    <?php 
    }
    ?>
                <?php 
}
?>
            </div>
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'account_tab_panes')->trigger();
?>
            <?php 
foreach (\thebuggenie\core\framework\Context::getModules() as $module_name => $module) {
    ?>
                <?php 
    if ($module->hasAccountSettings()) {
        ?>
                    <div id="tab_settings_<?php 
        echo $module_name;
        ?>
_pane" style="display: none;">
                        <form accept-charset="<?php 
        echo \thebuggenie\core\framework\Context::getI18n()->getCharset();
        ?>
" action="<?php 
 protected function _parse_line($line, $options = array())
 {
     $line_regexes = array();
     $line_regexes['preformat'] = '^\\s{1}(.*?)$';
     $line_regexes['quote'] = '^(\\&gt\\;)(.*?)$';
     $line_regexes['definitionlist'] = '^([\\;\\:])(?!\\-?[\\(\\)\\D\\/P])\\s*(.*?)$';
     $line_regexes['newline'] = '^$';
     $line_regexes['list'] = '^([\\*\\#]+)(.*?)$';
     $line_regexes['tableopener'] = '^\\{\\|(.*?)$';
     $line_regexes['tablecloser'] = '^\\|\\}$';
     $line_regexes['tablerow'] = '^\\|-(.*?)$';
     $line_regexes['tableheader'] = '^\\!(.*?)$';
     $line_regexes['tablerowcontent'] = '^\\|{1,2}\\s?(.*?)$';
     $line_regexes['headers'] = '^(={1,6})(.*?)(={1,6})$';
     $line_regexes['horizontalrule'] = '^----$';
     $char_regexes = array();
     $char_regexes[] = array('/(\'{2,5})/i', array($this, '_parse_emphasize'));
     $char_regexes[] = array('/(__NOTOC__|__NOEDITSECTION__)/i', array($this, '_parse_eliminate'));
     $char_regexes[] = array('/(\\[\\[(\\:?([^\\]]*?)\\:)?([^\\]]*?)(\\|([^\\]]*?))?\\]\\]([a-z]+)?)/i', array($this, "_parse_save_ilink"));
     $char_regexes[] = array('/(^|[ \\t\\r\\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;\\[\\]\\/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9\\[\\]$_.+!*(),;\\/?:@&~=-]*))?([A-Za-z0-9\\[\\]$_+!*();\\/?:~-]))/', array($this, '_parse_autosensedlink'));
     $char_regexes[] = array('/(\\[([^\\]]*?)(?:\\s+([^\\]]*?))?\\])/i', array($this, "_parse_save_elink"));
     $char_regexes[] = array(self::getIssueRegex(), array($this, '_parse_issuelink'));
     $char_regexes[] = array('/\\B\\@([\\w\\-.]+)/i', array($this, '_parse_mention'));
     $char_regexes[] = array('/(?<=\\s|^)(\\:\\(|\\:-\\(|\\:\\)|\\:-\\)|8\\)|8-\\)|B\\)|B-\\)|\\:-\\/|\\:-D|\\:-P|\\(\\!\\)|\\(\\?\\))(?=\\s|$)/', array($this, '_getsmiley'));
     $char_regexes[] = array('/&amp;([A-Za-z0-9]+|\\#[0-9]+|\\#[xX][0-9A-Fa-f]+);/', array($this, '_parse_specialchar'));
     $event = framework\Event::createNew('core', 'thebuggenie\\core\\framework\\helpers\\TextParser::_parse_line::char_regexes', $this, array(), $char_regexes);
     $event->trigger();
     $char_regexes = $event->getReturnList();
     $this->stop = false;
     $this->stop_all = false;
     $called = array();
     foreach ($line_regexes as $func => $regex) {
         if (preg_match("/{$regex}/i", $line, $matches)) {
             $called[$func] = true;
             $func = "_parse_" . $func;
             $line = $this->{$func}($matches);
             if ($this->stop || $this->stop_all) {
                 break;
             }
         }
     }
     if (!$this->stop_all) {
         $this->stop = false;
         foreach ($char_regexes as $regex) {
             $line = preg_replace_callback($regex[0], $regex[1], $line);
             if ($this->stop) {
                 break;
             }
         }
         foreach (self::getRegexes() as $regex) {
             $parser = $this;
             $line = preg_replace_callback($regex[0], function ($matches) use($regex, $parser) {
                 return call_user_func($regex[1], $matches, $parser);
             }, $line);
             if ($this->stop) {
                 break;
             }
         }
     }
     $isline = (bool) (mb_strlen(trim($line)) > 0);
     // if this wasn't a list item, and we are in a list, close the list tag(s)
     if ($this->list_level > 0 && !array_key_exists('list', $called)) {
         $line = $this->_parse_list(false, true) . $line;
     }
     if ($this->deflist && !array_key_exists('definitionlist', $called)) {
         $line = $this->_parse_definitionlist(false, true) . $line;
     }
     if ($this->preformat && !array_key_exists('preformat', $called)) {
         $line = $this->_parse_preformat(false, true) . $line;
     }
     if ($this->quote && !array_key_exists('quote', $called)) {
         $line = $this->_parse_quote(false, true) . $line;
     }
     // suppress linebreaks for the next line if we just displayed one; otherwise re-enable them
     if ($isline) {
         $this->ignore_newline = array_key_exists('newline', $called) || array_key_exists('headers', $called);
     }
     if (mb_substr($line, -1) != "\n") {
         $line .= isset($this->options['included']) ? "\n" : " \n";
     }
     return $line;
 }
 /**
  * Toggle favourite article (starring)
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runToggleFavouriteArticle(framework\Request $request)
 {
     if ($article_id = $request['article_id']) {
         try {
             $article = Articles::getTable()->selectById($article_id);
             $user = \thebuggenie\core\entities\User::getB2DBTable()->selectById($request['user_id']);
         } catch (\Exception $e) {
             return $this->renderText('fail');
         }
     } else {
         return $this->renderText('no article');
     }
     if ($user->isArticleStarred($article_id)) {
         $retval = !$user->removeStarredArticle($article_id);
     } else {
         $retval = $user->addStarredArticle($article_id);
         if ($user->getID() != $this->getUser()->getID()) {
             framework\Event::createNew('core', 'article_subscribe_user', $article, compact('user'))->trigger();
         }
     }
     return $this->renderText(json_encode(array('starred' => $retval, 'subscriber' => $this->getComponentHTML('publish/articlesubscriber', array('user' => $user, 'article' => $article)))));
 }
Exemple #23
0
 /**
  * @Listener(module='core', identifier='get_backdrop_partial')
  * @param \thebuggenie\core\framework\Event $event
  */
 public function listen_get_backdrop_partial(framework\Event $event)
 {
     if ($event->getSubject() == 'mailing_editincomingemailaccount') {
         $account = new IncomingEmailAccount(framework\Context::getRequest()->getParameter('account_id'));
         $event->addToReturnList($account, 'account');
         $event->setReturnValue('mailing/editincomingemailaccount');
         $event->setProcessed();
     }
 }
</a></li>
                <li id="statistics_per_resolution_selector"><a href="javascript:void(0);" onclick="TBG.Project.Statistics.get('<?php 
echo make_url('project_statistics_imagesets', array('project_key' => $selected_project->getKey(), 'set' => 'issues_per_resolution'));
?>
', 'resolution');"><?php 
echo __('%number_of_issues_per Resolution', array('%number_of_issues_per' => ''));
?>
</a></li>
                <li id="statistics_per_reproducability_selector"><a href="javascript:void(0);" onclick="TBG.Project.Statistics.get('<?php 
echo make_url('project_statistics_imagesets', array('project_key' => $selected_project->getKey(), 'set' => 'issues_per_reproducability'));
?>
', 'reproducability');"><?php 
echo __('%number_of_issues_per Reproducability', array('%number_of_issues_per' => ''));
?>
</a></li>
                <li id="statistics_per_status_selector"><a href="javascript:void(0);" onclick="TBG.Project.Statistics.get('<?php 
echo make_url('project_statistics_imagesets', array('project_key' => $selected_project->getKey(), 'set' => 'issues_per_status'));
?>
', 'status');"><?php 
echo __('%number_of_issues_per Status type', array('%number_of_issues_per' => ''));
?>
</a></li>
            </ul>
            <?php 
\thebuggenie\core\framework\Event::createNew('core', 'projectstatistics_links', $selected_project)->trigger();
?>
        </div>
    </div>
    <br style="clear: both;">
</div>
><?php 
echo javascript_link_tag(__('Team'), array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_developers', 'project_config_menu');"));
?>
</li>
                <li id="tab_permissions"<?php 
if ($selected_tab == 'permissions') {
    ?>
 class="selected"<?php 
}
?>
><?php 
echo javascript_link_tag(__('Roles and permissions'), array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_permissions', 'project_config_menu');"));
?>
</li>
                <?php 
\thebuggenie\core\framework\Event::createNew('core', 'config_project_tabs_other')->trigger(array('selected_tab' => $selected_tab));
?>
            </ul>
            <?php 
if ($settings_saved) {
    ?>
                <script type="text/javascript">
                    require(['domReady', 'thebuggenie/tbg'], function (domReady, TBG) {
                        domReady(function () {
                            TBG.Main.Helpers.Message.success('<?php 
    echo __('Settings saved');
    ?>
', '<?php 
    echo __('Project settings have been saved successfully');
    ?>
');
Exemple #26
0
 public static function listen_thebuggenie_core_entities_File_hasAccess(framework\Event $event)
 {
     $file = $event->getSubject();
     $projects = self::getB2DBTable()->getByFileID($file->getID());
     foreach ($projects as $project) {
         if ($project->hasAccess()) {
             $event->setReturnValue(true);
             $event->setProcessed();
             break;
         }
     }
 }
        }
        ?>
                        <?php 
        echo link_tag(make_url('client_dashboard', array('client_id' => $client->getID())), image_tag('tab_clients.png') . $client->getName());
        ?>
                    <?php 
    }
    ?>
                </div>
            </li>
        <?php 
}
?>
        <?php 
framework\Event::createNew('core', 'templates/headermainmenu::projectmenulinks', framework\Context::getCurrentProject())->trigger();
?>
    </ul>
    <?php 
if (framework\Context::isProjectContext() && !framework\Context::getCurrentProject()->isArchived() && !framework\Context::getCurrentProject()->isLocked() && ($tbg_user->canReportIssues() || $tbg_user->canReportIssues(framework\Context::getCurrentProject()->getID()))) {
    ?>
        <div class="reportissue_button_container">
        <?php 
    echo javascript_link_tag(image_tag('icon-mono-add.png') . __('Report an issue'), array('onclick' => "TBG.Issues.Add('" . make_url('get_partial_for_backdrop', array('key' => 'reportissue', 'project_id' => framework\Context::getCurrentProject()->getId())) . "');", 'class' => 'button button-lightblue', 'id' => 'reportissue_button'));
    ?>
        </div>
    <?php 
}
framework\Event::createNew('core', 'before_header_userinfo')->trigger();
?>
</nav>
Exemple #28
0
    echo $project->getID();
    ?>
_input" value="" placeholder="<?php 
    echo __('Enter an issue number to jump to an issue');
    ?>
">&nbsp;<input type="submit" value="<?php 
    echo __('Go to');
    ?>
">
                </form>
            </li>
        </ul>
    </li>
<?php 
}
\thebuggenie\core\framework\Event::createNew('core', 'project_overview_item_links', $project)->trigger();
if (!$project->isLocked() && $tbg_user->canReportIssues($project)) {
    ?>
    <?php 
    echo javascript_link_tag(__('Report an issue'), array('onclick' => "TBG.Issues.Add('" . make_url('get_partial_for_backdrop', array('key' => 'reportissue', 'project_id' => $project->getId())) . "', this);", 'class' => 'button button-green button-report-issue righthugging'));
    ?>
    <a class="dropper button button-green last lefthugging reportissue_dropdown_button" style="font-size: 0.9em; position: relative;" href="javascript:void(0);">&#x25BC;</a>
    <ul id="create_issue_<?php 
    echo $project->getID();
    ?>
" class="more_actions_dropdown popup_box" style="position: absolute; right: 0; margin-top: 25px; display: none;">
        <?php 
    foreach ($project->getIssuetypeScheme()->getReportableIssuetypes() as $issuetype) {
        ?>
            <li><?php 
        echo javascript_link_tag(image_tag($issuetype->getIcon() . '_tiny.png') . __($issuetype->getName()), array('onclick' => "TBG.Issues.Add('" . make_url('get_partial_for_backdrop', array('key' => 'reportissue', 'project_id' => $project->getId(), 'issuetype' => $issuetype->getKey())) . "', this);"));
 public static function getTemplates()
 {
     $templates = array('' => 'No template used - transition happens instantly', 'main/updateissueproperties' => 'Set issue properties or add comment');
     $event = \thebuggenie\core\framework\Event::createNew('core', 'workflow_templates', null, array(), $templates)->trigger();
     return $event->getReturnList();
 }
Exemple #30
0
 public function addScope(Scope $scope, $notify = true)
 {
     if (!$this->isMemberOfScope($scope)) {
         tables\UserScopes::getTable()->addUserToScope($this->getID(), $scope->getID());
         if ($notify) {
             \thebuggenie\core\framework\Event::createNew('core', 'self::addScope', $this, array('scope' => $scope))->trigger();
         }
         $this->_scopes = null;
         $this->_unconfirmed_scopes = null;
         $this->_confirmed_scopes = null;
     }
 }