예제 #1
0
 /**
  * Returns the object which the notification is for
  *
  * @return TBGIdentifiableScopedClass
  */
 public function getTarget()
 {
     if ($this->_target === null) {
         if ($this->_module_name == 'core') {
             switch ($this->_notification_type) {
                 case self::TYPE_ARTICLE_COMMENTED:
                 case self::TYPE_ARTICLE_MENTIONED:
                 case self::TYPE_ISSUE_COMMENTED:
                 case self::TYPE_ISSUE_MENTIONED:
                 case self::TYPE_COMMENT_MENTIONED:
                     $this->_target = TBGCommentsTable::getTable()->selectById((int) $this->_target_id);
                     break;
                 case self::TYPE_ISSUE_UPDATED:
                 case self::TYPE_ISSUE_CREATED:
                     $this->_target = TBGIssuesTable::getTable()->selectById((int) $this->_target_id);
                     break;
                 case self::TYPE_ARTICLE_UPDATED:
                     $this->_target = TBGArticlesTable::getTable()->selectById((int) $this->_target_id);
                     break;
             }
         } else {
             $event = new TBGEvent('core', 'TBGNotification::getTarget', $this);
             $event->triggerUntilProcessed();
             $this->_target = $event->getReturnValue();
         }
     }
     return $this->_target;
 }
예제 #2
0
 /**
  * @covers TBGEvent::listen
  * @covers TBGEvent::trigger
  * @covers TBGEvent::triggerUntilProcessed
  * @depends testListening
  */
 public function testTriggeringAndProcessing(TBGEvent $event)
 {
     $this->wastriggered = false;
     TBGEvent::clearListeners('modulename', 'identifier');
     TBGEvent::listen('modulename', 'identifier', array($this, 'listenerCallback'));
     $event->trigger();
     $this->assertAttributeEquals(true, 'wastriggered', $this);
     TBGEvent::clearListeners('modulename', 'identifier');
     TBGEvent::listen('modulename', 'identifier', array($this, 'listenerCallbackNonProcessingFirst'));
     TBGEvent::listen('modulename', 'identifier', array($this, 'listenerCallbackNonProcessingSecond'));
     TBGEvent::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);
 }
