public function perform(\thebuggenie\core\entities\Issue $issue, $request = null)
 {
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE_SELF:
             $issue->setAssignee(framework\Context::getUser());
             break;
         case self::ACTION_SET_STATUS:
             if ($this->getTargetValue()) {
                 $issue->setStatus(Status::getB2DBTable()->selectById((int) $this->getTargetValue()));
             } else {
                 $issue->setStatus($request['status_id']);
             }
             break;
         case self::ACTION_CLEAR_MILESTONE:
             $issue->setMilestone(null);
             break;
         case self::ACTION_SET_MILESTONE:
             if ($this->getTargetValue()) {
                 $issue->setMilestone(Milestone::getB2DBTable()->selectById((int) $this->getTargetValue()));
             } else {
                 $issue->setMilestone($request['milestone_id']);
             }
             break;
         case self::ACTION_CLEAR_PRIORITY:
             $issue->setPriority(null);
             break;
         case self::ACTION_SET_PRIORITY:
             if ($this->getTargetValue()) {
                 $issue->setPriority(Priority::getB2DBTable()->selectById((int) $this->getTargetValue()));
             } else {
                 $issue->setPriority($request['priority_id']);
             }
             break;
         case self::ACTION_CLEAR_PERCENT:
             $issue->setPercentCompleted(0);
             break;
         case self::ACTION_SET_PERCENT:
             if ($this->getTargetValue()) {
                 $issue->setPercentCompleted((int) $this->getTargetValue());
             } else {
                 $issue->setPercentCompleted((int) $request['percent_complete_id']);
             }
             break;
         case self::ACTION_CLEAR_DUPLICATE:
             $issue->setDuplicateOf(null);
             break;
         case self::ACTION_SET_DUPLICATE:
             $issue->setDuplicateOf($request['duplicate_issue_id']);
             break;
         case self::ACTION_CLEAR_RESOLUTION:
             $issue->setResolution(null);
             break;
         case self::ACTION_SET_RESOLUTION:
             if ($this->getTargetValue()) {
                 $issue->setResolution(Resolution::getB2DBTable()->selectById((int) $this->getTargetValue()));
             } else {
                 $issue->setResolution($request['resolution_id']);
             }
             break;
         case self::ACTION_CLEAR_REPRODUCABILITY:
             $issue->setReproducability(null);
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             if ($this->getTargetValue()) {
                 $issue->setReproducability(Reproducability::getB2DBTable()->selectById((int) $this->getTargetValue()));
             } else {
                 $issue->setReproducability($request['reproducability_id']);
             }
             break;
         case self::ACTION_CLEAR_ASSIGNEE:
             $issue->clearAssignee();
             break;
         case self::ACTION_ASSIGN_ISSUE:
             if ($this->getTargetValue()) {
                 $target_details = explode('_', $this->_target_value);
                 if ($target_details[0] == 'user') {
                     $assignee = \thebuggenie\core\entities\User::getB2DBTable()->selectById((int) $target_details[1]);
                 } else {
                     $assignee = Team::getB2DBTable()->selectById((int) $target_details[1]);
                 }
                 $issue->setAssignee($assignee);
             } else {
                 $assignee = null;
                 switch ($request['assignee_type']) {
                     case 'user':
                         $assignee = \thebuggenie\core\entities\User::getB2DBTable()->selectById((int) $request['assignee_id']);
                         break;
                     case 'team':
                         $assignee = Team::getB2DBTable()->selectById((int) $request['assignee_id']);
                         break;
                 }
                 if ((bool) $request->getParameter('assignee_teamup', false) && $assignee instanceof \thebuggenie\core\entities\User && $assignee->getID() != framework\Context::getUser()->getID()) {
                     $team = new \thebuggenie\core\entities\Team();
                     $team->setName($assignee->getBuddyname() . ' & ' . framework\Context::getUser()->getBuddyname());
                     $team->setOndemand(true);
                     $team->save();
                     $team->addMember($assignee);
                     $team->addMember(framework\Context::getUser());
                     $assignee = $team;
                 }
                 $issue->setAssignee($assignee);
             }
             break;
         case self::ACTION_USER_START_WORKING:
             $issue->clearUserWorkingOnIssue();
             if ($issue->getAssignee() instanceof \thebuggenie\core\entities\Team && $issue->getAssignee()->isOndemand()) {
                 $members = $issue->getAssignee()->getMembers();
                 $issue->startWorkingOnIssue(array_shift($members));
             } elseif ($issue->getAssignee() instanceof \thebuggenie\core\entities\User) {
                 $issue->startWorkingOnIssue($issue->getAssignee());
             }
             break;
         case self::ACTION_USER_STOP_WORKING:
             if ($request->getParameter('did', 'nothing') == 'nothing') {
                 $issue->clearUserWorkingOnIssue();
             } elseif ($request->getParameter('did', 'nothing') == 'this') {
                 $times = array();
                 if ($request['timespent_manual']) {
                     $times = Issue::convertFancyStringToTime($request['timespent_manual']);
                 } elseif ($request['timespent_specified_type']) {
                     $times = array('points' => 0, 'hours' => 0, 'days' => 0, 'weeks' => 0, 'months' => 0);
                     $times[$request['timespent_specified_type']] = $request['timespent_specified_value'];
                 }
                 if (array_sum($times) > 0) {
                     $times['hours'] *= 100;
                     $spenttime = new \thebuggenie\core\entities\IssueSpentTime();
                     $spenttime->setIssue($issue);
                     $spenttime->setUser(framework\Context::getUser());
                     $spenttime->setSpentPoints($times['points']);
                     $spenttime->setSpentHours($times['hours']);
                     $spenttime->setSpentDays($times['days']);
                     $spenttime->setSpentWeeks($times['weeks']);
                     $spenttime->setSpentMonths($times['months']);
                     $spenttime->setActivityType($request['timespent_activitytype']);
                     $spenttime->setComment($request['timespent_comment']);
                     $spenttime->save();
                 }
                 $issue->clearUserWorkingOnIssue();
             } else {
                 $issue->stopWorkingOnIssue();
             }
             break;
         default:
             if (strpos($this->_action_type, self::CUSTOMFIELD_CLEAR_PREFIX) === 0) {
                 $customkey = substr($this->_action_type, strlen(self::CUSTOMFIELD_CLEAR_PREFIX));
                 $issue->setCustomField($customkey, null);
             } elseif (strpos($this->_action_type, self::CUSTOMFIELD_SET_PREFIX) === 0) {
                 $customkey = substr($this->_action_type, strlen(self::CUSTOMFIELD_SET_PREFIX));
                 if ($this->getTargetValue()) {
                     $issue->setCustomField($customkey, $this->getTargetValue());
                 } else {
                     $issue->setCustomField($customkey, $request[$customkey . '_id']);
                 }
             } else {
                 $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionAction::perform', $issue, array('request' => $request));
                 $event->triggerUntilProcessed();
             }
     }
 }
