Passed
Pull Request — master (#6441)
by
unknown
09:23
created
drupal/sites/default/boinc/modules/boincwork/boincwork.admin.inc 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -10,80 +10,80 @@  discard block
 block discarded – undo
10 10
  * Allow configuration of general options for preference pages
11 11
  */
12 12
 function boincwork_admin_prefs_options_form(&$form_state) {
13
-  $form = array();
14
-  $form['beta'] = array(
13
+    $form = array();
14
+    $form['beta'] = array(
15 15
     '#type' => 'checkbox',
16 16
     '#title' => t('Allow users to opt in to test beta applications'),
17 17
     '#default_value' => variable_get('boinc_prefs_options_beta', 0),
18 18
     '#required' => TRUE
19
-  );
20
-  $form['submit'] = array(
19
+    );
20
+    $form['submit'] = array(
21 21
     '#type' => 'submit',
22 22
     '#value' => t('Submit')
23
-  );
24
-  // Add the official mechanical things and return
25
-  //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
26
-  return $form;
23
+    );
24
+    // Add the official mechanical things and return
25
+    //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
26
+    return $form;
27 27
 }
28 28
 
29 29
 /**
30
-  * Handle validation of preference general settings form.
31
-  */
30
+ * Handle validation of preference general settings form.
31
+ */
32 32
 function boincwork_admin_prefs_options_form_validate($form, &$form_state) {
33 33
 }
34 34
 
35 35
 /**
36
-  * Handle submission of preference general settings form.
37
-  */
36
+ * Handle submission of preference general settings form.
37
+ */
38 38
 function boincwork_admin_prefs_options_form_submit($form, &$form_state) {
39
-  variable_set('boinc_prefs_options_beta', $form_state['values']['beta']);
40
-  drupal_set_message('Preference options have been updated.');
39
+    variable_set('boinc_prefs_options_beta', $form_state['values']['beta']);
40
+    drupal_set_message('Preference options have been updated.');
41 41
 }
42 42
 
43 43
 /**
44 44
  *
45 45
  */
46 46
 function boincwork_admin_prefs_upload_form(&$form_state) {
47
-  $form = array();
48
-  $form['prefs_xml'] = array(
47
+    $form = array();
48
+    $form['prefs_xml'] = array(
49 49
     '#type' => 'textarea',
50 50
     '#title' => t('Project specific preferences XML'),
51 51
     '#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"),
52 52
     '#required' => TRUE
53
-  );
54
-  $form['submit'] = array(
53
+    );
54
+    $form['submit'] = array(
55 55
     '#type' => 'submit',
56 56
     '#value' => t('Submit')
57
-  );
58
-  // Add the official mechanical things and return
59
-  //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
60
-  return $form;
57
+    );
58
+    // Add the official mechanical things and return
59
+    //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
60
+    return $form;
61 61
 }
62 62
 
63 63
 /**
64
-  * Handle validation of preference upload form.
65
-  */
64
+ * Handle validation of preference upload form.
65
+ */
66 66
 function boincwork_admin_prefs_upload_form_validate($form, &$form_state) {
67 67
 
68
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
69
-  libxml_use_internal_errors(true);
70
-  $xml = new DomDocument();
71
-  $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS);
72
-  if (!$xml->schemaValidate($xsd)) {
68
+    $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
69
+    libxml_use_internal_errors(true);
70
+    $xml = new DomDocument();
71
+    $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS);
72
+    if (!$xml->schemaValidate($xsd)) {
73 73
     $errors = libxml_get_errors();
74 74
     $lines = explode("\r", $form_state['values']['prefs_xml']);
75 75
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
76
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
76
+        ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
77 77
     form_set_error('upload', t('XML file failed validation'));
78
-  }
78
+    }
79 79
 }
80 80
 
81 81
 /**
82
-  * Handle submission of preference upload form.
83
-  */
82
+ * Handle submission of preference upload form.
83
+ */
84 84
 function boincwork_admin_prefs_upload_form_submit($form, &$form_state) {
85
-  variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']);
86
-  drupal_set_message('The XML has been validated and any changes to
85
+    variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']);
86
+    drupal_set_message('The XML has been validated and any changes to
87 87
       preferences are now in place.');
88 88
 }
89 89
 
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
  *
92 92
  */
93 93
 function boincwork_admin_prefs_presets_page($preset = 'standard') {
94
-  // Configure preference presets
95
-  if (function_exists('jump_quickly')) {
94
+    // Configure preference presets
95
+    if (function_exists('jump_quickly')) {
96 96
     $path = 'admin/boinc/prefs/presets';
97 97
     $preset_options = array(
98
-      "{$path}/standard" => t('Standard'),
99
-      "{$path}/maximum" => t('Maximum'),
100
-      "{$path}/green" => t('Green'),
101
-      "{$path}/minimum" => t('Minimum')
98
+        "{$path}/standard" => t('Standard'),
99
+        "{$path}/maximum" => t('Maximum'),
100
+        "{$path}/green" => t('Green'),
101
+        "{$path}/minimum" => t('Minimum')
102 102
     );
103 103
     variable_set('jump_use_js_presets-Array', 1);
104 104
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
     $output .= '<label>Preset:</label>';
107 107
     $output .= jump_quickly($preset_options, 'presets');
108 108
     $output .= '</div></div>';
109
-  }
110
-  $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset);
111
-
112
-  $output .= '<div>';
113
-  $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets');
114
-  $output .= '<p>';
115
-  $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets');
116
-  $output .= '</div>';
117
-  return $output;
109
+    }
110
+    $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset);
111
+
112
+    $output .= '<div>';
113
+    $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets');
114
+    $output .= '<p>';
115
+    $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets');
116
+    $output .= '</div>';
117
+    return $output;
118 118
 }
119 119
 
120 120
 /**
@@ -122,141 +122,141 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function boincwork_admin_prefs_presets_form(&$form_state, $preset = 'standard') {
124 124
 
125
-  // Check database for preset prefs
126
-  if (!variable_get('boincwork_preset_prefs', null))
125
+    // Check database for preset prefs
126
+    if (!variable_get('boincwork_preset_prefs', null))
127 127
     drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), NULL, 'boinc:admin-boinc-preference-presets'), 'status');
128 128
 
129
-  // Load a copy of the general prefs form
130
-  $form = boincwork_generalprefs_form($form_state, NULL, $preset);
131
-  if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) {
129
+    // Load a copy of the general prefs form
130
+    $form = boincwork_generalprefs_form($form_state, NULL, $preset);
131
+    if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) {
132 132
     unset($form['#submit'][$key]);
133
-  }
134
-  $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit';
135
-
136
-  // Just keep the necessary items
137
-  $form['processor'] = $form['prefs']['advanced']['processor'];
138
-  $form['storage'] = $form['prefs']['advanced']['storage'];
139
-  $form['network'] = $form['prefs']['advanced']['network'];
140
-  unset($form['prefs']);
141
-
142
-  // Tweak some things so it behaves a little better
143
-  $form['#tree'] = TRUE;
144
-  $form['processor']['#collapsible'] = TRUE;
145
-  $form['storage']['#collapsible'] = TRUE;
146
-  $form['network']['#collapsible'] = TRUE;
147
-
148
-  // Add a submit button and a hidden field to pass the preset
149
-  $form['submit'] = array(
133
+    }
134
+    $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit';
135
+
136
+    // Just keep the necessary items
137
+    $form['processor'] = $form['prefs']['advanced']['processor'];
138
+    $form['storage'] = $form['prefs']['advanced']['storage'];
139
+    $form['network'] = $form['prefs']['advanced']['network'];
140
+    unset($form['prefs']);
141
+
142
+    // Tweak some things so it behaves a little better
143
+    $form['#tree'] = TRUE;
144
+    $form['processor']['#collapsible'] = TRUE;
145
+    $form['storage']['#collapsible'] = TRUE;
146
+    $form['network']['#collapsible'] = TRUE;
147
+
148
+    // Add a submit button and a hidden field to pass the preset
149
+    $form['submit'] = array(
150 150
     '#type' => 'submit',
151 151
     '#value' => t('Save configuration')
152
-  );
153
-  $form['saveuseconfigxml'] = array (
154
-      '#type' => 'submit',
155
-      '#value' => t('Save configuration with disk usage settings from config.xml'),
156
-      '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'),
157
-  );
158
-  $form['preset'] = array(
152
+    );
153
+    $form['saveuseconfigxml'] = array (
154
+        '#type' => 'submit',
155
+        '#value' => t('Save configuration with disk usage settings from config.xml'),
156
+        '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'),
157
+    );
158
+    $form['preset'] = array(
159 159
     '#type' => 'hidden',
160 160
     '#value' => $preset
161
-  );
161
+    );
162 162
 
163
-  // Add the official mechanical things and return
164
-  drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state);
165
-  return $form;
163
+    // Add the official mechanical things and return
164
+    drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state);
165
+    return $form;
166 166
 }
167 167
 
168 168
 /**
169
-  * Validate the preference presets form.
170
-  */
169
+ * Validate the preference presets form.
170
+ */
171 171
 function boincwork_admin_prefs_presets_form_validate($form, &$form_state) {
172
-  require_boinc('util');
173
-  $values = $form_state['values'];
174
-
175
-  // Verify all non-boolean user input values and notify form API of failures
176
-
177
-  // Processing preferences
178
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\"");
179
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\"");
180
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\"");
181
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\"");
182
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\"");
183
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\"");
184
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\"");
185
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\"");
186
-
187
-  // Storage preferences
188
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\"");
189
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\"");
190
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\"");
191
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\"");
192
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\"");
193
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\"");
194
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\"");
195
-
196
-  // Network preferences
197
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\"");
198
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\"");
199
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\"");
200
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\"");
201
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\"");
202
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\"");
203
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
204
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
172
+    require_boinc('util');
173
+    $values = $form_state['values'];
174
+
175
+    // Verify all non-boolean user input values and notify form API of failures
176
+
177
+    // Processing preferences
178
+    if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\"");
179
+    if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\"");
180
+    if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\"");
181
+    if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\"");
182
+    if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\"");
183
+    if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\"");
184
+    if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\"");
185
+    if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\"");
186
+
187
+    // Storage preferences
188
+    if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\"");
189
+    if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\"");
190
+    if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\"");
191
+    if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\"");
192
+    if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\"");
193
+    if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\"");
194
+    if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\"");
195
+
196
+    // Network preferences
197
+    if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\"");
198
+    if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\"");
199
+    if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\"");
200
+    if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\"");
201
+    if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\"");
202
+    if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\"");
203
+    if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
204
+    if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
205 205
 }
206 206
 
207 207
 /**
208
-  * Handle post-validation submission of preference presets form.
209
-  */
208
+ * Handle post-validation submission of preference presets form.
209
+ */
210 210
 function boincwork_admin_prefs_presets_form_submit($form, &$form_state) {
211
-  $values = $form_state['values'];
212
-  $preset = $form_state['values']['preset'];
213
-
214
-  // Load baseline settings from configuration
215
-  $prefs = boincwork_get_preset_prefs($preset);
216
-
217
-  // Processing preferences
218
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
219
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
220
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1;
221
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
222
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
223
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
224
-  $prefs['start_hour'] = $values['processor']['start_hour'];
225
-  $prefs['end_hour'] = $values['processor']['end_hour'];
226
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
227
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
228
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
229
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
230
-
231
-  // Storage preferences
232
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
233
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
234
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
235
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
236
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
237
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
238
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
239
-
240
-  // Network preferences
241
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
242
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
243
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
244
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
245
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
246
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
247
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
248
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
249
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
250
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
251
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
252
-
253
-  //Remove @attributes to match new format (see boincwork.forms.inc
254
-  //function boincwork_generalprefs_form)
255
-  unset($prefs['@attributes']['preset']);
256
-
257
-  // Update the configuration
258
-  boincwork_save_preset_prefs($prefs, $preset);
259
-  drupal_set_message(t('The "@name" preset has been updated.',
211
+    $values = $form_state['values'];
212
+    $preset = $form_state['values']['preset'];
213
+
214
+    // Load baseline settings from configuration
215
+    $prefs = boincwork_get_preset_prefs($preset);
216
+
217
+    // Processing preferences
218
+    $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
219
+    $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
220
+    $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1;
221
+    $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
222
+    $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
223
+    $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
224
+    $prefs['start_hour'] = $values['processor']['start_hour'];
225
+    $prefs['end_hour'] = $values['processor']['end_hour'];
226
+    $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
227
+    $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
228
+    $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
229
+    $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
230
+
231
+    // Storage preferences
232
+    $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
233
+    $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
234
+    $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
235
+    $prefs['disk_interval'] = $values['storage']['disk_interval'];
236
+    $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
237
+    $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
238
+    $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
239
+
240
+    // Network preferences
241
+    $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
242
+    $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
243
+    $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
244
+    $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
245
+    $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
246
+    $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
247
+    $prefs['net_start_hour'] = $values['network']['net_start_hour'];
248
+    $prefs['net_end_hour'] = $values['network']['net_end_hour'];
249
+    $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
250
+    $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
251
+    $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
252
+
253
+    //Remove @attributes to match new format (see boincwork.forms.inc
254
+    //function boincwork_generalprefs_form)
255
+    unset($prefs['@attributes']['preset']);
256
+
257
+    // Update the configuration
258
+    boincwork_save_preset_prefs($prefs, $preset);
259
+    drupal_set_message(t('The "@name" preset has been updated.',
260 260
     array('@name' => $preset)));
261 261
 }
262 262
 
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
  */
266 266
 function boincwork_save_preset_prefs($updated_prefs, $preset = 'standard') {
267 267
 
268
-  // Get the full configuration
269
-  $all_presets = boincwork_get_preset_prefs();
270
-  $all_presets = (array) $all_presets['general_preferences'];
268
+    // Get the full configuration
269
+    $all_presets = boincwork_get_preset_prefs();
270
+    $all_presets = (array) $all_presets['general_preferences'];
271 271
 
272
-  // Check for sane config
273
-  if (isset($all_presets['preset'])) {
272
+    // Check for sane config
273
+    if (isset($all_presets['preset'])) {
274 274
     if (!is_numeric(key($all_presets['preset']))) {
275
-      $all_presets['preset'] = array($all_presets['preset']);
275
+        $all_presets['preset'] = array($all_presets['preset']);
276 276
     }
277 277
     foreach ($all_presets['preset'] as $key => $old_preset) {
278
-      // Find the preset being updated and... update it
279
-      if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) {
278
+        // Find the preset being updated and... update it
279
+        if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) {
280 280
         $all_presets['preset'][$key] = $updated_prefs + $old_preset;
281
-      }
281
+        }
282
+    }
282 283
     }
283
-  }
284 284
 
285
-  // Convert prefs back to XML and save to database
286
-  $all_presets = array('general_preferences' => $all_presets);
287
-  variable_set('boincwork_preset_prefs', save_configuration($all_presets));
285
+    // Convert prefs back to XML and save to database
286
+    $all_presets = array('general_preferences' => $all_presets);
287
+    variable_set('boincwork_preset_prefs', save_configuration($all_presets));
288 288
 }
289 289
 
290 290
 /**
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam.module 1 patch
Indentation   +574 added lines, -574 removed lines patch added patch discarded remove patch
@@ -26,82 +26,82 @@  discard block
 block discarded – undo
26 26
  * Implementation of hook_menu()
27 27
  */
28 28
 function boincteam_menu() {
29
-  $items = array();
30
-  $items['community/teams/%/assume-foundership'] = array(
29
+    $items = array();
30
+    $items['community/teams/%/assume-foundership'] = array(
31 31
     'page callback' => 'boincteam_assume_foundership',
32 32
     'page arguments' => array(2),
33 33
     'access callback' => 'boincteam_is_member',
34 34
     'access arguments' => array(2),
35 35
     'type' => MENU_CALLBACK
36
-  );
37
-  $items['community/teams/%/join'] = array(
36
+    );
37
+    $items['community/teams/%/join'] = array(
38 38
     'page callback' => 'boincteam_join',
39 39
     'page arguments' => array(2),
40 40
     'access arguments' => array('join boincteam'),
41 41
     'type' => MENU_CALLBACK
42
-  );
43
-  $items['community/teams/%/leave'] = array(
42
+    );
43
+    $items['community/teams/%/leave'] = array(
44 44
     'page callback' => 'boincteam_leave',
45 45
     'page arguments' => array(2),
46 46
     'access arguments' => array('join boincteam'),
47 47
     'type' => MENU_CALLBACK
48
-  );
49
-  $items['community/teams/%/delete'] = array(
48
+    );
49
+    $items['community/teams/%/delete'] = array(
50 50
     'page callback' => 'boincteam_delete',
51 51
     'page arguments' => array(2),
52 52
     'access callback' => 'boincteam_is_founder',
53 53
     'access arguments' => array(2),
54 54
     'type' => MENU_CALLBACK
55
-  );
56
-  $items['community/teams/%/deny-foundership-request'] = array(
55
+    );
56
+    $items['community/teams/%/deny-foundership-request'] = array(
57 57
     'page callback' => 'boincteam_deny_foundership_request',
58 58
     'page arguments' => array(2),
59 59
     'access callback' => 'boincteam_is_founder',
60 60
     'access arguments' => array(2),
61 61
     'type' => MENU_CALLBACK
62
-  );
63
-  $items['community/teams/%/edit/admins/remove/%'] = array(
62
+    );
63
+    $items['community/teams/%/edit/admins/remove/%'] = array(
64 64
     'page callback' => 'boincteam_remove_admin',
65 65
     'page arguments' => array(2,6),
66 66
     'access callback' => 'boincteam_is_founder',
67 67
     'access arguments' => array(2),
68 68
     'type' => MENU_CALLBACK
69
-  );
70
-  $items['community/teams/%/edit/founder/set/%'] = array(
69
+    );
70
+    $items['community/teams/%/edit/founder/set/%'] = array(
71 71
     'page callback' => 'boincteam_set_founder',
72 72
     'page arguments' => array(2,6),
73 73
     'access callback' => 'boincteam_is_founder',
74 74
     'access arguments' => array(2),
75 75
     'type' => MENU_CALLBACK
76
-  );
77
-  $items['community/teams/%/edit/members/remove/%'] = array(
76
+    );
77
+    $items['community/teams/%/edit/members/remove/%'] = array(
78 78
     'page callback' => 'boincteam_remove_member',
79 79
     'page arguments' => array(2,6),
80 80
     'access callback' => 'boincteam_is_founder',
81 81
     'access arguments' => array(2),
82 82
     'type' => MENU_CALLBACK
83
-  );
84
-  $items['community/teams/%/history/xml'] = array(
83
+    );
84
+    $items['community/teams/%/history/xml'] = array(
85 85
     'page callback' => 'boincteam_history_xml',
86 86
     'page arguments' => array(2),
87 87
     'access callback' => 'boincteam_is_admin',
88 88
     'access arguments' => array(2),
89 89
     'type' => MENU_CALLBACK
90
-  );
91
-  $items['community/teams/%/request-foundership'] = array(
90
+    );
91
+    $items['community/teams/%/request-foundership'] = array(
92 92
     'page callback' => 'boincteam_request_foundership',
93 93
     'page arguments' => array(2),
94 94
     'access callback' => 'boincteam_is_member',
95 95
     'access arguments' => array(2),
96 96
     'type' => MENU_CALLBACK
97
-  );
98
-  $items['community/teams/%/user-name-autocomplete'] = array(
97
+    );
98
+    $items['community/teams/%/user-name-autocomplete'] = array(
99 99
     'page callback' => '_boincuser_user_name_autocomplete',
100 100
     'access callback' => 'boincteam_is_founder',
101 101
     'access arguments' => array(2),
102 102
     'type' => MENU_CALLBACK,
103
-  );
104
-  $items['community/teams/%/message-all-members'] = array(
103
+    );
104
+    $items['community/teams/%/message-all-members'] = array(
105 105
     'title' => bts('Send Message to Team', array(), NULL, 'boinc:team-manage'),
106 106
     'description' => bts('Send Message to Team', array(), NULL, 'boinc:team-manage'),
107 107
     'page callback' => 'drupal_get_form',
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
     'access callback' => 'boincteam_is_admin',
110 110
     'access arguments' => array(2),
111 111
     'type' => MENU_CALLBACK,
112
-  );
113
-  $items['admin/boinc/utility-team-delete'] = array(
112
+    );
113
+    $items['admin/boinc/utility-team-delete'] = array(
114 114
     'title' => 'Utility: Delete SPAM Teams',
115 115
     'description' => 'Utililities to help delete BOINC teams created by SPAMMERs.',
116 116
     'page callback' => 'drupal_get_form',
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     'access arguments' => array('administer site configuration'),
119 119
     'type' => MENU_NORMAL_ITEM,
120 120
     'file' => 'boincteam.admin.inc',
121
-  );
121
+    );
122 122
 
123
-  return $items;
123
+    return $items;
124 124
 }
125 125
 
126 126
 /**
@@ -137,41 +137,41 @@  discard block
 block discarded – undo
137 137
 
138 138
   See https://www.drupal.org/node/945102
139 139
 */
140
-  return array(
140
+    return array(
141 141
     'boincteam_utility_team_table' => array(
142
-      'arguments' => array('form' => NULL),
143
-      'file' => 'boincteam.admin.inc',
142
+        'arguments' => array('form' => NULL),
143
+        'file' => 'boincteam.admin.inc',
144 144
     ),
145
-  );
145
+    );
146 146
 }
147 147
 
148 148
 /**
149 149
 * Implementation of hook_views_api().
150 150
 */
151 151
 function boincteam_views_api() {
152
-  return array(
152
+    return array(
153 153
     'api' => 2.0,
154 154
     'path' => drupal_get_path('module', 'boincteam')
155
-  );
155
+    );
156 156
 }
157 157
 
158 158
 /**
159 159
  * Implementation of hook_perm()
160 160
  */
161 161
 function boincteam_perm() {
162
-  return array('join boincteam', 'create boincteam', 'manage boincteam');
162
+    return array('join boincteam', 'create boincteam', 'manage boincteam');
163 163
 }
164 164
 
165 165
 /**
166 166
  * Implementation of hook_cron()
167 167
  */
168 168
 function boincteam_cron() {
169
-  // Sync teams from BOINC DB every day to catch BOINC-wide team updates
170
-  $last_sync = variable_get('boincteam_last_sync', 0);
171
-  if ($last_sync < time() - 24*60*60) {
169
+    // Sync teams from BOINC DB every day to catch BOINC-wide team updates
170
+    $last_sync = variable_get('boincteam_last_sync', 0);
171
+    if ($last_sync < time() - 24*60*60) {
172 172
     boincteam_sync();
173 173
     variable_set('boincteam_last_sync', time());
174
-  }
174
+    }
175 175
 }
176 176
 
177 177
 /**
@@ -185,41 +185,41 @@  discard block
 block discarded – undo
185 185
 * Implementation of hook_views_pre_execute().
186 186
 */
187 187
 function boincteam_views_pre_execute(&$view) {
188
-  /* Specific boinc_teams sub-views use the boinc readonly replica
188
+    /* Specific boinc_teams sub-views use the boinc readonly replica
189 189
    * DB. These sub-views defined below by their title. If additional
190 190
    * sub-views need to be added, add their title to the list of cases
191 191
    * below. If a sub-view needs to be reverted to use the master DB,
192 192
    * then remove it from the list of cases.
193 193
    */
194
-  if ($view->name == 'boinc_teams') {
194
+    if ($view->name == 'boinc_teams') {
195 195
     switch ($view->display[$view->current_display]->display_title) {
196 196
     case 'Top teams overview pane':
197 197
     case 'Top teams pane':
198 198
     case 'Page':
199 199
       $view->base_database = 'boinc_ro';
200 200
     }
201
-  }
201
+    }
202 202
 }
203 203
 
204 204
 /**
205 205
  * Implementation of hook_cron_queue_info()
206 206
  */
207 207
 function boincteam_cron_queue_info() {
208
-  $queues = array();
209
-  $queues['queue_teamdelete'] = array(
208
+    $queues = array();
209
+    $queues['queue_teamdelete'] = array(
210 210
     'worker callback' => 'boincteam_delete',
211 211
     'time' => 60,
212
-  );
212
+    );
213 213
 }
214 214
 
215 215
 /**
216 216
  * Implementation of hook_mail_alter()
217 217
  */
218 218
 function boincteam_mail_alter(&$message) {
219
-  if (isset($message['params']['boincteam_headers'])) {
219
+    if (isset($message['params']['boincteam_headers'])) {
220 220
     $message['headers']['Bcc'] = $message['params']['boincteam_headers']['Bcc'];
221 221
     $message['to'] = '';
222
-  }
222
+    }
223 223
 }
224 224
 
225 225
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -231,49 +231,49 @@  discard block
 block discarded – undo
231 231
  * assume the role of founder
232 232
  */
233 233
 function boincteam_assume_foundership($team_id) {
234
-  global $user;
235
-  $account = user_load($user->uid);
236
-  $team = node_load($team_id);
237
-  $boincteam_id = boincteam_lookup_id($team_id);
238
-  $boincteam = boincteam_load($boincteam_id);
239
-  $boincuser_id = $account->boincuser_id;
240
-
241
-  if (boincteam_foundership_transfer_ok($boincteam)) {
234
+    global $user;
235
+    $account = user_load($user->uid);
236
+    $team = node_load($team_id);
237
+    $boincteam_id = boincteam_lookup_id($team_id);
238
+    $boincteam = boincteam_load($boincteam_id);
239
+    $boincuser_id = $account->boincuser_id;
240
+
241
+    if (boincteam_foundership_transfer_ok($boincteam)) {
242 242
     if ($boincuser_id == $boincteam->ping_user) {
243
-      db_set_active('boinc_rw');
244
-      db_query("
243
+        db_set_active('boinc_rw');
244
+        db_query("
245 245
         UPDATE {team}
246 246
         SET userid = '%d', ping_user = '0', ping_time = '0'
247 247
         WHERE id = '%d'",
248 248
         $boincuser_id, $boincteam_id
249
-      );
250
-      db_set_active('default');
251
-      drupal_set_message(t('You are now the founder of @team', array(
249
+        );
250
+        db_set_active('default');
251
+        drupal_set_message(t('You are now the founder of @team', array(
252 252
         '@team' => $team->title
253
-      )));
254
-      watchdog('boincteam', 'User @user assumed foundership of team @nid',
253
+        )));
254
+        watchdog('boincteam', 'User @user assumed foundership of team @nid',
255 255
         array(
256
-          '@current_user' => $account->uid,
257
-          '@nid' => $team_id
256
+            '@current_user' => $account->uid,
257
+            '@nid' => $team_id
258 258
         ), WATCHDOG_NOTICE
259
-      );
259
+        );
260 260
     }
261
-  }
262
-  else {
261
+    }
262
+    else {
263 263
     drupal_set_message(t('You are not allowed to assume foundership of this
264 264
       team.'
265 265
     ));
266
-  }
267
-  drupal_goto("community/teams/{$team_id}");
266
+    }
267
+    drupal_goto("community/teams/{$team_id}");
268 268
 }
269 269
 
270 270
 /**
271 271
  * Delete the team, if empty
272 272
  */
273 273
 function boincteam_delete($team_id) {
274
-  $team = node_load($team_id);
275
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
276
-  if ($boincteam->nusers == 1) {
274
+    $team = node_load($team_id);
275
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
276
+    if ($boincteam->nusers == 1) {
277 277
     require_boinc('team');
278 278
     $boincuser = boincuser_load();
279 279
     user_quit_team($boincuser);
@@ -282,35 +282,35 @@  discard block
 block discarded – undo
282 282
     $team->uid = 0;
283 283
     node_save($team);
284 284
     drupal_set_message(t('@team has been removed.',
285
-      array('@team' => $boincteam->name)));
285
+        array('@team' => $boincteam->name)));
286 286
     drupal_goto('community/teams');
287
-  }
288
-  else {
287
+    }
288
+    else {
289 289
     drupal_set_message(t('All members must be removed from @team before the
290 290
       team can be deleted.', array('@team' => $boincteam->name)), 'error');
291 291
     drupal_goto(strstr($_GET['q'], '/delete', TRUE));
292
-  }
292
+    }
293 293
 }
