protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, Projects::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, ListTypes::getTable());
     parent::_addForeignKeyColumn(self::TEAM_ID, Teams::getTable());
 }
Esempio n. 2
0
 public static function getAll()
 {
     if (self::$_teams === null) {
         self::$_teams = \thebuggenie\core\entities\tables\Teams::getTable()->getAll();
     }
     return self::$_teams;
 }
Esempio n. 3
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addVarchar(self::PERMISSION_TYPE, 100);
     parent::_addVarchar(self::TARGET_ID, 200, 0);
     parent::_addBoolean(self::ALLOWED);
     parent::_addVarchar(self::MODULE, 50);
     parent::_addForeignKeyColumn(self::UID, Users::getTable());
     parent::_addForeignKeyColumn(self::GID, Groups::getTable());
     parent::_addForeignKeyColumn(self::TID, Teams::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, ListTypes::getTable());
 }
Esempio n. 4
0
 public function clearTeamsByUserID($user_id)
 {
     $team_ids = array();
     $crit = $this->getCriteria();
     $crit->addWhere(self::UID, $user_id);
     $crit->addJoin(Teams::getTable(), Teams::ID, self::TID);
     $crit->addWhere(Teams::ONDEMAND, false);
     if ($res = $this->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $team_ids[$row->get(self::TID)] = true;
         }
     }
     if (!empty($team_ids)) {
         $crit = $this->getCriteria();
         $crit->addWhere(self::UID, $user_id);
         $crit->addWhere(self::TID, array_keys($team_ids), Criteria::DB_IN);
         $res = $this->doDelete($crit);
     }
 }
    if (!isset($an_issue)) {
        ?>
                        <a href="javascript:void(0);"><?php 
        echo __('No recent issues');
        ?>
</a>
                    <?php 
    }
    ?>
                </div>
            </li>
        <?php 
}
?>
        <?php 
if (!framework\Context::isProjectContext() && ($tbg_user->hasPageAccess('teamlist') || count($tbg_user->getTeams())) && !is_null(\thebuggenie\core\entities\tables\Teams::getTable()->getAll())) {
    ?>
            <li<?php 
    if ($tbg_response->getPage() == 'team') {
        ?>
 class="selected"<?php 
    }
    ?>
>
                <div class="menuitem_container">
                    <?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' => ""));
    ?>
Esempio n. 6
0
 public static function findTeams($details)
 {
     $crit = new \b2db\Criteria();
     $crit->addWhere(tables\Teams::NAME, "%{$details}%", \b2db\Criteria::DB_LIKE);
     $crit->addWhere(tables\Teams::ONDEMAND, false);
     $teams = array();
     if ($res = tables\Teams::getTable()->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $teams[$row->get(tables\Teams::ID)] = new \thebuggenie\core\entities\Team($row->get(tables\Teams::ID), $row);
         }
     }
     return $teams;
 }
Esempio n. 7
0
 /**
  * Find users and show selection box
  *
  * @param framework\Request $request The request object
  */
 public function runFindAssignee(framework\Request $request)
 {
     $this->forward403unless($request->isPost());
     $this->message = false;
     if ($request['find_by']) {
         $this->selected_project = entities\Project::getB2DBTable()->selectById($request['project_id']);
         $this->users = tables\Users::getTable()->getByDetails($request['find_by'], 10);
         $this->teams = tables\Teams::getTable()->quickfind($request['find_by']);
         $this->global_roles = entities\Role::getAll();
         $this->project_roles = entities\Role::getByProjectID($this->selected_project->getID());
     } else {
         $this->message = true;
     }
 }
 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();
     }
 }
Esempio n. 9
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;
     }
 }
Esempio n. 10
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'));
 }
Esempio n. 11
0
 public function runFilterFindTeams(framework\Request $request)
 {
     $filter = $request['filter'];
     $filterkey = $request['filterkey'];
     $existing_teams = $request['existing_id'];
     if (strlen($filter) < 3) {
         return $this->renderJSON(array('results' => '<li>' . $this->getI18n()->__('Please enter 3 characters or more') . '</li>'));
     }
     $teams = tables\Teams::getTable()->quickfind($filter, 10);
     if (isset($existing_teams)) {
         foreach ($existing_teams as $id => $one) {
             if (isset($teams[$id])) {
                 unset($teams[$id]);
             }
         }
     }
     return $this->renderJSON(array('results' => $this->getComponentHTML('search/filterfindteams', compact('teams', 'filterkey'))));
 }