Since: 3.0.0
Author: Jack P.
Inheritance: extends Traq\Models\Model
コード例 #1
0
ファイル: TicketFilters.php プロジェクト: dasklney/traq
 /**
  * Returns an array of custom field ticket filters for the specified project.
  *
  * @param Project $project
  *
  * @return array
  */
 public static function customFieldFiltersFor(Project $project)
 {
     static $filters = [];
     if (count($filters)) {
         return $filters;
     }
     foreach (CustomField::forProject($project->id) as $field) {
         $filters[$field->slug] = $field->name;
     }
     return $filters;
 }
コード例 #2
0
ファイル: TicketListing.php プロジェクト: nirix/traq
 /**
  * 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
ファイル: custom_fields.php プロジェクト: dasklney/traq
 /**
  * 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
ファイル: CustomFields.php プロジェクト: nirix/traq
 /**
  * Delete field.
  */
 public function destroyAction($id)
 {
     $field = CustomField::select()->where('id = ?')->andWhere('project_id = ?')->setParameter(0, $id)->setParameter(1, $this->currentProject['id'])->fetch();
     $field->delete();
     return $this->respondTo(function ($format) use($field) {
         if ($format == "html") {
             return $this->redirectTo('project_settings_custom_fields');
         } elseif ($format == "json") {
             return $this->jsonResponse(['deleted' => true, 'field' => $field->toArray()]);
         }
     });
 }
コード例 #5
0
ファイル: Ticketlist.php プロジェクト: dasklney/traq
 /**
  * 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 '';
 }
コード例 #6
0
ファイル: models.php プロジェクト: nirix/traq
function createCustomField($project = null)
{
    if (!$project) {
        $project = createProject();
    }
    $hash = mkRandomHash(5);
    $customField = new CustomField(['name' => $hash . '-name', 'slug' => $hash . '-slug', 'type' => 1, 'ticket_type_ids' => 0, 'project_id' => $project['id']]);
    $customField->save();
    return $customField;
}