Example #1
0
 public function componentEditAgileBoard()
 {
     $i18n = framework\Context::getI18n();
     $this->autosearches = array(\thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES => $i18n->__('Project open issues (recommended)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES_INCLUDING_SUBPROJECTS => $i18n->__('Project open issues (including subprojects)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES => $i18n->__('Project closed issues'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES_INCLUDING_SUBPROJECTS => $i18n->__('Project closed issues (including subprojects)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_REPORTED_THIS_MONTH => $i18n->__('Project issues reported last month'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_WISHLIST => $i18n->__('Project wishlist'));
     $this->savedsearches = \thebuggenie\core\entities\tables\SavedSearches::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(framework\Context::getUser()->getID(), $this->board->getProject()->getID());
     $this->issuetypes = $this->board->getProject()->getIssuetypeScheme()->getIssuetypes();
     $this->issuefields = \thebuggenie\core\entities\CustomDatatype::getByFieldType(\thebuggenie\core\entities\CustomDatatype::DATE_PICKER);
     $this->swimlane_groups = array('priority' => $i18n->__('Issue priority'), 'severity' => $i18n->__('Issue severity'), 'category' => $i18n->__('Issue category'));
     $this->priorities = \thebuggenie\core\entities\Priority::getAll();
     $this->severities = \thebuggenie\core\entities\Severity::getAll();
     $this->categories = \thebuggenie\core\entities\Category::getAll();
     $fakecolumn = new entities\BoardColumn();
     $fakecolumn->setBoard($this->board);
     $this->fakecolumn = $fakecolumn;
 }
 public static function getAvailablePostValidationRules()
 {
     $initial_list = array();
     $i18n = framework\Context::getI18n();
     $initial_list[self::RULE_PRIORITY_VALID] = $i18n->__('Validate specified priority');
     $initial_list[self::RULE_REPRODUCABILITY_VALID] = $i18n->__('Validate specified reproducability');
     $initial_list[self::RULE_RESOLUTION_VALID] = $i18n->__('Validate specified resolution');
     $initial_list[self::RULE_STATUS_VALID] = $i18n->__('Validate specified status');
     foreach (CustomDatatype::getAll() as $key => $details) {
         $initial_list[self::CUSTOMFIELD_VALIDATE_PREFIX . $key] = $i18n->__('Validate specified %key', array('%key' => $key));
     }
     $initial_list[self::RULE_TEAM_MEMBERSHIP_VALID] = $i18n->__('Validate team membership of assignee');
     $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::getAvailablePostValidationRules', null, array(), $initial_list);
     $event->trigger();
     return $event->getReturnList();
 }
 public function _migrateData(\b2db\Table $old_table)
 {
     switch ($old_table->getVersion()) {
         case 1:
             if ($res = $old_table->doSelectAll()) {
                 $customdatatypes_table = \thebuggenie\core\entities\CustomDatatype::getB2DBTable();
                 $crit = $customdatatypes_table->getCriteria();
                 $crit->indexBy(CustomFields::FIELD_KEY);
                 $customfields = $customdatatypes_table->select($crit);
                 while ($row = $res->getNextRow()) {
                     $key = $row->get('customfieldoptions.customfield_key');
                     $customfield = array_key_exists($key, $customfields) ? $customfields[$key] : null;
                     if ($customfield instanceof \thebuggenie\core\entities\CustomDatatype) {
                         $crit = $this->getCriteria();
                         $crit->addUpdate(self::CUSTOMFIELD_ID, $customfield->getID());
                         $this->doUpdateById($crit, $row->get(self::ID));
                     } else {
                         $this->doDeleteById($row->get(self::ID));
                     }
                 }
             }
             break;
     }
 }
            <div style="position: relative;">
                <?php 
    if ($show_edit) {
        ?>
                    <?php 
        if ($action->isCustomSetAction() && in_array(\thebuggenie\core\entities\CustomDatatype::getByKey($action->getCustomActionType())->getType(), array(\thebuggenie\core\entities\CustomDatatype::USER_CHOICE, \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE, \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE))) {
            ?>
                        <button id="workflowtransitionaction_<?php 
            echo $action->getID();
            ?>
_edit_button" class="dropper"><?php 
            echo __('Edit');
            ?>
</button>
                        <?php 
            switch (\thebuggenie\core\entities\CustomDatatype::getByKey($action->getCustomActionType())->getType()) {
                case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE:
                    echo include_component('main/identifiableselector', array('html_id' => 'workflowtransitionaction_' . $action->getID() . '_edit', 'header' => __('Select a user'), 'callback' => "TBG.Config.Workflows.Transition.Actions.update('" . make_url('configure_workflow_transition_update_action', array('workflow_id' => $action->getWorkflow()->getID(), 'transition_id' => $action->getTransition()->getID(), 'action_id' => $action->getID())) . "?target_value=%identifiable_value', '" . $action->getID() . "')", 'clear_link_text' => __('Clear currently selected user'), 'base_id' => 'workflowtransitionaction_' . $action->getID(), 'include_users' => true, 'include_teams' => false, 'include_clients' => false, 'absolute' => true, 'hidden' => false, 'classes' => 'leftie popup_box more_actions_dropdown'));
                    break;
                case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE:
                    echo include_component('main/identifiableselector', array('html_id' => 'workflowtransitionaction_' . $action->getID() . '_edit', 'header' => __('Select a team'), 'callback' => "TBG.Config.Workflows.Transition.Actions.update('" . make_url('configure_workflow_transition_update_action', array('workflow_id' => $action->getWorkflow()->getID(), 'transition_id' => $action->getTransition()->getID(), 'action_id' => $action->getID())) . "?target_value=%identifiable_value', '" . $action->getID() . "')", 'clear_link_text' => __('Clear currently selected team'), 'base_id' => 'workflowtransitionaction_' . $action->getID(), 'include_users' => false, 'include_teams' => true, 'include_clients' => false, 'absolute' => true, 'hidden' => false, 'classes' => 'leftie popup_box more_actions_dropdown'));
                    break;
                case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE:
                    echo include_component('main/identifiableselector', array('html_id' => 'workflowtransitionaction_' . $action->getID() . '_edit', 'header' => __('Select a client'), 'callback' => "TBG.Config.Workflows.Transition.Actions.update('" . make_url('configure_workflow_transition_update_action', array('workflow_id' => $action->getWorkflow()->getID(), 'transition_id' => $action->getTransition()->getID(), 'action_id' => $action->getID())) . "?target_value=%identifiable_value', '" . $action->getID() . "')", 'clear_link_text' => __('Clear currently selected client'), 'base_id' => 'workflowtransitionaction_' . $action->getID(), 'include_users' => false, 'include_teams' => false, 'include_clients' => true, 'absolute' => true, 'hidden' => false, 'classes' => 'leftie popup_box more_actions_dropdown'));
                    break;
            }
            ?>
                    <?php 
        } else {
            ?>
                        <button id="workflowtransitionaction_<?php 
 /**
  * Returns the custom field object used in the validation rule
  *
  * @return CustomDatatype
  */
 public function getCustomField()
 {
     return CustomDatatype::getByKey($this->getCustomFieldname());
 }
"><?php 
        echo $severity->getName();
        ?>
</option>
                                <?php 
    }
    ?>
                            </select>
                            <a href="javascript:void(0);" class="img" onclick="$('severity_link').show();$('severity_additional_div').hide();$('severity_id_additional').setValue(0);"><?php 
    echo image_tag('undo.png', array('style' => 'float: none; margin-left: 5px;'));
    ?>
</a>
                        </div>
                    </li>
                    <?php 
    foreach (\thebuggenie\core\entities\CustomDatatype::getAll() as $customdatatype) {
        ?>
                        <li id="<?php 
        echo $customdatatype->getKey();
        ?>
_additional" style="display: none;">
                            <?php 
        echo image_tag('icon_customdatatype.png');
        ?>
                            <div id="<?php 
        echo $customdatatype->getKey();
        ?>
_link"<?php 
        if ($selected_customdatatype[$customdatatype->getKey()] !== null) {
            ?>
 style="display: none;"<?php 
Example #7
0
 public function componentIssueTypeSchemeOptions()
 {
     $this->issuetype = entities\Issuetype::getB2DBTable()->selectById($this->id);
     $this->scheme = entities\IssuetypeScheme::getB2DBTable()->selectById($this->scheme_id);
     $this->builtinfields = entities\Datatype::getAvailableFields(true);
     $this->customtypes = entities\CustomDatatype::getAll();
     $this->visiblefields = $this->scheme->getVisibleFieldsForIssuetype($this->issuetype);
 }
Example #8
0
 protected static function _cacheAvailablePermissions()
 {
     if (self::$_available_permissions === null) {
         $i18n = self::getI18n();
         self::$_available_permissions = array('user' => array(), 'general' => array(), 'project' => array());
         self::$_available_permissions['user']['canseeallissues'] = array('description' => $i18n->__('Can see issues reported by other users'), 'mode' => 'permissive');
         self::$_available_permissions['user']['canseegroupissues'] = array('description' => $i18n->__('Can see issues reported by users in the same group'), 'mode' => 'permissive');
         self::$_available_permissions['configuration']['cansaveconfig'] = array('description' => $i18n->__('Can access the configuration page and edit all configuration'), 'details' => array());
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Settings" configuration page'), 'target_id' => 12));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Settings" configuration page'), 'target_id' => 12));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Permissions" configuration page'), 'target_id' => 5));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Permissions" configuration page'), 'target_id' => 5));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Uploads" configuration page'), 'target_id' => 3));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Uploads" configuration page'), 'target_id' => 3));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Scopes" configuration page'), 'target_id' => 14));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Scopes" configuration page'), 'target_id' => 14));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Import" configuration page'), 'target_id' => 16));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Import" configuration page'), 'target_id' => 16));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Projects" configuration page'), 'target_id' => 10));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Projects" configuration page'), 'target_id' => 10));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Issue types" configuration page'), 'target_id' => 6));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Issue types" configuration page'), 'target_id' => 6));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Issue fields" configuration page'), 'target_id' => 4));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Issue fields" configuration page'), 'target_id' => 4));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Users, teams and groups" configuration page'), 'target_id' => 2));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Users, teams and groups" configuration page'), 'target_id' => 2));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Modules" and any module configuration page'), 'target_id' => 15));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Modules" configuration page and any modules'), 'target_id' => 15));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('canviewconfig' => array('description' => $i18n->__('Read-only access: "Themes" configuration page and any themes'), 'target_id' => 19));
         self::$_available_permissions['configuration']['cansaveconfig']['details'][] = array('cansaveconfig' => array('description' => $i18n->__('Read + write access: "Themes" configuration page and any themes'), 'target_id' => 19));
         self::$_available_permissions['general']['canfindissuesandsavesearches'] = array('description' => $i18n->__('Can search for issues and create saved searches'), 'details' => array());
         self::$_available_permissions['general']['canfindissuesandsavesearches']['details']['canfindissues'] = array('description' => $i18n->__('Can search for issues'));
         self::$_available_permissions['general']['canfindissuesandsavesearches']['details']['cancreatepublicsearches'] = array('description' => $i18n->__('Can create saved searches that are public'));
         self::$_available_permissions['general']['caneditmainmenu'] = array('description' => $i18n->__('Can edit main menu'));
         self::$_available_permissions['pages']['page_home_access'] = array('description' => $i18n->__('Can access the frontpage'));
         self::$_available_permissions['pages']['page_dashboard_access'] = array('description' => $i18n->__('Can access the user dashboard'));
         self::$_available_permissions['pages']['page_search_access'] = array('description' => $i18n->__('Can access the search page'));
         self::$_available_permissions['pages']['page_about_access'] = array('description' => $i18n->__('Can access the "About" page'));
         self::$_available_permissions['pages']['page_account_access'] = array('description' => $i18n->__('Can access the "My account" page'), 'details' => array());
         self::$_available_permissions['pages']['page_account_access']['details']['canchangepassword'] = array('description' => $i18n->__('Can change own password'), 'mode' => 'permissive');
         self::$_available_permissions['pages']['page_teamlist_access'] = array('description' => $i18n->__('Can see list of teams in header menu'));
         self::$_available_permissions['pages']['page_clientlist_access'] = array('description' => $i18n->__('Can access all clients'));
         self::$_available_permissions['project_pages']['page_project_allpages_access'] = array('description' => $i18n->__('Can access all project pages'), 'details' => array());
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_dashboard_access'] = array('description' => $i18n->__('Can access the project dashboard'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_planning_access'] = array('description' => $i18n->__('Can access the project planning page'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_scrum_access'] = array('description' => $i18n->__('Can access the project scrum page'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_issues_access'] = array('description' => $i18n->__('Can access the project issues search page'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_roadmap_access'] = array('description' => $i18n->__('Can access the project roadmap page'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_team_access'] = array('description' => $i18n->__('Can access the project team page'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_statistics_access'] = array('description' => $i18n->__('Can access the project statistics page'));
         self::$_available_permissions['project_pages']['page_project_allpages_access']['details']['page_project_timeline_access'] = array('description' => $i18n->__('Can access the project timeline page'));
         self::$_available_permissions['project']['canseeproject'] = array('description' => $i18n->__('Can see that project exists'));
         self::$_available_permissions['project']['canseeprojecthierarchy'] = array('description' => $i18n->__('Can see complete project hierarchy'));
         self::$_available_permissions['project']['canseeprojecthierarchy']['details']['canseeallprojecteditions'] = array('description' => $i18n->__('Can see all editions'));
         self::$_available_permissions['project']['canseeprojecthierarchy']['details']['canseeallprojectcomponents'] = array('description' => $i18n->__('Can see all components'));
         self::$_available_permissions['project']['canseeprojecthierarchy']['details']['canseeallprojectbuilds'] = array('description' => $i18n->__('Can see all releases'));
         self::$_available_permissions['project']['canseeprojecthierarchy']['details']['canseeallprojectmilestones'] = array('description' => $i18n->__('Can see all milestones'));
         self::$_available_permissions['project']['candoscrumplanning'] = array('description' => $i18n->__('Can manage stories, tasks, sprints and backlog on the project planning page'), 'details' => array());
         self::$_available_permissions['project']['candoscrumplanning']['details']['canaddscrumsprints'] = array('description' => $i18n->__('Can add milestones/sprints on the project planning page'));
         self::$_available_permissions['project']['candoscrumplanning']['details']['canassignscrumuserstoriestosprints'] = array('description' => $i18n->__('Can (re-)assign issues/tasks/stories to milestones/sprints/backlog on the project planning page'));
         self::$_available_permissions['project']['canmanageproject'] = array('description' => $i18n->__('Can manage project'));
         self::$_available_permissions['project']['canmanageproject']['details']['canmanageprojectreleases'] = array('description' => $i18n->__('Can manage project releases and components'));
         self::$_available_permissions['project']['canmanageproject']['details']['caneditprojectdetails'] = array('description' => $i18n->__('Can edit project details and settings'));
         self::$_available_permissions['edition']['canseeedition'] = array('description' => $i18n->__('Can see this edition'));
         self::$_available_permissions['component']['canseecomponent'] = array('description' => $i18n->__('Can see this component'));
         self::$_available_permissions['build']['canseebuild'] = array('description' => $i18n->__('Can see this release'));
         self::$_available_permissions['milestone']['canseemilestone'] = array('description' => $i18n->__('Can see this milestone'));
         self::$_available_permissions['issues']['canvoteforissues'] = array('description' => $i18n->__('Can vote for issues'));
         self::$_available_permissions['issues']['canlockandeditlockedissues'] = array('description' => $i18n->__('Can toggle issue access between restricted and public'));
         self::$_available_permissions['issues']['cancreateandeditissues'] = array('description' => $i18n->__('Can create issues, edit basic information on issues reported by the user and close/re-open them'), 'details' => array());
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['cancreateissues'] = array('description' => $i18n->__('Can create new issues'), 'details' => array());
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['caneditissuebasicown'] = array('description' => $i18n->__('Can edit title and description on issues reported by the user'), 'details' => array());
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['caneditissuebasicown']['details']['caneditissuetitleown'] = array('description' => $i18n->__('Can edit issue title on issues reported by the user'));
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['caneditissuebasicown']['details']['caneditissuedescriptionown'] = array('description' => $i18n->__('Can edit issue description on issues reported by the user'));
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['caneditissuebasicown']['details']['caneditissuereproduction_stepsown'] = array('description' => $i18n->__('Can edit steps to reproduce on issues reported by the user'));
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['canclosereopenissuesown'] = array('description' => $i18n->__('Can close and reopen issues reported by the user'), 'details' => array());
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['canclosereopenissuesown']['details']['cancloseissuesown'] = array('description' => $i18n->__('Can close issues reported by the user'));
         self::$_available_permissions['issues']['cancreateandeditissues']['details']['canclosereopenissuesown']['details']['canreopenissuesown'] = array('description' => $i18n->__('Can re-open issues reported by the user'));
         self::$_available_permissions['issues']['caneditissue'] = array('description' => $i18n->__('Can delete, close, reopen and update any issue details and progress'), 'details' => array());
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuebasic'] = array('description' => $i18n->__('Can edit title and description on any issues'), 'details' => array());
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuebasic']['details']['caneditissuetitle'] = array('description' => $i18n->__('Can edit any issue title'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuebasic']['details']['caneditissuedescription'] = array('description' => $i18n->__('Can edit any issue description'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuebasic']['details']['caneditissuereproduction_steps'] = array('description' => $i18n->__('Can edit any issue steps to reproduce'));
         self::$_available_permissions['issues']['caneditissue']['details']['candeleteissues'] = array('description' => $i18n->__('Can delete issues'));
         self::$_available_permissions['issues']['caneditissue']['details']['canclosereopenissues'] = array('description' => $i18n->__('Can close any issues'));
         self::$_available_permissions['issues']['caneditissue']['details']['canclosereopenissues']['details']['cancloseissues'] = array('description' => $i18n->__('Can close any issues'));
         self::$_available_permissions['issues']['caneditissue']['details']['canclosereopenissues']['details']['canreopenissues'] = array('description' => $i18n->__('Can re-open any issues'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissueposted_by'] = array('description' => $i18n->__('Can edit issue posted by'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissueowned_by'] = array('description' => $i18n->__('Can edit issue owned by'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissueassigned_to'] = array('description' => $i18n->__('Can edit issue assigned_to'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuestatus'] = array('description' => $i18n->__('Can edit issue status'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuecategory'] = array('description' => $i18n->__('Can edit issue category'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuepriority'] = array('description' => $i18n->__('Can edit issue priority'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissueseverity'] = array('description' => $i18n->__('Can edit issue severity'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuereproducability'] = array('description' => $i18n->__('Can edit issue reproducability'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissueresolution'] = array('description' => $i18n->__('Can edit issue resolution'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissueestimated_time'] = array('description' => $i18n->__('Can estimate issues'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuespent_time'] = array('description' => $i18n->__('Can spend time working on issues'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuepercent_complete'] = array('description' => $i18n->__('Can edit issue percent complete'));
         self::$_available_permissions['issues']['caneditissue']['details']['caneditissuemilestone'] = array('description' => $i18n->__('Can set issue milestone'));
         self::$_available_permissions['issues']['caneditissuecustomfieldsown'] = array('description' => $i18n->__('Can change custom field values for issues reported by the user'), 'details' => array());
         self::$_available_permissions['issues']['caneditissuecustomfields'] = array('description' => $i18n->__('Can change custom field values for any issues'), 'details' => array());
         foreach (\thebuggenie\core\entities\CustomDatatype::getAll() as $cdf) {
             self::$_available_permissions['issues']['caneditissuecustomfieldsown']['details']['caneditissuecustomfields' . $cdf->getKey() . 'own'] = array('description' => $i18n->__('Can change custom field "%field_name" for issues reported by the user', array('%field_name' => $i18n->__($cdf->getDescription()))));
             self::$_available_permissions['issues']['caneditissuecustomfields']['details']['caneditissuecustomfields' . $cdf->getKey()] = array('description' => $i18n->__('Can change custom field "%field_name" for any issues', array('%field_name' => $i18n->__($cdf->getDescription()))));
             // Set permissions for custom option types
             if ($cdf->hasCustomOptions()) {
                 $options = $cdf->getOptions();
                 foreach ($options as $option) {
                     self::$_available_permissions['issues']['set_datatype_' . $option->getID()] = array('description' => $i18n->__('Can change issue field to "%option_name" for issues reported by the user', array('%option_name' => $i18n->__($option->getValue()))));
                 }
                 //endforeach
             }
             //endif
         }
         foreach (\thebuggenie\core\entities\Datatype::getTypes() as $type => $class) {
             self::$_available_permissions['issues']['set_datatype_' . $type] = array('description' => $i18n->__('Can change issue field "%type_name" for issues reported by the user', array('%type_name' => $i18n->__($type))));
         }
         self::$_available_permissions['issues']['canaddextrainformationtoissues'] = array('description' => $i18n->__('Can add/remove extra information and link issues (edition, component, release, links and files) to issues'), 'details' => array());
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddbuildsown'] = array('description' => $i18n->__('Can add releases / versions to list of affected versions for issues reported by the user'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddbuilds'] = array('description' => $i18n->__('Can add releases / versions to list of affected versions for any issues'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddcomponentsown'] = array('description' => $i18n->__('Can add components to list of affected components for issues reported by the user'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddcomponents'] = array('description' => $i18n->__('Can add components to list of affected components for any issues'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddeditionsown'] = array('description' => $i18n->__('Can add editions to list of affected editions for issues reported by the user'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddeditions'] = array('description' => $i18n->__('Can add editions to list of affected editions for any issues'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddlinkstoissuesown'] = array('description' => $i18n->__('Can add links to issues reported by the user'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddlinkstoissues'] = array('description' => $i18n->__('Can add links to any issues'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddfilestoissuesown'] = array('description' => $i18n->__('Can add files to and remove own files from issues reported by the user'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddfilestoissues'] = array('description' => $i18n->__('Can add files to and remove own files from any issues'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canremovefilesfromissuesown'] = array('description' => $i18n->__('Can remove any attachments from issues reported by the user'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canremovefilesfromissues'] = array('description' => $i18n->__('Can remove any attachments from any issues'));
         self::$_available_permissions['issues']['canaddextrainformationtoissues']['details']['canaddrelatedissues'] = array('description' => $i18n->__('Can add related issues to other issues'));
         self::$_available_permissions['issues']['canpostandeditcomments'] = array('description' => $i18n->__('Can see public comments, post new, edit own and delete own comments'), 'details' => array());
         self::$_available_permissions['issues']['canpostandeditcomments']['details']['canviewcomments'] = array('description' => $i18n->__('Can see public comments'));
         self::$_available_permissions['issues']['canpostandeditcomments']['details']['canpostcomments'] = array('description' => $i18n->__('Can post comments'));
         self::$_available_permissions['issues']['canpostandeditcomments']['details']['caneditcommentsown'] = array('description' => $i18n->__('Can edit own comments'));
         self::$_available_permissions['issues']['canpostandeditcomments']['details']['candeletecommentsown'] = array('description' => $i18n->__('Can delete own comments'));
         self::$_available_permissions['issues']['canpostseeandeditallcomments'] = array('description' => $i18n->__('Can see all comments (including non-public), post new, edit and delete all comments'), 'details' => array());
         self::$_available_permissions['issues']['canpostseeandeditallcomments']['details']['canseenonpubliccomments'] = array('description' => $i18n->__('Can see all comments including hidden'));
         self::$_available_permissions['issues']['canpostseeandeditallcomments']['details']['caneditcomments'] = array('description' => $i18n->__('Can edit all comments'));
         self::$_available_permissions['issues']['canpostseeandeditallcomments']['details']['candeletecomments'] = array('description' => $i18n->__('Can delete any comments'));
         //self::trigger('core', 'cachepermissions', array('permissions' => &self::$_available_permissions));
     }
 }
Example #9
0
 public function hasExclusiveValues()
 {
     $this->_populateCustomtype();
     return in_array($this->_customtype->getType(), array(CustomDatatype::RADIO_CHOICE, CustomDatatype::COMPONENTS_CHOICE, CustomDatatype::EDITIONS_CHOICE, CustomDatatype::RELEASES_CHOICE, CustomDatatype::STATUS_CHOICE));
 }
Example #10
0
 protected function _processChanges()
 {
     $related_issues_to_save = array();
     $changed_properties = $this->_getChangedProperties();
     if (count($changed_properties)) {
         $is_saved_estimated = false;
         $is_saved_spent = false;
         $is_saved_assignee = false;
         $is_saved_owner = false;
         foreach ($changed_properties as $property => $value) {
             $compare_value = is_object($this->{$property}) ? $this->{$property}->getID() : $this->{$property};
             $original_value = $value['original_value'];
             if ($original_value != $compare_value) {
                 switch ($property) {
                     case '_title':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_TITLE, framework\Context::getI18n()->__("Title updated"), $original_value, $compare_value);
                         break;
                     case '_shortname':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_SHORTNAME, framework\Context::getI18n()->__("Issue label updated"), $original_value, $compare_value);
                         break;
                     case '_description':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_DESCRIPTION, framework\Context::getI18n()->__("Description updated"), $original_value, $compare_value);
                         break;
                     case '_reproduction_steps':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_REPRODUCTIONSTEPS, framework\Context::getI18n()->__("Reproduction steps updated"), $original_value, $compare_value);
                         break;
                     case '_category':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getCategory() instanceof Datatype ? $this->getCategory()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_CATEGORY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_bug_type':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_bug_type', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_bug_type', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_BUG_TYPE, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_effect':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_effect', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_effect', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_EFFECT, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_likelihood':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_likelihood', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_likelihood', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_LIKELIHOOD, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_user_pain':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_CALCULATED, $original_value . ' &rArr; ' . $value['current_value']);
                         break;
                     case '_status':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getStatus() instanceof Datatype ? $this->getStatus()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_STATUS, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_reproducability':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Reproducability::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getReproducability() instanceof Datatype ? $this->getReproducability()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_REPRODUCABILITY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_priority':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Priority::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getPriority() instanceof Datatype ? $this->getPriority()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PRIORITY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_assignee_team':
                     case '_assignee_user':
                         if (!$is_saved_assignee) {
                             $new_name = $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->getName() : framework\Context::getI18n()->__('Not assigned');
                             if ($this->getAssignee() instanceof \thebuggenie\core\entities\User) {
                                 $this->startWorkingOnIssue($this->getAssignee());
                             }
                             $this->addLogEntry(tables\Log::LOG_ISSUE_ASSIGNED, $new_name);
                             $is_saved_assignee = true;
                         }
                         break;
                     case '_posted_by':
                         $old_identifiable = $original_value ? \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value) : framework\Context::getI18n()->__('Unknown');
                         $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown');
                         $new_name = $this->getPostedBy()->getName();
                         $this->addLogEntry(tables\Log::LOG_ISSUE_POSTED, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_being_worked_on_by_user':
                         if ($original_value != 0) {
                             $old_identifiable = \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value);
                             $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not being worked on');
                         }
                         $new_name = $this->getUserWorkingOnIssue() instanceof \thebuggenie\core\entities\User ? $this->getUserWorkingOnIssue()->getName() : framework\Context::getI18n()->__('Not being worked on');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_USERS, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_owner_team':
                     case '_owner_user':
                         if (!$is_saved_owner) {
                             $new_name = $this->getOwner() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getOwner()->getName() : framework\Context::getI18n()->__('Not owned by anyone');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_OWNED, $new_name);
                             $is_saved_owner = true;
                         }
                         break;
                     case '_percent_complete':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PERCENT, $original_value . '% &rArr; ' . $this->getPercentCompleted() . '', $original_value, $compare_value);
                         break;
                     case '_resolution':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Resolution::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getResolution() instanceof Datatype ? $this->getResolution()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_RESOLUTION, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_severity':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Severity::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getSeverity() instanceof Datatype ? $this->getSeverity()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_SEVERITY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_milestone':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getMilestone() instanceof \thebuggenie\core\entities\Milestone ? $this->getMilestone()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_MILESTONE, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         $this->_milestone_order = 0;
                         break;
                     case '_issuetype':
                         if ($original_value != 0) {
                             $old_name = ($old_item = Issuetype::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Unknown');
                         }
                         $new_name = $this->getIssuetype() instanceof \thebuggenie\core\entities\Issuetype ? $this->getIssuetype()->getName() : framework\Context::getI18n()->__('Unknown');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_ISSUETYPE, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_estimated_months':
                     case '_estimated_weeks':
                     case '_estimated_days':
                     case '_estimated_hours':
                     case '_estimated_points':
                         if (!$is_saved_estimated) {
                             $old_time = array('months' => $this->getChangedPropertyOriginal('_estimated_months'), 'weeks' => $this->getChangedPropertyOriginal('_estimated_weeks'), 'days' => $this->getChangedPropertyOriginal('_estimated_days'), 'hours' => $this->getChangedPropertyOriginal('_estimated_hours'), 'points' => $this->getChangedPropertyOriginal('_estimated_points'));
                             $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('Not estimated');
                             $new_formatted_time = $this->hasEstimatedTime() ? Issue::getFormattedTime($this->getEstimatedTime()) : framework\Context::getI18n()->__('Not estimated');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_ESTIMATED, $old_formatted_time . ' &rArr; ' . $new_formatted_time, serialize($old_time), serialize($this->getEstimatedTime()));
                             $is_saved_estimated = true;
                         }
                         break;
                     case '_spent_months':
                     case '_spent_weeks':
                     case '_spent_days':
                     case '_spent_hours':
                     case '_spent_points':
                         if (!$is_saved_spent) {
                             $old_time = array('months' => $this->getChangedPropertyOriginal('_spent_months'), 'weeks' => $this->getChangedPropertyOriginal('_spent_weeks'), 'days' => $this->getChangedPropertyOriginal('_spent_days'), 'hours' => round($this->getChangedPropertyOriginal('_spent_hours') / 100, 2), 'points' => $this->getChangedPropertyOriginal('_spent_points'));
                             $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('No time spent');
                             $new_formatted_time = $this->hasSpentTime() ? Issue::getFormattedTime($this->getSpentTime()) : framework\Context::getI18n()->__('No time spent');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_SPENT, $old_formatted_time . ' &rArr; ' . $new_formatted_time, serialize($old_time), serialize($this->getSpentTime()));
                             $is_saved_spent = true;
                         }
                         break;
                     case '_state':
                         if ($this->isClosed()) {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_CLOSE);
                             if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) {
                                 if ($this->getMilestone()->isSprint()) {
                                     if (!$this->getIssueType()->isTask()) {
                                         $this->setSpentPoints($this->getEstimatedPoints());
                                     } else {
                                         if ($this->getSpentHours() < $this->getEstimatedHours()) {
                                             $this->setSpentHours($this->getEstimatedHours());
                                         }
                                         foreach ($this->getParentIssues() as $parent_issue) {
                                             if ($parent_issue->checkTaskStates()) {
                                                 $related_issues_to_save[$parent_issue->getID()] = true;
                                             }
                                         }
                                     }
                                 }
                                 $this->getMilestone()->updateStatus();
                                 $this->getMilestone()->save();
                             }
                         } else {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_REOPEN);
                         }
                         break;
                     case '_blocking':
                         if ($this->isBlocking()) {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_BLOCKED);
                         } else {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_UNBLOCKED);
                         }
                         break;
                     default:
                         if (mb_substr($property, 0, 12) == '_customfield') {
                             $key = mb_substr($property, 12);
                             $customdatatype = CustomDatatype::getByKey($key);
                             switch ($customdatatype->getType()) {
                                 case CustomDatatype::INPUT_TEXT:
                                     $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value);
                                     break;
                                 case CustomDatatype::INPUT_TEXTAREA_SMALL:
                                 case CustomDatatype::INPUT_TEXTAREA_MAIN:
                                     $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value);
                                     break;
                                 case CustomDatatype::EDITIONS_CHOICE:
                                 case CustomDatatype::COMPONENTS_CHOICE:
                                 case CustomDatatype::RELEASES_CHOICE:
                                 case CustomDatatype::MILESTONE_CHOICE:
                                 case CustomDatatype::STATUS_CHOICE:
                                 case CustomDatatype::TEAM_CHOICE:
                                 case CustomDatatype::USER_CHOICE:
                                 case CustomDatatype::CLIENT_CHOICE:
                                     $old_object = null;
                                     $new_object = null;
                                     try {
                                         switch ($customdatatype->getType()) {
                                             case CustomDatatype::EDITIONS_CHOICE:
                                                 $old_object = Edition::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::COMPONENTS_CHOICE:
                                                 $old_object = Component::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::RELEASES_CHOICE:
                                                 $old_object = Build::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::MILESTONE_CHOICE:
                                                 $old_object = Milestone::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::STATUS_CHOICE:
                                                 $old_object = Status::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::TEAM_CHOICE:
                                                 $old_object = Team::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::USER_CHOICE:
                                                 $old_object = User::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::CLIENT_CHOICE:
                                                 $old_object = Client::getB2DBTable()->selectById($original_value);
                                                 break;
                                         }
                                     } catch (\Exception $e) {
                                     }
                                     try {
                                         switch ($customdatatype->getType()) {
                                             case CustomDatatype::EDITIONS_CHOICE:
                                             case CustomDatatype::COMPONENTS_CHOICE:
                                             case CustomDatatype::RELEASES_CHOICE:
                                             case CustomDatatype::MILESTONE_CHOICE:
                                             case CustomDatatype::STATUS_CHOICE:
                                             case CustomDatatype::TEAM_CHOICE:
                                             case CustomDatatype::USER_CHOICE:
                                             case CustomDatatype::CLIENT_CHOICE:
                                                 $new_object = $this->getCustomField($key);
                                                 break;
                                         }
                                     } catch (\Exception $e) {
                                     }
                                     $old_value = is_object($old_object) ? $old_object->getName() : framework\Context::getI18n()->__('Unknown');
                                     $new_value = is_object($new_object) ? $new_object->getName() : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' &rArr; ' . $new_value, $original_value, $compare_value);
                                     break;
                                 default:
                                     $old_item = null;
                                     try {
                                         $old_item = $original_value ? new CustomDatatypeOption($original_value) : null;
                                     } catch (\Exception $e) {
                                     }
                                     $old_value = $old_item instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                                     $new_value = $this->getCustomField($key) instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $this->getCustomField($key)->getName() : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' &rArr; ' . $new_value, $original_value, $compare_value);
                                     break;
                             }
                         }
                         break;
                 }
             }
         }
         if ($is_saved_estimated) {
             tables\IssueEstimates::getTable()->saveEstimate($this->getID(), $this->_estimated_months, $this->_estimated_weeks, $this->_estimated_days, $this->_estimated_hours, $this->_estimated_points);
         }
     }
     return $related_issues_to_save;
 }