294 294
 
295 295
 /**
296 296
  * Deny a foundership transfer request
297 297
  */
298 298
 function boincteam_deny_foundership_request($team_id) {
299
-  $boincteam_id = boincteam_lookup_id($team_id);
300
-  // Remove the request from the BOINC database
301
-  db_set_active('boinc_rw');
302
-  db_query("
299
+    $boincteam_id = boincteam_lookup_id($team_id);
300
+    // Remove the request from the BOINC database
301
+    db_set_active('boinc_rw');
302
+    db_query("
303 303
     UPDATE {team}
304 304
     SET ping_user=0
305 305
     WHERE id = '%d'",
306 306
     $boincteam_id
307
-  );
308
-  db_set_active('default');
307
+    );
308
+    db_set_active('default');
309 309
 
310
-  drupal_set_message(t('The transfer request has been denied. No additional
310
+    drupal_set_message(t('The transfer request has been denied. No additional
311 311
     requests will be allowed until 90 days have passed since this request was
312 312
     made.'));
313
-  drupal_goto("community/teams/{$team_id}/edit/founder");
313
+    drupal_goto("community/teams/{$team_id}/edit/founder");
314 314
 }
315 315
 
316 316
 
@@ -318,62 +318,62 @@  discard block
 block discarded – undo
318 318
  * Get the join date of a user
319 319
  */
320 320
 function boincteam_get_member_join_date($boincteam_id, $boincuser_id = NULL) {
321
-  if (!$boincuser_id) {
321
+    if (!$boincuser_id) {
322 322
     global $user;
323 323
     $account = user_load($user->uid);
324 324
     $boincuser_id = $account->boincuser_id;
325
-  }
326
-  db_set_active('boinc_rw');
327
-  $timestamp = db_result(db_query("
325
+    }
326
+    db_set_active('boinc_rw');
327
+    $timestamp = db_result(db_query("
328 328
     SELECT timestamp FROM {team_delta} WHERE
329 329
     userid = %d AND teamid = %d AND joining = 1
330 330
     ORDER BY timestamp DESC LIMIT 1",
331 331
     $boincuser_id, $boincteam_id
332
-  ));
333
-  db_set_active('default');
334
-  return $timestamp;
332
+    ));
333
+    db_set_active('default');
334
+    return $timestamp;
335 335
 }
336 336
 
337 337
 /**
338 338
  * Get the team type for display
339 339
  */
340 340
 function boincteam_get_type($team_id) {
341
-  //$vid = boincteam_get_vocabulary_by_name('Teams'); $team->vid = $vid;
342
-  $team = node_load($team_id);
343
-  $terms = taxonomy_node_get_terms($team);
344
-  if ($terms) {
341
+    //$vid = boincteam_get_vocabulary_by_name('Teams'); $team->vid = $vid;
342
+    $team = node_load($team_id);
343
+    $terms = taxonomy_node_get_terms($team);
344
+    if ($terms) {
345 345
     $term = reset($terms);
346 346
     return $term->name;
347
-  } else {
347
+    } else {
348 348
     return null;
349
-  }
349
+    }
350 350
 }
351 351
 
352 352
 /**
353 353
  * Access a vocabulary of terms by name
354 354
  */
355 355
 function boincteam_get_vocabulary_by_name($name) {
356
-  $vocabs = taxonomy_get_vocabularies('team');
357
-  foreach ($vocabs as $vocab) {
356
+    $vocabs = taxonomy_get_vocabularies('team');
357
+    foreach ($vocabs as $vocab) {
358 358
     if ($vocab->name == $name) return $vocab->vid;
359
-  }
360
-  return null;
359
+    }
360
+    return null;
361 361
 }
362 362
 
363 363
 /**
364 364
  * Output the XML of the team history
365 365
  */
366 366
 function boincteam_history_xml($team_id) {
367
-  $team = node_load($team_id);
368
-  $boincteam_id = boincteam_lookup_id($team_id);
369
-  $team_history = array(
367
+    $team = node_load($team_id);
368
+    $boincteam_id = boincteam_lookup_id($team_id);
369
+    $team_history = array(
370 370
     'actions' => array(
371
-      'action' => array(),
371
+        'action' => array(),
372 372
     ),
373
-  );
373
+    );
374 374
 
375
-  db_set_active('boinc_rw');
376
-  $result = db_query("
375
+    db_set_active('boinc_rw');
376
+    $result = db_query("
377 377
     SELECT
378 378
       td.userid AS id,
379 379
       u.name,
@@ -385,40 +385,40 @@  discard block
 block discarded – undo
385 385
     WHERE td.teamid = %d
386 386
     ORDER BY timestamp ASC",
387 387
     $boincteam_id
388
-  );
389
-  db_set_active('default');
388
+    );
389
+    db_set_active('default');
390 390
 
391
-  while ($record = db_fetch_array($result)) {
391
+    while ($record = db_fetch_array($result)) {
392 392
     $team_history['actions']['action'][] = $record;
393
-  }
393
+    }
394 394
 
395
-  header('Content-type: text/xml');
396
-  echo xml_to_text(array_to_xml($team_history));
395
+    header('Content-type: text/xml');
396
+    echo xml_to_text(array_to_xml($team_history));
397 397
 }
398 398
 
399 399
 /**
400 400
  * Convert a BOINC team ID to a Drupal team ID
401 401
  */
402 402
 function boincteam_lookup_nid($boinc_id) {
403
-  $drupal_id = db_result(db_query("SELECT nid FROM {boincteam} WHERE team_id='%d'", $boinc_id));
404
-  return $drupal_id;
403
+    $drupal_id = db_result(db_query("SELECT nid FROM {boincteam} WHERE team_id='%d'", $boinc_id));
404
+    return $drupal_id;
405 405
 }
406 406
 
407 407
 /**
408 408
  * Convert a Drupal team ID to a BOINC team ID
409 409
  */
410 410
 function boincteam_lookup_id($nid) {
411
-  $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = '%d'", $nid));
412
-  return $boinc_id;
411
+    $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = '%d'", $nid));
412
+    return $boinc_id;
413 413
 }
414 414
 
415 415
 /**
416 416
  * Get a BOINC team object
417 417
  */
418 418
 function boincteam_load($boincteam_id, $full_object = FALSE) {
419
-  require_boinc(array('team'));
420
-  $team = BoincTeam::lookup_id($boincteam_id);
421
-  if ($team AND $full_object) {
419
+    require_boinc(array('team'));
420
+    $team = BoincTeam::lookup_id($boincteam_id);
421
+    if ($team AND $full_object) {
422 422
     $team->nusers = BoincUser::count("teamid={$team->id}");
423 423
     $team->nusers_worked = BoincUser::count("teamid={$team->id} and total_credit>0");
424 424
     $team->nusers_active = BoincUser::count("teamid={$team->id} and expavg_credit>0.1");
@@ -426,314 +426,314 @@  discard block
 block discarded – undo
426 426
     $team->new_members = new_member_list($boincteam_id);
427 427
     $team->admins = admin_list($boincteam_id);
428 428
     $team->founder = BoincUser::lookup_id($team->userid);
429
-  }
430
-  return $team;
429
+    }
430
+    return $team;
431 431
 }
432 432
 
433 433
 /**
434 434
  * Check if a user is the team founder
435 435
  */
436 436
 function boincteam_is_founder($nid, $uid = NULL) {
437
-  if (!$uid) {
437
+    if (!$uid) {
438 438
     global $user;
439 439
     $uid = $user->uid;
440
-  }
441
-  if (!boincteam_is_member($nid, $uid)) {
440
+    }
441
+    if (!boincteam_is_member($nid, $uid)) {
442 442
     return FALSE;
443
-  }
444
-  $team_id = boincteam_lookup_id($nid);
445
-  require_boinc('team');
446
-  return is_team_founder(boincuser_load($uid, TRUE), boincteam_load($team_id));
443
+    }
444
+    $team_id = boincteam_lookup_id($nid);
445
+    require_boinc('team');
446
+    return is_team_founder(boincuser_load($uid, TRUE), boincteam_load($team_id));
447 447
 }
448 448
 
449 449
 /**
450 450
  * Check if a user is a team admin
451 451
  */
452 452
 function boincteam_is_admin($nid, $uid = NULL) {
453
-  if (!$uid) {
453
+    if (!$uid) {
454 454
     global $user;
455 455
     $uid = $user->uid;
456
-  }
457
-  if (!boincteam_is_member($nid, $uid)) {
456
+    }
457
+    if (!boincteam_is_member($nid, $uid)) {
458 458
     return FALSE;
459
-  }
460
-  $team_id = boincteam_lookup_id($nid);
461
-  require_boinc('team');
462
-  return is_team_admin(boincuser_load($uid, TRUE), boincteam_load($team_id));
459
+    }
460
+    $team_id = boincteam_lookup_id($nid);
461
+    require_boinc('team');
462
+    return is_team_admin(boincuser_load($uid, TRUE), boincteam_load($team_id));
463 463
 }
464 464
 
465 465
 /**
466 466
  * Check if a user is a team member
467 467
  */
468 468
 function boincteam_is_member($nid, $uid = NULL) {
469
-  if (!$uid) {
469
+    if (!$uid) {
470 470
     global $user;
471 471
     $uid = $user->uid;
472
-  }
473
-  $account = user_load($uid);
474
-  return ($account->team == $nid);
472
+    }
473
+    $account = user_load($uid);
474
+    return ($account->team == $nid);
475 475
 }
476 476
 
477 477
 /**
478 478
  * Display any persistent team messages
479 479
  */
480 480
 function boincteam_show_messages() {
481
-  global $user;
482
-  $uid = $user->uid;
483
-  $account = user_load($uid);
484
-  if ($account->team) {
481
+    global $user;
482
+    $uid = $user->uid;
483
+    $account = user_load($uid);
484
+    if ($account->team) {
485 485
     if (boincteam_is_founder($account->team, $account->uid)) {
486
-      // Set a notice of any pending foundership requests
487
-      $boincteam_id = boincteam_lookup_id($account->team);
488
-      $boincteam = boincteam_load($boincteam_id);
489
-      if ($boincteam->ping_user > 0) {
486
+        // Set a notice of any pending foundership requests
487
+        $boincteam_id = boincteam_lookup_id($account->team);
488
+        $boincteam = boincteam_load($boincteam_id);
489
+        if ($boincteam->ping_user > 0) {
490 490
         $foundership_url = "community/teams/{$account->team}/edit/founder";
491 491
         if (substr($_GET['q'], 0, strlen($foundership_url)) != $foundership_url) {
492
-          drupal_set_message(
492
+            drupal_set_message(
493 493
             bts(
494
-              'A foundership transfer request has been made for your team. Please !respond.',
495
-              array('!respond' => l(bts('respond to the request', array(), NULL, 'boinc:team-founder-change'), $foundership_url)),
496
-              NULL, 'boinc:team-founder-change'),
494
+                'A foundership transfer request has been made for your team. Please !respond.',
495
+                array('!respond' => l(bts('respond to the request', array(), NULL, 'boinc:team-founder-change'), $foundership_url)),
496
+                NULL, 'boinc:team-founder-change'),
497 497
             'warning', FALSE
498
-          );
498
+            );
499
+        }
499 500
         }
500
-      }
501 501
     }
502
-  }
502
+    }
503 503
 }
504 504
 
505 505
 /**
506 506
  * Add a user to a team
507 507
  */
508 508
 function boincteam_join($team_id) {
509
-  global $user;
510
-  $account = user_load($user->uid);
509
+    global $user;
510
+    $account = user_load($user->uid);
511 511
 
512
-  $boincteam_id = boincteam_lookup_id($team_id);
513
-  $boincteam = boincteam_load($boincteam_id);
514
-  if ($boincteam->joinable AND $account->team != $team_id) {
512
+    $boincteam_id = boincteam_lookup_id($team_id);
513
+    $boincteam = boincteam_load($boincteam_id);
514
+    if ($boincteam->joinable AND $account->team != $team_id) {
515 515
     require_boinc('team');
516 516
     $boincuser = boincuser_load();
517 517
     if (user_join_team($boincteam, $boincuser)) {
518
-      drupal_set_message(t('You are now a member of @team!',
518
+        drupal_set_message(t('You are now a member of @team!',
519 519
         array('@team' => $boincteam->name)));
520
-      watchdog('boincteam', 'added user @uid to team @nid',
520
+        watchdog('boincteam', 'added user @uid to team @nid',
521 521
         array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_NOTICE);
522 522
     }
523 523
     else {
524
-      // @todo - consider another rule/error event here
525
-      drupal_set_message(t('There was a problem joining @team, please try again
524
+        // @todo - consider another rule/error event here
525
+        drupal_set_message(t('There was a problem joining @team, please try again
526 526
         later', array('@team' => $boincteam->name)));
527
-      watchdog('boincteam', 'error adding user @uid to team @nid',
527
+        watchdog('boincteam', 'error adding user @uid to team @nid',
528 528
         array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_ERROR);
529 529
     }
530
-  }
531
-  drupal_goto("community/teams/{$team_id}");
530
+    }
531
+    drupal_goto("community/teams/{$team_id}");
532 532
 }
533 533
 
534 534
 /**
535 535
  * Leave a team
536 536
  */
537 537
 function boincteam_leave($team_id) {
538
-  global $user;
539
-  $account = user_load($user->uid);
538
+    global $user;
539
+    $account = user_load($user->uid);
540 540
 
541
-  $boincteam_id = boincteam_lookup_id($team_id);
542
-  $boincteam = boincteam_load($boincteam_id);
543
-  if ($account->team == $team_id) {
541
+    $boincteam_id = boincteam_lookup_id($team_id);
542
+    $boincteam = boincteam_load($boincteam_id);
543
+    if ($account->team == $team_id) {
544 544
     require_boinc('team');
545 545
     $boincuser = boincuser_load();
546 546
     user_quit_team($boincuser);
547 547
     drupal_set_message(t('You are no longer a member of @team.',
548
-      array('@team' => $boincteam->name)));
548
+        array('@team' => $boincteam->name)));
549 549
     watchdog('boincteam', 'removed user @uid from team @nid',
550
-      array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_NOTICE);
551
-  }
552
-  else {
553
-      drupal_set_message(t('You are not a member of @team, so you cannot revoke
550
+        array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_NOTICE);
551
+    }
552
+    else {
553
+        drupal_set_message(t('You are not a member of @team, so you cannot revoke
554 554
         your membership to it.', array('@team' => $boincteam->name)));
555
-  }
556
-  drupal_goto("community/teams/{$team_id}");
555
+    }
556
+    drupal_goto("community/teams/{$team_id}");
557 557
 }
558 558
 
559 559
 /**
560 560
  * Remove team admin status from a user
561 561
  */
562 562
 function boincteam_remove_admin($team_id, $user_id) {
563
-  global $user;
564
-  $account = user_load($user_id);
565
-  $team = node_load($team_id);
566
-  $boincteam_id = boincteam_lookup_id($team_id);
567
-  $boincuser_id = $account->boincuser_id;
563
+    global $user;
564
+    $account = user_load($user_id);
565
+    $team = node_load($team_id);
566
+    $boincteam_id = boincteam_lookup_id($team_id);
567
+    $boincuser_id = $account->boincuser_id;
568 568
 
569
-  if (boincteam_is_admin($team_id, $account->uid)) {
569
+    if (boincteam_is_admin($team_id, $account->uid)) {
570 570
     // Update the team in the BOINC db
571 571
     db_set_active('boinc_rw');
572 572
     db_query("
573 573
       DELETE FROM {team_admin} WHERE
574 574
         teamid = '%d' AND userid = '%d'",
575
-      $boincteam_id,
576
-      $boincuser_id
575
+        $boincteam_id,
576
+        $boincuser_id
577 577
     );
578 578
     db_set_active('default');
579 579
     drupal_set_message(t('@user is no longer an admin of @team.',
580
-      array(
580
+        array(
581 581
         '@user' => $account->boincuser_name,
582 582
         '@team' => $team->title
583
-      )
583
+        )
584 584
     ));
585 585
     watchdog('boincteam', 'User @current_user removed admin status for user
586 586
       @uid from team @nid',
587
-      array(
587
+        array(
588 588
         '@current_user' => $user->uid,
589 589
         '@uid' => $account->uid,
590 590
         '@nid' => $team_id
591
-      ), WATCHDOG_NOTICE);
592
-  }
593
-  drupal_goto("community/teams/{$team_id}/edit/admins");
591
+        ), WATCHDOG_NOTICE);
592
+    }
593
+    drupal_goto("community/teams/{$team_id}/edit/admins");
594 594
 }
595 595
 
596 596
 /**
597 597
  * Remove a user from a team
598 598
  */
599 599
 function boincteam_remove_member($team_id, $user_id) {
600
-  global $user;
601
-  $account = user_load($user_id);
600
+    global $user;
601
+    $account = user_load($user_id);
602 602
 
603
-  $boincteam_id = boincteam_lookup_id($team_id);
604
-  $boincteam = boincteam_load($boincteam_id);
605
-  if ($account->team == $team_id) {
603
+    $boincteam_id = boincteam_lookup_id($team_id);
604
+    $boincteam = boincteam_load($boincteam_id);
605
+    if ($account->team == $team_id) {
606 606
     require_boinc('team');
607 607
     $boincuser = boincuser_load($user_id, TRUE);
608 608
     user_quit_team($boincuser);
609 609
     drupal_set_message(t('@user has been removed from @team.',
610
-      array(
610
+        array(
611 611
         '@user' => $account->boincuser_name,
612 612
         '@team' => $boincteam->name
613
-      )
613
+        )
614 614
     ));
615 615
     watchdog('boincteam', 'User @current_user removed user @uid from team @nid',
616
-      array(
616
+        array(
617 617
         '@current_user' => $user->uid,
618 618
         '@uid' => $account->uid,
619 619
         '@nid' => $team_id
620
-      ), WATCHDOG_NOTICE);
621
-  }
622
-  else {
623
-      drupal_set_message(t('@user is not a member of @team, so you cannot
620
+        ), WATCHDOG_NOTICE);
621
+    }
622
+    else {
623
+        drupal_set_message(t('@user is not a member of @team, so you cannot
624 624
         revoke the membership.', array(
625
-          '@user' => $account->boincuser_name,
626
-          '@team' => $boincteam->name
625
+            '@user' => $account->boincuser_name,
626
+            '@team' => $boincteam->name
627 627
         )
628
-      ));
629
-  }
630
-  drupal_goto("community/teams/{$team_id}/edit/members");
628
+        ));
629
+    }
630
+    drupal_goto("community/teams/{$team_id}/edit/members");
631 631
 }
632 632
 
633 633
 /**
634 634
  * Request a foundership transfer
635 635
  */
636 636
 function boincteam_request_foundership($team_id) {
637
-  global $user;
638
-  $account = user_load($user->uid);
639
-  $team = node_load($team_id);
640
-  $boincteam_id = boincteam_lookup_id($team_id);
641
-  $boincteam = boincteam_load($boincteam_id);
642
-  $boincuser_id = $account->boincuser_id;
643
-
644
-  if (boincteam_is_founder($team_id, $account->uid)) {
637
+    global $user;
638
+    $account = user_load($user->uid);
639
+    $team = node_load($team_id);
640
+    $boincteam_id = boincteam_lookup_id($team_id);
641
+    $boincteam = boincteam_load($boincteam_id);
642
+    $boincuser_id = $account->boincuser_id;
643
+
644
+    if (boincteam_is_founder($team_id, $account->uid)) {
645 645
     // Shouldn't even be here...
646 646
     drupal_set_message(t('@user is already the team founder.',
647
-      array(
647
+        array(
648 648
         '@user' => $account->boincuser_name
649
-      )
649
+        )
650 650
     ), 'warning');
651
-  }
652
-  elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
651
+    }
652
+    elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
653 653
     // It hasn't been long enough since the last transfer request
654 654
     drupal_set_message(t('A foundership change was requested during the last 90
655 655
       days, so new requests are not allowed. Please try again later.'
656 656
     ), 'warning');
657
-  }
658
-  elseif (boincteam_is_member($team_id, $account->uid)) {
657
+    }
658
+    elseif (boincteam_is_member($team_id, $account->uid)) {
659 659
     // Log the transfer request
660 660
     db_set_active('boinc_rw');
661 661
     db_query("
662 662
       UPDATE {team}
663 663
       SET ping_user = '%d', ping_time='%d'
664 664
       WHERE id = '%d'",
665
-      $boincuser_id, time(), $boincteam_id
665
+        $boincuser_id, time(), $boincteam_id
666 666
     );
667 667
     db_set_active('default');
668 668
     drupal_set_message(t('You have requested foundership of @team. The current
669 669
       founder has 60 days to respond to this request.',
670
-      array(
670
+        array(
671 671
         '@team' => $team->title
672
-      )
672
+        )
673 673
     ));
674 674
     watchdog('boincteam', 'User @user requested foundership of team @nid',
675
-      array(
675
+        array(
676 676
         '@current_user' => $account->uid,
677 677
         '@nid' => $team_id
678
-      ), WATCHDOG_NOTICE);
679
-  }
680
-  drupal_goto("community/teams/{$team_id}");
678
+        ), WATCHDOG_NOTICE);
679
+    }
680
+    drupal_goto("community/teams/{$team_id}");
681 681
 }
682 682
 
683 683
 /**
684 684
  * Transfer foundership to another team member
685 685
  */
686 686
 function boincteam_set_founder($team_id, $user_id) {
687
-  global $user;
688
-  $account = user_load($user_id);
689
-  $team = node_load($team_id);
690
-  $boincteam_id = boincteam_lookup_id($team_id);
691
-  $boincuser_id = $account->boincuser_id;
687
+    global $user;
688
+    $account = user_load($user_id);
689
+    $team = node_load($team_id);
690
+    $boincteam_id = boincteam_lookup_id($team_id);
691
+    $boincuser_id = $account->boincuser_id;
692 692
 
693
-  if (boincteam_is_member($team_id, $account->uid)) {
693
+    if (boincteam_is_member($team_id, $account->uid)) {
694 694
     // Update the team in the BOINC db
695 695
     db_set_active('boinc_rw');
696 696
     db_query("
697 697
       UPDATE {team}
698 698
       SET userid = '%d', ping_user=0
699 699
       WHERE id = '%d'",
700
-      $boincuser_id, $boincteam_id
700
+        $boincuser_id, $boincteam_id
701 701
     );
702 702
     db_set_active('default');
703 703
     drupal_set_message(t('Foundership of @team has been transfered to @user.',
704
-      array(
704
+        array(
705 705
         '@user' => $account->boincuser_name,
706 706
         '@team' => $team->title
707
-      )
707
+        )
708 708
     ));
709 709
     watchdog('boincteam', 'User @current_user transferred foundership of team
710 710
       @nid to user @uid',
711
-      array(
711
+        array(
712 712
         '@current_user' => $user->uid,
713 713
         '@uid' => $account->uid,
714 714
         '@nid' => $team_id
715
-      ), WATCHDOG_NOTICE);
716
-  }
717
-  drupal_goto("community/teams/{$team_id}");
715
+        ), WATCHDOG_NOTICE);
716
+    }
717
+    drupal_goto("community/teams/{$team_id}");
718 718
 }
719 719
 
720 720
 /**
721 721
  * See if a new foundership transfer request is allowed
722 722
  */
723 723
 function boincteam_new_foundership_transfer_request_ok($team_id) {
724
-  $boincteam_id = boincteam_lookup_id($team_id);
725
-  $boincteam = boincteam_load($boincteam_id);
726
-  $now = time();
727
-  if ($boincteam->ping_user <= 0) {
724
+    $boincteam_id = boincteam_lookup_id($team_id);
725
+    $boincteam = boincteam_load($boincteam_id);
726
+    $now = time();
727
+    if ($boincteam->ping_user <= 0) {
728 728
     if ($boincteam->ping_time < $now - 60 * (24*60*60)) {
729
-      return TRUE;
729
+        return TRUE;
730 730
     }
731 731
     return FALSE;
732
-  }
733
-  if ($boincteam->ping_time < $now - 90 * (24*60*60)) {
732
+    }
733
+    if ($boincteam->ping_time < $now - 90 * (24*60*60)) {
734 734
     return TRUE;
735
-  }
736
-  return FALSE;
735
+    }
736
+    return FALSE;
737 737
 }
738 738
 
739 739
 /**
@@ -755,18 +755,18 @@  discard block
 block discarded – undo
755 755
  * Check if a user has an active foundership request with a team
756 756
  */
757 757
 function boincteam_user_requested_foundership($team_id, $user_id = NULL) {
758
-  if (!$user_id) {
758
+    if (!$user_id) {
759 759
     global $user;
760 760
     $user_id = $user->uid;
761
-  }
762
-  $account = user_load($user_id);
763
-  $boincteam_id = boincteam_lookup_id($team_id);
764
-  $boincteam = boincteam_load($boincteam_id);
761
+    }
762
+    $account = user_load($user_id);
763
+    $boincteam_id = boincteam_lookup_id($team_id);
764
+    $boincteam = boincteam_load($boincteam_id);
765 765
 
766
-  if ($boincteam->ping_user == $account->boincuser_id) {
766
+    if ($boincteam->ping_user == $account->boincuser_id) {
767 767
     // Be sure the request is still active
768 768
     return !boincteam_new_foundership_transfer_request_ok($team_id);
769
-  }
769
+    }
770 770
 }
771 771
 
772 772
 
@@ -778,125 +778,125 @@  discard block
 block discarded – undo
778 778
  * General info about team admins
779 779
  */
780 780
 function boincteam_about_admins_panel() {
781
-  $output = '';
782
-  $output .= '<h2 class="pane-title">' . bts('About team admins', array(), NULL, 'boinc:team-admins-panel') . '</h2>';
783
-  $output .= '<div>';
784
-  $output .= '<p>' . bts('Team admins can:', array(), NULL, 'boinc:team-admins-panel') . '</p>';
785
-  $output .= '<ul>';
786
-  $output .= '  <li>' . bts('Edit team information', array(), NULL, 'boinc:team-admins-panel') . '</li>';
787
-  $output .= '  <li>' . bts("View the team's join / quit history", array(), NULL, 'boinc:team-admins-panel') . '</li>';
788
-  $output .= '  <li>' . bts('Moderate the team forum', array(), NULL, 'boinc:team-admins-panel') . '</li>';
789
-  $output .= '  <li>' . bts('Remove members from the team', array(), NULL, 'boinc:team-admins-panel') . '</li>';
790
-  $output .= '  <li>' . bts('Disband a team if it has no members', array(), NULL, 'boinc:team-admins-panel') . '</li>';
791
-  $output .= '</ul>';
792
-  $output .= '</div>';
793
-  $output .= '<div>';
794
-  $output .= '<p>' . bts('Team admins cannot:', array(), NULL, 'boinc:team-admins-panel') . '</p>';
795
-  $output .= '<ul>';
796
-  $output .= '  <li>' . bts('Change the team founder', array(), NULL, 'boinc:team-admins-panel') . '</li>';
797
-  $output .= '  <li>' . bts('Remove members', array(), NULL, 'boinc:team-admins-panel') . '</li>';
798
-  $output .= '  <li>' . bts('Add / Remove team admins', array(), NULL, 'boinc:team-admins-panel') . '</li>';
799
-  $output .= '</ul>';
800
-  $output .= '</div>';
801
-  $output .= '<p>' . bts('If a team admin quits the team, they cease to be a'
781
+    $output = '';
782
+    $output .= '<h2 class="pane-title">' . bts('About team admins', array(), NULL, 'boinc:team-admins-panel') . '</h2>';
783
+    $output .= '<div>';
784
+    $output .= '<p>' . bts('Team admins can:', array(), NULL, 'boinc:team-admins-panel') . '</p>';
785
+    $output .= '<ul>';
786
+    $output .= '  <li>' . bts('Edit team information', array(), NULL, 'boinc:team-admins-panel') . '</li>';
787
+    $output .= '  <li>' . bts("View the team's join / quit history", array(), NULL, 'boinc:team-admins-panel') . '</li>';
788
+    $output .= '  <li>' . bts('Moderate the team forum', array(), NULL, 'boinc:team-admins-panel') . '</li>';
789
+    $output .= '  <li>' . bts('Remove members from the team', array(), NULL, 'boinc:team-admins-panel') . '</li>';
790
+    $output .= '  <li>' . bts('Disband a team if it has no members', array(), NULL, 'boinc:team-admins-panel') . '</li>';
791
+    $output .= '</ul>';
792
+    $output .= '</div>';
793
+    $output .= '<div>';
794
+    $output .= '<p>' . bts('Team admins cannot:', array(), NULL, 'boinc:team-admins-panel') . '</p>';
795
+    $output .= '<ul>';
796
+    $output .= '  <li>' . bts('Change the team founder', array(), NULL, 'boinc:team-admins-panel') . '</li>';
797
+    $output .= '  <li>' . bts('Remove members', array(), NULL, 'boinc:team-admins-panel') . '</li>';
798
+    $output .= '  <li>' . bts('Add / Remove team admins', array(), NULL, 'boinc:team-admins-panel') . '</li>';
799
+    $output .= '</ul>';
800
+    $output .= '</div>';
801
+    $output .= '<p>' . bts('If a team admin quits the team, they cease to be a'
802 802
     . ' team admin. We recommend only selecting people you know and trust', array(), NULL, 'boinc:team-admins-panel')
803 803
     . '</p>';
804
-  return $output;
804
+    return $output;
805 805
 }
806 806
 
807 807
 /**
808 808
  * General info about changing the team founder
809 809
  */
810 810
 function boincteam_about_founder_panel() {
811
-  $output = '';
812
-  $output .= '<h2 class="pane-title">' . bts('Changing the team founder', array(), NULL, 'boinc:team-founder-panel')
811
+    $output = '';
812
+    $output .= '<h2 class="pane-title">' . bts('Changing the team founder', array(), NULL, 'boinc:team-founder-panel')
813 813
     . '</h2>';
814
-  $output .= '<div>';
815
-  $output .= '<p>' . bts('Notes about changes in foundership:', array(), NULL, 'boinc:team-founder-panel') . '</p>';
816
-  $output .= '<ul>';
817
-  $output .= '  <li>' . bts('Any member of the team is eligible', array(), NULL, 'boinc:team-founder-panel') . '</li>';
818
-  $output .= '  <li>' . bts('Current founder becomes a normal user', array(), NULL, 'boinc:team-founder-panel') . '</li>';
819
-  $output .= '</ul>';
820
-  $output .= '</div>';
821
-  $output .= '<div>';
822
-  $output .= '<p>' . bts('Foundership can be requested by team members:', array(), NULL, 'boinc:team-founder-panel')
814
+    $output .= '<div>';
815
+    $output .= '<p>' . bts('Notes about changes in foundership:', array(), NULL, 'boinc:team-founder-panel') . '</p>';
816
+    $output .= '<ul>';
817
+    $output .= '  <li>' . bts('Any member of the team is eligible', array(), NULL, 'boinc:team-founder-panel') . '</li>';
818
+    $output .= '  <li>' . bts('Current founder becomes a normal user', array(), NULL, 'boinc:team-founder-panel') . '</li>';
819
+    $output .= '</ul>';
820
+    $output .= '</div>';
821
+    $output .= '<div>';
822
+    $output .= '<p>' . bts('Foundership can be requested by team members:', array(), NULL, 'boinc:team-founder-panel')
823 823
     . '</p>';
824
-  $output .= '<ul>';
825
-  $output .= '  <li>' . bts('One request is allowed at a time', array(), NULL, 'boinc:team-founder-panel') . '</li>';
826
-  $output .= '  <li>' . bts('It must be 60 days since any previous request', array(), NULL, 'boinc:team-founder-panel')
824
+    $output .= '<ul>';
825
+    $output .= '  <li>' . bts('One request is allowed at a time', array(), NULL, 'boinc:team-founder-panel') . '</li>';
826
+    $output .= '  <li>' . bts('It must be 60 days since any previous request', array(), NULL, 'boinc:team-founder-panel')
827 827
     . '</li>';
828
-  $output .= '  <li>' . bts('Any active request must be older than 90 days', array(), NULL, 'boinc:team-founder-panel')
828
+    $output .= '  <li>' . bts('Any active request must be older than 90 days', array(), NULL, 'boinc:team-founder-panel')
829 829
     . '</li>';
830
-  $output .= '  <li>' . bts('Current founder has 60 days to respond to a'
830
+    $output .= '  <li>' . bts('Current founder has 60 days to respond to a'
831 831
     . ' request', array(), NULL, 'boinc:team-founder-panel') . '</li>';
832
-  $output .= '</ul>';
833
-  $output .= '</div>';
834
-  return $output;
832
+    $output .= '</ul>';
833
+    $output .= '</div>';
834
+    return $output;
835 835
 }
836 836
 
837 837
 /**
838 838
  * Link to create a new team
839 839
  */
840 840
 function boincteam_create_team_link_panel() {
841
-  global $user;
842
-  $account = user_load($user->uid);
843
-  $unrestricted_role = array_search('verified contributor', user_roles(true));
844
-  $output = '';
845
-  $output .= '<h2 class="pane-title">' . bts('Create a new team', array(), NULL, 'boinc:create-team-panel') . '</h2>';
846
-  $output .= '<p>' . bts('If you cannot find a team that is right for you, you'
841
+    global $user;
842
+    $account = user_load($user->uid);
843
+    $unrestricted_role = array_search('verified contributor', user_roles(true));
844
+    $output = '';
845
+    $output .= '<h2 class="pane-title">' . bts('Create a new team', array(), NULL, 'boinc:create-team-panel') . '</h2>';
846
+    $output .= '<p>' . bts('If you cannot find a team that is right for you, you'
847 847
     . ' can create a team.', array(), NULL, 'boinc:create-team-panel') . '</p>';
848
-  $output .= '<ul class="tab-list">';
849
-  $output .= '  <li class="first last tab">';
850
-  if (isset($account->roles[$unrestricted_role])) {
848
+    $output .= '<ul class="tab-list">';
849
+    $output .= '  <li class="first last tab">';
850
+    if (isset($account->roles[$unrestricted_role])) {
851 851
     $output .= l(bts('Create new team', array(), NULL, 'boinc:create-team-panel'), 'community/teams/add');
852
-  } elseif ($account->uid <= 0) {
852
+    } elseif ($account->uid <= 0) {
853 853
     $output .= l(
854
-      bts('Login to create a new team', array(), NULL, 'boinc:create-team-panel'),
855
-      'user/login',
856
-      array('query' => drupal_get_destination())
854
+        bts('Login to create a new team', array(), NULL, 'boinc:create-team-panel'),
855
+        'user/login',
856
+        array('query' => drupal_get_destination())
857 857
     );
858
-  } else {
858
+    } else {
859 859
     $min_credit_needed = variable_get('boinc_comment_min_credit', 0);
860 860
     $credit_needed = $min_credit_needed - $account->boincuser_total_credit;
861 861
     $output .= '[';
862 862
     if ($credit_needed == 1) {
863
-      $output .= bts('You must earn 1 more credit!', array(), NULL, 'boinc:create-team-panel');
863
+        $output .= bts('You must earn 1 more credit!', array(), NULL, 'boinc:create-team-panel');
864 864
     }
865 865
     else {
866
-      $output .= bts('You must earn @count more credits!',
866
+        $output .= bts('You must earn @count more credits!',
867 867
         array('@count' => $credit_needed),
868
-	NULL, 'boinc:create-team-panel'
869
-      );
868
+    NULL, 'boinc:create-team-panel'
869
+        );
870 870
     }
871 871
     $output .= ']';
872
-  }
873
-  $output .= '  </li>';
874
-  $output .= '</ul>';
875
-  return $output;
872
+    }
873
+    $output .= '  </li>';
874
+    $output .= '</ul>';
875
+    return $output;
876 876
 }
877 877
 
878 878
 /**
879 879
  * Create team form
880 880
  */
881 881
 function boincteam_create_team_panel() {
882
-  $output = '';
883
-  $output .= '<h2 class="pane-title">' . bts('Create a team', array(), NULL, 'boinc:create-team-panel') . '</h2>';
884
-  $output .= drupal_get_form('boincteam_create_form');
882
+    $output = '';
883
+    $output .= '<h2 class="pane-title">' . bts('Create a team', array(), NULL, 'boinc:create-team-panel') . '</h2>';
884
+    $output .= drupal_get_form('boincteam_create_form');
885 885
 
886
-  return $output;
886
+    return $output;
887 887
 }
888 888
 
889 889
 /**
890 890
  * Link to user's team
891 891
  */
892 892
 function boincteam_dashboard_panel($uid = NULL) {
893
-  global $user;
894
-  if (!$uid) {
893
+    global $user;
894
+    if (!$uid) {
895 895
     $uid = $user->uid;
896
-  }
897
-  $output = '';
898
-  $account = user_load($uid);
899
-  if ($account->team) {
896
+    }
897
+    $output = '';
898
+    $account = user_load($uid);
899
+    if ($account->team) {
900 900
     $team = boincteam_load(boincteam_lookup_id($account->team));
901 901
     $output .= '<h2 class="pane-title">' . bts('Team', array(), NULL, 'boinc:team-dashboard') . '</h2>';
902 902
     $output .= '<div class="stats">';
@@ -915,254 +915,254 @@  discard block
 block discarded – undo
915 915
     $output .= '  <label>' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . ': </label>';
916 916
     $output .= '  <span>' . number_format($team->total_credit, 0) . '</span>';
917 917
     $output .= '</div>' . "\n";
918
-  }
919
-  else if ($user->uid == $account->uid) {
918
+    }
919
+    else if ($user->uid == $account->uid) {
920 920
     $output .= '<h2 class="pane-title">' . bts('Team (None)', array(), NULL, 'boinc:team-dashboard') . '</h2>';
921 921
     $output .= '<ul class="tab-list action-list">';
922 922
     $output .= '<li class="tab primary">';
923 923
     $output .= l(bts('Join a Team', array(), NULL, 'boinc:team-dashboard'), 'community/teams');
924 924
     $output .= '</li>';
925 925
     $output .= '</ul>';
926
-  }
927
-  return $output;
926
+    }
927
+    return $output;
928 928
 }
929 929
 
930 930
 /**
931 931
  * Edit team form
932 932
  */
933 933
 function boincteam_edit_team_panel($team_id) {
934
-  $team = node_load($team_id);
935
-  $output = '';
936
-  $output .= '<h2 class="pane-title">' . $team->title . '</h2>';
937
-  $output .= drupal_get_form('boincteam_edit_form', $team_id);
934
+    $team = node_load($team_id);
935
+    $output = '';
936
+    $output .= '<h2 class="pane-title">' . $team->title . '</h2>';
937
+    $output .= drupal_get_form('boincteam_edit_form', $team_id);
938 938
 
939
-  return $output;
939
+    return $output;
940 940
 }
941 941
 
942 942
 /**
943 943
  * Link to join a team
944 944
  */
945 945
 function boincteam_join_team_panel($team_id) {
946
-  $team = node_load($team_id);
947
-  $output = '';
948
-  $output .= '<h2 class="pane-title">' . bts('Join team', array(), NULL, 'boinc:join-team-panel') . '</h2>';
949
-  $output .= '<p>' . bts('Click here to become a member of @this_team',
946
+    $team = node_load($team_id);
947
+    $output = '';
948
+    $output .= '<h2 class="pane-title">' . bts('Join team', array(), NULL, 'boinc:join-team-panel') . '</h2>';
949
+    $output .= '<p>' . bts('Click here to become a member of @this_team',
950 950
     array('@this_team' =>$team->title), NULL, 'boinc:join-team-panel') . '</p>';
951
-  $output .= '<ul class="tab-list">';
952
-  $output .= '  <li class="first last tab">' .
951
+    $output .= '<ul class="tab-list">';
952
+    $output .= '  <li class="first last tab">' .
953 953
     l(bts('Join this team', array(), NULL, 'boinc:join-team-panel'), "community/teams/{$team_id}/join") . '</li>';
954
-  $output .= '</ul>';
955
-  return $output;
954
+    $output .= '</ul>';
955
+    return $output;
956 956
 }
957 957
 
958 958
 /**
959 959
  * Link to leave a team
960 960
  */
961 961
 function boincteam_leave_team_panel($team_id) {
962
-  $team = node_load($team_id);
963
-  $output = '';
964
-  $output .= '<h2 class="pane-title">' . bts('Leave team', array(), NULL, 'boinc:leave-team-panel') . '</h2>';
965
-  $output .= '<p>' . bts('Click here to revoke your membership with'
962
+    $team = node_load($team_id);
963
+    $output = '';
964
+    $output .= '<h2 class="pane-title">' . bts('Leave team', array(), NULL, 'boinc:leave-team-panel') . '</h2>';
965
+    $output .= '<p>' . bts('Click here to revoke your membership with'
966 966
     . ' @this_team', array('@this_team' =>$team->title), NULL, 'boinc:leave-team-panel') . '</p>';
967
-  $output .= '<ul class="tab-list">';
968
-  $output .= '  <li class="first last tab">' .
967
+    $output .= '<ul class="tab-list">';
968
+    $output .= '  <li class="first last tab">' .
969 969
     l(bts('Leave this team', array(), NULL, 'boinc:leave-team-panel'), "community/teams/{$team_id}/leave") . '</li>';
970
-  $output .= '</ul>';
971
-  return $output;
970
+    $output .= '</ul>';
971
+    return $output;
972 972
 }
973 973
 
974 974
 /**
975 975
  * General info about team admins
976 976
  */
977 977
 function boincteam_manage_admins_panel_header($team_id) {
978
-  $output = '';
979
-  $output .= '<h4>' . bts('Add team admin', array(), NULL, 'boinc:team-manage-admins') . '</h4>';
980
-  $output .= drupal_get_form('boincteam_add_admin_form', $team_id);
981
-  $output .= '<div class="clearfix"></div>';
982
-  $output .= '<h4>' . bts('Current team admins', array(), NULL, 'boinc:team-manage-admins') . '</h4>';
978
+    $output = '';
979
+    $output .= '<h4>' . bts('Add team admin', array(), NULL, 'boinc:team-manage-admins') . '</h4>';
980
+    $output .= drupal_get_form('boincteam_add_admin_form', $team_id);
981
+    $output .= '<div class="clearfix"></div>';
982
+    $output .= '<h4>' . bts('Current team admins', array(), NULL, 'boinc:team-manage-admins') . '</h4>';
983 983
 
984
-  return $output;
984
+    return $output;
985 985
 }
986 986
 
987 987
 /**
988 988
  * Team management tools
989 989
  */
990 990
 function boincteam_management_panel($team_id) {
991
-  $is_founder = boincteam_is_founder($team_id);
992
-  $team = node_load($team_id);
991
+    $is_founder = boincteam_is_founder($team_id);
992
+    $team = node_load($team_id);
993 993
 
994
-  $output = '';
995
-  $output .= '<h2 class="pane-title">' . bts('Manage team', array(), NULL, 'boinc:team-manage') . '</h2>';
994
+    $output = '';
995
+    $output .= '<h2 class="pane-title">' . bts('Manage team', array(), NULL, 'boinc:team-manage') . '</h2>';
996 996
 
997
-  // PM all members
998
-  if (module_exists('privatemsg')) {
997
+    // PM all members
998
+    if (module_exists('privatemsg')) {
999 999
     $output .= '<div class="form-item">';
1000 1000
     $output .= '  <ul class="tab-list action-list">';
1001 1001
     $output .= '    <li class="first tab primary">' .
1002
-      l('Send message to team', "community/teams/{$team_id}/message-all-members") . '</li>';
1002
+        l('Send message to team', "community/teams/{$team_id}/message-all-members") . '</li>';
1003 1003
     $output .= '  </ul>';
1004 1004
     $output .= '  <div class="description">';
1005 1005
     $output .=   bts('Contact all team members using e-mail.', array(), NULL, 'boinc:team-manage');
1006 1006
     $output .= '  </div>';
1007 1007
     $output .= '</div>';
1008
-  }
1008
+    }
1009 1009
 
1010
-  // Team forum
1011
-  if (module_exists('boincteam_forum')) {
1010
+    // Team forum
1011
+    if (module_exists('boincteam_forum')) {
1012 1012
     if ($is_founder) {
1013
-      // Determine whether to create a forum or edit the existing forum
1014
-      // (multiple forums per team could be supported in the future)
1015
-      $team_forum_link_path = 'add';
1016
-      $team_forums = boincteam_forum_list();
1017
-      if ($team_forums) {
1013
+        // Determine whether to create a forum or edit the existing forum
1014
+        // (multiple forums per team could be supported in the future)
1015
+        $team_forum_link_path = 'add';
1016
+        $team_forums = boincteam_forum_list();
1017
+        if ($team_forums) {
1018 1018
         $team_forum = reset($team_forums);
1019 1019
         $team_forum_link_path = "{$team_forum->tfid}/edit";
1020
-      }
1021
-      $output .= '<div class="form-item">';
1022
-      $output .= '  <ul class="tab-list action-list">';
1023
-      $output .= '    <li class="first tab primary">' .
1020
+        }
1021
+        $output .= '<div class="form-item">';
1022
+        $output .= '  <ul class="tab-list action-list">';
1023
+        $output .= '    <li class="first tab primary">' .
1024 1024
         l(bts('Manage team message board', array(), NULL, 'boinc:team-manage'),
1025
-          "community/teams/{$team_id}/forum/{$team_forum_link_path}"
1025
+            "community/teams/{$team_id}/forum/{$team_forum_link_path}"
1026 1026
         );
1027
-      $output .= '    </li>';
1028
-      $output .= '  <div class="description">';
1029
-      $output .=   bts('Create or manage message board', array(), NULL, 'boinc:team-manage');
1030
-      $output .= '  </div>';
1031
-      $output .= '</div>';
1027
+        $output .= '    </li>';
1028
+        $output .= '  <div class="description">';
1029
+        $output .=   bts('Create or manage message board', array(), NULL, 'boinc:team-manage');
1030
+        $output .= '  </div>';
1031
+        $output .= '</div>';
1032
+    }
1032 1033
     }
1033
-  }
1034 1034
 
1035
-  // Team history
1036
-  $output .= '<div class="form-item">';
1037
-  $output .= '  <label>' . bts('View change history', array(), NULL, 'boinc:team-manage') . '</label>';
1038
-  $output .= '  <ul class="tab-list">';
1039
-  $output .= '    <li class="first tab primary">' .
1035
+    // Team history
1036
+    $output .= '<div class="form-item">';
1037
+    $output .= '  <label>' . bts('View change history', array(), NULL, 'boinc:team-manage') . '</label>';
1038
+    $output .= '  <ul class="tab-list">';
1039
+    $output .= '    <li class="first tab primary">' .
1040 1040
     l('HTML', "community/teams/{$team_id}/history") . '</li>';
1041
-  $output .= '    <li class="last tab primary">' .
1041
+    $output .= '    <li class="last tab primary">' .
1042 1042
     l('XML', "community/teams/{$team_id}/history/xml") . '</li>';
1043
-  $output .= '  </ul>';
1044
-  $output .= '  <div class="description">';
1045
-  $output .=   bts('See member activity', array(), NULL, 'boinc:team-manage');
1046
-  $output .= '  </div>';
1047
-  $output .= '</div>';
1043
+    $output .= '  </ul>';
1044
+    $output .= '  <div class="description">';
1045
+    $output .=   bts('See member activity', array(), NULL, 'boinc:team-manage');
1046
+    $output .= '  </div>';
1047
+    $output .= '</div>';
1048 1048
 
1049
-  $output .= '<div class="form-item">';
1050
-  $output .= '  <ul class="tab-list action-list">';
1049
+    $output .= '<div class="form-item">';
1050
+    $output .= '  <ul class="tab-list action-list">';
1051 1051
 
1052
-  // Edit team information
1053
-  $output .= '    <li class="first tab primary">' .
1052
+    // Edit team information
1053
+    $output .= '    <li class="first tab primary">' .
1054 1054
     l(bts('Edit team info', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/edit/info") . '</li>';
1055 1055
 
1056
-  // Member list
1057
-  $output .= '    <li class="tab primary">' .
1056
+    // Member list
1057
+    $output .= '    <li class="tab primary">' .
1058 1058
     l(bts('View member list', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/members") . '</li>';
1059 1059
 
1060
-  // Remove members
1061
-  $output .= '    <li class="tab primary">' .
1060
+    // Remove members
1061
+    $output .= '    <li class="tab primary">' .
1062 1062
     l(bts('Remove members', array(), NULL, 'boinc:team-admins-panel'), "community/teams/{$team_id}/edit/members") . '</li>';
1063 1063
 
1064
-  if ($is_founder) {
1064
+    if ($is_founder) {
1065 1065
 
1066 1066
     // Change founder
1067 1067
     $output .= '    <li class="tab primary">' .
1068
-      l(bts('Change founder', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/edit/founder") . '</li>';
1068
+        l(bts('Change founder', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/edit/founder") . '</li>';
1069 1069
 
1070
-      // Manage admins
1070
+        // Manage admins
1071 1071
     $output .= '    <li class="tab primary">' .
1072
-      l(bts('Manage team admins', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/edit/admins") . '</li>';
1072
+        l(bts('Manage team admins', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/edit/admins") . '</li>';
1073 1073
 
1074 1074
     // Delete the team
1075 1075
     $output .= '    <li class="last tab primary">' .
1076
-      l(bts('Remove team', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/delete") . '</li>';
1077
-  }
1076
+        l(bts('Remove team', array(), NULL, 'boinc:team-manage'), "community/teams/{$team_id}/delete") . '</li>';
1077
+    }
1078 1078
 
1079
-  $output .= '  </ul>';
1080
-  $output .= '</div>';
1079
+    $output .= '  </ul>';
1080
+    $output .= '</div>';
1081 1081
 
1082
-  return $output;
1082
+    return $output;
1083 1083
 }
1084 1084
 
1085 1085
 /**
1086 1086
  * Link to user's team
1087 1087
  */
1088 1088
 function boincteam_member_link_panel() {
1089
-  global $user;
1090
-  $account = user_load($user->uid);
1091
-  $team = node_load($account->team);
1092
-  $output = '';
1093
-  $output .= '<h2 class="pane-title">' . bts('My team', array(), NULL, 'boinc:account-team-panel') . '</h2>';
1094
-  $output .= '<p>' . bts('You are a member of @team.',
1089
+    global $user;
1090
+    $account = user_load($user->uid);
1091
+    $team = node_load($account->team);
1092
+    $output = '';
1093
+    $output .= '<h2 class="pane-title">' . bts('My team', array(), NULL, 'boinc:account-team-panel') . '</h2>';
1094
+    $output .= '<p>' . bts('You are a member of @team.',
1095 1095
     array('@team' => $team->title), NULL, 'boinc:account-team-panel') . '</p>';
1096
-  $output .= '<ul class="tab-list">';
1097
-  $output .= '  <li class="first last tab">' .
1096
+    $output .= '<ul class="tab-list">';
1097
+    $output .= '  <li class="first last tab">' .
1098 1098
     l(bts('View my team', array(), NULL, 'boinc:account-team-panel'), "community/teams/{$account->team}") . '</li>';
1099
-  $output .= '</ul>';
1100
-  return $output;
1099
+    $output .= '</ul>';
1100
+    return $output;
1101 1101
 }
1102 1102
 
1103 1103
 /**
1104 1104
  * Link to request foundership transfer of a team
1105 1105
  */
1106 1106
 function boincteam_request_foundership_panel($team_id) {
1107
-  global $user;
1108
-  $account = user_load($user->uid);
1109
-  $team = node_load($team_id);
1110
-  $boincteam_id = boincteam_lookup_id($team_id);
1111
-  $boincteam = boincteam_load($boincteam_id);
1112
-  $boincuser_id = $account->boincuser_id;
1113
-  $output = '';
1114
-  $output .= '<h2 class="pane-title">' . bts('Request foundership', array(), NULL, 'boinc:team-request-foundership') . '</h2>';
1107
+    global $user;
1108
+    $account = user_load($user->uid);
1109
+    $team = node_load($team_id);
1110
+    $boincteam_id = boincteam_lookup_id($team_id);
1111
+    $boincteam = boincteam_load($boincteam_id);
1112
+    $boincuser_id = $account->boincuser_id;
1113
+    $output = '';
1114
+    $output .= '<h2 class="pane-title">' . bts('Request foundership', array(), NULL, 'boinc:team-request-foundership') . '</h2>';
1115 1115
 
1116
-  if (boincteam_user_requested_foundership($team_id)) {
1116
+    if (boincteam_user_requested_foundership($team_id)) {
1117 1117
     $deadline = boincteam_foundership_transfer_ok_time($boincteam);
1118 1118
     $days_to_deadline = ceil(($deadline - time()) / (24*60*60));
1119 1119
     $request_age = 60 - $days_to_deadline;
1120 1120
     $days_to_respond = 30 + $days_to_deadline;
1121 1121
     if (time() > $deadline) {
1122
-      $output .= '<p>';
1123
-      if ($request_age == 1) {
1122
+        $output .= '<p>';
1123
+        if ($request_age == 1) {
1124 1124
         $output .= bts('1 day has elapsed since your request and'
1125
-          . ' the founder has not responded.', array(), NULL, 'boinc:team-request-foundership');
1126
-      }
1127
-      else {
1125
+            . ' the founder has not responded.', array(), NULL, 'boinc:team-request-foundership');
1126
+        }
1127
+        else {
1128 1128
         $output .= bts('@count days have elapsed since your request and'
1129
-          . ' the founder has not responded.',
1130
-          array('@count' => $request_age),
1131
-          NULL, 'boinc:team-request-foundership');
1132
-      }
1133
-      $output .= ' ';
1134
-      if ($days_to_respond == 1) {
1129
+            . ' the founder has not responded.',
1130
+            array('@count' => $request_age),
1131
+            NULL, 'boinc:team-request-foundership');
1132
+        }
1133
+        $output .= ' ';
1134
+        if ($days_to_respond == 1) {
1135 1135
         $output .= bts('You now have 1 day to assume foundership before'
1136
-          . ' another team member may submit a request.', array(), NULL, 'boinc:team-request-foundership');
1137
-      }
1138
-      else {
1136
+            . ' another team member may submit a request.', array(), NULL, 'boinc:team-request-foundership');
1137
+        }
1138
+        else {
1139 1139
         $output .= bts('You now have @count days to assume foundership before'
1140
-          . ' another team member may submit a request.',
1141
-          array('@count' => $days_to_respond),
1142
-          NULL, 'boinc:team-request-foundership');
1143
-      }
1144
-      $output .= '</p>';
1145
-      $output .= '<ul class="tab-list">';
1146
-      $output .= '  <li class="first last tab">' .
1140
+            . ' another team member may submit a request.',
1141
+            array('@count' => $days_to_respond),
1142
+            NULL, 'boinc:team-request-foundership');
1143
+        }
1144
+        $output .= '</p>';
1145
+        $output .= '<ul class="tab-list">';
1146
+        $output .= '  <li class="first last tab">' .
1147 1147
         l(bts('Assume foundership', array(), NULL, 'boinc:team-request-foundership'), "community/teams/{$team_id}/assume-foundership") . '</li>';
1148
-      $output .= '</ul>';
1148
+        $output .= '</ul>';
1149 1149
     }
1150 1150
     else {
1151
-      $output .= '<p>';
1152
-      if ($days_to_deadline == 1) {
1151
+        $output .= '<p>';
1152
+        if ($days_to_deadline == 1) {
1153 1153
         $output .= bts('The team founder has 1 day to respond to your'
1154
-          . ' transfer request.',
1155
-          NULL, 'boinc:team-request-foundership');
1156
-      }
1157
-      else {
1154
+            . ' transfer request.',
1155
+            NULL, 'boinc:team-request-foundership');
1156
+        }
1157
+        else {
1158 1158
         $output .= bts('The team founder has @count days to respond to your'
1159
-          . ' transfer request.', array('@count' => $days_to_deadline),
1160
-          NULL, 'boinc:team-request-foundership');
1161
-      }
1162
-      $output .= '</p>';
1159
+            . ' transfer request.', array('@count' => $days_to_deadline),
1160
+            NULL, 'boinc:team-request-foundership');
1161
+        }
1162
+        $output .= '</p>';
1163 1163
     }
1164
-  }
1165
-  elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
1164
+    }
1165
+    elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
1166 1166
     // If this user does not have a transfer request pending, but new requests
1167 1167
     // are not allowed, set the deadline to 90 days instead of 60 (as the user
1168 1168
     // who made the request has 30 additional days to assume foundership if
@@ -1171,131 +1171,131 @@  discard block
 block discarded – undo
1171 1171
     $days_to_deadline = ceil(($deadline - time()) / (24*60*60)) + 30;
1172 1172
     $output .= '<p>';
1173 1173
     $output .= bts('A team foundership change was already requested recently.'
1174
-      . ' Only one request is allowed within a period of 90 days.',
1175
-      NULL, 'boinc:team-request-foundership');
1174
+        . ' Only one request is allowed within a period of 90 days.',
1175
+        NULL, 'boinc:team-request-foundership');
1176 1176
     if ($days_to_deadline == 1) {
1177
-      $output .= ' (' . bts('1 day remaining', array(), NULL, 'boinc:team-request-foundership') . ')';
1177
+        $output .= ' (' . bts('1 day remaining', array(), NULL, 'boinc:team-request-foundership') . ')';
1178 1178
     }
1179 1179
     else {
1180
-      $output .= ' (' . bts('@count days remaining',
1180
+        $output .= ' (' . bts('@count days remaining',
1181 1181
         array('@count' => $days_to_deadline),
1182 1182
         NULL, 'boinc:team-request-foundership') . ')';
1183 1183
     }
1184 1184
     $output .= '</p>';
1185
-  }
1186
-  else {
1185
+    }
1186
+    else {
1187 1187
     $output .= '<p>' . bts('If the team founder is not active and you want to'
1188
-      . ' assume the role of founder, click below to request foundership of'
1189
-      . ' @this_team.',
1190
-      array('@this_team' =>$team->title), NULL, 'boinc:team-request-foundership') . '</p>';
1188
+        . ' assume the role of founder, click below to request foundership of'
1189
+        . ' @this_team.',
1190
+        array('@this_team' =>$team->title), NULL, 'boinc:team-request-foundership') . '</p>';
1191 1191
     $output .= '<ul class="tab-list">';
1192 1192
     $output .= '  <li class="first last tab">' .
1193
-      l(bts('Initiate request', array(), NULL, 'boinc:team-request-foundership'), "community/teams/{$team_id}/request-foundership") . '</li>';
1193
+        l(bts('Initiate request', array(), NULL, 'boinc:team-request-foundership'), "community/teams/{$team_id}/request-foundership") . '</li>';
1194 1194
     $output .= '</ul>';
1195
-  }
1196
-  return $output;
1195
+    }
1196
+    return $output;
1197 1197
 }
1198 1198
 
1199 1199
 /**
1200 1200
  * Respond to foundership transfer requests for a team
1201 1201
  */
1202 1202
 function boincteam_request_foundership_response_panel($team_id) {
1203
-  global $user;
1204
-  $account = user_load($user->uid);
1205
-  $team = node_load($team_id);
1206
-  $boincteam_id = boincteam_lookup_id($team_id);
1207
-  $boincteam = boincteam_load($boincteam_id);
1208
-  $boincuser_id = $account->boincuser_id;
1209
-  $output = '';
1203
+    global $user;
1204
+    $account = user_load($user->uid);
1205
+    $team = node_load($team_id);
1206
+    $boincteam_id = boincteam_lookup_id($team_id);
1207
+    $boincteam = boincteam_load($boincteam_id);
1208
+    $boincuser_id = $account->boincuser_id;
1209
+    $output = '';
1210 1210
 
1211
-  if ($boincteam->ping_user) {
1211
+    if ($boincteam->ping_user) {
1212 1212
     if ($boincteam->ping_user < 0) {
1213
-      $member = user_load(boincuser_lookup_uid(-$boincteam->ping_user));
1214
-      $output .= '<h2 class="pane-title">' . bts('Obsolete transfer request', array(), NULL, 'boinc:team-request-foundership-response')
1213
+        $member = user_load(boincuser_lookup_uid(-$boincteam->ping_user));
1214
+        $output .= '<h2 class="pane-title">' . bts('Obsolete transfer request', array(), NULL, 'boinc:team-request-foundership-response')
1215 1215
         . '</h2>';
1216
-      $output .= '<p>' . bts('Team member @name requested team foundership on'
1216
+        $output .= '<p>' . bts('Team member @name requested team foundership on'
1217 1217
         . ' @date, but then left the team. This request is now canceled.',
1218 1218
         array(
1219
-          '@name' => $member->boincuser_name,
1220
-          '@date' => date('j M Y', $boincteam->ping_time),
1219
+            '@name' => $member->boincuser_name,
1220
+            '@date' => date('j M Y', $boincteam->ping_time),
1221 1221
         ),
1222 1222
         NULL, 'boinc:team-request-foundership-response') . '</p>';
1223
-      // Automatically cancel the request
1224
-      db_set_active('boinc_rw');
1225
-      db_query("
1223
+        // Automatically cancel the request
1224
+        db_set_active('boinc_rw');
1225
+        db_query("
1226 1226
         UPDATE {team}
1227 1227
         SET ping_user=0
1228 1228
         WHERE id = '%d'",
1229 1229
         $boincteam_id
1230
-      );
1231
-      db_set_active('default');
1230
+        );
1231
+        db_set_active('default');
1232 1232
     }
1233 1233
     else {
1234
-      $member = user_load(boincuser_lookup_uid($boincteam->ping_user));
1235
-      $output .= '<h2 class="pane-title">' . bts('Respond to transfer request', array(), NULL, 'boinc:team-request-foundership-response')
1234
+        $member = user_load(boincuser_lookup_uid($boincteam->ping_user));
1235
+        $output .= '<h2 class="pane-title">' . bts('Respond to transfer request', array(), NULL, 'boinc:team-request-foundership-response')
1236 1236
         . '</h2>';
1237
-      $output .= '<p>' . bts('Team member @name has requested team foundership.'
1237
+        $output .= '<p>' . bts('Team member @name has requested team foundership.'
1238 1238
         . ' This may be because you left the team or have not had contact with'
1239 1239
         . ' the team for a long time.', array(
1240
-          '@name' => $member->boincuser_name,
1240
+            '@name' => $member->boincuser_name,
1241 1241
         )
1242
-      , array(), NULL, 'boinc:team-request-foundership-response') . '</p>';
1243
-      $output .= '<p>' . bts("If you don't decline the request by @date, @name"
1242
+        , array(), NULL, 'boinc:team-request-foundership-response') . '</p>';
1243
+        $output .= '<p>' . bts("If you don't decline the request by @date, @name"
1244 1244
         . ' will have the option of assuming team foundership. (note: To'
1245 1245
         . ' accept the request, assign foundership to @name using the form'
1246 1246
         . ' below)',
1247 1247
         array(
1248
-          '@name' => $member->boincuser_name,
1249
-          '@date' => date('j M Y', boincteam_foundership_transfer_ok_time($boincteam)),
1248
+            '@name' => $member->boincuser_name,
1249
+            '@date' => date('j M Y', boincteam_foundership_transfer_ok_time($boincteam)),
1250 1250
         ),
1251 1251
         NULL, 'boinc:team-request-foundership-response') . '</p>';
1252
-      $output .= '<ul class="tab-list">';
1253
-      $output .= '  <li class="first last tab">' .
1252
+        $output .= '<ul class="tab-list">';
1253
+        $output .= '  <li class="first last tab">' .
1254 1254
         l(bts('Deny request', array(), NULL, 'boinc:team-request-foundership-response'), "community/teams/{$team_id}/deny-foundership-request") . '</li>';
1255
-      $output .= '</ul>';
1255
+        $output .= '</ul>';
1256 1256
     }
1257
-  }
1258
-  return $output;
1257
+    }
1258
+    return $output;
1259 1259
 }
1260 1260
 
1261 1261
 function boincteam_search_panel() {
1262
-  $output = '';
1263
-  if (module_exists('global_search_teams_solr')) {
1262
+    $output = '';
1263
+    if (module_exists('global_search_teams_solr')) {
1264 1264
     $output .= '<h2 class="pane-title">' . bts('Search teams', array(), NULL, 'boinc:search-team') . '</h2>';
1265 1265
     //$output .= '<p>' . bts('Render a search form here.', array(), NULL, 'boinc:search-team') . '</p>';
1266 1266
     $output .= '<p>' . boincteam_search_view() . '</p>';
1267
-  }
1268
-  return $output;
1267
+    }
1268
+    return $output;
1269 1269
 }
1270 1270
 
1271 1271
 function boincteam_search_view($type = 'team') {
1272
-  // Get the team search form
1273
-  $search_page = apachesolr_search_page_load('team_search');
1274
-  module_load_include('inc', 'apachesolr_search', 'apachesolr_search.pages');
1275
-  return drupal_get_form('apachesolr_search_custom_page_search_form', $search_page);
1272
+    // Get the team search form
1273
+    $search_page = apachesolr_search_page_load('team_search');
1274
+    module_load_include('inc', 'apachesolr_search', 'apachesolr_search.pages');
1275
+    return drupal_get_form('apachesolr_search_custom_page_search_form', $search_page);
1276 1276
 }
1277 1277
 
1278 1278
 /**
1279 1279
  * General info about the concept of teams
1280 1280
  */
1281 1281
 function boincteam_topic_overview_panel() {
1282
-  $site_name =  variable_get('site_name', 'Drupal-BOINC');
1283
-  $output = '';
1284
-  $output .= '<h2 class="pane-title">' . bts('Teams', array(), NULL, 'boinc:team-general-info') . '</h2>';
1285
-  $output .= '<div class="">';
1286
-  $output .= '<p>' . bts('@project participants may form teams. You may belong'
1282
+    $site_name =  variable_get('site_name', 'Drupal-BOINC');
1283
+    $output = '';
1284
+    $output .= '<h2 class="pane-title">' . bts('Teams', array(), NULL, 'boinc:team-general-info') . '</h2>';
1285
+    $output .= '<div class="">';
1286
+    $output .= '<p>' . bts('@project participants may form teams. You may belong'
1287 1287
     . ' to only one team. You can join or quit a team at any time. To join a'
1288 1288
     . ' team, visit its team page and click "Join this team". Each team has a'
1289 1289
     . ' founder who may:', array('@project' => $site_name), NULL, 'boinc:team-general-info') . '</p>';
1290
-  $output .= '<ul>';
1291
-  $output .= '  <li>' . bts('Private Message all team members', array(), NULL, 'boinc:team-general-info') . '</li>';
1292
-  $output .= '  <li>' . bts("edit the team's name and description", array(), NULL, 'boinc:team-general-info') . '</li>';
1293
-  $output .= '  <li>' . bts('add or remove team admins', array(), NULL, 'boinc:team-general-info') . '</li>';
1294
-  $output .= '  <li>' . bts('remove members from the team', array(), NULL, 'boinc:team-general-info') . '</li>';
1295
-  $output .= '  <li>' . bts('disband a team if it has no members', array(), NULL, 'boinc:team-general-info') . '</li>';
1296
-  $output .= '</ul>';
1297
-  $output .= '</div>';
1298
-  return $output;
1290
+    $output .= '<ul>';
1291
+    $output .= '  <li>' . bts('Private Message all team members', array(), NULL, 'boinc:team-general-info') . '</li>';
1292
+    $output .= '  <li>' . bts("edit the team's name and description", array(), NULL, 'boinc:team-general-info') . '</li>';
1293
+    $output .= '  <li>' . bts('add or remove team admins', array(), NULL, 'boinc:team-general-info') . '</li>';
1294
+    $output .= '  <li>' . bts('remove members from the team', array(), NULL, 'boinc:team-general-info') . '</li>';
1295
+    $output .= '  <li>' . bts('disband a team if it has no members', array(), NULL, 'boinc:team-general-info') . '</li>';
1296
+    $output .= '</ul>';
1297
+    $output .= '</div>';
1298
+    return $output;
1299 1299
 }
1300 1300
 
1301 1301
 /**
@@ -1323,50 +1323,50 @@  discard block
 block discarded – undo
1323 1323
  * Link to view a team
1324 1324
  */
1325 1325
 function boincteam_view_team_panel($team_id) {
1326
-  $team = node_load($team_id);
1327
-  if ($team->type != "team") {
1326
+    $team = node_load($team_id);
1327
+    if ($team->type != "team") {
1328 1328
     return;
1329
-  }
1330
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
1331
-  $founder = user_load(get_drupal_id($boincteam->userid));
1332
-  $new_members = array();
1333
-  if ($boincteam->new_members) {
1329
+    }
1330
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
1331
+    $founder = user_load(get_drupal_id($boincteam->userid));
1332
+    $new_members = array();
1333
+    if ($boincteam->new_members) {
1334 1334
     foreach ($boincteam->new_members as $member) {
1335
-      $account = user_load(get_drupal_id($member->id));
1336
-      $new_members[] = l($account->boincuser_name, "account/{$account->uid}");
1335
+        $account = user_load(get_drupal_id($member->id));
1336
+        $new_members[] = l($account->boincuser_name, "account/{$account->uid}");
1337 1337
     }
1338
-  }
1339
-  $output = '';
1340
-  $output .= '<h2 class="pane-title">' . $boincteam->name . '</h2>';
1341
-  $output .= '<div>';
1342
-  $output .= '<div class="left-column">';
1343
-  $output .= '<ul class="stats">';
1344
-  $output .= '  <li>' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . ': ' . number_format($boincteam->total_credit, 0) . '</li>';
1345
-  $output .= '  <li>' . bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC') . ': ' . number_format($boincteam->expavg_credit, 2) . '</li>';
1346
-  $output .= '  <li>' . bts('Country', array(), NULL, 'boinc:country-of-origin') . ': ' . $boincteam->country . '</li>';
1347
-  $output .= '  <li>' . bts('Type', array(), NULL, 'boinc:view-team-info') . ': ' . boincteam_get_type($team_id) . '</li>';
1348
-  $output .= '</ul>';
1349
-  $output .= '</div>';
1350
-  $output .= '<div class="right-column">';
1351
-  $output .= '<ul class="stats">';
1352
-  $output .= '  <li>' . bts('Founder', array(), NULL, 'boinc:view-team-info') . ': ' . l($founder->boincuser_name, "account/{$founder->uid}") . '</li>';
1353
-  $output .= '  <li>' . bts('New members in last day', array(), NULL, 'boinc:view-team-info') . ': ' . implode('&middot;', $new_members) . '</li>';
1354
-  $output .= '  <li>' . bts('Total members', array(), NULL, 'boinc:view-team-info') . ': ' . l($boincteam->nusers, "community/teams/{$team_id}/members") . '</li>';
1355
-  $output .= '  <li>' . bts('Active members', array(), NULL, 'boinc:view-team-info') . ': ' . $boincteam->nusers_active . '</li>';
1356
-  $output .= '  <li>' . bts('Members with credit', array(), NULL, 'boinc:view-team-info') . ': ' . $boincteam->nusers_worked . '</li>';
1357
-  $output .= '</ul>';
1358
-  $output .= '</div>';
1359
-  $output .= '</div>';
1360
-  $output .= '<div class="clearfix"></div>';
1361
-  if ($boincteam->url) {
1338
+    }
1339
+    $output = '';
1340
+    $output .= '<h2 class="pane-title">' . $boincteam->name . '</h2>';
1341
+    $output .= '<div>';
1342
+    $output .= '<div class="left-column">';
1343
+    $output .= '<ul class="stats">';
1344
+    $output .= '  <li>' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . ': ' . number_format($boincteam->total_credit, 0) . '</li>';
1345
+    $output .= '  <li>' . bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC') . ': ' . number_format($boincteam->expavg_credit, 2) . '</li>';
1346
+    $output .= '  <li>' . bts('Country', array(), NULL, 'boinc:country-of-origin') . ': ' . $boincteam->country . '</li>';
1347
+    $output .= '  <li>' . bts('Type', array(), NULL, 'boinc:view-team-info') . ': ' . boincteam_get_type($team_id) . '</li>';
1348
+    $output .= '</ul>';
1349
+    $output .= '</div>';
1350
+    $output .= '<div class="right-column">';
1351
+    $output .= '<ul class="stats">';
1352
+    $output .= '  <li>' . bts('Founder', array(), NULL, 'boinc:view-team-info') . ': ' . l($founder->boincuser_name, "account/{$founder->uid}") . '</li>';
1353
+    $output .= '  <li>' . bts('New members in last day', array(), NULL, 'boinc:view-team-info') . ': ' . implode('&middot;', $new_members) . '</li>';
1354
+    $output .= '  <li>' . bts('Total members', array(), NULL, 'boinc:view-team-info') . ': ' . l($boincteam->nusers, "community/teams/{$team_id}/members") . '</li>';
1355
+    $output .= '  <li>' . bts('Active members', array(), NULL, 'boinc:view-team-info') . ': ' . $boincteam->nusers_active . '</li>';
1356
+    $output .= '  <li>' . bts('Members with credit', array(), NULL, 'boinc:view-team-info') . ': ' . $boincteam->nusers_worked . '</li>';
1357
+    $output .= '</ul>';
1358
+    $output .= '</div>';
1359
+    $output .= '</div>';
1360
+    $output .= '<div class="clearfix"></div>';
1361
+    if ($boincteam->url) {
1362 1362
     $output .= '<div class="stats">';
1363 1363
     $output .= bts('Website', array(), NULL, 'boinc:website-of-user-or-team') . ': ' . l("http://{$boincteam->url}", "http://{$boincteam->url}");
1364 1364
     $output .= '</div>';
1365
-  }
1366
-  if ($team->body) {
1365
+    }
1366
+    if ($team->body) {
1367 1367
     $output .= '<h3>' . bts('Description', array(), NULL, 'boinc:team-description') . '</h3>';
1368 1368
     $output .= check_markup($team->body, $team->format);
1369 1369
     $output .= '</div>';
1370
-  }
1371
-  return $output;
1370
+    }
1371
+    return $output;
1372 1372
 }
Please login to merge, or discard this patch.
sites/default/boinc/modules/boincteam/includes/boincteam_forum.forms.inc 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -14,84 +14,84 @@  discard block
 block discarded – undo
14 14
  * The definition of the create team form
15 15
  */
16 16
 function boincteam_forum_create_form(&$form_state) {
17
-  $form = array();
17
+    $form = array();
18 18
 
19
-  global $user;
20
-  $account = user_load($user->uid);
19
+    global $user;
20
+    $account = user_load($user->uid);
21 21
 
22
-  $default = array(
22
+    $default = array(
23 23
     'title' => '',
24 24
     'min_time_between_posts' => '',
25 25
     'min_total_credit_to_post' => '',
26 26
     'min_avg_credit_to_post' => '',
27 27
     'public' => 0,
28 28
     'description' => '',
29
-  );
29
+    );
30 30
 
31
-  // Standard option sets
32
-  $form['boolean_options'] = array(
31
+    // Standard option sets
32
+    $form['boolean_options'] = array(
33 33
     '#type' => 'value',
34 34
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
35
-  );
35
+    );
36 36
 
37
-  // Form elements
38
-  $form['title'] = array(
37
+    // Form elements
38
+    $form['title'] = array(
39 39
     '#title' => bts('Message board title', array(), NULL, 'boinc:team-forum-create/edit'),
40 40
     '#type' => 'textfield',
41 41
     '#default_value' => $default['title'],
42 42
     '#size' => 34,
43 43
     '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'),
44
-  );
45
-  $form['min_time_between_posts'] = array(
44
+    );
45
+    $form['min_time_between_posts'] = array(
46 46
     '#title' => bts('Minimum time between posts', array(), NULL, 'boinc:team-forum-create/edit'),
47 47
     '#type' => 'textfield',
48 48
     '#default_value' => $default['min_time_between_posts'],
49 49
     '#size' => 12,
50 50
     '#description' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
51
-  );
52
-  $form['min_total_credit_to_post'] = array(
51
+    );
52
+    $form['min_total_credit_to_post'] = array(
53 53
     '#title' => bts('Minimum total credit to post', array(), NULL, 'boinc:team-forum-create/edit'),
54 54
     '#type' => 'textfield',
55 55
     '#default_value' => $default['min_total_credit_to_post'],
56 56
     '#size' => 12,
57
-  );
58
-  $form['min_avg_credit_to_post'] = array(
57
+    );
58
+    $form['min_avg_credit_to_post'] = array(
59 59
     '#title' => bts('Minimum avg credit to post', array(), NULL, 'boinc:team-forum-create/edit'),
60 60
     '#type' => 'textfield',
61 61
     '#default_value' => $default['min_avg_credit_to_post'],
62 62
     '#size' => 12,
63
-  );
64
-  $form['public'] = array(
63
+    );
64
+    $form['public'] = array(
65 65
     '#title' => bts('Allow public to read board?', array(), NULL, 'boinc:team-forum-create/edit'),
66 66
     '#type' => 'radios',
67 67
     '#options' => $form['boolean_options']['#value'],
68 68
     '#attributes' => array('class' => 'fancy'),
69 69
     '#default_value' => $default['public'],
70
-  );
71
-  $form['description'] = array(
70
+    );
71
+    $form['description'] = array(
72 72
     '#title' => bts('Description', array(), NULL, 'boinc:team-forum-create/edit:-1:ignoreoverwrite'),
73 73
     '#type' => 'textarea',
74 74
     '#default_value' => $default['description'],
75 75
     '#size' => 5,
76
-  );
76
+    );
77 77
 
78
-  // Form control
79
-  $form['form control tabs prefix'] = array(
78
+    // Form control
79
+    $form['form control tabs prefix'] = array(
80 80
     '#value' => '<ul class="form-control tab-list">'
81
-  );
82
-  $form['submit'] = array(
81
+    );
82
+    $form['submit'] = array(
83 83
     '#prefix' => '<li class="first tab">',
84 84
     '#type' => 'submit',
85 85
     '#value' => bts('Create message board', array(), NULL, 'boinc:team-forum-create/edit'),
86 86
     '#suffix' => '</li>',
87
-  );
88
-  $form['form control tabs'] = array(
87
+    );
88
+    $form['form control tabs'] = array(
89 89
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/forum/add', TRUE)) . '</li>'
90
-  );
90
+    );
91 91
 
92
-  $form['#redirect'] = "community/teams/{$account->team}";
92
+    $form['#redirect'] = "community/teams/{$account->team}";
93 93
 
94
-  return $form;
94
+    return $form;
95 95
 }
96 96
 
97 97
 /**
@@ -99,33 +99,33 @@  discard block
 block discarded – undo
99 99
  */
100 100
 function boincteam_forum_create_form_validate($form, &$form_state) {
101 101
 
102
-  $values = $form_state['values'];
102
+    $values = $form_state['values'];
103 103
 
104
-  if (!$values['title']) {
104
+    if (!$values['title']) {
105 105
     form_set_error('name', bts('Message board title is required.', array(), NULL, 'boinc:team-forum-create/edit'));
106
-  }
107
-  if (!is_numeric($values['min_time_between_posts']) OR
106
+    }
107
+    if (!is_numeric($values['min_time_between_posts']) OR
108 108
       $values['min_time_between_posts'] < 0) {
109 109
     form_set_error('min_time_between_posts',
110
-      bts('Please set the minimum time required between posts.', array(), NULL, 'boinc:team-forum-create/edit')
110
+        bts('Please set the minimum time required between posts.', array(), NULL, 'boinc:team-forum-create/edit')
111 111
     );
112
-  }
113
-  if (!is_numeric($values['min_total_credit_to_post']) OR
112
+    }
113
+    if (!is_numeric($values['min_total_credit_to_post']) OR
114 114
       $values['min_total_credit_to_post'] < 0) {
115 115
     form_set_error('min_total_credit_to_post',
116
-      bts('Please set the minimum total credit that a user'
116
+        bts('Please set the minimum total credit that a user'
117 117
         . ' must earn in order to post to this message board.',
118 118
         array(), NULL, 'boinc:team-forum-create/edit')
119 119
     );
120
-  }
121
-  if (!is_numeric($values['min_avg_credit_to_post']) OR
120
+    }
121
+    if (!is_numeric($values['min_avg_credit_to_post']) OR
122 122
       $values['min_avg_credit_to_post'] < 0) {
123 123
     form_set_error('min_avg_credit_to_post',
124
-      bts('Please set the minimum average credit that a user'
124
+        bts('Please set the minimum average credit that a user'
125 125
         . ' is required to have in order to post to this message board.',
126 126
         array(), NULL, 'boinc:team-forum-create/edit')
127 127
     );
128
-  }
128
+    }
129 129
 }
130 130
 
131 131
 /**
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
  */
134 134
 function boincteam_forum_create_form_submit($form, &$form_state) {
135 135
 
136
-  $values = $form_state['values'];
136
+    $values = $form_state['values'];
137 137
 
138
-  global $user;
139
-  $account = user_load($user->uid);
138
+    global $user;
139
+    $account = user_load($user->uid);
140 140
 
141
-  // Add the team forum to the db
142
-  db_query("
141
+    // Add the team forum to the db
142
+    db_query("
143 143
     INSERT INTO {boincteam_forum} SET
144 144
       nid = %d,
145 145
       title = '%s',
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
     (int) $values['min_avg_credit_to_post'],
158 158
     ($values['public']) ? 1 : 0,
159 159
     $values['description']
160
-  );
160
+    );
161 161
 
162
-  drupal_set_message(t('Message board "@forum" has been created.',
162
+    drupal_set_message(t('Message board "@forum" has been created.',
163 163
     array('@forum' => $values['title'])));
164 164
 }
165 165
 
@@ -171,84 +171,84 @@  discard block
 block discarded – undo
171 171
  * The definition of the edit team forum form
172 172
  */
173 173
 function boincteam_forum_edit_form(&$form_state, $tfid) {
174
-  $form = array();
175
-  $boincteam_forum = boincteam_forum_load($tfid);
174
+    $form = array();
175
+    $boincteam_forum = boincteam_forum_load($tfid);
176 176
 
177
-  $form_state['storage']['tfid'] = $tfid;
177
+    $form_state['storage']['tfid'] = $tfid;
178 178
 
179
-  $default = array(
179
+    $default = array(
180 180
     'title' => $boincteam_forum->title,
181 181
     'min_time_between_posts' => $boincteam_forum->min_time_between_posts,
182 182
     'min_total_credit_to_post' => $boincteam_forum->min_total_credit_to_post,
183 183
     'min_avg_credit_to_post' => $boincteam_forum->min_avg_credit_to_post,
184 184
     'public' => ($boincteam_forum->public) ? 1 : 0,
185 185
     'description' => $boincteam_forum->description,
186
-  );
186
+    );
187 187
 
188
-  // Standard option sets
189
-  $form['boolean_options'] = array(
188
+    // Standard option sets
189
+    $form['boolean_options'] = array(
190 190
     '#type' => 'value',
191 191
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
192
-  );
192
+    );
193 193
 
194
-  // Form elements
195
-  $form['title'] = array(
194
+    // Form elements
195
+    $form['title'] = array(
196 196
     '#title' => bts('Message board title', array(), NULL, 'boinc:team-forum-create/edit'),
197 197
     '#type' => 'textfield',
198 198
     '#default_value' => $default['title'],
199 199
     '#size' => 34,
200 200
     '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'),
201
-  );
202
-  $form['min_time_between_posts'] = array(
201
+    );
202
+    $form['min_time_between_posts'] = array(
203 203
     '#title' => bts('Minimum time between posts', array(), NULL, 'boinc:team-forum-create/edit'),
204 204
     '#type' => 'textfield',
205 205
     '#default_value' => $default['min_time_between_posts'],
206 206
     '#size' => 12,
207 207
     '#description' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
208
-  );
209
-  $form['min_total_credit_to_post'] = array(
208
+    );
209
+    $form['min_total_credit_to_post'] = array(
210 210
     '#title' => bts('Minimum total credit to post', array(), NULL, 'boinc:team-forum-create/edit'),
211 211
     '#type' => 'textfield',
212 212
     '#default_value' => $default['min_total_credit_to_post'],
213 213
     '#size' => 12,
214
-  );
215
-  $form['min_avg_credit_to_post'] = array(
214
+    );
215
+    $form['min_avg_credit_to_post'] = array(
216 216
     '#title' => bts('Minimum avg credit to post', array(), NULL, 'boinc:team-forum-create/edit'),
217 217
     '#type' => 'textfield',
218 218
     '#default_value' => $default['min_avg_credit_to_post'],
219 219
     '#size' => 12,
220
-  );
221
-  $form['public'] = array(
220
+    );
221
+    $form['public'] = array(
222 222
     '#title' => bts('Allow public to read board?', array(), NULL, 'boinc:team-forum-create/edit'),
223 223
     '#type' => 'radios',
224 224
     '#options' => $form['boolean_options']['#value'],
225 225
     '#attributes' => array('class' => 'fancy'),
226 226
     '#default_value' => $default['public'],
227
-  );
228
-  $form['description'] = array(
227
+    );
228
+    $form['description'] = array(
229 229
     '#title' => bts('Description', array(), NULL, 'boinc:team-forum-create/edit:-1:ignoreoverwrite'),
230 230
     '#type' => 'textarea',
231 231
     '#default_value' => $default['description'],
232 232
     '#size' => 5,
233
-  );
233
+    );
234 234
 
235
-  // Form control
236
-  $form['form control tabs prefix'] = array(
235
+    // Form control
236
+    $form['form control tabs prefix'] = array(
237 237
     '#value' => '<ul class="form-control tab-list">'
238
-  );
239
-  $form['submit'] = array(
238
+    );
239
+    $form['submit'] = array(
240 240
     '#prefix' => '<li class="first tab">',
241 241
     '#type' => 'submit',
242 242
     '#value' => bts('Save message board', array(), NULL, 'boinc:team-forum-create/edit'),
243 243
     '#suffix' => '</li>',
244
-  );
245
-  $form['form control tabs'] = array(
244
+    );
245
+    $form['form control tabs'] = array(
246 246
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/forum', TRUE)) . '</li>'
247
-  );
247
+    );
248 248
 
249
-  $form['#redirect'] = "community/teams/{$boincteam_forum->nid}";
249
+    $form['#redirect'] = "community/teams/{$boincteam_forum->nid}";
250 250
 
251
-  return $form;
251
+    return $form;
252 252
 }
253 253
 
254 254
 /**
@@ -256,33 +256,33 @@  discard block
 block discarded – undo
256 256
  */
257 257
 function boincteam_forum_edit_form_validate($form, &$form_state) {
258 258
 
259
-  $values = $form_state['values'];
259
+    $values = $form_state['values'];
260 260
 
261
-  if (!$values['title']) {
261
+    if (!$values['title']) {
262 262
     form_set_error('name', bts('Message board title is required.', array(), NULL, 'boinc:team-forum-create/edit'));
263
-  }
264
-  if (!is_numeric($values['min_time_between_posts']) OR
263
+    }
264
+    if (!is_numeric($values['min_time_between_posts']) OR
265 265
       $values['min_time_between_posts'] < 0) {
266 266
     form_set_error('min_time_between_posts',
267
-      bts('Please set the minimum time required between posts.', array(), NULL, 'boinc:team-forum-create/edit')
267
+        bts('Please set the minimum time required between posts.', array(), NULL, 'boinc:team-forum-create/edit')
268 268
     );
269
-  }
270
-  if (!is_numeric($values['min_total_credit_to_post']) OR
269
+    }
270
+    if (!is_numeric($values['min_total_credit_to_post']) OR
271 271
       $values['min_total_credit_to_post'] < 0) {
272 272
     form_set_error('min_total_credit_to_post',
273
-      bts('Please set the minimum total credit that a user'
273
+        bts('Please set the minimum total credit that a user'
274 274
         . ' must earn in order to post to this message board.',
275 275
         array(), NULL, 'boinc:team-forum-create/edit')
276 276
     );
277
-  }
278
-  if (!is_numeric($values['min_avg_credit_to_post']) OR
277
+    }
278
+    if (!is_numeric($values['min_avg_credit_to_post']) OR
279 279
       $values['min_avg_credit_to_post'] < 0) {
280 280
     form_set_error('min_avg_credit_to_post',
281
-      bts('Please set the minimum average credit that a user'
281
+        bts('Please set the minimum average credit that a user'
282 282
         . ' is required to have in order to post to this message board.',
283 283
         array(), NULL, 'boinc:team-forum-create/edit')
284 284
     );
285
-  }
285
+    }
286 286
 }
287 287
 
288 288
 /**
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
  */
291 291
 function boincteam_forum_edit_form_submit($form, &$form_state) {
292 292
 
293
-  $tfid = $form_state['storage']['tfid'];
294
-  $values = $form_state['values'];
293
+    $tfid = $form_state['storage']['tfid'];
294
+    $values = $form_state['values'];
295 295
 
296
-  // Update the team forum in the db
297
-  db_query("
296
+    // Update the team forum in the db
297
+    db_query("
298 298
     UPDATE {boincteam_forum} SET
299 299
       title = '%s',
300 300
       min_time_between_posts = '%d',
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
     ($values['public']) ? 1 : 0,
312 312
     $values['description'],
313 313
     $tfid
314
-  );
314
+    );
315 315
 
316
-  drupal_set_message(t('Details for message board "@forum" have been updated.',
316
+    drupal_set_message(t('Details for message board "@forum" have been updated.',
317 317
     array('@forum' => $values['title'])));
318 318
 
319
-  // The storage variable quietly kills redirection for some reason... unset it
320
-  unset($form_state['storage']);
319
+    // The storage variable quietly kills redirection for some reason... unset it
320
+    unset($form_state['storage']);
321 321
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/includes/boincteam.helpers.inc 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -15,41 +15,41 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function boincteam_sync() {
17 17
 
18
-  // Get the list of teams to import
19
-  db_set_active('boinc_rw');
20
-  $boinc_teams = db_query('
18
+    // Get the list of teams to import
19
+    db_set_active('boinc_rw');
20
+    $boinc_teams = db_query('
21 21
     SELECT id, name, description, userid, create_time, seti_id
22 22
     FROM team
23 23
     WHERE mod_time > FROM_UNIXTIME(%d)',
24 24
     variable_get('boincteam_last_sync', 0)
25
-  );
26
-  db_set_active('default');
25
+    );
26
+    db_set_active('default');
27 27
 
28
-  $existing_teams = array();
28
+    $existing_teams = array();
29 29
 
30
-  // Get the list of teams already in Drupal to be sure we're not importing
31
-  // any twice
32
-  $result = db_query('
30
+    // Get the list of teams already in Drupal to be sure we're not importing
31
+    // any twice
32
+    $result = db_query('
33 33
     SELECT nid, team_id FROM {boincteam}'
34
-  );
35
-  while ($row = db_fetch_object($result)) {
34
+    );
35
+    while ($row = db_fetch_object($result)) {
36 36
     $existing_teams[$row->team_id] = $row->nid;
37
-  }
37
+    }
38 38
 
39
-  while ($boinc_team = db_fetch_object($boinc_teams)) {
39
+    while ($boinc_team = db_fetch_object($boinc_teams)) {
40 40
     $success = NULL;
41 41
     if (isset($existing_teams[$boinc_team->id])) {
42
-      if ($boinc_team->seti_id > 0) {
42
+        if ($boinc_team->seti_id > 0) {
43 43
         // Sync BOINC-wide teams
44 44
         $nid = $existing_teams[$boinc_team->id];
45 45
         $success = boincteam_import($boinc_team, $nid);
46
-      }
46
+        }
47 47
     }
48 48
     else {
49
-      // Import new teams created by RPC or ops/team_import.php
50
-      $success = boincteam_import($boinc_team);
49
+        // Import new teams created by RPC or ops/team_import.php
50
+        $success = boincteam_import($boinc_team);
51
+    }
51 52
     }
52
-  }
53 53
 }
54 54
 
55 55
 
@@ -58,58 +58,58 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function boincteam_import($boincteam, $nid = NULL) {
60 60
 
61
-  $input_format = variable_get('boincimport_input_format', 0);
62
-  $team_type_map = variable_get('boincimport_team_types', array());
61
+    $input_format = variable_get('boincimport_input_format', 0);
62
+    $team_type_map = variable_get('boincimport_team_types', array());
63 63
 
64
-  // Save the team type affiliation
65
-  $team_type_tid = $team_type_map[$boincteam->type];
64
+    // Save the team type affiliation
65
+    $team_type_tid = $team_type_map[$boincteam->type];
66 66
 
67
-  $boincteam->description = html_entity_decode($boincteam->description, ENT_QUOTES, 'utf-8');
68
-  // Be sure the text is filtered for the default input format
69
-  $boincteam->description = check_markup($boincteam->description, $input_format);
67
+    $boincteam->description = html_entity_decode($boincteam->description, ENT_QUOTES, 'utf-8');
68
+    // Be sure the text is filtered for the default input format
69
+    $boincteam->description = check_markup($boincteam->description, $input_format);
70 70
 
71
-  $teaser = node_teaser($boincteam->description);
71
+    $teaser = node_teaser($boincteam->description);
72 72
 
73
-  if ($nid) {
73
+    if ($nid) {
74 74
     // Update an existing node
75 75
     $node = node_load($nid);
76 76
     $node->title = $boincteam->name;
77 77
     $node->body = $boincteam->description;
78 78
     $node->teaser = $teaser;
79 79
     $node->uid = boincuser_lookup_uid($boincteam->userid);
80
-  }
81
-  else {
80
+    }
81
+    else {
82 82
     // Construct the team as a new node
83 83
     $node = array(
84
-      'type' => 'team',
85
-      'title' => $boincteam->name,
86
-      'body' => $boincteam->description,
87
-      'teaser' => $teaser,
88
-      'uid' => boincuser_lookup_uid($boincteam->userid),
89
-      'path' => null,
90
-      'status' => 1,  // published or not - always publish
91
-      'promote' => 0,
92
-      'created' => $boincteam->create_time,
93
-      'comment' => 0,  // comments disabled
94
-      'moderate' => 0,
95
-      'sticky' => 0,
96
-      'format' => $input_format
84
+        'type' => 'team',
85
+        'title' => $boincteam->name,
86
+        'body' => $boincteam->description,
87
+        'teaser' => $teaser,
88
+        'uid' => boincuser_lookup_uid($boincteam->userid),
89
+        'path' => null,
90
+        'status' => 1,  // published or not - always publish
91
+        'promote' => 0,
92
+        'created' => $boincteam->create_time,
93
+        'comment' => 0,  // comments disabled
94
+        'moderate' => 0,
95
+        'sticky' => 0,
96
+        'format' => $input_format
97 97
     );
98 98
     $node = (object) $node; // node_save requires an object form
99
-  }
99
+    }
100 100
 
101
-  $node->taxonomy[] = taxonomy_get_term($team_type_tid);
101
+    $node->taxonomy[] = taxonomy_get_term($team_type_tid);
102 102
 
103
-  // Save the team node
104
-  node_save($node);
105
-  $success = ($node->nid) ? TRUE : FALSE;
103
+    // Save the team node
104
+    node_save($node);
105
+    $success = ($node->nid) ? TRUE : FALSE;
106 106
 
107
-  if (!$nid) {
107
+    if (!$nid) {
108 108
     // Save the team IDs to a BOINC <--> Drupal reference table, if needed
109 109
     db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam->id, $node->nid);
110
-  }
110
+    }
111 111
 
112
-  return $success;
112
+    return $success;
113 113
 }
114 114
 
115 115
 /**
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
  *   respected. This is useful the list of users are to be contacted.
127 127
  */
128 128
 function _boincteam_userids($boincteamid, $boincid=TRUE, $respectprivacy=TRUE) {
129
-  $sql = 'SELECT user.id as id FROM {user} user WHERE user.teamid=%s';
130
-  if ($respectprivacy) {
129
+    $sql = 'SELECT user.id as id FROM {user} user WHERE user.teamid=%s';
130
+    if ($respectprivacy) {
131 131
     $sql .= ' AND user.send_email=1';
132
-  }
132
+    }
133 133
 
134
-  db_set_active('boinc_ro');
135
-  $dbres = db_query($sql, $boincteamid);
136
-  db_set_active('default');
134
+    db_set_active('boinc_ro');
135
+    $dbres = db_query($sql, $boincteamid);
136
+    db_set_active('default');
137 137
 
138
-  $ids = array();
139
-  while (($result = db_fetch_object($dbres)) != FALSE) {
138
+    $ids = array();
139
+    while (($result = db_fetch_object($dbres)) != FALSE) {
140 140
     $ids[] = $result->id;
141
-  }
142
-  if ($boincid) {
141
+    }
142
+    if ($boincid) {
143 143
     return $ids;
144
-  }
145
-  else {
144
+    }
145
+    else {
146 146
     return array_map('boincuser_lookup_uid', $ids);
147
-  }
147
+    }
148 148
 }
149 149
 
150 150
 /**
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
  *   respected. This is useful the list of users are to be contacted.
159 159
  */
160 160
 function _boincteam_emails($boincteamid, $respectprivacy=TRUE) {
161
-  $sql = 'SELECT user.email_addr as email_addr FROM {user} user WHERE user.teamid=%s';
162
-  if ($respectprivacy) {
161
+    $sql = 'SELECT user.email_addr as email_addr FROM {user} user WHERE user.teamid=%s';
162
+    if ($respectprivacy) {
163 163
     $sql .= ' AND user.send_email=1';
164
-  }
164
+    }
165 165
 
166
-  db_set_active('boinc_ro');
167
-  $dbres = db_query($sql, $boincteamid);
168
-  db_set_active('default');
166
+    db_set_active('boinc_ro');
167
+    $dbres = db_query($sql, $boincteamid);
168
+    db_set_active('default');
169 169
 
170
-  $emails = array();
171
-  while (($result = db_fetch_object($dbres)) != FALSE) {
170
+    $emails = array();
171
+    while (($result = db_fetch_object($dbres)) != FALSE) {
172 172
     $emails[] = $result->email_addr;
173
-  }
174
-  return $emails;
173
+    }
174
+    return $emails;
175 175
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/includes/boincteam.forms.inc 1 patch
Indentation   +333 added lines, -333 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * The definition of the create team form
15 15
  */
16 16
 function boincteam_create_form(&$form_state) {
17
-  $form = array();
17
+    $form = array();
18 18
 
19
-  $default = array(
19
+    $default = array(
20 20
     'name' => '',
21 21
     'name_html' => '',
22 22
     'website' => '',
@@ -24,105 +24,105 @@  discard block
 block discarded – undo
24 24
     'country' => 0,
25 25
     'joinable' => TRUE,
26 26
     'description' => '',
27
-  );
27
+    );
28 28
 
29
-  // Standard option sets
30
-  $form['boolean_options'] = array(
29
+    // Standard option sets
30
+    $form['boolean_options'] = array(
31 31
     '#type' => 'value',
32 32
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
33
-  );
33
+    );
34 34
 
35
-  // Vocabulary based option sets
36
-  $form['type_options'] = array(
35
+    // Vocabulary based option sets
36
+    $form['type_options'] = array(
37 37
     '#type' => 'value',
38 38
     '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose'))
39
-  );
40
-  $vocabs = taxonomy_get_vocabularies(NULL);
41
-  foreach ($vocabs as $vocab) {
39
+    );
40
+    $vocabs = taxonomy_get_vocabularies(NULL);
41
+    foreach ($vocabs as $vocab) {
42 42
     switch ($vocab->name) {
43 43
     case 'Teams':
44 44
       $team_types = taxonomy_get_tree($vocab->vid);
45
-      if (module_exists('internationalization')) {
45
+        if (module_exists('internationalization')) {
46 46
         $team_types = i18ntaxonomy_localize_terms($team_types);
47
-      }
48
-      foreach ($team_types as $team_type) {
47
+        }
48
+        foreach ($team_types as $team_type) {
49 49
         $form['type_options']['#value'][$team_type->tid] = $team_type->name;
50
-      }
51
-      break;
50
+        }
51
+        break;
52 52
     default:
53 53
     }
54
-  }
55
-  $form['country_options'] = array(
54
+    }
55
+    $form['country_options'] = array(
56 56
     '#type' => 'value',
57 57
     '#value' => boinccore_get_country_list(),
58
-  );
58
+    );
59 59
 
60
-  // Form elements
61
-  $form['name'] = array(
60
+    // Form elements
61
+    $form['name'] = array(
62 62
     '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'),
63 63
     '#type' => 'textfield',
64 64
     '#default_value' => $default['name'],
65 65
     '#size' => 34,
66 66
     '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'),
67
-  );
68
-  $form['name_html'] = array(
67
+    );
68
+    $form['name_html'] = array(
69 69
     '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'),
70 70
     '#type' => 'textfield',
71 71
     '#default_value' => $default['name_html'],
72 72
     '#size' => 34,
73 73
     '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'),
74
-  );
75
-  $form['website'] = array(
74
+    );
75
+    $form['website'] = array(
76 76
     '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'),
77 77
     '#type' => 'textfield',
78 78
     '#default_value' => $default['website'],
79 79
     '#size' => 34,
80 80
     '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'),
81
-  );
82
-  $form['type'] = array(
81
+    );
82
+    $form['type'] = array(
83 83
     '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'),
84 84
     '#type' => 'select',
85 85
     '#options' => $form['type_options']['#value'],
86 86
     '#default_value' => $default['type'],
87
-  );
88
-  $form['country'] = array(
87
+    );
88
+    $form['country'] = array(
89 89
     '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'),
90 90
     '#type' => 'select',
91 91
     '#options' => $form['country_options']['#value'],
92 92
     '#default_value' => $default['country'],
93
-  );
94
-  $form['joinable'] = array(
93
+    );
94
+    $form['joinable'] = array(
95 95
     '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'),
96 96
     '#type' => 'radios',
97 97
     '#options' => $form['boolean_options']['#value'],
98 98
     '#attributes' => array('class' => 'fancy'),
99 99
     '#default_value' => $default['joinable'],
100 100
     '#size' => 34,
101
-  );
102
-  $form['description'] = array(
101
+    );
102
+    $form['description'] = array(
103 103
     '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'),
104 104
     '#type' => 'textarea',
105 105
     '#default_value' => $default['description'],
106 106
     '#size' => 5,
107 107
     '#description' => NULL,
108
-  );
109
-  $form['format'] = filter_form();
108
+    );
109
+    $form['format'] = filter_form();
110 110
 
111
-  // Form control
112
-  $form['form control tabs prefix'] = array(
111
+    // Form control
112
+    $form['form control tabs prefix'] = array(
113 113
     '#value' => '<ul class="form-control tab-list">'
114
-  );
115
-  $form['submit'] = array(
114
+    );
115
+    $form['submit'] = array(
116 116
     '#prefix' => '<li class="first tab">',
117 117
     '#type' => 'submit',
118 118
     '#value' => bts('Save team', array(), NULL, 'boinc:team-form-save'),
119 119
     '#suffix' => '</li>',
120
-  );
121
-  $form['form control tabs'] = array(
120
+    );
121
+    $form['form control tabs'] = array(
122 122
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
123
-  );
123
+    );
124 124
 
125
-  return $form;
125
+    return $form;
126 126
 }
127 127
 
128 128
 /**
@@ -130,41 +130,41 @@  discard block
 block discarded – undo
130 130
  */
131 131
 function boincteam_create_form_validate($form, &$form_state) {
132 132
 
133
-  $values = $form_state['values'];
134
-  $name = $values['name'];
133
+    $values = $form_state['values'];
134
+    $name = $values['name'];
135 135
 
136
-  if (!$name) {
136
+    if (!$name) {
137 137
     form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit'));
138
-  }
139
-  else {
138
+    }
139
+    else {
140 140
     require_boinc('boinc_db');
141 141
     if (BoincTeam::lookup_name($name)) {
142
-      form_set_error('name', bts('A team named "@name" already exists.',
142
+        form_set_error('name', bts('A team named "@name" already exists.',
143 143
         array('@name' => $name), NULL, 'boinc:team-create/edit'));
144 144
     }
145
-  }
145
+    }
146 146
 
147
-  if (!$values['type'] OR !isset($values['type_options'][$values['type']])) {
147
+    if (!$values['type'] OR !isset($values['type_options'][$values['type']])) {
148 148
     form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit'));
149
-  }
149
+    }
150 150
 }
151 151
 
152 152
 /**
153 153
  * The create team submit handler
154 154
  */
155 155
 function boincteam_create_form_submit($form, &$form_state) {
156
-  global $user;
157
-  $account = user_load($user->uid);
158
-  $values = $form_state['values'];
159
-  //drupal_set_message('<pre>' . print_r($values,true) . '</pre>');
156
+    global $user;
157
+    $account = user_load($user->uid);
158
+    $values = $form_state['values'];
159
+    //drupal_set_message('<pre>' . print_r($values,true) . '</pre>');
160 160
 
161
-  $input_format = !empty($values['format']) ? $values['format'] : 4;
162
-  $values['description'] = check_markup($values['description'], $input_format);
161
+    $input_format = !empty($values['format']) ? $values['format'] : 4;
162
+    $values['description'] = check_markup($values['description'], $input_format);
163 163
 
164
-  // Create the team in the BOINC db
164
+    // Create the team in the BOINC db
165 165
 
166
-  require_boinc(array('user','team'));
167
-  $boinc_team = make_team(
166
+    require_boinc(array('user','team'));
167
+    $boinc_team = make_team(
168 168
     $account->boincuser_id,
169 169
     $values['name'],
170 170
     $values['website'],
@@ -172,27 +172,27 @@  discard block
 block discarded – undo
172 172
     $values['name_html'],
173 173
     $values['description'],
174 174
     $values['country']
175
-  );
175
+    );
176 176
 
177
-  if ($boinc_team) {
177
+    if ($boinc_team) {
178 178
     $boinc_user = BoincUser::lookup_id($account->boincuser_id);
179 179
     user_join_team($boinc_team, $boinc_user);
180
-  }
181
-  else {
180
+    }
181
+    else {
182 182
     drupal_set_message(t('Teams cannot be created at this time. The @project administrators have been notified.', array('@project' => PROJECT)));
183 183
     rules_invoke_event('boincteam_create_team_error', $values['name'], variable_get('boinc_admin_mailing_list_subject_tag', ''));
184 184
     watchdog('BOINC team', 'BOINC teams cannot be created for an unknown
185 185
       reason.', 'error');
186 186
     return FALSE;
187
-  }
187
+    }
188 188
 
189
-  // Create the team node in Drupal
189
+    // Create the team node in Drupal
190 190
 
191
-  $teaser = node_teaser($values['description']);
192
-  $created_time = time();
193
-  $input_format = variable_get('filter_default_format', 1);
191
+    $teaser = node_teaser($values['description']);
192
+    $created_time = time();
193
+    $input_format = variable_get('filter_default_format', 1);
194 194
 
195
-  $node = array(
195
+    $node = array(
196 196
     'type' => 'team',
197 197
     'title' => $values['name'],
198 198
     'body' => $values['description'],
@@ -206,21 +206,21 @@  discard block
 block discarded – undo
206 206
     'moderate' => 0,
207 207
     'sticky' => 0,
208 208
     'format' => $input_format
209
-  );
209
+    );
210 210
 
211
-  // Use pathauto function, if available, to clean up the path
212
-  if (module_exists('pathauto')) {
211
+    // Use pathauto function, if available, to clean up the path
212
+    if (module_exists('pathauto')) {
213 213
     module_load_include('inc', 'pathauto', 'pathauto');
214 214
     $node['path'] = pathauto_cleanstring($values['name']);
215
-  }
216
-  else {
215
+    }
216
+    else {
217 217
     drupal_set_message(t('Teams cannot be created at this time. The @project administrators have been notified.', array('@project' => PROJECT)));
218 218
     rules_invoke_event('boincteam_create_team_nopathauto_error', $values['name'], variable_get('boinc_admin_mailing_list_subject_tag', ''));
219 219
     watchdog('BOINC team', 'BOINC teams require the Pathauto module. Teams
220 220
       cannot be created.', 'error');
221
-  }
221
+    }
222 222
 
223
-  /*
223
+    /*
224 224
   // Add special organic group properties
225 225
   $node['og_description'] = strip_tags($boincteam->description);
226 226
   $node['og_selective'] = OG_OPEN;
@@ -229,26 +229,26 @@  discard block
 block discarded – undo
229 229
   $node['og_private'] = 0;
230 230
   */
231 231
 
232
-  $node = (object) $node; // node_save requires an object form
232
+    $node = (object) $node; // node_save requires an object form
233 233
 
234
-  /*
234
+    /*
235 235
   $node->field_description[]['value'] = $boincteam->description;
236 236
   $node->field_url[]['value'] = $boincteam->url;
237 237
   $node->field_country[]['value'] = $boincteam->country;
238 238
   */
239 239
 
240
-  $node->taxonomy[] = taxonomy_get_term($values['type']);
240
+    $node->taxonomy[] = taxonomy_get_term($values['type']);
241 241
 
242
-  // Save the team node
243
-  node_save($node);
242
+    // Save the team node
243
+    node_save($node);
244 244
 
245
-  // Save the team IDs to a BOINC <--> Drupal reference table.
246
-  db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid);
245
+    // Save the team IDs to a BOINC <--> Drupal reference table.
246
+    db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid);
247 247
 
248
-  drupal_set_message(t('Team "@name" has been created.',
248
+    drupal_set_message(t('Team "@name" has been created.',
249 249
     array('@name' => $values['name'])));
250 250
 
251
-  $form_state['redirect'] = "community/teams/{$node->nid}";
251
+    $form_state['redirect'] = "community/teams/{$node->nid}";
252 252
 }
253 253
 
254 254
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
  * The definition of the edit team form
260 260
  */
261 261
 function boincteam_edit_form(&$form_state, $team_id) {
262
-  $form = array();
262
+    $form = array();
263 263
 
264
-  $team = node_load($team_id);
265
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id));
264
+    $team = node_load($team_id);
265
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id));
266 266
 
267
-  $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE;
267
+    $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE;
268 268
 
269
-  $form_state['storage']['team_id'] = $team_id;
270
-  $form_state['storage']['is_boinc_wide'] = $is_boinc_wide;
269
+    $form_state['storage']['team_id'] = $team_id;
270
+    $form_state['storage']['is_boinc_wide'] = $is_boinc_wide;
271 271
 
272
-  $default = array(
272
+    $default = array(
273 273
     'name' => $boincteam->name,
274 274
     'name_html' => $boincteam->name_html,
275 275
     'website' => $boincteam->url,
@@ -277,79 +277,79 @@  discard block
 block discarded – undo
277 277
     'country' => $boincteam->country,
278 278
     'joinable' => $boincteam->joinable,
279 279
     'description' => $boincteam->description,
280
-  );
280
+    );
281 281
 
282
-  // Standard option sets
283
-  $form['boolean_options'] = array(
282
+    // Standard option sets
283
+    $form['boolean_options'] = array(
284 284
     '#type' => 'value',
285 285
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
286
-  );
286
+    );
287 287
 
288
-  // Vocabulary based option sets
289
-  $form['type_options'] = array(
288
+    // Vocabulary based option sets
289
+    $form['type_options'] = array(
290 290
     '#type' => 'value',
291 291
     '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose'))
292
-  );
293
-  $vocabs = taxonomy_get_vocabularies(NULL);
294
-  foreach ($vocabs as $vocab) {
292
+    );
293
+    $vocabs = taxonomy_get_vocabularies(NULL);
294
+    foreach ($vocabs as $vocab) {
295 295
     switch ($vocab->name) {
296 296
     case 'Teams':
297 297
       $team_types = taxonomy_get_tree($vocab->vid);
298
-      if (module_exists('internationalization')) {
298
+        if (module_exists('internationalization')) {
299 299
         $team_types = i18ntaxonomy_localize_terms($team_types);
300
-      }
301
-      foreach ($team_types as $team_type) {
300
+        }
301
+        foreach ($team_types as $team_type) {
302 302
         $form['type_options']['#value'][$team_type->tid] = $team_type->name;
303
-      }
304
-      break;
303
+        }
304
+        break;
305 305
     default:
306 306
     }
307
-  }
308
-  $form['country_options'] = array(
307
+    }
308
+    $form['country_options'] = array(
309 309
     '#type' => 'value',
310 310
     '#value' => boinccore_get_country_list(),
311
-  );
311
+    );
312 312
 
313
-  // Form elements
314
-  $form['name'] = array(
313
+    // Form elements
314
+    $form['name'] = array(
315 315
     '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'),
316 316
     '#type' => 'textfield',
317 317
     '#default_value' => $default['name'],
318 318
     '#size' => 34,
319 319
     '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'),
320 320
     '#disabled' => $is_boinc_wide,
321
-  );
322
-  $form['name_html'] = array(
321
+    );
322
+    $form['name_html'] = array(
323 323
     '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'),
324 324
     '#type' => 'textfield',
325 325
     '#default_value' => $default['name_html'],
326 326
     '#size' => 34,
327 327
     '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'),
328 328
     '#disabled' => $is_boinc_wide,
329
-  );
330
-  $form['website'] = array(
329
+    );
330
+    $form['website'] = array(
331 331
     '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'),
332 332
     '#type' => 'textfield',
333 333
     '#default_value' => $default['website'],
334 334
     '#size' => 34,
335 335
     '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'),
336 336
     '#disabled' => $is_boinc_wide,
337
-  );
338
-  $form['type'] = array(
337
+    );
338
+    $form['type'] = array(
339 339
     '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'),
340 340
     '#type' => 'select',
341 341
     '#options' => $form['type_options']['#value'],
342 342
     '#default_value' => $default['type'],
343 343
     '#disabled' => $is_boinc_wide,
344
-  );
345
-  $form['country'] = array(
344
+    );
345
+    $form['country'] = array(
346 346
     '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'),
347 347
     '#type' => 'select',
348 348
     '#options' => $form['country_options']['#value'],
349 349
     '#default_value' => $default['country'],
350 350
     '#disabled' => $is_boinc_wide,
351
-  );
352
-  $form['joinable'] = array(
351
+    );
352
+    $form['joinable'] = array(
353 353
     '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'),
354 354
     '#type' => 'radios',
355 355
     '#options' => $form['boolean_options']['#value'],
@@ -357,49 +357,49 @@  discard block
 block discarded – undo
357 357
     '#default_value' => $default['joinable'],
358 358
     '#size' => 34,
359 359
     '#disabled' => $is_boinc_wide,
360
-  );
361
-  if (!$is_boinc_wide) {
360
+    );
361
+    if (!$is_boinc_wide) {
362 362
     $form['description'] = array(
363
-      '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'),
364
-      '#type' => 'textarea',
365
-      '#default_value' => $default['description'],
366
-      '#size' => 5,
367
-      '#description' => NULL,
363
+        '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'),
364
+        '#type' => 'textarea',
365
+        '#default_value' => $default['description'],
366
+        '#size' => 5,
367
+        '#description' => NULL,
368 368
     );
369 369
     $form['format'] = filter_form();
370 370
 
371 371
     // Form control
372 372
     $form['form control tabs prefix'] = array(
373
-      '#value' => '<ul class="form-control tab-list">'
373
+        '#value' => '<ul class="form-control tab-list">'
374 374
     );
375 375
     $form['submit'] = array(
376
-      '#prefix' => '<li class="first tab">',
377
-      '#type' => 'submit',
378
-      '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
379
-      '#suffix' => '</li>',
376
+        '#prefix' => '<li class="first tab">',
377
+        '#type' => 'submit',
378
+        '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
379
+        '#suffix' => '</li>',
380 380
     );
381 381
     $form['form control tabs'] = array(
382
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>'
382
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>'
383 383
     );
384
-  }
385
-  else {
384
+    }
385
+    else {
386 386
     $form['description'] = array(
387
-      '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">',
388
-      '#value' => $default['description'],
389
-      '#suffix' => '</div>',
387
+        '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">',
388
+        '#value' => $default['description'],
389
+        '#suffix' => '</div>',
390 390
     );
391 391
     drupal_set_message(
392
-      bts('This is a BOINC-wide team. Changes can be made at the !site.',
392
+        bts('This is a BOINC-wide team. Changes can be made at the !site.',
393 393
         array('!site' => l(bts('BOINC-wide teams site', array(), NULL, 'boinc:link-to-BOINC-wide-teams-Website'),
394
-          'http://boinc.berkeley.edu/teams/'
394
+            'http://boinc.berkeley.edu/teams/'
395 395
         )),
396 396
         NULL, 'boinc:team-edit-warning-message'),
397
-      'warning');
398
-  }
397
+        'warning');
398
+    }
399 399
 
400
-  $form['#redirect'] = "community/teams/{$team_id}";
400
+    $form['#redirect'] = "community/teams/{$team_id}";
401 401
 
402
-  return $form;
402
+    return $form;
403 403
 }
404 404
 
405 405
 /**
@@ -407,32 +407,32 @@  discard block
 block discarded – undo
407 407
  */
408 408
 function boincteam_edit_form_validate($form, &$form_state) {
409 409
 
410
-  $values = $form_state['values'];
411
-  $name = $values['name'];
410
+    $values = $form_state['values'];
411
+    $name = $values['name'];
412 412
 
413
-  if ($form_state['storage']['is_boinc_wide']) {
413
+    if ($form_state['storage']['is_boinc_wide']) {
414 414
     form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), NULL, 'boinc:team-create/edit'));
415
-  }
416
-  else {
415
+    }
416
+    else {
417 417
     if (!$name) {
418
-      form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit'));
418
+        form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit'));
419 419
     }
420 420
     else {
421
-      $team = node_load($form_state['storage']['team_id']);
422
-      if ($name != $team->title) {
421
+        $team = node_load($form_state['storage']['team_id']);
422
+        if ($name != $team->title) {
423 423
         // If changing the name ("title" in Drupal terms), check that the new name is available
424 424
         require_boinc('boinc_db');
425 425
         if (BoincTeam::lookup_name($name)) {
426
-          form_set_error('name', bts('A team named "@name" already exists.',
426
+            form_set_error('name', bts('A team named "@name" already exists.',
427 427
             array('@name' => $name), NULL, 'boinc:team-create/edit'));
428 428
         }
429
-      }
429
+        }
430 430
     }
431 431
 
432 432
     if (!$values['type'] OR !isset($values['type_options'][$values['type']])) {
433
-      form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit'));
433
+        form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit'));
434
+    }
434 435
     }
435
-  }
436 436
 }
