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->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;
 }
 protected function _populateMilestoneSwimlanes(\thebuggenie\core\entities\Milestone $milestone)
 {
     if (!array_key_exists($milestone->getID(), $this->_swimlanes)) {
         $this->_swimlanes[$milestone->getID()] = array();
         $swimlanes = array();
         if ($this->usesSwimlanes()) {
             switch ($this->getSwimlaneType()) {
                 case self::SWIMLANES_EXPEDITE:
                 case self::SWIMLANES_GROUPING:
                     switch ($this->getSwimlaneIdentifier()) {
                         case 'priority':
                             $items = \thebuggenie\core\entities\Priority::getAll();
                             break;
                         case 'severity':
                             $items = \thebuggenie\core\entities\Severity::getAll();
                             break;
                         case 'category':
                             $items = \thebuggenie\core\entities\Category::getAll();
                             break;
                         default:
                             $items = array();
                             break;
                     }
                     if ($this->getSwimlaneType() == self::SWIMLANES_EXPEDITE) {
                         $expedite_items = array();
                         foreach ($this->getSwimlaneFieldValues() as $value) {
                             if (array_key_exists($value, $items)) {
                                 $expedite_items[$items[$value]->getID()] = $items[$value];
                                 unset($items[$value]);
                             }
                         }
                         $swimlanes[] = array('identifiables' => $expedite_items);
                         $swimlanes[] = array('identifiables' => $items);
                         $swimlanes[] = array('identifiables' => 0);
                     } else {
                         foreach ($items as $item) {
                             $swimlanes[] = array('identifiables' => $item);
                         }
                         $swimlanes[] = array('identifiables' => 0);
                     }
                     break;
                 case self::SWIMLANES_ISSUES:
                     foreach ($milestone->getIssues() as $issue) {
                         if ($issue->isChildIssue()) {
                             foreach ($issue->getParentIssues() as $parent) {
                                 if ($parent->getIssueType()->getID() != $this->getEpicIssuetypeID()) {
                                     continue 2;
                                 }
                             }
                         }
                         if (in_array($issue->getIssueType()->getID(), $this->getSwimlaneFieldValues())) {
                             $swimlanes[] = array('identifiables' => $issue);
                         }
                     }
                     $swimlanes[] = array('identifiables' => 0);
                     break;
             }
         } else {
             $swimlanes[] = array('identifiables' => 0);
         }
         foreach ($swimlanes as $details) {
             $swimlane = new BoardSwimlane();
             $swimlane->setBoard($this);
             $swimlane->setIdentifiables($details['identifiables']);
             $swimlane->setMilestone($milestone);
             $this->_swimlanes[$milestone->getID()][] = $swimlane;
         }
     }
 }
Esempio n. 3
0
 protected function _populateCategoryCount()
 {
     if ($this->_categorycount === null) {
         $this->_categorycount = array();
         $this->_categorycount[0] = array('open' => 0, 'closed' => 0, 'percentage' => 0);
         foreach (Category::getAll() as $category_id => $category) {
             $this->_categorycount[$category_id] = array('open' => 0, 'closed' => 0, 'percentage' => 0);
         }
         foreach (tables\Issues::getTable()->getCategoryCountByProjectID($this->getID()) as $category_id => $category_count) {
             $this->_categorycount[$category_id] = $category_count;
         }
     }
 }