Example #11
0
 /**
  * Reverts an issue field back to the original value
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runIssueRevertField(framework\Request $request)
 {
     if ($issue_id = $request['issue_id']) {
         try {
             $issue = entities\Issue::getB2DBTable()->selectById($issue_id);
         } catch (\Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderText('fail');
         }
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderText('no issue');
     }
     $field = null;
     framework\Context::loadLibrary('common');
     switch ($request['field']) {
         case 'description':
             $issue->revertDescription();
             $issue->revertDescription_Syntax();
             $field = array('id' => (int) ($issue->getDescription() != ''), 'name' => $issue->getParsedDescription(array('issue' => $issue)), 'form_value' => $issue->getDescription());
             break;
         case 'reproduction_steps':
             $issue->revertReproduction_Steps();
             $issue->revertReproduction_Steps_Syntax();
             $field = array('id' => (int) ($issue->getReproductionSteps() != ''), 'name' => $issue->getParsedReproductionSteps(array('issue' => $issue)), 'form_value' => $issue->getReproductionSteps());
             break;
         case 'title':
             $issue->revertTitle();
             $field = array('id' => 1, 'name' => strip_tags($issue->getTitle()));
             break;
         case 'shortname':
             $issue->revertShortname();
             $field = array('id' => 1, 'name' => strip_tags($issue->getShortname()));
             break;
         case 'category':
             $issue->revertCategory();
             $field = $issue->getCategory() instanceof entities\Category ? array('id' => $issue->getCategory()->getID(), 'name' => $issue->getCategory()->getName()) : array('id' => 0);
             break;
         case 'resolution':
             $issue->revertResolution();
             $field = $issue->getResolution() instanceof entities\Resolution ? array('id' => $issue->getResolution()->getID(), 'name' => $issue->getResolution()->getName()) : array('id' => 0);
             break;
         case 'severity':
             $issue->revertSeverity();
             $field = $issue->getSeverity() instanceof entities\Severity ? array('id' => $issue->getSeverity()->getID(), 'name' => $issue->getSeverity()->getName()) : array('id' => 0);
             break;
         case 'reproducability':
             $issue->revertReproducability();
             $field = $issue->getReproducability() instanceof entities\Reproducability ? array('id' => $issue->getReproducability()->getID(), 'name' => $issue->getReproducability()->getName()) : array('id' => 0);
             break;
         case 'priority':
             $issue->revertPriority();
             $field = $issue->getPriority() instanceof entities\Priority ? array('id' => $issue->getPriority()->getID(), 'name' => $issue->getPriority()->getName()) : array('id' => 0);
             break;
         case 'percent_complete':
             $issue->revertPercentCompleted();
             $field = $issue->getPercentCompleted();
             break;
         case 'status':
             $issue->revertStatus();
             $field = $issue->getStatus() instanceof entities\Status ? array('id' => $issue->getStatus()->getID(), 'name' => $issue->getStatus()->getName(), 'color' => $issue->getStatus()->getColor()) : array('id' => 0);
             break;
         case 'pain_bug_type':
             $issue->revertPainBugType();
             $field = $issue->hasPainBugType() ? array('id' => $issue->getPainBugType(), 'name' => $issue->getPainBugTypeLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain());
             break;
         case 'pain_likelihood':
             $issue->revertPainLikelihood();
             $field = $issue->hasPainLikelihood() ? array('id' => $issue->getPainLikelihood(), 'name' => $issue->getPainLikelihoodLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain());
             break;
         case 'pain_effect':
             $issue->revertPainEffect();
             $field = $issue->hasPainEffect() ? array('id' => $issue->getPainEffect(), 'name' => $issue->getPainEffectLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain());
             break;
         case 'issuetype':
             $issue->revertIssuetype();
             $field = $issue->getIssuetype() instanceof entities\Issuetype ? array('id' => $issue->getIssuetype()->getID(), 'name' => $issue->getIssuetype()->getName(), 'src' => htmlspecialchars(framework\Context::getWebroot() . 'images/' . $issue->getIssuetype()->getIcon() . '_small.png')) : array('id' => 0);
             $visible_fields = $issue->getIssuetype() instanceof entities\Issuetype ? $issue->getProject()->getVisibleFieldsArray($issue->getIssuetype()->getID()) : array();
             return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $field, 'visible_fields' => $visible_fields));
             break;
         case 'milestone':
             $issue->revertMilestone();
             $field = $issue->getMilestone() instanceof entities\Milestone ? array('id' => $issue->getMilestone()->getID(), 'name' => $issue->getMilestone()->getName()) : array('id' => 0);
             break;
         case 'estimated_time':
             $issue->revertEstimatedTime();
             return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $issue->hasEstimatedTime() ? array('id' => 1, 'name' => entities\Issue::getFormattedTime($issue->getEstimatedTime(true, true))) : array('id' => 0), 'values' => $issue->getEstimatedTime(true, true), 'percentbar' => $this->getComponentHTML('main/percentbar', array('percent' => $issue->getEstimatedPercentCompleted(), 'height' => 3))));
             break;
         case 'spent_time':
             $issue->revertSpentTime();
             return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $issue->hasSpentTime() ? array('id' => 1, 'name' => entities\Issue::getFormattedTime($issue->getSpentTime(true, true))) : array('id' => 0), 'values' => $issue->getSpentTime(true, true)));
             break;
         case 'owned_by':
             $issue->revertOwner();
             return $this->renderJSON(array('changed' => $issue->isOwnerChanged(), 'field' => $issue->isOwned() ? array('id' => $issue->getOwner()->getID(), 'name' => $issue->getOwner() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getOwner())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getOwner()))) : array('id' => 0)));
             break;
         case 'assigned_to':
             $issue->revertAssignee();
             return $this->renderJSON(array('changed' => $issue->isAssigneeChanged(), 'field' => $issue->isAssigned() ? array('id' => $issue->getAssignee()->getID(), 'name' => $issue->getAssignee() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getAssignee())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getAssignee()))) : array('id' => 0)));
             break;
         case 'posted_by':
             $issue->revertPostedBy();
             return $this->renderJSON(array('changed' => $issue->isPostedByChanged(), 'field' => array('id' => $issue->getPostedByID(), 'name' => $this->getComponentHTML('main/userdropdown', array('user' => $issue->getPostedBy())))));
             break;
         default:
             if ($customdatatype = entities\CustomDatatype::getByKey($request['field'])) {
                 $key = $customdatatype->getKey();
                 $revert_methodname = "revertCustomfield{$key}";
                 $issue->{$revert_methodname}();
                 if ($customdatatype->hasCustomOptions()) {
                     $field = $issue->getCustomField($key) instanceof entities\CustomDatatypeOption ? array('value' => $issue->getCustomField($key)->getID(), 'name' => $issue->getCustomField($key)->getName()) : array('id' => 0);
                 } else {
                     switch ($customdatatype->getType()) {
                         case entities\CustomDatatype::INPUT_TEXTAREA_MAIN:
                         case entities\CustomDatatype::INPUT_TEXTAREA_SMALL:
                             $field = $issue->getCustomField($key) != '' ? array('value' => $key, 'name' => tbg_parse_text($issue->getCustomField($key))) : array('id' => 0);
                             break;
                         default:
                             $field = $issue->getCustomField($key) != '' ? array('value' => $key, 'name' => $issue->getCustomField($key)) : array('id' => 0);
                             break;
                     }
                 }
             }
             break;
     }
     if ($field !== null) {
         return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $field));
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('No valid field specified (%field)', array('%field' => $request['field']))));
     }
 }
    }
    ?>
">
            <?php 
    if ($swimlane->getBoard()->hasIssueFieldValues()) {
        ?>
                <?php 
        foreach ($issue_custom_fields_of_type as $key => $value) {
            ?>
                    <?php 
            if (!$swimlane->getBoard()->hasIssueFieldValue($key)) {
                continue;
            }
            ?>
                    <div class="issue_component issue_date" title="<?php 
            echo \thebuggenie\core\entities\CustomDatatype::getByKey($key)->getDescription();
            ?>
"><?php 
            echo tbg_formattime($value, 14);
            ?>
</div>
                <?php 
        }
        ?>
            <?php 
    }
    ?>
        </div>
    <?php 
}
?>
Example #13
0
 public function runAddFilter(framework\Request $request)
 {
     if ($request['filter_name'] == 'project_id' && count(entities\Project::getAll()) == 0) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('No projects exist so this filter can not be added')));
     } elseif (in_array($request['filter_name'], entities\SearchFilter::getValidSearchFilters()) || entities\CustomDatatype::doesKeyExist($request['filter_name'])) {
         return $this->renderJSON(array('content' => $this->getComponentHTML('search/filter', array('filter' => $request['filter_name'], 'key' => $request->getParameter('key', 0)))));
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('This is not a valid search field')));
     }
 }
 public function _migrateData(\b2db\Table $old_table)
 {
     switch ($old_table->getVersion()) {
         case 1:
             if ($res = $old_table->doSelectAll()) {
                 $customfields = \thebuggenie\core\entities\CustomDatatype::getB2DBTable()->selectAll();
                 while ($row = $res->getNextRow()) {
                     $customfield_id = $row->get(self::CUSTOMFIELDS_ID);
                     $customfield = array_key_exists($customfield_id, $customfields) ? $customfields[$customfield_id] : null;
                     if ($customfield instanceof \thebuggenie\core\entities\CustomDatatype && $customfield->hasCustomOptions()) {
                         $customfieldoption = CustomFieldOptions::getTable()->getByValueAndCustomfieldID((int) $row->get(self::OPTION_VALUE), $customfield->getID());
                         if ($customfieldoption instanceof \thebuggenie\core\entities\CustomDatatypeOption) {
                             $crit = $this->getCriteria();
                             $crit->addUpdate(self::CUSTOMFIELDOPTION_ID, $customfieldoption->getID());
                             $crit->addUpdate(self::OPTION_VALUE, null);
                             $this->doUpdateById($crit, $row->get(self::ID));
                         } elseif ($row->get(self::ID)) {
                             $this->doDeleteById($row->get(self::ID));
                         }
                     }
                 }
             }
             break;
     }
 }
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_POSTED:
     echo image_tag('icon_user.png');
     if ($item->hasChangeDetails()) {
         $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getNameWithUsername()) : __('Unknown') : __('Not determined');
         $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getNameWithUsername()) : __('Unknown') : __('Not determined');
         echo __("Posted by changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED:
     echo image_tag('icon_customdatatype.png');
     if ($item->hasChangeDetails()) {
         $key_data = explode(':', $item->getText());
         $key = $key_data[0];
         $customdatatype = \thebuggenie\core\entities\CustomDatatype::getByKey($key);
         if ($customdatatype instanceof \thebuggenie\core\entities\CustomDatatype) {
             $old_value = $item->getPreviousValue();
             $new_value = $item->getCurrentValue();
             switch ($customdatatype->getType()) {
                 case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXT:
                 case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_SMALL:
                 case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_MAIN:
                     break;
                 case \thebuggenie\core\entities\CustomDatatype::DATE_PICKER:
                     $old_value = $old_value != null ? date('Y-m-d', (int) $old_value) : \thebuggenie\core\framework\Context::getI18n()->__('Not determined');
                     $new_value = $new_value != null ? date('Y-m-d', (int) $new_value) : \thebuggenie\core\framework\Context::getI18n()->__('Not determined');
                     break;
                 case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
                 case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
                 case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
 protected static function _populateAvailableActions()
 {
     if (self::$_available_actions === null) {
         $initial_list = array('special' => array(), 'set' => array(), 'clear' => array());
         $i18n = framework\Context::getI18n();
         $initial_list['special'][self::ACTION_ASSIGN_ISSUE] = $i18n->__('Assign the issue to a user');
         $initial_list['special'][self::ACTION_ASSIGN_ISSUE_SELF] = $i18n->__('Assign the issue to the current user');
         $initial_list['special'][self::ACTION_CLEAR_DUPLICATE] = $i18n->__('Mark as not duplicate');
         $initial_list['special'][self::ACTION_SET_DUPLICATE] = $i18n->__('Possibly mark as duplicate');
         $initial_list['special'][self::ACTION_USER_START_WORKING] = $i18n->__('Start logging time');
         $initial_list['special'][self::ACTION_USER_STOP_WORKING] = $i18n->__('Stop logging time and optionally add time spent');
         $initial_list['clear'][self::ACTION_CLEAR_ASSIGNEE] = $i18n->__('Clear issue assignee');
         $initial_list['clear'][self::ACTION_CLEAR_PRIORITY] = $i18n->__('Clear issue priority');
         $initial_list['clear'][self::ACTION_CLEAR_PERCENT] = $i18n->__('Clear issue percent');
         $initial_list['clear'][self::ACTION_CLEAR_REPRODUCABILITY] = $i18n->__('Clear issue reproducability');
         $initial_list['clear'][self::ACTION_CLEAR_RESOLUTION] = $i18n->__('Clear issue resolution');
         $initial_list['clear'][self::ACTION_CLEAR_MILESTONE] = $i18n->__('Clear issue milestone');
         $initial_list['set'][self::ACTION_SET_PRIORITY] = $i18n->__('Set issue priority');
         $initial_list['set'][self::ACTION_SET_PERCENT] = $i18n->__('Set issue percent');
         $initial_list['set'][self::ACTION_SET_REPRODUCABILITY] = $i18n->__('Set issue reproducability');
         $initial_list['set'][self::ACTION_SET_RESOLUTION] = $i18n->__('Set issue resolution');
         $initial_list['set'][self::ACTION_SET_STATUS] = $i18n->__('Set issue status');
         $initial_list['set'][self::ACTION_SET_MILESTONE] = $i18n->__('Set issue milestone');
         foreach (CustomDatatype::getAll() as $key => $details) {
             $initial_list['clear'][self::CUSTOMFIELD_CLEAR_PREFIX . $key] = $i18n->__('Clear issue field %key', array('%key' => $key));
             $initial_list['set'][self::CUSTOMFIELD_SET_PREFIX . $key] = $i18n->__('Set issue field %key', array('%key' => $key));
         }
         $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionAction::getAvailableTransitionActions', null, array(), $initial_list);
         $event->trigger();
         self::$_available_actions = $event->getReturnList();
     }
 }
Example #17
0
 public function componentSearchbuilder()
 {
     $this->templates = entities\SavedSearch::getTemplates();
     $this->filters = $this->appliedfilters;
     $this->nondatecustomfields = entities\CustomDatatype::getAllExceptTypes(array(entities\CustomDatatype::DATE_PICKER));
     $this->datecustomfields = entities\CustomDatatype::getByFieldType(entities\CustomDatatype::DATE_PICKER);
     $i18n = framework\Context::getI18n();
     $columns = array('title' => $i18n->__('Issue title'), 'issuetype' => $i18n->__('Issue type'), 'assigned_to' => $i18n->__('Assigned to'), 'posted_by' => $i18n->__('Posted by'), 'status' => $i18n->__('Status'), 'resolution' => $i18n->__('Resolution'), 'category' => $i18n->__('Category'), 'severity' => $i18n->__('Severity'), 'percent_complete' => $i18n->__('Percent completed'), 'reproducability' => $i18n->__('Reproducability'), 'priority' => $i18n->__('Priority'), 'components' => $i18n->__('Component(s)'), 'milestone' => $i18n->__('Milestone'), 'estimated_time' => $i18n->__('Estimate'), 'spent_time' => $i18n->__('Time spent'), 'last_updated' => $i18n->__('Last updated time'), 'posted' => $i18n->__('Posted at'), 'comments' => $i18n->__('Number of comments'));
     foreach ($this->nondatecustomfields as $field) {
         $columns[$field->getKey()] = $i18n->__($field->getName());
     }
     foreach ($this->datecustomfields as $field) {
         $columns[$field->getKey()] = $i18n->__($field->getName());
     }
     $this->columns = $columns;
     $groupoptions = array();
     if (!framework\Context::isProjectContext()) {
         $groupoptions['project_id'] = $i18n->__('Project');
     }
     $groupoptions['milestone'] = $i18n->__('Milestone');
     $groupoptions['assignee'] = $i18n->__("Who's assigned");
     $groupoptions['posted_by'] = $i18n->__("Who posted the issue");
     $groupoptions['state'] = $i18n->__('State (open or closed)');
     $groupoptions['status'] = $i18n->__('Status');
     $groupoptions['category'] = $i18n->__('Category');
     $groupoptions['priority'] = $i18n->__('Priority');
     $groupoptions['severity'] = $i18n->__('Severity');
     $groupoptions['resolution'] = $i18n->__('Resolution');
     $groupoptions['issuetype'] = $i18n->__('Issue type');
     $groupoptions['edition'] = $i18n->__('Edition');
     $groupoptions['build'] = $i18n->__('Release');
     $groupoptions['component'] = $i18n->__('Component');
     $groupoptions['posted'] = $i18n->__('Posted at');
     $this->groupoptions = $groupoptions;
 }
Example #18
0
 /**
  *
  * @param \b2db\Criteria $crit
  * @param array|\thebuggenie\core\entities\SearchFilter $filters
  * @param \b2db\Criterion $ctn
  * @return null
  */
 public function addToCriteria($crit, $filters, $ctn = null)
 {
     $filter_key = $this->getFilterKey();
     if (in_array($this['operator'], array('=', '!=', '<=', '>=', '<', '>'))) {
         if ($filter_key == 'text') {
             if ($this['value'] != '') {
                 $searchterm = mb_strpos($this['value'], '%') !== false ? $this['value'] : "%{$this['value']}%";
                 $issue_no = Issue::extractIssueNoFromNumber($this['value']);
                 if ($this['operator'] == '=') {
                     if ($ctn === null) {
                         $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_LIKE);
                     }
                     $ctn->addOr(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_LIKE);
                     $ctn->addOr(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_LIKE);
                     $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE);
                     if (is_numeric($issue_no)) {
                         $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS);
                     }
                     $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE);
                     if (is_numeric($issue_no)) {
                         $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS);
                     }
                     // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE);
                 } else {
                     if ($ctn === null) {
                         $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_NOT_LIKE);
                     }
                     $ctn->addWhere(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_NOT_LIKE);
                     $ctn->addWhere(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_NOT_LIKE);
                     $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE);
                     if (is_numeric($issue_no)) {
                         $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS);
                     }
                     $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE);
                     if (is_numeric($issue_no)) {
                         $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS);
                     }
                     // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE);
                 }
                 return $ctn;
             }
         } elseif (in_array($filter_key, self::getValidSearchFilters())) {
             if ($filter_key == 'subprojects') {
                 if (framework\Context::isProjectContext()) {
                     if ($ctn === null) {
                         $ctn = $crit->returnCriterion(tables\Issues::PROJECT_ID, framework\Context::getCurrentProject()->getID());
                     }
                     if ($this->hasValue()) {
                         foreach ($this->getValues() as $value) {
                             switch ($value) {
                                 case 'all':
                                     $subprojects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject());
                                     foreach ($subprojects as $subproject) {
                                         if ($subproject->getID() == framework\Context::getCurrentProject()->getID()) {
                                             continue;
                                         }
                                         $ctn->addOr(tables\Issues::PROJECT_ID, $subproject->getID());
                                     }
                                     break;
                                 case 'none':
                                 case '':
                                     break;
                                 default:
                                     $ctn->addOr(tables\Issues::PROJECT_ID, (int) $value);
                                     break;
                             }
                         }
                     }
                     return $ctn;
                 }
             } elseif (in_array($filter_key, array('build', 'edition', 'component'))) {
                 switch ($filter_key) {
                     case 'component':
                         $tbl = tables\IssueAffectsComponent::getTable();
                         $fk = tables\IssueAffectsComponent::ISSUE;
                         break;
                     case 'edition':
                         $tbl = tables\IssueAffectsEdition::getTable();
                         $fk = tables\IssueAffectsEdition::ISSUE;
                         break;
                     case 'build':
                         $tbl = tables\IssueAffectsBuild::getTable();
                         $fk = tables\IssueAffectsBuild::ISSUE;
                         break;
                 }
                 $crit->addJoin($tbl, $fk, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.' . $filter_key, $this->getValues())), \b2db\Criteria::DB_INNER_JOIN);
                 return null;
             } else {
                 if ($filter_key == 'project_id' && in_array('subprojects', $filters)) {
                     return null;
                 }
                 $values = $this->getValues();
                 $num_values = 0;
                 if ($filter_key == 'status') {
                     if ($this->hasValue('open')) {
                         $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_OPEN);
                         $num_values++;
                     }
                     if ($this->hasValue('closed')) {
                         $num_values++;
                         if (isset($c)) {
                             $c->addWhere(tables\Issues::STATE, Issue::STATE_CLOSED);
                         } else {
                             $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_CLOSED);
                         }
                     }
                     if (isset($c)) {
                         if (count($values) == $num_values) {
                             return $c;
                         } else {
                             $crit->addWhere($c);
                         }
                     }
                 }
                 $dbname = tables\Issues::getTable()->getB2DBName();
                 foreach ($values as $value) {
                     $operator = $this['operator'];
                     $or = true;
                     if ($filter_key == 'status' && in_array($value, array('open', 'closed'))) {
                         continue;
                     } else {
                         $field = $dbname . '.' . $filter_key;
                         if ($operator == '!=' || in_array($filter_key, array('posted', 'last_updated'))) {
                             $or = false;
                         }
                     }
                     if ($ctn === null) {
                         $ctn = $crit->returnCriterion($field, $value, urldecode($operator));
                     } elseif ($or) {
                         $ctn->addOr($field, $value, urldecode($operator));
                     } else {
                         $ctn->addWhere($field, $value, urldecode($operator));
                     }
                 }
                 return $ctn;
             }
         } elseif (CustomDatatype::doesKeyExist($filter_key)) {
             $customdatatype = CustomDatatype::getByKey($filter_key);
             if (in_array($this->getFilterType(), CustomDatatype::getInternalChoiceFieldsAsArray())) {
                 $tbl = clone tables\IssueCustomFields::getTable();
                 $crit->addJoin($tbl, tables\IssueCustomFields::ISSUE_ID, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.customfields_id', $customdatatype->getID()), array($tbl->getB2DBAlias() . '.customfieldoption_id', $this->getValues())), \b2db\Criteria::DB_INNER_JOIN);
                 return null;
             } else {
                 foreach ($this->getValues() as $value) {
                     if ($customdatatype->hasCustomOptions()) {
                         if ($ctn === null) {
                             $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID());
                             $ctn->addWhere(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']);
                         } else {
                             $ctn->addOr(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']);
                         }
                     } else {
                         if ($ctn === null) {
                             $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID());
                             $ctn->addWhere(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']);
                         } else {
                             $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']);
                         }
                     }
                 }
                 return $ctn;
             }
         }
     }
 }