437 437
 
438 438
 /**
@@ -440,18 +440,18 @@  discard block
 block discarded – undo
440 440
  */
441 441
 function boincteam_edit_form_submit($form, &$form_state) {
442 442
 
443
-  $team_id = $form_state['storage']['team_id'];
444
-  $values = $form_state['values'];
443
+    $team_id = $form_state['storage']['team_id'];
444
+    $values = $form_state['values'];
445 445
 
446
-  $team = node_load($team_id);
447
-  $boincteam_id = boincteam_lookup_id($team_id);
446
+    $team = node_load($team_id);
447
+    $boincteam_id = boincteam_lookup_id($team_id);
448 448
 
449
-  $input_format = !empty($values['format']) ? $values['format'] : 4;
450
-  $values['description'] = check_markup($values['description'], $input_format);
449
+    $input_format = !empty($values['format']) ? $values['format'] : 4;
450
+    $values['description'] = check_markup($values['description'], $input_format);
451 451
 
452
-  // Update the team in the BOINC db
453
-  db_set_active('boinc_rw');
454
-  db_query("
452
+    // Update the team in the BOINC db
453
+    db_set_active('boinc_rw');
454
+    db_query("
455 455
     UPDATE {team} SET
456 456
       name = '%s',
457 457
       name_lc = '%s',
@@ -471,32 +471,32 @@  discard block
 block discarded – undo
471 471
     $values['country'],
472 472
     $values['joinable'],
473 473
     $boincteam_id
474
-  );
475
-  db_set_active('default');
474
+    );
475
+    db_set_active('default');
476 476
 
477
-  // Update the team node in Drupal
477
+    // Update the team node in Drupal
478 478
 
479
-  $team->title = $values['name'];
480
-  $team->body = $values['description'];
481
-  $team->teaser = node_teaser($values['description']);
479
+    $team->title = $values['name'];
480
+    $team->body = $values['description'];
481
+    $team->teaser = node_teaser($values['description']);
482 482
 
483
-  /*
483
+    /*
484 484
   $node->field_description[]['value'] = $boincteam->description;
485 485
   $node->field_url[]['value'] = $boincteam->url;
486 486
   $node->field_country[]['value'] = $boincteam->country;
487 487
   */
488 488
 
489
-  // Replace any existing taxonomy with the new one
490
-  $team->taxonomy = array(taxonomy_get_term($values['type']));
489
+    // Replace any existing taxonomy with the new one
490
+    $team->taxonomy = array(taxonomy_get_term($values['type']));
491 491
 
492
-  // Save the team node
493
-  node_save($team);
492
+    // Save the team node
493
+    node_save($team);
494 494
 
495
-  drupal_set_message(t('Details for "@team" have been updated.',
495
+    drupal_set_message(t('Details for "@team" have been updated.',
496 496
     array('@team' => $values['name'])));
497 497
 
498
-  // The storage variable quietly kills redirection for some reason... unset it
499
-  unset($form_state['storage']);
498
+    // The storage variable quietly kills redirection for some reason... unset it
499
+    unset($form_state['storage']);
500 500
 }
501 501
 
502 502
 
@@ -508,44 +508,44 @@  discard block
 block discarded – undo
508 508
  * The definition of the add team admin form
509 509
  */
510 510
 function boincteam_add_admin_form(&$form_state, $team_id) {
511
-  $form = array();
511
+    $form = array();
512 512
 
513
-  $team = node_load($team_id);
514
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id));
513
+    $team = node_load($team_id);
514
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id));
515 515
 
