Exemplo n.º 1
0
 protected function _getAvailableClientChoices()
 {
     $clients = tables\Clients::getTable()->getAll(10);
     foreach ($clients as $i => $client) {
         if (!$client->hasAccess()) {
             unset($clients[$i]);
         }
     }
     return $clients;
 }
 public function getRuleValueAsJoinedString()
 {
     $is_core = in_array($this->_name, array(self::RULE_STATUS_VALID, self::RULE_RESOLUTION_VALID, self::RULE_REPRODUCABILITY_VALID, self::RULE_PRIORITY_VALID, self::RULE_TEAM_MEMBERSHIP_VALID, self::RULE_ISSUE_IN_MILESTONE_VALID));
     $is_custom = $this->isCustom();
     $customtype = $this->getCustomType();
     if ($this->_name == self::RULE_STATUS_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Status';
     } elseif ($this->_name == self::RULE_RESOLUTION_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Resolution';
     } elseif ($this->_name == self::RULE_REPRODUCABILITY_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Reproducability';
     } elseif ($this->_name == self::RULE_PRIORITY_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Priority';
     } elseif ($this->_name == self::RULE_TEAM_MEMBERSHIP_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Team';
     } elseif ($this->_name == self::RULE_ISSUE_IN_MILESTONE_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Milestone';
     }
     if ($is_core || $is_custom) {
         $values = explode(',', $this->getRuleValue());
         if ($is_custom) {
             $custom_field_key = substr($this->_name, strlen(self::CUSTOMFIELD_VALIDATE_PREFIX) - 1);
             $custom_field = tables\CustomFields::getTable()->getByKey($custom_field_key);
         }
         $return_values = array();
         foreach ($values as $value) {
             try {
                 if ($is_core) {
                     $field = $fieldname::getB2DBTable()->selectByID((int) $value);
                 } elseif ($is_custom) {
                     switch ($customtype) {
                         case CustomDatatype::RADIO_CHOICE:
                         case CustomDatatype::DROPDOWN_CHOICE_TEXT:
                             $field = tables\CustomFieldOptions::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::TEAM_CHOICE:
                             $field = Teams::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::STATUS_CHOICE:
                             $field = ListTypes::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::MILESTONE_CHOICE:
                             $field = Milestones::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::CLIENT_CHOICE:
                             $field = Clients::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::COMPONENTS_CHOICE:
                             $field = Components::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::EDITIONS_CHOICE:
                             $field = Editions::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::RELEASES_CHOICE:
                             $field = Builds::getTable()->selectById((int) $value);
                             break;
                     }
                 }
                 if ($field instanceof \thebuggenie\core\entities\common\Identifiable) {
                     if ($field instanceof Milestone || $field instanceof Component || $field instanceof Edition || $field instanceof Build) {
                         $return_values[] = $field->getProject()->getName() . ' - ' . $field->getName();
                     } elseif ($field instanceof Status) {
                         $return_values[] = '<span class="status_badge" style="background-color: ' . $field->getColor() . '; color: ' . $field->getTextColor() . ';">' . $field->getName() . '</span>';
                     } else {
                         $return_values[] = $field->getName();
                     }
                 }
             } catch (\Exception $e) {
             }
         }
         return join(' / ', $return_values);
     } else {
         $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::getRuleValueAsJoinedString', $this);
         $event->triggerUntilProcessed();
         return $event->getReturnValue();
     }
 }
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? date('Y-m-d', (int) $action->getTargetValue()) : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE:
     echo __('Set issue field %key to ', array('%key' => $action->getCustomActionType()));
     echo '<div id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;display: inline;">';
     echo $action->getTargetValue() ? include_component('main/userdropdown', array('user' => $action->getTargetValue())) : __('Value provided by user');
     echo '</div>';
     break;
 case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE:
     echo __('Set issue field %key to ', array('%key' => $action->getCustomActionType()));
     echo '<div id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;display: inline;">';
     echo $action->getTargetValue() ? include_component('main/teamdropdown', array('team' => $action->getTargetValue())) : __('Value provided by user');
     echo '</div>';
     break;
 case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE:
     $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Clients::getTable()->selectById((int) $action->getTargetValue()) : null;
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
     $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $action->getTargetValue()) : null;
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
     $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $action->getTargetValue()) : null;
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
     $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $action->getTargetValue()) : null;
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE:
Exemplo n.º 4
0
 public function runAddClientMember(framework\Request $request)
 {
     try {
         $user_id = (int) $request['user_id'];
         $client = tables\Clients::getTable()->selectById((int) $request['client_id']);
         $user = entities\User::getB2DBTable()->selectByID($user_id);
         $client->addMember($user);
         return $this->renderJSON(array('clientlistitem' => $this->getComponentHTML('configuration/clientuserlistitem', compact('client', 'user_id', 'user')), 'update_clients' => array('ids' => array($client->getID()), 'membercounts' => array($client->getID() => $client->getNumberOfMembers()))));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Exemplo n.º 5
0
 public static function findClients($details)
 {
     $crit = new \b2db\Criteria();
     $crit->addWhere(tables\Clients::NAME, "%{$details}%", \b2db\Criteria::DB_LIKE);
     $clients = array();
     if ($res = tables\Clients::getTable()->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $clients[$row->get(tables\Clients::ID)] = new \thebuggenie\core\entities\Client($row->get(tables\Clients::ID), $row);
         }
     }
     return $clients;
 }
Exemplo n.º 6
0
 /**
  * Return the value of a custom field
  *
  * @param string $key
  *
  * @return mixed
  */
 public function getCustomField($key)
 {
     $var_name = "_customfield{$key}";
     if (property_exists($this, $var_name)) {
         $customtype = CustomDatatype::getByKey($key);
         if ($customtype->getType() == CustomDatatype::CALCULATED_FIELD) {
             $result = null;
             $options = $customtype->getOptions();
             if (!empty($options)) {
                 $formula = array_pop($options)->getValue();
                 preg_match_all('/{([[:alnum:]]+)}/', $formula, $matches);
                 $hasValues = false;
                 for ($i = 0; $i < count($matches[0]); $i++) {
                     $value = $this->getCustomField($matches[1][$i]);
                     if ($value instanceof \thebuggenie\core\entities\CustomDatatypeOption) {
                         $value = $value->getValue();
                     }
                     if (is_numeric($value)) {
                         $hasValues = true;
                     }
                     $value = floatval($value);
                     $formula = str_replace($matches[0][$i], $value, $formula);
                 }
                 // Check to verify formula only includes numbers and allowed operators
                 if ($hasValues && !preg_match('/[^0-9\\+-\\/*\\(\\)%]/', $formula)) {
                     try {
                         $m = new \Webit\Util\EvalMath\EvalMath();
                         $m->suppress_errors = true;
                         $result = $m->evaluate($formula);
                         if (!empty($m->last_error)) {
                             $result = $m->last_error;
                         } else {
                             $result = round($result, 2);
                         }
                     } catch (\Exception $e) {
                         $result = 'N/A';
                     }
                 }
             }
             return $result;
         } elseif ($this->{$var_name} && $customtype->hasCustomOptions() && !$this->{$var_name} instanceof \thebuggenie\core\entities\CustomDatatypeOption) {
             $this->{$var_name} = tables\CustomFieldOptions::getTable()->selectById($this->{$var_name});
         } elseif ($this->{$var_name} && $customtype->hasPredefinedOptions() && !$this->{$var_name} instanceof \thebuggenie\core\entities\common\Identifiable) {
             try {
                 switch ($customtype->getType()) {
                     case CustomDatatype::EDITIONS_CHOICE:
                         $this->{$var_name} = tables\Editions::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::COMPONENTS_CHOICE:
                         $this->{$var_name} = tables\Components::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::RELEASES_CHOICE:
                         $this->{$var_name} = tables\Builds::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::MILESTONE_CHOICE:
                         $this->{$var_name} = tables\Milestones::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::CLIENT_CHOICE:
                         $this->{$var_name} = tables\Clients::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::USER_CHOICE:
                         $this->{$var_name} = tables\Users::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::TEAM_CHOICE:
                         $this->{$var_name} = tables\Teams::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::STATUS_CHOICE:
                         $this->{$var_name} = Status::getB2DBTable()->selectById($this->{$var_name});
                         break;
                 }
             } catch (\Exception $e) {
             }
         }
         return $this->{$var_name};
     } else {
         return null;
     }
 }
Exemplo n.º 7
0
 /**
  * Find users and show selection links
  *
  * @param \thebuggenie\core\framework\Request $request The request object
  */
 public function runFindIdentifiable(framework\Request $request)
 {
     $this->forward403unless($request->isPost());
     $users = array();
     if ($find_identifiable_by = $request['find_identifiable_by']) {
         if ($request['include_clients']) {
             $clients = tables\Clients::getTable()->quickfind($find_identifiable_by);
         } else {
             $users = tables\Users::getTable()->getByDetails($find_identifiable_by, 10);
             if ($request['include_teams']) {
                 $teams = tables\Teams::getTable()->quickfind($find_identifiable_by);
             } else {
                 $teams = array();
             }
         }
     }
     $teamup_callback = $request['teamup_callback'];
     $team_callback = $request['team_callback'];
     $callback = $request['callback'];
     return $this->renderComponent('identifiableselectorresults', compact('users', 'teams', 'clients', 'callback', 'teamup_callback', 'team_callback'));
 }
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? date('Y-m-d', (int) $action->getTargetValue()) : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE:
     echo __('Set issue field %key to ', array('%key' => $action->getCustomActionType()));
     echo '<div id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;display: inline;">';
     echo $action->getTargetValue() ? include_component('main/userdropdown', array('user' => $action->getTargetValue())) : __('Value provided by user');
     echo '</div>';
     break;
 case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE:
     echo __('Set issue field %key to ', array('%key' => $action->getCustomActionType()));
     echo '<div id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;display: inline;">';
     echo $action->getTargetValue() ? include_component('main/teamdropdown', array('team' => $action->getTargetValue())) : __('Value provided by user');
     echo '</div>';
     break;
 case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE:
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Clients::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE:
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
     break;
 case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\ListTypes::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
Exemplo n.º 9
0
 public function runFilterFindClients(framework\Request $request)
 {
     $filter = $request['filter'];
     $filterkey = $request['filterkey'];
     $existing_clients = $request['existing_id'];
     if (strlen($filter) < 3) {
         return $this->renderJSON(array('results' => '<li>' . $this->getI18n()->__('Please enter 3 characters or more') . '</li>'));
     }
     $clients = tables\Clients::getTable()->quickfind($filter, 10);
     if (isset($existing_clients)) {
         foreach ($existing_clients as $id => $one) {
             if (isset($clients[$id])) {
                 unset($clients[$id]);
             }
         }
     }
     return $this->renderJSON(array('results' => $this->getComponentHTML('search/filterfindclients', compact('clients', 'filterkey'))));
 }
Exemplo n.º 10
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::UID, Users::getTable());
     parent::_addForeignKeyColumn(self::CID, Clients::getTable());
 }