@@ -48,20 +48,20 @@ |
||
48 | 48 | $value = $values->{$this->field_alias}; |
49 | 49 | |
50 | 50 | switch ($this->options['format']) { |
51 | - case 'hours': |
|
52 | - $output = date('g', (int) $value); |
|
53 | - break; |
|
54 | - case 'minutes': |
|
55 | - $output = date('i', (int) $value); |
|
56 | - break; |
|
57 | - case 'seconds': |
|
58 | - $output = date('s', (int) $value); |
|
59 | - break; |
|
60 | - case 'total': |
|
61 | - $output = check_plain($value); |
|
62 | - break; |
|
63 | - default: |
|
64 | - $output = theme('filefield_meta_duration', $value); |
|
51 | + case 'hours': |
|
52 | + $output = date('g', (int) $value); |
|
53 | + break; |
|
54 | + case 'minutes': |
|
55 | + $output = date('i', (int) $value); |
|
56 | + break; |
|
57 | + case 'seconds': |
|
58 | + $output = date('s', (int) $value); |
|
59 | + break; |
|
60 | + case 'total': |
|
61 | + $output = check_plain($value); |
|
62 | + break; |
|
63 | + default: |
|
64 | + $output = theme('filefield_meta_duration', $value); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Check to see if hiding should happen before adding prefix and suffix. |
@@ -50,11 +50,11 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | switch ($this->options['format']) { |
53 | - case 'raw': |
|
54 | - $output = $value; |
|
55 | - break; |
|
56 | - default: |
|
57 | - $output = theme('filefield_meta_bitrate', $value); |
|
53 | + case 'raw': |
|
54 | + $output = $value; |
|
55 | + break; |
|
56 | + default: |
|
57 | + $output = theme('filefield_meta_bitrate', $value); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']); |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | unset($fields['table']); |
23 | 23 | foreach ($fields as $filefield_field => $definition) { |
24 | 24 | switch ($filefield_field) { |
25 | - case $content_field['field_name'] .'_fid': |
|
26 | - $filefield_fields[$filefield_field] = array( |
|
27 | - 'table' => $table, |
|
28 | - 'field' => $filefield_field, |
|
29 | - ); |
|
30 | - $filefield_arguments['content: '. $content_field['field_name']] = &$filefield_fields[$filefield_field]; |
|
31 | - break; |
|
32 | - case $content_field['field_name'] .'_list': |
|
33 | - $filefield_filters[$content_field['field_name'] .'_fid_not null'] = array( |
|
34 | - 'table' => $table, |
|
35 | - 'field' => $filefield_field, |
|
36 | - ); |
|
37 | - break; |
|
25 | + case $content_field['field_name'] .'_fid': |
|
26 | + $filefield_fields[$filefield_field] = array( |
|
27 | + 'table' => $table, |
|
28 | + 'field' => $filefield_field, |
|
29 | + ); |
|
30 | + $filefield_arguments['content: '. $content_field['field_name']] = &$filefield_fields[$filefield_field]; |
|
31 | + break; |
|
32 | + case $content_field['field_name'] .'_list': |
|
33 | + $filefield_filters[$content_field['field_name'] .'_fid_not null'] = array( |
|
34 | + 'table' => $table, |
|
35 | + 'field' => $filefield_field, |
|
36 | + ); |
|
37 | + break; |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
@@ -43,39 +43,39 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | switch ($type) { |
46 | - case 'field': |
|
47 | - if (isset($filefield_fields[$field['field']])) { |
|
48 | - $multiple = array(); |
|
49 | - switch ($field['handler']) { |
|
50 | - case 'content_views_field_handler_ungroup': |
|
51 | - $view->set_item_option($display, 'field', $id, 'multiple', array('group' => FALSE)); |
|
52 | - break; |
|
53 | - case 'content_views_field_handler_last': |
|
54 | - $multiple['multiple_reversed'] = TRUE; |
|
55 | - case 'content_views_field_handler_first': |
|
56 | - $multiple['multiple_number'] = 1; |
|
57 | - $view->set_item_option($display, 'field', $id, 'multiple', $multiple); |
|
58 | - break; |
|
59 | - } |
|
60 | - $view->set_item_option($display, 'field', $id, 'format', $field['options']); |
|
61 | - } |
|
46 | + case 'field': |
|
47 | + if (isset($filefield_fields[$field['field']])) { |
|
48 | + $multiple = array(); |
|
49 | + switch ($field['handler']) { |
|
50 | + case 'content_views_field_handler_ungroup': |
|
51 | + $view->set_item_option($display, 'field', $id, 'multiple', array('group' => FALSE)); |
|
62 | 52 | break; |
63 | - case 'filter': |
|
64 | - if (isset($filefield_filters[$field['field']])) { |
|
65 | - $filter = $filefield_filters[$field['field']]; |
|
66 | - $item = $view->get_item($display, 'filter', $id); |
|
67 | - $item['value'] = $field['value']; |
|
68 | - $item['table'] = $filter['table']; |
|
69 | - $item['field'] = $filter['field']; |
|
70 | - $view->set_item($display, 'filter', $id, $item); |
|
71 | - } |
|
53 | + case 'content_views_field_handler_last': |
|
54 | + $multiple['multiple_reversed'] = TRUE; |
|
55 | + case 'content_views_field_handler_first': |
|
56 | + $multiple['multiple_number'] = 1; |
|
57 | + $view->set_item_option($display, 'field', $id, 'multiple', $multiple); |
|
72 | 58 | break; |
73 | - case 'argument': |
|
74 | - if (isset($filefield_arguments[$field['type']])) { |
|
75 | - $argument = $filefield_arguments[$field['type']]; |
|
76 | - $options = $field['argoptions']; |
|
77 | - $view->add_item($display, 'argument', $argument['table'], $argument['field'], $options, $field['id']); |
|
59 | + } |
|
60 | + $view->set_item_option($display, 'field', $id, 'format', $field['options']); |
|
78 | 61 | } |
79 | 62 | break; |
63 | + case 'filter': |
|
64 | + if (isset($filefield_filters[$field['field']])) { |
|
65 | + $filter = $filefield_filters[$field['field']]; |
|
66 | + $item = $view->get_item($display, 'filter', $id); |
|
67 | + $item['value'] = $field['value']; |
|
68 | + $item['table'] = $filter['table']; |
|
69 | + $item['field'] = $filter['field']; |
|
70 | + $view->set_item($display, 'filter', $id, $item); |
|
71 | + } |
|
72 | + break; |
|
73 | + case 'argument': |
|
74 | + if (isset($filefield_arguments[$field['type']])) { |
|
75 | + $argument = $filefield_arguments[$field['type']]; |
|
76 | + $options = $field['argoptions']; |
|
77 | + $view->add_item($display, 'argument', $argument['table'], $argument['field'], $options, $field['id']); |
|
78 | + } |
|
79 | + break; |
|
80 | 80 | } |
81 | 81 | } |
@@ -123,126 +123,126 @@ |
||
123 | 123 | function _filefield_generic_icon_map($file) { |
124 | 124 | switch ($file['filemime']) { |
125 | 125 | // Word document types. |
126 | - case 'application/msword': |
|
127 | - case 'application/vnd.ms-word.document.macroEnabled.12': |
|
128 | - case 'application/vnd.oasis.opendocument.text': |
|
129 | - case 'application/vnd.oasis.opendocument.text-template': |
|
130 | - case 'application/vnd.oasis.opendocument.text-master': |
|
131 | - case 'application/vnd.oasis.opendocument.text-web': |
|
132 | - case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': |
|
133 | - case 'application/vnd.stardivision.writer': |
|
134 | - case 'application/vnd.sun.xml.writer': |
|
135 | - case 'application/vnd.sun.xml.writer.template': |
|
136 | - case 'application/vnd.sun.xml.writer.global': |
|
137 | - case 'application/vnd.wordperfect': |
|
138 | - case 'application/x-abiword': |
|
139 | - case 'application/x-applix-word': |
|
140 | - case 'application/x-kword': |
|
141 | - case 'application/x-kword-crypt': |
|
142 | - return 'x-office-document'; |
|
143 | - |
|
144 | - // Spreadsheet document types. |
|
145 | - case 'application/vnd.ms-excel': |
|
146 | - case 'application/vnd.ms-excel.sheet.macroEnabled.12': |
|
147 | - case 'application/vnd.oasis.opendocument.spreadsheet': |
|
148 | - case 'application/vnd.oasis.opendocument.spreadsheet-template': |
|
149 | - case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': |
|
150 | - case 'application/vnd.stardivision.calc': |
|
151 | - case 'application/vnd.sun.xml.calc': |
|
152 | - case 'application/vnd.sun.xml.calc.template': |
|
153 | - case 'application/vnd.lotus-1-2-3': |
|
154 | - case 'application/x-applix-spreadsheet': |
|
155 | - case 'application/x-gnumeric': |
|
156 | - case 'application/x-kspread': |
|
157 | - case 'application/x-kspread-crypt': |
|
158 | - return 'x-office-spreadsheet'; |
|
159 | - |
|
160 | - // Presentation document types. |
|
161 | - case 'application/vnd.ms-powerpoint': |
|
162 | - case 'application/vnd.ms-powerpoint.presentation.macroEnabled.12': |
|
163 | - case 'application/vnd.oasis.opendocument.presentation': |
|
164 | - case 'application/vnd.oasis.opendocument.presentation-template': |
|
165 | - case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': |
|
166 | - case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': |
|
167 | - case 'application/vnd.stardivision.impress': |
|
168 | - case 'application/vnd.sun.xml.impress': |
|
169 | - case 'application/vnd.sun.xml.impress.template': |
|
170 | - case 'application/x-kpresenter': |
|
171 | - return 'x-office-presentation'; |
|
172 | - |
|
173 | - // Compressed archive types. |
|
174 | - case 'application/zip': |
|
175 | - case 'application/x-zip': |
|
176 | - case 'application/stuffit': |
|
177 | - case 'application/x-stuffit': |
|
178 | - case 'application/x-7z-compressed': |
|
179 | - case 'application/x-ace': |
|
180 | - case 'application/x-arj': |
|
181 | - case 'application/x-bzip': |
|
182 | - case 'application/x-bzip-compressed-tar': |
|
183 | - case 'application/x-compress': |
|
184 | - case 'application/x-compressed-tar': |
|
185 | - case 'application/x-cpio-compressed': |
|
186 | - case 'application/x-deb': |
|
187 | - case 'application/x-gzip': |
|
188 | - case 'application/x-java-archive': |
|
189 | - case 'application/x-lha': |
|
190 | - case 'application/x-lhz': |
|
191 | - case 'application/x-lzop': |
|
192 | - case 'application/x-rar': |
|
193 | - case 'application/x-rpm': |
|
194 | - case 'application/x-tzo': |
|
195 | - case 'application/x-tar': |
|
196 | - case 'application/x-tarz': |
|
197 | - case 'application/x-tgz': |
|
198 | - return 'package-x-generic'; |
|
199 | - |
|
200 | - // Script file types. |
|
201 | - case 'application/ecmascript': |
|
202 | - case 'application/javascript': |
|
203 | - case 'application/mathematica': |
|
204 | - case 'application/vnd.mozilla.xul+xml': |
|
205 | - case 'application/x-asp': |
|
206 | - case 'application/x-awk': |
|
207 | - case 'application/x-cgi': |
|
208 | - case 'application/x-csh': |
|
209 | - case 'application/x-m4': |
|
210 | - case 'application/x-perl': |
|
211 | - case 'application/x-php': |
|
212 | - case 'application/x-ruby': |
|
213 | - case 'application/x-shellscript': |
|
214 | - case 'text/vnd.wap.wmlscript': |
|
215 | - case 'text/x-emacs-lisp': |
|
216 | - case 'text/x-haskell': |
|
217 | - case 'text/x-literate-haskell': |
|
218 | - case 'text/x-lua': |
|
219 | - case 'text/x-makefile': |
|
220 | - case 'text/x-matlab': |
|
221 | - case 'text/x-python': |
|
222 | - case 'text/x-sql': |
|
223 | - case 'text/x-tcl': |
|
224 | - return 'text-x-script'; |
|
225 | - |
|
226 | - // HTML aliases. |
|
227 | - case 'application/xhtml+xml': |
|
228 | - return 'text-html'; |
|
229 | - |
|
230 | - // RTF files. |
|
231 | - case 'application/rtf': |
|
232 | - return 'text-rtf'; |
|
233 | - |
|
234 | - // Google earth files. |
|
235 | - case 'application/vnd.google-earth.kml+xml': |
|
236 | - case 'application/vnd.google-earth.kmz': |
|
237 | - return 'application-google-earth'; |
|
238 | - |
|
239 | - // Executable types. |
|
240 | - case 'application/x-macbinary': |
|
241 | - case 'application/x-ms-dos-executable': |
|
242 | - case 'application/x-pef-executable': |
|
243 | - return 'application-x-executable'; |
|
244 | - |
|
245 | - default: |
|
246 | - return FALSE; |
|
126 | + case 'application/msword': |
|
127 | + case 'application/vnd.ms-word.document.macroEnabled.12': |
|
128 | + case 'application/vnd.oasis.opendocument.text': |
|
129 | + case 'application/vnd.oasis.opendocument.text-template': |
|
130 | + case 'application/vnd.oasis.opendocument.text-master': |
|
131 | + case 'application/vnd.oasis.opendocument.text-web': |
|
132 | + case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': |
|
133 | + case 'application/vnd.stardivision.writer': |
|
134 | + case 'application/vnd.sun.xml.writer': |
|
135 | + case 'application/vnd.sun.xml.writer.template': |
|
136 | + case 'application/vnd.sun.xml.writer.global': |
|
137 | + case 'application/vnd.wordperfect': |
|
138 | + case 'application/x-abiword': |
|
139 | + case 'application/x-applix-word': |
|
140 | + case 'application/x-kword': |
|
141 | + case 'application/x-kword-crypt': |
|
142 | + return 'x-office-document'; |
|
143 | + |
|
144 | + // Spreadsheet document types. |
|
145 | + case 'application/vnd.ms-excel': |
|
146 | + case 'application/vnd.ms-excel.sheet.macroEnabled.12': |
|
147 | + case 'application/vnd.oasis.opendocument.spreadsheet': |
|
148 | + case 'application/vnd.oasis.opendocument.spreadsheet-template': |
|
149 | + case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': |
|
150 | + case 'application/vnd.stardivision.calc': |
|
151 | + case 'application/vnd.sun.xml.calc': |
|
152 | + case 'application/vnd.sun.xml.calc.template': |
|
153 | + case 'application/vnd.lotus-1-2-3': |
|
154 | + case 'application/x-applix-spreadsheet': |
|
155 | + case 'application/x-gnumeric': |
|
156 | + case 'application/x-kspread': |
|
157 | + case 'application/x-kspread-crypt': |
|
158 | + return 'x-office-spreadsheet'; |
|
159 | + |
|
160 | + // Presentation document types. |
|
161 | + case 'application/vnd.ms-powerpoint': |
|
162 | + case 'application/vnd.ms-powerpoint.presentation.macroEnabled.12': |
|
163 | + case 'application/vnd.oasis.opendocument.presentation': |
|
164 | + case 'application/vnd.oasis.opendocument.presentation-template': |
|
165 | + case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': |
|
166 | + case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': |
|
167 | + case 'application/vnd.stardivision.impress': |
|
168 | + case 'application/vnd.sun.xml.impress': |
|
169 | + case 'application/vnd.sun.xml.impress.template': |
|
170 | + case 'application/x-kpresenter': |
|
171 | + return 'x-office-presentation'; |
|
172 | + |
|
173 | + // Compressed archive types. |
|
174 | + case 'application/zip': |
|
175 | + case 'application/x-zip': |
|
176 | + case 'application/stuffit': |
|
177 | + case 'application/x-stuffit': |
|
178 | + case 'application/x-7z-compressed': |
|
179 | + case 'application/x-ace': |
|
180 | + case 'application/x-arj': |
|
181 | + case 'application/x-bzip': |
|
182 | + case 'application/x-bzip-compressed-tar': |
|
183 | + case 'application/x-compress': |
|
184 | + case 'application/x-compressed-tar': |
|
185 | + case 'application/x-cpio-compressed': |
|
186 | + case 'application/x-deb': |
|
187 | + case 'application/x-gzip': |
|
188 | + case 'application/x-java-archive': |
|
189 | + case 'application/x-lha': |
|
190 | + case 'application/x-lhz': |
|
191 | + case 'application/x-lzop': |
|
192 | + case 'application/x-rar': |
|
193 | + case 'application/x-rpm': |
|
194 | + case 'application/x-tzo': |
|
195 | + case 'application/x-tar': |
|
196 | + case 'application/x-tarz': |
|
197 | + case 'application/x-tgz': |
|
198 | + return 'package-x-generic'; |
|
199 | + |
|
200 | + // Script file types. |
|
201 | + case 'application/ecmascript': |
|
202 | + case 'application/javascript': |
|
203 | + case 'application/mathematica': |
|
204 | + case 'application/vnd.mozilla.xul+xml': |
|
205 | + case 'application/x-asp': |
|
206 | + case 'application/x-awk': |
|
207 | + case 'application/x-cgi': |
|
208 | + case 'application/x-csh': |
|
209 | + case 'application/x-m4': |
|
210 | + case 'application/x-perl': |
|
211 | + case 'application/x-php': |
|
212 | + case 'application/x-ruby': |
|
213 | + case 'application/x-shellscript': |
|
214 | + case 'text/vnd.wap.wmlscript': |
|
215 | + case 'text/x-emacs-lisp': |
|
216 | + case 'text/x-haskell': |
|
217 | + case 'text/x-literate-haskell': |
|
218 | + case 'text/x-lua': |
|
219 | + case 'text/x-makefile': |
|
220 | + case 'text/x-matlab': |
|
221 | + case 'text/x-python': |
|
222 | + case 'text/x-sql': |
|
223 | + case 'text/x-tcl': |
|
224 | + return 'text-x-script'; |
|
225 | + |
|
226 | + // HTML aliases. |
|
227 | + case 'application/xhtml+xml': |
|
228 | + return 'text-html'; |
|
229 | + |
|
230 | + // RTF files. |
|
231 | + case 'application/rtf': |
|
232 | + return 'text-rtf'; |
|
233 | + |
|
234 | + // Google earth files. |
|
235 | + case 'application/vnd.google-earth.kml+xml': |
|
236 | + case 'application/vnd.google-earth.kmz': |
|
237 | + return 'application-google-earth'; |
|
238 | + |
|
239 | + // Executable types. |
|
240 | + case 'application/x-macbinary': |
|
241 | + case 'application/x-ms-dos-executable': |
|
242 | + case 'application/x-pef-executable': |
|
243 | + return 'application-x-executable'; |
|
244 | + |
|
245 | + default: |
|
246 | + return FALSE; |
|
247 | 247 | } |
248 | 248 | } |
@@ -313,10 +313,10 @@ |
||
313 | 313 | */ |
314 | 314 | function filefield_widget_settings($op, $widget) { |
315 | 315 | switch ($op) { |
316 | - case 'form': |
|
317 | - return filefield_widget_settings_form($widget); |
|
318 | - case 'save': |
|
319 | - return filefield_widget_settings_save($widget); |
|
316 | + case 'form': |
|
317 | + return filefield_widget_settings_form($widget); |
|
318 | + case 'save': |
|
319 | + return filefield_widget_settings_save($widget); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | $allowed_options = variable_get('forum_access_allowed_node_edit_options', array('status', 'sticky', 'subscriptions_notify')); |
80 | 80 | foreach (element_children($form) as $key) { |
81 | 81 | switch ($key) { |
82 | - case 'options': |
|
83 | - foreach (element_children($form[$key]) as $key2) { |
|
84 | - if (array_search($key2, $allowed_options) === FALSE) { |
|
85 | - $form[$key][$key2]['#access'] = FALSE; |
|
86 | - } |
|
87 | - } |
|
88 | - break; |
|
89 | - case 'buttons': |
|
90 | - $tid = $form['taxonomy'][$vid]['#default_value'][0]; |
|
91 | - if (!forum_access_access($tid, 'update')) { |
|
92 | - $form['buttons']['submit']['#access'] = FALSE; |
|
93 | - $form['buttons']['preview']['#access'] = FALSE; |
|
94 | - } |
|
95 | - if (!forum_access_access($tid, 'delete')) { |
|
96 | - $form['buttons']['delete']['#access'] = FALSE; |
|
97 | - } |
|
98 | - break; |
|
99 | - default: |
|
100 | - if (array_search($key, $allowed_elements) === FALSE) { |
|
101 | - $form[$key]['#access'] = FALSE; |
|
82 | + case 'options': |
|
83 | + foreach (element_children($form[$key]) as $key2) { |
|
84 | + if (array_search($key2, $allowed_options) === FALSE) { |
|
85 | + $form[$key][$key2]['#access'] = FALSE; |
|
102 | 86 | } |
87 | + } |
|
88 | + break; |
|
89 | + case 'buttons': |
|
90 | + $tid = $form['taxonomy'][$vid]['#default_value'][0]; |
|
91 | + if (!forum_access_access($tid, 'update')) { |
|
92 | + $form['buttons']['submit']['#access'] = FALSE; |
|
93 | + $form['buttons']['preview']['#access'] = FALSE; |
|
94 | + } |
|
95 | + if (!forum_access_access($tid, 'delete')) { |
|
96 | + $form['buttons']['delete']['#access'] = FALSE; |
|
97 | + } |
|
98 | + break; |
|
99 | + default: |
|
100 | + if (array_search($key, $allowed_elements) === FALSE) { |
|
101 | + $form[$key]['#access'] = FALSE; |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | if ($tid = _forum_access_get_tid($node)) { |
121 | 121 | if (!forum_access_access($tid, 'comment_create') and !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
122 | 122 | switch (arg(0)) { |
123 | - case 'node': |
|
124 | - // Remove the in-line comment form, replace with text message to user. |
|
125 | - $form = NULL; |
|
126 | - $form['from'] = array( |
|
127 | - '#type' => 'item', |
|
128 | - '#value' => 'You do not have permission to post comments in this forum.',); |
|
129 | - break; |
|
130 | - case 'comment': |
|
131 | - if (arg(1)=='reply') { |
|
132 | - drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error'); |
|
133 | - drupal_goto("node/$node->nid"); |
|
134 | - exit; |
|
135 | - } |
|
136 | - break; |
|
123 | + case 'node': |
|
124 | + // Remove the in-line comment form, replace with text message to user. |
|
125 | + $form = NULL; |
|
126 | + $form['from'] = array( |
|
127 | + '#type' => 'item', |
|
128 | + '#value' => 'You do not have permission to post comments in this forum.',); |
|
129 | + break; |
|
130 | + case 'comment': |
|
131 | + if (arg(1)=='reply') { |
|
132 | + drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error'); |
|
133 | + drupal_goto("node/$node->nid"); |
|
134 | + exit; |
|
135 | + } |
|
136 | + break; |
|
137 | 137 | }//switch arg(0) |
138 | 138 | } |
139 | 139 | else { |
@@ -59,37 +59,37 @@ |
||
59 | 59 | // hook_user() functions. |
60 | 60 | |
61 | 61 | switch ($action) { |
62 | - case 'soft_obfuscate': |
|
63 | - obfuscate_account($boinc_user); |
|
64 | - _boincuser_delete_comment_reassign($account); |
|
65 | - _boincuser_delete_node_reassign($account); |
|
66 | - _boincuser_delete_privatemsg_delete($account); |
|
67 | - _boincuser_delete_friends($account); |
|
68 | - // delete the user's profile |
|
69 | - $profile = content_profile_load('profile', $account->uid); |
|
70 | - node_delete($profile->nid); |
|
71 | - // Drupal account - |
|
72 | - // * 'block'/disable the account |
|
73 | - // * set name, mail, pass, and init to deleted |
|
74 | - // * erase signature |
|
75 | - $myarray = array( |
|
76 | - 'status' => 0, |
|
77 | - 'name' => 'deleted_' . time() . '_' . random_string(), |
|
78 | - 'mail' => 'deleted_' . time() . '_' . random_string(), |
|
79 | - 'pass' => 'deleted_' . time() . '_' . random_string(), |
|
80 | - 'signature' => '', |
|
81 | - 'init' => 'deleted_' . time() . '_' . random_string(), |
|
82 | - ); |
|
83 | - user_save($account, $myarray); |
|
84 | - break; |
|
85 | - case 'hard_wipe': |
|
86 | - wipe_account($boinc_user); |
|
87 | - user_delete(array(), $account->uid); |
|
88 | - break; |
|
89 | - default: |
|
90 | - watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array( |
|
91 | - '%action' => $action, |
|
92 | - ), WATCHDOG_ERROR); |
|
62 | + case 'soft_obfuscate': |
|
63 | + obfuscate_account($boinc_user); |
|
64 | + _boincuser_delete_comment_reassign($account); |
|
65 | + _boincuser_delete_node_reassign($account); |
|
66 | + _boincuser_delete_privatemsg_delete($account); |
|
67 | + _boincuser_delete_friends($account); |
|
68 | + // delete the user's profile |
|
69 | + $profile = content_profile_load('profile', $account->uid); |
|
70 | + node_delete($profile->nid); |
|
71 | + // Drupal account - |
|
72 | + // * 'block'/disable the account |
|
73 | + // * set name, mail, pass, and init to deleted |
|
74 | + // * erase signature |
|
75 | + $myarray = array( |
|
76 | + 'status' => 0, |
|
77 | + 'name' => 'deleted_' . time() . '_' . random_string(), |
|
78 | + 'mail' => 'deleted_' . time() . '_' . random_string(), |
|
79 | + 'pass' => 'deleted_' . time() . '_' . random_string(), |
|
80 | + 'signature' => '', |
|
81 | + 'init' => 'deleted_' . time() . '_' . random_string(), |
|
82 | + ); |
|
83 | + user_save($account, $myarray); |
|
84 | + break; |
|
85 | + case 'hard_wipe': |
|
86 | + wipe_account($boinc_user); |
|
87 | + user_delete(array(), $account->uid); |
|
88 | + break; |
|
89 | + default: |
|
90 | + watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array( |
|
91 | + '%action' => $action, |
|
92 | + ), WATCHDOG_ERROR); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | 12 | |
13 | 13 | if (!function_exists('user_load_by_mail')) { |
14 | - /** |
|
14 | +/** |
|
15 | 15 | * user_load_by_mail will be broken out of user_load |
16 | 16 | */ |
17 | - function user_load_by_mail($mail) { |
|
18 | - return user_load(array('mail' => $mail)); |
|
19 | - } |
|
17 | +function user_load_by_mail($mail) { |
|
18 | +return user_load(array('mail' => $mail)); |
|
19 | +} |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * Get an image object from a given file and cck field |
29 | 29 | */ |
30 | 30 | function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) { |
31 | - $field = content_fields($field_name, $content_type); |
|
32 | - $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
33 | - if ($ignore_resolution) { |
|
34 | - unset($validators['filefield_validate_image_resolution']); |
|
35 | - } |
|
36 | - $target_path = filefield_widget_file_path($field); |
|
37 | - // Create the image object |
|
38 | - return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
31 | +$field = content_fields($field_name, $content_type); |
|
32 | +$validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
33 | +if ($ignore_resolution) { |
|
34 | +unset($validators['filefield_validate_image_resolution']); |
|
35 | +} |
|
36 | +$target_path = filefield_widget_file_path($field); |
|
37 | +// Create the image object |
|
38 | +return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,73 +47,73 @@ discard block |
||
47 | 47 | * |
48 | 48 | */ |
49 | 49 | function boincuser_check_credit_requirements() { |
50 | - global $user; |
|
51 | - if (!$user->uid) { |
|
52 | - return FALSE; |
|
53 | - } |
|
54 | - $account = user_load($user->uid); |
|
55 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
56 | - $community_role = array_search('community member', user_roles(true)); |
|
57 | - $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
50 | +global $user; |
|
51 | +if (!$user->uid) { |
|
52 | +return FALSE; |
|
53 | +} |
|
54 | +$account = user_load($user->uid); |
|
55 | +$min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
56 | +$community_role = array_search('community member', user_roles(true)); |
|
57 | +$unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
58 | 58 | |
59 | - // Set user roles based on current penalty status... |
|
60 | - if ($account->boincuser_penalty_expiration > time()) { |
|
61 | - drupal_set_message(bts( |
|
62 | - 'You are banned from community participation until @date', |
|
63 | - array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
64 | - ), 'warning', FALSE); |
|
65 | - if (isset($account->roles[$community_role])) { |
|
66 | - // Remove from the community role, if not already |
|
67 | - unset($account->roles[$community_role]); |
|
68 | - } |
|
69 | - if (isset($account->roles[$unrestricted_role])) { |
|
70 | - // Likewise, revoke extra privileges |
|
71 | - unset($account->roles[$unrestricted_role]); |
|
72 | - } |
|
59 | +// Set user roles based on current penalty status... |
|
60 | +if ($account->boincuser_penalty_expiration > time()) { |
|
61 | +drupal_set_message(bts( |
|
62 | + 'You are banned from community participation until @date', |
|
63 | + array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
64 | +), 'warning', FALSE); |
|
65 | +if (isset($account->roles[$community_role])) { |
|
66 | + // Remove from the community role, if not already |
|
67 | + unset($account->roles[$community_role]); |
|
68 | +} |
|
69 | +if (isset($account->roles[$unrestricted_role])) { |
|
70 | + // Likewise, revoke extra privileges |
|
71 | + unset($account->roles[$unrestricted_role]); |
|
72 | +} |
|
73 | +user_save($account, array('roles' => $account->roles)); |
|
74 | +} |
|
75 | +else { |
|
76 | +if (!isset($account->roles[$community_role])) { |
|
77 | + // The user should be a 'community member' role. If the user was |
|
78 | + // previously banned, this will restore that role. |
|
79 | + $account->roles[$community_role] = 'community member'; |
|
80 | + user_save($account, array('roles' => $account->roles)); |
|
81 | +} |
|
82 | + |
|
83 | +// ... and total credit. |
|
84 | +if ($account->boincuser_total_credit >= $min_credit_to_post) { |
|
85 | + if (!isset($account->roles[$unrestricted_role])) { |
|
86 | + // This user is now above the credit threshold and is allowed full |
|
87 | + // privileges |
|
88 | + $account->roles[$unrestricted_role] = 'verified contributor'; |
|
73 | 89 | user_save($account, array('roles' => $account->roles)); |
74 | 90 | } |
75 | - else { |
|
76 | - if (!isset($account->roles[$community_role])) { |
|
77 | - // The user should be a 'community member' role. If the user was |
|
78 | - // previously banned, this will restore that role. |
|
79 | - $account->roles[$community_role] = 'community member'; |
|
80 | - user_save($account, array('roles' => $account->roles)); |
|
81 | - } |
|
82 | - |
|
83 | - // ... and total credit. |
|
84 | - if ($account->boincuser_total_credit >= $min_credit_to_post) { |
|
85 | - if (!isset($account->roles[$unrestricted_role])) { |
|
86 | - // This user is now above the credit threshold and is allowed full |
|
87 | - // privileges |
|
88 | - $account->roles[$unrestricted_role] = 'verified contributor'; |
|
89 | - user_save($account, array('roles' => $account->roles)); |
|
90 | - } |
|
91 | - } |
|
92 | - else { |
|
93 | - drupal_set_message(bts( |
|
94 | - 'You must earn @count more credits to be able to post comments on this site.', |
|
95 | - array('@count' => $min_credit_to_post - $account->boincuser_total_credit) |
|
96 | - ), 'warning', FALSE); |
|
97 | - if (isset($account->roles[$unrestricted_role])) { |
|
98 | - // Either the threshold has been raised or credits have been revoked; |
|
99 | - // this user no longer qualifies for full privileges |
|
100 | - unset($account->roles[$unrestricted_role]); |
|
101 | - user_save($account, array('roles' => $account->roles)); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
91 | +} |
|
92 | +else { |
|
93 | + drupal_set_message(bts( |
|
94 | + 'You must earn @count more credits to be able to post comments on this site.', |
|
95 | + array('@count' => $min_credit_to_post - $account->boincuser_total_credit) |
|
96 | + ), 'warning', FALSE); |
|
97 | + if (isset($account->roles[$unrestricted_role])) { |
|
98 | + // Either the threshold has been raised or credits have been revoked; |
|
99 | + // this user no longer qualifies for full privileges |
|
100 | + unset($account->roles[$unrestricted_role]); |
|
101 | + user_save($account, array('roles' => $account->roles)); |
|
105 | 102 | } |
106 | 103 | } |
107 | 104 | |
105 | +} |
|
106 | +} |
|
107 | + |
|
108 | 108 | /** |
109 | 109 | * Get the cid of the first comment the user has not seen on a given node |
110 | 110 | */ |
111 | 111 | function boincuser_get_first_unread_comment_id($nid, $uid = NULL) { |
112 | - if (!$uid) { |
|
113 | - global $user; |
|
114 | - $uid = $user->uid; |
|
115 | - } |
|
116 | - return db_result(db_query(" |
|
112 | +if (!$uid) { |
|
113 | +global $user; |
|
114 | +$uid = $user->uid; |
|
115 | +} |
|
116 | +return db_result(db_query(" |
|
117 | 117 | SELECT c.cid |
118 | 118 | FROM {node} n |
119 | 119 | INNER JOIN {comments} c ON c.nid = n.nid |
@@ -123,41 +123,41 @@ discard block |
||
123 | 123 | AND c.timestamp > h.timestamp |
124 | 124 | ORDER BY c.timestamp ASC |
125 | 125 | LIMIT 1", |
126 | - $uid, $nid |
|
127 | - )); |
|
126 | +$uid, $nid |
|
127 | +)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * Choose and set the user of the day |
132 | 132 | */ |
133 | 133 | function boincuser_select_user_of_the_day() { |
134 | - // First get a list of users with recent credit |
|
135 | - db_set_active('boinc_rw'); |
|
136 | - $users_with_credit = db_query(" |
|
134 | +// First get a list of users with recent credit |
|
135 | +db_set_active('boinc_rw'); |
|
136 | +$users_with_credit = db_query(" |
|
137 | 137 | SELECT |
138 | 138 | id |
139 | 139 | FROM {user} u |
140 | 140 | JOIN {profile} p ON p.userid = u.id |
141 | 141 | WHERE expavg_credit > 1 |
142 | 142 | ORDER BY uotd_time ASC, RAND()" |
143 | - ); |
|
144 | - db_set_active('default'); |
|
145 | - $active_users = array(); |
|
146 | - while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
147 | - $active_users[] = $user_with_credit->id; |
|
148 | - } |
|
149 | - $active_users = implode(',', $active_users); |
|
150 | - // Limit to users who have never been user of the day, if there are any |
|
151 | - $never_been_picked = db_result(db_query(" |
|
143 | +); |
|
144 | +db_set_active('default'); |
|
145 | +$active_users = array(); |
|
146 | +while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
147 | +$active_users[] = $user_with_credit->id; |
|
148 | +} |
|
149 | +$active_users = implode(',', $active_users); |
|
150 | +// Limit to users who have never been user of the day, if there are any |
|
151 | +$never_been_picked = db_result(db_query(" |
|
152 | 152 | SELECT COUNT(*) |
153 | 153 | FROM {boincuser} bu |
154 | 154 | WHERE bu.uotd_time = 0 |
155 | 155 | " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') |
156 | - )); |
|
157 | - $new_uotd_uid = 0; |
|
158 | - while (!$new_uotd_uid) { |
|
159 | - // Select a user of the day randomly from the pool |
|
160 | - $new_uotd_uid = db_result(db_query(" |
|
156 | +)); |
|
157 | +$new_uotd_uid = 0; |
|
158 | +while (!$new_uotd_uid) { |
|
159 | +// Select a user of the day randomly from the pool |
|
160 | + $new_uotd_uid = db_result(db_query(" |
|
161 | 161 | SELECT |
162 | 162 | n.uid |
163 | 163 | FROM {node} n |
@@ -169,33 +169,33 @@ discard block |
||
169 | 169 | " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') . " |
170 | 170 | ORDER BY RAND() |
171 | 171 | LIMIT 1" |
172 | - )); |
|
173 | - if (!$new_uotd_uid) { |
|
174 | - // Can't find a user with a profile; remove constraints on the pool |
|
175 | - if ($never_been_picked) { |
|
176 | - // Allow users who have been previously selected |
|
177 | - $never_been_picked = FALSE; |
|
178 | - } |
|
179 | - elseif ($active_users) { |
|
180 | - // Allow users who are not even active (getting desperate) |
|
181 | - $active_users = FALSE; |
|
182 | - } |
|
183 | - else { |
|
184 | - // Process failed... |
|
185 | - return FALSE; |
|
186 | - } |
|
187 | - } |
|
172 | +)); |
|
173 | +if (!$new_uotd_uid) { |
|
174 | + // Can't find a user with a profile; remove constraints on the pool |
|
175 | + if ($never_been_picked) { |
|
176 | + // Allow users who have been previously selected |
|
177 | + $never_been_picked = FALSE; |
|
178 | + } |
|
179 | + elseif ($active_users) { |
|
180 | + // Allow users who are not even active (getting desperate) |
|
181 | + $active_users = FALSE; |
|
182 | + } |
|
183 | + else { |
|
184 | + // Process failed... |
|
185 | + return FALSE; |
|
188 | 186 | } |
189 | - $uotd = user_load($new_uotd_uid); |
|
190 | - if ($uotd->uid) { |
|
191 | - db_query(" |
|
187 | +} |
|
188 | +} |
|
189 | +$uotd = user_load($new_uotd_uid); |
|
190 | +if ($uotd->uid) { |
|
191 | +db_query(" |
|
192 | 192 | UPDATE {boincuser} |
193 | 193 | SET uotd_time = '%d' |
194 | 194 | WHERE uid = '%d'", |
195 | - time(), $uotd->uid |
|
196 | - ); |
|
197 | - } |
|
198 | - return $uotd; |
|
195 | + time(), $uotd->uid |
|
196 | +); |
|
197 | +} |
|
198 | +return $uotd; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -213,71 +213,71 @@ discard block |
||
213 | 213 | * new and prev email. |
214 | 214 | */ |
215 | 215 | function _boincuser_send_emailchange($account, $new_email=NULL, $prev_email=NULL, $adminuser=FALSE) { |
216 | - require_boinc('token'); |
|
217 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
216 | +require_boinc('token'); |
|
217 | +module_load_include('inc', 'rules', 'modules/system.rules'); |
|
218 | 218 | |
219 | - global $base_url; |
|
220 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
221 | - |
|
222 | - if (is_null($new_email)) { |
|
223 | - $new_email = $account->mail; |
|
224 | - } |
|
225 | - if (is_null($prev_email)) { |
|
226 | - $prev_email = $account->boincuser_previous_email_addr; |
|
227 | - } |
|
219 | +global $base_url; |
|
220 | +$site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
228 | 221 | |
229 | - // @todo - set constant in drupal, or use BOINC contsants |
|
230 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
231 | - $changedate = date('F j, Y \a\t G:i T', time()); |
|
232 | - $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
233 | - $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
234 | - if ($adminuser) { |
|
235 | - $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
|
236 | - . "on {$changedate}. If you need to reverse this change, please look for " |
|
237 | - . "an email send to the email address: {$prev_email}.\n"; |
|
238 | - } |
|
239 | - else { |
|
240 | - $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
|
241 | - . "on {$changedate}. You will not be able to change your email address " |
|
242 | - . "until {$newdate}. If you need to reverse this change, please look for " |
|
243 | - . "an email send to the email address: {$prev_email}.\n"; |
|
244 | - } |
|
222 | +if (is_null($new_email)) { |
|
223 | +$new_email = $account->mail; |
|
224 | +} |
|
225 | +if (is_null($prev_email)) { |
|
226 | +$prev_email = $account->boincuser_previous_email_addr; |
|
227 | +} |
|
245 | 228 | |
246 | - // Send email #1 to current address |
|
247 | - $mysubject = "Notification of email change at {$site_name}"; |
|
248 | - $mymessage = '' |
|
249 | - . "{$account->boincuser_name},\n" |
|
250 | - . "\n" |
|
251 | - . $graf1 |
|
252 | - . "\n" |
|
253 | - . "Thanks, \n" |
|
254 | - . "{$site_name} support team\n"; |
|
255 | - |
|
256 | - $settings = array( |
|
257 | - 'from' => '', |
|
258 | - 'to' => $new_email, |
|
259 | - 'subject' => $mysubject, |
|
260 | - 'message' => $mymessage, |
|
261 | - ); |
|
262 | - rules_action_mail_to_user($account, $settings); |
|
263 | - |
|
264 | - // Send email #2 to previous address. |
|
265 | - $mymessage = '' |
|
266 | - . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
267 | - . "\n" |
|
268 | - . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
269 | - . "\n" |
|
270 | - . "Thanks, \n" |
|
271 | - . "{$site_name} support team\n"; |
|
272 | - |
|
273 | - $settings = array( |
|
274 | - 'from' => '', |
|
275 | - 'to' => $prev_email, |
|
276 | - 'subject' => $mysubject, |
|
277 | - 'message' => $mymessage, |
|
278 | - ); |
|
229 | +// @todo - set constant in drupal, or use BOINC contsants |
|
230 | +$duration = TOKEN_DURATION_ONE_WEEK; |
|
231 | +$changedate = date('F j, Y \a\t G:i T', time()); |
|
232 | +$newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
233 | +$token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
234 | +if ($adminuser) { |
|
235 | +$graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
|
236 | + . "on {$changedate}. If you need to reverse this change, please look for " |
|
237 | + . "an email send to the email address: {$prev_email}.\n"; |
|
238 | +} |
|
239 | +else { |
|
240 | +$graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
|
241 | + . "on {$changedate}. You will not be able to change your email address " |
|
242 | + . "until {$newdate}. If you need to reverse this change, please look for " |
|
243 | + . "an email send to the email address: {$prev_email}.\n"; |
|
244 | +} |
|
279 | 245 | |
280 | - rules_action_mail($settings); |
|
246 | +// Send email #1 to current address |
|
247 | +$mysubject = "Notification of email change at {$site_name}"; |
|
248 | +$mymessage = '' |
|
249 | + . "{$account->boincuser_name},\n" |
|
250 | + . "\n" |
|
251 | + . $graf1 |
|
252 | + . "\n" |
|
253 | + . "Thanks, \n" |
|
254 | + . "{$site_name} support team\n"; |
|
255 | + |
|
256 | +$settings = array( |
|
257 | +'from' => '', |
|
258 | +'to' => $new_email, |
|
259 | +'subject' => $mysubject, |
|
260 | +'message' => $mymessage, |
|
261 | +); |
|
262 | +rules_action_mail_to_user($account, $settings); |
|
263 | + |
|
264 | +// Send email #2 to previous address. |
|
265 | +$mymessage = '' |
|
266 | + . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
267 | + . "\n" |
|
268 | + . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
269 | + . "\n" |
|
270 | + . "Thanks, \n" |
|
271 | + . "{$site_name} support team\n"; |
|
272 | + |
|
273 | +$settings = array( |
|
274 | +'from' => '', |
|
275 | +'to' => $prev_email, |
|
276 | +'subject' => $mysubject, |
|
277 | +'message' => $mymessage, |
|
278 | +); |
|
279 | + |
|
280 | +rules_action_mail($settings); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -287,32 +287,32 @@ discard block |
||
287 | 287 | * |
288 | 288 | */ |
289 | 289 | function create_proper_drupalname($requested_name) { |
290 | - if (!$requested_name) { |
|
291 | - // If the name is empty, set it |
|
292 | - $requested_name = 'anonymous'; |
|
293 | - } |
|
294 | - $same_name_tally = 1; |
|
295 | - |
|
296 | - // Remove extra spaces |
|
297 | - $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
298 | - // Remove any non-valid characters |
|
299 | - $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
300 | - // Truncate name |
|
301 | - $name_length = strlen($cleaned_name); |
|
302 | - if ($name_length > 56) { |
|
303 | - // Name is limited to 60 characters, but we want to leave space to add a |
|
304 | - // tally if needed (for users with duplicate names); Limit to 56 chars and |
|
305 | - // replace the middle of the string with "..." if too long |
|
306 | - $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3); |
|
307 | - } |
|
290 | +if (!$requested_name) { |
|
291 | +// If the name is empty, set it |
|
292 | +$requested_name = 'anonymous'; |
|
293 | +} |
|
294 | +$same_name_tally = 1; |
|
295 | + |
|
296 | +// Remove extra spaces |
|
297 | +$name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
298 | +// Remove any non-valid characters |
|
299 | +$cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
300 | +// Truncate name |
|
301 | +$name_length = strlen($cleaned_name); |
|
302 | +if ($name_length > 56) { |
|
303 | +// Name is limited to 60 characters, but we want to leave space to add a |
|
304 | +// tally if needed (for users with duplicate names); Limit to 56 chars and |
|
305 | +// replace the middle of the string with "..." if too long |
|
306 | +$cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3); |
|
307 | +} |
|
308 | 308 | |
309 | - // Determine if there are duplicate names, if so append a number to end. |
|
310 | - $unique_name = $cleaned_name; |
|
311 | - while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
312 | - $same_name_tally++; |
|
313 | - $unique_name = "{$cleaned_name}_{$same_name_tally}"; |
|
314 | - } |
|
315 | - return $unique_name; |
|
309 | +// Determine if there are duplicate names, if so append a number to end. |
|
310 | +$unique_name = $cleaned_name; |
|
311 | +while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
312 | +$same_name_tally++; |
|
313 | +$unique_name = "{$cleaned_name}_{$same_name_tally}"; |
|
314 | +} |
|
315 | +return $unique_name; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -326,17 +326,17 @@ discard block |
||
326 | 326 | * |
327 | 327 | */ |
328 | 328 | function boincuser_check_termsofuse($user) { |
329 | - // @todo - the condition for the terms of use needs to be saved in the |
|
330 | - // project's user table, which does not exist, but may be added |
|
331 | - // upstream. If/when that occurs, check it here. |
|
332 | - $qres = db_query('SELECT bu.privacy_consent_dt FROM {boincuser} AS bu WHERE uid=%d', $user->uid); |
|
333 | - $consent_dt = db_result($qres); |
|
334 | - // Check datetime of consent, it should not be zero. |
|
335 | - if ($consent_dt > 1 ) { |
|
336 | - return true; |
|
337 | - } |
|
329 | +// @todo - the condition for the terms of use needs to be saved in the |
|
330 | +// project's user table, which does not exist, but may be added |
|
331 | +// upstream. If/when that occurs, check it here. |
|
332 | +$qres = db_query('SELECT bu.privacy_consent_dt FROM {boincuser} AS bu WHERE uid=%d', $user->uid); |
|
333 | +$consent_dt = db_result($qres); |
|
334 | +// Check datetime of consent, it should not be zero. |
|
335 | +if ($consent_dt > 1 ) { |
|
336 | +return true; |
|
337 | +} |
|
338 | 338 | |
339 | - return false; |
|
339 | +return false; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * |
348 | 348 | */ |
349 | 349 | function boincuser_consentto_termsofuse($user) { |
350 | - $uid = $user->uid; |
|
350 | +$uid = $user->uid; |
|
351 | 351 | |
352 | - // @todo - Modify BOINC project database to record consent. |
|
353 | - $sql = 'UPDATE {boincuser} set privacy_consent_dt = %d WHERE uid=%d'; |
|
354 | - $qrc = db_query($sql, time(), $uid); |
|
355 | - return $qrc; |
|
352 | +// @todo - Modify BOINC project database to record consent. |
|
353 | +$sql = 'UPDATE {boincuser} set privacy_consent_dt = %d WHERE uid=%d'; |
|
354 | +$qrc = db_query($sql, time(), $uid); |
|
355 | +return $qrc; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -361,16 +361,16 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function _boincuser_ignore_paths($path, $paths_to_ignore) { |
363 | 363 | |
364 | - foreach ($paths_to_ignore as $pi) { |
|
365 | - // @todo Currently this function uses {} as PHP regexp |
|
366 | - // delimiters. Curly brace is not really allowed un URLs, but a |
|
367 | - // more robust function would first check for these curly braces |
|
368 | - // in the path_to_ignore patterms, just in case. |
|
369 | - if (preg_match('{' . $pi . '}', $path)) { |
|
370 | - return TRUE; |
|
371 | - } |
|
372 | - } |
|
373 | - return FALSE; |
|
364 | +foreach ($paths_to_ignore as $pi) { |
|
365 | +// @todo Currently this function uses {} as PHP regexp |
|
366 | +// delimiters. Curly brace is not really allowed un URLs, but a |
|
367 | +// more robust function would first check for these curly braces |
|
368 | +// in the path_to_ignore patterms, just in case. |
|
369 | +if (preg_match('{' . $pi . '}', $path)) { |
|
370 | + return TRUE; |
|
371 | +} |
|
372 | +} |
|
373 | +return FALSE; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -378,20 +378,20 @@ discard block |
||
378 | 378 | * Drupal's recover email path. |
379 | 379 | */ |
380 | 380 | function _boincuser_redirect_recover_email() { |
381 | - $params = array( |
|
382 | - 'boincid' => isset($_GET['id']) ? $_GET['id'] : '', |
|
383 | - 'token' => isset($_GET['token']) ? $_GET['token'] : '' |
|
384 | - ); |
|
385 | - |
|
386 | - // If boincid or token is not present, then go to the home page. |
|
387 | - if (empty($params['boincid']) or empty($params['token'])) { |
|
388 | - $redirect = ''; |
|
389 | - } |
|
390 | - else { |
|
391 | - $uid = boincuser_lookup_uid($params['boincid']); |
|
392 | - $redirect = "/user/${uid}/recoveremail/${params['token']}"; |
|
393 | - } |
|
394 | - drupal_goto($redirect); |
|
381 | +$params = array( |
|
382 | +'boincid' => isset($_GET['id']) ? $_GET['id'] : '', |
|
383 | +'token' => isset($_GET['token']) ? $_GET['token'] : '' |
|
384 | +); |
|
385 | + |
|
386 | +// If boincid or token is not present, then go to the home page. |
|
387 | +if (empty($params['boincid']) or empty($params['token'])) { |
|
388 | +$redirect = ''; |
|
389 | +} |
|
390 | +else { |
|
391 | +$uid = boincuser_lookup_uid($params['boincid']); |
|
392 | +$redirect = "/user/${uid}/recoveremail/${params['token']}"; |
|
393 | +} |
|
394 | +drupal_goto($redirect); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -402,17 +402,17 @@ discard block |
||
402 | 402 | * Require BOINC library |
403 | 403 | */ |
404 | 404 | function require_boinc($libraries) { |
405 | - if ($include_dir = boinc_get_path('html_inc')) { |
|
406 | - $working_dir = getcwd(); |
|
407 | - chdir($include_dir); |
|
408 | - if (!is_array($libraries)) { |
|
409 | - $libraries = array($libraries); |
|
410 | - } |
|
411 | - foreach ($libraries as $library) { |
|
412 | - require_once("{$library}.inc"); |
|
413 | - } |
|
414 | - chdir($working_dir); |
|
415 | - } |
|
405 | +if ($include_dir = boinc_get_path('html_inc')) { |
|
406 | +$working_dir = getcwd(); |
|
407 | +chdir($include_dir); |
|
408 | +if (!is_array($libraries)) { |
|
409 | + $libraries = array($libraries); |
|
410 | +} |
|
411 | +foreach ($libraries as $library) { |
|
412 | + require_once("{$library}.inc"); |
|
413 | +} |
|
414 | +chdir($working_dir); |
|
415 | +} |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -420,92 +420,92 @@ discard block |
||
420 | 420 | * The path from the BOINC html root must be included (e.g. user/file.php) |
421 | 421 | */ |
422 | 422 | function include_boinc($file) { |
423 | - if ($include_dir = boinc_get_path()) { |
|
424 | - $include_dir .= '/html'; |
|
425 | - $workingDir = getcwd(); |
|
426 | - $path = dirname($file); |
|
427 | - $file = basename($file); |
|
428 | - chdir("{$include_dir}/{$path}"); |
|
429 | - include($file); |
|
430 | - chdir($workingDir); |
|
431 | - } |
|
423 | +if ($include_dir = boinc_get_path()) { |
|
424 | +$include_dir .= '/html'; |
|
425 | +$workingDir = getcwd(); |
|
426 | +$path = dirname($file); |
|
427 | +$file = basename($file); |
|
428 | +chdir("{$include_dir}/{$path}"); |
|
429 | +include($file); |
|
430 | +chdir($workingDir); |
|
431 | +} |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
435 | 435 | * Get the BOINC include path |
436 | 436 | */ |
437 | 437 | function boinc_get_path($type = 'root') { |
438 | - $dir = "boinc_{$type}_dir"; |
|
439 | - if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
440 | - return $include_dir; |
|
441 | - } |
|
442 | - else { |
|
443 | - // Don't show errors on blacklisted pages |
|
444 | - $page_blacklist = array( |
|
445 | - 'admin/boinc/environment' |
|
446 | - ); |
|
447 | - if (!in_array($_GET['q'], $page_blacklist)) { |
|
448 | - watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
438 | +$dir = "boinc_{$type}_dir"; |
|
439 | +if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
440 | +return $include_dir; |
|
441 | +} |
|
442 | +else { |
|
443 | +// Don't show errors on blacklisted pages |
|
444 | +$page_blacklist = array( |
|
445 | + 'admin/boinc/environment' |
|
446 | +); |
|
447 | +if (!in_array($_GET['q'], $page_blacklist)) { |
|
448 | + watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
449 | 449 | !configure_it', array('!configure_it' => l(t('configure it now'), |
450 | - 'admin/boinc/environment')), WATCHDOG_WARNING); |
|
451 | - if (user_access('administer site configuration')) { |
|
452 | - drupal_set_message(t('The BOINC environment is not configured. Please |
|
450 | + 'admin/boinc/environment')), WATCHDOG_WARNING); |
|
451 | + if (user_access('administer site configuration')) { |
|
452 | + drupal_set_message(t('The BOINC environment is not configured. Please |
|
453 | 453 | !configure_it', array('!configure_it' => l(t('configure it now'), |
454 | - 'admin/boinc/environment'))), 'warning', FALSE); |
|
455 | - } |
|
456 | - else { |
|
457 | - drupal_set_message(t('There is a problem with the site. Please contact |
|
454 | + 'admin/boinc/environment'))), 'warning', FALSE); |
|
455 | + } |
|
456 | + else { |
|
457 | + drupal_set_message(t('There is a problem with the site. Please contact |
|
458 | 458 | the system administrator.'), 'error', FALSE); |
459 | - } |
|
460 | - // Redirect home to display the error message and avoid fatal errors |
|
461 | - // (unless on a blacklisted page) |
|
462 | - $redirect_blacklist = array( |
|
463 | - 'admin/settings/performance', |
|
464 | - 'admin/boinc/environment', |
|
465 | - 'home', |
|
466 | - '' |
|
467 | - ); |
|
468 | - if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
469 | - drupal_goto(''); |
|
470 | - } |
|
471 | - } |
|
472 | - else { |
|
473 | - // Clear the messages on the environment config page |
|
474 | - drupal_get_messages(); |
|
475 | - } |
|
476 | 459 | } |
477 | - return FALSE; |
|
460 | + // Redirect home to display the error message and avoid fatal errors |
|
461 | + // (unless on a blacklisted page) |
|
462 | + $redirect_blacklist = array( |
|
463 | + 'admin/settings/performance', |
|
464 | + 'admin/boinc/environment', |
|
465 | + 'home', |
|
466 | + '' |
|
467 | + ); |
|
468 | + if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
469 | + drupal_goto(''); |
|
470 | + } |
|
471 | +} |
|
472 | +else { |
|
473 | + // Clear the messages on the environment config page |
|
474 | + drupal_get_messages(); |
|
475 | +} |
|
476 | +} |
|
477 | +return FALSE; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Get the configured scheduler tags |
482 | 482 | */ |
483 | 483 | function boinc_get_scheduler_tags() { |
484 | - // Don't generate messages for blacklisted pages |
|
485 | - $page_blacklist = array( |
|
486 | - 'admin/boinc/environment', |
|
487 | - 'admin/boinc/scheduler' |
|
488 | - ); |
|
489 | - if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
490 | - return explode("\r\n", $url_config); |
|
491 | - } |
|
492 | - elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
493 | - watchdog('boincuser', 'The BOINC scheduling server settings are not yet |
|
484 | +// Don't generate messages for blacklisted pages |
|
485 | +$page_blacklist = array( |
|
486 | +'admin/boinc/environment', |
|
487 | +'admin/boinc/scheduler' |
|
488 | +); |
|
489 | +if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
490 | +return explode("\r\n", $url_config); |
|
491 | +} |
|
492 | +elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
493 | +watchdog('boincuser', 'The BOINC scheduling server settings are not yet |
|
494 | 494 | configured. Please !verify for the settings to become effective.', |
495 | - array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
496 | - t('and') . '</strong> ' . t('save the configuration'), |
|
497 | - 'admin/boinc/scheduler', array('html' => TRUE)) |
|
498 | - ), WATCHDOG_WARNING); |
|
499 | - if (user_access('administer site configuration')) { |
|
500 | - drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
495 | + array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
496 | + t('and') . '</strong> ' . t('save the configuration'), |
|
497 | + 'admin/boinc/scheduler', array('html' => TRUE)) |
|
498 | + ), WATCHDOG_WARNING); |
|
499 | +if (user_access('administer site configuration')) { |
|
500 | + drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
501 | 501 | configured. Please !verify for the settings to become effective', |
502 | - array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
503 | - t('and') . '</strong> ' . t('save the configuration'), |
|
504 | - 'admin/boinc/scheduler', array('html' => TRUE)) |
|
505 | - )), 'warning', FALSE); |
|
506 | - } |
|
507 | - } |
|
508 | - return array(); |
|
502 | + array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
503 | + t('and') . '</strong> ' . t('save the configuration'), |
|
504 | + 'admin/boinc/scheduler', array('html' => TRUE)) |
|
505 | + )), 'warning', FALSE); |
|
506 | +} |
|
507 | +} |
|
508 | +return array(); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -517,41 +517,41 @@ discard block |
||
517 | 517 | * Determine if a BOINC ID matches the logged in user |
518 | 518 | */ |
519 | 519 | function is_current_boinc_user($boinc_id) { |
520 | - global $user; |
|
521 | - if (!$user->uid) { |
|
522 | - return FALSE; |
|
523 | - } |
|
524 | - // boincuser_id is not stored in the global user, so load a new instance |
|
525 | - $drupuser = user_load($user->uid); |
|
526 | - return ($boinc_id == $drupuser->boincuser_id); |
|
520 | +global $user; |
|
521 | +if (!$user->uid) { |
|
522 | +return FALSE; |
|
523 | +} |
|
524 | +// boincuser_id is not stored in the global user, so load a new instance |
|
525 | +$drupuser = user_load($user->uid); |
|
526 | +return ($boinc_id == $drupuser->boincuser_id); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
530 | 530 | * Convert a BOINC ID to a Drupal ID |
531 | 531 | */ |
532 | 532 | function boincuser_lookup_uid($boinc_id) { |
533 | - $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
534 | - return $drupal_id; |
|
533 | +$drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
534 | +return $drupal_id; |
|
535 | 535 | } |
536 | 536 | function get_drupal_id($boinc_id) { |
537 | - return boincuser_lookup_uid($boinc_id); |
|
537 | +return boincuser_lookup_uid($boinc_id); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
541 | 541 | * Get a BOINC user object |
542 | 542 | */ |
543 | 543 | function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) { |
544 | - if (!$user_id) { |
|
545 | - global $user; |
|
546 | - $user_id = $user->uid; |
|
547 | - $is_drupal_id = TRUE; |
|
548 | - } |
|
549 | - if ($is_drupal_id) { |
|
550 | - $account = user_load($user_id); |
|
551 | - $user_id = $account->boincuser_id; |
|
552 | - } |
|
553 | - require_boinc('boinc_db'); |
|
554 | - return BoincUser::lookup_id($user_id); |
|
544 | +if (!$user_id) { |
|
545 | +global $user; |
|
546 | +$user_id = $user->uid; |
|
547 | +$is_drupal_id = TRUE; |
|
548 | +} |
|
549 | +if ($is_drupal_id) { |
|
550 | +$account = user_load($user_id); |
|
551 | +$user_id = $account->boincuser_id; |
|
552 | +} |
|
553 | +require_boinc('boinc_db'); |
|
554 | +return BoincUser::lookup_id($user_id); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | * page, delete button. |
562 | 562 | */ |
563 | 563 | function _boincuser_node_profile_delete_submit($form, &$form_state) { |
564 | - $node = $form['#node']; |
|
565 | - $deleteurl = 'node/'. $node->nid .'/delete'; |
|
566 | - $afterq = 'destination=account'; |
|
567 | - drupal_goto($deleteurl, $afterq); |
|
564 | +$node = $form['#node']; |
|
565 | +$deleteurl = 'node/'. $node->nid .'/delete'; |
|
566 | +$afterq = 'destination=account'; |
|
567 | +drupal_goto($deleteurl, $afterq); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -575,8 +575,8 @@ discard block |
||
575 | 575 | * Wrapper for boinc_version() function |
576 | 576 | */ |
577 | 577 | function get_boinc_version($x) { |
578 | - require_boinc('host'); |
|
579 | - return function_exists('boinc_version') ? boinc_version($x) : 'err!'; |
|
578 | +require_boinc('host'); |
|
579 | +return function_exists('boinc_version') ? boinc_version($x) : 'err!'; |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | * Generate the friend block header |
589 | 589 | */ |
590 | 590 | function boincuser_views_friends_block_header($context = null) { |
591 | - // Get the friend count for the user being viewed |
|
592 | - $view = views_get_current_view(); |
|
593 | - $account_id = $view->args[0]; |
|
594 | - $friend_count = flag_friend_get_friend_count($account_id); |
|
595 | - return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
596 | - array('@count' => $friend_count)) . '</h2>'; |
|
591 | +// Get the friend count for the user being viewed |
|
592 | +$view = views_get_current_view(); |
|
593 | +$account_id = $view->args[0]; |
|
594 | +$friend_count = flag_friend_get_friend_count($account_id); |
|
595 | +return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
596 | +array('@count' => $friend_count)) . '</h2>'; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | * database. |
602 | 602 | */ |
603 | 603 | function _boincuser_user_name_autocomplete($string) { |
604 | - $matches = array(); |
|
605 | - db_set_active('boinc_ro'); |
|
606 | - $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
607 | - db_set_active('default'); |
|
608 | - while ($user = db_fetch_object($result)) { |
|
609 | - $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
610 | - } |
|
604 | +$matches = array(); |
|
605 | +db_set_active('boinc_ro'); |
|
606 | +$result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
607 | +db_set_active('default'); |
|
608 | +while ($user = db_fetch_object($result)) { |
|
609 | + $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
610 | +} |
|
611 | 611 | |
612 | - drupal_json((object)$matches); |
|
612 | +drupal_json((object)$matches); |
|
613 | 613 | } |
@@ -94,64 +94,64 @@ discard block |
||
94 | 94 | global $user; |
95 | 95 | |
96 | 96 | switch($form_id) { |
97 | - case 'user_profile_form': |
|
98 | - if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
|
99 | - $form['delete'] = array( |
|
100 | - '#type' => 'submit', |
|
101 | - '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
102 | - '#weight' => 1009, |
|
103 | - '#submit' => array('user_edit_delete_submit'), |
|
104 | - '#prefix' => '<li class="tab">', |
|
105 | - '#suffix' => '</li>', |
|
106 | - ); |
|
107 | - } |
|
108 | - else if ( user_access('administer users') ) { |
|
109 | - $form['delete'] = array( |
|
110 | - '#type' => 'submit', |
|
111 | - '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
112 | - '#weight' => 1009, |
|
113 | - '#submit' => array('_boincuser_delete_goto_admindelete'), |
|
114 | - '#prefix' => '<li class="tab">', |
|
115 | - '#suffix' => '</li>', |
|
116 | - ); |
|
117 | - } |
|
118 | - else { |
|
119 | - unset($form['delete']); |
|
120 | - } |
|
121 | - break; |
|
122 | - case 'user_confirm_delete': |
|
123 | - |
|
124 | - $disable_delete = FALSE; |
|
125 | - // If email address was changed less than 7 days (7 * 86400 s) |
|
126 | - // ago, it cannot be changed again. |
|
127 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
128 | - if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) { |
|
129 | - drupal_set_message( |
|
130 | - bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
131 | - array( |
|
132 | - '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
133 | - ), NULL, 'boinc:account-credentials-change') |
|
134 | - , 'info'); |
|
135 | - $disable_delete = TRUE; |
|
136 | - } |
|
137 | - |
|
138 | - // Configure radio options |
|
139 | - $deleteoptions = array( |
|
140 | - 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'), |
|
141 | - 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'), |
|
97 | + case 'user_profile_form': |
|
98 | + if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
|
99 | + $form['delete'] = array( |
|
100 | + '#type' => 'submit', |
|
101 | + '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
102 | + '#weight' => 1009, |
|
103 | + '#submit' => array('user_edit_delete_submit'), |
|
104 | + '#prefix' => '<li class="tab">', |
|
105 | + '#suffix' => '</li>', |
|
142 | 106 | ); |
107 | + } |
|
108 | + else if ( user_access('administer users') ) { |
|
109 | + $form['delete'] = array( |
|
110 | + '#type' => 'submit', |
|
111 | + '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
112 | + '#weight' => 1009, |
|
113 | + '#submit' => array('_boincuser_delete_goto_admindelete'), |
|
114 | + '#prefix' => '<li class="tab">', |
|
115 | + '#suffix' => '</li>', |
|
116 | + ); |
|
117 | + } |
|
118 | + else { |
|
119 | + unset($form['delete']); |
|
120 | + } |
|
121 | + break; |
|
122 | + case 'user_confirm_delete': |
|
123 | + |
|
124 | + $disable_delete = FALSE; |
|
125 | + // If email address was changed less than 7 days (7 * 86400 s) |
|
126 | + // ago, it cannot be changed again. |
|
127 | + $duration = TOKEN_DURATION_ONE_WEEK; |
|
128 | + if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) { |
|
129 | + drupal_set_message( |
|
130 | + bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
131 | + array( |
|
132 | + '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
133 | + ), NULL, 'boinc:account-credentials-change') |
|
134 | + , 'info'); |
|
135 | + $disable_delete = TRUE; |
|
136 | + } |
|
137 | + |
|
138 | + // Configure radio options |
|
139 | + $deleteoptions = array( |
|
140 | + 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'), |
|
141 | + 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'), |
|
142 | + ); |
|
143 | 143 | |
144 | - $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
145 | - // unset the other option if dtype is set. i.e., if dtype is set |
|
146 | - // to soft delete, unset the hard delete option. |
|
147 | - switch ($dtypes) { |
|
148 | - case 'soft_obfuscate': |
|
149 | - unset($deleteoptions['boincuser_delete_delete']); |
|
150 | - break; |
|
151 | - case 'hard_wipe': |
|
152 | - unset($deleteoptions['boincuser_delete_softdelete']); |
|
153 | - break; |
|
154 | - } |
|
144 | + $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
145 | + // unset the other option if dtype is set. i.e., if dtype is set |
|
146 | + // to soft delete, unset the hard delete option. |
|
147 | + switch ($dtypes) { |
|
148 | + case 'soft_obfuscate': |
|
149 | + unset($deleteoptions['boincuser_delete_delete']); |
|
150 | + break; |
|
151 | + case 'hard_wipe': |
|
152 | + unset($deleteoptions['boincuser_delete_softdelete']); |
|
153 | + break; |
|
154 | + } |
|
155 | 155 | |
156 | 156 | $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
157 | 157 | drupal_set_title($question); |
@@ -301,56 +301,56 @@ discard block |
||
301 | 301 | // create token with 1 day/24 hour expiration |
302 | 302 | $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
303 | 303 | switch ($op) { |
304 | - case 'boincuser_delete_softdelete': |
|
305 | - $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
306 | - break; |
|
307 | - case 'boincuser_delete_delete': |
|
308 | - $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
304 | + case 'boincuser_delete_softdelete': |
|
305 | + $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
309 | 306 | break; |
310 | - } |
|
311 | - |
|
312 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
313 | - $mymessage = '' |
|
314 | - . "{$account->boincuser_name},\n" |
|
315 | - . "\n" |
|
316 | - . "We have received a request to DELETE your user account at " |
|
317 | - . "${site_name}. Below in this email is a one-time token you must " |
|
318 | - . "use. Either click on the link or copy-and-paste the URL into your " |
|
319 | - . "browser address bar. Then you will be required to enter your password " |
|
320 | - . "again to confirm your identity.\n" |
|
321 | - . "\n" |
|
322 | - . "${myurl}\n" |
|
323 | - . "\n" |
|
324 | - . "This one-time token will expire in 24 hours. Afterwards you must " |
|
325 | - . "re-request deletion of your account in order to generate a new token.\n" |
|
326 | - . "\n" |
|
327 | - . "If you did not initiate this request, please login to the " |
|
328 | - . "${site_name} Web site (${site_url}) and " |
|
329 | - . "then contact the administrators.\n" |
|
330 | - . "\n" |
|
331 | - . "Thanks, \n" |
|
332 | - . "\n" |
|
333 | - . "{$site_name} support team"; |
|
334 | - |
|
335 | - // Create array for sending email to user to notify account is being |
|
336 | - // disabled/deleted. Then send email. |
|
337 | - $settings = array( |
|
338 | - 'from' => '', |
|
339 | - 'subject' => $mysubject, |
|
340 | - 'message' => $mymessage, |
|
341 | - ); |
|
342 | - rules_action_mail_to_user($account, $settings); |
|
343 | - |
|
344 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
307 | +case 'boincuser_delete_delete': |
|
308 | + $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
309 | + break; |
|
310 | +} |
|
345 | 311 | |
346 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
347 | - // Redirect |
|
348 | - if (!empty($redirect)) { |
|
349 | - drupal_goto($redirect); |
|
350 | - } |
|
351 | - else { |
|
352 | - drupal_goto(); |
|
353 | - } |
|
312 | +$mysubject = "Instructions for account deletion at {$site_name}"; |
|
313 | +$mymessage = '' |
|
314 | +. "{$account->boincuser_name},\n" |
|
315 | +. "\n" |
|
316 | +. "We have received a request to DELETE your user account at " |
|
317 | +. "${site_name}. Below in this email is a one-time token you must " |
|
318 | +. "use. Either click on the link or copy-and-paste the URL into your " |
|
319 | +. "browser address bar. Then you will be required to enter your password " |
|
320 | +. "again to confirm your identity.\n" |
|
321 | +. "\n" |
|
322 | +. "${myurl}\n" |
|
323 | +. "\n" |
|
324 | +. "This one-time token will expire in 24 hours. Afterwards you must " |
|
325 | +. "re-request deletion of your account in order to generate a new token.\n" |
|
326 | +. "\n" |
|
327 | +. "If you did not initiate this request, please login to the " |
|
328 | +. "${site_name} Web site (${site_url}) and " |
|
329 | +. "then contact the administrators.\n" |
|
330 | +. "\n" |
|
331 | +. "Thanks, \n" |
|
332 | +. "\n" |
|
333 | +. "{$site_name} support team"; |
|
334 | + |
|
335 | +// Create array for sending email to user to notify account is being |
|
336 | +// disabled/deleted. Then send email. |
|
337 | +$settings = array( |
|
338 | +'from' => '', |
|
339 | +'subject' => $mysubject, |
|
340 | +'message' => $mymessage, |
|
341 | +); |
|
342 | +rules_action_mail_to_user($account, $settings); |
|
343 | + |
|
344 | +drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
345 | + |
|
346 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
347 | +// Redirect |
|
348 | +if (!empty($redirect)) { |
|
349 | +drupal_goto($redirect); |
|
350 | +} |
|
351 | +else { |
|
352 | +drupal_goto(); |
|
353 | +} |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -362,77 +362,77 @@ discard block |
||
362 | 362 | * The final confirmation form for the user to delete their account. |
363 | 363 | */ |
364 | 364 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
365 | - require_boinc('token'); |
|
366 | - |
|
367 | - global $user; |
|
368 | - $form = array(); |
|
369 | - |
|
370 | - // check BOINC user exists |
|
371 | - $account = user_load(array('uid' => $user->uid)); |
|
372 | - $uid = $user->uid; |
|
373 | - $boincid = $account->boincuser_id; |
|
374 | - // check $token is valid |
|
375 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
376 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
377 | - array( |
|
378 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
379 | - ), |
|
380 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
381 | - drupal_goto(); |
|
382 | - } |
|
383 | - |
|
384 | - // Attach account to this form. |
|
385 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
386 | - |
|
387 | - // This form is for hard/wipe delete |
|
388 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
389 | - |
|
390 | - // Instructions |
|
391 | - $form['main']['instructions1'] = array( |
|
392 | - '#value' => '<p>'. |
|
393 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
394 | - '</p>', |
|
395 | - ); |
|
396 | - |
|
397 | - $form['main']['instructions2'] = array( |
|
398 | - '#value' => '<p>'. |
|
399 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
400 | - '</p>', |
|
401 | - ); |
|
402 | - |
|
403 | - // Password field |
|
404 | - $form['main']['current_pass'] = array( |
|
405 | - '#type' => 'password', |
|
406 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
407 | - '#size' => 17, |
|
408 | - '#attributes' => array( |
|
409 | - 'autocomplete' => 'off', |
|
410 | - ), |
|
411 | - '#weight' => 25, |
|
412 | - ); |
|
413 | - |
|
414 | - // Form control |
|
415 | - $form['form control tabs prefix'] = array( |
|
416 | - '#value' => '<ul class="form-control tab-list">', |
|
417 | - '#weight' => 1001, |
|
418 | - ); |
|
419 | - $form['submit'] = array( |
|
420 | - '#prefix' => '<li class="first tab">', |
|
421 | - '#type' => 'submit', |
|
422 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
423 | - '#suffix' => '</li>', |
|
424 | - '#weight' => 1002, |
|
425 | - ); |
|
426 | - $form['form control tabs'] = array( |
|
427 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
428 | - '#weight' => 1003, |
|
429 | - ); |
|
430 | - $form['form control tabs suffix'] = array( |
|
431 | - '#value' => '</ul>', |
|
432 | - '#weight' => 1004, |
|
433 | - ); |
|
365 | +require_boinc('token'); |
|
366 | + |
|
367 | +global $user; |
|
368 | +$form = array(); |
|
369 | + |
|
370 | +// check BOINC user exists |
|
371 | +$account = user_load(array('uid' => $user->uid)); |
|
372 | +$uid = $user->uid; |
|
373 | +$boincid = $account->boincuser_id; |
|
374 | +// check $token is valid |
|
375 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
376 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
377 | +array( |
|
378 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
379 | +), |
|
380 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
381 | +drupal_goto(); |
|
382 | +} |
|
434 | 383 | |
435 | - return $form; |
|
384 | +// Attach account to this form. |
|
385 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
386 | + |
|
387 | +// This form is for hard/wipe delete |
|
388 | +$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
389 | + |
|
390 | +// Instructions |
|
391 | +$form['main']['instructions1'] = array( |
|
392 | +'#value' => '<p>'. |
|
393 | +bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
394 | +'</p>', |
|
395 | +); |
|
396 | + |
|
397 | +$form['main']['instructions2'] = array( |
|
398 | +'#value' => '<p>'. |
|
399 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
400 | +'</p>', |
|
401 | +); |
|
402 | + |
|
403 | +// Password field |
|
404 | +$form['main']['current_pass'] = array( |
|
405 | +'#type' => 'password', |
|
406 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
407 | +'#size' => 17, |
|
408 | +'#attributes' => array( |
|
409 | + 'autocomplete' => 'off', |
|
410 | +), |
|
411 | +'#weight' => 25, |
|
412 | +); |
|
413 | + |
|
414 | +// Form control |
|
415 | +$form['form control tabs prefix'] = array( |
|
416 | +'#value' => '<ul class="form-control tab-list">', |
|
417 | +'#weight' => 1001, |
|
418 | +); |
|
419 | +$form['submit'] = array( |
|
420 | +'#prefix' => '<li class="first tab">', |
|
421 | +'#type' => 'submit', |
|
422 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
423 | +'#suffix' => '</li>', |
|
424 | +'#weight' => 1002, |
|
425 | +); |
|
426 | +$form['form control tabs'] = array( |
|
427 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
428 | +'#weight' => 1003, |
|
429 | +); |
|
430 | +$form['form control tabs suffix'] = array( |
|
431 | +'#value' => '</ul>', |
|
432 | +'#weight' => 1004, |
|
433 | +); |
|
434 | + |
|
435 | +return $form; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -440,122 +440,122 @@ discard block |
||
440 | 440 | * the soft/obfuscate method. |
441 | 441 | */ |
442 | 442 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
443 | - require_boinc('token'); |
|
444 | - |
|
445 | - global $user; |
|
446 | - $form = array(); |
|
447 | - |
|
448 | - // check BOINC user exists |
|
449 | - $account = user_load(array('uid' => $user->uid)); |
|
450 | - $uid = $user->uid; |
|
451 | - $boincid = $account->boincuser_id; |
|
452 | - |
|
453 | - // check $token is valid |
|
454 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
455 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
456 | - array( |
|
457 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
458 | - ), |
|
459 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
460 | - drupal_goto(); |
|
461 | - } |
|
462 | - |
|
463 | - // Attach account to this form. |
|
464 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
465 | - |
|
466 | - // This form is for hard/wipe delete |
|
467 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
468 | - |
|
469 | - // Instructions |
|
470 | - $form['main']['instructions1'] = array( |
|
471 | - '#value' => '<p>'. |
|
472 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
473 | - '</p>', |
|
474 | - ); |
|
475 | - |
|
476 | - $form['main']['instructions2'] = array( |
|
477 | - '#value' => '<p>'. |
|
478 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
479 | - '</p>', |
|
480 | - ); |
|
481 | - |
|
482 | - // Password field |
|
483 | - $form['main']['current_pass'] = array( |
|
484 | - '#type' => 'password', |
|
485 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
486 | - '#size' => 17, |
|
487 | - '#attributes' => array( |
|
488 | - 'autocomplete' => 'off', |
|
489 | - ), |
|
490 | - '#weight' => 25, |
|
491 | - ); |
|
492 | - |
|
493 | - // Form control |
|
494 | - $form['form control tabs prefix'] = array( |
|
495 | - '#value' => '<ul class="form-control tab-list">', |
|
496 | - '#weight' => 1001, |
|
497 | - ); |
|
498 | - $form['submit'] = array( |
|
499 | - '#prefix' => '<li class="first tab">', |
|
500 | - '#type' => 'submit', |
|
501 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
502 | - '#suffix' => '</li>', |
|
503 | - '#weight' => 1002, |
|
504 | - ); |
|
505 | - $form['form control tabs'] = array( |
|
506 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
507 | - '#weight' => 1003, |
|
508 | - ); |
|
509 | - $form['form control tabs suffix'] = array( |
|
510 | - '#value' => '</ul>', |
|
511 | - '#weight' => 1004, |
|
512 | - ); |
|
443 | +require_boinc('token'); |
|
444 | + |
|
445 | +global $user; |
|
446 | +$form = array(); |
|
447 | + |
|
448 | +// check BOINC user exists |
|
449 | +$account = user_load(array('uid' => $user->uid)); |
|
450 | +$uid = $user->uid; |
|
451 | +$boincid = $account->boincuser_id; |
|
452 | + |
|
453 | +// check $token is valid |
|
454 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
455 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
456 | +array( |
|
457 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
458 | +), |
|
459 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
460 | +drupal_goto(); |
|
461 | +} |
|
513 | 462 | |
514 | - //set validation and submit to the functions below |
|
515 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
516 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
517 | - return $form; |
|
463 | +// Attach account to this form. |
|
464 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
465 | + |
|
466 | +// This form is for hard/wipe delete |
|
467 | +$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
468 | + |
|
469 | +// Instructions |
|
470 | +$form['main']['instructions1'] = array( |
|
471 | +'#value' => '<p>'. |
|
472 | +bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
473 | +'</p>', |
|
474 | +); |
|
475 | + |
|
476 | +$form['main']['instructions2'] = array( |
|
477 | +'#value' => '<p>'. |
|
478 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
479 | +'</p>', |
|
480 | +); |
|
481 | + |
|
482 | +// Password field |
|
483 | +$form['main']['current_pass'] = array( |
|
484 | +'#type' => 'password', |
|
485 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
486 | +'#size' => 17, |
|
487 | +'#attributes' => array( |
|
488 | + 'autocomplete' => 'off', |
|
489 | +), |
|
490 | +'#weight' => 25, |
|
491 | +); |
|
492 | + |
|
493 | +// Form control |
|
494 | +$form['form control tabs prefix'] = array( |
|
495 | +'#value' => '<ul class="form-control tab-list">', |
|
496 | +'#weight' => 1001, |
|
497 | +); |
|
498 | +$form['submit'] = array( |
|
499 | +'#prefix' => '<li class="first tab">', |
|
500 | +'#type' => 'submit', |
|
501 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
502 | +'#suffix' => '</li>', |
|
503 | +'#weight' => 1002, |
|
504 | +); |
|
505 | +$form['form control tabs'] = array( |
|
506 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
507 | +'#weight' => 1003, |
|
508 | +); |
|
509 | +$form['form control tabs suffix'] = array( |
|
510 | +'#value' => '</ul>', |
|
511 | +'#weight' => 1004, |
|
512 | +); |
|
513 | + |
|
514 | +//set validation and submit to the functions below |
|
515 | +$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
516 | +$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
517 | +return $form; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Validation for final confirmation |
522 | 522 | */ |
523 | 523 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
524 | - $account = $form_state['values']['_account']; |
|
525 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
524 | +$account = $form_state['values']['_account']; |
|
525 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
526 | 526 | |
527 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
528 | - return true; |
|
529 | - } |
|
527 | +if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
528 | +return true; |
|
529 | +} |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
533 | 533 | * Submit for final confirmation |
534 | 534 | */ |
535 | 535 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
536 | - global $user; |
|
537 | - |
|
538 | - // Delete the user |
|
539 | - $account = $form_state['values']['_account']; |
|
540 | - $action = $form_state['values']['_action']; |
|
541 | - _boincuser_delete_deleteuser($account, $action); |
|
542 | - |
|
543 | - // Destroy the current session: |
|
544 | - session_destroy(); |
|
545 | - // Only variables can be passed by reference workaround. |
|
546 | - $null = NULL; |
|
547 | - user_module_invoke('logout', $null, $user); |
|
548 | - |
|
549 | - // Load the anonymous user |
|
550 | - $user = drupal_anonymous_user(); |
|
551 | - |
|
552 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
553 | - // Redirect |
|
554 | - if (!empty($redirect)) { |
|
555 | - drupal_goto($redirect); |
|
556 | - } |
|
557 | - else { |
|
558 | - drupal_goto(); |
|
559 | - } |
|
536 | +global $user; |
|
537 | + |
|
538 | +// Delete the user |
|
539 | +$account = $form_state['values']['_account']; |
|
540 | +$action = $form_state['values']['_action']; |
|
541 | +_boincuser_delete_deleteuser($account, $action); |
|
542 | + |
|
543 | +// Destroy the current session: |
|
544 | +session_destroy(); |
|
545 | +// Only variables can be passed by reference workaround. |
|
546 | +$null = NULL; |
|
547 | +user_module_invoke('logout', $null, $user); |
|
548 | + |
|
549 | +// Load the anonymous user |
|
550 | +$user = drupal_anonymous_user(); |
|
551 | + |
|
552 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
553 | +// Redirect |
|
554 | +if (!empty($redirect)) { |
|
555 | +drupal_goto($redirect); |
|
556 | +} |
|
557 | +else { |
|
558 | +drupal_goto(); |
|
559 | +} |
|
560 | 560 | |
561 | 561 | } |