516
-  $form_state['storage']['team_id'] = $team_id;
516
+    $form_state['storage']['team_id'] = $team_id;
517 517
 
518
-  $default = array(
518
+    $default = array(
519 519
     'username' => '',
520
-  );
520
+    );
521 521
 
522
-  // Form elements
523
-  $form['username'] = array(
522
+    // Form elements
523
+    $form['username'] = array(
524 524
     '#title' => bts('Enter BOINC username', array(), NULL, 'boinc:team--add-admin'),
525 525
     '#description' => bts('The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'),
526 526
     '#type' => 'textfield',
527 527
     '#default_value' => $default['username'],
528 528
     '#size' => 34,
529 529
     '#autocomplete_path' => "community/teams/${team_id}/user-name-autocomplete",
530
-  );
530
+    );
531 531
 
532
-  // Form control
533
-  $form['form control tabs prefix'] = array(
532
+    // Form control
533
+    $form['form control tabs prefix'] = array(
534 534
     '#value' => '<ul class="form-control tab-list">'
535
-  );
536
-  $form['submit'] = array(
535
+    );
536
+    $form['submit'] = array(
537 537
     '#prefix' => '<li class="first tab">',
538 538
     '#type' => 'submit',
539 539
     '#value' => bts('Add', array(), NULL, 'boinc:form-add'),
540 540
     '#suffix' => '</li>',
541
-  );
542
-  $form['form control tabs'] = array(
541
+    );
542
+    $form['form control tabs'] = array(
543 543
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>'
544
-  );
544
+    );
545 545
 
