Esempio n. 1
0
 public static function getTeamsCount()
 {
     if (self::$_num_teams === null) {
         if (self::$_teams !== null) {
             self::$_num_teams = count(self::$_teams);
         } else {
             self::$_num_teams = TBGTeamsTable::getTable()->countTeams();
         }
     }
     return self::$_num_teams;
 }
 public function hasValidTarget()
 {
     if (!$this->_target_value) {
         return true;
     }
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE:
             $target_details = explode('_', $this->_target_value);
             return (bool) ($target_details[0] == 'user') ? TBGUser::doesIDExist($target_details[1]) : TBGTeam::doesIDExist($target_details[1]);
             break;
         case self::ACTION_SET_PERCENT:
             return (bool) ($this->_target_value > -1);
             break;
         case self::ACTION_SET_MILESTONE:
             return (bool) TBGMilestone::doesIDExist($this->_target_value);
             break;
         case self::ACTION_SET_PRIORITY:
             return (bool) TBGPriority::has($this->_target_value);
             break;
         case self::ACTION_SET_STATUS:
             return (bool) TBGStatus::has($this->_target_value);
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             return (bool) TBGReproducability::has($this->_target_value);
             break;
         case self::ACTION_SET_RESOLUTION:
             return (bool) TBGResolution::has($this->_target_value);
             break;
         default:
             return true;
     }
 }
 public function perform(TBGIssue $issue, $request = null)
 {
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE_SELF:
             $issue->setAssignee(TBGContext::getUser());
             break;
         case self::ACTION_SET_STATUS:
             if ($this->getTargetValue()) {
                 $issue->setStatus(TBGContext::factory()->TBGStatus((int) $this->getTargetValue()));
             } else {
                 $issue->setStatus($request->getParameter('status_id'));
             }
             break;
         case self::ACTION_SET_MILESTONE:
             if ($this->getTargetValue()) {
                 $issue->setMilestone(TBGContext::factory()->TBGMilestone((int) $this->getTargetValue()));
             } else {
                 $issue->setMilestone($request->getParameter('milestone_id'));
             }
             break;
         case self::ACTION_CLEAR_PRIORITY:
             $issue->setPriority(null);
             break;
         case self::ACTION_SET_PRIORITY:
             if ($this->getTargetValue()) {
                 $issue->setPriority(TBGContext::factory()->TBGPriority((int) $this->getTargetValue()));
             } else {
                 $issue->setPriority($request->getParameter('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->getParameter('percent_complete_id'));
             }
             break;
         case self::ACTION_CLEAR_RESOLUTION:
             $issue->setResolution(null);
             break;
         case self::ACTION_SET_RESOLUTION:
             if ($this->getTargetValue()) {
                 $issue->setResolution(TBGContext::factory()->TBGResolution((int) $this->getTargetValue()));
             } else {
                 $issue->setResolution($request->getParameter('resolution_id'));
             }
             break;
         case self::ACTION_CLEAR_REPRODUCABILITY:
             $issue->setReproducability(null);
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             if ($this->getTargetValue()) {
                 $issue->setReproducability(TBGContext::factory()->TBGReproducability((int) $this->getTargetValue()));
             } else {
                 $issue->setReproducability($request->getParameter('reproducability_id'));
             }
             break;
         case self::ACTION_CLEAR_ASSIGNEE:
             $issue->unsetAssignee();
             break;
         case self::ACTION_ASSIGN_ISSUE:
             if ($this->getTargetValue()) {
                 $issue->setAssignee(TBGContext::factory()->TBGUser((int) $this->getTargetValue()));
             } else {
                 $assignee = null;
                 switch ($request->getParameter('assignee_type')) {
                     case TBGIdentifiableClass::TYPE_USER:
                         $assignee = TBGContext::factory()->TBGUser($request->getParameter('assignee_id'));
                         break;
                     case TBGIdentifiableClass::TYPE_TEAM:
                         $assignee = TBGContext::factory()->TBGTeam($request->getParameter('assignee_id'));
                         break;
                 }
                 if ((bool) $request->getParameter('assignee_teamup', false)) {
                     $team = new TBGTeam();
                     $team->setName($assignee->getBuddyname() . ' & ' . TBGContext::getUser()->getBuddyname());
                     $team->setOndemand(true);
                     $team->save();
                     $team->addMember($assignee);
                     $team->addMember(TBGContext::getUser());
                     $assignee = $team;
                 }
                 $issue->setAssignee($assignee);
             }
             break;
         case self::ACTION_USER_START_WORKING:
             $issue->clearUserWorkingOnIssue();
             if ($issue->getAssignee() instanceof TBGTeam && $issue->getAssignee()->isOndemand()) {
                 $members = $issue->getAssignee()->getMembers();
                 $issue->startWorkingOnIssue(array_shift($members));
             } else {
                 $issue->startWorkingOnIssue($issue->getAssignee());
             }
             break;
         case self::ACTION_USER_STOP_WORKING:
             if ($request->getParameter('did', 'nothing') == 'nothing') {
                 $issue->clearUserWorkingOnIssue();
             } else {
                 $issue->stopWorkingOnIssue();
             }
             break;
     }
 }
 public function getPredefinedBreadcrumbLinks($type, $project = null)
 {
     $i18n = TBGContext::getI18n();
     $links = array();
     switch ($type) {
         case 'main_links':
             $links[] = array('url' => TBGContext::getRouting()->generate('home'), 'title' => $i18n->__('Frontpage'));
             $links[] = array('url' => TBGContext::getRouting()->generate('dashboard'), 'title' => $i18n->__('Personal dashboard'));
             $links[] = array('title' => $i18n->__('Issues'));
             $links[] = array('title' => $i18n->__('Teams'));
             $links[] = array('title' => $i18n->__('Clients'));
             $links = TBGEvent::createNew('core', 'breadcrumb_main_links', null, array(), $links)->trigger()->getReturnList();
             if (TBGContext::getUser()->canAccessConfigurationPage()) {
                 $links[] = array('url' => make_url('configure'), 'title' => $i18n->__('Configure The Bug Genie'));
             }
             $links[] = array('url' => TBGContext::getRouting()->generate('about'), 'title' => $i18n->__('About %sitename%', array('%sitename%' => TBGSettings::getTBGname())));
             $links[] = array('url' => TBGContext::getRouting()->generate('account'), 'title' => $i18n->__('Account details'));
             break;
         case 'project_summary':
             $links[] = array('url' => TBGContext::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $i18n->__('Dashboard'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_scrum', array('project_key' => $project->getKey())), 'title' => $i18n->__('Sprint planning'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_roadmap', array('project_key' => $project->getKey())), 'title' => $i18n->__('Roadmap'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_team', array('project_key' => $project->getKey())), 'title' => $i18n->__('Team overview'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_statistics', array('project_key' => $project->getKey())), 'title' => $i18n->__('Statistics'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_timeline', array('project_key' => $project->getKey())), 'title' => $i18n->__('Timeline'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_reportissue', array('project_key' => $project->getKey())), 'title' => $i18n->__('Report an issue'));
             $links[] = array('url' => TBGContext::getRouting()->generate('project_issues', array('project_key' => $project->getKey())), 'title' => $i18n->__('Issues'));
             $links = TBGEvent::createNew('core', 'breadcrumb_project_links', null, array(), $links)->trigger()->getReturnList();
             break;
         case 'client_list':
             foreach (TBGClient::getAll() as $client) {
                 if ($client->hasAccess()) {
                     $links[] = array('url' => TBGContext::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName());
                 }
             }
             break;
         case 'team_list':
             foreach (TBGTeam::getAll() as $team) {
                 if ($team->hasAccess()) {
                     $links[] = array('url' => TBGContext::getRouting()->generate('team_dashboard', array('team_id' => $team->getID())), 'title' => $team->getName());
                 }
             }
             break;
     }
     return $links;
 }
									<label for="team_<?php 
        echo $user->getID();
        ?>
_<?php 
        echo $team->getID();
        ?>
" style="font-weight: normal;"><?php 
        echo $team->getName();
        ?>
</label>&nbsp;&nbsp;
								</div>
							<?php 
    }
    ?>
							<?php 
    if (count(TBGTeam::getAll()) == 0) {
        ?>
								<?php 
        echo __('No teams exist');
        ?>
							<?php 
    }
    ?>
						</td>
					</tr>
					<tr>
						<td style="vertical-align: top; padding-top: 4px;"><label><?php 
    echo __('Member of client(s)');
    ?>
