@@ -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 { |
@@ -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 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.', 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 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.', 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); |
@@ -303,56 +303,56 @@ discard block |
||
303 | 303 | // create token with 1 day/24 hour expiration |
304 | 304 | $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
305 | 305 | switch ($op) { |
306 | - case 'boincuser_delete_softdelete': |
|
307 | - $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
308 | - break; |
|
309 | - case 'boincuser_delete_delete': |
|
310 | - $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
306 | + case 'boincuser_delete_softdelete': |
|
307 | + $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
311 | 308 | break; |
312 | - } |
|
313 | - |
|
314 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
315 | - $mymessage = '' |
|
316 | - . "{$account->boincuser_name},\n" |
|
317 | - . "\n" |
|
318 | - . "We have received a request to DELETE your user account at " |
|
319 | - . "${site_name}. Below in this email is a one-time token you must " |
|
320 | - . "use. Either click on the link or copy-and-paste the URL into your " |
|
321 | - . "browser address bar. Then you will be required to enter your password " |
|
322 | - . "again to confirm your identity.\n" |
|
323 | - . "\n" |
|
324 | - . "${myurl}\n" |
|
325 | - . "\n" |
|
326 | - . "This one-time token will expire in 24 hours. Afterwards you must " |
|
327 | - . "re-request deletion of your account in order to generate a new token.\n" |
|
328 | - . "\n" |
|
329 | - . "If you did not initiate this request, please login to the " |
|
330 | - . "${site_name} Web site (${site_url}) and " |
|
331 | - . "then contact the administrators.\n" |
|
332 | - . "\n" |
|
333 | - . "Thanks, \n" |
|
334 | - . "\n" |
|
335 | - . "{$site_name} support team"; |
|
336 | - |
|
337 | - // Create array for sending email to user to notify account is being |
|
338 | - // disabled/deleted. Then send email. |
|
339 | - $settings = array( |
|
340 | - 'from' => '', |
|
341 | - 'subject' => $mysubject, |
|
342 | - 'message' => $mymessage, |
|
343 | - ); |
|
344 | - rules_action_mail_to_user($account, $settings); |
|
345 | - |
|
346 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
309 | +case 'boincuser_delete_delete': |
|
310 | + $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
311 | + break; |
|
312 | +} |
|
347 | 313 | |
348 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
349 | - // Redirect |
|
350 | - if (!empty($redirect)) { |
|
351 | - drupal_goto($redirect); |
|
352 | - } |
|
353 | - else { |
|
354 | - drupal_goto(); |
|
355 | - } |
|
314 | +$mysubject = "Instructions for account deletion at {$site_name}"; |
|
315 | +$mymessage = '' |
|
316 | +. "{$account->boincuser_name},\n" |
|
317 | +. "\n" |
|
318 | +. "We have received a request to DELETE your user account at " |
|
319 | +. "${site_name}. Below in this email is a one-time token you must " |
|
320 | +. "use. Either click on the link or copy-and-paste the URL into your " |
|
321 | +. "browser address bar. Then you will be required to enter your password " |
|
322 | +. "again to confirm your identity.\n" |
|
323 | +. "\n" |
|
324 | +. "${myurl}\n" |
|
325 | +. "\n" |
|
326 | +. "This one-time token will expire in 24 hours. Afterwards you must " |
|
327 | +. "re-request deletion of your account in order to generate a new token.\n" |
|
328 | +. "\n" |
|
329 | +. "If you did not initiate this request, please login to the " |
|
330 | +. "${site_name} Web site (${site_url}) and " |
|
331 | +. "then contact the administrators.\n" |
|
332 | +. "\n" |
|
333 | +. "Thanks, \n" |
|
334 | +. "\n" |
|
335 | +. "{$site_name} support team"; |
|
336 | + |
|
337 | +// Create array for sending email to user to notify account is being |
|
338 | +// disabled/deleted. Then send email. |
|
339 | +$settings = array( |
|
340 | +'from' => '', |
|
341 | +'subject' => $mysubject, |
|
342 | +'message' => $mymessage, |
|
343 | +); |
|
344 | +rules_action_mail_to_user($account, $settings); |
|
345 | + |
|
346 | +drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
347 | + |
|
348 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
349 | +// Redirect |
|
350 | +if (!empty($redirect)) { |
|
351 | +drupal_goto($redirect); |
|
352 | +} |
|
353 | +else { |
|
354 | +drupal_goto(); |
|
355 | +} |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -364,77 +364,77 @@ discard block |
||
364 | 364 | * The final confirmation form for the user to delete their account. |
365 | 365 | */ |
366 | 366 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
367 | - require_boinc('token'); |
|
368 | - |
|
369 | - global $user; |
|
370 | - $form = array(); |
|
371 | - |
|
372 | - // check BOINC user exists |
|
373 | - $account = user_load(array('uid' => $user->uid)); |
|
374 | - $uid = $user->uid; |
|
375 | - $boincid = $account->boincuser_id; |
|
376 | - // check $token is valid |
|
377 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
378 | - 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.', |
|
379 | - array( |
|
380 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
381 | - ), |
|
382 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
383 | - drupal_goto(); |
|
384 | - } |
|
385 | - |
|
386 | - // Attach account to this form. |
|
387 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
388 | - |
|
389 | - // This form is for hard/wipe delete |
|
390 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
391 | - |
|
392 | - // Instructions |
|
393 | - $form['main']['instructions1'] = array( |
|
394 | - '#value' => '<p>'. |
|
395 | - 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'). |
|
396 | - '</p>', |
|
397 | - ); |
|
398 | - |
|
399 | - $form['main']['instructions2'] = array( |
|
400 | - '#value' => '<p>'. |
|
401 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
402 | - '</p>', |
|
403 | - ); |
|
404 | - |
|
405 | - // Password field |
|
406 | - $form['main']['current_pass'] = array( |
|
407 | - '#type' => 'password', |
|
408 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
409 | - '#size' => 17, |
|
410 | - '#attributes' => array( |
|
411 | - 'autocomplete' => 'off', |
|
412 | - ), |
|
413 | - '#weight' => 25, |
|
414 | - ); |
|
415 | - |
|
416 | - // Form control |
|
417 | - $form['form control tabs prefix'] = array( |
|
418 | - '#value' => '<ul class="form-control tab-list">', |
|
419 | - '#weight' => 1001, |
|
420 | - ); |
|
421 | - $form['submit'] = array( |
|
422 | - '#prefix' => '<li class="first tab">', |
|
423 | - '#type' => 'submit', |
|
424 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
425 | - '#suffix' => '</li>', |
|
426 | - '#weight' => 1002, |
|
427 | - ); |
|
428 | - $form['form control tabs'] = array( |
|
429 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
430 | - '#weight' => 1003, |
|
431 | - ); |
|
432 | - $form['form control tabs suffix'] = array( |
|
433 | - '#value' => '</ul>', |
|
434 | - '#weight' => 1004, |
|
435 | - ); |
|
367 | +require_boinc('token'); |
|
368 | + |
|
369 | +global $user; |
|
370 | +$form = array(); |
|
371 | + |
|
372 | +// check BOINC user exists |
|
373 | +$account = user_load(array('uid' => $user->uid)); |
|
374 | +$uid = $user->uid; |
|
375 | +$boincid = $account->boincuser_id; |
|
376 | +// check $token is valid |
|
377 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
378 | +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.', |
|
379 | +array( |
|
380 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
381 | +), |
|
382 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
383 | +drupal_goto(); |
|
384 | +} |
|
436 | 385 | |
437 | - return $form; |
|
386 | +// Attach account to this form. |
|
387 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
388 | + |
|
389 | +// This form is for hard/wipe delete |
|
390 | +$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
391 | + |
|
392 | +// Instructions |
|
393 | +$form['main']['instructions1'] = array( |
|
394 | +'#value' => '<p>'. |
|
395 | +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'). |
|
396 | +'</p>', |
|
397 | +); |
|
398 | + |
|
399 | +$form['main']['instructions2'] = array( |
|
400 | +'#value' => '<p>'. |
|
401 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
402 | +'</p>', |
|
403 | +); |
|
404 | + |
|
405 | +// Password field |
|
406 | +$form['main']['current_pass'] = array( |
|
407 | +'#type' => 'password', |
|
408 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
409 | +'#size' => 17, |
|
410 | +'#attributes' => array( |
|
411 | + 'autocomplete' => 'off', |
|
412 | +), |
|
413 | +'#weight' => 25, |
|
414 | +); |
|
415 | + |
|
416 | +// Form control |
|
417 | +$form['form control tabs prefix'] = array( |
|
418 | +'#value' => '<ul class="form-control tab-list">', |
|
419 | +'#weight' => 1001, |
|
420 | +); |
|
421 | +$form['submit'] = array( |
|
422 | +'#prefix' => '<li class="first tab">', |
|
423 | +'#type' => 'submit', |
|
424 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
425 | +'#suffix' => '</li>', |
|
426 | +'#weight' => 1002, |
|
427 | +); |
|
428 | +$form['form control tabs'] = array( |
|
429 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
430 | +'#weight' => 1003, |
|
431 | +); |
|
432 | +$form['form control tabs suffix'] = array( |
|
433 | +'#value' => '</ul>', |
|
434 | +'#weight' => 1004, |
|
435 | +); |
|
436 | + |
|
437 | +return $form; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -442,122 +442,122 @@ discard block |
||
442 | 442 | * the soft/obfuscate method. |
443 | 443 | */ |
444 | 444 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
445 | - require_boinc('token'); |
|
446 | - |
|
447 | - global $user; |
|
448 | - $form = array(); |
|
449 | - |
|
450 | - // check BOINC user exists |
|
451 | - $account = user_load(array('uid' => $user->uid)); |
|
452 | - $uid = $user->uid; |
|
453 | - $boincid = $account->boincuser_id; |
|
454 | - |
|
455 | - // check $token is valid |
|
456 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
457 | - 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.', |
|
458 | - array( |
|
459 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
460 | - ), |
|
461 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
462 | - drupal_goto(); |
|
463 | - } |
|
464 | - |
|
465 | - // Attach account to this form. |
|
466 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
467 | - |
|
468 | - // This form is for hard/wipe delete |
|
469 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
470 | - |
|
471 | - // Instructions |
|
472 | - $form['main']['instructions1'] = array( |
|
473 | - '#value' => '<p>'. |
|
474 | - 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'). |
|
475 | - '</p>', |
|
476 | - ); |
|
477 | - |
|
478 | - $form['main']['instructions2'] = array( |
|
479 | - '#value' => '<p>'. |
|
480 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
481 | - '</p>', |
|
482 | - ); |
|
483 | - |
|
484 | - // Password field |
|
485 | - $form['main']['current_pass'] = array( |
|
486 | - '#type' => 'password', |
|
487 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
488 | - '#size' => 17, |
|
489 | - '#attributes' => array( |
|
490 | - 'autocomplete' => 'off', |
|
491 | - ), |
|
492 | - '#weight' => 25, |
|
493 | - ); |
|
494 | - |
|
495 | - // Form control |
|
496 | - $form['form control tabs prefix'] = array( |
|
497 | - '#value' => '<ul class="form-control tab-list">', |
|
498 | - '#weight' => 1001, |
|
499 | - ); |
|
500 | - $form['submit'] = array( |
|
501 | - '#prefix' => '<li class="first tab">', |
|
502 | - '#type' => 'submit', |
|
503 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
504 | - '#suffix' => '</li>', |
|
505 | - '#weight' => 1002, |
|
506 | - ); |
|
507 | - $form['form control tabs'] = array( |
|
508 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
509 | - '#weight' => 1003, |
|
510 | - ); |
|
511 | - $form['form control tabs suffix'] = array( |
|
512 | - '#value' => '</ul>', |
|
513 | - '#weight' => 1004, |
|
514 | - ); |
|
445 | +require_boinc('token'); |
|
446 | + |
|
447 | +global $user; |
|
448 | +$form = array(); |
|
449 | + |
|
450 | +// check BOINC user exists |
|
451 | +$account = user_load(array('uid' => $user->uid)); |
|
452 | +$uid = $user->uid; |
|
453 | +$boincid = $account->boincuser_id; |
|
454 | + |
|
455 | +// check $token is valid |
|
456 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
457 | +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.', |
|
458 | +array( |
|
459 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
460 | +), |
|
461 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
462 | +drupal_goto(); |
|
463 | +} |
|
515 | 464 | |
516 | - //set validation and submit to the functions below |
|
517 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
518 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
519 | - return $form; |
|
465 | +// Attach account to this form. |
|
466 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
467 | + |
|
468 | +// This form is for hard/wipe delete |
|
469 | +$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
470 | + |
|
471 | +// Instructions |
|
472 | +$form['main']['instructions1'] = array( |
|
473 | +'#value' => '<p>'. |
|
474 | +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'). |
|
475 | +'</p>', |
|
476 | +); |
|
477 | + |
|
478 | +$form['main']['instructions2'] = array( |
|
479 | +'#value' => '<p>'. |
|
480 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
481 | +'</p>', |
|
482 | +); |
|
483 | + |
|
484 | +// Password field |
|
485 | +$form['main']['current_pass'] = array( |
|
486 | +'#type' => 'password', |
|
487 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
488 | +'#size' => 17, |
|
489 | +'#attributes' => array( |
|
490 | + 'autocomplete' => 'off', |
|
491 | +), |
|
492 | +'#weight' => 25, |
|
493 | +); |
|
494 | + |
|
495 | +// Form control |
|
496 | +$form['form control tabs prefix'] = array( |
|
497 | +'#value' => '<ul class="form-control tab-list">', |
|
498 | +'#weight' => 1001, |
|
499 | +); |
|
500 | +$form['submit'] = array( |
|
501 | +'#prefix' => '<li class="first tab">', |
|
502 | +'#type' => 'submit', |
|
503 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
504 | +'#suffix' => '</li>', |
|
505 | +'#weight' => 1002, |
|
506 | +); |
|
507 | +$form['form control tabs'] = array( |
|
508 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
509 | +'#weight' => 1003, |
|
510 | +); |
|
511 | +$form['form control tabs suffix'] = array( |
|
512 | +'#value' => '</ul>', |
|
513 | +'#weight' => 1004, |
|
514 | +); |
|
515 | + |
|
516 | +//set validation and submit to the functions below |
|
517 | +$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
518 | +$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
519 | +return $form; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
523 | 523 | * Validation for final confirmation |
524 | 524 | */ |
525 | 525 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
526 | - $account = $form_state['values']['_account']; |
|
527 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
526 | +$account = $form_state['values']['_account']; |
|
527 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
528 | 528 | |
529 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
530 | - return true; |
|
531 | - } |
|
529 | +if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
530 | +return true; |
|
531 | +} |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
535 | 535 | * Submit for final confirmation |
536 | 536 | */ |
537 | 537 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
538 | - global $user; |
|
539 | - |
|
540 | - // Delete the user |
|
541 | - $account = $form_state['values']['_account']; |
|
542 | - $action = $form_state['values']['_action']; |
|
543 | - _boincuser_delete_deleteuser($account, $action); |
|
544 | - |
|
545 | - // Destroy the current session: |
|
546 | - session_destroy(); |
|
547 | - // Only variables can be passed by reference workaround. |
|
548 | - $null = NULL; |
|
549 | - user_module_invoke('logout', $null, $user); |
|
550 | - |
|
551 | - // Load the anonymous user |
|
552 | - $user = drupal_anonymous_user(); |
|
553 | - |
|
554 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
555 | - // Redirect |
|
556 | - if (!empty($redirect)) { |
|
557 | - drupal_goto($redirect); |
|
558 | - } |
|
559 | - else { |
|
560 | - drupal_goto(); |
|
561 | - } |
|
538 | +global $user; |
|
539 | + |
|
540 | +// Delete the user |
|
541 | +$account = $form_state['values']['_account']; |
|
542 | +$action = $form_state['values']['_action']; |
|
543 | +_boincuser_delete_deleteuser($account, $action); |
|
544 | + |
|
545 | +// Destroy the current session: |
|
546 | +session_destroy(); |
|
547 | +// Only variables can be passed by reference workaround. |
|
548 | +$null = NULL; |
|
549 | +user_module_invoke('logout', $null, $user); |
|
550 | + |
|
551 | +// Load the anonymous user |
|
552 | +$user = drupal_anonymous_user(); |
|
553 | + |
|
554 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
555 | +// Redirect |
|
556 | +if (!empty($redirect)) { |
|
557 | +drupal_goto($redirect); |
|
558 | +} |
|
559 | +else { |
|
560 | +drupal_goto(); |
|
561 | +} |
|
562 | 562 | |
563 | 563 | } |
@@ -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 |
@@ -27,287 +27,287 @@ discard block |
||
27 | 27 | * with defined URL paths |
28 | 28 | */ |
29 | 29 | function boincuser_menu() { |
30 | - $items['account/posts'] = array( |
|
31 | - 'title' => 'Recent posts', |
|
32 | - 'description' => '', |
|
33 | - 'page callback' => 'boincuser_goto_recent_posts', |
|
34 | - 'access callback' => 'user_is_logged_in', |
|
35 | - 'type' => MENU_CALLBACK, |
|
36 | - ); |
|
37 | - $items['account/profile'] = array( |
|
38 | - 'title' => '', |
|
39 | - 'description' => '', |
|
40 | - 'page callback' => 'boincuser_view_profile', |
|
41 | - 'access callback' => 'user_is_logged_in', |
|
42 | - 'type' => MENU_NORMAL_ITEM |
|
43 | - ); |
|
44 | - $items['account/profile/view'] = array( |
|
45 | - 'title' => 'View', |
|
46 | - 'description' => 'Show a user profile', |
|
47 | - 'page callback' => 'boincuser_view_profile', |
|
48 | - 'access callback' => 'user_is_logged_in', |
|
49 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | - 'weight' => 0 |
|
51 | - ); |
|
52 | - $items['account/profile/edit'] = array( |
|
53 | - 'title' => 'Edit', |
|
54 | - 'description' => 'Edit a user profile', |
|
55 | - 'page callback' => 'boincuser_edit_profile', |
|
56 | - 'access callback' => 'user_is_logged_in', |
|
57 | - 'type' => MENU_LOCAL_TASK, |
|
58 | - 'weight' => 5 |
|
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
61 | - 'title' => 'User team', |
|
62 | - 'description' => '', |
|
63 | - 'page callback' => 'boincuser_goto_team', |
|
64 | - 'access callback' => 'user_is_logged_in', |
|
65 | - 'type' => MENU_CALLBACK, |
|
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
68 | - 'title' => 'Profile approval', |
|
69 | - 'description' => 'Approve profile content', |
|
70 | - 'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | - 'page arguments' => array(2), |
|
72 | - 'access arguments' => array('edit any profile content'), |
|
73 | - 'type' => MENU_CALLBACK, |
|
74 | - 'weight' => 5 |
|
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
77 | - 'title' => 'Profile editor', |
|
78 | - 'description' => 'Edit a user profile', |
|
79 | - 'page callback' => 'boincuser_edit_profile', |
|
80 | - 'page arguments' => array(2), |
|
81 | - 'access arguments' => array('edit any profile content'), |
|
82 | - 'type' => MENU_CALLBACK, |
|
83 | - 'weight' => 5 |
|
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
86 | - 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | - 'description' => 'Reject profile content', |
|
88 | - 'page callback' => 'drupal_get_form', |
|
89 | - 'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | - 'access arguments' => array('edit any profile content'), |
|
91 | - 'type' => MENU_CALLBACK, |
|
92 | - 'weight' => 5 |
|
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
95 | - 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | - 'description' => 'Ban a user from using community features', |
|
97 | - 'page callback' => 'drupal_get_form', |
|
98 | - 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | - 'access callback' => 'boincuser_moderate_community_access', |
|
100 | - 'type' => MENU_CALLBACK, |
|
101 | - ); |
|
102 | - $items['join'] = array( |
|
103 | - 'title' => '', |
|
104 | - 'description' => '', |
|
105 | - 'page callback' => 'join_page', |
|
106 | - 'access arguments' => array('access content'), |
|
107 | - 'type' => MENU_NORMAL_ITEM |
|
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
110 | - 'title' => bts("I'm new"), |
|
111 | - 'page callback' => 'join_page', |
|
112 | - 'page arguments' => array(1), |
|
113 | - 'access arguments' => array('access content'), |
|
114 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | - 'weight' => 0 |
|
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
118 | - 'title' => bts("I'm a BOINC user"), |
|
119 | - 'page callback' => 'join_page', |
|
120 | - 'page arguments' => array(1), |
|
121 | - 'access arguments' => array('access content'), |
|
122 | - 'type' => MENU_LOCAL_TASK, |
|
123 | - 'weight' => 5 |
|
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
126 | - 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | - 'description' => 'Log in using a user authenticator', |
|
128 | - 'page callback' => 'drupal_get_form', |
|
129 | - 'page arguments' => array('boincuser_authloginform'), |
|
130 | - 'access arguments' => array('access content'), |
|
131 | - 'type' => MENU_CALLBACK, |
|
132 | - ); |
|
133 | - $items['user/termsofuse'] = array( |
|
134 | - 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
135 | - 'description' => 'A site\'s term of use.', |
|
136 | - 'page callback' => 'drupal_get_form', |
|
137 | - 'page arguments' => array('boincuser_termsofuse_form'), |
|
138 | - 'access callback' => 'user_is_logged_in', |
|
139 | - 'type' => MENU_CALLBACK, |
|
140 | - ); |
|
141 | - $items['user_control'] = array( |
|
142 | - 'page callback' => 'boincuser_control', |
|
143 | - 'access arguments' => array('access user profiles'), |
|
144 | - 'type' => MENU_CALLBACK |
|
145 | - ); |
|
146 | - $items['admin/boinc'] = array( |
|
147 | - 'title' => 'BOINC configuration', |
|
148 | - 'position' => 'right', |
|
149 | - 'weight' => -8, |
|
150 | - 'page callback' => 'system_admin_menu_block_page', |
|
151 | - 'access arguments' => array('administer site configuration'), |
|
152 | - 'file' => 'system.admin.inc', |
|
153 | - 'file path' => drupal_get_path('module', 'system'), |
|
154 | - ); |
|
155 | - $items['admin/boinc/environment'] = array( |
|
156 | - 'title' => 'Environment: General', |
|
157 | - 'description' => 'Set paths to BOINC functions and any other necessary |
|
30 | +$items['account/posts'] = array( |
|
31 | +'title' => 'Recent posts', |
|
32 | +'description' => '', |
|
33 | +'page callback' => 'boincuser_goto_recent_posts', |
|
34 | +'access callback' => 'user_is_logged_in', |
|
35 | +'type' => MENU_CALLBACK, |
|
36 | +); |
|
37 | +$items['account/profile'] = array( |
|
38 | +'title' => '', |
|
39 | +'description' => '', |
|
40 | +'page callback' => 'boincuser_view_profile', |
|
41 | +'access callback' => 'user_is_logged_in', |
|
42 | +'type' => MENU_NORMAL_ITEM |
|
43 | +); |
|
44 | +$items['account/profile/view'] = array( |
|
45 | +'title' => 'View', |
|
46 | +'description' => 'Show a user profile', |
|
47 | +'page callback' => 'boincuser_view_profile', |
|
48 | +'access callback' => 'user_is_logged_in', |
|
49 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | +'weight' => 0 |
|
51 | +); |
|
52 | +$items['account/profile/edit'] = array( |
|
53 | +'title' => 'Edit', |
|
54 | +'description' => 'Edit a user profile', |
|
55 | +'page callback' => 'boincuser_edit_profile', |
|
56 | +'access callback' => 'user_is_logged_in', |
|
57 | +'type' => MENU_LOCAL_TASK, |
|
58 | +'weight' => 5 |
|
59 | +); |
|
60 | +$items['account/team'] = array( |
|
61 | +'title' => 'User team', |
|
62 | +'description' => '', |
|
63 | +'page callback' => 'boincuser_goto_team', |
|
64 | +'access callback' => 'user_is_logged_in', |
|
65 | +'type' => MENU_CALLBACK, |
|
66 | +); |
|
67 | +$items['moderate/profile/%user/approve'] = array( |
|
68 | +'title' => 'Profile approval', |
|
69 | +'description' => 'Approve profile content', |
|
70 | +'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | +'page arguments' => array(2), |
|
72 | +'access arguments' => array('edit any profile content'), |
|
73 | +'type' => MENU_CALLBACK, |
|
74 | +'weight' => 5 |
|
75 | +); |
|
76 | +$items['moderate/profile/%user/edit'] = array( |
|
77 | +'title' => 'Profile editor', |
|
78 | +'description' => 'Edit a user profile', |
|
79 | +'page callback' => 'boincuser_edit_profile', |
|
80 | +'page arguments' => array(2), |
|
81 | +'access arguments' => array('edit any profile content'), |
|
82 | +'type' => MENU_CALLBACK, |
|
83 | +'weight' => 5 |
|
84 | +); |
|
85 | +$items['moderate/profile/%/reject'] = array( |
|
86 | +'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | +'description' => 'Reject profile content', |
|
88 | +'page callback' => 'drupal_get_form', |
|
89 | +'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | +'access arguments' => array('edit any profile content'), |
|
91 | +'type' => MENU_CALLBACK, |
|
92 | +'weight' => 5 |
|
93 | +); |
|
94 | +$items['moderate/user/%/ban'] = array( |
|
95 | +'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | +'description' => 'Ban a user from using community features', |
|
97 | +'page callback' => 'drupal_get_form', |
|
98 | +'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | +'access callback' => 'boincuser_moderate_community_access', |
|
100 | +'type' => MENU_CALLBACK, |
|
101 | +); |
|
102 | +$items['join'] = array( |
|
103 | +'title' => '', |
|
104 | +'description' => '', |
|
105 | +'page callback' => 'join_page', |
|
106 | +'access arguments' => array('access content'), |
|
107 | +'type' => MENU_NORMAL_ITEM |
|
108 | +); |
|
109 | +$items['join/new'] = array( |
|
110 | +'title' => bts("I'm new"), |
|
111 | +'page callback' => 'join_page', |
|
112 | +'page arguments' => array(1), |
|
113 | +'access arguments' => array('access content'), |
|
114 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | +'weight' => 0 |
|
116 | +); |
|
117 | +$items['join/boinc'] = array( |
|
118 | +'title' => bts("I'm a BOINC user"), |
|
119 | +'page callback' => 'join_page', |
|
120 | +'page arguments' => array(1), |
|
121 | +'access arguments' => array('access content'), |
|
122 | +'type' => MENU_LOCAL_TASK, |
|
123 | +'weight' => 5 |
|
124 | +); |
|
125 | +$items['user/login/auth'] = array( |
|
126 | +'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | +'description' => 'Log in using a user authenticator', |
|
128 | +'page callback' => 'drupal_get_form', |
|
129 | +'page arguments' => array('boincuser_authloginform'), |
|
130 | +'access arguments' => array('access content'), |
|
131 | +'type' => MENU_CALLBACK, |
|
132 | +); |
|
133 | +$items['user/termsofuse'] = array( |
|
134 | +'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
135 | +'description' => 'A site\'s term of use.', |
|
136 | +'page callback' => 'drupal_get_form', |
|
137 | +'page arguments' => array('boincuser_termsofuse_form'), |
|
138 | +'access callback' => 'user_is_logged_in', |
|
139 | +'type' => MENU_CALLBACK, |
|
140 | +); |
|
141 | +$items['user_control'] = array( |
|
142 | +'page callback' => 'boincuser_control', |
|
143 | +'access arguments' => array('access user profiles'), |
|
144 | +'type' => MENU_CALLBACK |
|
145 | +); |
|
146 | +$items['admin/boinc'] = array( |
|
147 | +'title' => 'BOINC configuration', |
|
148 | +'position' => 'right', |
|
149 | +'weight' => -8, |
|
150 | +'page callback' => 'system_admin_menu_block_page', |
|
151 | +'access arguments' => array('administer site configuration'), |
|
152 | +'file' => 'system.admin.inc', |
|
153 | +'file path' => drupal_get_path('module', 'system'), |
|
154 | +); |
|
155 | +$items['admin/boinc/environment'] = array( |
|
156 | +'title' => 'Environment: General', |
|
157 | +'description' => 'Set paths to BOINC functions and any other necessary |
|
158 | 158 | variables that establish a BOINC environment.', |
159 | - 'page callback' => 'drupal_get_form', |
|
160 | - 'page arguments' => array('boincuser_admin_environment'), |
|
161 | - 'access arguments' => array('administer site configuration'), |
|
162 | - 'type' => MENU_NORMAL_ITEM, |
|
163 | - 'file' => 'boincuser.admin.inc' |
|
164 | - ); |
|
165 | - $items['admin/boinc/scheduler'] = array( |
|
166 | - 'title' => 'Environment: Scheduling server URLs', |
|
167 | - 'description' => 'Set BOINC scheduler options.', |
|
168 | - 'page callback' => 'drupal_get_form', |
|
169 | - 'page arguments' => array('boincuser_admin_scheduler'), |
|
170 | - 'access arguments' => array('administer site configuration'), |
|
171 | - 'type' => MENU_NORMAL_ITEM, |
|
172 | - 'file' => 'boincuser.admin.inc' |
|
173 | - ); |
|
174 | - $items['admin/boinc/weboptions'] = array( |
|
175 | - 'title' => 'Environment: Website Options', |
|
176 | - 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
177 | - 'page callback' => 'drupal_get_form', |
|
178 | - 'page arguments' => array('boincuser_admin_weboptions'), |
|
179 | - 'access arguments' => array('administer site configuration'), |
|
180 | - 'type' => MENU_NORMAL_ITEM, |
|
181 | - 'file' => 'boincuser.admin.inc' |
|
182 | - ); |
|
159 | +'page callback' => 'drupal_get_form', |
|
160 | +'page arguments' => array('boincuser_admin_environment'), |
|
161 | +'access arguments' => array('administer site configuration'), |
|
162 | +'type' => MENU_NORMAL_ITEM, |
|
163 | +'file' => 'boincuser.admin.inc' |
|
164 | +); |
|
165 | +$items['admin/boinc/scheduler'] = array( |
|
166 | +'title' => 'Environment: Scheduling server URLs', |
|
167 | +'description' => 'Set BOINC scheduler options.', |
|
168 | +'page callback' => 'drupal_get_form', |
|
169 | +'page arguments' => array('boincuser_admin_scheduler'), |
|
170 | +'access arguments' => array('administer site configuration'), |
|
171 | +'type' => MENU_NORMAL_ITEM, |
|
172 | +'file' => 'boincuser.admin.inc' |
|
173 | +); |
|
174 | +$items['admin/boinc/weboptions'] = array( |
|
175 | +'title' => 'Environment: Website Options', |
|
176 | +'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
177 | +'page callback' => 'drupal_get_form', |
|
178 | +'page arguments' => array('boincuser_admin_weboptions'), |
|
179 | +'access arguments' => array('administer site configuration'), |
|
180 | +'type' => MENU_NORMAL_ITEM, |
|
181 | +'file' => 'boincuser.admin.inc' |
|
182 | +); |
|
183 | 183 | |
184 | - $items['create_account.php'] = array( |
|
185 | - 'title' => 'Create Account RPC', |
|
186 | - 'description' => 'RPC for creating user accounts.', |
|
187 | - 'page callback' => 'boincuser_create_account', |
|
188 | - 'access callback' => TRUE, |
|
189 | - 'type' => MENU_CALLBACK |
|
190 | - ); |
|
191 | - $items['account_finish.php'] = array( |
|
192 | - 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
193 | - 'description' => 'RPC for after a user has created an account.', |
|
194 | - 'page callback' => 'boincuser_account_finish', |
|
195 | - 'access callback' => TRUE, |
|
196 | - 'type' => MENU_CALLBACK, |
|
197 | - ); |
|
198 | - $items['boincuser/autocomplete'] = array( |
|
199 | - 'page callback' => '_boincuser_user_name_autocomplete', |
|
200 | - 'access callback' => TRUE, |
|
201 | - 'type' => MENU_CALLBACK, |
|
202 | - ); |
|
203 | - $items['user/%user/recoveremail/%'] = array( |
|
204 | - 'title' => t('Recover previous email'), |
|
205 | - 'description' => t('Form to revert email to previous address.'), |
|
206 | - 'page callback' => 'drupal_get_form', |
|
207 | - 'page arguments' => array('boincuser_revertemail', 3), |
|
208 | - 'access callback' => 'user_is_logged_in', |
|
209 | - 'type' => MENU_CALLBACK, |
|
210 | - ); |
|
211 | - $items['recover_email.php'] = array( |
|
212 | - 'title' => t('Recover previous email'), |
|
213 | - 'description' => t('redirect'), |
|
214 | - 'page callback' => '_boincuser_redirect_recover_email', |
|
215 | - 'access callback' => TRUE, |
|
216 | - 'type' => MENU_CALLBACK, |
|
217 | - ); |
|
218 | - return $items; |
|
184 | +$items['create_account.php'] = array( |
|
185 | +'title' => 'Create Account RPC', |
|
186 | +'description' => 'RPC for creating user accounts.', |
|
187 | +'page callback' => 'boincuser_create_account', |
|
188 | +'access callback' => TRUE, |
|
189 | +'type' => MENU_CALLBACK |
|
190 | +); |
|
191 | +$items['account_finish.php'] = array( |
|
192 | +'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
193 | +'description' => 'RPC for after a user has created an account.', |
|
194 | +'page callback' => 'boincuser_account_finish', |
|
195 | +'access callback' => TRUE, |
|
196 | +'type' => MENU_CALLBACK, |
|
197 | +); |
|
198 | +$items['boincuser/autocomplete'] = array( |
|
199 | +'page callback' => '_boincuser_user_name_autocomplete', |
|
200 | +'access callback' => TRUE, |
|
201 | +'type' => MENU_CALLBACK, |
|
202 | +); |
|
203 | +$items['user/%user/recoveremail/%'] = array( |
|
204 | +'title' => t('Recover previous email'), |
|
205 | +'description' => t('Form to revert email to previous address.'), |
|
206 | +'page callback' => 'drupal_get_form', |
|
207 | +'page arguments' => array('boincuser_revertemail', 3), |
|
208 | +'access callback' => 'user_is_logged_in', |
|
209 | +'type' => MENU_CALLBACK, |
|
210 | +); |
|
211 | +$items['recover_email.php'] = array( |
|
212 | +'title' => t('Recover previous email'), |
|
213 | +'description' => t('redirect'), |
|
214 | +'page callback' => '_boincuser_redirect_recover_email', |
|
215 | +'access callback' => TRUE, |
|
216 | +'type' => MENU_CALLBACK, |
|
217 | +); |
|
218 | +return $items; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Implementation of hook_init() |
223 | 223 | */ |
224 | 224 | function boincuser_init() { |
225 | - global $user; |
|
226 | - // Skip this check for charts, which are loaded separately |
|
227 | - // (may get duplicate or unexpected messages otherwise) |
|
228 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | - return; |
|
230 | - } |
|
225 | +global $user; |
|
226 | +// Skip this check for charts, which are loaded separately |
|
227 | +// (may get duplicate or unexpected messages otherwise) |
|
228 | +if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | +return; |
|
230 | +} |
|
231 | 231 | |
232 | - // If admin user, do some basic site functionality checks |
|
233 | - if (user_access('administer site configuration')) { |
|
234 | - // Ensure we have a configured BOINC environment |
|
235 | - boinc_get_path(); |
|
236 | - boinc_get_scheduler_tags(); |
|
237 | - } |
|
232 | +// If admin user, do some basic site functionality checks |
|
233 | +if (user_access('administer site configuration')) { |
|
234 | +// Ensure we have a configured BOINC environment |
|
235 | +boinc_get_path(); |
|
236 | +boinc_get_scheduler_tags(); |
|
237 | +} |
|
238 | 238 | |
239 | - // Check credits for the verified contributor role |
|
240 | - boincuser_check_credit_requirements(); |
|
239 | +// Check credits for the verified contributor role |
|
240 | +boincuser_check_credit_requirements(); |
|
241 | 241 | |
242 | - if (module_exists('boincteam')) { |
|
243 | - // Display any persistent team messages |
|
244 | - boincteam_show_messages(); |
|
245 | - } |
|
242 | +if (module_exists('boincteam')) { |
|
243 | +// Display any persistent team messages |
|
244 | +boincteam_show_messages(); |
|
245 | +} |
|
246 | 246 | |
247 | - // Check if user has agreed to the terms of use. If not, send the |
|
248 | - // user to the terms-of-use form. This is only makes sense if the |
|
249 | - // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | - if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
254 | - |
|
255 | - // Admins are exempt, otherwise the admin may not be able to |
|
256 | - // access the site! |
|
257 | - $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | - if (!isset($user->roles[$administrator_role])) { |
|
259 | - $path = drupal_get_path_alias($_GET['q']); |
|
260 | - |
|
261 | - // Any paths that should NOT be redirected go here. |
|
262 | - // @todo - replace this static array with one that allows |
|
263 | - // admins to specify custom paths (patterns) to ignore. |
|
264 | - $paths_to_ignore = array( |
|
265 | - 'user/termsofuse', |
|
266 | - 'logout', |
|
267 | - 'privacy', |
|
268 | - 'moderation', |
|
269 | - 'account/info/edit', |
|
270 | - 'user/' . $user->uid . '/edit', |
|
271 | - 'user/' . $user->uid . '/recoveremail/*', |
|
272 | - 'recover_email.php', |
|
273 | - ); |
|
274 | - if (module_exists('boincuser_delete')) { |
|
275 | - $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | - $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | - $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
278 | - } |
|
279 | - if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
280 | - drupal_goto('user/termsofuse'); |
|
281 | - } |
|
282 | - } |
|
247 | +// Check if user has agreed to the terms of use. If not, send the |
|
248 | +// user to the terms-of-use form. This is only makes sense if the |
|
249 | +// termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | +$existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | +$termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | +if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | +if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
254 | + |
|
255 | + // Admins are exempt, otherwise the admin may not be able to |
|
256 | + // access the site! |
|
257 | + $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | + if (!isset($user->roles[$administrator_role])) { |
|
259 | + $path = drupal_get_path_alias($_GET['q']); |
|
260 | + |
|
261 | + // Any paths that should NOT be redirected go here. |
|
262 | + // @todo - replace this static array with one that allows |
|
263 | + // admins to specify custom paths (patterns) to ignore. |
|
264 | + $paths_to_ignore = array( |
|
265 | + 'user/termsofuse', |
|
266 | + 'logout', |
|
267 | + 'privacy', |
|
268 | + 'moderation', |
|
269 | + 'account/info/edit', |
|
270 | + 'user/' . $user->uid . '/edit', |
|
271 | + 'user/' . $user->uid . '/recoveremail/*', |
|
272 | + 'recover_email.php', |
|
273 | + ); |
|
274 | + if (module_exists('boincuser_delete')) { |
|
275 | + $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | + $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | + $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
278 | + } |
|
279 | + if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
280 | + drupal_goto('user/termsofuse'); |
|
283 | 281 | } |
284 | 282 | } |
285 | 283 | } |
284 | +} |
|
285 | +} |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Implementation of hook_user(); add custom actions to standard |
289 | 289 | * Drupal user operations |
290 | 290 | */ |
291 | 291 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
292 | - require_boinc('boinc_db'); |
|
293 | - require_boinc('user'); |
|
294 | - require_boinc('xml'); |
|
295 | - |
|
296 | - require_boinc('password_compat/password'); |
|
297 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
298 | - if ($account->uid > 1) { |
|
299 | - switch($op) { |
|
300 | - case 'load': |
|
301 | - // User loading; insert BOINC data into the user object |
|
302 | - $drupal_user = db_fetch_object(db_query(" |
|
292 | +require_boinc('boinc_db'); |
|
293 | +require_boinc('user'); |
|
294 | +require_boinc('xml'); |
|
295 | + |
|
296 | +require_boinc('password_compat/password'); |
|
297 | +// Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
298 | +if ($account->uid > 1) { |
|
299 | +switch($op) { |
|
300 | +case 'load': |
|
301 | +// User loading; insert BOINC data into the user object |
|
302 | +$drupal_user = db_fetch_object(db_query(" |
|
303 | 303 | SELECT boinc_id, penalty_expiration |
304 | 304 | FROM {boincuser} WHERE uid = %d", |
305 | - $account->uid |
|
306 | - )); |
|
307 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
308 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
309 | - db_set_active('boinc_rw'); |
|
310 | - $boinc_user = db_fetch_object(db_query(" |
|
305 | +$account->uid |
|
306 | +)); |
|
307 | +$account->boincuser_id = $drupal_user->boinc_id; |
|
308 | +$account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
309 | +db_set_active('boinc_rw'); |
|
310 | +$boinc_user = db_fetch_object(db_query(" |
|
311 | 311 | SELECT |
312 | 312 | name, |
313 | 313 | authenticator, |
@@ -322,30 +322,30 @@ discard block |
||
322 | 322 | email_addr_change_time |
323 | 323 | FROM {user} |
324 | 324 | WHERE id = %d", |
325 | - $account->boincuser_id |
|
326 | - )); |
|
327 | - $account->boincuser_name = $boinc_user->name; |
|
328 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
329 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
330 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
331 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
332 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
333 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
334 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
335 | - $account->boincteam_id = $boinc_user->teamid; |
|
336 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
337 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
338 | - db_set_active('default'); |
|
339 | - // Set Drupal team ID |
|
340 | - $account->team = NULL; |
|
341 | - if ($account->boincteam_id) { |
|
342 | - $account->team = db_result(db_query(" |
|
325 | +$account->boincuser_id |
|
326 | +)); |
|
327 | +$account->boincuser_name = $boinc_user->name; |
|
328 | +$account->boincuser_account_key = $boinc_user->authenticator; |
|
329 | +$account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
330 | +$account->boincuser_total_credit = round($boinc_user->total_credit); |
|
331 | +$account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
332 | +$account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
333 | +$account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
334 | +$account->boincuser_default_pref_set = $boinc_user->venue; |
|
335 | +$account->boincteam_id = $boinc_user->teamid; |
|
336 | +$account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
337 | +$account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
338 | +db_set_active('default'); |
|
339 | +// Set Drupal team ID |
|
340 | +$account->team = NULL; |
|
341 | +if ($account->boincteam_id) { |
|
342 | +$account->team = db_result(db_query(" |
|
343 | 343 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
344 | - $account->boincteam_id |
|
345 | - )); |
|
346 | - } |
|
347 | - // Set post count |
|
348 | - $account->post_count = db_result(db_query(" |
|
344 | +$account->boincteam_id |
|
345 | +)); |
|
346 | +} |
|
347 | +// Set post count |
|
348 | +$account->post_count = db_result(db_query(" |
|
349 | 349 | SELECT COUNT(*) + |
350 | 350 | ( |
351 | 351 | SELECT COUNT(*) FROM {node} |
@@ -357,13 +357,13 @@ discard block |
||
357 | 357 | INNER JOIN node ON comments.nid = node.nid |
358 | 358 | WHERE comments.uid = '%d' |
359 | 359 | AND node.status = 1", |
360 | - $account->uid, $account->uid |
|
361 | - )); |
|
362 | - break; |
|
360 | +$account->uid, $account->uid |
|
361 | +)); |
|
362 | +break; |
|
363 | 363 | |
364 | - case 'view': |
|
365 | - // SAMPLE: Add BOINC data to the user profile |
|
366 | - /*$account->content['summary']['boinc_id'] = array( |
|
364 | +case 'view': |
|
365 | +// SAMPLE: Add BOINC data to the user profile |
|
366 | +/*$account->content['summary']['boinc_id'] = array( |
|
367 | 367 | '#type' => 'user_profile_item', |
368 | 368 | '#title' => bts('BIONC ID'), |
369 | 369 | '#value' => $account->boincuser_id, |
@@ -377,149 +377,149 @@ discard block |
||
377 | 377 | '#attributes' => array('class' => 'boinc-data'), |
378 | 378 | '#weight' => 10 |
379 | 379 | );*/ |
380 | - break; |
|
380 | +break; |
|
381 | 381 | |
382 | - case 'validate': |
|
383 | - if (isset($edit['validation_source'])) { |
|
384 | - switch ($edit['validation_source']) { |
|
385 | - case 'user_account': |
|
386 | - // Validate data before updating user account info |
|
387 | - boincuser_account_validate($edit, $account); |
|
388 | - break; |
|
382 | +case 'validate': |
|
383 | +if (isset($edit['validation_source'])) { |
|
384 | +switch ($edit['validation_source']) { |
|
385 | +case 'user_account': |
|
386 | +// Validate data before updating user account info |
|
387 | +boincuser_account_validate($edit, $account); |
|
388 | +break; |
|
389 | 389 | |
390 | - default: |
|
390 | +default: |
|
391 | 391 | |
392 | - } |
|
393 | - // We don't want to save validation source, so remove it |
|
394 | - $edit['validation_source'] = null; |
|
395 | - } |
|
396 | - break; |
|
392 | +} |
|
393 | + // We don't want to save validation source, so remove it |
|
394 | + $edit['validation_source'] = null; |
|
395 | + } |
|
396 | + break; |
|
397 | 397 | |
398 | - case 'insert': |
|
399 | - // New user being added to the system |
|
400 | - $imported = $_SESSION['importedUser']; |
|
401 | - unset($_SESSION['importedUser']); |
|
398 | +case 'insert': |
|
399 | + // New user being added to the system |
|
400 | + $imported = $_SESSION['importedUser']; |
|
401 | + unset($_SESSION['importedUser']); |
|
402 | 402 | |
403 | - watchdog( |
|
404 | - 'boincuser', |
|
405 | - 'Creating user account for %email_addr', |
|
406 | - array('%email_addr' => $edit['mail']), |
|
407 | - WATCHDOG_NOTICE |
|
408 | - ); |
|
403 | + watchdog( |
|
404 | + 'boincuser', |
|
405 | + 'Creating user account for %email_addr', |
|
406 | + array('%email_addr' => $edit['mail']), |
|
407 | + WATCHDOG_NOTICE |
|
408 | + ); |
|
409 | 409 | |
410 | - // The create_acount RPC will call this block of code when |
|
411 | - // user_save() is used. If user is registering using the Web |
|
412 | - // registration form, create a BOINC user and relationships. |
|
413 | - // Create a BOINC account unless importing from BOINC. |
|
414 | - if (!$imported) { |
|
415 | - |
|
416 | - if ($edit['boincuser_name']) { |
|
417 | - $myname = $edit['boincuser_name']; |
|
418 | - } |
|
419 | - else if ($edit['name']) { |
|
420 | - $myname = $edit['name']; |
|
421 | - } |
|
422 | - else { |
|
423 | - $myname = 'noname'; |
|
424 | - } |
|
410 | + // The create_acount RPC will call this block of code when |
|
411 | + // user_save() is used. If user is registering using the Web |
|
412 | + // registration form, create a BOINC user and relationships. |
|
413 | + // Create a BOINC account unless importing from BOINC. |
|
414 | + if (!$imported) { |
|
415 | + |
|
416 | + if ($edit['boincuser_name']) { |
|
417 | + $myname = $edit['boincuser_name']; |
|
418 | + } |
|
419 | + else if ($edit['name']) { |
|
420 | + $myname = $edit['name']; |
|
421 | + } |
|
422 | + else { |
|
423 | + $myname = 'noname'; |
|
424 | + } |
|
425 | 425 | |
426 | - $user_params = array( |
|
427 | - 'email_addr' => $edit['mail'], |
|
428 | - 'name' => $myname, |
|
429 | - 'passwd_hash' => password_hash( md5($edit['pass'].$edit['mail']) , PASSWORD_DEFAULT ), |
|
430 | - ); |
|
431 | - $boinc_user = boincuser_register_make_user($user_params); |
|
432 | - if (!$boinc_user) { |
|
433 | - // Account exists with this email addr |
|
434 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
435 | - return; |
|
436 | - } |
|
426 | + $user_params = array( |
|
427 | + 'email_addr' => $edit['mail'], |
|
428 | + 'name' => $myname, |
|
429 | + 'passwd_hash' => password_hash( md5($edit['pass'].$edit['mail']) , PASSWORD_DEFAULT ), |
|
430 | + ); |
|
431 | + $boinc_user = boincuser_register_make_user($user_params); |
|
432 | + if (!$boinc_user) { |
|
433 | + // Account exists with this email addr |
|
434 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
435 | + return; |
|
436 | + } |
|
437 | 437 | |
438 | - // Add user to community role by default (not banned) |
|
439 | - $unrestricted_role = array_search('community member', user_roles(true)); |
|
440 | - $edit['roles'] = array( |
|
441 | - $unrestricted_role => '' |
|
442 | - ); |
|
438 | + // Add user to community role by default (not banned) |
|
439 | + $unrestricted_role = array_search('community member', user_roles(true)); |
|
440 | + $edit['roles'] = array( |
|
441 | + $unrestricted_role => '' |
|
442 | + ); |
|
443 | 443 | |
444 | - // Disable show_hosts flag, set to TRUE by default |
|
445 | - db_set_active('boinc_rw'); |
|
446 | - db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
447 | - db_set_active('default'); |
|
444 | + // Disable show_hosts flag, set to TRUE by default |
|
445 | + db_set_active('boinc_rw'); |
|
446 | + db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
447 | + db_set_active('default'); |
|
448 | 448 | |
449 | - // Cross reference Drupal account with BOINC |
|
450 | - $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
451 | - if (!$reference) { |
|
452 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
453 | - return; |
|
454 | - } |
|
449 | + // Cross reference Drupal account with BOINC |
|
450 | + $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
451 | + if (!$reference) { |
|
452 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
453 | + return; |
|
454 | + } |
|
455 | 455 | |
456 | - // if terms of use exist, the user must agree. |
|
457 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
458 | - if (!empty($termsofuse)) { |
|
459 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
460 | - } |
|
456 | + // if terms of use exist, the user must agree. |
|
457 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
458 | + if (!empty($termsofuse)) { |
|
459 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
460 | + } |
|
461 | 461 | |
462 | - // Don't save custom fields to the Drupal user object |
|
463 | - $edit['boincuser_name'] = null; |
|
464 | - } |
|
465 | - break; |
|
462 | + // Don't save custom fields to the Drupal user object |
|
463 | + $edit['boincuser_name'] = null; |
|
464 | + } |
|
465 | + break; |
|
466 | 466 | |
467 | - case 'update': |
|
468 | - if (isset($edit['update_source'])) { |
|
469 | - require_boinc('boinc_db'); |
|
470 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
471 | - switch ($edit['update_source']) { |
|
472 | - case 'user_account': |
|
473 | - // Ensure that BOINC data is altered |
|
474 | - |
|
475 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
476 | - $changing_pass = ($edit['pass']) ? true : false; |
|
477 | - if ($changing_email OR $changing_pass) { |
|
478 | - // Set password hash appropriately |
|
479 | - $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
480 | - $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
|
481 | - $email_addr = $edit['mail']; |
|
482 | - |
|
483 | - // Algorithm for changing email and/or password |
|
484 | - if ($changing_email) { |
|
485 | - // locally store current email to set as previous email |
|
486 | - $prev_email = $account->mail; |
|
487 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
488 | - $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
489 | - } |
|
490 | - else { |
|
491 | - $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
|
492 | - } |
|
493 | - |
|
494 | - // Update user account information |
|
495 | - $result = $boinc_user->update($querypart); |
|
496 | - |
|
497 | - if ($changing_email) { |
|
498 | - // reload account |
|
499 | - $account = user_load($account->uid); |
|
500 | - _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users')); |
|
501 | - } |
|
502 | - } |
|
503 | - |
|
504 | - // Change boinc username |
|
505 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
506 | - $boincuser_name = $edit['boincuser_name']; |
|
507 | - $result = $boinc_user->update( |
|
508 | - "name='{$boincuser_name}'" |
|
509 | - ); |
|
510 | - } |
|
511 | - |
|
512 | - break; |
|
513 | - case 'user_profile': |
|
514 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
515 | - $boincuser_name = $edit['boincuser_name']; |
|
516 | - $result = $boinc_user->update( |
|
517 | - "name='{$boincuser_name}'" |
|
518 | - ); |
|
519 | - } |
|
520 | - break; |
|
521 | - default: |
|
522 | - } |
|
467 | +case 'update': |
|
468 | + if (isset($edit['update_source'])) { |
|
469 | + require_boinc('boinc_db'); |
|
470 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
471 | + switch ($edit['update_source']) { |
|
472 | + case 'user_account': |
|
473 | + // Ensure that BOINC data is altered |
|
474 | + |
|
475 | + $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
476 | + $changing_pass = ($edit['pass']) ? true : false; |
|
477 | + if ($changing_email OR $changing_pass) { |
|
478 | + // Set password hash appropriately |
|
479 | + $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
480 | + $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
|
481 | + $email_addr = $edit['mail']; |
|
482 | + |
|
483 | + // Algorithm for changing email and/or password |
|
484 | + if ($changing_email) { |
|
485 | + // locally store current email to set as previous email |
|
486 | + $prev_email = $account->mail; |
|
487 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
488 | + $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
489 | + } |
|
490 | + else { |
|
491 | + $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
|
492 | + } |
|
493 | + |
|
494 | + // Update user account information |
|
495 | + $result = $boinc_user->update($querypart); |
|
496 | + |
|
497 | + if ($changing_email) { |
|
498 | + // reload account |
|
499 | + $account = user_load($account->uid); |
|
500 | + _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users')); |
|
501 | + } |
|
502 | + } |
|
503 | + |
|
504 | + // Change boinc username |
|
505 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
506 | + $boincuser_name = $edit['boincuser_name']; |
|
507 | + $result = $boinc_user->update( |
|
508 | + "name='{$boincuser_name}'" |
|
509 | + ); |
|
510 | + } |
|
511 | + |
|
512 | + break; |
|
513 | + case 'user_profile': |
|
514 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
515 | + $boincuser_name = $edit['boincuser_name']; |
|
516 | + $result = $boinc_user->update( |
|
517 | + "name='{$boincuser_name}'" |
|
518 | + ); |
|
519 | + } |
|
520 | + break; |
|
521 | + default: |
|
522 | + } |
|
523 | 523 | // We don't want to save update source or duplicate custom fields, so |
524 | 524 | // remove them before continuing to core Drupal routines |
525 | 525 | $edit['update_source'] = null; |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | } |
528 | 528 | break; |
529 | 529 | |
530 | - case 'login': |
|
531 | - // Function is forward compatible to Drupal 7 |
|
532 | - boincuser_user_login($edit, $account); |
|
533 | - break; |
|
530 | +case 'login': |
|
531 | + // Function is forward compatible to Drupal 7 |
|
532 | + boincuser_user_login($edit, $account); |
|
533 | + break; |
|
534 | 534 | |
535 | - case 'delete': |
|
536 | - // Function is forward compatible to Drupal 7 |
|
537 | - boincuser_user_delete($account); |
|
538 | - break; |
|
535 | +case 'delete': |
|
536 | + // Function is forward compatible to Drupal 7 |
|
537 | + boincuser_user_delete($account); |
|
538 | + break; |
|
539 | 539 | |
540 | - default: |
|
540 | +default: |
|
541 | 541 | |
542 | 542 | } |
543 | 543 | } |