546
-  //$form['#redirect'] = "community/teams/{$team_id}";
546
+    //$form['#redirect'] = "community/teams/{$team_id}";
547 547
 
548
-  return $form;
548
+    return $form;
549 549
 }
550 550
 
551 551
 /**
@@ -553,45 +553,45 @@  discard block
 block discarded – undo
553 553
  */
554 554
 function boincteam_add_admin_form_validate($form, &$form_state) {
555 555
 
556
-  $team_id = $form_state['storage']['team_id'];
557
-  $values = $form_state['values'];
558
-  $team = node_load($team_id);
556
+    $team_id = $form_state['storage']['team_id'];
557
+    $values = $form_state['values'];
558
+    $team = node_load($team_id);
559 559
 
560
-  if (!$values['username']) {
560
+    if (!$values['username']) {
561 561
     form_set_error('username', bts('BOINC username is required.', array(), NULL, 'boinc:team-add-admin'));
562
-  }
563
-  else {
562
+    }
563
+    else {
564 564
     // Load user account associated with username
565 565
     $account = boincuser_privatemsg_name_lookup($values['username']);
566 566
     // Validate the account
567 567
     if ((!$account) OR ($account->team != $team_id)) {
568
-      form_set_error('username', bts('There is no user on your team with name @username.',
568
+        form_set_error('username', bts('There is no user on your team with name @username.',
569 569
         array(
570
-          '@username' => $account->boincuser_name
570
+            '@username' => $account->boincuser_name
571 571
         ),
572
-      NULL, 'boinc:team-add-admin'));
572
+        NULL, 'boinc:team-add-admin'));
573 573
     }
574 574
     elseif (boincteam_is_founder($team_id, $account->uid)) {
575
-      form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.',
575
+        form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.',
576 576
         array(
577
-          '@user' => $account->boincuser_name,
578
-          '@team' => $team->title,
577
+            '@user' => $account->boincuser_name,
578
+            '@team' => $team->title,
579 579
         ),
580 580
         NULL, 'boinc:team-add-admin'));
581 581
     }
582 582
     elseif (boincteam_is_admin($team_id, $account->uid)) {
583
-      form_set_error('username', bts('@user is already an admin of @team.',
583
+        form_set_error('username', bts('@user is already an admin of @team.',
584 584
         array(
585
-          '@user' => $account->boincuser_name,
586
-          '@team' => $team->title,
585
+            '@user' => $account->boincuser_name,
586
+            '@team' => $team->title,
587 587
         ),
588 588
         NULL, 'boinc:team-add-admin'));
589 589
     }
590 590
     else {
591
-      $form_state['storage']['boincuser_id'] = $account->boincuser_id;
592
-      $form_state['storage']['boincuser_name'] = $account->boincuser_name;
591
+        $form_state['storage']['boincuser_id'] = $account->boincuser_id;
592
+        $form_state['storage']['boincuser_name'] = $account->boincuser_name;
593
+    }
593 594
     }
594
-  }
595 595
 }