Exemplo n.º 2
0
 /**
  * Returns the object which the notification is for
  *
  * @return \thebuggenie\core\entities\common\IdentifiableScoped
  */
 public function getTarget()
 {
     if ($this->_target === null) {
         if ($this->_module_name == 'core') {
             switch ($this->_notification_type) {
                 case self::TYPE_ARTICLE_COMMENTED:
                 case self::TYPE_ISSUE_COMMENTED:
                 case self::TYPE_COMMENT_MENTIONED:
                     $this->_target = tables\Comments::getTable()->selectById((int) $this->_target_id);
                     break;
                 case self::TYPE_ISSUE_UPDATED:
                 case self::TYPE_ISSUE_CREATED:
                 case self::TYPE_ISSUE_MENTIONED:
                     $this->_target = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $this->_target_id);
                     break;
                 case self::TYPE_ARTICLE_CREATED:
                 case self::TYPE_ARTICLE_UPDATED:
                 case self::TYPE_ARTICLE_MENTIONED:
                     $this->_target = Articles::getTable()->selectById((int) $this->_target_id);
                     break;
             }
         } else {
             $event = new \thebuggenie\core\framework\Event('core', 'thebuggenie\\core\\entities\\Notification::getTarget', $this);
             $event->triggerUntilProcessed();
             $this->_target = $event->getReturnValue();
         }
     }
     return $this->_target;
 }
 public function isValid($input)
 {
     switch ($this->_name) {
         case self::RULE_MAX_ASSIGNED_ISSUES:
             $num_issues = (int) $this->getRuleValue();
             return $num_issues ? (bool) (count(framework\Context::getUser()->getUserAssignedIssues()) < $num_issues) : true;
             break;
         case self::RULE_TEAM_MEMBERSHIP_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $teams = \thebuggenie\core\entities\Team::getAll();
             if ($this->isPost()) {
                 if ($input instanceof \thebuggenie\core\entities\Issue) {
                     $assignee = $input->getAssignee();
                 }
             }
             if (!isset($assignee)) {
                 $assignee = framework\Context::getUser();
             }
             if ($assignee instanceof \thebuggenie\core\entities\User) {
                 if (count($valid_items) == 1 && reset($valid_items) == '') {
                     return true;
                 }
                 foreach ($valid_items as $team_id) {
                     if ($assignee->isMemberOfTeam($teams[$team_id])) {
                         return true;
                     }
                 }
             } elseif ($assignee instanceof \thebuggenie\core\entities\Team) {
                 foreach ($valid_items as $team_id) {
                     if ($assignee->getID() == $team_id) {
                         return true;
                     }
                 }
             }
             return false;
         case self::RULE_ISSUE_IN_MILESTONE_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             if ($input instanceof \thebuggenie\core\entities\Issue) {
                 $issue = $input;
             } else {
                 if ($input->hasParameter('issue_id')) {
                     $issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectByID((int) $input->getParameter('issue_id'));
                 }
             }
             if (isset($issue) && $issue instanceof \thebuggenie\core\entities\Issue) {
                 if (!$issue->getMilestone() instanceof \thebuggenie\core\entities\Milestone) {
                     return false;
                 }
                 if (count($valid_items) == 1 && reset($valid_items) == '') {
                     return true;
                 }
                 return in_array($issue->getMilestone()->getID(), $valid_items);
             }
             return false;
         case self::RULE_STATUS_VALID:
         case self::RULE_PRIORITY_VALID:
         case self::RULE_RESOLUTION_VALID:
         case self::RULE_REPRODUCABILITY_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $valid = false;
             if ($this->_name == self::RULE_STATUS_VALID) {
                 $fieldname = 'Status';
                 $fieldname_small = 'status';
             } elseif ($this->_name == self::RULE_RESOLUTION_VALID) {
                 $fieldname = 'Resolution';
                 $fieldname_small = 'resolution';
             } elseif ($this->_name == self::RULE_REPRODUCABILITY_VALID) {
                 $fieldname = 'Reproducability';
                 $fieldname_small = 'reproducability';
             } elseif ($this->_name == self::RULE_PRIORITY_VALID) {
                 $fieldname = 'Priority';
                 $fieldname_small = 'priority';
             } else {
                 throw new framework\exceptions\ConfigurationException(framework\Context::getI18n()->__('Invalid workflow validation rule: %rule_name', array('%rule_name' => $this->_name)));
             }
             if (!$this->getRuleValue()) {
                 if ($input instanceof \thebuggenie\core\entities\Issue) {
                     $getter = "get{$fieldname}";
                     if (is_object($input->{$getter}())) {
                         $valid = true;
                     }
                 } elseif ($input instanceof framework\Request) {
                     if ($input->getParameter("{$fieldname_small}_id") && Status::has($input->getParameter("{$fieldname_small}_id"))) {
                         $valid = true;
                     }
                 }
             } else {
                 foreach ($valid_items as $item) {
                     if ($input instanceof \thebuggenie\core\entities\Issue) {
                         $type = "\\thebuggenie\\core\\entities\\{$fieldname}";
                         $getter = "get{$fieldname}";
                         if (is_object($input->{$getter}()) && $type::getB2DBTable()->selectByID((int) $item)->getID() == $input->{$getter}()->getID()) {
                             $valid = true;
                             break;
                         }
                     } elseif ($input instanceof framework\Request) {
                         if ($input->getParameter("{$fieldname_small}_id") == $item) {
                             $valid = true;
                             break;
                         }
                     }
                 }
             }
             return $valid;
             break;
         default:
             if ($this->isCustom()) {
                 switch ($this->getCustomType()) {
                     case CustomDatatype::RADIO_CHOICE:
                     case CustomDatatype::DROPDOWN_CHOICE_TEXT:
                     case CustomDatatype::TEAM_CHOICE:
                     case CustomDatatype::STATUS_CHOICE:
                     case CustomDatatype::MILESTONE_CHOICE:
                     case CustomDatatype::CLIENT_CHOICE:
                     case CustomDatatype::COMPONENTS_CHOICE:
                     case CustomDatatype::EDITIONS_CHOICE:
                     case CustomDatatype::RELEASES_CHOICE:
                         $valid_items = explode(',', $this->getRuleValue());
                         if ($input instanceof \thebuggenie\core\entities\Issue) {
                             $value = $input->getCustomField($this->getCustomFieldname());
                         } elseif ($input instanceof framework\Request) {
                             $value = $input->getParameter($this->getCustomFieldname() . "_id");
                         }
                         $valid = false;
                         if (!$this->getRuleValue()) {
                             foreach ($this->getCustomField()->getOptions() as $item) {
                                 if ($item->getID() == $value) {
                                     $valid = true;
                                     break;
                                 }
                             }
                         } else {
                             foreach ($valid_items as $item) {
                                 if ($value instanceof Identifiable && $value->getID() == $item) {
                                     $valid = true;
                                     break;
                                 } elseif (is_numeric($value) && $value == $item) {
                                     $valid = true;
                                     break;
                                 }
                             }
                         }
                         return $valid;
                         break;
                 }
             } else {
                 $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::isValid', $this);
                 $event->setReturnValue(false);
                 $event->triggerUntilProcessed(array('input' => $input));
                 return $event->getReturnValue();
             }
     }
 }
