示例#1
0
 public function __construct()
 {
     parent::__construct();
     $this->addCrumb($this->translate('custom_fields'), $this->generateUrl('project_settings_custom_fields'));
     $this->before(['edit', 'save', 'destroy'], function () {
         $this->object = CustomField::find(Request::$properties->get('id'));
         if (!$this->object || $this->object->project_id != $this->currentProject['id']) {
             return $this->show404();
         }
     });
 }
示例#2
0
 /**
  * Set ticket filters.
  */
 public function setFiltersAction()
 {
     $queryString = [];
     $filters = Request::$post->get('filters', [], false);
     // Add filter
     if ($newFilter = Request::$post->get('new_filter') and $newFilter !== '') {
         if (!isset($filters[$newFilter])) {
             $filters[$newFilter] = ['prefix' => '', 'values' => []];
         } else {
             $filters[$newFilter]['values'][] = '';
         }
     }
     foreach ($filters as $name => $filter) {
         $filter['prefix'] = $filter['prefix'] == '-' ? '!' : '';
         // Is this a filter?
         if (!in_array($name, array_keys(TicketFilters::filtersFor($this->currentProject)))) {
             continue;
         }
         if (!isset($filter['values'])) {
             $filter['values'] = [];
         }
         if ($field = CustomField::find('slug', $name)) {
             $queryString[$name] = $filter['prefix'] . implode(',', $filter['values']);
         } else {
             $queryString[$name] = $filter['prefix'] . implode(',', $filter['values']);
         }
     }
     return $this->redirect($this->generateUrl('tickets', ['pslug' => $this->currentProject['slug']]) . '?' . Request::buildQueryString($queryString, false));
 }
示例#3
0
 /**
  * Delete field.
  */
 public function action_delete($id)
 {
     // Find field
     $field = CustomField::find($id);
     // Verify project
     if ($field->project_id != $this->project->id) {
         return $this->show_no_permission();
     }
     // Delete and redirect
     $field->delete();
     if ($this->is_api) {
         return \API::response(1);
     } else {
         Request::redirectTo($this->project->href('settings/custom_fields'));
     }
 }
示例#4
0
 /**
  * Returns the content for the ticket listing headers.
  *
  * @param string $column The column to get the content for.
  *
  * @return mixed
  */
 public static function headerFor($column)
 {
     switch ($column) {
         case 'ticket_id':
             return Language::translate('id');
             break;
         case 'summary':
         case 'status':
         case 'owner':
         case 'type':
         case 'component':
         case 'milestone':
         case 'version':
         case 'assigned_to':
         case 'updates':
         case 'votes':
         case 'priority':
         case 'severity':
             return Language::translate($column);
         case 'created_at':
             return Language::translate('created');
             break;
         case 'updated_at':
             return Language::translate('updated');
             break;
     }
     // If we're still here, it may be a custom field
     if ($column = CustomField::find($column)) {
         return $column->name;
     }
     // Nothing!
     return '';
 }