Example #19
0
 public function runConfigureWorkflowTransition(framework\Request $request)
 {
     $this->workflow = null;
     $this->transition = null;
     try {
         $this->workflow = tables\Workflows::getTable()->selectById((int) $request['workflow_id']);
         if ($request->hasParameter('transition_id')) {
             $mode = $request['mode'];
             $this->transition = tables\WorkflowTransitions::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 = tables\WorkflowSteps::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'], $request['step_id']);
                     $this->forward(framework\Context::getRouting()->generate('configure_workflow_step', array('workflow_id' => $this->workflow->getID(), 'step_id' => $request['step_id'])));
                 } elseif ($mode == 'delete_action') {
                     $this->action = tables\WorkflowTransitionActions::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 entities\WorkflowTransitionAction();
                     $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 = tables\WorkflowTransitionActions::getTable()->selectById((int) $request['action_id']);
                     $this->action->setTargetValue($request['target_value']);
                     $this->action->save();
                     $text = $request['target_value'];
                     switch ($this->action->getActionType()) {
                         case entities\WorkflowTransitionAction::ACTION_ASSIGN_ISSUE:
                             if ($this->action->hasTargetValue()) {
                                 $target_details = explode('_', $this->action->getTargetValue());
                                 $text = $target_details[0] == 'user' ? entities\User::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : entities\Team::getB2DBTable()->selectById((int) $target_details[1])->getName();
                             } else {
                                 $text = $this->getI18n()->__('User specified during transition');
                             }
                             break;
                         case entities\WorkflowTransitionAction::ACTION_SET_RESOLUTION:
                             $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Resolution specified by user');
                             break;
                         case entities\WorkflowTransitionAction::ACTION_SET_REPRODUCABILITY:
                             $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Reproducability specified by user');
                             break;
                         case entities\WorkflowTransitionAction::ACTION_SET_STATUS:
                             $target = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                             $text = $this->action->getTargetValue() ? '<span class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . $target->getName() . '</span>' : $this->getI18n()->__('Status provided by user');
                             break;
                         case entities\WorkflowTransitionAction::ACTION_SET_PRIORITY:
                             $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Priority specified by user');
                             break;
                         case entities\WorkflowTransitionAction::ACTION_SET_MILESTONE:
                             $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                             $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Milestone specified by user');
                             break;
                         case entities\WorkflowTransitionAction::CUSTOMFIELD_SET_PREFIX . $this->action->getCustomActionType():
                             switch (\thebuggenie\core\entities\CustomDatatype::getByKey($this->action->getCustomActionType())->getType()) {
                                 case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_MAIN:
                                 case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_SMALL:
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::DATE_PICKER:
                                     return $this->renderJSON(array('content' => date('Y-m-d', (int) $text)));
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE:
                                     return $this->renderJSON(array('content' => $this->getComponentHTML('main/userdropdown', array('user' => $text))));
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE:
                                     return $this->renderJSON(array('content' => $this->getComponentHTML('main/teamdropdown', array('team' => $text))));
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $text = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Clients::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                                         $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                                         $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                                         $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                                         $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $target = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null;
                                         $text = $this->action->getTargetValue() ? '<span class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . $target->getName() . '</span>' : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                                 case \thebuggenie\core\entities\CustomDatatype::DROPDOWN_CHOICE_TEXT:
                                 default:
                                     if (is_numeric($this->action->getTargetValue())) {
                                         $text = $this->action->getTargetValue() ? tables\CustomFieldOptions::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Value provided by user');
                                     }
                                     break;
                             }
                             break;
                     }
                     return $this->renderJSON(array('content' => $text));
                 } elseif ($mode == 'delete_validation_rule') {
                     $this->rule = tables\WorkflowTransitionValidationRules::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') {
                     if (!in_array($request['postorpre'], array('post', 'pre'))) {
                         throw new \InvalidArgumentException($this->getI18n()->__('Invalid transition definition'));
                     }
                     $rule = new entities\WorkflowTransitionValidationRule();
                     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->getComponentHTML('configuration/workflowtransitionvalidationrule', array('rule' => $rule))));
                 } elseif ($mode == 'update_validation_rule') {
                     $rule = tables\WorkflowTransitionValidationRules::getTable()->selectById((int) $request['rule_id']);
                     $text = null;
                     if ($rule->isCustom()) {
                         switch ($rule->getCustomType()) {
                             case entities\CustomDatatype::RADIO_CHOICE:
                             case entities\CustomDatatype::DROPDOWN_CHOICE_TEXT:
                             case entities\CustomDatatype::TEAM_CHOICE:
                             case entities\CustomDatatype::STATUS_CHOICE:
                             case entities\CustomDatatype::MILESTONE_CHOICE:
                             case entities\CustomDatatype::CLIENT_CHOICE:
                             case entities\CustomDatatype::COMPONENTS_CHOICE:
                             case entities\CustomDatatype::EDITIONS_CHOICE:
                             case entities\CustomDatatype::RELEASES_CHOICE:
                                 $rule->setRuleValue(join(',', $request['rule_value'] ?: array()));
                                 $text = $rule->getRuleValue() ? $rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value');
                                 break;
                         }
                     } else {
                         switch ($rule->getRule()) {
                             case entities\WorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES:
                                 $rule->setRuleValue($request['rule_value']);
                                 $text = $rule->getRuleValue() ? $rule->getRuleValue() : $this->getI18n()->__('Unlimited');
                                 break;
                             case entities\WorkflowTransitionValidationRule::RULE_PRIORITY_VALID:
                             case entities\WorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID:
                             case entities\WorkflowTransitionValidationRule::RULE_RESOLUTION_VALID:
                             case entities\WorkflowTransitionValidationRule::RULE_STATUS_VALID:
                             case entities\WorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID:
                             case entities\WorkflowTransitionValidationRule::RULE_ISSUE_IN_MILESTONE_VALID:
                                 $rule->setRuleValue(join(',', $request['rule_value'] ?: array()));
                                 $text = $rule->getRuleValue() ? $rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value');
                                 break;
                         }
                     }
                     $rule->save();
                     $this->rule = $rule;
                     return $this->renderJSON(array('content' => $text));
                 }
             }
         } elseif ($request->isPost() && $request->hasParameter('step_id')) {
             $step = tables\WorkflowSteps::getTable()->selectById((int) $request['step_id']);
             if ($request['add_transition_type'] == 'existing' && $request->hasParameter('existing_transition_id')) {
                 $transition = tables\WorkflowTransitions::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 = tables\WorkflowSteps::getTable()->selectById((int) $request['outgoing_step_id'])) && $step instanceof entities\WorkflowStep) {
                         if (!$request['template'] || array_key_exists($request['template'], entities\WorkflowTransition::getTemplates())) {
                             $transition = new entities\WorkflowTransition();
                             $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) {
         $this->error = $e->getMessage();
     } catch (\Exception $e) {
         $this->error = $this->getI18n()->__('This workflow / transition does not exist');
     }
     if (isset($redirect_transition) && $redirect_transition) {
         $this->forward(framework\Context::getRouting()->generate('configure_workflow_transition', array('workflow_id' => $this->workflow->getID(), 'transition_id' => $transition->getID())));
     } elseif (isset($redirect_transition)) {
         $this->forward(framework\Context::getRouting()->generate('configure_workflow_steps', array('workflow_id' => $this->workflow->getID())));
     }
 }