596 596
 
597 597
 /**
@@ -599,17 +599,17 @@  discard block
 block discarded – undo
599 599
  */
600 600
 function boincteam_add_admin_form_submit($form, &$form_state) {
601 601
 
602
-  $team_id = $form_state['storage']['team_id'];
603
-  $boincuser_id = $form_state['storage']['boincuser_id'];
604
-  $user_name = $form_state['storage']['boincuser_name'];
605
-  $values = $form_state['values'];
602
+    $team_id = $form_state['storage']['team_id'];
603
+    $boincuser_id = $form_state['storage']['boincuser_id'];
604
+    $user_name = $form_state['storage']['boincuser_name'];
605
+    $values = $form_state['values'];
606 606
 
607
-  $team = node_load($team_id);
608
-  $boincteam_id = boincteam_lookup_id($team_id);
607
+    $team = node_load($team_id);
608
+    $boincteam_id = boincteam_lookup_id($team_id);
609 609
 
610
-  // Update the team in the BOINC db
611
-  db_set_active('boinc_rw');
612
-  db_query("
610
+    // Update the team in the BOINC db
611
+    db_set_active('boinc_rw');
612
+    db_query("
613 613
     INSERT INTO {team_admin} SET
614 614
       teamid = '%d',
615 615
       userid = '%d',
@@ -617,17 +617,17 @@  discard block
 block discarded – undo
617 617
     $boincteam_id,
618 618
     $boincuser_id,
619 619
     time()
620
-  );
621
-  db_set_active('default');
620
+    );
621
+    db_set_active('default');
622 622
 
623
-  // Could assign a role in Drupal here, as needed
623
+    // Could assign a role in Drupal here, as needed
624 624
 
625 625
 
626
-  drupal_set_message(t('@user has been added as an admin.',
626
+    drupal_set_message(t('@user has been added as an admin.',
627 627
     array('@user' => $user_name)));
628 628
 
629
-  // The storage variable quietly kills redirection for some reason... unset it
630
-  unset($form_state['storage']);
629
+    // The storage variable quietly kills redirection for some reason... unset it
630
+    unset($form_state['storage']);
631 631
 }
632 632
 
633 633
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -639,80 +639,80 @@  discard block
 block discarded – undo
639 639
  * Send all team members an email message function
640 640
  */
641 641
 function boincteam_sendmessagetoteam(&$form_state, $team_id) {
642
-  global $user;
643
-  $form = array();
642
+    global $user;
643
+    $form = array();
644 644
 
645
-  if (isset($form_state['values'])) {
645
+    if (isset($form_state['values'])) {
646 646
     $subject   = $form_state['values']['subject'];
647 647
     $body      = $form_state['values']['body'];
648
-  }
649
-  else {
648
+    }
649
+    else {
650 650
     $subject   = '';
651 651
     $body      = '';
652
-  }
652
+    }
653 653
 
654
-  // Title
655
-  $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form');
656
-  drupal_set_title($mytitle);
654
+    // Title
655
+    $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form');
656
+    drupal_set_title($mytitle);
657 657
 
658
-  $form['emailteam']['header'] = array(
658
+    $form['emailteam']['header'] = array(
659 659
     '#value'              => '<h1>' . $mytitle . '</h1>',
660 660
     '#weight'             => '-10',
661 661
     '#prefix'             => "<div id='sendmessageteammembers-header'>",
662 662
     '#suffix'             => "</div>",
663
-  );
663
+    );
664 664
 
665
-  $form['emailteam']['instructions'] = array(
665
+    $form['emailteam']['instructions'] = array(
666 666
     '#value'              => bts('This will send an email to all team members. If a team member has opt-ed out of notification e-mails, they will not receive your message. At the bottom of your message, there will be a link allowing team members to send you a Direct Message. This link is added automatically, you do not need to add it below in the Message box. Your email address will not be shown to the recipients.', array(), NULL, 'boinc:team-message-form'),
667 667
     '#weight'             => '-8',
668 668
     '#prefix'             => "<div id='sendmessageteammembers-instructions'>",
669 669
     '#suffix'             => "</div>",
670
-  );
670
+    );
671 671
 
672
-  // Subject
673
-  $form['emailteam']['subject'] = array(
672
+    // Subject
673
+    $form['emailteam']['subject'] = array(
674 674
     '#type'               => 'textfield',
675 675
     '#title'              => bts('Subject', array(), NULL, 'boinc:team-message-form'),
676 676
     '#size'               => 50,
677 677
     '#maxlength'          => 255,
678 678
     '#default_value'      => $subject,
679 679
     '#weight'             => -5,
680
-  );
680
+    );
681 681
 
682
-  // Body
683
-  $form['emailteam']['body'] = array(
682
+    // Body
683
+    $form['emailteam']['body'] = array(
684 684
     '#type'               => 'textarea',
685 685
     '#title'              => bts('Message', array(), NULL, 'boinc:team-message-form'),
686 686
     '#rows'               => 8,
687 687
     '#weight'             => 0,
688 688
     '#default_value'      => $body,
689 689
     '#resizable'          => TRUE,
690
-  );
690
+    );
691 691
 
692
-  // checkbox for 'sent to self'
693
-  $form['emailteam']['selfsend'] = array(
692
+    // checkbox for 'sent to self'
693
+    $form['emailteam']['selfsend'] = array(
694 694
     '#type'    => 'checkbox',
695 695
     '#title'   => bts('Check this box if you wish to be sent a copy of your message to your email address.', array(), NULL, 'boinc:team-message-form'),
696 696
     '#weight'  => 10,
697 697
     '#prefix'  => '<div class="clearfix" id="confirm-checkbox">',
698 698
     '#suffix'  => '</div>',
699
-  );
699
+    );
700 700
 
701
-  // Add a captcha to form
702
-  if (module_exists('captcha')) {
701
+    // Add a captcha to form
702
+    if (module_exists('captcha')) {
703 703
     $form['register_captcha'] = array(
704 704
         '#type' => 'captcha',
705 705
         '#weight' => 1000,
706 706
     );
707
-  }
707
+    }
708 708
 
709
-  // form buttons
710
-  $form['emailteam']['form control tabs prefix'] = array(
709
+    // form buttons
710
+    $form['emailteam']['form control tabs prefix'] = array(
711 711
     '#value'  => '<ul class="form-control tab-list">',
712 712
     '#weight' => 1000,
713
-  );
713
+    );
714 714
 
715
-  $form['emailteam']['submit'] = array(
715
+    $form['emailteam']['submit'] = array(
716 716
     '#type'               => 'submit',
717 717
     '#value'              => bts('Send message', array(), NULL, 'boinc:form-submit'),
718 718
     '#submit'             => array('boincteam_sendmessagetoteam_submit'),
@@ -720,133 +720,133 @@  discard block
 block discarded – undo
720 720
     '#weight'             => 1001,
721 721
     '#prefix'             => '<li class="first tab">',
722 722
     '#suffix'             => '</li>'
723
-  );
723
+    );
724 724
 
725
-  $title = bts('Cancel', array(), NULL, 'boinc:form-cancel');
726
-  $url = "community/teams/{$team_id}";
727
-  $form['emailteam']['cancel'] = array(
725
+    $title = bts('Cancel', array(), NULL, 'boinc:form-cancel');
726
+    $url = "community/teams/{$team_id}";
727
+    $form['emailteam']['cancel'] = array(
728 728
     '#value'              => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))),
729 729
     '#weight'             => 1005,
730 730
     '#prefix'             => '<li class="tab">',
731 731
     '#suffix'             => '</li>'
732
-  );
732
+    );
733 733
 
734
-  $form['emailteam']['form control tabs suffix'] = array(
734
+    $form['emailteam']['form control tabs suffix'] = array(
735 735
     '#value'  => '</ul>',
736 736
     '#weight' => 1010,
737
-  );
737
+    );
738 738
 
739
-  // Add team id information to form_state
740
-  $form['_team_id'] = array(
739
+    // Add team id information to form_state
740
+    $form['_team_id'] = array(
741 741
     '#type'  => 'value',
742 742
     '#value' => $team_id,
743
-  );
743
+    );
744 744
 
745
-  // Add sender user object to form_state
746
-  $form['_senderuid'] = array(
745
+    // Add sender user object to form_state
746
+    $form['_senderuid'] = array(
747 747
     '#type'  => 'value',
748 748
     '#value' => $user->uid,
749
-  );
749
+    );
750 750
 
751
-  // redirect after sending message
752
-  $form['#redirect'] = "community/teams/{$team_id}";
751
+    // redirect after sending message
752
+    $form['#redirect'] = "community/teams/{$team_id}";
753 753
 
754
-  return $form;
754
+    return $form;
755 755
 }
756 756
 
757 757
 /**
758 758
  * Send all team members validation handler
759 759
  */
760 760
 function boincteam_sendmessagetoteam_validate($form, &$form_state) {
761
-  $message = $form_state['values'];
762
-  $message['timestamp'] = time();
763
-  // Avoid subjects which only consist of a space as these can not be clicked.
764
-  $message['subject'] = trim($message['subject']);
761
+    $message = $form_state['values'];
762
+    $message['timestamp'] = time();
763
+    // Avoid subjects which only consist of a space as these can not be clicked.
764
+    $message['subject'] = trim($message['subject']);
765 765
 
766
-  $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE));
767
-  if (empty($message['subject']) && !empty($trimed_body)) {
766
+    $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE));
767
+    if (empty($message['subject']) && !empty($trimed_body)) {
768 768
     $message['subject'] = $trimed_body;
769 769
     $form_state['values']['subject'] = $message['subject'];
770
-  }
770
+    }
771 771
 
772
-  // Check subject line
773
-  $message['subject'] = trim($message['subject']);
774
-  if (empty($message['subject'])) {
772
+    // Check subject line
773
+    $message['subject'] = trim($message['subject']);
774
+    if (empty($message['subject'])) {
775 775
     form_set_error('subject',
776
-      bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form')
776
+        bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form')
777 777
     );
778
-  }
778
+    }
779 779
 
780
-  // Check body
781
-  if ( ($message['body'] === NULL || $message['body'] === '') ) {
780
+    // Check body
781
+    if ( ($message['body'] === NULL || $message['body'] === '') ) {
782 782
     form_set_error('body',
783
-      bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form')
783
+        bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form')
784 784
     );
785
-  }
785
+    }
786 786
 
787
-  // Check team id
788
-  if (empty($message['_team_id'])) {
787
+    // Check team id
788
+    if (empty($message['_team_id'])) {
789 789
     form_set_error('team_id',
790
-      bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form')
790
+        bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form')
791 791
     );
792
-  }
792
+    }
793 793
 
794
-  $form_state['validated_built_message'] = $message;
794
+    $form_state['validated_built_message'] = $message;
795 795
 }
796 796
 
797 797
 /**
798 798
  * Send all team members submit handler
799 799
  */