</label></td>
						<td colspan="3">
 public function componentWorkflowtransitionaction()
 {
     $available_assignees_users = array();
     foreach (TBGContext::getUser()->getTeams() as $team) {
         foreach ($team->getMembers() as $user) {
             $available_assignees_users[$user->getID()] = $user;
         }
     }
     foreach (TBGContext::getUser()->getFriends() as $user) {
         $available_assignees_users[$user->getID()] = $user;
     }
     $this->available_assignees_teams = TBGTeam::getAll();
     $this->available_assignees_users = $available_assignees_users;
 }
Esempio n. 7
0
 public function runConfigureWorkflowTransition(TBGRequest $request)
 {
     $this->workflow = null;
     $this->transition = null;
     try {
         $this->workflow = TBGWorkflowsTable::getTable()->selectById((int) $request['workflow_id']);
         if ($request->hasParameter('transition_id')) {
             $mode = $request['mode'];
             $this->transition = TBGWorkflowTransitionsTable::getTable()->selectById((int) $request['transition_id']);
             if ($request->isPost()) {
                 if ($mode == 'edit') {
                     if (!$this->transition->isInitialTransition()) {
                         $this->transition->setName($request['transition_name']);
                         $this->transition->setDescription($request['transition_description']);
                         if ($request['template']) {
                             $this->transition->setTemplate($request['template']);
                         } else {
                             $this->transition->setTemplate(null);
                         }
                     }
                     try {
                         $step = TBGWorkflowStepsTable::getTable()->selectById((int) $request['outgoing_step_id']);
                         $this->transition->setOutgoingStep($step);
                     } catch (Exception $e) {
                     }
                     $this->transition->save();
                     $transition = $this->transition;
                     $redirect_transition = true;
                 } elseif ($mode == 'delete') {
                     $this->transition->deleteTransition($request['direction']);
                     return $this->renderJSON('ok');
                 } elseif ($mode == 'delete_action') {
                     $this->action = TBGWorkflowTransitionActionsTable::getTable()->selectById((int) $request['action_id']);
                     $this->action->delete();
                     return $this->renderJSON(array('message' => $this->getI18n()->__('The action has been deleted')));
                 } elseif ($mode == 'new_action') {
                     $action = new TBGWorkflowTransitionAction();
                     $action->setActionType($request['action_type']);
                     $action->setTransition($this->transition);
                     $action->setWorkflow($this->workflow);
                     $action->setTargetValue('');
                     $action->save();
                     return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/workflowtransitionaction', array('action' => $action))));
                 } elseif ($mode == 'update_action') {
                     $this->action = TBGWorkflowTransitionActionsTable::getTable()->selectById((int) $request['action_id']);
                     $this->action->setTargetValue($request['target_value']);
                     $this->action->save();
                     $text = $request['target_value'];
                     switch ($this->action->getActionType()) {
                         case TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE:
                             if ($this->action->hasTargetValue()) {
                                 $target_details = explode('_', $this->action->getTargetValue());
                                 $text = $target_details[0] == 'user' ? TBGUser::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : TBGTeam::getB2DBTable()->selectById((int) $target_details[1])->getName();
                             } else {
                                 $text = $this->getI18n()->__('User specified during transition');
                             }
                             break;
                         case TBGWorkflowTransitionAction::ACTION_SET_RESOLUTION:
                             $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Resolution specified by user');
                             break;
                         case TBGWorkflowTransitionAction::ACTION_SET_REPRODUCABILITY:
                             $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Reproducability specified by user');
                             break;
                         case TBGWorkflowTransitionAction::ACTION_SET_STATUS:
                             $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Status specified by user');
                             break;
                         case TBGWorkflowTransitionAction::ACTION_SET_PRIORITY:
                             $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Priority specified by user');
                             break;
                         case TBGWorkflowTransitionAction::ACTION_SET_MILESTONE:
                             $text = $this->action->getTargetValue() ? TBGMilestonesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Milestone specified by user');
                             break;
                     }
                     return $this->renderJSON(array('content' => $text));
                 } elseif ($mode == 'delete_validation_rule') {
                     $this->rule = TBGWorkflowTransitionValidationRulesTable::getTable()->selectById((int) $request['rule_id']);
                     $this->rule->delete();
                     return $this->renderJSON(array('message' => $this->getI18n()->__('The validation rule has been deleted')));
                 } elseif ($mode == 'new_validation_rule') {
                     $rule = new TBGWorkflowTransitionValidationRule();
                     if ($request['postorpre'] == 'post') {
                         $exists = (bool) $this->transition->hasPostValidationRule($request['rule']);
                         if (!$exists) {
                             $rule->setPost();
                         }
                     } elseif ($request['postorpre'] == 'pre') {
                         $exists = (bool) $this->transition->hasPreValidationRule($request['rule']);
                         if (!$exists) {
                             $rule->setPre();
                         }
                     }
                     if ($exists) {
                         $this->getResponse()->setHttpStatus(400);
                         return $this->renderJSON(array('message' => $this->getI18n()->__('This validation rule already exist')));
                     }
                     $rule->setRule($request['rule']);
                     $rule->setRuleValue('');
                     $rule->setTransition($this->transition);
                     $rule->setWorkflow($this->workflow);
                     $rule->save();
                     return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflowtransitionvalidationrule', array('rule' => $rule))));
                 } elseif ($mode == 'update_validation_rule') {
                     $this->rule = TBGWorkflowTransitionValidationRulesTable::getTable()->selectById((int) $request['rule_id']);
                     $text = null;
                     switch ($this->rule->getRule()) {
                         case TBGWorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES:
                             $this->rule->setRuleValue($request['rule_value']);
                             $text = $this->rule->getRuleValue() ? $this->rule->getRuleValue() : $this->getI18n()->__('Unlimited');
                             break;
                         case TBGWorkflowTransitionValidationRule::RULE_PRIORITY_VALID:
                         case TBGWorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID:
                         case TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID:
                         case TBGWorkflowTransitionValidationRule::RULE_STATUS_VALID:
                         case TBGWorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID:
                             $this->rule->setRuleValue(join(',', $request['rule_value']));
                             $text = $this->rule->getRuleValue() ? $this->rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value');
                             break;
                     }
                     $this->rule->save();
                     return $this->renderJSON(array('content' => $text));
                 }
             }
         } elseif ($request->isPost() && $request->hasParameter('step_id')) {
             $step = TBGWorkflowStepsTable::getTable()->selectById((int) $request['step_id']);
             /*if ($step->isCore() || $workflow->isCore())
             		{
             			throw new InvalidArgumentException("The default workflow cannot be edited");
             		}*/
             if ($request['add_transition_type'] == 'existing' && $request->hasParameter('existing_transition_id')) {
                 $transition = TBGWorkflowTransitionsTable::getTable()->selectById((int) $request['existing_transition_id']);
                 $redirect_transition = false;
             } else {
                 if ($request['transition_name'] && $request['outgoing_step_id'] && $request->hasParameter('template')) {
                     if (($outgoing_step = TBGWorkflowStepsTable::getTable()->selectById((int) $request['outgoing_step_id'])) && $step instanceof TBGWorkflowStep) {
                         if (array_key_exists($request['template'], TBGWorkflowTransition::getTemplates())) {
                             $transition = new TBGWorkflowTransition();
                             $transition->setWorkflow($this->workflow);
                             $transition->setName($request['transition_name']);
                             $transition->setDescription($request['transition_description']);
                             $transition->setOutgoingStep($outgoing_step);
                             $transition->setTemplate($request['template']);
                             $transition->save();
                             $step->addOutgoingTransition($transition);
                             $redirect_transition = true;
                         } else {
                             throw new InvalidArgumentException($this->getI18n()->__('Please select a valid template'));
                         }
                     } else {
                         throw new InvalidArgumentException($this->getI18n()->__('Please select a valid outgoing step'));
                     }
                 } else {
                     throw new InvalidArgumentException($this->getI18n()->__('Please fill in all required fields'));
                 }
             }
             $step->addOutgoingTransition($transition);
         } else {
             throw new InvalidArgumentException('Invalid action');
         }
     } catch (InvalidArgumentException $e) {
         //throw $e;
         $this->error = $e->getMessage();
     } catch (Exception $e) {
         throw $e;
         $this->error = $this->getI18n()->__('This workflow / transition does not exist');
     }
     if (isset($redirect_transition) && $redirect_transition) {
         $this->forward(TBGContext::getRouting()->generate('configure_workflow_transition', array('workflow_id' => $this->workflow->getID(), 'transition_id' => $transition->getID())));
     } elseif (isset($redirect_transition)) {
         $this->forward(TBGContext::getRouting()->generate('configure_workflow_steps', array('workflow_id' => $this->workflow->getID())));
     }
 }
    }
    ?>
 text-align: center;">
					<?php 
    include_component('configuration/permissionsinfoitem', array('key' => $key, 'target_id' => $target_id, 'type' => 'group', 'mode' => $mode, 'item_id' => $group->getID(), 'item_name' => $group->getName(), 'module' => $module, 'access_level' => $access_level));
    ?>
				</td>
			</tr>
			<?php 
    $cc++;
    ?>
		<?php 
}
?>
		<?php 
$teams = TBGTeam::getAll();
?>
		<?php 
foreach ($teams as $team) {
    ?>
			<tr class="hover_highlight">
				<td style="padding: 2px;"><?php 
    echo '<b>' . __('Team: %team_name', array('%team_name' => '</b>' . $team->getName()));
    ?>
</td>
				<td style="padding: 2px; text-align: center;">
					<?php 
    include_component('configuration/permissionsinfoitem', array('key' => $key, 'type' => 'team', 'target_id' => $target_id, 'mode' => $mode, 'item_id' => $team->getID(), 'item_name' => $team->getName(), 'module' => $module, 'access_level' => $access_level));
    ?>
				</td>
			</tr>
 public function hasTeamsAvailable()
 {
     return $this->getMaxTeams() ? TBGTeam::getTeamsCount() < $this->getMaxTeams() : true;
 }
 public function isValid($input)
 {
     switch ($this->_name) {
         case self::RULE_MAX_ASSIGNED_ISSUES:
             $num_issues = (int) $this->getRuleValue();
             return $num_issues ? (bool) (count(TBGContext::getUser()->getUserAssignedIssues()) < $num_issues) : true;
             break;
         case self::RULE_TEAM_MEMBERSHIP_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $teams = TBGTeam::getAll();
             if ($this->isPost()) {
                 if ($input instanceof TBGIssue) {
                     $assignee = $input->getAssignee();
                 }
             } else {
                 $assignee = TBGContext::getUser();
             }
             if ($assignee instanceof TBGUser) {
                 foreach ($valid_items as $team_id) {
                     if ($assignee->isMemberOfTeam($teams[$team_id])) {
                         return true;
                     }
                 }
             } elseif ($assignee instanceof TBGTeam) {
                 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';
                 }
                 if ($input instanceof TBGIssue) {
                     $type = "TBG{$fieldname}";
                     $getter = "get{$fieldname}";
                     if (TBGContext::factory()->{$type}((int) $item)->getID() == $input->{$getter}()->getID()) {
                         $valid = true;
                         break;
                     }
                 } elseif ($input instanceof TBGRequest) {
                     if ($input->getParameter("{$fieldname_small}_id") == $item) {
                         $valid = true;
                         break;
                     }
                 }
             }
             return $valid;
             break;
     }
 }
Esempio n. 11
0
 /**
  * Sets an issue field to a specified value
  * 
  * @param TBGRequest $request
  */
 public function runIssueSetField(TBGRequest $request)
 {
     if ($issue_id = $request['issue_id']) {
         try {
             $issue = TBGIssuesTable::getTable()->selectById($issue_id);
         } catch (Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderText('fail');
         }
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderText('no issue');
     }
     TBGContext::loadLibrary('common');
     if (!$issue instanceof TBGIssue) {
         return false;
     }
     switch ($request['field']) {
         case 'description':
             if (!$issue->canEditDescription()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             $issue->setDescription($request->getRawParameter('value'));
             $issue->setDescriptionSyntax($request->getParameter('value_syntax'));
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isDescriptionChanged(), 'field' => array('id' => (int) ($issue->getDescription() != ''), 'name' => $issue->getParsedDescription(array('issue' => $issue))), 'description' => $issue->getParsedDescription(array('issue' => $issue))));
             break;
         case 'reproduction_steps':
             if (!$issue->canEditReproductionSteps()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             $issue->setReproductionSteps($request->getRawParameter('value'));
             $issue->setReproductionStepsSyntax($request->getParameter('value_syntax'));
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isReproductionStepsChanged(), 'field' => array('id' => (int) ($issue->getReproductionSteps() != ''), 'name' => $issue->getParsedReproductionSteps(array('issue' => $issue))), 'reproduction_steps' => $issue->getParsedReproductionSteps(array('issue' => $issue))));
             break;
         case 'title':
             if (!$issue->canEditTitle()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if ($request['value'] == '') {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You have to provide a title')));
             } else {
                 $issue->setTitle($request->getRawParameter('value'));
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isTitleChanged(), 'field' => array('id' => 1, 'name' => strip_tags($issue->getTitle()))));
             }
             break;
         case 'percent_complete':
             if (!$issue->canEditPercentage()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             $issue->setPercentCompleted($request['percent']);
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'field' => 'percent_complete', 'changed' => $issue->isPercentCompletedChanged(), 'percent' => $issue->getPercentCompleted()));
             break;
         case 'estimated_time':
             if (!$issue->canEditEstimatedTime()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if (!$issue->isUpdateable()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('This issue cannot be updated')));
             }
             if ($request['estimated_time']) {
                 $issue->setEstimatedTime($request['estimated_time']);
             } elseif ($request->hasParameter('value')) {
                 $issue->setEstimatedTime($request['value']);
             } else {
                 $issue->setEstimatedMonths($request['months']);
                 $issue->setEstimatedWeeks($request['weeks']);
                 $issue->setEstimatedDays($request['days']);
                 $issue->setEstimatedHours($request['hours']);
                 $issue->setEstimatedPoints($request['points']);
             }
             if ($request['do_save']) {
                 $issue->save();
             }
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isEstimatedTimeChanged(), 'field' => $issue->hasEstimatedTime() ? array('id' => 1, 'name' => TBGIssue::getFormattedTime($issue->getEstimatedTime())) : array('id' => 0), 'values' => $issue->getEstimatedTime()));
             break;
         case 'posted_by':
         case 'owned_by':
         case 'assigned_to':
             if ($request['field'] == 'posted_by' && !$issue->canEditPostedBy()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'owned_by' && !$issue->canEditOwner()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'assigned_to' && !$issue->canEditAssignee()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if ($request->hasParameter('value')) {
                 if ($request->hasParameter('identifiable_type')) {
                     if (in_array($request['identifiable_type'], array('team', 'user')) && $request['value'] != 0) {
                         switch ($request['identifiable_type']) {
                             case 'user':
                                 $identified = TBGContext::factory()->TBGUser($request['value']);
                                 break;
                             case 'team':
                                 $identified = TBGContext::factory()->TBGTeam($request['value']);
                                 break;
                         }
                         if ($identified instanceof TBGUser || $identified instanceof TBGTeam) {
                             if ((bool) $request->getParameter('teamup', false)) {
                                 $team = new TBGTeam();
                                 $team->setName($identified->getBuddyname() . ' & ' . $this->getUser()->getBuddyname());
                                 $team->setOndemand(true);
                                 $team->save();
                                 $team->addMember($identified);
                                 $team->addMember($this->getUser());
                                 $identified = $team;
                             }
                             if ($request['field'] == 'owned_by') {
                                 $issue->setOwner($identified);
                             } elseif ($request['field'] == 'assigned_to') {
                                 $issue->setAssignee($identified);
                             }
                         }
                     } else {
                         if ($request['field'] == 'owned_by') {
                             $issue->clearOwner();
                         } elseif ($request['field'] == 'assigned_to') {
                             $issue->clearAssignee();
                         }
                     }
                 } elseif ($request['field'] == 'posted_by') {
                     $identified = TBGContext::factory()->TBGUser($request['value']);
                     if ($identified instanceof TBGUser) {
                         $issue->setPostedBy($identified);
                     }
                 }
                 if ($request['field'] == 'posted_by') {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isPostedByChanged(), 'field' => array('id' => $issue->getPostedByID(), 'name' => $this->getComponentHTML('main/userdropdown', array('user' => $issue->getPostedBy())))));
                 }
                 if ($request['field'] == 'owned_by') {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isOwnerChanged(), 'field' => $issue->isOwned() ? array('id' => $issue->getOwner()->getID(), 'name' => $issue->getOwner() instanceof TBGUser ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getOwner())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getOwner()))) : array('id' => 0)));
                 }
                 if ($request['field'] == 'assigned_to') {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isAssigneeChanged(), 'field' => $issue->isAssigned() ? array('id' => $issue->getAssignee()->getID(), 'name' => $issue->getAssignee() instanceof TBGUser ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getAssignee())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getAssignee()))) : array('id' => 0)));
                 }
             }
             break;
         case 'spent_time':
             if (!$issue->canEditSpentTime()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if ($request['spent_time'] != TBGContext::getI18n()->__('Enter time spent here') && $request['spent_time']) {
                 $issue->addSpentTime($request['spent_time']);
             } elseif ($request->hasParameter('value')) {
                 $issue->addSpentTime($request['value']);
             } else {
                 $issue->addSpentMonths($request['months']);
                 $issue->addSpentWeeks($request['weeks']);
                 $issue->addSpentDays($request['days']);
                 $issue->addSpentHours($request['hours']);
                 $issue->addSpentPoints($request['points']);
             }
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isSpentTimeChanged(), 'field' => $issue->hasSpentTime() ? array('id' => 1, 'name' => TBGIssue::getFormattedTime($issue->getSpentTime())) : array('id' => 0), 'values' => $issue->getSpentTime()));
             break;
         case 'category':
         case 'resolution':
         case 'severity':
         case 'reproducability':
         case 'priority':
         case 'milestone':
         case 'issuetype':
         case 'status':
         case 'pain_bug_type':
         case 'pain_likelihood':
         case 'pain_effect':
             if ($request['field'] == 'category' && !$issue->canEditCategory()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'resolution' && !$issue->canEditResolution()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'severity' && !$issue->canEditSeverity()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'reproducability' && !$issue->canEditReproducability()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'priority' && !$issue->canEditPriority()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'milestone' && !$issue->canEditMilestone()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'issuetype' && !$issue->canEditIssuetype()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'status' && !$issue->canEditStatus()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif (in_array($request['field'], array('pain_bug_type', 'pain_likelihood', 'pain_effect')) && !$issue->canEditUserPain()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             try {
                 $classname = null;
                 $parameter_name = mb_strtolower($request['field']);
                 $parameter_id_name = "{$parameter_name}_id";
                 $is_pain = in_array($parameter_name, array('pain_bug_type', 'pain_likelihood', 'pain_effect'));
                 if ($is_pain) {
                     switch ($parameter_name) {
                         case 'pain_bug_type':
                             $set_function_name = 'setPainBugType';
                             $is_changed_function_name = 'isPainBugTypeChanged';
                             $get_pain_type_label_function = 'getPainBugTypeLabel';
                             break;
                         case 'pain_likelihood':
                             $set_function_name = 'setPainLikelihood';
                             $is_changed_function_name = 'isPainLikelihoodChanged';
                             $get_pain_type_label_function = 'getPainLikelihoodLabel';
                             break;
                         case 'pain_effect':
                             $set_function_name = 'setPainEffect';
                             $is_changed_function_name = 'isPainEffectChanged';
                             $get_pain_type_label_function = 'getPainEffectLabel';
                             break;
                     }
                 } else {
                     $classname = 'TBG' . ucfirst($parameter_name);
                     $lab_function_name = $classname;
                     $set_function_name = 'set' . ucfirst($parameter_name);
                     $is_changed_function_name = 'is' . ucfirst($parameter_name) . 'Changed';
                 }
                 if ($request->hasParameter($parameter_id_name)) {
                     $parameter_id = $request->getParameter($parameter_id_name);
                     if ($parameter_id !== 0) {
                         $is_valid = $is_pain ? in_array($parameter_id, array_keys(TBGIssue::getPainTypesOrLabel($parameter_name))) : $parameter_id == 0 || ($parameter = TBGContext::factory()->{$lab_function_name}($parameter_id)) instanceof $classname;
                     }
                     if ($parameter_id == 0 || $parameter_id !== 0 && $is_valid) {
                         if ($classname == 'TBGIssuetype') {
                             $visible_fields = $issue->getIssuetype() instanceof TBGIssuetype ? $issue->getProject()->getVisibleFieldsArray($issue->getIssuetype()->getID()) : array();
                         } else {
                             $visible_fields = null;
                         }
                         $issue->{$set_function_name}($parameter_id);
                         if ($is_pain) {
                             if (!$issue->{$is_changed_function_name}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'field' => array('id' => 0), 'user_pain' => $issue->getUserPain(), 'user_pain_diff_text' => $issue->getUserPainDiffText()));
                             }
                             return $parameter_id == 0 ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0), 'user_pain' => $issue->getUserPain(), 'user_pain_diff_text' => $issue->getUserPainDiffText())) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => $parameter_id, 'name' => $issue->{$get_pain_type_label_function}()), 'user_pain' => $issue->getUserPain(), 'user_pain_diff_text' => $issue->getUserPainDiffText()));
                         } else {
                             if (!$issue->{$is_changed_function_name}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             if (isset($parameter)) {
                                 $name = $parameter->getName();
                             } else {
                                 $name = null;
                             }
                             $field = array('id' => $parameter_id, 'name' => $name);
                             if ($classname == 'TBGIssuetype') {
                                 TBGContext::loadLibrary('ui');
                                 $field['src'] = htmlspecialchars(TBGContext::getTBGPath() . 'iconsets/' . TBGSettings::getThemeName() . '/' . $issue->getIssuetype()->getIcon() . '_small.png');
                             }
                             if ($parameter_id == 0) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0)));
                             } else {
                                 $options = array('issue_id' => $issue->getID(), 'changed' => true, 'visible_fields' => $visible_fields, 'field' => $field);
                                 if ($request['field'] == 'milestone') {
                                     $options['field']['url'] = $this->getRouting()->generate('project_milestone_details', array('project_key' => $issue->getProject()->getKey(), 'milestone_id' => $issue->getMilestone()->getID()));
                                 }
                                 if ($request['field'] == 'status') {
                                     $options['field']['color'] = $issue->getStatus()->getItemdata();
                                 }
                                 return $this->renderJSON($options);
                             }
                         }
                     }
                 }
             } catch (Exception $e) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('error' => $e->getMessage()));
             }
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('error' => TBGContext::getI18n()->__('No valid field value specified')));
             break;
         default:
             if ($customdatatype = TBGCustomDatatype::getByKey($request['field'])) {
                 $key = $customdatatype->getKey();
                 $customdatatypeoption_value = $request->getParameter("{$key}_value");
                 if (!$customdatatype->hasCustomOptions()) {
                     switch ($customdatatype->getType()) {
                         case TBGCustomDatatype::EDITIONS_CHOICE:
                         case TBGCustomDatatype::COMPONENTS_CHOICE:
                         case TBGCustomDatatype::RELEASES_CHOICE:
                         case TBGCustomDatatype::STATUS_CHOICE:
                         case TBGCustomDatatype::MILESTONE_CHOICE:
                         case TBGCustomDatatype::USER_CHOICE:
                         case TBGCustomDatatype::TEAM_CHOICE:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 switch ($customdatatype->getType()) {
                                     case TBGCustomDatatype::EDITIONS_CHOICE:
                                         $temp = TBGEditionsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::COMPONENTS_CHOICE:
                                         $temp = TBGComponentsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::RELEASES_CHOICE:
                                         $temp = TBGBuildsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::MILESTONE_CHOICE:
                                         $temp = TBGMilestonesTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::STATUS_CHOICE:
                                         $temp = TBGStatus::getB2DBTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::USER_CHOICE:
                                         $temp = TBGUsersTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::TEAM_CHOICE:
                                         $temp = TBGTeamsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                 }
                                 $finalvalue = $temp->getName();
                                 $issue->setCustomField($key, $request->getRawParameter("{$key}_value"));
                             }
                             if ($customdatatype->getType() == TBGCustomDatatype::STATUS_CHOICE && isset($temp) && is_object($temp)) {
                                 $finalvalue = '<div class="status_badge" style="background-color: ' . $temp->getColor() . ';"><span>' . $finalvalue . '</span></div>';
                             } elseif ($customdatatype->getType() == TBGCustomDatatype::USER_CHOICE && isset($temp) && is_object($temp)) {
                                 $finalvalue = $this->getComponentHTML('main/userdropdown', array('user' => $temp));
                             } elseif ($customdatatype->getType() == TBGCustomDatatype::TEAM_CHOICE && isset($temp) && is_object($temp)) {
                                 $finalvalue = $this->getComponentHTML('main/teamdropdown', array('team' => $temp));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => $finalvalue)));
                             break;
                         case TBGCustomDatatype::INPUT_TEXTAREA_MAIN:
                         case TBGCustomDatatype::INPUT_TEXTAREA_SMALL:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 $issue->setCustomField($key, $request->getRawParameter("{$key}_value"));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => tbg_parse_text($request->getRawParameter("{$key}_value")))));
                             break;
                         case TBGCustomDatatype::DATE_PICKER:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 $issue->setCustomField($key, $request->getParameter("{$key}_value"));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => date('Y-m-d', (int) $request->getRawParameter("{$key}_value")))));
                             break;
                         default:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 $issue->setCustomField($key, $request->getParameter("{$key}_value"));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => filter_var($customdatatypeoption_value, FILTER_VALIDATE_URL) !== false ? "<a href=\"{$customdatatypeoption_value}\">{$customdatatypeoption_value}</a>" : $customdatatypeoption_value)));
                             break;
                     }
                 }
                 $customdatatypeoption = $customdatatypeoption_value ? TBGCustomDatatypeOption::getB2DBTable()->selectById($customdatatypeoption_value) : null;
                 if ($customdatatypeoption instanceof TBGCustomDatatypeOption) {
                     $issue->setCustomField($key, $customdatatypeoption->getID());
                 } else {
                     $issue->setCustomField($key, null);
                 }
                 $changed_methodname = "isCustomfield{$key}Changed";
                 if (!$issue->{$changed_methodname}()) {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                 }
                 return !$customdatatypeoption instanceof TBGCustomDatatypeOption ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $customdatatypeoption->getID(), 'name' => $customdatatypeoption->getName())));
             }
             break;
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('error' => TBGContext::getI18n()->__('No valid field specified (%field)', array('%field' => $request['field']))));
 }
							<?php 
                echo __('Set resolution to %resolution', array('%resolution' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? TBGContext::factory()->TBGResolution((int) $action->getTargetValue())->getName() : __('Resolution provided by user')) . '</span>'));
                ?>
						<?php 
            } elseif ($action->getActionType() == TBGWorkflowTransitionAction::ACTION_SET_REPRODUCABILITY) {
                ?>
							<?php 
                echo __('Set reproducability to %reproducability', array('%reproducability' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? TBGContext::factory()->TBGReproducability((int) $action->getTargetValue())->getName() : __('Reproducability provided by user')) . '</span>'));
                ?>
						<?php 
            } elseif ($action->getActionType() == TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE) {
                ?>
							<?php 
                if ($action->hasTargetValue()) {
                    $target_details = explode('_', $action->getTargetValue());
                    echo __('Assign issue to %assignee', array('%assignee' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($target_details[0] == 'user' ? TBGUser::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : TBGTeam::getB2DBTable()->selectById((int) $target_details[1])->getName()) . '</span>'));
                } else {
                    echo __('Assign issue to %assignee', array('%assignee' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . __('User or team specified during transition') . '</span>'));
                }
                ?>
						<?php 
            }
            ?>
					<?php 
        } elseif ($action->getTargetValue()) {
            ?>
						<span class="generic_error_message"><?php 
            echo __('Invalid transition configuration');
            ?>
</span>
					<?php 
Esempio n. 13
0
<?php

$tbg_response->setTitle(__('Configure users, teams and clients'));
$users_text = TBGContext::getScope()->getMaxUsers() ? __('Users (%num/%max)', array('%num' => '<span id="current_user_num_count">' . TBGUser::getUsersCount() . '</span>', '%max' => TBGContext::getScope()->getMaxUsers())) : __('Users');
$teams_text = TBGContext::getScope()->getMaxTeams() ? __('Teams (%num/%max)', array('%num' => '<span id="current_team_num_count">' . TBGTeam::countAll() . '</span>', '%max' => TBGContext::getScope()->getMaxTeams())) : __('Teams');
?>
<table style="table-layout: fixed; width: 100%" cellpadding=0 cellspacing=0 class="configuration_page">
	<tr>
		<?php 
include_component('leftmenu', array('selected_section' => TBGSettings::CONFIGURATION_SECTION_USERS));
?>
		<td valign="top" style="padding-left: 15px;">
			<div style="width: 730px;">
				<h3><?php 
echo __('Configure users, teams and clients');
?>
</h3>
				<div class="tab_menu inset">
					<ul id="usersteamsgroups_menu">
						<li id="tab_users" class="selected"><?php 
echo javascript_link_tag($users_text, array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_users', 'usersteamsgroups_menu');"));
?>
</li>
						<li id="tab_teams"><?php 
echo javascript_link_tag($teams_text, array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_teams', 'usersteamsgroups_menu');"));
?>
</li>
						<li id="tab_clients"><?php 
echo javascript_link_tag(__('Clients'), array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_clients', 'usersteamsgroups_menu');"));
?>
</li>
                ?>
								<?php 
            }
            ?>
							</label>
							<?php 
            if ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_STATUS_VALID) {
                $options = TBGStatus::getAll();
            } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_PRIORITY_VALID) {
                $options = TBGPriority::getAll();
            } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID) {
                $options = TBGResolution::getAll();
            } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID) {
                $options = TBGReproducability::getAll();
            } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID) {
                $options = TBGTeam::getAll();
            }
            ?>
							<?php 
            foreach ($options as $option) {
                ?>
							<br><input type="checkbox" style="margin-left: 25px;" name="rule_value[<?php 
                echo $option->getID();
                ?>
]" value="<?php 
                echo $option->getID();
                ?>
"<?php 
                if ($rule->isValueValid($option->getID())) {
                    echo ' checked';
                }
Esempio n. 15
0
        ?>
 class="selected"<?php 
    }
    ?>
>
												<div>
													<?php 
    echo link_tag('javascript:void(0)', image_tag('tab_teams.png') . __('Teams'), array('class' => 'not_clickable'));
    ?>
													<?php 
    echo javascript_link_tag(image_tag('tabmenu_dropdown.png', array('class' => 'menu_dropdown')), array('onmouseover' => ""));
    ?>
												</div>
												<div id="team_menu" class="tab_menu_dropdown shadowed">
													<?php 
    foreach (TBGTeam::getAll() as $team) {
        ?>
														<?php 
        if (!$team->hasAccess()) {
            continue;
        }
        ?>
														<?php 
        echo link_tag(make_url('team_dashboard', array('team_id' => $team->getID())), image_tag('tab_teams.png') . $team->getName());
        ?>
													<?php 
    }
    ?>
												</div>											
											</li>
										<?php 
Esempio n. 16
0
 /**
  * Add this user to a team
  * 
  * @param TBGTeam $team 
  */
 public function addToTeam(TBGTeam $team)
 {
     $team->addMember($this);
     $this->_teams = null;
 }
Esempio n. 17
0
 public function runAddTeam(TBGRequest $request)
 {
     try {
         $mode = $request->getParameter('mode');
         if ($team_name = $request->getParameter('team_name')) {
             if ($mode == 'clone') {
                 try {
                     $old_team = TBGContext::factory()->TBGTeam($request->getParameter('team_id'));
                 } catch (Exception $e) {
                 }
                 if (!$old_team instanceof TBGTeam) {
                     throw new Exception(TBGContext::getI18n()->__("You cannot clone this team"));
                 }
             }
             if (TBGTeam::doesTeamNameExist(trim($team_name))) {
                 throw new Exception(TBGContext::getI18n()->__("Please enter a team name that doesn't already exist"));
             }
             $team = new TBGTeam();
             $team->setName($team_name);
             $team->save();
             if ($mode == 'clone') {
                 if ($request->getParameter('clone_permissions')) {
                     TBGPermissionsTable::getTable()->cloneTeamPermissions($old_team->getID(), $team->getID());
                 }
                 if ($request->getParameter('clone_memberships')) {
                     TBGTeamMembersTable::getTable()->cloneTeamMemberships($old_team->getID(), $team->getID());
                 }
                 $message = TBGContext::getI18n()->__('The team was cloned');
             } else {
                 $message = TBGContext::getI18n()->__('The team was added');
             }
             return $this->renderJSON(array('failed' => false, 'message' => $message, 'content' => $this->getTemplateHTML('configuration/teambox', array('team' => $team)), 'total_count' => TBGTeam::getTeamsCount(), 'more_available' => TBGContext::getScope()->hasTeamsAvailable()));
         } else {
             throw new Exception(TBGContext::getI18n()->__('Please enter a team name'));
         }
     } catch (Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('failed' => true, 'error' => $e->getMessage()));
     }
 }
Esempio n. 18
0
 /**
  * Find users and show selection links
  * 
  * @param TBGRequest $request The request object
  */
 public function runFindIdentifiable(TBGRequest $request)
 {
     $this->forward403unless($request->isMethod(TBGRequest::POST));
     $this->users = array();
     if ($find_identifiable_by = $request->getParameter('find_identifiable_by')) {
         $this->users = TBGUser::findUsers($find_identifiable_by, 10);
         if ($request->getParameter('include_teams')) {
             $this->teams = TBGTeam::findTeams($find_identifiable_by);
         } else {
             $this->teams = array();
         }
     }
     $teamup_callback = $request->getParameter('teamup_callback');
     return $this->renderComponent('identifiableselectorresults', array('users' => $this->users, 'teams' => $this->teams, 'callback' => $request->getParameter('callback'), 'teamup_callback' => $teamup_callback));
 }