Esempio n. 4
0
 public function getAvailableValues()
 {
     switch ($this->getFilterKey()) {
         case 'issuetype':
             return framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getIssuetypeScheme()->getIssuetypes() : Issuetype::getAll();
         case 'status':
             return Status::getAll();
         case 'category':
             return Category::getAll();
         case 'priority':
             return Priority::getAll();
         case 'severity':
             return Severity::getAll();
         case 'reproducability':
             return Reproducability::getAll();
         case 'resolution':
             return Resolution::getAll();
         case 'project_id':
             return \thebuggenie\core\entities\Project::getAll();
         case 'build':
             return $this->_getAvailableBuildChoices();
         case 'component':
             return $this->_getAvailableComponentChoices();
         case 'edition':
             return $this->_getAvailableEditionChoices();
         case 'milestone':
             return $this->_getAvailableMilestoneChoices();
         case 'subprojects':
             $filters = array();
             $projects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject());
             foreach ($projects as $project) {
                 if ($project->getID() == framework\Context::getCurrentProject()->getID()) {
                     continue;
                 }
                 $filters[$project->getID()] = $project;
             }
             return $filters;
         case 'owner_user':
         case 'assignee_user':
         case 'posted_by':
             return $this->_getAvailableUserChoices();
         case 'owner_team':
         case 'assignee_team':
             return $this->_getAvailableTeamChoices();
         default:
             $customdatatype = CustomDatatype::getByKey($this->getFilterKey());
             if ($customdatatype instanceof \thebuggenie\core\entities\CustomDatatype && $customdatatype->hasCustomOptions()) {
                 return $customdatatype->getOptions();
             } else {
                 switch ($this->getFilterType()) {
                     case CustomDatatype::COMPONENTS_CHOICE:
                         return $this->_getAvailableComponentChoices();
                     case CustomDatatype::RELEASES_CHOICE:
                         return $this->_getAvailableBuildChoices();
                     case CustomDatatype::EDITIONS_CHOICE:
                         return $this->_getAvailableEditionChoices();
                     case CustomDatatype::MILESTONE_CHOICE:
                         return $this->_getAvailableMilestoneChoices();
                     case CustomDatatype::USER_CHOICE:
                         return $this->_getAvailableUserChoices();
                     case CustomDatatype::TEAM_CHOICE:
                         return $this->_getAvailableTeamChoices();
                     case CustomDatatype::CLIENT_CHOICE:
                         return $this->_getAvailableClientChoices();
                     case CustomDatatype::STATUS_CHOICE:
                         return Status::getAll();
                     default:
                         return array();
                 }
             }
     }
 }
Esempio n. 5
0
                                    <table class="cleantable">
                                        <thead>
                                            <tr>
                                                <th><?php 
echo __('Name');
?>
</th>
                                                <th><?php 
echo __('ID');
?>
</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php 
foreach (\thebuggenie\core\entities\Category::getAll() as $item) {
    ?>
                                            <tr><td><?php 
    echo $item->getName();
    ?>
</td><td><?php 
    echo $item->getID();
    ?>
</td></tr>
                                        <?php 
}
?>
                                        </tbody>
                                    </table>
                                </div>
                                <br class="clear" />
Esempio n. 6
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();
 }