800 800
 function boincteam_sendmessagetoteam_submit($form, &$form_state) {
801
-  module_load_include('inc', 'rules', 'modules/system.rules');
802
-  global $base_url;
803
-  global $base_path;
804
-
805
-  $suid = $form_state['values']['_senderuid'];
806
-  $account = user_load(array('uid' => $suid ));
807
-  $site_url = $base_url . $base_path . "messages/new/" . $suid;
808
-
809
-  // Form is validated, now send to all team members. Lookup boinc
810
-  // id of all team members, and then use user_load() to load user
811
-  // object. Send message using email.
812
-  //
813
-  $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']);
814
-  // Email addresses, with those who have opt-ed out of notification
815
-  // emails removed.
816
-  $member_emails = _boincteam_emails($boinc_id);
817
-  // Remove sender's email address, unless selfsend is true.
818
-  if ( !$form_state['values']['selfsend'] ) {
801
+    module_load_include('inc', 'rules', 'modules/system.rules');
802
+    global $base_url;
803
+    global $base_path;
804
+
805
+    $suid = $form_state['values']['_senderuid'];
806
+    $account = user_load(array('uid' => $suid ));
807
+    $site_url = $base_url . $base_path . "messages/new/" . $suid;
808
+
809
+    // Form is validated, now send to all team members. Lookup boinc
810
+    // id of all team members, and then use user_load() to load user
811
+    // object. Send message using email.
812
+    //
813
+    $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']);
814
+    // Email addresses, with those who have opt-ed out of notification
815
+    // emails removed.
816
+    $member_emails = _boincteam_emails($boinc_id);
817
+    // Remove sender's email address, unless selfsend is true.
818
+    if ( !$form_state['values']['selfsend'] ) {
819 819
     $pos = array_search($account->mail, $member_emails);
820 820
     unset($member_emails[$pos]);
821
-  }
821
+    }
822 822
 
823
-  // Add link at bottom of body
824
-  $mybody = $form_state['validated_built_message']['body'];
825
-  $mybody .= "\n\n"
826
-      . "To reply to the sender using a Direct Message (DM), please use this link:\n"
827
-      . "${site_url}";
823
+    // Add link at bottom of body
824
+    $mybody = $form_state['validated_built_message']['body'];
825
+    $mybody .= "\n\n"
826
+        . "To reply to the sender using a Direct Message (DM), please use this link:\n"
827
+        . "${site_url}";
828 828
 
829
-  // Transform HTML body into plain text
830
-  $mybody = drupal_html_to_text($mybody);
829
+    // Transform HTML body into plain text
830
+    $mybody = drupal_html_to_text($mybody);
831 831
 
832
-  $emailsettings = array(
832
+    $emailsettings = array(
833 833
     'from'    => '',
834 834
     'to'      => "webmaster@{$base_url}",
835 835
     'boincteam_headers' => array(
836
-      'Bcc'     => implode(', ', $member_emails),
836
+        'Bcc'     => implode(', ', $member_emails),
837 837
     ),
838 838
     'subject' => $form_state['validated_built_message']['subject'],
839 839
     'message' => $mybody,
840
-  );
841
-  rules_action_mail($emailsettings);
840
+    );
841
+    rules_action_mail($emailsettings);
842 842
 
843
-  $om = bts(
843
+    $om = bts(
844 844
     'Sent your email message to !number team members.',
845 845
     array( '!number' => count($member_emails) ),
846 846
     'NULL',
847 847
     'boinc:team-message-sent'
848
-  );
849
-  drupal_set_message($om, 'info');
848
+    );
849
+    drupal_set_message($om, 'info');
850 850
 
851
-  $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}";
851
+    $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}";
852 852
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam_forum.views.inc 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,80 +13,80 @@
 block discarded – undo
13 13
  */
14 14
 function boincteam_forum_views_data() {
15 15
 
16
-  // -----------------------------------------------------------------------------------------------
17
-  // Definition for team table
18
-  // -----------------------------------------------------------------------------------------------
16
+    // -----------------------------------------------------------------------------------------------
17
+    // Definition for team table
18
+    // -----------------------------------------------------------------------------------------------
19 19
 
20
-  $data['boincteam_forum_node']['table']['group'] = t('BOINC');
20
+    $data['boincteam_forum_node']['table']['group'] = t('BOINC');
21 21
 
22
-  $data['boincteam_forum_node']['table']['base'] = array(
23
-      'field' => 'nid',
24
-      'title' => t('BOINC team forum topic'),
25
-      'help' => t('Forum topics for a team'),
26
-  );
22
+    $data['boincteam_forum_node']['table']['base'] = array(
23
+        'field' => 'nid',
24
+        'title' => t('BOINC team forum topic'),
25
+        'help' => t('Forum topics for a team'),
26
+    );
27 27
 
28
-  // Describe each of the individual fields in this table to Views. For
29
-  // each field, you may define what field, sort, argument, and/or filter
30
-  // handlers it supports. This will determine where in the Views interface you
31
-  // may use the field.
28
+    // Describe each of the individual fields in this table to Views. For
29
+    // each field, you may define what field, sort, argument, and/or filter
30
+    // handlers it supports. This will determine where in the Views interface you
31
+    // may use the field.
32 32
 
33
-  // Primary keys allowed as arguments
33
+    // Primary keys allowed as arguments
34 34
 
35
-  $data['boincteam_forum_node']['tfid'] = array(
35
+    $data['boincteam_forum_node']['tfid'] = array(
36 36
     'title' => t('Team forum ID'),
37 37
     'help' => t('The ID of the team forum containing this topic.'),
38 38
     'field' => array(
39
-      'handler' => 'views_handler_field_numeric',
40
-      'click sortable' => TRUE
39
+        'handler' => 'views_handler_field_numeric',
40
+        'click sortable' => TRUE
41 41
     ),
42 42
     'argument' => array(
43
-      'handler' => 'views_handler_argument_numeric',
44
-      'name field' => 'title', // the field to display in the summary.
45
-      'numeric' => TRUE,
46
-      'validate type' => 'id'
43
+        'handler' => 'views_handler_argument_numeric',
44
+        'name field' => 'title', // the field to display in the summary.
45
+        'numeric' => TRUE,
46
+        'validate type' => 'id'
47 47
     ),
48 48
     'relationship' => array(
49
-      'base' => 'boincteam_forum',
50
-      'field' => 'tfid',
51
-      'handler' => 'views_handler_relationship',
52
-      'label' => t('Team Forum')
49
+        'base' => 'boincteam_forum',
50
+        'field' => 'tfid',
51
+        'handler' => 'views_handler_relationship',
52
+        'label' => t('Team Forum')
53 53
     ),
54 54
     'filter' => array(
55
-      'handler' => 'views_handler_filter_numeric'
55
+        'handler' => 'views_handler_filter_numeric'
56 56
     ),
57 57
     'sort' => array(
58
-      'handler' => 'views_handler_sort_numeric'
58
+        'handler' => 'views_handler_sort_numeric'
59 59
     )
60
-  );
60
+    );
61 61
 
62
-  // Foreign key fields
62
+    // Foreign key fields
63 63
 
64
-  $data['boincteam_forum_node']['nid'] = array(
64
+    $data['boincteam_forum_node']['nid'] = array(
65 65
     'title' => t('Team forum node'),
66 66
     'help' => t('The node containing the content of this team forum topic.'),
67 67
     // This is a foreign key to the {node} table. When the view is configured
68 68
     // with this relationship, all the fields for the related user node will be
69 69
     // available.
70 70
     'relationship' => array(
71
-      'base' => 'node',
72
-      'field' => 'nid',
73
-      'handler' => 'views_handler_relationship',
74
-      'label' => t('Team Forum Topic Node')
71
+        'base' => 'node',
72
+        'field' => 'nid',
73
+        'handler' => 'views_handler_relationship',
74
+        'label' => t('Team Forum Topic Node')
75 75
     ),
76 76
     'field' => array(
77
-      'handler' => 'views_handler_field_numeric',
78
-      'click sortable' => TRUE
77
+        'handler' => 'views_handler_field_numeric',
78
+        'click sortable' => TRUE
79 79
     ),
80 80
     'filter' => array(
81
-      'handler' => 'views_handler_filter_numeric'
81
+        'handler' => 'views_handler_filter_numeric'
82 82
     ),
83 83
     'sort' => array(
84
-      'handler' => 'views_handler_sort_numeric'
84
+        'handler' => 'views_handler_sort_numeric'
85 85
     )
86
-  );
86
+    );
87 87
 
88
-  // Descriptions of general fields (alphabetized)
89
-  // ...
88
+    // Descriptions of general fields (alphabetized)
89
+    // ...
90 90
 
91
-  return $data;
91
+    return $data;
92 92
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam.views.inc 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -13,103 +13,103 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function boincteam_views_data() {
15 15
 
16
-  // -----------------------------------------------------------------------------------------------
17
-  // Definition for team table
18
-  // -----------------------------------------------------------------------------------------------
16
+    // -----------------------------------------------------------------------------------------------
17
+    // Definition for team table
18
+    // -----------------------------------------------------------------------------------------------
19 19
 
20
-  $data['team']['table']['group'] = t('BOINC');
20
+    $data['team']['table']['group'] = t('BOINC');
21 21
 
22
-  $data['team']['table']['base'] = array(
23
-      'field' => 'id',
24
-      'title' => t('BOINC team'),
25
-      'help' => t('BOINC data for a team'),
26
-      'database' => 'boinc_rw'
27
-  );
22
+    $data['team']['table']['base'] = array(
23
+        'field' => 'id',
24
+        'title' => t('BOINC team'),
25
+        'help' => t('BOINC data for a team'),
26
+        'database' => 'boinc_rw'
27
+    );
28 28
 
29
-  // This table references the {user} table.
30
-  // This join creates an 'implicit' relationship to the user table, so that when
31
-  // "User" is the base table, the fields are automatically available.
29
+    // This table references the {user} table.
30
+    // This join creates an 'implicit' relationship to the user table, so that when
31
+    // "User" is the base table, the fields are automatically available.
32 32
 
33
-  // Index this array by the table name to which this table refers.
34
-  // 'left_field' is the primary key in the referenced table.
35
-  // 'field' is the foreign key in this table.
33
+    // Index this array by the table name to which this table refers.
34
+    // 'left_field' is the primary key in the referenced table.
35
+    // 'field' is the foreign key in this table.
36 36
 
37
-  $data['team']['table']['join'] = array(
37
+    $data['team']['table']['join'] = array(
38 38
     'user' => array(
39
-      'left_field' => 'id',
40
-      'field' => 'userid',
39
+        'left_field' => 'id',
40
+        'field' => 'userid',
41 41
     ),
42
-  );
42
+    );
43 43
 
44
-  // Describe each of the individual fields in this table to Views. For
45
-  // each field, you may define what field, sort, argument, and/or filter
46
-  // handlers it supports. This will determine where in the Views interface you
47
-  // may use the field.
44
+    // Describe each of the individual fields in this table to Views. For
45
+    // each field, you may define what field, sort, argument, and/or filter
46
+    // handlers it supports. This will determine where in the Views interface you
47
+    // may use the field.
48 48
 
49
-  // Primary keys allowed as arguments
49
+    // Primary keys allowed as arguments
50 50
 
51
-  $data['team']['id'] = array(
51
+    $data['team']['id'] = array(
52 52
     'title' => bts('Team ID', array(), NULL, 'boinc:team-id'),
53 53
     'help' => t('The BOINC ID of the team.'),
54 54
     'field' => array(
55
-      'handler' => 'views_handler_field_numeric',
56
-      'click sortable' => TRUE
55
+        'handler' => 'views_handler_field_numeric',
56
+        'click sortable' => TRUE
57 57
     ),
58 58
     'argument' => array(
59
-      'handler' => 'views_handler_argument_boincteam_id', // custom handler
60
-      'name field' => 'title', // the field to display in the summary.
61
-      'numeric' => TRUE,
62
-      'validate type' => 'id'
59
+        'handler' => 'views_handler_argument_boincteam_id', // custom handler
60
+        'name field' => 'title', // the field to display in the summary.
61
+        'numeric' => TRUE,
62
+        'validate type' => 'id'
63 63
     ),
64 64
     'relationship' => array(
65
-      'base' => 'team_delta',
66
-      'field' => 'id',
67
-      'base field' => 'teamid',
68
-      'handler' => 'views_handler_relationship',
69
-      'label' => t('Team History')
65
+        'base' => 'team_delta',
66
+        'field' => 'id',
67
+        'base field' => 'teamid',
68
+        'handler' => 'views_handler_relationship',
69
+        'label' => t('Team History')
70 70
     ),
71 71
     'filter' => array(
72
-      'handler' => 'views_handler_filter_numeric'
72
+        'handler' => 'views_handler_filter_numeric'
73 73
     ),
74 74
     'sort' => array(
75
-      'handler' => 'views_handler_sort_numeric'
75
+        'handler' => 'views_handler_sort_numeric'
76 76
     )
77
-  );
77
+    );
78 78
 
79
-  // Foreign key fields
79
+    // Foreign key fields
80 80
 
81
-  $data['team']['userid'] = array(
81
+    $data['team']['userid'] = array(
82 82
     'title' => bts('Founder', array(), NULL, 'boinc:view-team-info'),
83 83
     'help' => t('The founder of this team.'),
84 84
     // This is a foreign key to the {user} table. When the view is configured
85 85
     // with this relationship, all the fields for the related user node will be
86 86
     // available.
87 87
     'argument' => array(
88
-      'handler' => 'views_handler_argument_boincuser_id',
89
-      'name field' => 'title',
90
-      'numeric' => TRUE,
91
-      'validate type' => 'id'
88
+        'handler' => 'views_handler_argument_boincuser_id',
89
+        'name field' => 'title',
90
+        'numeric' => TRUE,
91
+        'validate type' => 'id'
92 92
     ),
93 93
     'relationship' => array(
94
-      'base' => 'user',
95
-      'field' => 'userid',
96
-      'handler' => 'views_handler_relationship',
97
-      'label' => t('User')
94
+        'base' => 'user',
95
+        'field' => 'userid',
96
+        'handler' => 'views_handler_relationship',
97
+        'label' => t('User')
98 98
     ),
99 99
     'field' => array(
100
-      'handler' => 'views_handler_field_numeric',
101
-      'click sortable' => TRUE
100
+        'handler' => 'views_handler_field_numeric',
101
+        'click sortable' => TRUE
102 102
     ),
103 103
     'filter' => array(
104
-      'handler' => 'views_handler_filter_numeric'
104
+        'handler' => 'views_handler_filter_numeric'
105 105
     ),
106 106
     'sort' => array(
107
-      'handler' => 'views_handler_sort_numeric'
107
+        'handler' => 'views_handler_sort_numeric'
108 108
     )
109
-  );
109
+    );
110 110
 
111
-  // Descriptions of general fields (alphabetized)
112
-  /*
111
+    // Descriptions of general fields (alphabetized)
112
+    /*
113 113
   $data['team']['create_time'] = array(
114 114
     'title' => bts('Team established', array(), NULL, 'boinc:date-team-established'),
115 115
     'help' => t('When the BOINC team was created.'),
@@ -140,298 +140,298 @@  discard block
 block discarded – undo
140 140
   );
141 141
   */
142 142
 
143
-  $data['team']['country'] = array(
143
+    $data['team']['country'] = array(
144 144
     'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'),
145 145
     'help' => t('The country of a team.'),
146 146
     'field' => array(
147
-      'handler' => 'views_handler_field',
148
-      'click sortable' => TRUE
147
+        'handler' => 'views_handler_field',
148
+        'click sortable' => TRUE
149 149
     ),
150 150
     'filter' => array(
151
-      'handler' => 'views_handler_filter_string'
151
+        'handler' => 'views_handler_filter_string'
152 152
     ),
153 153
     'sort' => array(
154
-      'handler' => 'views_handler_sort_string'
154
+        'handler' => 'views_handler_sort_string'
155 155
     )
156
-  );
157
-  $data['team']['expavg_credit'] = array(
156
+    );
157
+    $data['team']['expavg_credit'] = array(
158 158
     'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'),
159 159
     'help' => t('A decaying average of team credit per day.'),
160 160
     'field' => array(
161
-      'handler' => 'views_handler_field_numeric',
162
-      'click sortable' => TRUE,
163
-      'float' => TRUE
161
+        'handler' => 'views_handler_field_numeric',
162
+        'click sortable' => TRUE,
163
+        'float' => TRUE
164 164
     ),
165 165
     'filter' => array(
166
-      'handler' => 'views_handler_filter_numeric'
166
+        'handler' => 'views_handler_filter_numeric'
167 167
     ),
168 168
     'sort' => array(
169
-      'handler' => 'views_handler_sort_numeric'
169
+        'handler' => 'views_handler_sort_numeric'
170 170
     )
171
-  );
172
-  $data['team']['name'] = array(
171
+    );
172
+    $data['team']['name'] = array(
173 173
     'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'),
174 174
     'help' => t('The name of the team.'),
175 175
     'field' => array(
176
-      'handler' => 'views_handler_field',
177
-      'click sortable' => TRUE
176
+        'handler' => 'views_handler_field',
177
+        'click sortable' => TRUE
178 178
     ),
179 179
     'filter' => array(
180
-      'handler' => 'views_handler_filter_string'
180
+        'handler' => 'views_handler_filter_string'
181 181
     ),
182 182
     'sort' => array(
183
-      'handler' => 'views_handler_sort_string'
183
+        'handler' => 'views_handler_sort_string'
184 184
     )
185
-  );
186
-  $data['team']['nusers'] = array(
185
+    );
186
+    $data['team']['nusers'] = array(
187 187
     'title' => bts('Members', array(), NULL, 'boinc:team-members'),
188 188
     'help' => t('Count of team members.'),
189 189
     'field' => array(
190
-      'handler' => 'views_handler_field_numeric',
191
-      'click sortable' => TRUE
190
+        'handler' => 'views_handler_field_numeric',
191
+        'click sortable' => TRUE
192 192
     ),
193 193
     'filter' => array(
194
-      'handler' => 'views_handler_filter_numeric'
194
+        'handler' => 'views_handler_filter_numeric'
195 195
     ),
196 196
     'sort' => array(
197
-      'handler' => 'views_handler_sort_numeric'
197
+        'handler' => 'views_handler_sort_numeric'
198 198
     )
199
-  );
200
-  $data['team']['total_credit'] = array(
199
+    );
200
+    $data['team']['total_credit'] = array(
201 201
     'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'),
202 202
     'help' => t('The total team accumulated BOINC credit.'),
203 203
     'field' => array(
204
-      'handler' => 'views_handler_field_numeric',
205
-      'click sortable' => TRUE,
206
-      'float' => TRUE
204
+        'handler' => 'views_handler_field_numeric',
205
+        'click sortable' => TRUE,
206
+        'float' => TRUE
207 207
     ),
208 208
     'filter' => array(
209
-      'handler' => 'views_handler_filter_numeric'
209
+        'handler' => 'views_handler_filter_numeric'
210 210
     ),
211 211
     'sort' => array(
212
-      'handler' => 'views_handler_sort_numeric'
212
+        'handler' => 'views_handler_sort_numeric'
213 213
     )
214
-  );
214
+    );
215 215
 
216
-  // -----------------------------------------------------------------------------------------------
217
-  // Definition for team_admin table
218
-  // -----------------------------------------------------------------------------------------------
216
+    // -----------------------------------------------------------------------------------------------
217
+    // Definition for team_admin table
218
+    // -----------------------------------------------------------------------------------------------
219 219
 
220
-  $data['team_admin']['table']['group'] = t('BOINC');
220
+    $data['team_admin']['table']['group'] = t('BOINC');
221 221
 
222
-  $data['team_admin']['table']['base'] = array(
223
-      'field' => 'id',
224
-      'title' => t('BOINC team admins'),
225
-      'help' => t('BOINC admins for a team'),
226
-      'database' => 'boinc_rw'
227
-  );
222
+    $data['team_admin']['table']['base'] = array(
223
+        'field' => 'id',
224
+        'title' => t('BOINC team admins'),
225
+        'help' => t('BOINC admins for a team'),
226
+        'database' => 'boinc_rw'
227
+    );
228 228
 
229
-  // This table references the {team} table.
230
-  // This join creates an 'implicit' relationship to the team table, so that when
231
-  // "Team" is the base table, the fields are automatically available.
229
+    // This table references the {team} table.
230
+    // This join creates an 'implicit' relationship to the team table, so that when
231
+    // "Team" is the base table, the fields are automatically available.
232 232
 
233
-  // Index this array by the table name to which this table refers.
234
-  // 'left_field' is the primary key in the referenced table.
235
-  // 'field' is the foreign key in this table.
233
+    // Index this array by the table name to which this table refers.
234
+    // 'left_field' is the primary key in the referenced table.
235
+    // 'field' is the foreign key in this table.
236 236
 
237
-  $data['team_admin']['table']['join'] = array(
237
+    $data['team_admin']['table']['join'] = array(
238 238
     'team' => array(
239
-      'left_field' => 'id',
240
-      'field' => 'teamid',
239
+        'left_field' => 'id',
240
+        'field' => 'teamid',
241 241
     ),
242
-  );
242
+    );
243 243
 
244
-  // Describe each of the individual fields in this table to Views. For
245
-  // each field, you may define what field, sort, argument, and/or filter
246
-  // handlers it supports. This will determine where in the Views interface you
247
-  // may use the field.
244
+    // Describe each of the individual fields in this table to Views. For
245
+    // each field, you may define what field, sort, argument, and/or filter
246
+    // handlers it supports. This will determine where in the Views interface you
247
+    // may use the field.
248 248
 
249
-  // Primary keys allowed as arguments
249
+    // Primary keys allowed as arguments
250 250
 
251
-  $data['team_admin']['teamid'] = array(
251
+    $data['team_admin']['teamid'] = array(
252 252
     'title' => bts('Team ID', array(), NULL, 'boinc:team-id'),
253 253
     'help' => t('The BOINC ID of the team on which this user is an admin.'),
254 254
     'field' => array(
255
-      'handler' => 'views_handler_field_numeric',
256
-      'click sortable' => TRUE
255
+        'handler' => 'views_handler_field_numeric',
256
+        'click sortable' => TRUE
257 257
     ),
258 258
     'argument' => array(
259
-      'handler' => 'views_handler_argument_boincteam_id', // custom handler
260
-      'name field' => 'title', // the field to display in the summary.
261
-      'numeric' => TRUE,
262
-      'validate type' => 'id'
259
+        'handler' => 'views_handler_argument_boincteam_id', // custom handler
260
+        'name field' => 'title', // the field to display in the summary.
261
+        'numeric' => TRUE,
262
+        'validate type' => 'id'
263 263
     ),
264 264
     'relationship' => array(
265
-      'base' => 'team',
266
-      'field' => 'teamid',
267
-      'handler' => 'views_handler_relationship',
268
-      'label' => t('Team')
265
+        'base' => 'team',
266
+        'field' => 'teamid',
267
+        'handler' => 'views_handler_relationship',
268
+        'label' => t('Team')
269 269
     ),
270 270
     'filter' => array(
271
-      'handler' => 'views_handler_filter_numeric'
271
+        'handler' => 'views_handler_filter_numeric'
272 272
     ),
273 273
     'sort' => array(
274
-      'handler' => 'views_handler_sort_numeric'
274
+        'handler' => 'views_handler_sort_numeric'
275 275
     )
276
-  );
276
+    );
277 277
 
278
-  // Foreign key fields
278
+    // Foreign key fields
279 279
 
280
-  $data['team_admin']['userid'] = array(
280
+    $data['team_admin']['userid'] = array(
281 281
     'title' => bts('User ID', array(), NULL, 'boinc:user-details'),
282 282
     'help' => t('The user that is a team admin.'),
283 283
     // This is a foreign key to the {user} table. When the view is configured
284 284
     // with this relationship, all the fields for the related user node will be
285 285
     // available.
286 286
     'argument' => array(
287
-      'handler' => 'views_handler_argument_boincteam_id',
288
-      'name field' => 'title',
289
-      'numeric' => TRUE,
290
-      'validate type' => 'id'
287
+        'handler' => 'views_handler_argument_boincteam_id',
288
+        'name field' => 'title',
289
+        'numeric' => TRUE,
290
+        'validate type' => 'id'
291 291
     ),
292 292
     'relationship' => array(
293
-      'base' => 'user',
294
-      'field' => 'userid',
295
-      'handler' => 'views_handler_relationship',
296
-      'label' => bts('User', array(), NULL, 'boinc:user-on-team')
293
+        'base' => 'user',
294
+        'field' => 'userid',
295
+        'handler' => 'views_handler_relationship',
296
+        'label' => bts('User', array(), NULL, 'boinc:user-on-team')
297 297
     ),
298 298
     'field' => array(
299
-      'handler' => 'views_handler_field_numeric',
300
-      'click sortable' => TRUE
299
+        'handler' => 'views_handler_field_numeric',
300
+        'click sortable' => TRUE
301 301
     ),
302 302
     'filter' => array(
303
-      'handler' => 'views_handler_filter_numeric'
303
+        'handler' => 'views_handler_filter_numeric'
304 304
     ),
305 305
     'sort' => array(
306
-      'handler' => 'views_handler_sort_numeric'
306
+        'handler' => 'views_handler_sort_numeric'
307 307
     )
308
-  );
308
+    );
309 309
 
310
-  // Descriptions of general fields (alphabetized)
310
+    // Descriptions of general fields (alphabetized)
311 311
 
312
-  $data['team_admin']['create_time'] = array(
312
+    $data['team_admin']['create_time'] = array(
313 313
     'title' => bts('Admin since', array(), NULL, 'boinc:team-when-user-became-an-admin'),
314 314
     'help' => t('When the BOINC user became a team admin.'),
315 315
     'field' => array(
316
-      'handler' => 'views_handler_field_date',
317
-      'click sortable' => TRUE
316
+        'handler' => 'views_handler_field_date',
317
+        'click sortable' => TRUE
318 318
     ),
319 319
     'filter' => array(
320
-      'handler' => 'views_handler_filter_date'
320
+        'handler' => 'views_handler_filter_date'
321 321
     ),
322 322
     'sort' => array(
323
-      'handler' => 'views_handler_sort_date'
323
+        'handler' => 'views_handler_sort_date'
324 324
     )
325
-  );
325
+    );
326 326
 
327
-  // -----------------------------------------------------------------------------------------------
328
-  // Definition for team_delta table
329
-  // -----------------------------------------------------------------------------------------------
327
+    // -----------------------------------------------------------------------------------------------
328
+    // Definition for team_delta table
329
+    // -----------------------------------------------------------------------------------------------
330 330
 
331
-  $data['team_delta']['table']['group'] = t('BOINC');
331
+    $data['team_delta']['table']['group'] = t('BOINC');
332 332
 
333
-  // Describe each of the individual fields in this table to Views. For
334
-  // each field, you may define what field, sort, argument, and/or filter
335
-  // handlers it supports. This will determine where in the Views interface you
336
-  // may use the field.
333
+    // Describe each of the individual fields in this table to Views. For
334
+    // each field, you may define what field, sort, argument, and/or filter
335
+    // handlers it supports. This will determine where in the Views interface you
336
+    // may use the field.
337 337
 
338
-  // Primary keys allowed as arguments
338
+    // Primary keys allowed as arguments
339 339
 
340
-  $data['team_delta']['teamid'] = array(
340
+    $data['team_delta']['teamid'] = array(
341 341
     'title' => bts('Team ID', array(), NULL, 'boinc:team-id'),
342 342
     'help' => t('The team ID for this team history event.'),
343 343
     // This is a foreign key to the {team} table. When the view is configured
344 344
     // with this relationship, all the fields for the related user node will be
345 345
     // available.
346 346
     'argument' => array(
347
-      'handler' => 'views_handler_argument_boincteam_id',
348
-      'name field' => 'title',
349
-      'numeric' => TRUE,
350
-      'validate type' => 'id'
347
+        'handler' => 'views_handler_argument_boincteam_id',
348
+        'name field' => 'title',
349
+        'numeric' => TRUE,
350
+        'validate type' => 'id'
351 351
     ),
352 352
     'field' => array(
353
-      'handler' => 'views_handler_field_numeric',
354
-      'click sortable' => TRUE
353
+        'handler' => 'views_handler_field_numeric',
354
+        'click sortable' => TRUE
355 355
     ),
356 356
     'filter' => array(
357
-      'handler' => 'views_handler_filter_numeric'
357
+        'handler' => 'views_handler_filter_numeric'
358 358
     ),
359 359
     'sort' => array(
360
-      'handler' => 'views_handler_sort_numeric'
360
+        'handler' => 'views_handler_sort_numeric'
361 361
     )
362
-  );
362
+    );
363 363
 
364
-  // Foreign key fields
364
+    // Foreign key fields
365 365
 