Exemplo n.º 4
0
                        echo __("Please enter a valid triaged effect");
                        break;
                    default:
                        echo __("Please triage the reported issue, so the user pain score can be properly calculated");
                        break;
                }
                ?>
                        <?php 
            } elseif (\thebuggenie\core\entities\CustomDatatype::doesKeyExist($key)) {
                ?>
                            <?php 
                echo __('Required field "%field_name" is missing or invalid', array('%field_name' => \thebuggenie\core\entities\CustomDatatype::getByKey($key)->getDescription()));
                ?>
                        <?php 
            } else {
                $event = new \thebuggenie\core\framework\Event('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>
Exemplo n.º 5
0
 /**
  * Partial backdrop loader
  *
  * @Route(name="get_partial_for_backdrop", url="/get/partials/:key/*")
  * @AnonymousRoute
  *
  * @param framework\Request $request
  *
  * @return bool
  */
 public function runGetBackdropPartial(framework\Request $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 = entities\Issue::getB2DBTable()->selectById($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 = entities\User::getB2DBTable()->selectById($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 'attachlink':
                 $template_name = 'main/attachlink';
                 break;
             case 'openid':
                 $template_name = 'main/openid';
                 break;
             case 'notifications':
                 $template_name = 'main/notifications';
                 $options['first_notification_id'] = $request['first_notification_id'];
                 $options['last_notification_id'] = $request['last_notification_id'];
                 break;
             case 'workflow_transition':
                 $transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']);
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 if ($request->hasParameter('issue_ids')) {
                     $options['issues'] = array();
                     foreach ($request['issue_ids'] as $issue_id) {
                         $options['issues'][$issue_id] = new entities\Issue($issue_id);
                     }
                 } else {
                     $options['issue'] = new entities\Issue($request['issue_id']);
                 }
                 $options['show'] = true;
                 $options['interactive'] = true;
                 $options['project'] = $this->selected_project;
                 break;
             case 'reportissue':
                 $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
                 if ($this->selected_project instanceof entities\Project && !$this->selected_project->isLocked() && $this->getUser()->canReportIssues($this->selected_project)) {
                     $template_name = 'main/reportissuecontainer';
                     $options['selected_project'] = $this->selected_project;
                     $options['selected_issuetype'] = $this->selected_issuetype;
                     $options['locked_issuetype'] = $this->locked_issuetype;
                     $options['selected_milestone'] = $this->_getMilestoneFromRequest($request);
                     $options['parent_issue'] = $this->_getParentIssueFromRequest($request);
                     $options['board'] = $this->_getBoardFromRequest($request);
                     $options['selected_build'] = $this->_getBuildFromRequest($request);
                     $options['issuetypes'] = $this->issuetypes;
                     $options['errors'] = array();
                 } else {
                     throw new \Exception($this->getI18n()->__('You are not allowed to do this'));
                 }
                 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 'project_build':
                 $template_name = 'project/build';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 if ($request->hasParameter('build_id')) {
                     $options['build'] = entities\Build::getB2DBTable()->selectById($request['build_id']);
                 }
                 break;
             case 'project_icons':
                 $template_name = 'project/projecticons';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'project_workflow':
                 $template_name = 'project/projectworkflow';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'permissions':
                 $options['key'] = $request['permission_key'];
                 $target_module = $request['target_module'] !== 'core' ? $request['target_module'] : null;
                 if ($details = framework\Context::getPermissionDetails($options['key'], null, $target_module)) {
                     $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 = framework\Context::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'];
                 }
                 break;
             case 'site_icons':
                 $template_name = 'configuration/siteicons';
                 break;
             case 'project_config':
                 $template_name = 'project/projectconfig_container';
                 $project = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = entities\Edition::getB2DBTable()->selectById($request['edition_id']);
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = entities\Client::getB2DBTable()->selectById($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 'add_dashboard_view':
                 $template_name = 'main/adddashboardview';
                 break;
             case 'userscopes':
                 if (!framework\Context::getScope()->isDefault()) {
                     throw new \Exception($this->getI18n()->__('This is not allowed outside the default scope'));
                 }
                 $template_name = 'configuration/userscopes';
                 $options['user'] = new entities\User((int) $request['user_id']);
                 break;
             case 'milestone':
                 $template_name = 'project/milestone';
                 $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
                 if ($request->hasParameter('milestone_id')) {
                     $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
                 }
                 break;
             default:
                 $event = new \thebuggenie\core\framework\Event('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' => framework\Context::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage()))));
     }
     $this->getResponse()->cleanBuffer();
     $this->getResponse()->setHttpStatus(400);
     $error = framework\Context::isDebugMode() ? framework\Context::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup');
     return $this->renderJSON(array('error' => $error));
 }
 public function isValid($input)
 {
     switch ($this->_name) {
         case self::RULE_MAX_ASSIGNED_ISSUES:
             $num_issues = (int) $this->getRuleValue();
             return $num_issues ? (bool) (count(framework\Context::getUser()->getUserAssignedIssues()) < $num_issues) : true;
             break;
         case self::RULE_TEAM_MEMBERSHIP_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $teams = \thebuggenie\core\entities\Team::getAll();
             if ($this->isPost()) {
                 if ($input instanceof \thebuggenie\core\entities\Issue) {
                     $assignee = $input->getAssignee();
                 }
             } else {
                 $assignee = framework\Context::getUser();
             }
             if ($assignee instanceof \thebuggenie\core\entities\User) {
                 foreach ($valid_items as $team_id) {
                     if ($assignee->isMemberOfTeam($teams[$team_id])) {
                         return true;
                     }
                 }
             } elseif ($assignee instanceof \thebuggenie\core\entities\Team) {
                 foreach ($valid_items as $team_id) {
                     if ($assignee->getID() == $team_id) {
                         return true;
                     }
                 }
             }
             return false;
         case self::RULE_STATUS_VALID:
         case self::RULE_PRIORITY_VALID:
         case self::RULE_RESOLUTION_VALID:
         case self::RULE_REPRODUCABILITY_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $valid = false;
             foreach ($valid_items as $item) {
                 if ($this->_name == self::RULE_STATUS_VALID) {
                     $fieldname = 'Status';
                     $fieldname_small = 'status';
                 } elseif ($this->_name == self::RULE_RESOLUTION_VALID) {
                     $fieldname = 'Resolution';
                     $fieldname_small = 'resolution';
                 } elseif ($this->_name == self::RULE_REPRODUCABILITY_VALID) {
                     $fieldname = 'Reproducability';
                     $fieldname_small = 'reproducability';
                 } elseif ($this->_name == self::RULE_PRIORITY_VALID) {
                     $fieldname = 'Priority';
                     $fieldname_small = 'priority';
                 } else {
                     throw new framework\exceptions\ConfigurationException(framework\Context::getI18n()->__('Invalid workflow validation rule: %rule_name', array('%rule_name' => $this->_name)));
                 }
                 if ($input instanceof \thebuggenie\core\entities\Issue) {
                     $type = "\\thebuggenie\\core\\entities\\{$fieldname}";
                     $getter = "get{$fieldname}";
                     if ($type::getB2DBTable()->selectByID((int) $item)->getID() == $input->{$getter}()->getID()) {
                         $valid = true;
                         break;
                     }
                 } elseif ($input instanceof framework\Request) {
                     if ($input->getParameter("{$fieldname_small}_id") == $item) {
                         $valid = true;
                         break;
                     }
                 }
             }
             return $valid;
             break;
         default:
             if (strpos($this->_name, self::CUSTOMFIELD_VALIDATE_PREFIX) !== false) {
             } else {
                 $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::isValid', $this);
                 $event->setReturnValue(false);
                 $event->triggerUntilProcessed(array('input' => $input));
                 return $event->getReturnValue();
             }
     }
 }