Example #20
0
 /**
  * Return an array specifying visibility, requirement and choices for fields in issues
  *
  * @param integer $issue_type
  * @param boolean $reportable [optional] Whether to only include fields that can be reported
  *
  * @return array
  */
 protected function _getFieldsArray($issue_type, $reportable = true)
 {
     $issue_type = is_object($issue_type) ? $issue_type->getID() : $issue_type;
     if (!isset($this->_fieldsarrays[$issue_type][(int) $reportable])) {
         $retval = array();
         $res = tables\IssueFields::getTable()->getBySchemeIDandIssuetypeID($this->getIssuetypeScheme()->getID(), $issue_type);
         if ($res) {
             $builtin_types = Datatype::getAvailableFields(true);
             while ($row = $res->getNextRow()) {
                 if (!$reportable || (bool) $row->get(tables\IssueFields::REPORTABLE) == true) {
                     if ($reportable) {
                         if (in_array($row->get(tables\IssueFields::FIELD_KEY), $builtin_types) && (!$this->fieldPermissionCheck($row->get(tables\IssueFields::FIELD_KEY)) && !($row->get(tables\IssueFields::REQUIRED) && $reportable))) {
                             continue;
                         } elseif (!in_array($row->get(tables\IssueFields::FIELD_KEY), $builtin_types) && (!$this->fieldPermissionCheck($row->get(tables\IssueFields::FIELD_KEY), true) && !($row->get(tables\IssueFields::REQUIRED) && $reportable))) {
                             continue;
                         }
                     }
                     $field_key = $row->get(tables\IssueFields::FIELD_KEY);
                     $retval[$field_key] = array('required' => (bool) $row->get(tables\IssueFields::REQUIRED), 'additional' => (bool) $row->get(tables\IssueFields::ADDITIONAL));
                     if (!in_array($field_key, $builtin_types)) {
                         $retval[$field_key]['custom'] = true;
                         $custom_type = CustomDatatype::getByKey($field_key);
                         if ($custom_type instanceof \thebuggenie\core\entities\CustomDatatype) {
                             $retval[$field_key]['custom_type'] = $custom_type->getType();
                         } else {
                             unset($retval[$field_key]);
                         }
                     }
                 }
             }
             if (array_key_exists('user_pain', $retval)) {
                 $retval['pain_bug_type'] = array('required' => $retval['user_pain']['required']);
                 $retval['pain_likelihood'] = array('required' => $retval['user_pain']['required']);
                 $retval['pain_effect'] = array('required' => $retval['user_pain']['required']);
             }
             if ($reportable) {
                 foreach ($retval as $key => $return_details) {
                     if ($key == 'edition' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::EDITIONS_CHOICE) {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getEditions() as $edition) {
                             $retval[$key]['values'][$edition->getID()] = $edition->getName();
                         }
                         if (!$this->isEditionsEnabled() || empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                         if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) {
                             asort($retval[$key]['values'], SORT_STRING);
                         }
                     } elseif ($key == 'status' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::STATUS_CHOICE) {
                         $retval[$key]['values'] = array();
                         foreach (Status::getAll() as $status) {
                             $retval[$key]['values'][$status->getID()] = $status->getName();
                         }
                         if (empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                         if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) {
                             asort($retval[$key]['values'], SORT_STRING);
                         }
                     } elseif ($key == 'component' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::COMPONENTS_CHOICE) {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getComponents() as $component) {
                             $retval[$key]['values'][$component->getID()] = $component->getName();
                         }
                         if (!$this->isComponentsEnabled() || empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                         if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) {
                             asort($retval[$key]['values'], SORT_STRING);
                         }
                     } elseif ($key == 'build' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::RELEASES_CHOICE) {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getBuilds() as $build) {
                             if ($build->isLocked()) {
                                 continue;
                             }
                             $retval[$key]['values'][$build->getID()] = $build->getName() . ' (' . $build->getVersion() . ')';
                         }
                         if (!$this->isBuildsEnabled() || empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                     } elseif ($key == 'milestone') {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getOpenMilestones() as $milestone) {
                             if (!$milestone->hasAccess()) {
                                 continue;
                             }
                             $retval[$key]['values'][$milestone->getID()] = $milestone->getName();
                         }
                         if (empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                     }
                 }
             }
         }
         $this->_fieldsarrays[$issue_type][(int) $reportable] = $retval;
     }
     return $this->_fieldsarrays[$issue_type][(int) $reportable];
 }