Esempio n. 7
0
 public function componentFilter()
 {
     $pkey = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getID() : null;
     $i18n = framework\Context::getI18n();
     $this->selected_operator = isset($this->selected_operator) ? $this->selected_operator : '=';
     $this->key = isset($this->key) ? $this->key : null;
     $this->filter = isset($this->filter) ? $this->filter : null;
     if (in_array($this->filter, array('posted', 'last_updated'))) {
         $this->selected_value = $this->selected_value ? $this->selected_value : NOW;
     } else {
         $this->selected_value = isset($this->selected_value) ? $this->selected_value : 0;
     }
     $this->filter_info = isset($this->filter_info) ? $this->filter_info : null;
     $filters = array();
     $filters['status'] = array('description' => $i18n->__('Status'), 'options' => entities\Status::getAll());
     $filters['category'] = array('description' => $i18n->__('Category'), 'options' => entities\Category::getAll());
     $filters['priority'] = array('description' => $i18n->__('Priority'), 'options' => entities\Priority::getAll());
     $filters['severity'] = array('description' => $i18n->__('Severity'), 'options' => entities\Severity::getAll());
     $filters['reproducability'] = array('description' => $i18n->__('Reproducability'), 'options' => entities\Reproducability::getAll());
     $filters['resolution'] = array('description' => $i18n->__('Resolution'), 'options' => entities\Resolution::getAll());
     $filters['issuetype'] = array('description' => $i18n->__('Issue type'), 'options' => entities\Issuetype::getAll());
     $filters['component'] = array('description' => $i18n->__('Component'), 'options' => array());
     $filters['build'] = array('description' => $i18n->__('Build'), 'options' => array());
     $filters['edition'] = array('description' => $i18n->__('Edition'), 'options' => array());
     $filters['milestone'] = array('description' => $i18n->__('Milestone'), 'options' => array());
     if (framework\Context::isProjectContext()) {
         $filters['subprojects'] = array('description' => $i18n->__('Include subproject(s)'), 'options' => array('all' => $this->getI18n()->__('All subprojects'), 'none' => $this->getI18n()->__("Don't include subprojects (default, unless specified otherwise)")));
         $projects = entities\Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject());
         foreach ($projects as $project) {
             if ($project->getID() == framework\Context::getCurrentProject()->getID()) {
                 continue;
             }
             $filters['subprojects']['options'][$project->getID()] = "{$project->getName()} ({$project->getKey()})";
         }
     } else {
         $projects = array();
         foreach (entities\Project::getAllRootProjects() as $project) {
             entities\Project::getSubprojectsArray($project, $projects);
         }
     }
     if (count($projects) > 0) {
         foreach ($projects as $project) {
             foreach ($project->getComponents() as $component) {
                 $filters['component']['options'][] = $component;
             }
             foreach ($project->getBuilds() as $build) {
                 $filters['build']['options'][] = $build;
             }
             foreach ($project->getEditions() as $edition) {
                 $filters['edition']['options'][] = $edition;
             }
             foreach ($project->getMilestones() as $milestone) {
                 $filters['milestone']['options'][] = $milestone;
             }
         }
     }
     $filters['posted_by'] = array('description' => $i18n->__('Posted by'));
     $filters['assignee_user'] = array('description' => $i18n->__('Assigned to user'));
     $filters['assignee_team'] = array('description' => $i18n->__('Assigned to team'));
     $filters['owner_user'] = array('description' => $i18n->__('Owned by user'));
     $filters['owner_team'] = array('description' => $i18n->__('Owned by team'));
     $filters['posted'] = array('description' => $i18n->__('Date reported'));
     $filters['last_updated'] = array('description' => $i18n->__('Date last updated'));
     $this->filters = $filters;
 }
Esempio n. 8
0
" id="<?php 
        echo $key;
        ?>
_yes">
                                            <option value="0"<?php 
        if ($tbg_user->getNotificationSetting($key, 0)->getValue() == 0) {
            ?>
 selected<?php 
        }
        ?>
><?php 
        echo __('All categories');
        ?>
</option>
                                            <?php 
        foreach (\thebuggenie\core\entities\Category::getAll() as $category_id => $category) {
            ?>
                                                <?php 
            if (!$category->canUserSet($tbg_user)) {
                continue;
            }
            ?>
                                                <option value="<?php 
            echo $category_id;
            ?>
"<?php 
            if ($tbg_user->getNotificationSetting($key, 0)->getValue() == $category_id) {
                ?>
 selected<?php 
            }
            ?>
Esempio n. 9
0
 public function componentDashboardViewProjectStatistics()
 {
     switch ($this->view->getType()) {
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_PRIORITY:
             $counts = framework\Context::getCurrentProject()->getPriorityCount();
             $items = entities\Priority::getAll();
             $key = 'priority';
             break;
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_SEVERITY:
             $counts = framework\Context::getCurrentProject()->getSeverityCount();
             $items = entities\Severity::getAll();
             $key = 'priority';
             break;
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_CATEGORY:
             $counts = framework\Context::getCurrentProject()->getCategoryCount();
             $items = entities\Category::getAll();
             $key = 'category';
             break;
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_RESOLUTION:
             $counts = framework\Context::getCurrentProject()->getResolutionCount();
             $items = entities\Resolution::getAll();
             $key = 'resolution';
             break;
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_STATUS:
             $counts = framework\Context::getCurrentProject()->getStatusCount();
             $items = entities\Status::getAll();
             $key = 'status';
             break;
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_WORKFLOW_STEP:
             $counts = framework\Context::getCurrentProject()->getWorkflowCount();
             $items = entities\WorkflowStep::getAllByWorkflowSchemeID(framework\Context::getCurrentProject()->getWorkflowScheme()->getID());
             $key = 'workflowstep';
             break;
         case entities\DashboardView::VIEW_PROJECT_STATISTICS_STATE:
             $counts = framework\Context::getCurrentProject()->getStateCount();
             $items = array('open' => $this->getI18n()->__('Open'), 'closed' => $this->getI18n()->__('Closed'));
             $key = 'state';
             break;
     }
     $this->counts = $counts;
     $this->key = $key;
     $this->items = $items;
 }
Esempio n. 10
0
 /**
  * "My account" page
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runMyAccount(framework\Request $request)
 {
     $this->forward403unless($this->getUser()->hasPageAccess('account'));
     $categories = \thebuggenie\core\entities\Category::getAll();
     $projects = [];
     $project_subscription_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS;
     $category_subscription_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY;
     $category_notification_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_NOTIFY_NEW_ISSUES_MY_PROJECTS_CATEGORY;
     $subscriptionssettings = framework\Settings::getSubscriptionsSettings();
     $notificationsettings = framework\Settings::getNotificationSettings();
     $selected_project_subscriptions = [];
     $selected_category_subscriptions = [];
     $selected_category_notifications = [];
     $this->all_projects_subscription = $this->getUser()->getNotificationSetting($project_subscription_key, false)->isOn();
     foreach (\thebuggenie\core\entities\Project::getAll() as $project_id => $project) {
         if ($project->hasAccess()) {
             $projects[$project_id] = $project;
             if ($this->getUser()->getNotificationSetting($project_subscription_key . '_' . $project_id, false)->isOn()) {
                 $selected_project_subscriptions[] = $project_id;
             }
         }
     }
     foreach ($categories as $category_id => $category) {
         if ($this->getUser()->getNotificationSetting($category_subscription_key . '_' . $category_id, false)->isOn()) {
             $selected_category_subscriptions[] = $category_id;
         }
         if ($this->getUser()->getNotificationSetting($category_notification_key . '_' . $category_id, false)->isOn()) {
             $selected_category_notifications[] = $category_id;
         }
     }
     $this->selected_project_subscriptions = $this->all_projects_subscription ? [] : $selected_project_subscriptions;
     $this->projects = $projects;
     $this->selected_category_subscriptions = $selected_category_subscriptions;
     $this->selected_category_notifications = $selected_category_notifications;
     $this->categories = $categories;
     $this->subscriptionssettings = $subscriptionssettings;
     $this->notificationsettings = $notificationsettings;
     $this->has_autopassword = framework\Context::hasMessage('auto_password');
     if ($this->has_autopassword) {
         $this->autopassword = framework\Context::getMessage('auto_password');
     }
     if ($request->isPost() && $request->hasParameter('mode')) {
         switch ($request['mode']) {
             case 'information':
                 if (!$request['buddyname'] || !$request['email']) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Please fill out all the required fields')));
                 }
                 $this->getUser()->setBuddyname($request['buddyname']);
                 $this->getUser()->setRealname($request['realname']);
                 $this->getUser()->setHomepage($request['homepage']);
                 $this->getUser()->setEmailPrivate((bool) $request['email_private']);
                 $this->getUser()->setUsesGravatar((bool) $request['use_gravatar']);
                 $this->getUser()->setTimezone($request->getRawParameter('timezone'));
                 $this->getUser()->setLanguage($request['profile_language']);
                 if ($this->getUser()->getEmail() != $request['email']) {
                     if (\thebuggenie\core\framework\Event::createNew('core', 'changeEmail', $this->getUser(), array('email' => $request['email']))->triggerUntilProcessed()->isProcessed() == false) {
                         $this->getUser()->setEmail($request['email']);
                     }
                 }
                 $this->getUser()->save();
                 return $this->renderJSON(array('title' => framework\Context::getI18n()->__('Profile information saved')));
                 break;
             case 'settings':
                 $this->getUser()->setPreferredWikiSyntax($request['syntax_articles']);
                 $this->getUser()->setPreferredIssuesSyntax($request['syntax_issues']);
                 $this->getUser()->setPreferredCommentsSyntax($request['syntax_comments']);
                 $this->getUser()->setKeyboardNavigationEnabled($request['enable_keyboard_navigation']);
                 $this->getUser()->save();
                 return $this->renderJSON(array('title' => framework\Context::getI18n()->__('Profile settings saved')));
                 break;
             case 'notificationsettings':
                 $this->getUser()->setDesktopNotificationsNewTabEnabled($request['enable_desktop_notifications_new_tab']);
                 foreach ($subscriptionssettings as $setting => $description) {
                     if ($setting == framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY) {
                         foreach ($categories as $category_id => $category) {
                             if ($request->hasParameter('core_' . $setting . '_' . $category_id)) {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $category_id, true)->save();
                             } else {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $category_id, false)->save();
                             }
                         }
                     } elseif ($setting == framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS) {
                         if ($request->hasParameter('core_' . $setting . '_all')) {
                             $this->getUser()->setNotificationSetting($setting, true)->save();
                             foreach (\thebuggenie\core\entities\Project::getAll() as $project_id => $project) {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $project_id, false)->save();
                             }
                         } else {
                             $this->getUser()->setNotificationSetting($setting, false)->save();
                             foreach (\thebuggenie\core\entities\Project::getAll() as $project_id => $project) {
                                 if ($request->hasParameter('core_' . $setting . '_' . $project_id)) {
                                     $this->getUser()->setNotificationSetting($setting . '_' . $project_id, true)->save();
                                 } else {
                                     $this->getUser()->setNotificationSetting($setting . '_' . $project_id, false)->save();
                                 }
                             }
                         }
                     } else {
                         if ($request->hasParameter('core_' . $setting)) {
                             $this->getUser()->setNotificationSetting($setting, true)->save();
                         } else {
                             $this->getUser()->setNotificationSetting($setting, false)->save();
                         }
                     }
                 }
                 foreach ($notificationsettings as $setting => $description) {
                     if ($setting == framework\Settings::SETTINGS_USER_NOTIFY_NEW_ISSUES_MY_PROJECTS_CATEGORY) {
                         foreach ($categories as $category_id => $category) {
                             if ($request->hasParameter('core_' . $setting . '_' . $category_id)) {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $category_id, true)->save();
                             } else {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $category_id, false)->save();
                             }
                         }
                     } else {
                         if ($request->hasParameter('core_' . $setting)) {
                             if ($setting == framework\Settings::SETTINGS_USER_NOTIFY_GROUPED_NOTIFICATIONS) {
                                 $this->getUser()->setNotificationSetting($setting, $request->getParameter('core_' . $setting))->save();
                             } else {
                                 $this->getUser()->setNotificationSetting($setting, true)->save();
                             }
                         } else {
                             $this->getUser()->setNotificationSetting($setting, false)->save();
                         }
                     }
                 }
                 \thebuggenie\core\framework\Event::createNew('core', 'mainActions::myAccount::saveNotificationSettings')->trigger(compact('request', 'categories'));
                 $this->getUser()->save();
                 return $this->renderJSON(array('title' => framework\Context::getI18n()->__('Notification settings saved')));
                 break;
             case 'module':
                 foreach (framework\Context::getModules() as $module_name => $module) {
                     if ($request['target_module'] == $module_name && $module->hasAccountSettings()) {
                         if ($module->postAccountSettings($request)) {
                             return $this->renderJSON(array('title' => framework\Context::getI18n()->__('Settings saved')));
                         } else {
                             $this->getResponse()->setHttpStatus(400);
                             return $this->renderJSON(array('error' => framework\Context::getI18n()->__('An error occured')));
                         }
                     }
                 }
                 break;
         }
     }
     $this->rnd_no = rand();
     $this->languages = framework\I18n::getLanguages();
     $this->timezones = framework\I18n::getTimezones();
     $this->error = framework\Context::getMessageAndClear('error');
     $this->username_chosen = framework\Context::getMessageAndClear('username_chosen');
     $this->openid_used = framework\Context::getMessageAndClear('openid_used');
     $this->rsskey_generated = framework\Context::getMessageAndClear('rsskey_generated');
     $this->selected_tab = 'profile';
     if ($this->rsskey_generated) {
         $this->selected_tab = 'security';
     }
 }
Esempio n. 11
0
 /**
  * Configuration import page
  *
  * @param framework\Request $request
  */
 public function runIndex(framework\Request $request)
 {
     if ($request->isPost()) {
         if ($request['import_sample_data']) {
             $transaction = \b2db\Core::startTransaction();
             $users = array();
             $user1 = new entities\User();
             $user1->setUsername('john');
             $user1->setPassword('john');
             $user1->setBuddyname('John');
             $user1->setRealname('John');
             $user1->setActivated();
             $user1->setEnabled();
             $user1->save();
             $users[] = $user1;
             $user2 = new entities\User();
             $user2->setUsername('jane');
             $user2->setPassword('jane');
             $user2->setBuddyname('Jane');
             $user2->setRealname('Jane');
             $user2->setActivated();
             $user2->setEnabled();
             $user2->save();
             $users[] = $user2;
             $user3 = new entities\User();
             $user3->setUsername('jackdaniels');
             $user3->setPassword('jackdaniels');
             $user3->setBuddyname('Jack');
             $user3->setRealname('Jack Daniels');
             $user3->setActivated();
             $user3->setEnabled();
             $user3->save();
             $users[] = $user3;
             $project1 = new entities\Project();
             $project1->setName('Sample project 1');
             $project1->setOwner($users[rand(0, 2)]);
             $project1->setLeader($users[rand(0, 2)]);
             $project1->setQaResponsible($users[rand(0, 2)]);
             $project1->setDescription('This is a sample project that is awesome. Try it out!');
             $project1->setHomepage('http://www.google.com');
             $project1->save();
             $project2 = new entities\Project();
             $project2->setName('Sample project 2');
             $project2->setOwner($users[rand(0, 2)]);
             $project2->setLeader($users[rand(0, 2)]);
             $project2->setQaResponsible($users[rand(0, 2)]);
             $project2->setDescription('This is the second sample project. Not as awesome as the first one, but still worth a try!');
             $project2->setHomepage('http://www.bing.com');
             $project2->save();
             foreach (array($project1, $project2) as $project) {
                 for ($cc = 1; $cc <= 5; $cc++) {
                     $milestone = new entities\Milestone();
                     $milestone->setName("Milestone {$cc}");
                     $milestone->setProject($project);
                     $milestone->setType(entities\Milestone::TYPE_REGULAR);
                     if ((bool) rand(0, 1)) {
                         $milestone->setScheduledDate(NOW + 100000 * (20 * $cc));
                     }
                     $milestone->save();
                 }
             }
             $p1_milestones = $project1->getMilestones();
             $p2_milestones = $project2->getMilestones();
             $issues = array();
             $priorities = entities\Priority::getAll();
             $categories = entities\Category::getAll();
             $severities = entities\Severity::getAll();
             $statuses = entities\Status::getAll();
             $reproducabilities = entities\Reproducability::getAll();
             $lorem_ipsum = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName('LoremIpsum');
             $lorem_words = explode(' ', $lorem_ipsum->getContent());
             foreach (array('bugreport', 'featurerequest', 'enhancement', 'idea') as $issuetype) {
                 $issuetype = entities\Issuetype::getByKeyish($issuetype);
                 for ($cc = 1; $cc <= 10; $cc++) {
                     $issue1 = new entities\Issue();
                     $issue1->setProject($project1);
                     $issue1->setPostedBy($users[rand(0, 2)]);
                     $issue1->setPosted(NOW - 86400 * rand(1, 30));
                     $title_string = '';
                     $description_string = '';
                     $rand_length = rand(4, 15);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $title_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $title_string .= '.';
                             $ucnext = true;
                         }
                         $title_string .= ' ';
                     }
                     $rand_length = rand(40, 500);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $description_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $description_string .= '.';
                             $ucnext = true;
                             $description_string .= $ll != $rand_length && rand(1, 15) == 8 ? "\n\n" : ' ';
                         } else {
                             $description_string .= ' ';
                         }
                     }
                     $issue1->setTitle(ucfirst($title_string));
                     $issue1->setDescription($description_string);
                     $issue1->setIssuetype($issuetype);
                     $issue1->setMilestone($p1_milestones[array_rand($p1_milestones)]);
                     $issue1->setPriority($priorities[array_rand($priorities)]);
                     $issue1->setCategory($categories[array_rand($categories)]);
                     $issue1->setSeverity($severities[array_rand($severities)]);
                     $issue1->setReproducability($reproducabilities[array_rand($reproducabilities)]);
                     $issue1->setPercentCompleted(rand(0, 100));
                     $issue1->save();
                     $issue1->setStatus($statuses[array_rand($statuses)]);
                     if (rand(0, 1)) {
                         $issue1->setAssignee($users[array_rand($users)]);
                     }
                     $issue1->save();
                     $issues[] = $issue1;
                     $issue2 = new entities\Issue();
                     $issue2->setProject($project2);
                     $issue2->setPostedBy($users[rand(0, 2)]);
                     $issue2->setPosted(NOW - 86400 * rand(1, 30));
                     $title_string = '';
                     $description_string = '';
                     $rand_length = rand(4, 15);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $title_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $title_string .= '.';
                             $ucnext = true;
                         }
                         $title_string .= ' ';
                     }
                     $rand_length = rand(40, 500);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $description_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $description_string .= '.';
                             $ucnext = true;
                             $description_string .= $ll != $rand_length && rand(1, 15) == 8 ? "\n\n" : ' ';
                         } else {
                             $description_string .= ' ';
                         }
                     }
                     $issue2->setTitle(ucfirst($title_string));
                     $issue2->setDescription($description_string);
                     $issue2->setIssuetype($issuetype);
                     $issue2->setMilestone($p2_milestones[array_rand($p2_milestones)]);
                     $issue2->setPriority($priorities[array_rand($priorities)]);
                     $issue2->setCategory($categories[array_rand($categories)]);
                     $issue2->setSeverity($severities[array_rand($severities)]);
                     $issue2->setReproducability($reproducabilities[array_rand($reproducabilities)]);
                     $issue2->setPercentCompleted(rand(0, 100));
                     if (rand(0, 1)) {
                         $issue1->setAssignee($users[array_rand($users)]);
                     }
                     $issue2->save();
                     $issue2->setStatus($statuses[array_rand($statuses)]);
                     $issue2->save();
                     $issues[] = $issue2;
                 }
             }
             $rand_issues_to_close = rand(8, 40);
             $resolutions = entities\Resolution::getAll();
             for ($cc = 1; $cc <= $rand_issues_to_close; $cc++) {
                 $issue = array_slice($issues, array_rand($issues), 1);
                 $issue = $issue[0];
                 $issue->setResolution($resolutions[array_rand($resolutions)]);
                 $issue->close();
                 $issue->save();
             }
             $this->imported_data = true;
             $roles = entities\Role::getAll();
             foreach (array($project1, $project2) as $project) {
                 foreach ($users as $user) {
                     $project->addAssignee($user, $roles[array_rand($roles)]);
                 }
             }
             $transaction->commitAndEnd();
         }
     }
     $project1 = entities\Project::getByKey('sampleproject1');
     $project2 = entities\Project::getByKey('sampleproject2');
     $this->canimport = !$project1 instanceof entities\Project && !$project2 instanceof entities\Project;
 }