@@ -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 { |
@@ -9,28 +9,28 @@ discard block |
||
9 | 9 | * Helper functions |
10 | 10 | */ |
11 | 11 | function _boincuser_delete_goto_admindelete($form, &$form_state) { |
12 | - drupal_goto('/admin/boinc/user_delete/' . $form['#uid']); |
|
12 | +drupal_goto('/admin/boinc/user_delete/' . $form['#uid']); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | function _boincuser_delete_cancel($form, &$form_state) { |
16 | - drupal_goto('/user/' . $form['#uid'] . '/edit'); |
|
16 | +drupal_goto('/user/' . $form['#uid'] . '/edit'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Validation user password function. |
21 | 21 | */ |
22 | 22 | function _boincuser_delete_validatepasswd($boinc_user, $current_pass) { |
23 | - if (!$current_pass) { |
|
24 | - return form_set_error('current_pass', bts('Authentication is required when requesting account deletion.', array(), NULL, 'boinc:delete-user-account')); |
|
25 | - } |
|
23 | +if (!$current_pass) { |
|
24 | +return form_set_error('current_pass', bts('Authentication is required when requesting account deletion.', array(), NULL, 'boinc:delete-user-account')); |
|
25 | +} |
|
26 | 26 | |
27 | - $given_hash = md5($current_pass . $boinc_user->email_addr); |
|
27 | +$given_hash = md5($current_pass . $boinc_user->email_addr); |
|
28 | 28 | |
29 | - if ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
30 | - return form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:delete-user-account')); |
|
31 | - } |
|
29 | +if ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
30 | +return form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:delete-user-account')); |
|
31 | +} |
|
32 | 32 | |
33 | - return true; |
|
33 | +return true; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -41,56 +41,56 @@ discard block |
||
41 | 41 | * Delete the user function. |
42 | 42 | */ |
43 | 43 | function _boincuser_delete_deleteuser($account, $action=NULL) { |
44 | - require_boinc('user_util'); |
|
45 | - require_boinc('delete_account'); |
|
46 | - |
|
47 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
48 | - |
|
49 | - // watchdog message |
|
50 | - watchdog('boincuser_delete', 'Deleting account drupal UID: %uid, BOINC id: %boincuser_id., BOINC displayname: %displayname', |
|
51 | - array( |
|
52 | - '%uid' => $account->uid, |
|
53 | - '%boincuser_id' => $account->boincuser_id, |
|
54 | - '%displayname' => $account->boincuser_name, |
|
55 | - ), WATCHDOG_NOTICE); |
|
56 | - |
|
57 | - // delete the account - This will delete the boinc user from the |
|
58 | - // boinc project database, and then delete the Drupal user using the |
|
59 | - // hook_user() functions. |
|
60 | - |
|
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); |
|
93 | - } |
|
44 | +require_boinc('user_util'); |
|
45 | +require_boinc('delete_account'); |
|
46 | + |
|
47 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
48 | + |
|
49 | +// watchdog message |
|
50 | +watchdog('boincuser_delete', 'Deleting account drupal UID: %uid, BOINC id: %boincuser_id., BOINC displayname: %displayname', |
|
51 | +array( |
|
52 | +'%uid' => $account->uid, |
|
53 | +'%boincuser_id' => $account->boincuser_id, |
|
54 | +'%displayname' => $account->boincuser_name, |
|
55 | +), WATCHDOG_NOTICE); |
|
56 | + |
|
57 | +// delete the account - This will delete the boinc user from the |
|
58 | +// boinc project database, and then delete the Drupal user using the |
|
59 | +// hook_user() functions. |
|
60 | + |
|
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); |
|
93 | +} |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 | } |