echo image_tag('spinning_16.gif', array('style' => 'margin-right: 5px; display: none;', 'id' => 'add_custom_type_indicator'));
?>
                        </div>
                        <label for="new_custom_field_name" style="width: 150px; display: inline-block;"><?php 
echo __('Add new issue field');
?>
</label>
                        <input type="text" name="name" id="new_custom_field_name" style="width: 250px;">
                        <br style="clear: both;">
                        <label for="new_custom_field_name" style="width: 150px; display: inline-block;"><?php 
echo __('Field type');
?>
</label>
                        <select id="new_custom_field_type" name="field_type" style="width: 400px;">
                            <?php 
foreach (\thebuggenie\core\entities\CustomDatatype::getFieldTypes() as $type => $description) {
    ?>
                                <option value="<?php 
    echo $type;
    ?>
"><?php 
    echo $description;
    ?>
</option>
                            <?php 
}
?>
                        </select>
                        <br style="clear: both;">
                    </form>
                </div>
Example #22
0
 public static function getAvailableFields($builtin_only = false)
 {
     $builtin_types = array('shortname', 'description', 'reproduction_steps', 'status', 'category', 'resolution', 'priority', 'reproducability', 'percent_complete', 'severity', 'owned_by', 'assignee', 'edition', 'build', 'component', 'estimated_time', 'spent_time', 'milestone', 'user_pain', 'votes');
     if ($builtin_only) {
         return $builtin_types;
     }
     $customtypes = CustomDatatype::getAll();
     $types = array_merge($builtin_types, array_keys($customtypes));
     return $types;
 }
