@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | if ($disable_account_creation || defined('INVITE_CODES')) { |
89 | - echo " <account_creation_disabled/>\n"; |
|
89 | + echo " <account_creation_disabled/>\n"; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | if (defined('INVITE_CODES')) { |
93 | - echo " <invite_code_required/>\n"; |
|
93 | + echo " <invite_code_required/>\n"; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | echo " <min_passwd_length>$min_passwd_length</min_passwd_length>\n"; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | // the terms_of_use.txt file in the project base directory. |
114 | 114 | // |
115 | 115 | if (defined('TERMSOFUSE_FILE')) { |
116 | - $tou_file = TERMSOFUSE_FILE; |
|
116 | + $tou_file = TERMSOFUSE_FILE; |
|
117 | 117 | } else { |
118 | - $tou_file = "../../terms_of_use.txt"; |
|
118 | + $tou_file = "../../terms_of_use.txt"; |
|
119 | 119 | } |
120 | 120 | if (file_exists($tou_file)) { |
121 | 121 | $terms_of_use = trim(file_get_contents($tou_file)); |
@@ -4,152 +4,152 @@ |
||
4 | 4 | * Implementation of hook_ctools_plugin_api(). |
5 | 5 | */ |
6 | 6 | function teams_ctools_plugin_api() { |
7 | - list($module, $api) = func_get_args(); |
|
8 | - if ($module == "page_manager" && $api == "pages_default") { |
|
7 | + list($module, $api) = func_get_args(); |
|
8 | + if ($module == "page_manager" && $api == "pages_default") { |
|
9 | 9 | return array("version" => 1); |
10 | - } |
|
11 | - elseif ($module == "strongarm" && $api == "strongarm") { |
|
10 | + } |
|
11 | + elseif ($module == "strongarm" && $api == "strongarm") { |
|
12 | 12 | return array("version" => 1); |
13 | - } |
|
13 | + } |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Implementation of hook_node_info(). |
18 | 18 | */ |
19 | 19 | function teams_node_info() { |
20 | - $items = array( |
|
20 | + $items = array( |
|
21 | 21 | 'team' => array( |
22 | - 'name' => t('Team'), |
|
23 | - 'module' => 'features', |
|
24 | - 'description' => t('A grouping of users, centered on a common interest.'), |
|
25 | - 'has_title' => '1', |
|
26 | - 'title_label' => t('Name'), |
|
27 | - 'has_body' => '1', |
|
28 | - 'body_label' => t('Description'), |
|
29 | - 'min_word_count' => '0', |
|
30 | - 'help' => '', |
|
22 | + 'name' => t('Team'), |
|
23 | + 'module' => 'features', |
|
24 | + 'description' => t('A grouping of users, centered on a common interest.'), |
|
25 | + 'has_title' => '1', |
|
26 | + 'title_label' => t('Name'), |
|
27 | + 'has_body' => '1', |
|
28 | + 'body_label' => t('Description'), |
|
29 | + 'min_word_count' => '0', |
|
30 | + 'help' => '', |
|
31 | 31 | ), |
32 | - ); |
|
33 | - return $items; |
|
32 | + ); |
|
33 | + return $items; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Implementation of hook_rules_defaults(). |
38 | 38 | */ |
39 | 39 | function teams_rules_defaults() { |
40 | - return array( |
|
40 | + return array( |
|
41 | 41 | 'rules' => array( |
42 | - 'rules_notify_admins_about_error_creating_a_boinc_team' => array( |
|
42 | + 'rules_notify_admins_about_error_creating_a_boinc_team' => array( |
|
43 | 43 | '#type' => 'rule', |
44 | 44 | '#set' => 'event_boincteam_create_team_error', |
45 | 45 | '#label' => 'Notify admins about error creating a BOINC team', |
46 | 46 | '#active' => 1, |
47 | 47 | '#weight' => '0', |
48 | 48 | '#categories' => array( |
49 | - '0' => 'boinc_team', |
|
50 | - 'teams' => 'teams', |
|
49 | + '0' => 'boinc_team', |
|
50 | + 'teams' => 'teams', |
|
51 | 51 | ), |
52 | 52 | '#status' => 'default', |
53 | 53 | '#conditions' => array(), |
54 | 54 | '#actions' => array( |
55 | - '0' => array( |
|
55 | + '0' => array( |
|
56 | 56 | '#type' => 'action', |
57 | 57 | '#settings' => array( |
58 | - 'from' => '', |
|
59 | - 'subject' => '[subject_tag:string] Error creating new team', |
|
60 | - 'message' => '[user:display-name] attempted to create team [team_name:string], but an error was returned. See function \'boincteam_create_form_submit\'. BOINC function \'make_team\' did not return a valid boinc_team object.', |
|
61 | - '#eval input' => array( |
|
58 | + 'from' => '', |
|
59 | + 'subject' => '[subject_tag:string] Error creating new team', |
|
60 | + 'message' => '[user:display-name] attempted to create team [team_name:string], but an error was returned. See function \'boincteam_create_form_submit\'. BOINC function \'make_team\' did not return a valid boinc_team object.', |
|
61 | + '#eval input' => array( |
|
62 | 62 | 'token_rules_input_evaluator' => array( |
63 | - 'subject' => array( |
|
63 | + 'subject' => array( |
|
64 | 64 | '0' => 'subject_tag', |
65 | 65 | '1' => ':global', |
66 | - ), |
|
67 | - 'message' => array( |
|
66 | + ), |
|
67 | + 'message' => array( |
|
68 | 68 | '0' => 'team_name', |
69 | 69 | '1' => 'user', |
70 | 70 | '2' => ':global', |
71 | - ), |
|
72 | - 'from' => array( |
|
71 | + ), |
|
72 | + 'from' => array( |
|
73 | 73 | '0' => ':global', |
74 | - ), |
|
74 | + ), |
|
75 | + ), |
|
75 | 76 | ), |
76 | - ), |
|
77 | 77 | ), |
78 | 78 | '#name' => 'boinccore_rules_action_mail_to_admins', |
79 | 79 | '#info' => array( |
80 | - 'label' => 'Notify admins via email', |
|
81 | - 'module' => 'BOINC core', |
|
82 | - 'eval input' => array( |
|
80 | + 'label' => 'Notify admins via email', |
|
81 | + 'module' => 'BOINC core', |
|
82 | + 'eval input' => array( |
|
83 | 83 | '0' => 'subject', |
84 | 84 | '1' => 'message', |
85 | 85 | '2' => 'from', |
86 | - ), |
|
86 | + ), |
|
87 | 87 | ), |
88 | 88 | '#weight' => 0.0, |
89 | - ), |
|
89 | + ), |
|
90 | 90 | ), |
91 | 91 | '#version' => 6003, |
92 | - ), |
|
93 | - 'rules_notify_admins_about_error_creating_a_boinc_team_no_pathauto' => array( |
|
92 | + ), |
|
93 | + 'rules_notify_admins_about_error_creating_a_boinc_team_no_pathauto' => array( |
|
94 | 94 | '#type' => 'rule', |
95 | 95 | '#set' => 'event_boincteam_create_team_nopathauto_error', |
96 | 96 | '#label' => 'Notify admins about error creating a BOINC team no pathauto', |
97 | 97 | '#active' => 1, |
98 | 98 | '#weight' => '0', |
99 | 99 | '#categories' => array( |
100 | - '0' => 'boinc_team', |
|
101 | - 'teams' => 'teams', |
|
100 | + '0' => 'boinc_team', |
|
101 | + 'teams' => 'teams', |
|
102 | 102 | ), |
103 | 103 | '#status' => 'default', |
104 | 104 | '#conditions' => array(), |
105 | 105 | '#actions' => array( |
106 | - '0' => array( |
|
106 | + '0' => array( |
|
107 | 107 | '#type' => 'action', |
108 | 108 | '#settings' => array( |
109 | - 'from' => '', |
|
110 | - 'subject' => '[subject_tag:string] Error creating BOINC team - no pathauo module', |
|
111 | - 'message' => '[user:display-name] attempted to create team [team_name:string], but no pathauto module detected. See function \'boincteam_create_form_submit\'.', |
|
112 | - '#eval input' => array( |
|
109 | + 'from' => '', |
|
110 | + 'subject' => '[subject_tag:string] Error creating BOINC team - no pathauo module', |
|
111 | + 'message' => '[user:display-name] attempted to create team [team_name:string], but no pathauto module detected. See function \'boincteam_create_form_submit\'.', |
|
112 | + '#eval input' => array( |
|
113 | 113 | 'token_rules_input_evaluator' => array( |
114 | - 'subject' => array( |
|
114 | + 'subject' => array( |
|
115 | 115 | '0' => 'subject_tag', |
116 | 116 | '1' => ':global', |
117 | - ), |
|
118 | - 'message' => array( |
|
117 | + ), |
|
118 | + 'message' => array( |
|
119 | 119 | '0' => 'team_name', |
120 | 120 | '1' => 'user', |
121 | 121 | '2' => ':global', |
122 | - ), |
|
123 | - 'from' => array( |
|
122 | + ), |
|
123 | + 'from' => array( |
|
124 | 124 | '0' => ':global', |
125 | - ), |
|
125 | + ), |
|
126 | + ), |
|
126 | 127 | ), |
127 | - ), |
|
128 | 128 | ), |
129 | 129 | '#name' => 'boinccore_rules_action_mail_to_admins', |
130 | 130 | '#info' => array( |
131 | - 'label' => 'Notify admins via email', |
|
132 | - 'module' => 'BOINC core', |
|
133 | - 'eval input' => array( |
|
131 | + 'label' => 'Notify admins via email', |
|
132 | + 'module' => 'BOINC core', |
|
133 | + 'eval input' => array( |
|
134 | 134 | '0' => 'subject', |
135 | 135 | '1' => 'message', |
136 | 136 | '2' => 'from', |
137 | - ), |
|
137 | + ), |
|
138 | 138 | ), |
139 | 139 | '#weight' => 0.0, |
140 | - ), |
|
140 | + ), |
|
141 | 141 | ), |
142 | 142 | '#version' => 6003, |
143 | - ), |
|
143 | + ), |
|
144 | 144 | ), |
145 | - ); |
|
145 | + ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Implementation of hook_views_api(). |
150 | 150 | */ |
151 | 151 | function teams_views_api() { |
152 | - return array( |
|
152 | + return array( |
|
153 | 153 | 'api' => '2', |
154 | - ); |
|
154 | + ); |
|
155 | 155 | } |
@@ -16,39 +16,39 @@ |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | function boincteam_rules_event_info() { |
19 | - return array( |
|
19 | + return array( |
|
20 | 20 | 'boincteam_create_team_error' => array( |
21 | - 'label' => bts('Error creating a new BOINC team - general error.', array(), NULL, 'boinc:rule-event'), |
|
22 | - 'module' => 'Boincteam', |
|
23 | - 'arguments' => rules_events_hook_boincteam_arguments(), |
|
21 | + 'label' => bts('Error creating a new BOINC team - general error.', array(), NULL, 'boinc:rule-event'), |
|
22 | + 'module' => 'Boincteam', |
|
23 | + 'arguments' => rules_events_hook_boincteam_arguments(), |
|
24 | 24 | ), |
25 | 25 | 'boincteam_create_team_nopathauto_error' => array( |
26 | - 'label' => bts('Error creating a new BOINC team - no pathauto module.', array(), NULL, 'boinc:rule-event'), |
|
27 | - 'module' => 'Boincteam', |
|
28 | - 'arguments' => rules_events_hook_boincteam_arguments(), |
|
26 | + 'label' => bts('Error creating a new BOINC team - no pathauto module.', array(), NULL, 'boinc:rule-event'), |
|
27 | + 'module' => 'Boincteam', |
|
28 | + 'arguments' => rules_events_hook_boincteam_arguments(), |
|
29 | 29 | ), |
30 | - ); |
|
30 | + ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Arguments suitable for boincteam |
35 | 35 | **/ |
36 | 36 | function rules_events_hook_boincteam_arguments() { |
37 | - return array( |
|
37 | + return array( |
|
38 | 38 | 'team_name' => array( |
39 | - 'type' => 'string', |
|
40 | - 'label' => 'team name', |
|
41 | - 'required' => TRUE, |
|
39 | + 'type' => 'string', |
|
40 | + 'label' => 'team name', |
|
41 | + 'required' => TRUE, |
|
42 | 42 | ), |
43 | - ) + rules_events_hook_boincteam_adminnotify_argument(); |
|
43 | + ) + rules_events_hook_boincteam_adminnotify_argument(); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function rules_events_hook_boincteam_adminnotify_argument() { |
47 | - return array( |
|
47 | + return array( |
|
48 | 48 | 'subject_tag' => array( |
49 | - 'type' => 'string', |
|
50 | - 'label' => 'Subject tag for email filtering', |
|
51 | - 'required' => TRUE, |
|
49 | + 'type' => 'string', |
|
50 | + 'label' => 'Subject tag for email filtering', |
|
51 | + 'required' => TRUE, |
|
52 | 52 | ), |
53 | - ) + rules_events_global_user_argument(); |
|
53 | + ) + rules_events_global_user_argument(); |
|
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -16,59 +16,59 @@ |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | function boincuser_rules_event_info() { |
19 | - return array( |
|
19 | + return array( |
|
20 | 20 | 'boincuser_change_email_error' => array( |
21 | - 'label' => bts('Error from user changing e-mail address.', array(), NULL, 'boinc:rule-event'), |
|
22 | - 'module' => 'Boincuser', |
|
23 | - 'arguments' => rules_events_hook_boincuser_chemail_arguments(), |
|
21 | + 'label' => bts('Error from user changing e-mail address.', array(), NULL, 'boinc:rule-event'), |
|
22 | + 'module' => 'Boincuser', |
|
23 | + 'arguments' => rules_events_hook_boincuser_chemail_arguments(), |
|
24 | 24 | ), |
25 | 25 | 'boincuser_revert_email_error' => array( |
26 | - 'label' => bts('Error from user reverting to previous e-mail address.', array(), NULL, 'boinc:rule-event'), |
|
27 | - 'module' => 'Boincuser', |
|
28 | - 'arguments' => rules_events_hook_boincuser_chemail_arguments(), |
|
26 | + 'label' => bts('Error from user reverting to previous e-mail address.', array(), NULL, 'boinc:rule-event'), |
|
27 | + 'module' => 'Boincuser', |
|
28 | + 'arguments' => rules_events_hook_boincuser_chemail_arguments(), |
|
29 | 29 | ), |
30 | 30 | 'boincuser_general_consent_error' => array( |
31 | - 'label' => bts('Error from user consenting to terms-of-use.', array(), NULL, 'boinc:rule-event'), |
|
32 | - 'module' => 'Boincuser', |
|
33 | - 'arguments' => rules_events_hook_boincuser_adminnotify_argument(), |
|
31 | + 'label' => bts('Error from user consenting to terms-of-use.', array(), NULL, 'boinc:rule-event'), |
|
32 | + 'module' => 'Boincuser', |
|
33 | + 'arguments' => rules_events_hook_boincuser_adminnotify_argument(), |
|
34 | 34 | ), |
35 | 35 | 'boincuser_general_consent_type_error' => array( |
36 | - 'label' => bts('Error dealing with missing consent type.', array(), NULL, 'boinc:rule-event'), |
|
37 | - 'module' => 'Boincuser', |
|
38 | - 'arguments' => rules_events_hook_boincuser_consenttype_argument(), |
|
36 | + 'label' => bts('Error dealing with missing consent type.', array(), NULL, 'boinc:rule-event'), |
|
37 | + 'module' => 'Boincuser', |
|
38 | + 'arguments' => rules_events_hook_boincuser_consenttype_argument(), |
|
39 | 39 | ), |
40 | - ); |
|
40 | + ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Arguments suitable for boincuser |
45 | 45 | **/ |
46 | 46 | function rules_events_hook_boincuser_chemail_arguments() { |
47 | - return array( |
|
47 | + return array( |
|
48 | 48 | 'new_email_addr' => array( |
49 | - 'type' => 'string', |
|
50 | - 'label' => 'New email address', |
|
51 | - 'required' => TRUE, |
|
49 | + 'type' => 'string', |
|
50 | + 'label' => 'New email address', |
|
51 | + 'required' => TRUE, |
|
52 | 52 | ), |
53 | - ) + rules_events_hook_boincuser_adminnotify_argument(); |
|
53 | + ) + rules_events_hook_boincuser_adminnotify_argument(); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function rules_events_hook_boincuser_consenttype_argument() { |
57 | - return array( |
|
57 | + return array( |
|
58 | 58 | 'consent_type' => array( |
59 | - 'type' => 'string', |
|
60 | - 'label' => 'Consent type id that caused the error', |
|
61 | - 'required' => TRUE, |
|
59 | + 'type' => 'string', |
|
60 | + 'label' => 'Consent type id that caused the error', |
|
61 | + 'required' => TRUE, |
|
62 | 62 | ), |
63 | - ) + rules_events_hook_boincuser_adminnotify_argument(); |
|
63 | + ) + rules_events_hook_boincuser_adminnotify_argument(); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function rules_events_hook_boincuser_adminnotify_argument() { |
67 | - return array( |
|
67 | + return array( |
|
68 | 68 | 'subject_tag' => array( |
69 | - 'type' => 'string', |
|
70 | - 'label' => 'Subject tag for email filtering', |
|
71 | - 'required' => TRUE, |
|
69 | + 'type' => 'string', |
|
70 | + 'label' => 'Subject tag for email filtering', |
|
71 | + 'required' => TRUE, |
|
72 | 72 | ), |
73 | - ) + rules_events_global_user_argument(); |
|
73 | + ) + rules_events_global_user_argument(); |
|
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | * Implementation of hook_perm(). |
21 | 21 | */ |
22 | 22 | function boincuser_delete_perm() { |
23 | - return array('delete own account'); |
|
23 | + return array('delete own account'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Implementation of hook_menu(). |
28 | 28 | */ |
29 | 29 | function boincuser_delete_menu() { |
30 | - $items = array(); |
|
31 | - $items['admin/boinc/user_delete'] = array( |
|
30 | + $items = array(); |
|
31 | + $items['admin/boinc/user_delete'] = array( |
|
32 | 32 | 'title' => t('Preferences: BOINC user delete'), |
33 | 33 | 'description' => t('Configure the BOINC user delete action.'), |
34 | 34 | 'page callback' => 'drupal_get_form', |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | 'access arguments' => array('administer users'), |
37 | 37 | 'type' => MENU_NORMAL_ITEM, |
38 | 38 | 'file' => 'boincuser_delete.admin.inc', |
39 | - ); |
|
39 | + ); |
|
40 | 40 | |
41 | - $items['admin/boinc/user_delete/%'] = array( |
|
41 | + $items['admin/boinc/user_delete/%'] = array( |
|
42 | 42 | 'title' => t('Admin delete user'), |
43 | 43 | 'description' => t('Deletes a user as an admin'), |
44 | 44 | 'page callback' => 'drupal_get_form', |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | 'access arguments' => array('administer users'), |
47 | 47 | 'type' => MENU_CALLBACK, |
48 | 48 | 'file' => 'boincuser_delete.admin.inc', |
49 | - ); |
|
49 | + ); |
|
50 | 50 | |
51 | - $items['user/%user/deleteconfirm/%'] = array( |
|
51 | + $items['user/%user/deleteconfirm/%'] = array( |
|
52 | 52 | 'title' => t('Final confirmation for account deletion'), |
53 | 53 | 'description' => t('Final confirmation for account deletion'), |
54 | 54 | 'page callback' => 'drupal_get_form', |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | 'access callback' => 'boincuser_delete_access', |
57 | 57 | 'access arguments' => array(1), |
58 | 58 | 'type' => MENU_CALLBACK, |
59 | - ); |
|
59 | + ); |
|
60 | 60 | |
61 | - $items['user/%user/odeleteconfirm/%'] = array( |
|
61 | + $items['user/%user/odeleteconfirm/%'] = array( |
|
62 | 62 | 'title' => t('Final confirmation for account deletion'), |
63 | 63 | 'description' => t('Final confirmation for account deletion'), |
64 | 64 | 'page callback' => 'drupal_get_form', |
@@ -66,204 +66,204 @@ discard block |
||
66 | 66 | 'access callback' => 'boincuser_delete_access', |
67 | 67 | 'access arguments' => array(1), |
68 | 68 | 'type' => MENU_CALLBACK, |
69 | - ); |
|
69 | + ); |
|
70 | 70 | |
71 | - return $items; |
|
71 | + return $items; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Checks whether a user can delete an account. |
76 | 76 | */ |
77 | 77 | function boincuser_delete_access($account) { |
78 | - global $user; |
|
79 | - return ((user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) && $account->uid > 0); |
|
78 | + global $user; |
|
79 | + return ((user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) && $account->uid > 0); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Implementation of hook_menu_alter(). |
84 | 84 | */ |
85 | 85 | function boincuser_delete_menu_alter(&$callbacks) { |
86 | - $callbacks['user/%user/delete']['access callback'] = 'boincuser_delete_access'; |
|
87 | - $callbacks['user/%user/delete']['access arguments'] = array(1); |
|
88 | - $callbacks['user/%user/delete']['type'] = MENU_CALLBACK; |
|
86 | + $callbacks['user/%user/delete']['access callback'] = 'boincuser_delete_access'; |
|
87 | + $callbacks['user/%user/delete']['access arguments'] = array(1); |
|
88 | + $callbacks['user/%user/delete']['type'] = MENU_CALLBACK; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Implementation of hook_form_alter(). |
93 | 93 | */ |
94 | 94 | function boincuser_delete_form_alter(&$form, $form_state, $form_id) { |
95 | - global $user; |
|
95 | + global $user; |
|
96 | 96 | |
97 | - switch($form_id) { |
|
97 | + switch($form_id) { |
|
98 | 98 | case 'user_profile_form': |
99 | 99 | if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
100 | 100 | $form['delete'] = array( |
101 | - '#type' => 'submit', |
|
102 | - '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
103 | - '#weight' => 1009, |
|
104 | - '#submit' => array('user_edit_delete_submit'), |
|
105 | - '#prefix' => '<li class="tab">', |
|
106 | - '#suffix' => '</li>', |
|
101 | + '#type' => 'submit', |
|
102 | + '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
103 | + '#weight' => 1009, |
|
104 | + '#submit' => array('user_edit_delete_submit'), |
|
105 | + '#prefix' => '<li class="tab">', |
|
106 | + '#suffix' => '</li>', |
|
107 | 107 | ); |
108 | - } |
|
109 | - else if ( user_access('administer users') ) { |
|
108 | + } |
|
109 | + else if ( user_access('administer users') ) { |
|
110 | 110 | $form['delete'] = array( |
111 | - '#type' => 'submit', |
|
112 | - '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
113 | - '#weight' => 1009, |
|
114 | - '#submit' => array('_boincuser_delete_goto_admindelete'), |
|
115 | - '#prefix' => '<li class="tab">', |
|
116 | - '#suffix' => '</li>', |
|
111 | + '#type' => 'submit', |
|
112 | + '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
113 | + '#weight' => 1009, |
|
114 | + '#submit' => array('_boincuser_delete_goto_admindelete'), |
|
115 | + '#prefix' => '<li class="tab">', |
|
116 | + '#suffix' => '</li>', |
|
117 | 117 | ); |
118 | - } |
|
119 | - else { |
|
118 | + } |
|
119 | + else { |
|
120 | 120 | unset($form['delete']); |
121 | - } |
|
122 | - break; |
|
121 | + } |
|
122 | + break; |
|
123 | 123 | case 'user_confirm_delete': |
124 | 124 | |
125 | 125 | $disable_delete = FALSE; |
126 | - // If email address was changed less than 7 days (7 * 86400 s) |
|
127 | - // ago, it cannot be changed again. |
|
128 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
129 | - if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) { |
|
126 | + // If email address was changed less than 7 days (7 * 86400 s) |
|
127 | + // ago, it cannot be changed again. |
|
128 | + $duration = TOKEN_DURATION_ONE_WEEK; |
|
129 | + if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) { |
|
130 | 130 | drupal_set_message( |
131 | - bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
131 | + bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
132 | 132 | array( |
133 | - '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
133 | + '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
134 | 134 | ), NULL, 'boinc:account-credentials-change') |
135 | 135 | , 'info'); |
136 | 136 | $disable_delete = TRUE; |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - // Configure radio options |
|
140 | - $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. 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'); |
|
139 | + // Configure radio options |
|
140 | + $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. 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 | 141 | |
142 | - $deleteoptions = array( |
|
142 | + $deleteoptions = array( |
|
143 | 143 | 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> your account. Your account will be disabled. ', array(), NULL, 'boinc:delete-user-account'), |
144 | 144 | 'boincuser_delete_delete' => bts('<b>Delete</b> your account. ', array(), NULL, 'boinc:delete-user-account'), |
145 | - ); |
|
145 | + ); |
|
146 | 146 | |
147 | - $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
148 | - // Unset the other option if dtype is set. i.e., if dtype is set |
|
149 | - // to soft delete, unset the hard delete option. Likewise, add |
|
150 | - // the 'common_acts' sentences to the option that remains. |
|
151 | - switch ($dtypes) { |
|
147 | + $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
148 | + // Unset the other option if dtype is set. i.e., if dtype is set |
|
149 | + // to soft delete, unset the hard delete option. Likewise, add |
|
150 | + // the 'common_acts' sentences to the option that remains. |
|
151 | + switch ($dtypes) { |
|
152 | 152 | case 'soft_obfuscate': |
153 | 153 | unset($deleteoptions['boincuser_delete_delete']); |
154 | - $deleteoptions['boincuser_delete_softdelete'] .= $common_acts; |
|
155 | - break; |
|
154 | + $deleteoptions['boincuser_delete_softdelete'] .= $common_acts; |
|
155 | + break; |
|
156 | 156 | case 'hard_wipe': |
157 | 157 | unset($deleteoptions['boincuser_delete_softdelete']); |
158 | - $deleteoptions['boincuser_delete_delete'] .= $common_acts; |
|
159 | - break; |
|
160 | - } |
|
158 | + $deleteoptions['boincuser_delete_delete'] .= $common_acts; |
|
159 | + break; |
|
160 | + } |
|
161 | 161 | |
162 | - $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
|
163 | - drupal_set_title($question); |
|
162 | + $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
|
163 | + drupal_set_title($question); |
|
164 | 164 | |
165 | - unset($form['description']); |
|
165 | + unset($form['description']); |
|
166 | 166 | |
167 | - $form['main'] = array( |
|
167 | + $form['main'] = array( |
|
168 | 168 | '#type' => 'fieldset', |
169 | 169 | '#weight' => 1, |
170 | - ); |
|
170 | + ); |
|
171 | 171 | |
172 | - $form['main']['fs1'] = array( |
|
172 | + $form['main']['fs1'] = array( |
|
173 | 173 | '#type' => 'fieldset', |
174 | 174 | '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
175 | 175 | '#weight' => 10, |
176 | 176 | '#collapsible' => TRUE, |
177 | 177 | '#collapsed' => TRUE, |
178 | - ); |
|
179 | - $form['main']['fs1']['help'] = array( |
|
178 | + ); |
|
179 | + $form['main']['fs1']['help'] = array( |
|
180 | 180 | '#value' => bts( |
181 | - "<p>In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" . |
|
182 | - "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>", |
|
183 | - array( |
|
181 | + "<p>In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" . |
|
182 | + "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>", |
|
183 | + array( |
|
184 | 184 | '!link' => l(bts('change your email address', array(), NULL, 'boinc:delete-user-account'), '/account/info/edit'), |
185 | - ), NULL, 'boinc:delete-user-account'), |
|
185 | + ), NULL, 'boinc:delete-user-account'), |
|
186 | 186 | '#weight' => 11, |
187 | 187 | '#prefix' => "<div id='delete-instructions'>", |
188 | 188 | '#suffix' => "</div>", |
189 | - ); |
|
189 | + ); |
|
190 | 190 | |
191 | - if ($dtypes == 'user_decides') { |
|
191 | + if ($dtypes == 'user_decides') { |
|
192 | 192 | $form['main']['common'] = array( |
193 | - '#value' => bts('All choices: ', array(), NULL, 'boinc:delete-user-account') . $common_acts . '<p>' . bts('Disabled means some of your personal data, such as your username and email address, are kept on our systems. Choose \'delete your account\' if you want all personal data to be removed.', array(), NULL, 'boinc:delete-user-account'), |
|
194 | - '#prefix' => "<div id='delete-instructions'>", |
|
195 | - '#suffix' => "</div>", |
|
196 | - '#weight' => 20, |
|
193 | + '#value' => bts('All choices: ', array(), NULL, 'boinc:delete-user-account') . $common_acts . '<p>' . bts('Disabled means some of your personal data, such as your username and email address, are kept on our systems. Choose \'delete your account\' if you want all personal data to be removed.', array(), NULL, 'boinc:delete-user-account'), |
|
194 | + '#prefix' => "<div id='delete-instructions'>", |
|
195 | + '#suffix' => "</div>", |
|
196 | + '#weight' => 20, |
|
197 | 197 | ); |
198 | - } |
|
198 | + } |
|
199 | 199 | |
200 | - $form['main']['user_delete_action'] = array( |
|
200 | + $form['main']['user_delete_action'] = array( |
|
201 | 201 | '#type' => 'radios', |
202 | 202 | '#options' => $deleteoptions, |
203 | 203 | '#weight' => 21, |
204 | - ); |
|
205 | - if ($disable_delete) { |
|
204 | + ); |
|
205 | + if ($disable_delete) { |
|
206 | 206 | $form['main']['user_delete_action']['#disabled'] = TRUE; |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - // Password field |
|
210 | - if (!$disable_delete) { |
|
209 | + // Password field |
|
210 | + if (!$disable_delete) { |
|
211 | 211 | $form['main']['current_pass'] = array( |
212 | - '#type' => 'password', |
|
213 | - '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
|
214 | - '#size' => 17, |
|
215 | - '#attributes' => array( |
|
212 | + '#type' => 'password', |
|
213 | + '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
|
214 | + '#size' => 17, |
|
215 | + '#attributes' => array( |
|
216 | 216 | 'autocomplete' => 'off', |
217 | - ), |
|
218 | - '#prefix' => "<div id='delete-password-field'>", |
|
219 | - '#suffix' => "</div>", |
|
220 | - '#weight' => 25, |
|
217 | + ), |
|
218 | + '#prefix' => "<div id='delete-password-field'>", |
|
219 | + '#suffix' => "</div>", |
|
220 | + '#weight' => 25, |
|
221 | 221 | ); |
222 | - } |
|
222 | + } |
|
223 | 223 | |
224 | - $form['separator_bottom'] = array( |
|
224 | + $form['separator_bottom'] = array( |
|
225 | 225 | '#value' => '<div class="separator buttons"></div>', |
226 | 226 | '#weight' => 999, |
227 | - ); |
|
227 | + ); |
|
228 | 228 | |
229 | - // Configure the action buttons |
|
230 | - $uid = $form['_account']['#value']->uid; |
|
231 | - $form['actions']['#weight'] = 1000; |
|
232 | - $form['actions']['form control tabs prefix'] = array( |
|
229 | + // Configure the action buttons |
|
230 | + $uid = $form['_account']['#value']->uid; |
|
231 | + $form['actions']['#weight'] = 1000; |
|
232 | + $form['actions']['form control tabs prefix'] = array( |
|
233 | 233 | '#value' => '<ul class="form-control tab-list">', |
234 | 234 | '#weight' => 1001, |
235 | - ); |
|
236 | - |
|
237 | - unset($form['actions']['#prefix']); |
|
238 | - unset($form['actions']['#suffix']); |
|
239 | - $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
|
240 | - $form['actions']['submit']['#suffix'] = '</li>'; |
|
241 | - $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
242 | - $form['actions']['submit']['#weight'] = 1002; |
|
243 | - if ($disable_delete) { |
|
235 | + ); |
|
236 | + |
|
237 | + unset($form['actions']['#prefix']); |
|
238 | + unset($form['actions']['#suffix']); |
|
239 | + $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
|
240 | + $form['actions']['submit']['#suffix'] = '</li>'; |
|
241 | + $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
242 | + $form['actions']['submit']['#weight'] = 1002; |
|
243 | + if ($disable_delete) { |
|
244 | 244 | $form['actions']['submit']['#disabled'] = TRUE; |
245 | 245 | $form['actions']['submit']['#value'] = ''; |
246 | - } |
|
246 | + } |
|
247 | 247 | |
248 | - $form['actions']['cancel']['#prefix'] = '<li class="tab">'; |
|
249 | - $form['actions']['cancel']['#suffix'] = '</li>'; |
|
250 | - $form['actions']['cancel']['#weight'] = 1003; |
|
251 | - $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit'); |
|
252 | - if ($disable_delete) { |
|
248 | + $form['actions']['cancel']['#prefix'] = '<li class="tab">'; |
|
249 | + $form['actions']['cancel']['#suffix'] = '</li>'; |
|
250 | + $form['actions']['cancel']['#weight'] = 1003; |
|
251 | + $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit'); |
|
252 | + if ($disable_delete) { |
|
253 | 253 | $form['actions']['cancel']['#prefix'] = '<li class="first tab">'; |
254 | - } |
|
254 | + } |
|
255 | 255 | |
256 | - $form['actions']['form control tabs suffix'] = array( |
|
256 | + $form['actions']['form control tabs suffix'] = array( |
|
257 | 257 | '#value' => '</ul>', |
258 | 258 | '#weight' => 1010, |
259 | - ); |
|
259 | + ); |
|
260 | 260 | |
261 | - $form['#redirect'] = 'account/' . $uid; |
|
262 | - $form['#validate'] = array('boincuser_delete_validate'); |
|
263 | - $form['#submit'] = array('boincuser_delete_submit'); |
|
264 | - break; |
|
261 | + $form['#redirect'] = 'account/' . $uid; |
|
262 | + $form['#validate'] = array('boincuser_delete_validate'); |
|
263 | + $form['#submit'] = array('boincuser_delete_submit'); |
|
264 | + break; |
|
265 | 265 | |
266 | - } // switch |
|
266 | + } // switch |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -274,29 +274,29 @@ discard block |
||
274 | 274 | * password. |
275 | 275 | */ |
276 | 276 | function boincuser_delete_validate($form, &$form_state) { |
277 | - require_boinc('boinc_db'); |
|
277 | + require_boinc('boinc_db'); |
|
278 | 278 | |
279 | - if ($form_state['values']['user_delete_action'] == '') { |
|
279 | + if ($form_state['values']['user_delete_action'] == '') { |
|
280 | 280 | form_set_error('user_delete_action', bts('Please select an action to perform using the radio buttons.', array(), NULL, 'boinc:delete-user-account')); |
281 | - } |
|
281 | + } |
|
282 | 282 | |
283 | - // check BOINC user exists |
|
284 | - $account = $form_state['values']['_account']; |
|
285 | - $boinc_user = boincuser_load($account->uid, TRUE); |
|
286 | - if (!$boinc_user) { |
|
283 | + // check BOINC user exists |
|
284 | + $account = $form_state['values']['_account']; |
|
285 | + $boinc_user = boincuser_load($account->uid, TRUE); |
|
286 | + if (!$boinc_user) { |
|
287 | 287 | rules_invoke_event('boincuser_delete_general_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
288 | 288 | return form_set_error('current_pass', |
289 | - bts('There was a problem deleting your account. The @project administrators have been contacted.', |
|
290 | - array( |
|
289 | + bts('There was a problem deleting your account. The @project administrators have been contacted.', |
|
290 | + array( |
|
291 | 291 | '@project' => variable_get('site_name', 'Drupal-BOINC'), |
292 | - ) |
|
293 | - , NULL, 'boinc:delete-user-account') |
|
292 | + ) |
|
293 | + , NULL, 'boinc:delete-user-account') |
|
294 | 294 | ); |
295 | - } |
|
295 | + } |
|
296 | 296 | |
297 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
297 | + if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
298 | 298 | return true; |
299 | - } |
|
299 | + } |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -307,46 +307,46 @@ discard block |
||
307 | 307 | * to delete the account. |
308 | 308 | */ |
309 | 309 | function boincuser_delete_submit($form, &$form_state) { |
310 | - require_boinc('token'); |
|
311 | - global $user; |
|
310 | + require_boinc('token'); |
|
311 | + global $user; |
|
312 | 312 | |
313 | - $uid = $form_state['values']['_account']->uid; |
|
314 | - $account = user_load(array('uid' => $uid)); |
|
313 | + $uid = $form_state['values']['_account']->uid; |
|
314 | + $account = user_load(array('uid' => $uid)); |
|
315 | 315 | |
316 | - if (!$account) { |
|
316 | + if (!$account) { |
|
317 | 317 | rules_invoke_event('boincuser_delete_uid_invalid_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
318 | 318 | drupal_set_message( |
319 | - bts('ERROR: The user account @uid does not exist. The @project administrators have been notified.', |
|
319 | + bts('ERROR: The user account @uid does not exist. The @project administrators have been notified.', |
|
320 | 320 | array( |
321 | - '@uid' => $uid, |
|
322 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
321 | + '@uid' => $uid, |
|
322 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
323 | 323 | ), NULL, 'delete-user-account'), |
324 | - 'error'); |
|
324 | + 'error'); |
|
325 | 325 | watchdog('user', 'Attempted to cancel non-existing user account UID: %uid.', array('%uid' => $uid), WATCHDOG_ERROR); |
326 | 326 | return; |
327 | - } |
|
328 | - |
|
329 | - global $base_url; |
|
330 | - global $base_path; |
|
331 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
332 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
333 | - $site_url = $base_url . $base_path . "user/login"; |
|
334 | - |
|
335 | - // Perform the requested operation |
|
336 | - $op = $form_state['values']['user_delete_action']; |
|
337 | - // create token with 1 day/24 hour expiration |
|
338 | - $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
|
339 | - switch ($op) { |
|
327 | + } |
|
328 | + |
|
329 | + global $base_url; |
|
330 | + global $base_path; |
|
331 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
332 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
333 | + $site_url = $base_url . $base_path . "user/login"; |
|
334 | + |
|
335 | + // Perform the requested operation |
|
336 | + $op = $form_state['values']['user_delete_action']; |
|
337 | + // create token with 1 day/24 hour expiration |
|
338 | + $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
|
339 | + switch ($op) { |
|
340 | 340 | case 'boincuser_delete_softdelete': |
341 | 341 | $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
342 | - break; |
|
342 | + break; |
|
343 | 343 | case 'boincuser_delete_delete': |
344 | 344 | $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
345 | - break; |
|
346 | - } |
|
345 | + break; |
|
346 | + } |
|
347 | 347 | |
348 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
349 | - $mymessage = '' |
|
348 | + $mysubject = "Instructions for account deletion at {$site_name}"; |
|
349 | + $mymessage = '' |
|
350 | 350 | . "{$account->boincuser_name},\n" |
351 | 351 | . "\n" |
352 | 352 | . "We have received a request to DELETE your user account at " |
@@ -368,25 +368,25 @@ discard block |
||
368 | 368 | . "\n" |
369 | 369 | . "{$site_name} support team"; |
370 | 370 | |
371 | - // Create array for sending email to user to notify account is being |
|
372 | - // disabled/deleted. Then send email. |
|
373 | - $settings = array( |
|
371 | + // Create array for sending email to user to notify account is being |
|
372 | + // disabled/deleted. Then send email. |
|
373 | + $settings = array( |
|
374 | 374 | 'from' => '', |
375 | 375 | 'subject' => $mysubject, |
376 | 376 | 'message' => $mymessage, |
377 | - ); |
|
378 | - rules_action_mail_to_user($account, $settings); |
|
377 | + ); |
|
378 | + rules_action_mail_to_user($account, $settings); |
|
379 | 379 | |
380 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
380 | + drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
381 | 381 | |
382 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
383 | - // Redirect |
|
384 | - if (!empty($redirect)) { |
|
382 | + $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
383 | + // Redirect |
|
384 | + if (!empty($redirect)) { |
|
385 | 385 | drupal_goto($redirect); |
386 | - } |
|
387 | - else { |
|
386 | + } |
|
387 | + else { |
|
388 | 388 | drupal_goto(); |
389 | - } |
|
389 | + } |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -398,88 +398,88 @@ discard block |
||
398 | 398 | * The final confirmation form for the user to delete their account. |
399 | 399 | */ |
400 | 400 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
401 | - require_boinc('token'); |
|
401 | + require_boinc('token'); |
|
402 | 402 | |
403 | - global $user; |
|
404 | - $form = array(); |
|
403 | + global $user; |
|
404 | + $form = array(); |
|
405 | 405 | |
406 | - // check BOINC user exists |
|
407 | - $account = user_load(array('uid' => $user->uid)); |
|
408 | - $uid = $user->uid; |
|
409 | - $boincid = $account->boincuser_id; |
|
410 | - // check $token is valid |
|
411 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
406 | + // check BOINC user exists |
|
407 | + $account = user_load(array('uid' => $user->uid)); |
|
408 | + $uid = $user->uid; |
|
409 | + $boincid = $account->boincuser_id; |
|
410 | + // check $token is valid |
|
411 | + if (!is_valid_token($boincid, $token, 'D')) { |
|
412 | 412 | 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.', |
413 | 413 | array( |
414 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
414 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
415 | 415 | ), |
416 | 416 | NULL, 'boinc:delete-user-account'), 'error'); |
417 | 417 | drupal_goto(); |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | - // Attach account to this form. |
|
421 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
420 | + // Attach account to this form. |
|
421 | + $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
422 | 422 | |
423 | - // This form is for hard/wipe delete |
|
424 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
423 | + // This form is for hard/wipe delete |
|
424 | + $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
425 | 425 | |
426 | - // Instructions |
|
427 | - $form['main']['fs1'] = array( |
|
426 | + // Instructions |
|
427 | + $form['main']['fs1'] = array( |
|
428 | 428 | '#type' => 'fieldset', |
429 | 429 | '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
430 | 430 | '#weight' => 10, |
431 | 431 | '#collapsible' => TRUE, |
432 | 432 | '#collapsed' => TRUE, |
433 | - ); |
|
434 | - $form['main']['fs1']['instructions1'] = array( |
|
433 | + ); |
|
434 | + $form['main']['fs1']['instructions1'] = array( |
|
435 | 435 | '#value' => '<p>'. |
436 | 436 | 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'). |
437 | 437 | '</p>', |
438 | 438 | '#prefix' => "<div id='delete-instructions'>", |
439 | 439 | '#suffix' => "</div>", |
440 | - ); |
|
440 | + ); |
|
441 | 441 | |
442 | - $form['main']['fs1']['instructions2'] = array( |
|
442 | + $form['main']['fs1']['instructions2'] = array( |
|
443 | 443 | '#value' => '<p>'. |
444 | 444 | bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
445 | 445 | '</p>', |
446 | 446 | '#prefix' => "<div id='delete-instructions'>", |
447 | 447 | '#suffix' => "</div>", |
448 | - ); |
|
448 | + ); |
|
449 | 449 | |
450 | - // Password field |
|
451 | - $form['main']['current_pass'] = array( |
|
450 | + // Password field |
|
451 | + $form['main']['current_pass'] = array( |
|
452 | 452 | '#type' => 'password', |
453 | 453 | '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
454 | 454 | '#size' => 17, |
455 | 455 | '#attributes' => array( |
456 | - 'autocomplete' => 'off', |
|
456 | + 'autocomplete' => 'off', |
|
457 | 457 | ), |
458 | 458 | '#weight' => 25, |
459 | - ); |
|
459 | + ); |
|
460 | 460 | |
461 | - // Form control |
|
462 | - $form['form control tabs prefix'] = array( |
|
461 | + // Form control |
|
462 | + $form['form control tabs prefix'] = array( |
|
463 | 463 | '#value' => '<ul class="form-control tab-list">', |
464 | 464 | '#weight' => 1001, |
465 | - ); |
|
466 | - $form['submit'] = array( |
|
465 | + ); |
|
466 | + $form['submit'] = array( |
|
467 | 467 | '#prefix' => '<li class="first tab">', |
468 | 468 | '#type' => 'submit', |
469 | 469 | '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
470 | 470 | '#suffix' => '</li>', |
471 | 471 | '#weight' => 1002, |
472 | - ); |
|
473 | - $form['form control tabs'] = array( |
|
472 | + ); |
|
473 | + $form['form control tabs'] = array( |
|
474 | 474 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
475 | 475 | '#weight' => 1003, |
476 | - ); |
|
477 | - $form['form control tabs suffix'] = array( |
|
476 | + ); |
|
477 | + $form['form control tabs suffix'] = array( |
|
478 | 478 | '#value' => '</ul>', |
479 | 479 | '#weight' => 1004, |
480 | - ); |
|
480 | + ); |
|
481 | 481 | |
482 | - return $form; |
|
482 | + return $form; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -487,133 +487,133 @@ discard block |
||
487 | 487 | * the soft/obfuscate method. |
488 | 488 | */ |
489 | 489 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
490 | - require_boinc('token'); |
|
490 | + require_boinc('token'); |
|
491 | 491 | |
492 | - global $user; |
|
493 | - $form = array(); |
|
492 | + global $user; |
|
493 | + $form = array(); |
|
494 | 494 | |
495 | - // check BOINC user exists |
|
496 | - $account = user_load(array('uid' => $user->uid)); |
|
497 | - $uid = $user->uid; |
|
498 | - $boincid = $account->boincuser_id; |
|
495 | + // check BOINC user exists |
|
496 | + $account = user_load(array('uid' => $user->uid)); |
|
497 | + $uid = $user->uid; |
|
498 | + $boincid = $account->boincuser_id; |
|
499 | 499 | |
500 | - // check $token is valid |
|
501 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
500 | + // check $token is valid |
|
501 | + if (!is_valid_token($boincid, $token, 'D')) { |
|
502 | 502 | 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.', |
503 | 503 | array( |
504 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
504 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
505 | 505 | ), |
506 | 506 | NULL, 'boinc:delete-user-account'), 'error'); |
507 | 507 | drupal_goto(); |
508 | - } |
|
508 | + } |
|
509 | 509 | |
510 | - // Attach account to this form. |
|
511 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
510 | + // Attach account to this form. |
|
511 | + $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
512 | 512 | |
513 | - // This form is for hard/wipe delete |
|
514 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
513 | + // This form is for hard/wipe delete |
|
514 | + $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
515 | 515 | |
516 | - // Instructions |
|
517 | - $form['main']['fs1'] = array( |
|
516 | + // Instructions |
|
517 | + $form['main']['fs1'] = array( |
|
518 | 518 | '#type' => 'fieldset', |
519 | 519 | '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
520 | 520 | '#weight' => 10, |
521 | 521 | '#collapsible' => TRUE, |
522 | 522 | '#collapsed' => TRUE, |
523 | - ); |
|
524 | - $form['main']['fs1']['instructions1'] = array( |
|
523 | + ); |
|
524 | + $form['main']['fs1']['instructions1'] = array( |
|
525 | 525 | '#value' => '<p>'. |
526 | 526 | 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'). |
527 | 527 | '</p>', |
528 | 528 | '#prefix' => "<div id='delete-instructions'>", |
529 | 529 | '#suffix' => "</div>", |
530 | - ); |
|
530 | + ); |
|
531 | 531 | |
532 | - $form['main']['fs1']['instructions2'] = array( |
|
532 | + $form['main']['fs1']['instructions2'] = array( |
|
533 | 533 | '#value' => '<p>'. |
534 | 534 | bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
535 | 535 | '</p>', |
536 | 536 | '#prefix' => "<div id='delete-instructions'>", |
537 | 537 | '#suffix' => "</div>", |
538 | - ); |
|
538 | + ); |
|
539 | 539 | |
540 | - // Password field |
|
541 | - $form['main']['current_pass'] = array( |
|
540 | + // Password field |
|
541 | + $form['main']['current_pass'] = array( |
|
542 | 542 | '#type' => 'password', |
543 | 543 | '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
544 | 544 | '#size' => 17, |
545 | 545 | '#attributes' => array( |
546 | - 'autocomplete' => 'off', |
|
546 | + 'autocomplete' => 'off', |
|
547 | 547 | ), |
548 | 548 | '#weight' => 25, |
549 | - ); |
|
549 | + ); |
|
550 | 550 | |
551 | - // Form control |
|
552 | - $form['form control tabs prefix'] = array( |
|
551 | + // Form control |
|
552 | + $form['form control tabs prefix'] = array( |
|
553 | 553 | '#value' => '<ul class="form-control tab-list">', |
554 | 554 | '#weight' => 1001, |
555 | - ); |
|
556 | - $form['submit'] = array( |
|
555 | + ); |
|
556 | + $form['submit'] = array( |
|
557 | 557 | '#prefix' => '<li class="first tab">', |
558 | 558 | '#type' => 'submit', |
559 | 559 | '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
560 | 560 | '#suffix' => '</li>', |
561 | 561 | '#weight' => 1002, |
562 | - ); |
|
563 | - $form['form control tabs'] = array( |
|
562 | + ); |
|
563 | + $form['form control tabs'] = array( |
|
564 | 564 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
565 | 565 | '#weight' => 1003, |
566 | - ); |
|
567 | - $form['form control tabs suffix'] = array( |
|
566 | + ); |
|
567 | + $form['form control tabs suffix'] = array( |
|
568 | 568 | '#value' => '</ul>', |
569 | 569 | '#weight' => 1004, |
570 | - ); |
|
570 | + ); |
|
571 | 571 | |
572 | - //set validation and submit to the functions below |
|
573 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
574 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
575 | - return $form; |
|
572 | + //set validation and submit to the functions below |
|
573 | + $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
574 | + $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
575 | + return $form; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
579 | 579 | * Validation for final confirmation |
580 | 580 | */ |
581 | 581 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
582 | - $account = $form_state['values']['_account']; |
|
583 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
582 | + $account = $form_state['values']['_account']; |
|
583 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
584 | 584 | |
585 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
585 | + if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
586 | 586 | return true; |
587 | - } |
|
587 | + } |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
591 | 591 | * Submit for final confirmation |
592 | 592 | */ |
593 | 593 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
594 | - global $user; |
|
594 | + global $user; |
|
595 | 595 | |
596 | - // Delete the user |
|
597 | - $account = $form_state['values']['_account']; |
|
598 | - $action = $form_state['values']['_action']; |
|
599 | - _boincuser_delete_deleteuser($account, $action); |
|
596 | + // Delete the user |
|
597 | + $account = $form_state['values']['_account']; |
|
598 | + $action = $form_state['values']['_action']; |
|
599 | + _boincuser_delete_deleteuser($account, $action); |
|
600 | 600 | |
601 | - // Destroy the current session: |
|
602 | - session_destroy(); |
|
603 | - // Only variables can be passed by reference workaround. |
|
604 | - $null = NULL; |
|
605 | - user_module_invoke('logout', $null, $user); |
|
601 | + // Destroy the current session: |
|
602 | + session_destroy(); |
|
603 | + // Only variables can be passed by reference workaround. |
|
604 | + $null = NULL; |
|
605 | + user_module_invoke('logout', $null, $user); |
|
606 | 606 | |
607 | - // Load the anonymous user |
|
608 | - $user = drupal_anonymous_user(); |
|
607 | + // Load the anonymous user |
|
608 | + $user = drupal_anonymous_user(); |
|
609 | 609 | |
610 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
611 | - // Redirect |
|
612 | - if (!empty($redirect)) { |
|
610 | + $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
611 | + // Redirect |
|
612 | + if (!empty($redirect)) { |
|
613 | 613 | drupal_goto($redirect); |
614 | - } |
|
615 | - else { |
|
614 | + } |
|
615 | + else { |
|
616 | 616 | drupal_goto(); |
617 | - } |
|
617 | + } |
|
618 | 618 | |
619 | 619 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | function boincuser_delete_rules_event_info() { |
19 | - return array( |
|
19 | + return array( |
|
20 | 20 | 'boincuser_delete_general_error' => array( |
21 | - 'label' => bts('Error from user deleting own account.', array(), NULL, 'boinc:rule-event'), |
|
22 | - 'module' => 'Boincuser_Delete', |
|
23 | - 'arguments' => rules_events_hook_boincuser_adminnotify_argument(), |
|
21 | + 'label' => bts('Error from user deleting own account.', array(), NULL, 'boinc:rule-event'), |
|
22 | + 'module' => 'Boincuser_Delete', |
|
23 | + 'arguments' => rules_events_hook_boincuser_adminnotify_argument(), |
|
24 | 24 | ), |
25 | 25 | 'boincuser_delete_uid_invalid_error' => array( |
26 | - 'label' => bts('Error from user deleting own account. User ID is invalid', array(), NULL, 'boinc:rule-event'), |
|
27 | - 'module' => 'Boincuser_Delete', |
|
28 | - 'arguments' => rules_events_hook_boincuser_adminnotify_argument(), |
|
26 | + 'label' => bts('Error from user deleting own account. User ID is invalid', array(), NULL, 'boinc:rule-event'), |
|
27 | + 'module' => 'Boincuser_Delete', |
|
28 | + 'arguments' => rules_events_hook_boincuser_adminnotify_argument(), |
|
29 | 29 | ), |
30 | - ); |
|
30 | + ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // function rules_events_hook_boincuser_adminnotify_argument is located in boincuser_rules.inc |
34 | 34 | \ No newline at end of file |
@@ -16,44 +16,44 @@ |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | function boincwork_rules_event_info() { |
19 | - return array( |
|
19 | + return array( |
|
20 | 20 | 'boincwork_circular_merge_error' => array( |
21 | - 'label' => bts('A circular merge of hosts was attempted with error.', array(), NULL, 'boinc:rule-event'), |
|
22 | - 'module' => 'BOINCwork', |
|
23 | - 'arguments' => rules_events_hook_boincwork_arguments(), |
|
21 | + 'label' => bts('A circular merge of hosts was attempted with error.', array(), NULL, 'boinc:rule-event'), |
|
22 | + 'module' => 'BOINCwork', |
|
23 | + 'arguments' => rules_events_hook_boincwork_arguments(), |
|
24 | 24 | ), |
25 | 25 | 'boincwork_zombie_merge_error' => array( |
26 | - 'label' => bts('A host merge into a zombie host was attempted with error.', array(), NULL, 'boinc:rule-event'), |
|
27 | - 'module' => 'BOINCwork', |
|
28 | - 'arguments' => rules_events_hook_boincwork_arguments(), |
|
26 | + 'label' => bts('A host merge into a zombie host was attempted with error.', array(), NULL, 'boinc:rule-event'), |
|
27 | + 'module' => 'BOINCwork', |
|
28 | + 'arguments' => rules_events_hook_boincwork_arguments(), |
|
29 | 29 | ), |
30 | - ); |
|
30 | + ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Arguments suitable for boincwork |
35 | 35 | **/ |
36 | 36 | function rules_events_hook_boincwork_arguments() { |
37 | - return array( |
|
37 | + return array( |
|
38 | 38 | 'oldhost_id' => array( |
39 | - 'type' => 'number', |
|
40 | - 'label' => 'old host id', |
|
41 | - 'required' => TRUE, |
|
39 | + 'type' => 'number', |
|
40 | + 'label' => 'old host id', |
|
41 | + 'required' => TRUE, |
|
42 | 42 | ), |
43 | 43 | 'targethost_id' => array( |
44 | - 'type' => 'number', |
|
45 | - 'label' => 'target host id', |
|
46 | - 'required' => TRUE, |
|
44 | + 'type' => 'number', |
|
45 | + 'label' => 'target host id', |
|
46 | + 'required' => TRUE, |
|
47 | 47 | ), |
48 | - ) + rules_events_hook_boincwork_adminnotify_argument(); |
|
48 | + ) + rules_events_hook_boincwork_adminnotify_argument(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | function rules_events_hook_boincwork_adminnotify_argument() { |
52 | - return array( |
|
52 | + return array( |
|
53 | 53 | 'subject_tag' => array( |
54 | - 'type' => 'string', |
|
55 | - 'label' => 'Subject tag for email filtering', |
|
56 | - 'required' => TRUE, |
|
54 | + 'type' => 'string', |
|
55 | + 'label' => 'Subject tag for email filtering', |
|
56 | + 'required' => TRUE, |
|
57 | 57 | ), |
58 | - ) + rules_events_global_user_argument(); |
|
58 | + ) + rules_events_global_user_argument(); |
|
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -286,11 +286,11 @@ |
||
286 | 286 | |
287 | 287 | require_once("../inc/account_ownership.inc"); |
288 | 288 | if (file_exists($account_ownership_private_key_file_path)) { |
289 | - // If the server has keys configured show the account ownership form |
|
290 | - row2( |
|
291 | - tra("Account Ownership"), |
|
292 | - "<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
|
293 | - ); |
|
289 | + // If the server has keys configured show the account ownership form |
|
290 | + row2( |
|
291 | + tra("Account Ownership"), |
|
292 | + "<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
|
293 | + ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | } |
@@ -28,140 +28,140 @@ |
||
28 | 28 | check_tokens($user->authenticator); |
29 | 29 | |
30 | 30 | function account_ownership_action($user) { |
31 | - // POST request - the user has submitted the form. |
|
32 | - page_head(tra("Proof of account ownership results"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
33 | - |
|
34 | - global $recaptcha_private_key; |
|
35 | - if ($recaptcha_private_key) { |
|
36 | - // Recaptcha is enabled on the BOINC server |
|
37 | - if (!boinc_recaptcha_isValidated($recaptcha_private_key)) { |
|
38 | - // The user failed to solve the recaptcha prompt - redirect them to an error message! |
|
39 | - error_page( |
|
40 | - tra("Your reCAPTCHA response was not correct. Please try again.") |
|
41 | - ); |
|
42 | - } |
|
43 | - } |
|
44 | - |
|
45 | - // Input is passed in from the openssl_sign_form |
|
46 | - $user_data = htmlentities(post_str("user_data", true), ENT_QUOTES, "UTF-8"); // Convert special characters to html equivelant |
|
47 | - |
|
48 | - if ((strlen($user_data) > 0) && (strlen($user_data) <= 4096)) { |
|
49 | - require_once("../inc/account_ownership.inc"); |
|
50 | - // Check that the private key file exists where specified. If not, redirect to error page. |
|
51 | - if (!file_exists($account_ownership_private_key_file_path)) { |
|
52 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
53 | - } |
|
54 | - |
|
55 | - // Check that the public key file exists where specified. If not, redirect to error page. |
|
56 | - if (!file_exists($account_ownership_public_key_file_path)) { |
|
57 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
58 | - } |
|
59 | - |
|
60 | - $privkey = fopen($account_ownership_private_key_file_path, "r"); // Opening private key file |
|
61 | - if (!isset($privkey) || empty($privkey)) { |
|
31 | + // POST request - the user has submitted the form. |
|
32 | + page_head(tra("Proof of account ownership results"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
33 | + |
|
34 | + global $recaptcha_private_key; |
|
35 | + if ($recaptcha_private_key) { |
|
36 | + // Recaptcha is enabled on the BOINC server |
|
37 | + if (!boinc_recaptcha_isValidated($recaptcha_private_key)) { |
|
38 | + // The user failed to solve the recaptcha prompt - redirect them to an error message! |
|
39 | + error_page( |
|
40 | + tra("Your reCAPTCHA response was not correct. Please try again.") |
|
41 | + ); |
|
42 | + } |
|
43 | + } |
|
44 | + |
|
45 | + // Input is passed in from the openssl_sign_form |
|
46 | + $user_data = htmlentities(post_str("user_data", true), ENT_QUOTES, "UTF-8"); // Convert special characters to html equivelant |
|
47 | + |
|
48 | + if ((strlen($user_data) > 0) && (strlen($user_data) <= 4096)) { |
|
49 | + require_once("../inc/account_ownership.inc"); |
|
50 | + // Check that the private key file exists where specified. If not, redirect to error page. |
|
51 | + if (!file_exists($account_ownership_private_key_file_path)) { |
|
52 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
53 | + } |
|
54 | + |
|
55 | + // Check that the public key file exists where specified. If not, redirect to error page. |
|
56 | + if (!file_exists($account_ownership_public_key_file_path)) { |
|
57 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
58 | + } |
|
59 | + |
|
60 | + $privkey = fopen($account_ownership_private_key_file_path, "r"); // Opening private key file |
|
61 | + if (!isset($privkey) || empty($privkey)) { |
|
62 | 62 | error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
63 | - } |
|
64 | - $privkey_contents = fread($privkey, 8192); // Reading contents of private key into var |
|
65 | - fclose($privkey); // Closing private key file |
|
63 | + } |
|
64 | + $privkey_contents = fread($privkey, 8192); // Reading contents of private key into var |
|
65 | + fclose($privkey); // Closing private key file |
|
66 | 66 | |
67 | - $userid = $user->id; // Retrieving the user's UserId |
|
68 | - $message_data = "$userid $user_data"; // Create the message which will be signed. |
|
67 | + $userid = $user->id; // Retrieving the user's UserId |
|
68 | + $message_data = "$userid $user_data"; // Create the message which will be signed. |
|
69 | 69 | |
70 | - $private_key_pem = openssl_pkey_get_private($privkey_contents); // Loading the private key into memory |
|
71 | - openssl_sign($message_data, $signature, $private_key_pem, OPENSSL_ALGO_SHA512); // Compute signature using SHA512 |
|
72 | - openssl_free_key($private_key_pem); // Free the private key from memory for additional security |
|
70 | + $private_key_pem = openssl_pkey_get_private($privkey_contents); // Loading the private key into memory |
|
71 | + openssl_sign($message_data, $signature, $private_key_pem, OPENSSL_ALGO_SHA512); // Compute signature using SHA512 |
|
72 | + openssl_free_key($private_key_pem); // Free the private key from memory for additional security |
|
73 | 73 | |
74 | - $pubkey = fopen($account_ownership_public_key_file_path, "r"); // Open public key file |
|
75 | - if ((!isset($pubkey)) || empty($pubkey)) { |
|
74 | + $pubkey = fopen($account_ownership_public_key_file_path, "r"); // Open public key file |
|
75 | + if ((!isset($pubkey)) || empty($pubkey)) { |
|
76 | 76 | error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
77 | - } |
|
78 | - $pubkey_contents = fread($pubkey, 8192); // Read contents to var |
|
79 | - fclose($pubkey); // Close pub key file |
|
80 | - |
|
81 | - $base64_sig = base64_encode($signature); // Base64 encode the generated signature to enable safe output to text file. |
|
82 | - $decoded_sig = base64_decode($base64_sig); // Decode base64 sig for use in sig_verification |
|
83 | - $pubkeyid = openssl_pkey_get_public($pubkey_contents); // fetch public key into memory |
|
84 | - $sig_verification = openssl_verify($message_data, $decoded_sig, $pubkeyid, OPENSSL_ALGO_SHA512); // Verify that the generated signature against the original data, using the public key. |
|
85 | - openssl_free_key($pubkeyid); // Free the public key from memory |
|
86 | - |
|
87 | - // Check if signature was successfully validated |
|
88 | - if ($sig_verification == 1) { |
|
89 | - $url_tokens = url_tokens($user->authenticator); |
|
90 | - // The generated signature has been successfully verified using the public key. |
|
91 | - global $master_url; // Define global master_url variable for use in output |
|
92 | - echo "<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>"; |
|
93 | - echo "<textarea rows='13' cols='50' id='result_textbox'><account_ownership_verification>\n<master_url>$master_url</master_url>\n<msg>$message_data</msg>\n<signature>$base64_sig</signature>\n</account_ownership_verification></textarea>"; |
|
94 | - echo "<br/><br/><button class='btn btn-success' onclick='copy_result_textbox()'>Copy text</button>"; |
|
95 | - echo "<a href='account_ownership.php?$url_tokens'><button class='btn btn-default'>Go back</button></a>"; |
|
96 | - echo '<script type="text/javascript">'; |
|
97 | - echo 'function copy_result_textbox() { |
|
77 | + } |
|
78 | + $pubkey_contents = fread($pubkey, 8192); // Read contents to var |
|
79 | + fclose($pubkey); // Close pub key file |
|
80 | + |
|
81 | + $base64_sig = base64_encode($signature); // Base64 encode the generated signature to enable safe output to text file. |
|
82 | + $decoded_sig = base64_decode($base64_sig); // Decode base64 sig for use in sig_verification |
|
83 | + $pubkeyid = openssl_pkey_get_public($pubkey_contents); // fetch public key into memory |
|
84 | + $sig_verification = openssl_verify($message_data, $decoded_sig, $pubkeyid, OPENSSL_ALGO_SHA512); // Verify that the generated signature against the original data, using the public key. |
|
85 | + openssl_free_key($pubkeyid); // Free the public key from memory |
|
86 | + |
|
87 | + // Check if signature was successfully validated |
|
88 | + if ($sig_verification == 1) { |
|
89 | + $url_tokens = url_tokens($user->authenticator); |
|
90 | + // The generated signature has been successfully verified using the public key. |
|
91 | + global $master_url; // Define global master_url variable for use in output |
|
92 | + echo "<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>"; |
|
93 | + echo "<textarea rows='13' cols='50' id='result_textbox'><account_ownership_verification>\n<master_url>$master_url</master_url>\n<msg>$message_data</msg>\n<signature>$base64_sig</signature>\n</account_ownership_verification></textarea>"; |
|
94 | + echo "<br/><br/><button class='btn btn-success' onclick='copy_result_textbox()'>Copy text</button>"; |
|
95 | + echo "<a href='account_ownership.php?$url_tokens'><button class='btn btn-default'>Go back</button></a>"; |
|
96 | + echo '<script type="text/javascript">'; |
|
97 | + echo 'function copy_result_textbox() { |
|
98 | 98 | var target_textbox = document.getElementById("result_textbox"); |
99 | 99 | target_textbox.select(); |
100 | 100 | document.execCommand("copy"); |
101 | 101 | alert("Copied to clipboard"); |
102 | 102 | }'; |
103 | - echo '</script>'; |
|
104 | - page_tail(); |
|
105 | - |
|
106 | - } elseif ($sig_verification == 0) { |
|
107 | - // The generated signature has not been verified. The private/public keys do not match. |
|
108 | - error_page(tra("Signature verification failed. Contact the project administrator to resolve the issue.")); |
|
109 | - } else { |
|
110 | - // Something has gone wrong & an error has occurred. |
|
111 | - error_page(tra("An error occurred during the signature verification. Contact the project administrator to resolve the issue.")); |
|
112 | - } |
|
113 | - } else { |
|
114 | - // User data input invalid |
|
115 | - error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>")); |
|
116 | - } |
|
103 | + echo '</script>'; |
|
104 | + page_tail(); |
|
105 | + |
|
106 | + } elseif ($sig_verification == 0) { |
|
107 | + // The generated signature has not been verified. The private/public keys do not match. |
|
108 | + error_page(tra("Signature verification failed. Contact the project administrator to resolve the issue.")); |
|
109 | + } else { |
|
110 | + // Something has gone wrong & an error has occurred. |
|
111 | + error_page(tra("An error occurred during the signature verification. Contact the project administrator to resolve the issue.")); |
|
112 | + } |
|
113 | + } else { |
|
114 | + // User data input invalid |
|
115 | + error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>")); |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | function account_ownership_form($user) { |
120 | - // GET request - the user has navigated to the page. |
|
121 | - page_head(tra("Generate proof of account ownership"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
122 | - |
|
123 | - if ($user) { // Verify the user is logged in |
|
124 | - require_once("../inc/account_ownership.inc"); |
|
125 | - |
|
126 | - if (!file_exists($account_ownership_private_key_file_path)) { |
|
127 | - // Check that the private key file exists where specified. If not, redirect to error page. |
|
128 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
129 | - } |
|
130 | - |
|
131 | - if (!file_exists($account_ownership_public_key_file_path)) { |
|
132 | - // Check that the public key file exists where specified. If not, redirect to error page. |
|
133 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
134 | - } |
|
135 | - |
|
136 | - echo "<p>This tool is designed to create a proof of account ownership for external systems.</p>"; |
|
137 | - |
|
138 | - global $recaptcha_public_key; |
|
139 | - if ($recaptcha_public_key) { |
|
140 | - // Recaptcha configured |
|
141 | - echo "<p>Enter a message with length less than 4096 characters into the input textbox below, solve the captcha then click the 'Generate' button.</p>"; |
|
142 | - } else { |
|
143 | - // Recaptcha not configured |
|
144 | - echo "<p>Enter a message with length less than 4096 characters into the input textbox below then click the 'Generate' button.</p>"; |
|
145 | - } |
|
146 | - echo "<p>A textbox will then appear which contains your proof of account ownership."; |
|
147 | - echo "<form method=post action=account_ownership.php>"; |
|
148 | - |
|
149 | - echo form_tokens($user->authenticator); |
|
150 | - echo "<textarea rows='4' cols='50' name=user_data type=text size=20 placeholder='Enter text'></textarea><br/><br/>"; |
|
151 | - |
|
152 | - if ($recaptcha_public_key) { |
|
153 | - // Trigger recaptcha! |
|
154 | - form_general("", boinc_recaptcha_get_html($recaptcha_public_key)); |
|
155 | - } |
|
156 | - |
|
157 | - echo "<input class=\"btn btn-success\" type=submit value='".tra("Generate")."'>"; |
|
158 | - echo "</form><br/><hr/>"; |
|
159 | - } else { |
|
160 | - // The user is not logged in! |
|
161 | - echo "<p>You need to be logged in to use this functionality.</p>"; |
|
162 | - } |
|
163 | - |
|
164 | - page_tail(); |
|
120 | + // GET request - the user has navigated to the page. |
|
121 | + page_head(tra("Generate proof of account ownership"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
122 | + |
|
123 | + if ($user) { // Verify the user is logged in |
|
124 | + require_once("../inc/account_ownership.inc"); |
|
125 | + |
|
126 | + if (!file_exists($account_ownership_private_key_file_path)) { |
|
127 | + // Check that the private key file exists where specified. If not, redirect to error page. |
|
128 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
129 | + } |
|
130 | + |
|
131 | + if (!file_exists($account_ownership_public_key_file_path)) { |
|
132 | + // Check that the public key file exists where specified. If not, redirect to error page. |
|
133 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
134 | + } |
|
135 | + |
|
136 | + echo "<p>This tool is designed to create a proof of account ownership for external systems.</p>"; |
|
137 | + |
|
138 | + global $recaptcha_public_key; |
|
139 | + if ($recaptcha_public_key) { |
|
140 | + // Recaptcha configured |
|
141 | + echo "<p>Enter a message with length less than 4096 characters into the input textbox below, solve the captcha then click the 'Generate' button.</p>"; |
|
142 | + } else { |
|
143 | + // Recaptcha not configured |
|
144 | + echo "<p>Enter a message with length less than 4096 characters into the input textbox below then click the 'Generate' button.</p>"; |
|
145 | + } |
|
146 | + echo "<p>A textbox will then appear which contains your proof of account ownership."; |
|
147 | + echo "<form method=post action=account_ownership.php>"; |
|
148 | + |
|
149 | + echo form_tokens($user->authenticator); |
|
150 | + echo "<textarea rows='4' cols='50' name=user_data type=text size=20 placeholder='Enter text'></textarea><br/><br/>"; |
|
151 | + |
|
152 | + if ($recaptcha_public_key) { |
|
153 | + // Trigger recaptcha! |
|
154 | + form_general("", boinc_recaptcha_get_html($recaptcha_public_key)); |
|
155 | + } |
|
156 | + |
|
157 | + echo "<input class=\"btn btn-success\" type=submit value='".tra("Generate")."'>"; |
|
158 | + echo "</form><br/><hr/>"; |
|
159 | + } else { |
|
160 | + // The user is not logged in! |
|
161 | + echo "<p>You need to be logged in to use this functionality.</p>"; |
|
162 | + } |
|
163 | + |
|
164 | + page_tail(); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |