public function getIssues()
 {
     if (!$this->getBoard()->usesSwimlanes() || in_array($this->getBoard()->getSwimlaneType(), array(AgileBoard::SWIMLANES_EXPEDITE, AgileBoard::SWIMLANES_GROUPING))) {
         $this->_setupSearchObject();
         return $this->_search_object->getIssues();
     } else {
         if ($this->getIdentifierIssue() instanceof \thebuggenie\core\entities\Issue) {
             return $this->getIdentifierIssue()->getChildIssues();
         } else {
             $this->_setupSearchObject();
             return $this->_search_object->getIssues();
         }
     }
 }
 /**
  * Returns the associated search object
  *
  * @return \thebuggenie\core\entities\SavedSearch
  */
 public function getBacklogSearchObject()
 {
     if ($this->_search_object === null) {
         if ($this->usesSavedSearchBacklog()) {
             $this->_search_object = $this->getBacklogSearch();
         } elseif (!$this->_search_object instanceof \thebuggenie\core\entities\SavedSearch) {
             $this->_search_object = \thebuggenie\core\entities\SavedSearch::getPredefinedSearchObject($this->_autogenerated_search);
             $this->_search_object->setFilter('issuetype', \thebuggenie\core\entities\SearchFilter::createFilter('issuetype', array('o' => '!=', 'v' => $this->getEpicIssuetypeID())));
             $this->_search_object->setFilter('milestone', \thebuggenie\core\entities\SearchFilter::createFilter('milestone', array('o' => '!=', 'v' => null)));
         }
         $this->_search_object->setIssuesPerPage(0);
         $this->_search_object->setOffset(0);
         $this->_search_object->setSortFields(array('issues.milestone_order' => 'desc'));
     }
     return $this->_search_object;
 }
Beispiel #3
0
 /**
  * Return whether the user can access a saved search
  *
  * @param B2DBrow $savedsearch
  *
  * @return boolean
  */
 public function canAccessSavedSearch(\thebuggenie\core\entities\SavedSearch $savedsearch)
 {
     return (bool) ($savedsearch->isPublic() || $savedsearch->getUserID() == $this->getID());
 }
Beispiel #4
0
 public function getOpenIssuesSearchForFrontpageSummary()
 {
     $search_object = new SavedSearch();
     $search_object->setAppliesToProject($this);
     $issue_type_filter = SearchFilter::createFilter('issuetype', array('value' => array_keys($this->getVisibleIssuetypes())), $search_object);
     $search_object->setFilter('issuetype', $issue_type_filter);
     $search_object->setGroupby('issuetype');
     return $search_object;
     //            $res = tables\Issues::getTable()->getOpenIssuesByProjectIDAndIssueTypes($this->getID(), array_keys($this->getVisibleIssuetypes()), tables\Issues::ISSUE_TYPE);
     //
     //            $retval = array();
     //            if (!$merged)
     //            {
     //                foreach ($this->getVisibleIssuetypes() as $issuetype_id => $issuetype)
     //                {
     //                    $retval[$issuetype_id] = array('issuetype' => $issuetype, 'issues' => array());
     //                }
     //            }
     //            if ($res)
     //            {
     //                while ($row = $res->getNextRow())
     //                {
     //                    $issue = new \thebuggenie\core\entities\Issue($row->get(tables\Issues::ID));
     //                    if (!$issue->hasAccess()) continue;
     //                    if (!$merged)
     //                    {
     //                        $retval[$row->get(tables\Issues::ISSUE_TYPE)]['issues'][] = $issue;
     //                    }
     //                    else
     //                    {
     //                        $retval[] = $issue;
     //                    }
     //                }
     //            }
     //
     //            return $retval;
 }
Beispiel #5
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;
 }