Example #23
0
 protected function _setupReportIssueProperties()
 {
     $this->locked_issuetype = $this->locked_issuetype ?: null;
     $this->selected_issuetype = $this->selected_issuetype ?: null;
     $this->selected_edition = $this->selected_edition ?: null;
     $this->selected_build = $this->selected_build ?: null;
     $this->selected_milestone = $this->selected_milestone ?: null;
     $this->parent_issue = $this->parent_issue ?: null;
     $this->selected_component = $this->selected_component ?: null;
     $this->selected_category = $this->selected_category ?: null;
     $this->selected_status = $this->selected_status ?: null;
     $this->selected_resolution = $this->selected_resolution ?: null;
     $this->selected_priority = $this->selected_priority ?: null;
     $this->selected_reproducability = $this->selected_reproducability ?: null;
     $this->selected_severity = $this->selected_severity ?: null;
     $this->selected_estimated_time = $this->selected_estimated_time ?: null;
     $this->selected_spent_time = $this->selected_spent_time ?: null;
     $this->selected_percent_complete = $this->selected_percent_complete ?: null;
     $this->selected_pain_bug_type = $this->selected_pain_bug_type ?: null;
     $this->selected_pain_likelihood = $this->selected_pain_likelihood ?: null;
     $this->selected_pain_effect = $this->selected_pain_effect ?: null;
     $selected_customdatatype = $this->selected_customdatatype ?: array();
     foreach (entities\CustomDatatype::getAll() as $customdatatype) {
         $selected_customdatatype[$customdatatype->getKey()] = isset($selected_customdatatype[$customdatatype->getKey()]) ? $selected_customdatatype[$customdatatype->getKey()] : null;
     }
     $this->selected_customdatatype = $selected_customdatatype;
     $this->issuetype_id = $this->issuetype_id ?: null;
     $this->issue = $this->issue ?: null;
     $this->categories = entities\Category::getAll();
     $this->severities = entities\Severity::getAll();
     $this->priorities = entities\Priority::getAll();
     $this->reproducabilities = entities\Reproducability::getAll();
     $this->resolutions = entities\Resolution::getAll();
     $this->statuses = entities\Status::getAll();
     $this->milestones = framework\Context::getCurrentProject()->getMilestonesForIssues();
     $this->al_items = array();
 }