/[drupal]/contributions/modules/project_issue_file_test/pift.admin.inc
ViewVC logotype

Contents of /contributions/modules/project_issue_file_test/pift.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.13 - (show annotations) (download) (as text)
Fri Oct 23 03:06:32 2009 UTC (4 weeks, 6 days ago) by boombatower
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-7--1
Changes since 1.12: +2 -1 lines
File MIME type: text/x-php
Add 8.x core API as an option.
1 <?php
2 // $Id: pift.admin.inc,v 1.12 2009/03/28 03:14:41 boombatower Exp $
3 /**
4 * @file
5 * Provide admin pages.
6 *
7 * Copyright 2008-2009 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)
8 */
9
10 /**
11 * PIFT settings.
12 */
13 function pift_admin_settings_form() {
14 $form = array();
15
16 $form['general'] = array(
17 '#type' => 'fieldset',
18 '#title' => t('General'),
19 );
20 $form['general']['pift_frequency'] = array(
21 '#type' => 'select',
22 '#title' => t('Send frequency'),
23 '#description' => t('Frequency at which test requests will be sent and test results retrieved.'),
24 '#options' => array(
25 -1 => t('Disabled'),
26 0 => t('Cron run'),
27 01 * 60 * 60 => t('Hourly'),
28 24 * 60 * 60 => t('Daily'),
29 ),
30 '#default_value' => PIFT_FREQUENCY,
31 '#required' => TRUE,
32 );
33 $form['general']['pift_key'] = array(
34 '#type' => 'textfield',
35 '#title' => t('Client key'),
36 '#description' => t('The key assigned to this client.'),
37 '#default_value' => PIFT_KEY,
38 '#required' => TRUE,
39 );
40 $form['general']['pift_server'] = array(
41 '#type' => 'textfield',
42 '#title' => t('Server URL'),
43 '#description' => t('The URL of the test server, include ending forward slash.'),
44 '#default_value' => PIFT_SERVER,
45 '#required' => TRUE,
46 );
47
48 $form['interface'] = array(
49 '#type' => 'fieldset',
50 '#title' => t('User interface'),
51 '#collapsible' => TRUE,
52 '#collapsed' => TRUE,
53 );
54 $form['interface']['pift_description'] = array(
55 '#type' => 'textarea',
56 '#title' => t('File description'),
57 '#description' => t('Additional text to be displayed on the project issue attachment fieldset.'),
58 '#default_value' => PIFT_DESCRIPTION,
59 );
60 $criteria = array(
61 t('The file has failed testing.'),
62 t('The issue the file is attached to is still passing the file testing criteria.'),
63 t('The file is the last testable file posted to the issue.'),
64 );
65 $form['interface']['pift_followup_fail'] = array(
66 '#type' => 'select',
67 '#title' => t('Followup issue status - fail'),
68 '#description' => t('The status to set an issue to when a test result meets all of the following criteria.' . theme('item_list', $criteria)),
69 '#default_value' => PIFT_FOLLOWUP_FAIL,
70 '#options' => project_issue_state(),
71 '#required' => TRUE,
72 );
73 $form['interface']['pift_followup_retest'] = array(
74 '#type' => 'select',
75 '#title' => t('Followup issue status - retest'),
76 '#description' => t('The status to set an issue to when someone requests a re-test and the issue currently does not fit the test criteria.'),
77 '#default_value' => PIFT_FOLLOWUP_RETEST,
78 '#options' => project_issue_state(),
79 '#required' => TRUE,
80 );
81
82 $form['criteria'] = array(
83 '#type' => 'fieldset',
84 '#title' => t('Criteria'),
85 '#collapsible' => TRUE,
86 '#collapsed' => TRUE,
87 );
88 $form['criteria']['pift_regex'] = array(
89 '#type' => 'textfield',
90 '#title' => t('File regex'),
91 '#description' => t('Full regex pattern that a filename must match for the file to be tested.'),
92 '#default_value' => PIFT_REGEX,
93 '#required' => TRUE,
94 );
95 $form['criteria']['pift_status'] = array(
96 '#type' => 'select',
97 '#multiple' => TRUE,
98 '#title' => t('Issue statuses'),
99 '#description' => t('List of issue statuses that an issue must belong to one of in order to test files.'),
100 '#default_value' => variable_get('pift_status', array()),
101 '#options' => project_issue_state(),
102 '#required' => TRUE,
103 );
104 $form['criteria']['pift_core'] = array(
105 '#type' => 'checkboxes',
106 '#title' => t('Core branches'),
107 '#description' => t('Drupal core branches that are to be tested. Issues pertaining to them will have files tested.'),
108 '#options' => array(
109 6 => t('6.x'),
110 7 => t('7.x'),
111 8 => t('8.x'),
112 ),
113 '#default_value' => variable_get('pift_core', array()),
114 );
115
116 $form['advanced'] = array(
117 '#type' => 'fieldset',
118 '#title' => t('Advanced'),
119 '#collapsible' => TRUE,
120 '#collapsed' => TRUE,
121 );
122 $project = node_load(PIFT_PID);
123 $form['advanced']['pift_pid'] = array(
124 '#type' => 'textfield',
125 '#title' => t('Core'),
126 '#description' => t('Project that contains the core code required by modules to function.'),
127 '#autocomplete_path' => 'project/autocomplete/issue/project',
128 '#default_value' => ($project ? $project->title : ''),
129 '#required' => TRUE,
130 );
131 $form['advanced']['pift_retest'] = array(
132 '#type' => 'select',
133 '#title' => t('Re-test interval'),
134 '#description' => t('Number of days to wait before re-testing a previously passed file.'),
135 '#options' => array(
136 -1,
137 24 * 60 * 60,
138 48 * 60 * 60,
139 72 * 60 * 60,
140 96 * 60 * 60,
141 ),
142 '#default_value' => PIFT_RETEST,
143 '#element_validate' => array('pift_is_numeric_validate'),
144 '#required' => TRUE,
145 );
146 $form['advanced']['pift_retest']['#options'] = drupal_map_assoc($form['advanced']['pift_retest']['#options'], 'format_interval');
147 $form['advanced']['pift_retest']['#options'][-1] = t('Disabled');
148
149 $form['#submit'] = array('pift_admin_settings_form_submit');
150 return system_settings_form($form);
151 }
152
153 /**
154 * Validate general settings.
155 */
156 function pift_admin_settings_form_validate($form, &$form_state) {
157 if (drupal_strlen($form_state['values']['pift_key']) != 32) {
158 form_set_error('client_key', t('Key must be 32 characters long.'));
159 }
160
161 if (!$form_state['values']['pift_server'] || !@parse_url($form_state['values']['pift_server'])) {
162 form_set_error('pift_server', t('Server URL must be a complete URL, schema included.'));
163 }
164 else if (drupal_substr($form_state['values']['pift_server'],
165 drupal_strlen($form_state['values']['pift_server']) - 1) != '/') {
166 form_set_error('pift_server', t('Server URL must end with a slash.'));
167 }
168 }
169
170 /**
171 * Query pid using project title.
172 */
173 function pift_admin_settings_form_submit($form, &$form_state) {
174 $form_state['values']['pift_pid'] = db_result(
175 db_query("SELECT nid
176 FROM {node}
177 WHERE title = '%s'
178 AND type = '%s'", $form_state['values']['pift_pid'], 'project_project')
179 );
180 }

  ViewVC Help
Powered by ViewVC 1.1.2