366
-  $data['team_delta']['userid'] = array(
366
+    $data['team_delta']['userid'] = array(
367 367
     'title' => bts('User ID', array(), NULL, 'boinc:user-details'),
368 368
     'help' => t('The user for this team history event.'),
369 369
     'relationship' => array(
370
-      'base' => 'user',
371
-      'field' => 'userid',
372
-      'handler' => 'views_handler_relationship',
373
-      'label' => t('User')
370
+        'base' => 'user',
371
+        'field' => 'userid',
372
+        'handler' => 'views_handler_relationship',
373
+        'label' => t('User')
374 374
     ),
375 375
     'field' => array(
376
-      'handler' => 'views_handler_field_numeric',
377
-      'click sortable' => TRUE
376
+        'handler' => 'views_handler_field_numeric',
377
+        'click sortable' => TRUE
378 378
     ),
379 379
     'filter' => array(
380
-      'handler' => 'views_handler_filter_numeric'
380
+        'handler' => 'views_handler_filter_numeric'
381 381
     ),
382 382
     'sort' => array(
383
-      'handler' => 'views_handler_sort_numeric'
383
+        'handler' => 'views_handler_sort_numeric'
384 384
     )
385
-  );
385
+    );
386 386
 
387
-  // Descriptions of general fields (alphabetized)
387
+    // Descriptions of general fields (alphabetized)
388 388
 
389
-  $data['team_delta']['joining'] = array(
389
+    $data['team_delta']['joining'] = array(
390 390
     'title' => bts('User joined', array(), NULL, 'boinc:user-joined-or-leaving-team'),
391 391
     'help' => t('Whether the event is the user joining the team or leaving.'),
392 392
     'field' => array(
393
-      'handler' => 'views_handler_field_numeric',
394
-      'click sortable' => TRUE
393
+        'handler' => 'views_handler_field_numeric',
394
+        'click sortable' => TRUE
395 395
     ),
396 396
     'filter' => array(
397
-      'handler' => 'views_handler_filter_numeric'
397
+        'handler' => 'views_handler_filter_numeric'
398 398
     ),
399 399
     'sort' => array(
400
-      'handler' => 'views_handler_sort_numeric'
400
+        'handler' => 'views_handler_sort_numeric'
401 401
     )
402
-  );
403
-  $data['team_delta']['timestamp'] = array(
402
+    );
403
+    $data['team_delta']['timestamp'] = array(
404 404
     'title' => bts('Timestamp', array(), NULL, 'boinc:team-history-timestamp'),
405 405
     'help' => t('When the BOINC team history event took place.'),
406 406
     'field' => array(
407
-      'handler' => 'views_handler_field_date',
408
-      'click sortable' => TRUE
407
+        'handler' => 'views_handler_field_date',
408
+        'click sortable' => TRUE
409 409
     ),
410 410
     'filter' => array(
411
-      'handler' => 'views_handler_filter_date'
411
+        'handler' => 'views_handler_filter_date'
412 412
     ),
413 413
     'sort' => array(
414
-      'handler' => 'views_handler_sort_date'
414
+        'handler' => 'views_handler_sort_date'
415 415
     )
416
-  );
417
-  $data['team_delta']['total_credit'] = array(
416
+    );
417
+    $data['team_delta']['total_credit'] = array(
418 418
     'title' => bts('Total credit', array(), NULL, 'user-or-team-total-credits'),
419 419
     'help' => t('The total accumulated BOINC credit of the user when the
420 420
       history event took place.'),
421 421
     'field' => array(
422
-      'handler' => 'views_handler_field_numeric',
423
-      'click sortable' => TRUE,
424
-      'float' => TRUE
422
+        'handler' => 'views_handler_field_numeric',
423
+        'click sortable' => TRUE,
424
+        'float' => TRUE
425 425
     ),
426 426
     'filter' => array(
427
-      'handler' => 'views_handler_filter_numeric'
427
+        'handler' => 'views_handler_filter_numeric'
428 428
     ),
429 429
     'sort' => array(
430
-      'handler' => 'views_handler_sort_numeric'
430
+        'handler' => 'views_handler_sort_numeric'
431 431
     )
432
-  );
432
+    );
433 433
 
434
-  return $data;
434
+    return $data;
435 435
 }
436 436
 
437 437
 /*
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
  */
443 443
 
444 444
 function boincteam_views_handlers() {
445
-  return array(
445
+    return array(
446 446
     'info' => array(
447
-      'path' => drupal_get_path('module', 'boincteam') . '/views',
447
+        'path' => drupal_get_path('module', 'boincteam') . '/views',
448 448
     ),
449 449
     'handlers' => array(
450
-      'views_handler_argument_boincteam_id' => array(
450
+        'views_handler_argument_boincteam_id' => array(
451 451
         'parent' => 'views_handler_argument_numeric'
452
-      )
452
+        )
453 453
     )
454
-  );
454
+    );
455 455
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam_forum.module 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -25,29 +25,29 @@  discard block
 block discarded – undo
25 25
  * Implementation of hook_menu()
26 26
  */
27 27
 function boincteam_forum_menu() {
28
-  $items = array();
28
+    $items = array();
29 29
 
30
-  return $items;
30
+    return $items;
31 31
 }
32 32
 
33 33
 /**
34 34
 * Implementation of hook_form_alter()
35 35
 */
36 36
 function boincteam_forum_form_alter(&$form, $form_state, $form_id) {
37
-  switch ($form_id) {
38
-  // Team forum node edit form
39
-  case 'team_forum_node_form':
37
+    switch ($form_id) {
38
+    // Team forum node edit form
39
+    case 'team_forum_node_form':
40 40
 
41 41
     // Internal fields to indicate where these changes are taking place
42 42
     array_unshift($form, array(
43
-      'tfid' => array(
43
+        'tfid' => array(
44 44
         '#type' => 'hidden',
45 45
         '#value' => arg(3),
46
-      ),
46
+        ),
47 47
     ));
48 48
     break;
49 49
 
50
-  default:
50
+    default:
51 51
   }
52 52
 }
53 53
 
@@ -56,26 +56,26 @@  discard block
 block discarded – undo
56 56
  * Obsolete in Drupal 7...
57 57
  */
58 58
 function boincteam_forum_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
59
-  // In Drupal 7, these operation cases will all exist as their own hooks,
60
-  // so let's approximate that here so that this function can simply be removed
61
-  // upon migration to 7
62
-  switch($op) {
63
-  case 'insert':
59
+    // In Drupal 7, these operation cases will all exist as their own hooks,
60
+    // so let's approximate that here so that this function can simply be removed
61
+    // upon migration to 7
62
+    switch($op) {
63
+    case 'insert':
64 64
     boincteam_forum_node_insert($node);
65 65
     break;
66
-  case 'load':
66
+    case 'load':
67 67
     boincteam_forum_node_load($node);
68 68
     break;
69
-  case 'update':
69
+    case 'update':
70 70
     boincteam_forum_node_update($node);
71 71
     break;
72
-  case 'validate':
72
+    case 'validate':
73 73
     boincteam_forum_node_validate($node);
74 74
     break;
75
-  case 'view':
75
+    case 'view':
76 76
     boincteam_forum_node_view($node);
77 77
     break;
78
-  default:
78
+    default:
79 79
   }
80 80
 }
81 81
 
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
  * is inserted (forward compatible to Drupal 7)
85 85
  */
86 86
 function boincteam_forum_node_insert($node) {
87
-  switch($node->type) {
88
-  case 'team_forum':
87
+    switch($node->type) {
88
+    case 'team_forum':
89 89
     $account = user_load($node->uid);
90 90
     $team_id = boincteam_forum_lookup_nid($node->tfid);
91 91
     if ($account->team == $team_id) {
92
-      db_query("
92
+        db_query("
93 93
         INSERT INTO {boincteam_forum_node} SET
94 94
           nid = %d,
95 95
           tfid = %d",
96 96
         $node->nid, $node->tfid
97
-      );
97
+        );
98 98
     }
99 99
     unset($node->tfid);
100 100
     break;
101
-  default:
101
+    default:
102 102
   }
103 103
 }
104 104
 
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
  * is loaded (forward compatible to Drupal 7)
108 108
  */
109 109
 function boincteam_forum_node_load($node) {
110
-  switch($node->type) {
111
-  case 'team_forum':
110
+    switch($node->type) {
111
+    case 'team_forum':
112 112
     $node->tfid = db_result(db_query("
113 113
       SELECT tfid FROM {boincteam_forum_node}
114 114
       WHERE nid = %d", $node->nid
115 115
     ));
116 116
     break;
117 117
 
118
-  default:
118
+    default:
119 119
 
120 120
   }
121 121
 }
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
  * is updated (forward compatible to Drupal 7)
126 126
  */
127 127
 function boincteam_forum_node_update($node) {
128
-  switch($node->type) {
129
-  case 'team_forum':
128
+    switch($node->type) {
129
+    case 'team_forum':
130 130
 
131 131
     break;
132 132
 
133
-  default:
133
+    default:
134 134
 
135 135
   }
136 136
 }
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
  * is validated (forward compatible to Drupal 7)
141 141
  */
142 142
 function boincteam_forum_node_validate($node) {
143
-  switch($node->type) {
144
-  case 'team_forum':
143
+    switch($node->type) {
144
+    case 'team_forum':
145 145
     $account = user_load($node->uid);
146 146
     // Get tfid from node, but if empty/null, get it from the database
147 147
     if (!($node->tfid)) {
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
     }
155 155
     $team_id = boincteam_forum_lookup_nid($tfid);
156 156
     if (!$account->team OR $account->team != $team_id) {
157
-      drupal_set_message(t('Failed to add team forum topic.'), 'error');
158
-      drupal_goto('community/forum');
157
+        drupal_set_message(t('Failed to add team forum topic.'), 'error');
158
+        drupal_goto('community/forum');
159 159
     }
160 160
     break;
161
-  default:
161
+    default:
162 162
   }
163 163
 }
164 164
 
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
  * is viewed (forward compatible to Drupal 7)
168 168
  */
169 169
 function boincteam_forum_node_view($node) {
170
-  switch($node->type) {
171
-  case 'team_forum':
170
+    switch($node->type) {
171
+    case 'team_forum':
172 172
     $team_id = boincteam_forum_lookup_nid($node->tfid);
173 173
     $public_forum = boincteam_forum_is_public($node->tfid);
174 174
     $is_member = boincteam_is_member($team_id);
175 175
     $is_global_moderator = boincteam_forum_is_global_moderator();
176 176
     if (!$public_forum AND !$is_member AND !$is_global_moderator) {
177
-      drupal_not_found();
178
-      module_invoke_all('exit');
179
-      exit();
177
+        drupal_not_found();
178
+        module_invoke_all('exit');
179
+        exit();
180 180
     }
181 181
     break;
182
-  default:
182
+    default:
183 183
   }
184 184
 }
185 185
 
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 * Implementation of hook_views_api().
188 188
 */
189 189
 function boincteam_forum_views_api() {
190
-  return array(
190
+    return array(
191 191
     'api' => 2.0,
192 192
     'path' => drupal_get_path('module', 'boincteam_forum')
193
-  );
193
+    );
194 194
 }
195 195
 
196 196
 /**
197 197
  * Implementation of hook_perm()
198 198
  */
199 199
 function boincteam_forum_perm() {
200
-  return array('manage boincteam forum');
200
+    return array('manage boincteam forum');
201 201
 }
202 202
 
203 203
 
@@ -209,43 +209,43 @@  discard block
 block discarded – undo
209 209
  * Check if the user has global access to moderate team forums
210 210
  */
211 211
 function boincteam_forum_is_global_moderator() {
212
-  global $user;
213
-  return user_access('manage boincteam forum');
212
+    global $user;
213
+    return user_access('manage boincteam forum');
214 214
 }
215 215
 
216 216
 /*
217 217
  * Check if any forums for a team are public
218 218
  */
219 219
 function boincteam_forum_is_any_public($team_id) {
220
-  $forums = boincteam_forum_list($team_id);
221
-  foreach ($forums as $forum) {
220
+    $forums = boincteam_forum_list($team_id);
221
+    foreach ($forums as $forum) {
222 222
     if ($forum->public) {
223
-      return TRUE;
223
+        return TRUE;
224 224
     }
225
-  }
226
-  return FALSE;
225
+    }
226
+    return FALSE;
227 227
 }
228 228
 
229 229
 /*
230 230
  * Check if a team forum should be visible to everyone
231 231
  */
232 232
 function boincteam_forum_is_public($tfid) {
233
-  return db_result(db_query("
233
+    return db_result(db_query("
234 234
     SELECT public FROM {boincteam_forum} WHERE tfid=%d", $tfid
235
-  ));
235
+    ));
236 236
 }
237 237
 
238 238
 /*
239 239
  * Load the forums for a team, if any exist
240 240
  */
241 241
 function boincteam_forum_list($team_id = NULL) {
242
-  if (!$team_id) {
242
+    if (!$team_id) {
243 243
     global $user;
244 244
     $account = user_load($user->uid);
245 245
     $team_id = $account->team;
246
-  }
247
-  $team_forums = array();
248
-  if ($team_id) {
246
+    }
247
+    $team_forums = array();
248
+    if ($team_id) {
249 249
     // Load any team forum objects for the user's team
250 250
     $result = db_query("
251 251
       SELECT tfid, nid, title, description, created, updated, public,
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
     $row = 0;
256 256
     while ($team_forum = db_fetch_object($result)) {
257 257
 
258
-      $team_forum->link = url("community/teams/{$team_id}/forum/{$team_forum->tfid}");
259
-      $team_forum->zebra = $row % 2 ? 'even' : 'odd';
260
-      $team_forum->new_topics = 0; // TODO: Track user views of team topics
261
-      $team_forum->new_text = '';
262
-      $team_forum->new_url = '';
263
-      $team_forum->num_topics = db_result(db_query("
258
+        $team_forum->link = url("community/teams/{$team_id}/forum/{$team_forum->tfid}");
259
+        $team_forum->zebra = $row % 2 ? 'even' : 'odd';
260
+        $team_forum->new_topics = 0; // TODO: Track user views of team topics
261
+        $team_forum->new_text = '';
262
+        $team_forum->new_url = '';
263
+        $team_forum->num_topics = db_result(db_query("
264 264
         SELECT COUNT(nid) FROM {boincteam_forum_node}
265 265
         WHERE tfid = %d",
266 266
         $team_forum->tfid
267
-      ));
268
-      $team_forum->num_posts = db_result(db_query("
267
+        ));
268
+        $team_forum->num_posts = db_result(db_query("
269 269
         SELECT COALESCE(SUM(ncs.comment_count),0) + COUNT(ncs.nid)
270 270
         FROM {boincteam_forum_node} bfn
271 271
         JOIN {node_comment_statistics} ncs ON ncs.nid = bfn.nid
272 272
         JOIN {node} n ON n.nid = ncs.nid
273 273
         WHERE bfn.tfid = %d AND n.status = 1",
274 274
         $team_forum->tfid
275
-      ));
276
-      $last_post = new stdClass();
277
-      $last_post->timestamp = db_result(db_query("
275
+        ));
276
+        $last_post = new stdClass();
277
+        $last_post->timestamp = db_result(db_query("
278 278
         SELECT ncs.last_comment_timestamp FROM {node} n
279 279
         INNER JOIN {boincteam_forum_node} bfn
280 280
         INNER JOIN {node_comment_statistics} ncs ON n.nid = bfn.nid AND n.nid = ncs.nid
@@ -282,36 +282,36 @@  discard block
 block discarded – undo
282 282
         ORDER BY ncs.last_comment_timestamp DESC
283 283
         LIMIT 1",
284 284
         $team_forum->tfid
285
-      ));
286
-      $team_forum->last_reply = theme('forum_submitted', ($last_post->timestamp) ? $last_post : NULL);
287
-      $team_forums[$team_forum->tfid] = $team_forum;
288
-      $row++;
285
+        ));
286
+        $team_forum->last_reply = theme('forum_submitted', ($last_post->timestamp) ? $last_post : NULL);
287
+        $team_forums[$team_forum->tfid] = $team_forum;
288
+        $row++;
289 289
     }
290
-  }
291
-  return $team_forums;
290
+    }
291
+    return $team_forums;
292 292
 }
293 293
 
294 294
 /*
295 295
  * Load a team forum by ID
296 296
  */
297 297
 function boincteam_forum_load($tfid) {
298
-  // Load any team forum objects for the user's team
299
-  $result = db_query("
298
+    // Load any team forum objects for the user's team
299
+    $result = db_query("
300 300
     SELECT tfid, nid, title, description, created, updated, public,
301 301
       min_time_between_posts, min_total_credit_to_post, min_avg_credit_to_post
302 302
     FROM {boincteam_forum} WHERE tfid=%d", $tfid
303
-  );
304
-  return db_fetch_object($result);
303
+    );
304
+    return db_fetch_object($result);
305 305
 }
306 306
 
307 307
 /*
308 308
  * Look up the team ID for a given team forum
309 309
  */
310 310
 function boincteam_forum_lookup_nid($tfid) {
311
-  return db_result(db_query("
311
+    return db_result(db_query("
312 312
     SELECT nid FROM {boincteam_forum}
313 313
     WHERE tfid=%d", $tfid
314
-  ));
314
+    ));
315 315
 }
316 316
 
317 317
 
@@ -323,80 +323,80 @@  discard block
 block discarded – undo
323 323
  * Create team forum form
324 324
  */
325 325
 function boincteam_forum_create_form_panel() {
326
-  $output = '';
327
-  $output .= '<h2 class="pane-title">' . bts('Create team message board', array(), NULL, 'boinc:team-forum')
326
+    $output = '';
327
+    $output .= '<h2 class="pane-title">' . bts('Create team message board', array(), NULL, 'boinc:team-forum')
328 328
     . '</h2>';
329
-  $output .= drupal_get_form('boincteam_forum_create_form');
329
+    $output .= drupal_get_form('boincteam_forum_create_form');
330 330
 
331
-  return $output;
331
+    return $output;
332 332
 }
333 333
 
334 334
 /**
335 335
  * Edit team forum form
336 336
  */
337 337
 function boincteam_forum_edit_form_panel($tfid) {
338
-  $team_forum = boincteam_forum_load($tfid);
339
-  $output = '';
340
-  $output .= '<h2 class="pane-title">' . bts('Edit message board', array(), NULL, 'boinc:team-forum') . ': ' .
338
+    $team_forum = boincteam_forum_load($tfid);
339
+    $output = '';
340
+    $output .= '<h2 class="pane-title">' . bts('Edit message board', array(), NULL, 'boinc:team-forum') . ': ' .
341 341
     $team_forum->title . '</h2>';
342
-  $output .= drupal_get_form('boincteam_forum_edit_form', $tfid);
342
+    $output .= drupal_get_form('boincteam_forum_edit_form', $tfid);
343 343
 
344
-  return $output;
344
+    return $output;
345 345
 }
346 346
 
347 347
 /**
348 348
  * Link to team forums
349 349
  */
350 350
 function boincteam_forum_link_panel($team_id) {
351
-  $show_public_only = (
351
+    $show_public_only = (
352 352
     !boincteam_is_member($team_id) AND
353 353
     !boincteam_forum_is_global_moderator()
354
-  );
355
-  $forums = boincteam_forum_list($team_id);
356
-  $output = '';
357
-  $output .= '<h2 class="pane-title">' . bts('Team forum', array(), NULL, 'boinc:team-forum') . '</h2>';
358
-  $output .= '<p>'
354
+    );
355
+    $forums = boincteam_forum_list($team_id);
356
+    $output = '';
357
+    $output .= '<h2 class="pane-title">' . bts('Team forum', array(), NULL, 'boinc:team-forum') . '</h2>';
358
+    $output .= '<p>'
359 359
     . bts('A discussion forum has been set up for team members.', array(), NULL, 'boinc:team-forum')
360 360
     . '</p>';
361
-  $output .= '<ul class="tab-list action-list">';
362
-  foreach ($forums as $forum) {
361
+    $output .= '<ul class="tab-list action-list">';
362
+    foreach ($forums as $forum) {
363 363
     if (!$show_public_only OR $forum->public) {
364
-      $output .= '  <li class="tab primary">' .
364
+        $output .= '  <li class="tab primary">' .
365 365
         l(
366
-          //$forum->title,
367
-          bts('Enter forum', array(), NULL, 'boinc:team-forum'),
368
-          "community/teams/{$team_id}/forum/{$forum->tfid}"
366
+            //$forum->title,
367
+            bts('Enter forum', array(), NULL, 'boinc:team-forum'),
368
+            "community/teams/{$team_id}/forum/{$forum->tfid}"
369 369
         ) . '</li>';
370
-      // Since we're only supporting one team forum for now, we've labeled the
371
-      // link in a generic way above and will now just break out of the loop
372
-      break;
370
+        // Since we're only supporting one team forum for now, we've labeled the
371
+        // link in a generic way above and will now just break out of the loop
372
+        break;
373 373
     }
374
-  }
375
-  $output .= '</ul>';
376
-  return $output;
374
+    }
375
+    $output .= '</ul>';
376
+    return $output;
377 377
 }
378 378
 
379 379
 /**
380 380
  * General info about team forums
381 381
  */
382 382
 function boincteam_forum_topic_overview_panel($nid = NULL) {
383
-  $output = '';
384
-  $output .= '<h2 class="pane-title">' . bts('About message boards', array(), NULL, 'boinc:team-forum') . '</h2>';
385
-  $output .= '<div>';
386
-  if ($nid) {
383
+    $output = '';
384
+    $output .= '<h2 class="pane-title">' . bts('About message boards', array(), NULL, 'boinc:team-forum') . '</h2>';
385
+    $output .= '<div>';
386
+    if ($nid) {
387 387
     $team = node_load($nid);
388 388
     $output .= '<p>' . bts('You may create a message board for use by @team',
389
-      array('@team' => $team->title), NULL, 'boinc:team-forum') . ':</p>';
390
-  }
391
-  else {
389
+        array('@team' => $team->title), NULL, 'boinc:team-forum') . ':</p>';
390
+    }
391
+    else {
392 392
     $output .= '<p>' . bts('This is a team-only message board', array(), NULL, 'boinc:team-forum') . ':</p>';
393
-  }
394
-  $output .= '<ul>';
395
-  $output .= '  <li>' . bts('Only members may post', array(), NULL, 'boinc:team-forum') . '</li>';
396
-  $output .= '  <li>' . bts('Only members may read (optional)', array(), NULL, 'boinc:team-forum') . '</li>';
397
-  $output .= '  <li>' . bts('Founder & Team Admins have moderator privileges', array(), NULL, 'boinc:team-forum') .
393
+    }
394
+    $output .= '<ul>';
395
+    $output .= '  <li>' . bts('Only members may post', array(), NULL, 'boinc:team-forum') . '</li>';
396
+    $output .= '  <li>' . bts('Only members may read (optional)', array(), NULL, 'boinc:team-forum') . '</li>';
397
+    $output .= '  <li>' . bts('Founder & Team Admins have moderator privileges', array(), NULL, 'boinc:team-forum') .
398 398
     '</li>';
399
-  $output .= '</ul>';
400
-  $output .= '</div>';
401
-  return $output;
399
+    $output .= '</ul>';
400
+    $output .= '</div>';
401
+    return $output;
402 402
 }
Please login to merge, or discard this patch.
sites/default/boinc/modules/flag_comment_notify/flag_comment_notify.module 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
  * Implementation of hook_comment();
27 27
  */
28 28
 function flag_comment_notify_comment(&$a1, $op) {
29
-  switch ($op) {
30
-  case 'insert':
29
+    switch ($op) {
30
+    case 'insert':
31 31
     module_load_include('inc', 'drupal_queue', 'drupal_queue');
32 32
     $queue = DrupalQueue::get('flag_comment_notify');
33 33
     $subscribed_users = array_keys((array) flag_get_content_flags('node', $a1['nid'], 'subscriptions'));
34 34
     foreach ($subscribed_users as $uid) {
35
-      $queue->createItem(array('uid' => $uid, 'cid' => (int) $a1['cid']));
35
+        $queue->createItem(array('uid' => $uid, 'cid' => (int) $a1['cid']));
36 36
     }
37 37
     break;
38
-  default:
38
+    default:
39 39
   }
40 40
 }
41 41
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * Implementation of hook_cron_queue_info()
44 44
  */
45 45
 function flag_comment_notify_cron_queue_info() {
46
-  $queues = array();
47
-  $queues['flag_comment_notify'] = array(
46
+    $queues = array();
47
+    $queues['flag_comment_notify'] = array(
48 48
     'worker callback' => 'flag_comment_notify_send_notification',
49 49
     'time' => 60,
50
-  );
51
-  return $queues;
50
+    );
51
+    return $queues;
52 52
 }
53 53
 
54 54
 
@@ -57,44 +57,44 @@  discard block
 block discarded – undo
57 57
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
58 58
 
59 59
 function flag_comment_notify_send_notification($data) {
60
-  $account = user_load($data['uid']);
61
-  $comment = _comment_load($data['cid']);
62
-  $node = node_load($comment->nid);
63
-  $author = user_load($comment->uid);
64
-  if ($account->mail AND $node->nid) {
60
+    $account = user_load($data['uid']);
61
+    $comment = _comment_load($data['cid']);
62
+    $node = node_load($comment->nid);
63
+    $author = user_load($comment->uid);
64
+    if ($account->mail AND $node->nid) {
65 65
     // Don't send notifications to the author of the comment
66 66
     if ($account->uid != $author->uid) {
67
-      $params['account'] = $account;
68
-      $params['comment'] = $comment;
69
-      $params['node'] = $node;
70
-      $params['author'] = $author;
71
-      drupal_mail('flag_comment_notify', 'comment_posted', $account->mail,
67
+        $params['account'] = $account;
68
+        $params['comment'] = $comment;
69
+        $params['node'] = $node;
70
+        $params['author'] = $author;
71
+        drupal_mail('flag_comment_notify', 'comment_posted', $account->mail,
72 72
         user_preferred_language($account), $params);
73 73
     }
74
-  }
74
+    }
75 75
 }
76 76
 
77 77
 
78 78
 function flag_comment_notify_mail($key, &$message, $params) {
79
-  $language = $message['language'];
80
-  $variables = user_mail_tokens($params['account'], $language);
81
-  $variables['!comment_url'] = url(
79
+    $language = $message['language'];
80
+    $variables = user_mail_tokens($params['account'], $language);
81
+    $variables['!comment_url'] = url(
82 82
     "goto/comment/{$params['comment']->cid}",
83 83
     array(
84
-      'absolute' => TRUE,
84
+        'absolute' => TRUE,
85 85
     )
86
-  );
87
-  $variables['!topic_name'] = $params['node']->title;
88
-  $variables['!author'] = $params['author']->name;
89
-  switch($key) {
90
-  case 'comment_posted':
86
+    );
87
+    $variables['!topic_name'] = $params['node']->title;
88
+    $variables['!author'] = $params['author']->name;
89
+    switch($key) {
90
+    case 'comment_posted':
91 91
     $message['subject'] = bts('!site: comment posted to "!topic_name"', $variables,
92
-      $language->language, 'boinc:forum-topic-subscription-email-notification');
92
+        $language->language, 'boinc:forum-topic-subscription-email-notification');
93 93
     $message['body'][] = bts('!author has posted a reply to "!topic_name".',
94
-      $variables, $language->language, 'boinc:forum-topic-subscription-email-notification');
94
+        $variables, $language->language, 'boinc:forum-topic-subscription-email-notification');
95 95
     $message['body'][] = bts("To view this topic at !site, click here: \n!comment_url",
96
-      $variables, $language->language, 'boinc:forum-topic-subscription-email-notification');
96
+        $variables, $language->language, 'boinc:forum-topic-subscription-email-notification');
97 97
     break;
98
-  default:
98
+    default:
99 99
   }
100 100
 }
Please login to merge, or discard this patch.