예제 #3
0
 public function runGetBackdropPartial(TBGRequest $request)
 {
     if (!$request->isAjaxCall()) {
         return $this->return404($this->getI18n()->__('You need to enable javascript for The Bug Genie to work properly'));
     }
     try {
         $template_name = null;
         if ($request->hasParameter('issue_id')) {
             $issue = TBGContext::factory()->TBGIssue($request['issue_id']);
             $options = array('issue' => $issue);
         } else {
             $options = array();
         }
         switch ($request['key']) {
             case 'usercard':
                 $template_name = 'main/usercard';
                 if ($user_id = $request['user_id']) {
                     $user = TBGContext::factory()->TBGUser($user_id);
                     $options['user'] = $user;
                 }
                 break;
             case 'login':
                 $template_name = 'main/loginpopup';
                 $options = $request->getParameters();
                 $options['content'] = $this->getComponentHTML('login', array('section' => $request->getParameter('section', 'login')));
                 $options['mandatory'] = false;
                 break;
             case 'uploader':
                 $template_name = 'main/uploader';
                 $options = $request->getParameters();
                 $options['uploader'] = $request['uploader'] == 'dynamic' ? 'dynamic' : 'standard';
                 break;
             case 'openid':
                 $template_name = 'main/openid';
                 break;
             case 'notifications':
                 $template_name = 'main/notifications';
                 break;
             case 'workflow_transition':
                 $transition = TBGContext::factory()->TBGWorkflowTransition($request['transition_id']);
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 $options['issues'] = array();
                 foreach ($request['issue_ids'] as $issue_id) {
                     $options['issues'][$issue_id] = new TBGIssue($issue_id);
                 }
                 $options['project'] = $this->selected_project;
                 break;
             case 'reportissue':
                 $template_name = 'main/reportissuecontainer';
                 $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
                 $options['selected_project'] = $this->selected_project;
                 $options['selected_issuetype'] = $this->selected_issuetype;
                 if ($request->hasParameter('milestone_id')) {
                     try {
                         $options['selected_milestone'] = TBGContext::factory()->TBGMilestone((int) $request['milestone_id']);
                     } catch (Exception $e) {
                     }
                 }
                 if ($request->hasParameter('parent_issue_id')) {
                     try {
                         $options['parent_issue'] = TBGContext::factory()->TBGIssue((int) $request['parent_issue_id']);
                     } catch (Exception $e) {
                     }
                 }
                 if ($request->hasParameter('build_id')) {
                     try {
                         $options['selected_build'] = TBGContext::factory()->TBGBuild((int) $request['build_id']);
                     } catch (Exception $e) {
                     }
                 }
                 $options['issuetypes'] = $this->issuetypes;
                 $options['errors'] = array();
                 break;
             case 'move_issue':
                 $template_name = 'main/moveissue';
                 $options['multi'] = (bool) $request->getParameter('multi', false);
                 break;
             case 'issue_permissions':
                 $template_name = 'main/issuepermissions';
                 break;
             case 'issue_subscribers':
                 $template_name = 'main/issuesubscribers';
                 break;
             case 'issue_spenttimes':
                 $template_name = 'main/issuespenttimes';
                 $options['initial_view'] = $request->getParameter('initial_view', 'list');
                 break;
             case 'issue_spenttime':
                 $template_name = 'main/issuespenttime';
                 $options['entry_id'] = $request->getParameter('entry_id');
                 break;
             case 'relate_issue':
                 $template_name = 'main/relateissue';
                 break;
             case 'milestone':
                 $template_name = 'project/milestone';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 if ($request->hasParameter('milestone_id')) {
                     $options['milestone'] = TBGContext::factory()->TBGMilestone($request['milestone_id']);
                 }
                 break;
             case 'project_build':
                 $template_name = 'project/build';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 if ($request->hasParameter('build_id')) {
                     $options['build'] = TBGContext::factory()->TBGBuild($request['build_id']);
                 }
                 break;
             case 'project_icons':
                 $template_name = 'project/projecticons';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 break;
             case 'project_workflow':
                 $template_name = 'project/projectworkflow';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 break;
             case 'permissions':
                 $options['key'] = $request['permission_key'];
                 if ($details = TBGContext::getPermissionDetails($options['key'])) {
                     $template_name = 'configuration/permissionspopup';
                     $options['mode'] = $request['mode'];
                     $options['module'] = $request['target_module'];
                     $options['target_id'] = $request['target_id'];
                     $options['item_name'] = $details['description'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'issuefield_permissions':
                 $options['item_key'] = $request['item_key'];
                 if ($details = TBGContext::getPermissionDetails($options['item_key'])) {
                     $template_name = 'configuration/issuefieldpermissions';
                     $options['item_name'] = $details['description'];
                     $options['item_id'] = $request['item_id'];
                     $options['access_level'] = $request['access_level'];
                 } else {
                     die('fu');
                 }
                 break;
             case 'site_icons':
                 $template_name = 'configuration/siteicons';
                 break;
             case 'project_config':
                 $template_name = 'project/projectconfig_container';
                 $project = TBGContext::factory()->TBGProject($request['project_id']);
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = TBGContext::factory()->TBGEdition($request['edition_id']);
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = TBGContext::factory()->TBGIssue($request['issue_id']);
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = TBGContext::factory()->TBGClient($request['client_id']);
                 $template_name = 'main/clientusers';
                 break;
             case 'dashboard_config':
                 $template_name = 'main/dashboardconfig';
                 $options['tid'] = $request['tid'];
                 $options['target_type'] = $request['target_type'];
                 $options['previous_route'] = $request['previous_route'];
                 $options['mandatory'] = true;
                 break;
             case 'archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['mandatory'] = true;
                 break;
             case 'team_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'team';
                 $options['id'] = $request['tid'];
                 $options['mandatory'] = true;
                 break;
             case 'client_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'client';
                 $options['id'] = $request['cid'];
                 $options['mandatory'] = true;
                 break;
             case 'project_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'project';
                 $options['id'] = $request['pid'];
                 $options['mandatory'] = true;
                 break;
             case 'bulk_workflow':
                 $template_name = 'search/bulkworkflow';
                 $options['issue_ids'] = $request['issue_ids'];
                 break;
             case 'confirm_username':
                 $template_name = 'main/confirmusername';
                 $options['username'] = $request['username'];
                 break;
             case 'userscopes':
                 if (!TBGContext::getScope()->isDefault()) {
                     throw new Exception($this->getI18n()->__('This is not allowed outside the default scope'));
                 }
                 $template_name = 'configuration/userscopes';
                 $options['user'] = new TBGUser((int) $request['user_id']);
                 break;
             default:
                 $event = new TBGEvent('core', 'get_backdrop_partial', $request['key']);
                 $event->triggerUntilProcessed();
                 $options = $event->getReturnList();
                 $template_name = $event->getReturnValue();
         }
         if ($template_name !== null) {
             return $this->renderJSON(array('content' => $this->getComponentHTML($template_name, $options)));
         }
     } catch (Exception $e) {
         $this->getResponse()->cleanBuffer();
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => TBGContext::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage()))));
     }
     $this->getResponse()->cleanBuffer();
     $this->getResponse()->setHttpStatus(400);
     $error = TBGContext::isDebugMode() ? TBGContext::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup');
     return $this->renderJSON(array('error' => $error));
 }
예제 #4
0
                    default:
                        echo __("Please triage the reported issue, so the user pain score can be properly calculated");
                        break;
                }
                ?>
						<?php 
            } elseif (TBGCustomDatatype::doesKeyExist($key)) {
                ?>
							<?php 
                echo __('Required field "%field_name" is missing or invalid', array('%field_name' => TBGCustomDatatype::getByKey($key)->getDescription()));
                ?>
						<?php 
            } else {
                $event = new TBGEvent('core', 'reportissue.validationerror', $key);
                $event->setReturnValue($key);
                $event->triggerUntilProcessed();
                echo __('A validation error occured: %error', array('%error' => $event->getReturnValue()));
                ?>
						<?php 
            }
            ?>
					</li>
				<?php 
        } else {
            ?>
					<li><?php 
            echo $error;
            ?>
</li>
				<?php 
        }