作者:pkdevbox
项目:thebuggeni
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();
}
}
作者:nrense
项目:thebuggeni
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;
}
作者:JonathanR
项目:thebuggeni
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;
}
作者:JonathanR
项目:thebuggeni
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;
}
作者:RTechSof
项目:thebuggeni
<?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>
作者:pkdevbox
项目:thebuggeni
</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>
作者:ellipsoni
项目:thebuggenige_ap
?>
<?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;
?>
作者:shoreless-Limite
项目:thebuggeni
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>
作者:JonathanR
项目:thebuggeni
/**
* 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 {
//.........这里部分代码省略.........
作者:JonathanR
项目:thebuggeni
}
?>
</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>
作者:founderi
项目:thebuggeni
</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
作者:founderi
项目:thebuggeni
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;
}
作者:RTechSof
项目:thebuggeni
public function listen_configurationAuthenticationMethod(framework\Event $event)
{
if (framework\Settings::getAuthenticationBackend() == $this->getName()) {
$event->setReturnValue(framework\Action::AUTHENTICATION_METHOD_CORE);
}
}
作者:JonathanR
项目:thebuggeni
?>
_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>
作者:founderi
项目:thebuggeni
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();
}
作者:AzerothShar
项目:thebuggeni
//.........这里部分代码省略.........
$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;
}
作者:JonathanR
项目:thebuggeni
/**
* 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();
}
}
作者:founderi
项目:thebuggeni
} 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
}
作者:pkdevbox
项目:thebuggeni
/**
* @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);
}
作者:RTechSof
项目:thebuggeni
?>
</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