Beispiel #6
0
 public function runUserdata(framework\Request $request)
 {
     if ($this->getUser()->isGuest()) {
         return $this->renderJSON(array());
     } else {
         $data = array();
         if ($request->isPost()) {
             switch ($request['say']) {
                 case 'install-module':
                     try {
                         entities\Module::downloadModule($request['module_key']);
                         $module = entities\Module::installModule($request['module_key']);
                         $data['installed'] = true;
                         $data['module_key'] = $request['module_key'];
                         $data['module'] = $this->getComponentHTML('configuration/modulebox', array('module' => $module));
                     } catch (framework\exceptions\ModuleDownloadException $e) {
                         $this->getResponse()->setHttpStatus(400);
                         switch ($e->getCode()) {
                             case framework\exceptions\ModuleDownloadException::JSON_NOT_FOUND:
                                 return $this->renderJSON(array('message' => $this->getI18n()->__('An error occured when trying to retrieve the module data')));
                                 break;
                             case framework\exceptions\ModuleDownloadException::FILE_NOT_FOUND:
                                 return $this->renderJSON(array('message' => $this->getI18n()->__('The module could not be downloaded')));
                                 break;
                         }
                     } catch (\Exception $e) {
                         $this->getResponse()->setHttpStatus(400);
                         return $this->renderJSON(array('message' => $this->getI18n()->__('An error occured when trying to install the module')));
                     }
                     break;
                 case 'install-theme':
                     try {
                         entities\Module::downloadTheme($request['theme_key']);
                         $data['installed'] = true;
                         $data['theme_key'] = $request['theme_key'];
                         $themes = framework\Context::getThemes();
                         $data['theme'] = $this->getComponentHTML('configuration/theme', array('theme' => $themes[$request['theme_key']]));
                     } catch (framework\exceptions\ModuleDownloadException $e) {
                         $this->getResponse()->setHttpStatus(400);
                         switch ($e->getCode()) {
                             case framework\exceptions\ModuleDownloadException::JSON_NOT_FOUND:
                                 return $this->renderJSON(array('message' => $this->getI18n()->__('An error occured when trying to retrieve the module data')));
                                 break;
                             case framework\exceptions\ModuleDownloadException::FILE_NOT_FOUND:
                                 return $this->renderJSON(array('message' => $this->getI18n()->__('The module could not be downloaded')));
                                 break;
                         }
                     } catch (\Exception $e) {
                         $this->getResponse()->setHttpStatus(400);
                         return $this->renderJSON(array('message' => $this->getI18n()->__('An error occured when trying to install the module')));
                     }
                     break;
                 case 'notificationstatus':
                     $notification = tables\Notifications::getTable()->selectById($request['notification_id']);
                     $data['notification_id'] = $request['notification_id'];
                     $data['is_read'] = 1;
                     if ($notification instanceof entities\Notification) {
                         $notification->setIsRead(!$notification->isRead());
                         $notification->save();
                         $data['is_read'] = (int) $notification->isRead();
                         $this->getUser()->markNotificationGroupedNotificationsRead($notification);
                     }
                     break;
                 case 'notificationsread':
                     $this->getUser()->markAllNotificationsRead();
                     $data['all'] = 'read';
                     break;
             }
         } else {
             switch ($request['say']) {
                 case 'get_module_updates':
                     $addons_param = array();
                     foreach ($request['addons'] as $addon) {
                         $addons_param[] = 'addons[]=' . $addon;
                     }
                     try {
                         $client = new \Net_Http_Client();
                         $client->get('http://www.thebuggenie.com/addons.json?' . join('&', $addons_param));
                         $addons_json = json_decode($client->getBody(), true);
                     } catch (\Exception $e) {
                     }
                     return $this->renderJSON($addons_json);
                     break;
                 case 'getsearchcounts':
                     $counts_json = array();
                     foreach ($request['search_ids'] as $search_id) {
                         if (is_numeric($search_id)) {
                             $search = tables\SavedSearches::getTable()->selectById($search_id);
                         } else {
                             $predefined_id = str_replace('predefined_', '', $search_id);
                             $search = \thebuggenie\core\entities\SavedSearch::getPredefinedSearchObject($predefined_id);
                         }
                         if ($search instanceof entities\SavedSearch) {
                             $counts_json[$search_id] = $search->getTotalNumberOfIssues();
                         }
                     }
                     return $this->renderJSON($counts_json);
                     break;
                 case 'get_theme_updates':
                     $addons_param = array();
                     foreach ($request['addons'] as $addon) {
                         $addons_param[] = 'themes[]=' . $addon;
                     }
                     try {
                         $client = new \Net_Http_Client();
                         $client->get('http://www.thebuggenie.com/themes.json?' . join('&', $addons_param));
                         $addons_json = json_decode($client->getBody(), true);
                     } catch (\Exception $e) {
                     }
                     return $this->renderJSON($addons_json);
                     break;
                 case 'verify_module_update_file':
                     $filename = THEBUGGENIE_CACHE_PATH . $request['module_key'] . '.zip';
                     $exists = file_exists($filename) && dirname($filename) . DS == THEBUGGENIE_CACHE_PATH;
                     return $this->renderJSON(array('verified' => (int) $exists));
                     break;
                 case 'get_modules':
                     return $this->renderComponent('configuration/onlinemodules');
                     break;
                 case 'get_themes':
                     return $this->renderComponent('configuration/onlinethemes');
                     break;
                 case 'get_mentionables':
                     switch ($request['target_type']) {
                         case 'issue':
                             $target = entities\Issue::getB2DBTable()->selectById($request['target_id']);
                             break;
                         case 'article':
                             $target = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->selectById($request['target_id']);
                             break;
                         case 'project':
                             $target = tables\Projects::getTable()->selectById($request['target_id']);
                             break;
                     }
                     $mentionables = array();
                     if (isset($target) && $target instanceof \thebuggenie\core\helpers\MentionableProvider) {
                         foreach ($target->getMentionableUsers() as $user) {
                             if ($user->isOpenIdLocked()) {
                                 continue;
                             }
                             $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL());
                         }
                     }
                     foreach ($this->getUser()->getFriends() as $user) {
                         if ($user->isOpenIdLocked()) {
                             continue;
                         }
                         $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL());
                     }
                     foreach ($this->getUser()->getTeams() as $team) {
                         foreach ($team->getMembers() as $user) {
                             if ($user->isOpenIdLocked()) {
                                 continue;
                             }
                             $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL());
                         }
                     }
                     foreach ($this->getUser()->getClients() as $client) {
                         foreach ($client->getMembers() as $user) {
                             if ($user->isOpenIdLocked()) {
                                 continue;
                             }
                             $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL());
                         }
                     }
                     $data['mentionables'] = array_values($mentionables);
                     break;
                 default:
                     $data['unread_notifications_count'] = $this->getUser()->getNumberOfUnreadNotifications();
                     $data['unread_notifications'] = array();
                     foreach ($this->getUser()->getUnreadNotifications() as $unread_notification) {
                         $data['unread_notifications'][] = $unread_notification->getID();
                     }
                     $data['poll_interval'] = framework\Settings::getNotificationPollInterval();
             }
         }
         return $this->renderJSON($data);
     }
 }
Beispiel #7
0
 /**
  * Performs the "find issues" action
  *
  * @param framework\Request $request
  */
 public function runFindIssues(framework\Request $request)
 {
     $this->resultcount = 0;
     if ($request['quicksearch'] == true) {
         if ($request->isAjaxCall()) {
             return $this->redirect('quicksearch');
         } else {
             $issues = $this->issues;
             $issue = array_shift($issues);
             if ($issue instanceof entities\Issue) {
                 return $this->forward($this->getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())));
             }
         }
     }
     if ($this->search_object->hasQuickfoundIssues()) {
         $issues = $this->search_object->getQuickfoundIssues();
         $issue = array_shift($issues);
         if ($issue instanceof entities\Issue) {
             return $this->forward($this->getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())));
         }
     }
     $this->search_error = framework\Context::getMessageAndClear('search_error');
     $this->search_message = framework\Context::getMessageAndClear('search_message');
     $this->appliedfilters = $this->filters;
     $this->templates = entities\SavedSearch::getTemplates();
 }