@@ -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 |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * The definition of the create team form |
15 | 15 | */ |
16 | 16 | function boincteam_create_form(&$form_state) { |
17 | - $form = array(); |
|
17 | + $form = array(); |
|
18 | 18 | |
19 | - $default = array( |
|
19 | + $default = array( |
|
20 | 20 | 'name' => '', |
21 | 21 | 'name_html' => '', |
22 | 22 | 'website' => '', |
@@ -24,105 +24,105 @@ discard block |
||
24 | 24 | 'country' => 0, |
25 | 25 | 'joinable' => TRUE, |
26 | 26 | 'description' => '', |
27 | - ); |
|
27 | + ); |
|
28 | 28 | |
29 | - // Standard option sets |
|
30 | - $form['boolean_options'] = array( |
|
29 | + // Standard option sets |
|
30 | + $form['boolean_options'] = array( |
|
31 | 31 | '#type' => 'value', |
32 | 32 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
33 | - ); |
|
33 | + ); |
|
34 | 34 | |
35 | - // Vocabulary based option sets |
|
36 | - $form['type_options'] = array( |
|
35 | + // Vocabulary based option sets |
|
36 | + $form['type_options'] = array( |
|
37 | 37 | '#type' => 'value', |
38 | 38 | '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
39 | - ); |
|
40 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
41 | - foreach ($vocabs as $vocab) { |
|
39 | + ); |
|
40 | + $vocabs = taxonomy_get_vocabularies(NULL); |
|
41 | + foreach ($vocabs as $vocab) { |
|
42 | 42 | switch ($vocab->name) { |
43 | 43 | case 'Teams': |
44 | 44 | $team_types = taxonomy_get_tree($vocab->vid); |
45 | - if (module_exists('internationalization')) { |
|
45 | + if (module_exists('internationalization')) { |
|
46 | 46 | $team_types = i18ntaxonomy_localize_terms($team_types); |
47 | - } |
|
48 | - foreach ($team_types as $team_type) { |
|
47 | + } |
|
48 | + foreach ($team_types as $team_type) { |
|
49 | 49 | $form['type_options']['#value'][$team_type->tid] = $team_type->name; |
50 | - } |
|
51 | - break; |
|
50 | + } |
|
51 | + break; |
|
52 | 52 | default: |
53 | 53 | } |
54 | - } |
|
55 | - $form['country_options'] = array( |
|
54 | + } |
|
55 | + $form['country_options'] = array( |
|
56 | 56 | '#type' => 'value', |
57 | 57 | '#value' => boinccore_get_country_list(), |
58 | - ); |
|
58 | + ); |
|
59 | 59 | |
60 | - // Form elements |
|
61 | - $form['name'] = array( |
|
60 | + // Form elements |
|
61 | + $form['name'] = array( |
|
62 | 62 | '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
63 | 63 | '#type' => 'textfield', |
64 | 64 | '#default_value' => $default['name'], |
65 | 65 | '#size' => 34, |
66 | 66 | '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
67 | - ); |
|
68 | - $form['name_html'] = array( |
|
67 | + ); |
|
68 | + $form['name_html'] = array( |
|
69 | 69 | '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
70 | 70 | '#type' => 'textfield', |
71 | 71 | '#default_value' => $default['name_html'], |
72 | 72 | '#size' => 34, |
73 | 73 | '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
74 | - ); |
|
75 | - $form['website'] = array( |
|
74 | + ); |
|
75 | + $form['website'] = array( |
|
76 | 76 | '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
77 | 77 | '#type' => 'textfield', |
78 | 78 | '#default_value' => $default['website'], |
79 | 79 | '#size' => 34, |
80 | 80 | '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
81 | - ); |
|
82 | - $form['type'] = array( |
|
81 | + ); |
|
82 | + $form['type'] = array( |
|
83 | 83 | '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
84 | 84 | '#type' => 'select', |
85 | 85 | '#options' => $form['type_options']['#value'], |
86 | 86 | '#default_value' => $default['type'], |
87 | - ); |
|
88 | - $form['country'] = array( |
|
87 | + ); |
|
88 | + $form['country'] = array( |
|
89 | 89 | '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
90 | 90 | '#type' => 'select', |
91 | 91 | '#options' => $form['country_options']['#value'], |
92 | 92 | '#default_value' => $default['country'], |
93 | - ); |
|
94 | - $form['joinable'] = array( |
|
93 | + ); |
|
94 | + $form['joinable'] = array( |
|
95 | 95 | '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
96 | 96 | '#type' => 'radios', |
97 | 97 | '#options' => $form['boolean_options']['#value'], |
98 | 98 | '#attributes' => array('class' => 'fancy'), |
99 | 99 | '#default_value' => $default['joinable'], |
100 | 100 | '#size' => 34, |
101 | - ); |
|
102 | - $form['description'] = array( |
|
101 | + ); |
|
102 | + $form['description'] = array( |
|
103 | 103 | '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
104 | 104 | '#type' => 'textarea', |
105 | 105 | '#default_value' => $default['description'], |
106 | 106 | '#size' => 5, |
107 | 107 | '#description' => NULL, |
108 | - ); |
|
109 | - $form['format'] = filter_form(); |
|
108 | + ); |
|
109 | + $form['format'] = filter_form(); |
|
110 | 110 | |
111 | - // Form control |
|
112 | - $form['form control tabs prefix'] = array( |
|
111 | + // Form control |
|
112 | + $form['form control tabs prefix'] = array( |
|
113 | 113 | '#value' => '<ul class="form-control tab-list">' |
114 | - ); |
|
115 | - $form['submit'] = array( |
|
114 | + ); |
|
115 | + $form['submit'] = array( |
|
116 | 116 | '#prefix' => '<li class="first tab">', |
117 | 117 | '#type' => 'submit', |
118 | 118 | '#value' => bts('Save team', array(), NULL, 'boinc:team-form-save'), |
119 | 119 | '#suffix' => '</li>', |
120 | - ); |
|
121 | - $form['form control tabs'] = array( |
|
120 | + ); |
|
121 | + $form['form control tabs'] = array( |
|
122 | 122 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
123 | - ); |
|
123 | + ); |
|
124 | 124 | |
125 | - return $form; |
|
125 | + return $form; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,41 +130,41 @@ discard block |
||
130 | 130 | */ |
131 | 131 | function boincteam_create_form_validate($form, &$form_state) { |
132 | 132 | |
133 | - $values = $form_state['values']; |
|
134 | - $name = $values['name']; |
|
133 | + $values = $form_state['values']; |
|
134 | + $name = $values['name']; |
|
135 | 135 | |
136 | - if (!$name) { |
|
136 | + if (!$name) { |
|
137 | 137 | form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
138 | - } |
|
139 | - else { |
|
138 | + } |
|
139 | + else { |
|
140 | 140 | require_boinc('boinc_db'); |
141 | 141 | if (BoincTeam::lookup_name($name)) { |
142 | - form_set_error('name', bts('A team named "@name" already exists.', |
|
142 | + form_set_error('name', bts('A team named "@name" already exists.', |
|
143 | 143 | array('@name' => $name), NULL, 'boinc:team-create/edit')); |
144 | 144 | } |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
147 | + if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
148 | 148 | form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
149 | - } |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * The create team submit handler |
154 | 154 | */ |
155 | 155 | function boincteam_create_form_submit($form, &$form_state) { |
156 | - global $user; |
|
157 | - $account = user_load($user->uid); |
|
158 | - $values = $form_state['values']; |
|
159 | - //drupal_set_message('<pre>' . print_r($values,true) . '</pre>'); |
|
156 | + global $user; |
|
157 | + $account = user_load($user->uid); |
|
158 | + $values = $form_state['values']; |
|
159 | + //drupal_set_message('<pre>' . print_r($values,true) . '</pre>'); |
|
160 | 160 | |
161 | - $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
162 | - $values['description'] = check_markup($values['description'], $input_format); |
|
161 | + $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
162 | + $values['description'] = check_markup($values['description'], $input_format); |
|
163 | 163 | |
164 | - // Create the team in the BOINC db |
|
164 | + // Create the team in the BOINC db |
|
165 | 165 | |
166 | - require_boinc(array('user','team')); |
|
167 | - $boinc_team = make_team( |
|
166 | + require_boinc(array('user','team')); |
|
167 | + $boinc_team = make_team( |
|
168 | 168 | $account->boincuser_id, |
169 | 169 | $values['name'], |
170 | 170 | $values['website'], |
@@ -172,27 +172,27 @@ discard block |
||
172 | 172 | $values['name_html'], |
173 | 173 | $values['description'], |
174 | 174 | $values['country'] |
175 | - ); |
|
175 | + ); |
|
176 | 176 | |
177 | - if ($boinc_team) { |
|
177 | + if ($boinc_team) { |
|
178 | 178 | $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
179 | 179 | user_join_team($boinc_team, $boinc_user); |
180 | - } |
|
181 | - else { |
|
180 | + } |
|
181 | + else { |
|
182 | 182 | drupal_set_message(t('Teams cannot be created at this time. The @project administrators have been notified.', array('@project' => PROJECT))); |
183 | 183 | rules_invoke_event('boincteam_create_team_error', $values['name'], variable_get('boinc_admin_mailing_list_subject_tag', '')); |
184 | 184 | watchdog('BOINC team', 'BOINC teams cannot be created for an unknown |
185 | 185 | reason.', 'error'); |
186 | 186 | return FALSE; |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - // Create the team node in Drupal |
|
189 | + // Create the team node in Drupal |
|
190 | 190 | |
191 | - $teaser = node_teaser($values['description']); |
|
192 | - $created_time = time(); |
|
193 | - $input_format = variable_get('filter_default_format', 1); |
|
191 | + $teaser = node_teaser($values['description']); |
|
192 | + $created_time = time(); |
|
193 | + $input_format = variable_get('filter_default_format', 1); |
|
194 | 194 | |
195 | - $node = array( |
|
195 | + $node = array( |
|
196 | 196 | 'type' => 'team', |
197 | 197 | 'title' => $values['name'], |
198 | 198 | 'body' => $values['description'], |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | 'moderate' => 0, |
207 | 207 | 'sticky' => 0, |
208 | 208 | 'format' => $input_format |
209 | - ); |
|
209 | + ); |
|
210 | 210 | |
211 | - // Use pathauto function, if available, to clean up the path |
|
212 | - if (module_exists('pathauto')) { |
|
211 | + // Use pathauto function, if available, to clean up the path |
|
212 | + if (module_exists('pathauto')) { |
|
213 | 213 | module_load_include('inc', 'pathauto', 'pathauto'); |
214 | 214 | $node['path'] = pathauto_cleanstring($values['name']); |
215 | - } |
|
216 | - else { |
|
215 | + } |
|
216 | + else { |
|
217 | 217 | drupal_set_message(t('Teams cannot be created at this time. The @project administrators have been notified.', array('@project' => PROJECT))); |
218 | 218 | rules_invoke_event('boincteam_create_team_nopathauto_error', $values['name'], variable_get('boinc_admin_mailing_list_subject_tag', '')); |
219 | 219 | watchdog('BOINC team', 'BOINC teams require the Pathauto module. Teams |
220 | 220 | cannot be created.', 'error'); |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - /* |
|
223 | + /* |
|
224 | 224 | // Add special organic group properties |
225 | 225 | $node['og_description'] = strip_tags($boincteam->description); |
226 | 226 | $node['og_selective'] = OG_OPEN; |
@@ -229,26 +229,26 @@ discard block |
||
229 | 229 | $node['og_private'] = 0; |
230 | 230 | */ |
231 | 231 | |
232 | - $node = (object) $node; // node_save requires an object form |
|
232 | + $node = (object) $node; // node_save requires an object form |
|
233 | 233 | |
234 | - /* |
|
234 | + /* |
|
235 | 235 | $node->field_description[]['value'] = $boincteam->description; |
236 | 236 | $node->field_url[]['value'] = $boincteam->url; |
237 | 237 | $node->field_country[]['value'] = $boincteam->country; |
238 | 238 | */ |
239 | 239 | |
240 | - $node->taxonomy[] = taxonomy_get_term($values['type']); |
|
240 | + $node->taxonomy[] = taxonomy_get_term($values['type']); |
|
241 | 241 | |
242 | - // Save the team node |
|
243 | - node_save($node); |
|
242 | + // Save the team node |
|
243 | + node_save($node); |
|
244 | 244 | |
245 | - // Save the team IDs to a BOINC <--> Drupal reference table. |
|
246 | - db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid); |
|
245 | + // Save the team IDs to a BOINC <--> Drupal reference table. |
|
246 | + db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid); |
|
247 | 247 | |
248 | - drupal_set_message(t('Team "@name" has been created.', |
|
248 | + drupal_set_message(t('Team "@name" has been created.', |
|
249 | 249 | array('@name' => $values['name']))); |
250 | 250 | |
251 | - $form_state['redirect'] = "community/teams/{$node->nid}"; |
|
251 | + $form_state['redirect'] = "community/teams/{$node->nid}"; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | * The definition of the edit team form |
260 | 260 | */ |
261 | 261 | function boincteam_edit_form(&$form_state, $team_id) { |
262 | - $form = array(); |
|
262 | + $form = array(); |
|
263 | 263 | |
264 | - $team = node_load($team_id); |
|
265 | - $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
264 | + $team = node_load($team_id); |
|
265 | + $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
266 | 266 | |
267 | - $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
267 | + $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
268 | 268 | |
269 | - $form_state['storage']['team_id'] = $team_id; |
|
270 | - $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
|
269 | + $form_state['storage']['team_id'] = $team_id; |
|
270 | + $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
|
271 | 271 | |
272 | - $default = array( |
|
272 | + $default = array( |
|
273 | 273 | 'name' => $boincteam->name, |
274 | 274 | 'name_html' => $boincteam->name_html, |
275 | 275 | 'website' => $boincteam->url, |
@@ -277,79 +277,79 @@ discard block |
||
277 | 277 | 'country' => $boincteam->country, |
278 | 278 | 'joinable' => $boincteam->joinable, |
279 | 279 | 'description' => $boincteam->description, |
280 | - ); |
|
280 | + ); |
|
281 | 281 | |
282 | - // Standard option sets |
|
283 | - $form['boolean_options'] = array( |
|
282 | + // Standard option sets |
|
283 | + $form['boolean_options'] = array( |
|
284 | 284 | '#type' => 'value', |
285 | 285 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
286 | - ); |
|
286 | + ); |
|
287 | 287 | |
288 | - // Vocabulary based option sets |
|
289 | - $form['type_options'] = array( |
|
288 | + // Vocabulary based option sets |
|
289 | + $form['type_options'] = array( |
|
290 | 290 | '#type' => 'value', |
291 | 291 | '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
292 | - ); |
|
293 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
294 | - foreach ($vocabs as $vocab) { |
|
292 | + ); |
|
293 | + $vocabs = taxonomy_get_vocabularies(NULL); |
|
294 | + foreach ($vocabs as $vocab) { |
|
295 | 295 | switch ($vocab->name) { |
296 | 296 | case 'Teams': |
297 | 297 | $team_types = taxonomy_get_tree($vocab->vid); |
298 | - if (module_exists('internationalization')) { |
|
298 | + if (module_exists('internationalization')) { |
|
299 | 299 | $team_types = i18ntaxonomy_localize_terms($team_types); |
300 | - } |
|
301 | - foreach ($team_types as $team_type) { |
|
300 | + } |
|
301 | + foreach ($team_types as $team_type) { |
|
302 | 302 | $form['type_options']['#value'][$team_type->tid] = $team_type->name; |
303 | - } |
|
304 | - break; |
|
303 | + } |
|
304 | + break; |
|
305 | 305 | default: |
306 | 306 | } |
307 | - } |
|
308 | - $form['country_options'] = array( |
|
307 | + } |
|
308 | + $form['country_options'] = array( |
|
309 | 309 | '#type' => 'value', |
310 | 310 | '#value' => boinccore_get_country_list(), |
311 | - ); |
|
311 | + ); |
|
312 | 312 | |
313 | - // Form elements |
|
314 | - $form['name'] = array( |
|
313 | + // Form elements |
|
314 | + $form['name'] = array( |
|
315 | 315 | '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
316 | 316 | '#type' => 'textfield', |
317 | 317 | '#default_value' => $default['name'], |
318 | 318 | '#size' => 34, |
319 | 319 | '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
320 | 320 | '#disabled' => $is_boinc_wide, |
321 | - ); |
|
322 | - $form['name_html'] = array( |
|
321 | + ); |
|
322 | + $form['name_html'] = array( |
|
323 | 323 | '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
324 | 324 | '#type' => 'textfield', |
325 | 325 | '#default_value' => $default['name_html'], |
326 | 326 | '#size' => 34, |
327 | 327 | '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
328 | 328 | '#disabled' => $is_boinc_wide, |
329 | - ); |
|
330 | - $form['website'] = array( |
|
329 | + ); |
|
330 | + $form['website'] = array( |
|
331 | 331 | '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
332 | 332 | '#type' => 'textfield', |
333 | 333 | '#default_value' => $default['website'], |
334 | 334 | '#size' => 34, |
335 | 335 | '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
336 | 336 | '#disabled' => $is_boinc_wide, |
337 | - ); |
|
338 | - $form['type'] = array( |
|
337 | + ); |
|
338 | + $form['type'] = array( |
|
339 | 339 | '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
340 | 340 | '#type' => 'select', |
341 | 341 | '#options' => $form['type_options']['#value'], |
342 | 342 | '#default_value' => $default['type'], |
343 | 343 | '#disabled' => $is_boinc_wide, |
344 | - ); |
|
345 | - $form['country'] = array( |
|
344 | + ); |
|
345 | + $form['country'] = array( |
|
346 | 346 | '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
347 | 347 | '#type' => 'select', |
348 | 348 | '#options' => $form['country_options']['#value'], |
349 | 349 | '#default_value' => $default['country'], |
350 | 350 | '#disabled' => $is_boinc_wide, |
351 | - ); |
|
352 | - $form['joinable'] = array( |
|
351 | + ); |
|
352 | + $form['joinable'] = array( |
|
353 | 353 | '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
354 | 354 | '#type' => 'radios', |
355 | 355 | '#options' => $form['boolean_options']['#value'], |
@@ -357,49 +357,49 @@ discard block |
||
357 | 357 | '#default_value' => $default['joinable'], |
358 | 358 | '#size' => 34, |
359 | 359 | '#disabled' => $is_boinc_wide, |
360 | - ); |
|
361 | - if (!$is_boinc_wide) { |
|
360 | + ); |
|
361 | + if (!$is_boinc_wide) { |
|
362 | 362 | $form['description'] = array( |
363 | - '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
364 | - '#type' => 'textarea', |
|
365 | - '#default_value' => $default['description'], |
|
366 | - '#size' => 5, |
|
367 | - '#description' => NULL, |
|
363 | + '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
364 | + '#type' => 'textarea', |
|
365 | + '#default_value' => $default['description'], |
|
366 | + '#size' => 5, |
|
367 | + '#description' => NULL, |
|
368 | 368 | ); |
369 | 369 | $form['format'] = filter_form(); |
370 | 370 | |
371 | 371 | // Form control |
372 | 372 | $form['form control tabs prefix'] = array( |
373 | - '#value' => '<ul class="form-control tab-list">' |
|
373 | + '#value' => '<ul class="form-control tab-list">' |
|
374 | 374 | ); |
375 | 375 | $form['submit'] = array( |
376 | - '#prefix' => '<li class="first tab">', |
|
377 | - '#type' => 'submit', |
|
378 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
379 | - '#suffix' => '</li>', |
|
376 | + '#prefix' => '<li class="first tab">', |
|
377 | + '#type' => 'submit', |
|
378 | + '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
379 | + '#suffix' => '</li>', |
|
380 | 380 | ); |
381 | 381 | $form['form control tabs'] = array( |
382 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
382 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
383 | 383 | ); |
384 | - } |
|
385 | - else { |
|
384 | + } |
|
385 | + else { |
|
386 | 386 | $form['description'] = array( |
387 | - '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | - '#value' => $default['description'], |
|
389 | - '#suffix' => '</div>', |
|
387 | + '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | + '#value' => $default['description'], |
|
389 | + '#suffix' => '</div>', |
|
390 | 390 | ); |
391 | 391 | drupal_set_message( |
392 | - bts('This is a BOINC-wide team. Changes can be made at the !site.', |
|
392 | + bts('This is a BOINC-wide team. Changes can be made at the !site.', |
|
393 | 393 | array('!site' => l(bts('BOINC-wide teams site', array(), NULL, 'boinc:link-to-BOINC-wide-teams-Website'), |
394 | - 'http://boinc.berkeley.edu/teams/' |
|
394 | + 'http://boinc.berkeley.edu/teams/' |
|
395 | 395 | )), |
396 | 396 | NULL, 'boinc:team-edit-warning-message'), |
397 | - 'warning'); |
|
398 | - } |
|
397 | + 'warning'); |
|
398 | + } |
|
399 | 399 | |
400 | - $form['#redirect'] = "community/teams/{$team_id}"; |
|
400 | + $form['#redirect'] = "community/teams/{$team_id}"; |
|
401 | 401 | |
402 | - return $form; |
|
402 | + return $form; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -407,32 +407,32 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function boincteam_edit_form_validate($form, &$form_state) { |
409 | 409 | |
410 | - $values = $form_state['values']; |
|
411 | - $name = $values['name']; |
|
410 | + $values = $form_state['values']; |
|
411 | + $name = $values['name']; |
|
412 | 412 | |
413 | - if ($form_state['storage']['is_boinc_wide']) { |
|
413 | + if ($form_state['storage']['is_boinc_wide']) { |
|
414 | 414 | form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), NULL, 'boinc:team-create/edit')); |
415 | - } |
|
416 | - else { |
|
415 | + } |
|
416 | + else { |
|
417 | 417 | if (!$name) { |
418 | - form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
418 | + form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
419 | 419 | } |
420 | 420 | else { |
421 | - $team = node_load($form_state['storage']['team_id']); |
|
422 | - if ($name != $team->title) { |
|
421 | + $team = node_load($form_state['storage']['team_id']); |
|
422 | + if ($name != $team->title) { |
|
423 | 423 | // If changing the name ("title" in Drupal terms), check that the new name is available |
424 | 424 | require_boinc('boinc_db'); |
425 | 425 | if (BoincTeam::lookup_name($name)) { |
426 | - form_set_error('name', bts('A team named "@name" already exists.', |
|
426 | + form_set_error('name', bts('A team named "@name" already exists.', |
|
427 | 427 | array('@name' => $name), NULL, 'boinc:team-create/edit')); |
428 | 428 | } |
429 | - } |
|
429 | + } |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
433 | - form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
433 | + form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
434 | + } |
|
434 | 435 | } |
435 | - } |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | */ |
441 | 441 | function boincteam_edit_form_submit($form, &$form_state) { |
442 | 442 | |
443 | - $team_id = $form_state['storage']['team_id']; |
|
444 | - $values = $form_state['values']; |
|
443 | + $team_id = $form_state['storage']['team_id']; |
|
444 | + $values = $form_state['values']; |
|
445 | 445 | |
446 | - $team = node_load($team_id); |
|
447 | - $boincteam_id = boincteam_lookup_id($team_id); |
|
446 | + $team = node_load($team_id); |
|
447 | + $boincteam_id = boincteam_lookup_id($team_id); |
|
448 | 448 | |
449 | - $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
450 | - $values['description'] = check_markup($values['description'], $input_format); |
|
449 | + $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
450 | + $values['description'] = check_markup($values['description'], $input_format); |
|
451 | 451 | |
452 | - // Update the team in the BOINC db |
|
453 | - db_set_active('boinc_rw'); |
|
454 | - db_query(" |
|
452 | + // Update the team in the BOINC db |
|
453 | + db_set_active('boinc_rw'); |
|
454 | + db_query(" |
|
455 | 455 | UPDATE {team} SET |
456 | 456 | name = '%s', |
457 | 457 | name_lc = '%s', |
@@ -471,32 +471,32 @@ discard block |
||
471 | 471 | $values['country'], |
472 | 472 | $values['joinable'], |
473 | 473 | $boincteam_id |
474 | - ); |
|
475 | - db_set_active('default'); |
|
474 | + ); |
|
475 | + db_set_active('default'); |
|
476 | 476 | |
477 | - // Update the team node in Drupal |
|
477 | + // Update the team node in Drupal |
|
478 | 478 | |
479 | - $team->title = $values['name']; |
|
480 | - $team->body = $values['description']; |
|
481 | - $team->teaser = node_teaser($values['description']); |
|
479 | + $team->title = $values['name']; |
|
480 | + $team->body = $values['description']; |
|
481 | + $team->teaser = node_teaser($values['description']); |
|
482 | 482 | |
483 | - /* |
|
483 | + /* |
|
484 | 484 | $node->field_description[]['value'] = $boincteam->description; |
485 | 485 | $node->field_url[]['value'] = $boincteam->url; |
486 | 486 | $node->field_country[]['value'] = $boincteam->country; |
487 | 487 | */ |
488 | 488 | |
489 | - // Replace any existing taxonomy with the new one |
|
490 | - $team->taxonomy = array(taxonomy_get_term($values['type'])); |
|
489 | + // Replace any existing taxonomy with the new one |
|
490 | + $team->taxonomy = array(taxonomy_get_term($values['type'])); |
|
491 | 491 | |
492 | - // Save the team node |
|
493 | - node_save($team); |
|
492 | + // Save the team node |
|
493 | + node_save($team); |
|
494 | 494 | |
495 | - drupal_set_message(t('Details for "@team" have been updated.', |
|
495 | + drupal_set_message(t('Details for "@team" have been updated.', |
|
496 | 496 | array('@team' => $values['name']))); |
497 | 497 | |
498 | - // The storage variable quietly kills redirection for some reason... unset it |
|
499 | - unset($form_state['storage']); |
|
498 | + // The storage variable quietly kills redirection for some reason... unset it |
|
499 | + unset($form_state['storage']); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -508,44 +508,44 @@ discard block |
||
508 | 508 | * The definition of the add team admin form |
509 | 509 | */ |
510 | 510 | function boincteam_add_admin_form(&$form_state, $team_id) { |
511 | - $form = array(); |
|
511 | + $form = array(); |
|
512 | 512 | |
513 | - $team = node_load($team_id); |
|
514 | - $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
513 | + $team = node_load($team_id); |
|
514 | + $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
515 | 515 | |
516 | - $form_state['storage']['team_id'] = $team_id; |
|
516 | + $form_state['storage']['team_id'] = $team_id; |
|
517 | 517 | |
518 | - $default = array( |
|
518 | + $default = array( |
|
519 | 519 | 'username' => '', |
520 | - ); |
|
520 | + ); |
|
521 | 521 | |
522 | - // Form elements |
|
523 | - $form['username'] = array( |
|
522 | + // Form elements |
|
523 | + $form['username'] = array( |
|
524 | 524 | '#title' => bts('Enter BOINC username', array(), NULL, 'boinc:team--add-admin'), |
525 | 525 | '#description' => bts('The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
526 | 526 | '#type' => 'textfield', |
527 | 527 | '#default_value' => $default['username'], |
528 | 528 | '#size' => 34, |
529 | 529 | '#autocomplete_path' => "community/teams/${team_id}/user-name-autocomplete", |
530 | - ); |
|
530 | + ); |
|
531 | 531 | |
532 | - // Form control |
|
533 | - $form['form control tabs prefix'] = array( |
|
532 | + // Form control |
|
533 | + $form['form control tabs prefix'] = array( |
|
534 | 534 | '#value' => '<ul class="form-control tab-list">' |
535 | - ); |
|
536 | - $form['submit'] = array( |
|
535 | + ); |
|
536 | + $form['submit'] = array( |
|
537 | 537 | '#prefix' => '<li class="first tab">', |
538 | 538 | '#type' => 'submit', |
539 | 539 | '#value' => bts('Add', array(), NULL, 'boinc:form-add'), |
540 | 540 | '#suffix' => '</li>', |
541 | - ); |
|
542 | - $form['form control tabs'] = array( |
|
541 | + ); |
|
542 | + $form['form control tabs'] = array( |
|
543 | 543 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
544 | - ); |
|
544 | + ); |
|
545 | 545 | |
546 | - //$form['#redirect'] = "community/teams/{$team_id}"; |
|
546 | + //$form['#redirect'] = "community/teams/{$team_id}"; |
|
547 | 547 | |
548 | - return $form; |
|
548 | + return $form; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -553,45 +553,45 @@ discard block |
||
553 | 553 | */ |
554 | 554 | function boincteam_add_admin_form_validate($form, &$form_state) { |
555 | 555 | |
556 | - $team_id = $form_state['storage']['team_id']; |
|
557 | - $values = $form_state['values']; |
|
558 | - $team = node_load($team_id); |
|
556 | + $team_id = $form_state['storage']['team_id']; |
|
557 | + $values = $form_state['values']; |
|
558 | + $team = node_load($team_id); |
|
559 | 559 | |
560 | - if (!$values['username']) { |
|
560 | + if (!$values['username']) { |
|
561 | 561 | form_set_error('username', bts('BOINC username is required.', array(), NULL, 'boinc:team-add-admin')); |
562 | - } |
|
563 | - else { |
|
562 | + } |
|
563 | + else { |
|
564 | 564 | // Load user account associated with username |
565 | 565 | $account = boincuser_privatemsg_name_lookup($values['username']); |
566 | 566 | // Validate the account |
567 | 567 | if ((!$account) OR ($account->team != $team_id)) { |
568 | - form_set_error('username', bts('There is no user on your team with name @username.', |
|
568 | + form_set_error('username', bts('There is no user on your team with name @username.', |
|
569 | 569 | array( |
570 | - '@username' => $account->boincuser_name |
|
570 | + '@username' => $account->boincuser_name |
|
571 | 571 | ), |
572 | - NULL, 'boinc:team-add-admin')); |
|
572 | + NULL, 'boinc:team-add-admin')); |
|
573 | 573 | } |
574 | 574 | elseif (boincteam_is_founder($team_id, $account->uid)) { |
575 | - form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
|
575 | + form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
|
576 | 576 | array( |
577 | - '@user' => $account->boincuser_name, |
|
578 | - '@team' => $team->title, |
|
577 | + '@user' => $account->boincuser_name, |
|
578 | + '@team' => $team->title, |
|
579 | 579 | ), |
580 | 580 | NULL, 'boinc:team-add-admin')); |
581 | 581 | } |
582 | 582 | elseif (boincteam_is_admin($team_id, $account->uid)) { |
583 | - form_set_error('username', bts('@user is already an admin of @team.', |
|
583 | + form_set_error('username', bts('@user is already an admin of @team.', |
|
584 | 584 | array( |
585 | - '@user' => $account->boincuser_name, |
|
586 | - '@team' => $team->title, |
|
585 | + '@user' => $account->boincuser_name, |
|
586 | + '@team' => $team->title, |
|
587 | 587 | ), |
588 | 588 | NULL, 'boinc:team-add-admin')); |
589 | 589 | } |
590 | 590 | else { |
591 | - $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
|
592 | - $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
|
591 | + $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
|
592 | + $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
|
593 | + } |
|
593 | 594 | } |
594 | - } |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -599,17 +599,17 @@ discard block |
||
599 | 599 | */ |
600 | 600 | function boincteam_add_admin_form_submit($form, &$form_state) { |
601 | 601 | |
602 | - $team_id = $form_state['storage']['team_id']; |
|
603 | - $boincuser_id = $form_state['storage']['boincuser_id']; |
|
604 | - $user_name = $form_state['storage']['boincuser_name']; |
|
605 | - $values = $form_state['values']; |
|
602 | + $team_id = $form_state['storage']['team_id']; |
|
603 | + $boincuser_id = $form_state['storage']['boincuser_id']; |
|
604 | + $user_name = $form_state['storage']['boincuser_name']; |
|
605 | + $values = $form_state['values']; |
|
606 | 606 | |
607 | - $team = node_load($team_id); |
|
608 | - $boincteam_id = boincteam_lookup_id($team_id); |
|
607 | + $team = node_load($team_id); |
|
608 | + $boincteam_id = boincteam_lookup_id($team_id); |
|
609 | 609 | |
610 | - // Update the team in the BOINC db |
|
611 | - db_set_active('boinc_rw'); |
|
612 | - db_query(" |
|
610 | + // Update the team in the BOINC db |
|
611 | + db_set_active('boinc_rw'); |
|
612 | + db_query(" |
|
613 | 613 | INSERT INTO {team_admin} SET |
614 | 614 | teamid = '%d', |
615 | 615 | userid = '%d', |
@@ -617,17 +617,17 @@ discard block |
||
617 | 617 | $boincteam_id, |
618 | 618 | $boincuser_id, |
619 | 619 | time() |
620 | - ); |
|
621 | - db_set_active('default'); |
|
620 | + ); |
|
621 | + db_set_active('default'); |
|
622 | 622 | |
623 | - // Could assign a role in Drupal here, as needed |
|
623 | + // Could assign a role in Drupal here, as needed |
|
624 | 624 | |
625 | 625 | |
626 | - drupal_set_message(t('@user has been added as an admin.', |
|
626 | + drupal_set_message(t('@user has been added as an admin.', |
|
627 | 627 | array('@user' => $user_name))); |
628 | 628 | |
629 | - // The storage variable quietly kills redirection for some reason... unset it |
|
630 | - unset($form_state['storage']); |
|
629 | + // The storage variable quietly kills redirection for some reason... unset it |
|
630 | + unset($form_state['storage']); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -639,80 +639,80 @@ discard block |
||
639 | 639 | * Send all team members an email message function |
640 | 640 | */ |
641 | 641 | function boincteam_sendmessagetoteam(&$form_state, $team_id) { |
642 | - global $user; |
|
643 | - $form = array(); |
|
642 | + global $user; |
|
643 | + $form = array(); |
|
644 | 644 | |
645 | - if (isset($form_state['values'])) { |
|
645 | + if (isset($form_state['values'])) { |
|
646 | 646 | $subject = $form_state['values']['subject']; |
647 | 647 | $body = $form_state['values']['body']; |
648 | - } |
|
649 | - else { |
|
648 | + } |
|
649 | + else { |
|
650 | 650 | $subject = ''; |
651 | 651 | $body = ''; |
652 | - } |
|
652 | + } |
|
653 | 653 | |
654 | - // Title |
|
655 | - $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
656 | - drupal_set_title($mytitle); |
|
654 | + // Title |
|
655 | + $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
656 | + drupal_set_title($mytitle); |
|
657 | 657 | |
658 | - $form['emailteam']['header'] = array( |
|
658 | + $form['emailteam']['header'] = array( |
|
659 | 659 | '#value' => '<h1>' . $mytitle . '</h1>', |
660 | 660 | '#weight' => '-10', |
661 | 661 | '#prefix' => "<div id='sendmessageteammembers-header'>", |
662 | 662 | '#suffix' => "</div>", |
663 | - ); |
|
663 | + ); |
|
664 | 664 | |
665 | - $form['emailteam']['instructions'] = array( |
|
665 | + $form['emailteam']['instructions'] = array( |
|
666 | 666 | '#value' => bts('This will send an email to all team members. If a team member has opt-ed out of notification e-mails, they will not receive your message. At the bottom of your message, there will be a link allowing team members to send you a Direct Message. This link is added automatically, you do not need to add it below in the Message box. Your email address will not be shown to the recipients.', array(), NULL, 'boinc:team-message-form'), |
667 | 667 | '#weight' => '-8', |
668 | 668 | '#prefix' => "<div id='sendmessageteammembers-instructions'>", |
669 | 669 | '#suffix' => "</div>", |
670 | - ); |
|
670 | + ); |
|
671 | 671 | |
672 | - // Subject |
|
673 | - $form['emailteam']['subject'] = array( |
|
672 | + // Subject |
|
673 | + $form['emailteam']['subject'] = array( |
|
674 | 674 | '#type' => 'textfield', |
675 | 675 | '#title' => bts('Subject', array(), NULL, 'boinc:team-message-form'), |
676 | 676 | '#size' => 50, |
677 | 677 | '#maxlength' => 255, |
678 | 678 | '#default_value' => $subject, |
679 | 679 | '#weight' => -5, |
680 | - ); |
|
680 | + ); |
|
681 | 681 | |
682 | - // Body |
|
683 | - $form['emailteam']['body'] = array( |
|
682 | + // Body |
|
683 | + $form['emailteam']['body'] = array( |
|
684 | 684 | '#type' => 'textarea', |
685 | 685 | '#title' => bts('Message', array(), NULL, 'boinc:team-message-form'), |
686 | 686 | '#rows' => 8, |
687 | 687 | '#weight' => 0, |
688 | 688 | '#default_value' => $body, |
689 | 689 | '#resizable' => TRUE, |
690 | - ); |
|
690 | + ); |
|
691 | 691 | |
692 | - // checkbox for 'sent to self' |
|
693 | - $form['emailteam']['selfsend'] = array( |
|
692 | + // checkbox for 'sent to self' |
|
693 | + $form['emailteam']['selfsend'] = array( |
|
694 | 694 | '#type' => 'checkbox', |
695 | 695 | '#title' => bts('Check this box if you wish to be sent a copy of your message to your email address.', array(), NULL, 'boinc:team-message-form'), |
696 | 696 | '#weight' => 10, |
697 | 697 | '#prefix' => '<div class="clearfix" id="confirm-checkbox">', |
698 | 698 | '#suffix' => '</div>', |
699 | - ); |
|
699 | + ); |
|
700 | 700 | |
701 | - // Add a captcha to form |
|
702 | - if (module_exists('captcha')) { |
|
701 | + // Add a captcha to form |
|
702 | + if (module_exists('captcha')) { |
|
703 | 703 | $form['register_captcha'] = array( |
704 | 704 | '#type' => 'captcha', |
705 | 705 | '#weight' => 1000, |
706 | 706 | ); |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - // form buttons |
|
710 | - $form['emailteam']['form control tabs prefix'] = array( |
|
709 | + // form buttons |
|
710 | + $form['emailteam']['form control tabs prefix'] = array( |
|
711 | 711 | '#value' => '<ul class="form-control tab-list">', |
712 | 712 | '#weight' => 1000, |
713 | - ); |
|
713 | + ); |
|
714 | 714 | |
715 | - $form['emailteam']['submit'] = array( |
|
715 | + $form['emailteam']['submit'] = array( |
|
716 | 716 | '#type' => 'submit', |
717 | 717 | '#value' => bts('Send message', array(), NULL, 'boinc:form-submit'), |
718 | 718 | '#submit' => array('boincteam_sendmessagetoteam_submit'), |
@@ -720,130 +720,130 @@ discard block |
||
720 | 720 | '#weight' => 1001, |
721 | 721 | '#prefix' => '<li class="first tab">', |
722 | 722 | '#suffix' => '</li>' |
723 | - ); |
|
723 | + ); |
|
724 | 724 | |
725 | - $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
726 | - $url = "community/teams/{$team_id}"; |
|
727 | - $form['emailteam']['cancel'] = array( |
|
725 | + $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
726 | + $url = "community/teams/{$team_id}"; |
|
727 | + $form['emailteam']['cancel'] = array( |
|
728 | 728 | '#value' => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))), |
729 | 729 | '#weight' => 1005, |
730 | 730 | '#prefix' => '<li class="tab">', |
731 | 731 | '#suffix' => '</li>' |
732 | - ); |
|
732 | + ); |
|
733 | 733 | |
734 | - $form['emailteam']['form control tabs suffix'] = array( |
|
734 | + $form['emailteam']['form control tabs suffix'] = array( |
|
735 | 735 | '#value' => '</ul>', |
736 | 736 | '#weight' => 1010, |
737 | - ); |
|
737 | + ); |
|
738 | 738 | |
739 | - // Add team id information to form_state |
|
740 | - $form['_team_id'] = array( |
|
739 | + // Add team id information to form_state |
|
740 | + $form['_team_id'] = array( |
|
741 | 741 | '#type' => 'value', |
742 | 742 | '#value' => $team_id, |
743 | - ); |
|
743 | + ); |
|
744 | 744 | |
745 | - // Add sender user object to form_state |
|
746 | - $form['_senderuid'] = array( |
|
745 | + // Add sender user object to form_state |
|
746 | + $form['_senderuid'] = array( |
|
747 | 747 | '#type' => 'value', |
748 | 748 | '#value' => $user->uid, |
749 | - ); |
|
749 | + ); |
|
750 | 750 | |
751 | - // redirect after sending message |
|
752 | - $form['#redirect'] = "community/teams/{$team_id}"; |
|
751 | + // redirect after sending message |
|
752 | + $form['#redirect'] = "community/teams/{$team_id}"; |
|
753 | 753 | |
754 | - return $form; |
|
754 | + return $form; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | 758 | * Send all team members validation handler |
759 | 759 | */ |
760 | 760 | function boincteam_sendmessagetoteam_validate($form, &$form_state) { |
761 | - $message = $form_state['values']; |
|
762 | - $message['timestamp'] = time(); |
|
763 | - // Avoid subjects which only consist of a space as these can not be clicked. |
|
764 | - $message['subject'] = trim($message['subject']); |
|
761 | + $message = $form_state['values']; |
|
762 | + $message['timestamp'] = time(); |
|
763 | + // Avoid subjects which only consist of a space as these can not be clicked. |
|
764 | + $message['subject'] = trim($message['subject']); |
|
765 | 765 | |
766 | - $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
767 | - if (empty($message['subject']) && !empty($trimed_body)) { |
|
766 | + $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
767 | + if (empty($message['subject']) && !empty($trimed_body)) { |
|
768 | 768 | $message['subject'] = $trimed_body; |
769 | 769 | $form_state['values']['subject'] = $message['subject']; |
770 | - } |
|
770 | + } |
|
771 | 771 | |
772 | - // Check subject line |
|
773 | - $message['subject'] = trim($message['subject']); |
|
774 | - if (empty($message['subject'])) { |
|
772 | + // Check subject line |
|
773 | + $message['subject'] = trim($message['subject']); |
|
774 | + if (empty($message['subject'])) { |
|
775 | 775 | form_set_error('subject', |
776 | - bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
776 | + bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
777 | 777 | ); |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | - // Check body |
|
781 | - if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
780 | + // Check body |
|
781 | + if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
782 | 782 | form_set_error('body', |
783 | - bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
783 | + bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
784 | 784 | ); |
785 | - } |
|
785 | + } |
|
786 | 786 | |
787 | - // Check team id |
|
788 | - if (empty($message['_team_id'])) { |
|
787 | + // Check team id |
|
788 | + if (empty($message['_team_id'])) { |
|
789 | 789 | form_set_error('team_id', |
790 | - bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
790 | + bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
791 | 791 | ); |
792 | - } |
|
792 | + } |
|
793 | 793 | |
794 | - $form_state['validated_built_message'] = $message; |
|
794 | + $form_state['validated_built_message'] = $message; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
798 | 798 | * Send all team members submit handler |
799 | 799 | */ |
800 | 800 | function boincteam_sendmessagetoteam_submit($form, &$form_state) { |
801 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
802 | - global $base_url; |
|
803 | - global $base_path; |
|
804 | - |
|
805 | - $suid = $form_state['values']['_senderuid']; |
|
806 | - $account = user_load(array('uid' => $suid )); |
|
807 | - $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
808 | - |
|
809 | - // Form is validated, now send to all team members. Lookup boinc |
|
810 | - // id of all team members, and then use user_load() to load user |
|
811 | - // object. Send message using email. |
|
812 | - // |
|
813 | - $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']); |
|
814 | - // Email addresses, with those who have opt-ed out of notification |
|
815 | - // emails removed. |
|
816 | - $member_emails = _boincteam_emails($boinc_id); |
|
817 | - // Remove sender's email address, unless selfsend is true. |
|
818 | - if ( !$form_state['values']['selfsend'] ) { |
|
801 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
802 | + global $base_url; |
|
803 | + global $base_path; |
|
804 | + |
|
805 | + $suid = $form_state['values']['_senderuid']; |
|
806 | + $account = user_load(array('uid' => $suid )); |
|
807 | + $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
808 | + |
|
809 | + // Form is validated, now send to all team members. Lookup boinc |
|
810 | + // id of all team members, and then use user_load() to load user |
|
811 | + // object. Send message using email. |
|
812 | + // |
|
813 | + $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']); |
|
814 | + // Email addresses, with those who have opt-ed out of notification |
|
815 | + // emails removed. |
|
816 | + $member_emails = _boincteam_emails($boinc_id); |
|
817 | + // Remove sender's email address, unless selfsend is true. |
|
818 | + if ( !$form_state['values']['selfsend'] ) { |
|
819 | 819 | $pos = array_search($account->mail, $member_emails); |
820 | 820 | unset($member_emails[$pos]); |
821 | - } |
|
821 | + } |
|
822 | 822 | |
823 | - // Add link at bottom of body |
|
824 | - $mybody = $form_state['validated_built_message']['body']; |
|
825 | - $mybody .= "\n\n" |
|
826 | - . "To reply to the sender using a Direct Message (DM), please use this link:\n" |
|
827 | - . "${site_url}"; |
|
823 | + // Add link at bottom of body |
|
824 | + $mybody = $form_state['validated_built_message']['body']; |
|
825 | + $mybody .= "\n\n" |
|
826 | + . "To reply to the sender using a Direct Message (DM), please use this link:\n" |
|
827 | + . "${site_url}"; |
|
828 | 828 | |
829 | - $emailsettings = array( |
|
829 | + $emailsettings = array( |
|
830 | 830 | 'from' => '', |
831 | 831 | 'to' => "webmaster@{$base_url}", |
832 | 832 | 'boincteam_headers' => array( |
833 | - 'Bcc' => implode(',', $member_emails), |
|
833 | + 'Bcc' => implode(',', $member_emails), |
|
834 | 834 | ), |
835 | 835 | 'subject' => $form_state['validated_built_message']['subject'], |
836 | 836 | 'message' => $mybody, |
837 | - ); |
|
838 | - rules_action_mail($emailsettings); |
|
837 | + ); |
|
838 | + rules_action_mail($emailsettings); |
|
839 | 839 | |
840 | - $om = bts( |
|
840 | + $om = bts( |
|
841 | 841 | 'Sent your email message to !number team members.', |
842 | 842 | array( '!number' => count($member_emails) ), |
843 | 843 | 'NULL', |
844 | 844 | 'boinc:team-message-sent' |
845 | - ); |
|
846 | - drupal_set_message($om, 'info'); |
|
845 | + ); |
|
846 | + drupal_set_message($om, 'info'); |
|
847 | 847 | |
848 | - $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}"; |
|
848 | + $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}"; |
|
849 | 849 | } |
@@ -15,59 +15,59 @@ discard block |
||
15 | 15 | * Form validation handler for login |
16 | 16 | */ |
17 | 17 | function boincuser_login_validate($form, &$form_state) { |
18 | - /* // SAMPLE: To try validation with Drupal first... |
|
18 | + /* // SAMPLE: To try validation with Drupal first... |
|
19 | 19 | global $user; |
20 | 20 | if (!empty($user->uid)) { |
21 | 21 | // Authentication with Drupal was successful |
22 | 22 | return; |
23 | 23 | }*/ |
24 | 24 | |
25 | - // Set name for logging purposes |
|
26 | - $form_state['values']['name'] = $form_state['values']['email']; |
|
25 | + // Set name for logging purposes |
|
26 | + $form_state['values']['name'] = $form_state['values']['email']; |
|
27 | 27 | |
28 | - // Bypass BOINC validation if passed the name of user 1 |
|
29 | - $user_1 = user_load(1); |
|
30 | - if ($form_state['values']['email'] == $user_1->name) { |
|
28 | + // Bypass BOINC validation if passed the name of user 1 |
|
29 | + $user_1 = user_load(1); |
|
30 | + if ($form_state['values']['email'] == $user_1->name) { |
|
31 | 31 | user_authenticate($form_state['values']); |
32 | 32 | return; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - // Call our custom authentication function to check for an existing BOINC user |
|
36 | - if (!boincuser_login_authenticate($form_state['values'])) { |
|
35 | + // Call our custom authentication function to check for an existing BOINC user |
|
36 | + if (!boincuser_login_authenticate($form_state['values'])) { |
|
37 | 37 | // Authentication failed; set an error accordingly |
38 | 38 | form_set_error('name', bts('Sorry, unrecognized email address or password.', array(), NULL, 'boinc:forgot-password') . ' ' . l(bts('Have you forgotten your password?', array(), NULL, 'boinc:forgot-password'), 'user/password')); |
39 | - } |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Custom authentication function to check BOINC account information |
44 | 44 | */ |
45 | 45 | function boincuser_login_authenticate($form_values) { |
46 | - global $boincuser_authenticated; |
|
47 | - $lower_email_addr = strtolower($form_values['email']); |
|
48 | - $passwd = $form_values['pass']; |
|
49 | - $passwd_hash = md5($passwd.$lower_email_addr); |
|
46 | + global $boincuser_authenticated; |
|
47 | + $lower_email_addr = strtolower($form_values['email']); |
|
48 | + $passwd = $form_values['pass']; |
|
49 | + $passwd_hash = md5($passwd.$lower_email_addr); |
|
50 | 50 | |
51 | - // Include BOINC user library |
|
52 | - require_boinc('boinc_db'); |
|
53 | - require_boinc('user_util'); |
|
51 | + // Include BOINC user library |
|
52 | + require_boinc('boinc_db'); |
|
53 | + require_boinc('user_util'); |
|
54 | 54 | |
55 | - // Get the BOINC user and check credentials |
|
56 | - $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
57 | - if (!$boinc_user) return false; |
|
55 | + // Get the BOINC user and check credentials |
|
56 | + $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
57 | + if (!$boinc_user) return false; |
|
58 | 58 | |
59 | - if (!check_passwd_hash($boinc_user, $passwd_hash)) { |
|
59 | + if (!check_passwd_hash($boinc_user, $passwd_hash)) { |
|
60 | 60 | return false; |
61 | - } |
|
61 | + } |
|
62 | 62 | |
63 | - // BOINC authentication successful; log in and synchronize accounts |
|
64 | - boincuser_login_register($boinc_user); |
|
65 | - // Write session, update timestamp, run user 'login' hook. |
|
66 | - user_authenticate_finalize($form_values); |
|
67 | - // Use a global variable to save the fact that we did authentication. |
|
68 | - $boincuser_authenticated = true; |
|
63 | + // BOINC authentication successful; log in and synchronize accounts |
|
64 | + boincuser_login_register($boinc_user); |
|
65 | + // Write session, update timestamp, run user 'login' hook. |
|
66 | + user_authenticate_finalize($form_values); |
|
67 | + // Use a global variable to save the fact that we did authentication. |
|
68 | + $boincuser_authenticated = true; |
|
69 | 69 | |
70 | - return true; |
|
70 | + return true; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | * Drupal accounts |
76 | 76 | */ |
77 | 77 | function boincuser_login_register($boinc_user) { |
78 | - global $user; |
|
79 | - require_boinc('boinc_db'); |
|
80 | - // If a Drupal account already exists, log in |
|
81 | - $existing_user = user_load(array('mail' => $boinc_user->email_addr)); |
|
82 | - if (!empty($existing_user->uid)) { |
|
78 | + global $user; |
|
79 | + require_boinc('boinc_db'); |
|
80 | + // If a Drupal account already exists, log in |
|
81 | + $existing_user = user_load(array('mail' => $boinc_user->email_addr)); |
|
82 | + if (!empty($existing_user->uid)) { |
|
83 | 83 | $user = $existing_user; |
84 | - } else { |
|
84 | + } else { |
|
85 | 85 | // Create a Drupal user from the BOINC user |
86 | 86 | if ($user = boincuser_register_make_drupal_user($boinc_user)) { |
87 | - watchdog('user', 'New external user: %email using module %module.', array('%email' => $email_addr, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit')); |
|
87 | + watchdog('user', 'New external user: %email using module %module.', array('%email' => $email_addr, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit')); |
|
88 | + } |
|
88 | 89 | } |
89 | - } |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,113 +98,113 @@ discard block |
||
98 | 98 | * New user registration validation handler. |
99 | 99 | */ |
100 | 100 | function boincuser_register_validate($form, &$form_state) { |
101 | - // Include BOINC database objects library |
|
102 | - require_boinc('boinc_db'); |
|
101 | + // Include BOINC database objects library |
|
102 | + require_boinc('boinc_db'); |
|
103 | 103 | |
104 | - // Check terms of use agreement |
|
105 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
106 | - if (!empty($termsofuse)) { |
|
104 | + // Check terms of use agreement |
|
105 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
106 | + if (!empty($termsofuse)) { |
|
107 | 107 | if (!$form_state['values']['termsofuse']['agreeTOU']) { |
108 | - form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', NULL, 'boinc:register-new-user')); |
|
109 | - return false; |
|
108 | + form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', NULL, 'boinc:register-new-user')); |
|
109 | + return false; |
|
110 | + } |
|
110 | 111 | } |
111 | - } |
|
112 | 112 | |
113 | - // Lower-case the email address |
|
114 | - $lower_email_addr = strtolower($form_state['values']['mail']); |
|
115 | - $tmp_user = BoincUser::lookup_prev_email_addr($lower_email_addr); |
|
116 | - if ($tmp_user) { |
|
113 | + // Lower-case the email address |
|
114 | + $lower_email_addr = strtolower($form_state['values']['mail']); |
|
115 | + $tmp_user = BoincUser::lookup_prev_email_addr($lower_email_addr); |
|
116 | + if ($tmp_user) { |
|
117 | 117 | // User already exists |
118 | 118 | rules_invoke_event('boincuser_change_email_error', $lower_email_addr, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
119 | 119 | form_set_error('mail', |
120 | - bts('An account already exists for @email. The @project administrators have been notified.', |
|
120 | + bts('An account already exists for @email. The @project administrators have been notified.', |
|
121 | 121 | array( |
122 | - '@email' => $lower_email_addr, |
|
123 | - '@project' => variable_get('site_name', 'Drupal-BOINC') |
|
122 | + '@email' => $lower_email_addr, |
|
123 | + '@project' => variable_get('site_name', 'Drupal-BOINC') |
|
124 | 124 | ), NULL, 'boinc:register-new-user') |
125 | 125 | ); |
126 | - } |
|
126 | + } |
|
127 | 127 | |
128 | - // Check for an existing BOINC user |
|
129 | - // This is somewhat redundent as Drupal will also check if the email |
|
130 | - // is a duplicate. However, in the case where there is no Drupal |
|
131 | - // account, but a BOINC account exists with this email, the check |
|
132 | - // will fail. |
|
133 | - $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
134 | - if ($boinc_user) { |
|
128 | + // Check for an existing BOINC user |
|
129 | + // This is somewhat redundent as Drupal will also check if the email |
|
130 | + // is a duplicate. However, in the case where there is no Drupal |
|
131 | + // account, but a BOINC account exists with this email, the check |
|
132 | + // will fail. |
|
133 | + $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
134 | + if ($boinc_user) { |
|
135 | 135 | // User already exists |
136 | 136 | form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $lower_email_addr, '@project' => PROJECT), NULL, 'boinc:add-new-user')); |
137 | 137 | return false; |
138 | - } |
|
138 | + } |
|
139 | 139 | |
140 | - // Check Drupal name is not a duplicate, and create a proper drupal |
|
141 | - // name from the boinc username. |
|
142 | - $form_state['values']['name'] = create_proper_drupalname($form_state['values']['boincuser_name']); |
|
140 | + // Check Drupal name is not a duplicate, and create a proper drupal |
|
141 | + // name from the boinc username. |
|
142 | + $form_state['values']['name'] = create_proper_drupalname($form_state['values']['boincuser_name']); |
|
143 | 143 | |
144 | - return true; |
|
144 | + return true; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Create BOINC account |
149 | 149 | */ |
150 | 150 | function boincuser_register_make_user($params) { |
151 | - // Include BOINC user library |
|
152 | - require_boinc('user_util'); |
|
153 | - // Create the BOINC user |
|
154 | - $boinc_user = make_user($params['email_addr'], $params['name'], $params['passwd_hash'], $params['country'], $params['postal_code']); |
|
155 | - return $boinc_user; |
|
151 | + // Include BOINC user library |
|
152 | + require_boinc('user_util'); |
|
153 | + // Create the BOINC user |
|
154 | + $boinc_user = make_user($params['email_addr'], $params['name'], $params['passwd_hash'], $params['country'], $params['postal_code']); |
|
155 | + return $boinc_user; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Create Drupal account from existing BOINC account |
160 | 160 | */ |
161 | 161 | function boincuser_register_make_drupal_user($boinc_user) { |
162 | - $account = null; |
|
163 | - if (is_numeric($boinc_user)) { |
|
162 | + $account = null; |
|
163 | + if (is_numeric($boinc_user)) { |
|
164 | 164 | $boinc_user = boincuser_load($boinc_user); |
165 | - } |
|
166 | - if ($boinc_user) { |
|
165 | + } |
|
166 | + if ($boinc_user) { |
|
167 | 167 | $account = boincuser_create_drupal_user($boinc_user); |
168 | 168 | if ($account) { |
169 | - boincuser_create_drupal_profile($account, $boinc_user); |
|
169 | + boincuser_create_drupal_profile($account, $boinc_user); |
|
170 | + } |
|
170 | 171 | } |
171 | - } |
|
172 | - return $account; |
|
172 | + return $account; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | function boincuser_create_drupal_user($boinc_user) { |
176 | - require_boinc('forum_db'); |
|
177 | - BoincForumPrefs::lookup($boinc_user); |
|
178 | - $account = NULL; |
|
179 | - $module = 'boincuser'; |
|
176 | + require_boinc('forum_db'); |
|
177 | + BoincForumPrefs::lookup($boinc_user); |
|
178 | + $account = NULL; |
|
179 | + $module = 'boincuser'; |
|
180 | 180 | |
181 | - // Verify that this account has not already been imported |
|
182 | - $already_imported = db_result(db_query(' |
|
181 | + // Verify that this account has not already been imported |
|
182 | + $already_imported = db_result(db_query(' |
|
183 | 183 | SELECT COUNT(*) FROM {boincuser} WHERE boinc_id = %d', |
184 | 184 | $boinc_user->id) |
185 | - ); |
|
186 | - if ($already_imported) { |
|
185 | + ); |
|
186 | + if ($already_imported) { |
|
187 | 187 | return NULL; |
188 | - } |
|
188 | + } |
|
189 | 189 | |
190 | - // Email is limited to 64 characters... |
|
191 | - $boinc_email = substr($boinc_user->email_addr, 0, 64); |
|
190 | + // Email is limited to 64 characters... |
|
191 | + $boinc_email = substr($boinc_user->email_addr, 0, 64); |
|
192 | 192 | |
193 | - // Email should be unique |
|
194 | - $already_imported = db_result(db_query(" |
|
193 | + // Email should be unique |
|
194 | + $already_imported = db_result(db_query(" |
|
195 | 195 | SELECT COUNT(*) FROM {users} WHERE mail = '%s'", |
196 | 196 | $boinc_email) |
197 | - ); |
|
198 | - if ($already_imported) { |
|
197 | + ); |
|
198 | + if ($already_imported) { |
|
199 | 199 | drupal_set_message(t('An account for @email already exists', array('@email' => $boinc_email)), 'warning'); |
200 | 200 | watchdog('boincimport', 'An account for @email already exists', array('@email' => $boinc_email), WATCHDOG_WARNING); |
201 | 201 | return NULL; |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - // Make sure name is unique |
|
205 | - $unique_name = create_proper_drupalname($boinc_user->name); |
|
204 | + // Make sure name is unique |
|
205 | + $unique_name = create_proper_drupalname($boinc_user->name); |
|
206 | 206 | |
207 | - $userinfo = array( |
|
207 | + $userinfo = array( |
|
208 | 208 | 'name' => $unique_name, |
209 | 209 | 'pass' => $boinc_user->passwd_hash, |
210 | 210 | 'mail' => $boinc_email, |
@@ -214,126 +214,126 @@ discard block |
||
214 | 214 | 'status' => 1, |
215 | 215 | "authname_{$module}" => $boinc_email, |
216 | 216 | 'access' => time() |
217 | - ); |
|
217 | + ); |
|
218 | 218 | |
219 | - $in_penalty = ($boinc_user->prefs->banished_until > time()); |
|
219 | + $in_penalty = ($boinc_user->prefs->banished_until > time()); |
|
220 | 220 | |
221 | - // Add user to community member role (if no current penalty) |
|
222 | - if (!$in_penalty) { |
|
221 | + // Add user to community member role (if no current penalty) |
|
222 | + if (!$in_penalty) { |
|
223 | 223 | $community_role = array_search('community member', user_roles(true)); |
224 | 224 | $userinfo['roles'] = array( |
225 | - $community_role => '' |
|
225 | + $community_role => '' |
|
226 | 226 | ); |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | - // Mark account as imported so a BOINC account is not created on Insert (i.e. user_save) |
|
230 | - $_SESSION['importedUser'] = true; |
|
231 | - $account = user_save('', $userinfo); |
|
229 | + // Mark account as imported so a BOINC account is not created on Insert (i.e. user_save) |
|
230 | + $_SESSION['importedUser'] = true; |
|
231 | + $account = user_save('', $userinfo); |
|
232 | 232 | |
233 | - // Drupal overrides the original registration date, so update to the correct date |
|
234 | - $account = user_save($account, array('created' => $userinfo['created'])); |
|
233 | + // Drupal overrides the original registration date, so update to the correct date |
|
234 | + $account = user_save($account, array('created' => $userinfo['created'])); |
|
235 | 235 | |
236 | - // Terminate if an error occured during user_save(). |
|
237 | - if (!$account) { |
|
236 | + // Terminate if an error occured during user_save(). |
|
237 | + if (!$account) { |
|
238 | 238 | drupal_set_message(t("Error saving user account."), 'error'); |
239 | 239 | return NULL; |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | - // Cross reference the Drupal and BOINC accounts |
|
243 | - boincuser_account_cross_reference($account->uid, $boinc_user->id); |
|
242 | + // Cross reference the Drupal and BOINC accounts |
|
243 | + boincuser_account_cross_reference($account->uid, $boinc_user->id); |
|
244 | 244 | |
245 | - if ($in_penalty) { |
|
245 | + if ($in_penalty) { |
|
246 | 246 | // Import the timestamp of when the penalty period will be over |
247 | 247 | $boincuser_record = array( |
248 | - 'uid' => $account->uid, |
|
249 | - 'penalty_expiration' => $boinc_user->prefs->banished_until, |
|
248 | + 'uid' => $account->uid, |
|
249 | + 'penalty_expiration' => $boinc_user->prefs->banished_until, |
|
250 | 250 | ); |
251 | 251 | drupal_write_record('boincuser', $boincuser_record, 'uid'); |
252 | - } |
|
252 | + } |
|
253 | 253 | |
254 | - return $account; |
|
254 | + return $account; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | function boincuser_create_drupal_profile($account, $boinc_user) { |
258 | 258 | |
259 | - require_boinc('forum_db'); |
|
260 | - BoincForumPrefs::lookup($boinc_user); |
|
259 | + require_boinc('forum_db'); |
|
260 | + BoincForumPrefs::lookup($boinc_user); |
|
261 | 261 | |
262 | - $image_dir = boinc_get_path('user_image'); |
|
262 | + $image_dir = boinc_get_path('user_image'); |
|
263 | 263 | |
264 | - // Automatically create a content profile |
|
265 | - $now = time(); |
|
266 | - $profile_background = null; |
|
267 | - $profile_opinions = null; |
|
268 | - $profile_image = null; |
|
269 | - $avatar_image = null; |
|
270 | - $profile_approved = NULL; |
|
264 | + // Automatically create a content profile |
|
265 | + $now = time(); |
|
266 | + $profile_background = null; |
|
267 | + $profile_opinions = null; |
|
268 | + $profile_image = null; |
|
269 | + $avatar_image = null; |
|
270 | + $profile_approved = NULL; |
|
271 | 271 | |
272 | - // Load the BOINC profile, if available |
|
273 | - if ($boinc_user->has_profile) { |
|
272 | + // Load the BOINC profile, if available |
|
273 | + if ($boinc_user->has_profile) { |
|
274 | 274 | $boinc_profile = BoincProfile::lookup("userid={$boinc_user->id}"); |
275 | 275 | $profile_background = $boinc_profile->response1; |
276 | 276 | $profile_opinions = $boinc_profile->response2; |
277 | 277 | if ($boinc_profile->has_picture) { |
278 | - // Load picture; load validators; determine where to store it in Drupal |
|
279 | - $image_path = "{$image_dir}/{$boinc_user->id}.jpg"; |
|
280 | - $profile_image = get_cck_image_object($image_path, 'field_profile_image', 'profile', TRUE); |
|
281 | - // If the user does not have a different image as an avatar, use this one |
|
282 | - if (!$boinc_user->prefs->avatar) { |
|
278 | + // Load picture; load validators; determine where to store it in Drupal |
|
279 | + $image_path = "{$image_dir}/{$boinc_user->id}.jpg"; |
|
280 | + $profile_image = get_cck_image_object($image_path, 'field_profile_image', 'profile', TRUE); |
|
281 | + // If the user does not have a different image as an avatar, use this one |
|
282 | + if (!$boinc_user->prefs->avatar) { |
|
283 | 283 | $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
284 | - } |
|
284 | + } |
|
285 | 285 | } |
286 | 286 | if ($boinc_user->prefs->avatar) { |
287 | - $image_path = "{$image_dir}/{$boinc_user->id}_avatar.jpg"; |
|
288 | - $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
|
287 | + $image_path = "{$image_dir}/{$boinc_user->id}_avatar.jpg"; |
|
288 | + $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
|
289 | 289 | } |
290 | 290 | $profile_approved = $boinc_profile->verification ? TRUE : FALSE; |
291 | - } |
|
292 | - $default_input_format = db_result(db_query(" |
|
291 | + } |
|
292 | + $default_input_format = db_result(db_query(" |
|
293 | 293 | SELECT format FROM {filter_formats} WHERE name = '%s'", 'Rich text')); |
294 | - if (!$default_input_format) $default_input_format = 1; |
|
295 | - |
|
296 | - // Populate the profile object |
|
297 | - $profile_node = new stdClass(); |
|
298 | - $profile_node->title = $boinc_user->name; |
|
299 | - $profile_node->uid = $account->uid; |
|
300 | - $profile_node->body = ''; |
|
301 | - $profile_node->type = 'profile'; |
|
302 | - $profile_node->created = $now; |
|
303 | - $profile_node->changed = $now; |
|
304 | - $profile_node->status = 1; |
|
305 | - $profile_node->promote = 0; |
|
306 | - $profile_node->sticky = 0; |
|
307 | - $profile_node->format = $default_input_format; |
|
308 | - $profile_node->name = $account->name; // Set to link profile to account uid! |
|
309 | - $profile_node->field_country[]['value'] = $boinc_user->country; |
|
310 | - $profile_node->field_zip[]['value'] = $boinc_user->postal_code; |
|
311 | - $profile_node->field_url[]['value'] = $boinc_user->url; |
|
312 | - $profile_node->field_background[]['value'] = $profile_background; |
|
313 | - $profile_node->field_opinions[]['value'] = $profile_opinions; |
|
314 | - $profile_node->field_image[] = $avatar_image; |
|
315 | - $profile_node->field_profile_image[] = $profile_image; |
|
316 | - |
|
317 | - // Save the profile object to the database |
|
318 | - // This will automatically set the author uid if node->name has been set |
|
319 | - $profile_node = node_submit($profile_node); |
|
320 | - node_save($profile_node); |
|
321 | - |
|
322 | - // Mark profile as approved if it has already been vetted somehow |
|
323 | - if ($profile_approved OR !$boinc_user->has_profile) { |
|
294 | + if (!$default_input_format) $default_input_format = 1; |
|
295 | + |
|
296 | + // Populate the profile object |
|
297 | + $profile_node = new stdClass(); |
|
298 | + $profile_node->title = $boinc_user->name; |
|
299 | + $profile_node->uid = $account->uid; |
|
300 | + $profile_node->body = ''; |
|
301 | + $profile_node->type = 'profile'; |
|
302 | + $profile_node->created = $now; |
|
303 | + $profile_node->changed = $now; |
|
304 | + $profile_node->status = 1; |
|
305 | + $profile_node->promote = 0; |
|
306 | + $profile_node->sticky = 0; |
|
307 | + $profile_node->format = $default_input_format; |
|
308 | + $profile_node->name = $account->name; // Set to link profile to account uid! |
|
309 | + $profile_node->field_country[]['value'] = $boinc_user->country; |
|
310 | + $profile_node->field_zip[]['value'] = $boinc_user->postal_code; |
|
311 | + $profile_node->field_url[]['value'] = $boinc_user->url; |
|
312 | + $profile_node->field_background[]['value'] = $profile_background; |
|
313 | + $profile_node->field_opinions[]['value'] = $profile_opinions; |
|
314 | + $profile_node->field_image[] = $avatar_image; |
|
315 | + $profile_node->field_profile_image[] = $profile_image; |
|
316 | + |
|
317 | + // Save the profile object to the database |
|
318 | + // This will automatically set the author uid if node->name has been set |
|
319 | + $profile_node = node_submit($profile_node); |
|
320 | + node_save($profile_node); |
|
321 | + |
|
322 | + // Mark profile as approved if it has already been vetted somehow |
|
323 | + if ($profile_approved OR !$boinc_user->has_profile) { |
|
324 | 324 | $profile_node->moderate = 0; |
325 | 325 | node_save($profile_node); |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - return; |
|
328 | + return; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | function boincuser_account_cross_reference($uid, $boinc_id) { |
332 | 332 | // Cross reference Drupal account with BOINC |
333 | 333 | $reference = db_query("INSERT INTO {boincuser} SET uid=%d, boinc_id=%d", $uid, $boinc_id); |
334 | 334 | if (!$reference) { |
335 | - drupal_set_message(t("Error connecting BOINC account."), 'error'); |
|
336 | - return false; |
|
335 | + drupal_set_message(t("Error connecting BOINC account."), 'error'); |
|
336 | + return false; |
|
337 | 337 | } |
338 | 338 | return true; |
339 | 339 | } |
@@ -342,35 +342,35 @@ discard block |
||
342 | 342 | * Convert any BOINC forum thread subscriptions to Drupal flag subscriptions |
343 | 343 | */ |
344 | 344 | function boincuser_pull_subscriptions($account = NULL) { |
345 | - if (!$account) { |
|
345 | + if (!$account) { |
|
346 | 346 | global $user; |
347 | 347 | $account = user_load($user->id); |
348 | - } |
|
349 | - elseif (is_numeric($account)) { |
|
348 | + } |
|
349 | + elseif (is_numeric($account)) { |
|
350 | 350 | $account = user_load($account); |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | - // Get any subscriptions for this user |
|
354 | - db_set_active('boinc_rw'); |
|
355 | - $subscriptions = db_query(' |
|
353 | + // Get any subscriptions for this user |
|
354 | + db_set_active('boinc_rw'); |
|
355 | + $subscriptions = db_query(' |
|
356 | 356 | SELECT threadid FROM {subscriptions} |
357 | 357 | WHERE userid = %d', $account->boincuser_id); |
358 | - db_set_active('default'); |
|
358 | + db_set_active('default'); |
|
359 | 359 | |
360 | - $flag = flag_get_flag('subscriptions') or die('no "subscriptions" flag defined'); |
|
361 | - $count = 0; |
|
362 | - while ($thread_id = db_result($subscriptions)) { |
|
360 | + $flag = flag_get_flag('subscriptions') or die('no "subscriptions" flag defined'); |
|
361 | + $count = 0; |
|
362 | + while ($thread_id = db_result($subscriptions)) { |
|
363 | 363 | // For each BOINC thread ID subscribed, look up the corresponding node ID |
364 | 364 | $nid = db_result(db_query(' |
365 | 365 | SELECT nid FROM {boincimport_temp_topic} |
366 | 366 | WHERE topic_id = %d', $thread_id)); |
367 | 367 | // Flag this node for the user |
368 | 368 | if ($nid > 0) { |
369 | - $flag->flag('flag', $nid, $account); |
|
370 | - $count++; |
|
369 | + $flag->flag('flag', $nid, $account); |
|
370 | + $count++; |
|
371 | + } |
|
371 | 372 | } |
372 | - } |
|
373 | - return $count; |
|
373 | + return $count; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | * User account update validation handler. |
383 | 383 | */ |
384 | 384 | function boincuser_account_validate($edit, $account) { |
385 | - // Include BOINC database objects library, load BOINC account data |
|
386 | - require_boinc('boinc_db'); |
|
387 | - $boinc_user = BoincUser::lookup_email_addr($account->mail); |
|
388 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $account->mail) ? true : false; |
|
389 | - $changing_pass = ($edit['pass']) ? true : false; |
|
390 | - if ($changing_email) { |
|
385 | + // Include BOINC database objects library, load BOINC account data |
|
386 | + require_boinc('boinc_db'); |
|
387 | + $boinc_user = BoincUser::lookup_email_addr($account->mail); |
|
388 | + $changing_email = ($edit['mail'] AND $edit['mail'] != $account->mail) ? true : false; |
|
389 | + $changing_pass = ($edit['pass']) ? true : false; |
|
390 | + if ($changing_email) { |
|
391 | 391 | // E-mail address is set to change; check for an existing BOINC user |
392 | 392 | // Check previous email addresses as well, this user's current |
393 | 393 | // email cannot be the same as another user's previous email |
@@ -398,50 +398,50 @@ discard block |
||
398 | 398 | |
399 | 399 | $boinc_user_already_exists = ( BoincUser::lookup_email_addr($edit['mail']) || BoincUser::lookup_prev_email_addr($edit['mail']) ); |
400 | 400 | if ($boinc_user_already_exists) { |
401 | - form_set_error('mail', bts('A BOINC account already exists for @email.', array('@email' => $edit['mail']), NULL, 'boinc:add-new-user')); |
|
401 | + form_set_error('mail', bts('A BOINC account already exists for @email.', array('@email' => $edit['mail']), NULL, 'boinc:add-new-user')); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | // Check email has not been changed in last X days (default X=7). |
405 | 405 | $duration = 86400 * 7; |
406 | 406 | if ( (($boinc_user->email_addr_change_time + $duration) > time()) and (!(user_access('administer users'))) ) { |
407 | - form_set_error('email_addr_change_time', |
|
407 | + form_set_error('email_addr_change_time', |
|
408 | 408 | bts('Your email address was changed within the past seven (7) days. You must wait until !futuredate to change your email again. If you need to reverse this change, please look for an email sent to !prev_email_addr.', |
409 | 409 | array( |
410 | - '!futuredate' => date('F j, Y \a\t H:i T', $boinc_user->email_addr_change_time + $duration), |
|
411 | - '!prev_email_addr' => $boinc_user->previous_email_addr, |
|
410 | + '!futuredate' => date('F j, Y \a\t H:i T', $boinc_user->email_addr_change_time + $duration), |
|
411 | + '!prev_email_addr' => $boinc_user->previous_email_addr, |
|
412 | 412 | ), |
413 | 413 | NULL, 'boinc:account-credentials-change') |
414 | - ); |
|
414 | + ); |
|
415 | + } |
|
415 | 416 | } |
416 | - } |
|
417 | 417 | |
418 | - // If user is changing email or password, require that the current |
|
419 | - // password has been given as well. |
|
420 | - if (($changing_email OR $changing_pass) AND !user_access('administer users')) { |
|
418 | + // If user is changing email or password, require that the current |
|
419 | + // password has been given as well. |
|
420 | + if (($changing_email OR $changing_pass) AND !user_access('administer users')) { |
|
421 | 421 | // If changing email or password, require current password |
422 | 422 | // (except in cases where password is being reset) |
423 | 423 | if (isset($_SESSION['reset_pass'])) { |
424 | - unset($_SESSION['reset_pass']); |
|
424 | + unset($_SESSION['reset_pass']); |
|
425 | 425 | } |
426 | 426 | else { |
427 | - $given_hash = md5($edit['current_pass'] . strtolower($account->mail)); |
|
428 | - if (!$edit['current_pass']) { |
|
427 | + $given_hash = md5($edit['current_pass'] . strtolower($account->mail)); |
|
428 | + if (!$edit['current_pass']) { |
|
429 | 429 | form_set_error('current_pass', bts('Authentication is required when changing E-mail address or setting new password.', array(), NULL, 'boinc:account-credentials-change')); |
430 | - } |
|
431 | - elseif ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
430 | + } |
|
431 | + elseif ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
432 | 432 | form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:account-credentials-change')); |
433 | - } |
|
433 | + } |
|
434 | 434 | |
435 | 435 | } |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - // If an admin tries to change the email and NOT the password, show |
|
439 | - // error message. BOINC requires both to be changed together. |
|
440 | - if ($changing_email AND !$changing_pass AND user_access('administer users')) { |
|
438 | + // If an admin tries to change the email and NOT the password, show |
|
439 | + // error message. BOINC requires both to be changed together. |
|
440 | + if ($changing_email AND !$changing_pass AND user_access('administer users')) { |
|
441 | 441 | form_set_error('pass', bts('If changing a user\'s email, you must also change the password simultaneously.', array(), NULL, 'boinc:account-credentials-change')); |
442 | - } |
|
442 | + } |
|
443 | 443 | |
444 | - // Expansion required to allow account key in place of passwd...? |
|
444 | + // Expansion required to allow account key in place of passwd...? |
|
445 | 445 | |
446 | 446 | } |
447 | 447 | |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | * Password request validation handler. |
455 | 455 | */ |
456 | 456 | function boincuser_request_pass_validate($form, &$form_state) { |
457 | - $edit = $form_state['values']; |
|
458 | - // The Drupal submit function expects a "name" field, even though |
|
459 | - // it contains an email address and we will not allow a user name |
|
460 | - if (!$edit['name']) form_set_error('name', bts('Please enter your email address', array(), NULL, 'boinc:forgot-password')); |
|
461 | - elseif (!valid_email_address($edit['name'])) form_set_error('name', bts('@email is not a well formed email address, please verify', array('@email' => $edit['name']), NULL, 'boinc:forgot-password')); |
|
462 | - else { |
|
457 | + $edit = $form_state['values']; |
|
458 | + // The Drupal submit function expects a "name" field, even though |
|
459 | + // it contains an email address and we will not allow a user name |
|
460 | + if (!$edit['name']) form_set_error('name', bts('Please enter your email address', array(), NULL, 'boinc:forgot-password')); |
|
461 | + elseif (!valid_email_address($edit['name'])) form_set_error('name', bts('@email is not a well formed email address, please verify', array('@email' => $edit['name']), NULL, 'boinc:forgot-password')); |
|
462 | + else { |
|
463 | 463 | // set email addrress to lower case |
464 | 464 | $lower_email_addr = strtolower($edit['name']); |
465 | 465 | |
@@ -469,110 +469,110 @@ discard block |
||
469 | 469 | require_boinc('boinc_db'); |
470 | 470 | $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
471 | 471 | if ($boinc_user) { |
472 | - // If the user is in BOINC but not Drupal, bring them over... |
|
473 | - boincuser_register_make_drupal_user($boinc_user); |
|
472 | + // If the user is in BOINC but not Drupal, bring them over... |
|
473 | + boincuser_register_make_drupal_user($boinc_user); |
|
474 | 474 | } else { |
475 | - // If there is no existing BOINC user either, show an error |
|
476 | - form_set_error('name', bts('No account exists for @email -- please create an account using a BOINC client -- !instructions', |
|
477 | - array( |
|
478 | - '@email' => $edit['name'], |
|
479 | - '!instructions' => l(bts('Instructions', array(), NULL, 'boinc:forgot-password'), 'join') |
|
480 | - ), NULL, 'boinc:forgot-password')); |
|
481 | - } |
|
482 | - } |
|
475 | + // If there is no existing BOINC user either, show an error |
|
476 | + form_set_error('name', bts('No account exists for @email -- please create an account using a BOINC client -- !instructions', |
|
477 | + array( |
|
478 | + '@email' => $edit['name'], |
|
479 | + '!instructions' => l(bts('Instructions', array(), NULL, 'boinc:forgot-password'), 'join') |
|
480 | + ), NULL, 'boinc:forgot-password')); |
|
481 | + } |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
486 | 486 | * The definition of the authenticator login form. |
487 | 487 | */ |
488 | 488 | function boincuser_authloginform() { |
489 | - $headers = apache_request_headers(); |
|
490 | - $project_name = variable_get('site_name', 'Drupal-BOINC'); |
|
491 | - $project_domain = $headers['Host']; |
|
492 | - $form['heading'] = array( |
|
489 | + $headers = apache_request_headers(); |
|
490 | + $project_name = variable_get('site_name', 'Drupal-BOINC'); |
|
491 | + $project_domain = $headers['Host']; |
|
492 | + $form['heading'] = array( |
|
493 | 493 | '#type' => 'markup', |
494 | 494 | '#value' => '<h3>' . bts("If you forgot your account's email address, or you can't receive email there:", array(), NULL, 'boinc:authenticator-login-page') . '</h3>' |
495 | - ); |
|
496 | - $form['instructions'] = array( |
|
495 | + ); |
|
496 | + $form['instructions'] = array( |
|
497 | 497 | '#type' => 'markup', |
498 | 498 | '#value' => '' . |
499 | - '<p>' . bts("If you have run BOINC under the account, you can still access it. Here's how:", array(), NULL, 'boinc:authenticator-login-page') . |
|
500 | - ' <ul>' . |
|
501 | - ' <li>' . bts('Go to the BOINC data directory on your computer (see !boinc_wiki for help finding this).', array('!boinc_wiki' => l(bts('BOINC documentation', array(), NULL, 'boinc:authenticator-login-page'), 'http://boinc.berkeley.edu/wiki/BOINC_Data_directory')), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
502 | - ' <li>' . bts('Find your account file for this project; it will have a name like %file (where the project URL is %url).', array('%file' => "account_{$project_domain}.xml", '%url' => "http://{$project_domain}"), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
503 | - ' <li>' . bts("Open the file in a text editor like Notepad. You'll see something like:", array(), NULL, 'boinc:authenticator-login-page') . |
|
504 | - ' <pre>' . |
|
505 | - '<account>' . "\n" . |
|
506 | - " <master_url>http://{$project_domain}/</master_url>" . "\n" . |
|
507 | - ' <authenticator>8b8496fdd26df7dc0423ecd43c09a56b</authenticator>' . "\n" . |
|
508 | - " <project_name>{$project_name}</project_name>" . "\n" . |
|
509 | - ' ...' . "\n" . |
|
510 | - '</account>' . |
|
511 | - ' </pre>' . |
|
512 | - ' </li>' . |
|
513 | - ' <li>' . bts('Select and Copy the string between <authenticator> and </authenticator> (%auth in the above example).', array('%auth' => '8b8496fdd26df7dc0423ecd43c09a56b'), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
514 | - ' <li>' . bts('Paste the string into the field below, and click OK.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
515 | - ' <li>' . bts('You will now be logged in to your account; update the email and password of your account.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
516 | - ' </ul>' . |
|
517 | - '</p>' |
|
518 | - ); |
|
519 | - $form['authenticator'] = array( |
|
499 | + '<p>' . bts("If you have run BOINC under the account, you can still access it. Here's how:", array(), NULL, 'boinc:authenticator-login-page') . |
|
500 | + ' <ul>' . |
|
501 | + ' <li>' . bts('Go to the BOINC data directory on your computer (see !boinc_wiki for help finding this).', array('!boinc_wiki' => l(bts('BOINC documentation', array(), NULL, 'boinc:authenticator-login-page'), 'http://boinc.berkeley.edu/wiki/BOINC_Data_directory')), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
502 | + ' <li>' . bts('Find your account file for this project; it will have a name like %file (where the project URL is %url).', array('%file' => "account_{$project_domain}.xml", '%url' => "http://{$project_domain}"), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
503 | + ' <li>' . bts("Open the file in a text editor like Notepad. You'll see something like:", array(), NULL, 'boinc:authenticator-login-page') . |
|
504 | + ' <pre>' . |
|
505 | + '<account>' . "\n" . |
|
506 | + " <master_url>http://{$project_domain}/</master_url>" . "\n" . |
|
507 | + ' <authenticator>8b8496fdd26df7dc0423ecd43c09a56b</authenticator>' . "\n" . |
|
508 | + " <project_name>{$project_name}</project_name>" . "\n" . |
|
509 | + ' ...' . "\n" . |
|
510 | + '</account>' . |
|
511 | + ' </pre>' . |
|
512 | + ' </li>' . |
|
513 | + ' <li>' . bts('Select and Copy the string between <authenticator> and </authenticator> (%auth in the above example).', array('%auth' => '8b8496fdd26df7dc0423ecd43c09a56b'), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
514 | + ' <li>' . bts('Paste the string into the field below, and click OK.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
515 | + ' <li>' . bts('You will now be logged in to your account; update the email and password of your account.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
516 | + ' </ul>' . |
|
517 | + '</p>' |
|
518 | + ); |
|
519 | + $form['authenticator'] = array( |
|
520 | 520 | '#title' => bts('Log in with authenticator', array(), NULL, 'boinc:authenticator-login-page'), |
521 | 521 | '#type' => 'textfield', |
522 | 522 | '#size' => 60, |
523 | 523 | '#maxlength' => 32, |
524 | 524 | '#required' => TRUE, |
525 | 525 | '#description' => null |
526 | - ); |
|
526 | + ); |
|
527 | 527 | |
528 | - // Form control |
|
529 | - $form['form control tabs prefix'] = array( |
|
528 | + // Form control |
|
529 | + $form['form control tabs prefix'] = array( |
|
530 | 530 | '#value' => '<ul class="form-control tab-list">', |
531 | 531 | '#weight' => 1001, |
532 | - ); |
|
533 | - $form['submit'] = array( |
|
532 | + ); |
|
533 | + $form['submit'] = array( |
|
534 | 534 | '#prefix' => '<li class="first tab">', |
535 | 535 | '#type' => 'submit', |
536 | 536 | '#value' => bts('OK', array(), NULL, 'boinc:form-ok'), |
537 | 537 | '#suffix' => '</li>', |
538 | 538 | '#weight' => 1002, |
539 | - ); |
|
540 | - $form['form control tabs'] = array( |
|
539 | + ); |
|
540 | + $form['form control tabs'] = array( |
|
541 | 541 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/password') . '</li>', |
542 | 542 | '#weight' => 1003, |
543 | - ); |
|
544 | - $form['form control tabs suffix'] = array( |
|
543 | + ); |
|
544 | + $form['form control tabs suffix'] = array( |
|
545 | 545 | '#value' => '</ul>', |
546 | 546 | '#weight' => 1004, |
547 | - ); |
|
548 | - return $form; |
|
547 | + ); |
|
548 | + return $form; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
552 | 552 | * The authenticator login validation handler |
553 | 553 | */ |
554 | 554 | function boincuser_authloginform_validate($form, &$form_state) { |
555 | - $authenticator = $form_state['values']['authenticator']; |
|
556 | - if (strlen($authenticator) != 32) { |
|
555 | + $authenticator = $form_state['values']['authenticator']; |
|
556 | + if (strlen($authenticator) != 32) { |
|
557 | 557 | // We notify the form API that this field has failed validation. |
558 | 558 | form_set_error('authenticator', bts('That authenticator is not valid.', array(), NULL, 'boinc:authenticator-login-page')); |
559 | - } else { |
|
559 | + } else { |
|
560 | 560 | require_boinc('boinc_db'); |
561 | 561 | $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
562 | 562 | if (!$boinc_user) form_set_error('authenticator', bts('There is no account with that authenticator.', array(), NULL, 'boinc:authenticator-login-page')); |
563 | - } |
|
563 | + } |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
567 | 567 | * The authenticator login submit handler |
568 | 568 | */ |
569 | 569 | function boincuser_authloginform_submit($form, &$form_state) { |
570 | - global $user; |
|
571 | - $authenticator = $form_state['values']['authenticator']; |
|
572 | - require_boinc('boinc_db'); |
|
573 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
|
574 | - if (!$user = user_load(get_drupal_id($boinc_user->id))) drupal_set_message(t('An unresolved error occurred while logging into this account.')); |
|
575 | - else $form_state['redirect'] = 'account/info/edit'; |
|
570 | + global $user; |
|
571 | + $authenticator = $form_state['values']['authenticator']; |
|
572 | + require_boinc('boinc_db'); |
|
573 | + $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
|
574 | + if (!$user = user_load(get_drupal_id($boinc_user->id))) drupal_set_message(t('An unresolved error occurred while logging into this account.')); |
|
575 | + else $form_state['redirect'] = 'account/info/edit'; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -580,44 +580,44 @@ discard block |
||
580 | 580 | * The definition of the moderator reject user profile form. |
581 | 581 | */ |
582 | 582 | function boincuser_moderate_profile_reject_form(&$form_state, $uid) { |
583 | - $form_state['storage']['reject_profile_uid'] = $uid; |
|
584 | - $form['reason'] = array( |
|
583 | + $form_state['storage']['reject_profile_uid'] = $uid; |
|
584 | + $form['reason'] = array( |
|
585 | 585 | '#title' => bts('Reason for rejecting this profile', array(), NULL, 'boinc:moderate-user'), |
586 | 586 | '#type' => 'textarea', |
587 | 587 | '#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of the problem and how to fix it.', array(), NULL, 'boinc:moderate-user'), |
588 | 588 | '#default_value' => '', |
589 | - ); |
|
589 | + ); |
|
590 | 590 | |
591 | - // Form control |
|
592 | - $form['form control tabs prefix'] = array( |
|
591 | + // Form control |
|
592 | + $form['form control tabs prefix'] = array( |
|
593 | 593 | '#value' => '<ul class="form-control tab-list">', |
594 | 594 | '#weight' => 1001, |
595 | - ); |
|
596 | - $form['submit'] = array( |
|
595 | + ); |
|
596 | + $form['submit'] = array( |
|
597 | 597 | '#prefix' => '<li class="first tab">', |
598 | 598 | '#type' => 'submit', |
599 | 599 | '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
600 | 600 | '#suffix' => '</li>', |
601 | 601 | '#weight' => 1002, |
602 | - ); |
|
603 | - $form['form control tabs'] = array( |
|
602 | + ); |
|
603 | + $form['form control tabs'] = array( |
|
604 | 604 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>', |
605 | 605 | '#weight' => 1003, |
606 | - ); |
|
607 | - $form['form control tabs suffix'] = array( |
|
606 | + ); |
|
607 | + $form['form control tabs suffix'] = array( |
|
608 | 608 | '#value' => '</ul>', |
609 | 609 | '#weight' => 1004, |
610 | - ); |
|
611 | - return $form; |
|
610 | + ); |
|
611 | + return $form; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
615 | 615 | * The moderator reject user profile submit handler |
616 | 616 | */ |
617 | 617 | function boincuser_moderate_profile_reject_form_submit($form, &$form_state) { |
618 | - $uid = $form_state['storage']['reject_profile_uid']; |
|
619 | - $reason = $form_state['values']['reason']; |
|
620 | - boincuser_moderate_profile_reject($uid, $reason); |
|
618 | + $uid = $form_state['storage']['reject_profile_uid']; |
|
619 | + $reason = $form_state['values']['reason']; |
|
620 | + boincuser_moderate_profile_reject($uid, $reason); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | |
@@ -625,52 +625,52 @@ discard block |
||
625 | 625 | * The definition of the ban user form. |
626 | 626 | */ |
627 | 627 | function boincuser_moderate_user_ban_form(&$form_state, $uid) { |
628 | - $form_state['storage']['ban_user_uid'] = $uid; |
|
629 | - $form['reason'] = array( |
|
628 | + $form_state['storage']['ban_user_uid'] = $uid; |
|
629 | + $form['reason'] = array( |
|
630 | 630 | '#title' => bts('Reason for banning this user', array(), NULL, 'boinc:moderate-user'), |
631 | 631 | '#type' => 'textarea', |
632 | 632 | '#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of why the user is being banned.', array(), NULL, 'boinc:moderate-user'), |
633 | 633 | '#default_value' => '', |
634 | - ); |
|
635 | - $form['duration'] = array( |
|
634 | + ); |
|
635 | + $form['duration'] = array( |
|
636 | 636 | '#title' => bts('Duration of the ban', array(), NULL, 'boinc:moderate-user'), |
637 | 637 | '#type' => 'textfield', |
638 | 638 | '#description' => bts('The number of days until the ban expires. Set to 0 to ban permanently.', array(), NULL, 'boinc:moderate-user'), |
639 | 639 | '#default_value' => '', |
640 | - ); |
|
640 | + ); |
|
641 | 641 | |
642 | - // Form control |
|
643 | - $form['form control tabs prefix'] = array( |
|
642 | + // Form control |
|
643 | + $form['form control tabs prefix'] = array( |
|
644 | 644 | '#value' => '<ul class="form-control tab-list">', |
645 | 645 | '#weight' => 1001, |
646 | - ); |
|
647 | - $form['submit'] = array( |
|
646 | + ); |
|
647 | + $form['submit'] = array( |
|
648 | 648 | '#prefix' => '<li class="first tab">', |
649 | 649 | '#type' => 'submit', |
650 | 650 | '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
651 | 651 | '#suffix' => '</li>', |
652 | 652 | '#weight' => 1002, |
653 | - ); |
|
654 | - $form['form control tabs'] = array( |
|
653 | + ); |
|
654 | + $form['form control tabs'] = array( |
|
655 | 655 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>', |
656 | 656 | '#weight' => 1003, |
657 | - ); |
|
658 | - $form['form control tabs suffix'] = array( |
|
657 | + ); |
|
658 | + $form['form control tabs suffix'] = array( |
|
659 | 659 | '#value' => '</ul>', |
660 | 660 | '#weight' => 1004, |
661 | - ); |
|
662 | - return $form; |
|
661 | + ); |
|
662 | + return $form; |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
666 | 666 | * The ban user submit handler |
667 | 667 | */ |
668 | 668 | function boincuser_moderate_user_ban_form_submit($form, &$form_state) { |
669 | - $uid = $form_state['storage']['ban_user_uid']; |
|
670 | - $reason = $form_state['values']['reason']; |
|
671 | - $duration = $form_state['values']['duration']; |
|
672 | - if ($duration) $duration = $duration * 24*60*60; |
|
673 | - boincuser_moderate_user_ban($uid, $reason, $duration); |
|
669 | + $uid = $form_state['storage']['ban_user_uid']; |
|
670 | + $reason = $form_state['values']['reason']; |
|
671 | + $duration = $form_state['values']['duration']; |
|
672 | + if ($duration) $duration = $duration * 24*60*60; |
|
673 | + boincuser_moderate_user_ban($uid, $reason, $duration); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | |
@@ -678,10 +678,10 @@ discard block |
||
678 | 678 | * Hack to fix submission of the flag friend unfriend form |
679 | 679 | */ |
680 | 680 | function boincuser_fix_unfriend_form_submit($form, &$form_state) { |
681 | - // Leaving action as "unfriend" causes problems |
|
682 | - if ($form_state['values']['action'] == 'unfriend') { |
|
681 | + // Leaving action as "unfriend" causes problems |
|
682 | + if ($form_state['values']['action'] == 'unfriend') { |
|
683 | 683 | $form_state['values']['action'] = 'unflag'; |
684 | - } |
|
684 | + } |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -689,102 +689,102 @@ discard block |
||
689 | 689 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
690 | 690 | |
691 | 691 | function boincuser_termsofuse_form() { |
692 | - global $user; |
|
692 | + global $user; |
|
693 | 693 | |
694 | - // If user has already signed terms of use, and got to this form in error, send them to site home. |
|
695 | - if (boincuser_check_termsofuse($user)) { |
|
694 | + // If user has already signed terms of use, and got to this form in error, send them to site home. |
|
695 | + if (boincuser_check_termsofuse($user)) { |
|
696 | 696 | drupal_goto(); |
697 | - } |
|
697 | + } |
|
698 | 698 | |
699 | - drupal_set_message( bts('WARNING: You have not agreed to our terms of use. Please agree to the terms of use before continuing.', array(), NULL, 'boinc:termsofuse-form'), 'warning' ); |
|
699 | + drupal_set_message( bts('WARNING: You have not agreed to our terms of use. Please agree to the terms of use before continuing.', array(), NULL, 'boinc:termsofuse-form'), 'warning' ); |
|
700 | 700 | |
701 | - $form = array(); |
|
702 | - drupal_add_js(drupal_get_path('module', 'boincuser') . '/boincuser.js'); |
|
703 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
701 | + $form = array(); |
|
702 | + drupal_add_js(drupal_get_path('module', 'boincuser') . '/boincuser.js'); |
|
703 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
704 | 704 | |
705 | - // Fieldset to hold all of the form as a container |
|
706 | - $form['termsofuse'] = array( |
|
705 | + // Fieldset to hold all of the form as a container |
|
706 | + $form['termsofuse'] = array( |
|
707 | 707 | '#type' => 'fieldset', |
708 | 708 | '#prefix' => '<div id="termsofuse-wrapper">', // This is our wrapper div. |
709 | 709 | '#suffix' => '</div>', |
710 | 710 | '#tree' => TRUE, |
711 | - ); |
|
711 | + ); |
|
712 | 712 | |
713 | - $form['termsofuse']['title1'] = array( |
|
713 | + $form['termsofuse']['title1'] = array( |
|
714 | 714 | '#weight' => -12, |
715 | 715 | '#value' => '<h2>' . bts( variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:termsofuse-form' ) . '</h2>', |
716 | 716 | '#prefix' => '<div id="register-title1">', |
717 | 717 | '#suffix' => '</div>', |
718 | - ); |
|
718 | + ); |
|
719 | 719 | |
720 | - // Terms of use section |
|
721 | - $form['termsofuse']['body'] = array( |
|
720 | + // Terms of use section |
|
721 | + $form['termsofuse']['body'] = array( |
|
722 | 722 | '#weight' => -10, |
723 | 723 | '#value' => bts($termsofuse, array(), NULL, 'project:termsofuse-form'), |
724 | 724 | '#prefix' => '<div id="register-termsofuse">', |
725 | 725 | '#suffix' => '</div>', |
726 | - ); |
|
726 | + ); |
|
727 | 727 | |
728 | - $form['termsofuse']['agreeTOU'] = array( |
|
728 | + $form['termsofuse']['agreeTOU'] = array( |
|
729 | 729 | '#type' => 'checkbox', |
730 | 730 | '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:termsofuse-form'), |
731 | 731 | '#weight' => -8, |
732 | 732 | '#prefix' => '<div id="register-checkbox">', |
733 | 733 | '#suffix' => '</div>', |
734 | - ); |
|
734 | + ); |
|
735 | 735 | |
736 | - $form['termsofuse']['spacer'] = array( |
|
736 | + $form['termsofuse']['spacer'] = array( |
|
737 | 737 | '#prefix' => '<div class="clearfix" id="register-title2">', |
738 | 738 | '#value' => ' ', |
739 | 739 | '#suffix' => '</div>', |
740 | - ); |
|
740 | + ); |
|
741 | 741 | |
742 | - // Form Control |
|
743 | - $form['submit'] = array( |
|
742 | + // Form Control |
|
743 | + $form['submit'] = array( |
|
744 | 744 | '#prefix' => '<p><p><p><li class="first tab" id="register-submit">', |
745 | 745 | '#type' => 'submit', |
746 | 746 | '#value' => bts('Yes', array(), NULL, 'boinc:form-submit'), |
747 | 747 | '#suffix' => '</li>', |
748 | - ); |
|
749 | - $form['form control tabs'] = array( |
|
748 | + ); |
|
749 | + $form['form control tabs'] = array( |
|
750 | 750 | '#value' => '<li class="tab">' . l(bts('NO - LOGOUT', array(), NULL, 'boinc:form-cancel'), '/logout') . '</li>', |
751 | - ); |
|
752 | - if (module_exists('boincuser_delete')) { |
|
751 | + ); |
|
752 | + if (module_exists('boincuser_delete')) { |
|
753 | 753 | $deletelink = '/user/' . $user->uid . '/delete'; |
754 | 754 | $form['deleteaccount'] = array( |
755 | - '#value' => '<li class="tab">' . l(bts('NO - DELETE ACCOUNT', array(), NULL, 'boinc:form-delete-user'), $deletelink) . '</li>', |
|
755 | + '#value' => '<li class="tab">' . l(bts('NO - DELETE ACCOUNT', array(), NULL, 'boinc:form-delete-user'), $deletelink) . '</li>', |
|
756 | 756 | ); |
757 | - } |
|
757 | + } |
|
758 | 758 | |
759 | - // Set form redirect |
|
760 | - $form['#redirect'] = $_REQUEST['destination']; |
|
759 | + // Set form redirect |
|
760 | + $form['#redirect'] = $_REQUEST['destination']; |
|
761 | 761 | |
762 | - // Add the current user's data into the form |
|
763 | - $form['#account'] = $user; |
|
762 | + // Add the current user's data into the form |
|
763 | + $form['#account'] = $user; |
|
764 | 764 | |
765 | - return $form; |
|
765 | + return $form; |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | function boincuser_termsofuse_form_validate($form, &$form_state) { |
769 | - // Check TOU agreement |
|
770 | - if (!$form_state['values']['termsofuse']['agreeTOU']) { |
|
769 | + // Check TOU agreement |
|
770 | + if (!$form_state['values']['termsofuse']['agreeTOU']) { |
|
771 | 771 | form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', array(), NULL, 'boinc:termsofuse-form')); |
772 | - } |
|
772 | + } |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | function boincuser_termsofuse_form_submit($form, &$form_state) { |
776 | - $user = $form['#account']; |
|
777 | - if (!boincuser_consentto_termsofuse($user)) { |
|
776 | + $user = $form['#account']; |
|
777 | + if (!boincuser_consentto_termsofuse($user)) { |
|
778 | 778 | form_set_error('termsofuse', |
779 | - bts('There was an error in agreeing to the terms of use. The @project administrators have been notified.', |
|
779 | + bts('There was an error in agreeing to the terms of use. The @project administrators have been notified.', |
|
780 | 780 | array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:termsofuse-form') |
781 | 781 | ); |
782 | - } |
|
782 | + } |
|
783 | 783 | |
784 | - // Delete session messages |
|
785 | - if ($_SESSION['messages']['warning']) { |
|
784 | + // Delete session messages |
|
785 | + if ($_SESSION['messages']['warning']) { |
|
786 | 786 | unset($_SESSION['messages']['warning']); |
787 | - } |
|
787 | + } |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
@@ -793,89 +793,89 @@ discard block |
||
793 | 793 | * removed after used. |
794 | 794 | */ |
795 | 795 | function boincuser_revertemail(&$form_state, $token) { |
796 | - require_boinc('token'); |
|
797 | - require_boinc('util'); |
|
796 | + require_boinc('token'); |
|
797 | + require_boinc('util'); |
|
798 | 798 | |
799 | - global $user; |
|
800 | - $form = array(); |
|
799 | + global $user; |
|
800 | + $form = array(); |
|
801 | 801 | |
802 | - // drupal JS for dynamic password validation |
|
803 | - _user_password_dynamic_validation(); |
|
802 | + // drupal JS for dynamic password validation |
|
803 | + _user_password_dynamic_validation(); |
|
804 | 804 | |
805 | - // check BOINC user exists |
|
806 | - $account = user_load(array('uid' => $user->uid)); |
|
807 | - $uid = $user->uid; |
|
808 | - $boincid = $account->boincuser_id; |
|
809 | - // check $token is valid |
|
810 | - if (!is_valid_token($boincid, $token, 'E')) { |
|
805 | + // check BOINC user exists |
|
806 | + $account = user_load(array('uid' => $user->uid)); |
|
807 | + $uid = $user->uid; |
|
808 | + $boincid = $account->boincuser_id; |
|
809 | + // check $token is valid |
|
810 | + if (!is_valid_token($boincid, $token, 'E')) { |
|
811 | 811 | drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your email address.', |
812 | 812 | array( |
813 | - '!link' => l(bts('changing', array(), NULL, 'boinc:revert-email-change'), "/account/info/edit"), |
|
813 | + '!link' => l(bts('changing', array(), NULL, 'boinc:revert-email-change'), "/account/info/edit"), |
|
814 | 814 | ), |
815 | 815 | NULL, 'boinc:revert-email-change'), 'error'); |
816 | 816 | drupal_goto(); |
817 | - } |
|
817 | + } |
|
818 | 818 | |
819 | - // Attach account and token to this form. |
|
820 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
821 | - $form['_token'] = array('#type' => 'value', '#value' => $token); |
|
819 | + // Attach account and token to this form. |
|
820 | + $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
821 | + $form['_token'] = array('#type' => 'value', '#value' => $token); |
|
822 | 822 | |
823 | - // Instructions |
|
824 | - $form['main']['instructions1'] = array( |
|
823 | + // Instructions |
|
824 | + $form['main']['instructions1'] = array( |
|
825 | 825 | '#value' => '<p>'. |
826 | 826 | bts('In order to change your email back to your previous email address, <strong>!prev_email</strong>, you must also change your password.', |
827 | - array( |
|
827 | + array( |
|
828 | 828 | '!prev_email' => $account->boincuser_previous_email_addr, |
829 | - ), |
|
830 | - NULL, 'boinc:revert-email-change'). |
|
829 | + ), |
|
830 | + NULL, 'boinc:revert-email-change'). |
|
831 | 831 | '</p>', |
832 | - ); |
|
832 | + ); |
|
833 | 833 | |
834 | - $form['main']['pass'] = array( |
|
834 | + $form['main']['pass'] = array( |
|
835 | 835 | '#type' => 'password_confirm', |
836 | 836 | '#description' => 'Enter a new password in both fields', |
837 | 837 | '#size' => 17, |
838 | - ); |
|
839 | - |
|
840 | - // Wrap action buttons for styling consistency |
|
841 | - $form['buttons']['form control tabs prefix'] = array( |
|
842 | - '#value' => '<ul class="form-control tab-list">', |
|
843 | - '#weight' => 1001, |
|
844 | - ); |
|
845 | - $form['buttons']['submit']['#type'] = 'submit'; |
|
846 | - $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
|
847 | - $form['buttons']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
848 | - $form['buttons']['submit']['#suffix'] = '</li>'; |
|
849 | - $form['buttons']['submit']['#weight'] = 1002; |
|
850 | - $form['buttons']['cancel'] = array( |
|
851 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/info/edit') . '</li>', |
|
852 | - '#weight' => 1005, |
|
853 | - ); |
|
854 | - $form['buttons']['form control tabs suffix'] = array( |
|
855 | - '#value' => '</ul>', |
|
856 | - '#weight' => 1010, |
|
857 | - ); |
|
858 | - |
|
859 | - return $form; |
|
838 | + ); |
|
839 | + |
|
840 | + // Wrap action buttons for styling consistency |
|
841 | + $form['buttons']['form control tabs prefix'] = array( |
|
842 | + '#value' => '<ul class="form-control tab-list">', |
|
843 | + '#weight' => 1001, |
|
844 | + ); |
|
845 | + $form['buttons']['submit']['#type'] = 'submit'; |
|
846 | + $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
|
847 | + $form['buttons']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
848 | + $form['buttons']['submit']['#suffix'] = '</li>'; |
|
849 | + $form['buttons']['submit']['#weight'] = 1002; |
|
850 | + $form['buttons']['cancel'] = array( |
|
851 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/info/edit') . '</li>', |
|
852 | + '#weight' => 1005, |
|
853 | + ); |
|
854 | + $form['buttons']['form control tabs suffix'] = array( |
|
855 | + '#value' => '</ul>', |
|
856 | + '#weight' => 1010, |
|
857 | + ); |
|
858 | + |
|
859 | + return $form; |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
863 | 863 | * Validation handler for revertemail form |
864 | 864 | */ |
865 | 865 | function boincuser_revertemail_validate($form, &$form_state) { |
866 | - // Load account and boincuser |
|
867 | - $account = $form_state['values']['_account']; |
|
868 | - $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
866 | + // Load account and boincuser |
|
867 | + $account = $form_state['values']['_account']; |
|
868 | + $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
869 | 869 | |
870 | - if (BoincUser::lookup_email_addr($boinc_user->previous_email_addr)) { |
|
870 | + if (BoincUser::lookup_email_addr($boinc_user->previous_email_addr)) { |
|
871 | 871 | rules_invoke_event('boincuser_revert_email_error', $boinc_user->previous_email_addr, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
872 | 872 | form_set_error('mail', |
873 | - bts('An account already exists for @email. Previous email address cannot be used because another account is using it as their email address. The @project administrators have been notified.', |
|
873 | + bts('An account already exists for @email. Previous email address cannot be used because another account is using it as their email address. The @project administrators have been notified.', |
|
874 | 874 | array( |
875 | - '@email' => $boinc_user->previous_email_addr, |
|
876 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
875 | + '@email' => $boinc_user->previous_email_addr, |
|
876 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
877 | 877 | ), NULL, 'boinc:add-new-user')); |
878 | - } |
|
878 | + } |
|
879 | 879 | |
880 | 880 | } |
881 | 881 | |
@@ -883,25 +883,25 @@ discard block |
||
883 | 883 | * Submit handler for revertemail form |
884 | 884 | */ |
885 | 885 | function boincuser_revertemail_submit($form, &$form_state) { |
886 | - require_boinc('password_compat/password'); |
|
886 | + require_boinc('password_compat/password'); |
|
887 | 887 | |
888 | - // Load account and boincuser |
|
889 | - $account = $form_state['values']['_account']; |
|
890 | - $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
888 | + // Load account and boincuser |
|
889 | + $account = $form_state['values']['_account']; |
|
890 | + $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
891 | 891 | |
892 | - $pem = strtolower($boinc_user->previous_email_addr); |
|
892 | + $pem = strtolower($boinc_user->previous_email_addr); |
|
893 | 893 | |
894 | - // Set new password based on previous email address and entered |
|
895 | - // password. |
|
896 | - $new_passwd_hash = password_hash( md5($form_state['values']['pass'].$pem), PASSWORD_DEFAULT); |
|
894 | + // Set new password based on previous email address and entered |
|
895 | + // password. |
|
896 | + $new_passwd_hash = password_hash( md5($form_state['values']['pass'].$pem), PASSWORD_DEFAULT); |
|
897 | 897 | |
898 | - $boinc_user->update("email_addr='${pem}', previous_email_addr='', email_addr_change_time=0, passwd_hash='${new_passwd_hash}'"); |
|
898 | + $boinc_user->update("email_addr='${pem}', previous_email_addr='', email_addr_change_time=0, passwd_hash='${new_passwd_hash}'"); |
|
899 | 899 | |
900 | - // Set email in drupal database to previous email |
|
901 | - user_save($account, array('mail' => $pem)); |
|
900 | + // Set email in drupal database to previous email |
|
901 | + user_save($account, array('mail' => $pem)); |
|
902 | 902 | |
903 | - // delete the token |
|
904 | - $result = delete_token($account->boincuser_id, $form_state['values']['_token'], 'E'); |
|
903 | + // delete the token |
|
904 | + $result = delete_token($account->boincuser_id, $form_state['values']['_token'], 'E'); |
|
905 | 905 | |
906 | - drupal_goto('account'); |
|
906 | + drupal_goto('account'); |
|
907 | 907 | } |
@@ -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 |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | 12 | |
13 | 13 | if (!function_exists('user_load_by_mail')) { |
14 | - /** |
|
15 | - * user_load_by_mail will be broken out of user_load |
|
16 | - */ |
|
17 | - function user_load_by_mail($mail) { |
|
14 | + /** |
|
15 | + * user_load_by_mail will be broken out of user_load |
|
16 | + */ |
|
17 | + function user_load_by_mail($mail) { |
|
18 | 18 | return user_load(array('mail' => $mail)); |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * Get an image object from a given file and cck field |
29 | 29 | */ |
30 | 30 | function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) { |
31 | - $field = content_fields($field_name, $content_type); |
|
32 | - $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
33 | - if ($ignore_resolution) { |
|
31 | + $field = content_fields($field_name, $content_type); |
|
32 | + $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
33 | + if ($ignore_resolution) { |
|
34 | 34 | unset($validators['filefield_validate_image_resolution']); |
35 | - } |
|
36 | - $target_path = filefield_widget_file_path($field); |
|
37 | - // Create the image object |
|
38 | - return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
35 | + } |
|
36 | + $target_path = filefield_widget_file_path($field); |
|
37 | + // Create the image object |
|
38 | + return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,73 +47,73 @@ discard block |
||
47 | 47 | * |
48 | 48 | */ |
49 | 49 | function boincuser_check_credit_requirements() { |
50 | - global $user; |
|
51 | - if (!$user->uid) { |
|
50 | + global $user; |
|
51 | + if (!$user->uid) { |
|
52 | 52 | return FALSE; |
53 | - } |
|
54 | - $account = user_load($user->uid); |
|
55 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
56 | - $community_role = array_search('community member', user_roles(true)); |
|
57 | - $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
53 | + } |
|
54 | + $account = user_load($user->uid); |
|
55 | + $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
56 | + $community_role = array_search('community member', user_roles(true)); |
|
57 | + $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
58 | 58 | |
59 | - // Set user roles based on current penalty status... |
|
60 | - if ($account->boincuser_penalty_expiration > time()) { |
|
59 | + // Set user roles based on current penalty status... |
|
60 | + if ($account->boincuser_penalty_expiration > time()) { |
|
61 | 61 | drupal_set_message(bts( |
62 | - 'You are banned from community participation until @date', |
|
63 | - array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
62 | + 'You are banned from community participation until @date', |
|
63 | + array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
64 | 64 | ), 'warning', FALSE); |
65 | 65 | if (isset($account->roles[$community_role])) { |
66 | - // Remove from the community role, if not already |
|
67 | - unset($account->roles[$community_role]); |
|
66 | + // Remove from the community role, if not already |
|
67 | + unset($account->roles[$community_role]); |
|
68 | 68 | } |
69 | 69 | if (isset($account->roles[$unrestricted_role])) { |
70 | - // Likewise, revoke extra privileges |
|
71 | - unset($account->roles[$unrestricted_role]); |
|
70 | + // Likewise, revoke extra privileges |
|
71 | + unset($account->roles[$unrestricted_role]); |
|
72 | 72 | } |
73 | 73 | user_save($account, array('roles' => $account->roles)); |
74 | - } |
|
75 | - else { |
|
74 | + } |
|
75 | + else { |
|
76 | 76 | if (!isset($account->roles[$community_role])) { |
77 | - // The user should be a 'community member' role. If the user was |
|
78 | - // previously banned, this will restore that role. |
|
79 | - $account->roles[$community_role] = 'community member'; |
|
80 | - user_save($account, array('roles' => $account->roles)); |
|
77 | + // The user should be a 'community member' role. If the user was |
|
78 | + // previously banned, this will restore that role. |
|
79 | + $account->roles[$community_role] = 'community member'; |
|
80 | + user_save($account, array('roles' => $account->roles)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // ... and total credit. |
84 | 84 | if ($account->boincuser_total_credit >= $min_credit_to_post) { |
85 | - if (!isset($account->roles[$unrestricted_role])) { |
|
85 | + if (!isset($account->roles[$unrestricted_role])) { |
|
86 | 86 | // This user is now above the credit threshold and is allowed full |
87 | 87 | // privileges |
88 | 88 | $account->roles[$unrestricted_role] = 'verified contributor'; |
89 | 89 | user_save($account, array('roles' => $account->roles)); |
90 | - } |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | else { |
93 | - drupal_set_message(bts( |
|
93 | + drupal_set_message(bts( |
|
94 | 94 | 'You must earn @count more credits to be able to post comments on this site and create or modify your user profile.', |
95 | 95 | array('@count' => $min_credit_to_post - $account->boincuser_total_credit) |
96 | - ), 'warning', FALSE); |
|
97 | - if (isset($account->roles[$unrestricted_role])) { |
|
96 | + ), 'warning', FALSE); |
|
97 | + if (isset($account->roles[$unrestricted_role])) { |
|
98 | 98 | // Either the threshold has been raised or credits have been revoked; |
99 | 99 | // this user no longer qualifies for full privileges |
100 | 100 | unset($account->roles[$unrestricted_role]); |
101 | 101 | user_save($account, array('roles' => $account->roles)); |
102 | - } |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | |
105 | - } |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Get the cid of the first comment the user has not seen on a given node |
110 | 110 | */ |
111 | 111 | function boincuser_get_first_unread_comment_id($nid, $uid = NULL) { |
112 | - if (!$uid) { |
|
112 | + if (!$uid) { |
|
113 | 113 | global $user; |
114 | 114 | $uid = $user->uid; |
115 | - } |
|
116 | - return db_result(db_query(" |
|
115 | + } |
|
116 | + return db_result(db_query(" |
|
117 | 117 | SELECT c.cid |
118 | 118 | FROM {node} n |
119 | 119 | INNER JOIN {comments} c ON c.nid = n.nid |
@@ -124,40 +124,40 @@ discard block |
||
124 | 124 | ORDER BY c.timestamp ASC |
125 | 125 | LIMIT 1", |
126 | 126 | $uid, $nid |
127 | - )); |
|
127 | + )); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * Choose and set the user of the day |
132 | 132 | */ |
133 | 133 | function boincuser_select_user_of_the_day() { |
134 | - // First get a list of users with recent credit |
|
135 | - db_set_active('boinc_rw'); |
|
136 | - $users_with_credit = db_query(" |
|
134 | + // First get a list of users with recent credit |
|
135 | + db_set_active('boinc_rw'); |
|
136 | + $users_with_credit = db_query(" |
|
137 | 137 | SELECT |
138 | 138 | id |
139 | 139 | FROM {user} u |
140 | 140 | JOIN {profile} p ON p.userid = u.id |
141 | 141 | WHERE expavg_credit > 1 |
142 | 142 | ORDER BY uotd_time ASC, RAND()" |
143 | - ); |
|
144 | - db_set_active('default'); |
|
145 | - $active_users = array(); |
|
146 | - while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
143 | + ); |
|
144 | + db_set_active('default'); |
|
145 | + $active_users = array(); |
|
146 | + while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
147 | 147 | $active_users[] = $user_with_credit->id; |
148 | - } |
|
149 | - $active_users = implode(',', $active_users); |
|
150 | - // Limit to users who have never been user of the day, if there are any |
|
151 | - $never_been_picked = db_result(db_query(" |
|
148 | + } |
|
149 | + $active_users = implode(',', $active_users); |
|
150 | + // Limit to users who have never been user of the day, if there are any |
|
151 | + $never_been_picked = db_result(db_query(" |
|
152 | 152 | SELECT COUNT(*) |
153 | 153 | FROM {boincuser} bu |
154 | 154 | WHERE bu.uotd_time = 0 |
155 | 155 | " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') |
156 | - )); |
|
157 | - $new_uotd_uid = 0; |
|
158 | - while (!$new_uotd_uid) { |
|
156 | + )); |
|
157 | + $new_uotd_uid = 0; |
|
158 | + while (!$new_uotd_uid) { |
|
159 | 159 | // Select a user of the day randomly from the pool |
160 | - $new_uotd_uid = db_result(db_query(" |
|
160 | + $new_uotd_uid = db_result(db_query(" |
|
161 | 161 | SELECT |
162 | 162 | n.uid |
163 | 163 | FROM {node} n |
@@ -171,31 +171,31 @@ discard block |
||
171 | 171 | LIMIT 1" |
172 | 172 | )); |
173 | 173 | if (!$new_uotd_uid) { |
174 | - // Can't find a user with a profile; remove constraints on the pool |
|
175 | - if ($never_been_picked) { |
|
174 | + // Can't find a user with a profile; remove constraints on the pool |
|
175 | + if ($never_been_picked) { |
|
176 | 176 | // Allow users who have been previously selected |
177 | 177 | $never_been_picked = FALSE; |
178 | - } |
|
179 | - elseif ($active_users) { |
|
178 | + } |
|
179 | + elseif ($active_users) { |
|
180 | 180 | // Allow users who are not even active (getting desperate) |
181 | 181 | $active_users = FALSE; |
182 | - } |
|
183 | - else { |
|
182 | + } |
|
183 | + else { |
|
184 | 184 | // Process failed... |
185 | 185 | return FALSE; |
186 | - } |
|
186 | + } |
|
187 | 187 | } |
188 | - } |
|
189 | - $uotd = user_load($new_uotd_uid); |
|
190 | - if ($uotd->uid) { |
|
188 | + } |
|
189 | + $uotd = user_load($new_uotd_uid); |
|
190 | + if ($uotd->uid) { |
|
191 | 191 | db_query(" |
192 | 192 | UPDATE {boincuser} |
193 | 193 | SET uotd_time = '%d' |
194 | 194 | WHERE uid = '%d'", |
195 | - time(), $uotd->uid |
|
195 | + time(), $uotd->uid |
|
196 | 196 | ); |
197 | - } |
|
198 | - return $uotd; |
|
197 | + } |
|
198 | + return $uotd; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -213,71 +213,71 @@ discard block |
||
213 | 213 | * new and prev email. |
214 | 214 | */ |
215 | 215 | function _boincuser_send_emailchange($account, $new_email=NULL, $prev_email=NULL, $adminuser=FALSE) { |
216 | - require_boinc('token'); |
|
217 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
216 | + require_boinc('token'); |
|
217 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
218 | 218 | |
219 | - global $base_url; |
|
220 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
219 | + global $base_url; |
|
220 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
221 | 221 | |
222 | - if (is_null($new_email)) { |
|
222 | + if (is_null($new_email)) { |
|
223 | 223 | $new_email = $account->mail; |
224 | - } |
|
225 | - if (is_null($prev_email)) { |
|
224 | + } |
|
225 | + if (is_null($prev_email)) { |
|
226 | 226 | $prev_email = $account->boincuser_previous_email_addr; |
227 | - } |
|
228 | - |
|
229 | - // @todo - set constant in drupal, or use BOINC contsants |
|
230 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
231 | - $changedate = date('F j, Y \a\t G:i T', time()); |
|
232 | - $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
233 | - $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
234 | - if ($adminuser) { |
|
227 | + } |
|
228 | + |
|
229 | + // @todo - set constant in drupal, or use BOINC contsants |
|
230 | + $duration = TOKEN_DURATION_ONE_WEEK; |
|
231 | + $changedate = date('F j, Y \a\t G:i T', time()); |
|
232 | + $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
233 | + $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
234 | + if ($adminuser) { |
|
235 | 235 | $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
236 | - . "on {$changedate}. If you need to reverse this change, please look for " |
|
237 | - . "an email send to the email address: {$prev_email}.\n"; |
|
238 | - } |
|
239 | - else { |
|
236 | + . "on {$changedate}. If you need to reverse this change, please look for " |
|
237 | + . "an email send to the email address: {$prev_email}.\n"; |
|
238 | + } |
|
239 | + else { |
|
240 | 240 | $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
241 | - . "on {$changedate}. You will not be able to change your email address " |
|
242 | - . "until {$newdate}. If you need to reverse this change, please look for " |
|
243 | - . "an email send to the email address: {$prev_email}.\n"; |
|
244 | - } |
|
245 | - |
|
246 | - // Send email #1 to current address |
|
247 | - $mysubject = "Notification of email change at {$site_name}"; |
|
248 | - $mymessage = '' |
|
249 | - . "{$account->boincuser_name},\n" |
|
250 | - . "\n" |
|
251 | - . $graf1 |
|
252 | - . "\n" |
|
253 | - . "Thanks, \n" |
|
254 | - . "{$site_name} support team\n"; |
|
255 | - |
|
256 | - $settings = array( |
|
241 | + . "on {$changedate}. You will not be able to change your email address " |
|
242 | + . "until {$newdate}. If you need to reverse this change, please look for " |
|
243 | + . "an email send to the email address: {$prev_email}.\n"; |
|
244 | + } |
|
245 | + |
|
246 | + // Send email #1 to current address |
|
247 | + $mysubject = "Notification of email change at {$site_name}"; |
|
248 | + $mymessage = '' |
|
249 | + . "{$account->boincuser_name},\n" |
|
250 | + . "\n" |
|
251 | + . $graf1 |
|
252 | + . "\n" |
|
253 | + . "Thanks, \n" |
|
254 | + . "{$site_name} support team\n"; |
|
255 | + |
|
256 | + $settings = array( |
|
257 | 257 | 'from' => '', |
258 | 258 | 'to' => $new_email, |
259 | 259 | 'subject' => $mysubject, |
260 | 260 | 'message' => $mymessage, |
261 | - ); |
|
262 | - rules_action_mail_to_user($account, $settings); |
|
263 | - |
|
264 | - // Send email #2 to previous address. |
|
265 | - $mymessage = '' |
|
266 | - . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
267 | - . "\n" |
|
268 | - . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
269 | - . "\n" |
|
270 | - . "Thanks, \n" |
|
271 | - . "{$site_name} support team\n"; |
|
272 | - |
|
273 | - $settings = array( |
|
261 | + ); |
|
262 | + rules_action_mail_to_user($account, $settings); |
|
263 | + |
|
264 | + // Send email #2 to previous address. |
|
265 | + $mymessage = '' |
|
266 | + . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
267 | + . "\n" |
|
268 | + . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
269 | + . "\n" |
|
270 | + . "Thanks, \n" |
|
271 | + . "{$site_name} support team\n"; |
|
272 | + |
|
273 | + $settings = array( |
|
274 | 274 | 'from' => '', |
275 | 275 | 'to' => $prev_email, |
276 | 276 | 'subject' => $mysubject, |
277 | 277 | 'message' => $mymessage, |
278 | - ); |
|
278 | + ); |
|
279 | 279 | |
280 | - rules_action_mail($settings); |
|
280 | + rules_action_mail($settings); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -287,32 +287,32 @@ discard block |
||
287 | 287 | * |
288 | 288 | */ |
289 | 289 | function create_proper_drupalname($requested_name) { |
290 | - if (!$requested_name) { |
|
290 | + if (!$requested_name) { |
|
291 | 291 | // If the name is empty, set it |
292 | 292 | $requested_name = 'anonymous'; |
293 | - } |
|
294 | - $same_name_tally = 1; |
|
295 | - |
|
296 | - // Remove extra spaces |
|
297 | - $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
298 | - // Remove any non-valid characters |
|
299 | - $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
300 | - // Truncate name |
|
301 | - $name_length = strlen($cleaned_name); |
|
302 | - if ($name_length > 56) { |
|
293 | + } |
|
294 | + $same_name_tally = 1; |
|
295 | + |
|
296 | + // Remove extra spaces |
|
297 | + $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
298 | + // Remove any non-valid characters |
|
299 | + $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
300 | + // Truncate name |
|
301 | + $name_length = strlen($cleaned_name); |
|
302 | + if ($name_length > 56) { |
|
303 | 303 | // Name is limited to 60 characters, but we want to leave space to add a |
304 | 304 | // tally if needed (for users with duplicate names); Limit to 56 chars and |
305 | 305 | // replace the middle of the string with "..." if too long |
306 | 306 | $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3); |
307 | - } |
|
307 | + } |
|
308 | 308 | |
309 | - // Determine if there are duplicate names, if so append a number to end. |
|
310 | - $unique_name = $cleaned_name; |
|
311 | - while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
309 | + // Determine if there are duplicate names, if so append a number to end. |
|
310 | + $unique_name = $cleaned_name; |
|
311 | + while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
312 | 312 | $same_name_tally++; |
313 | 313 | $unique_name = "{$cleaned_name}_{$same_name_tally}"; |
314 | - } |
|
315 | - return $unique_name; |
|
314 | + } |
|
315 | + return $unique_name; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | * |
327 | 327 | */ |
328 | 328 | function boincuser_check_termsofuse($user) { |
329 | - require_boinc('consent'); |
|
330 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
331 | - return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL); |
|
329 | + require_boinc('consent'); |
|
330 | + $boinc_user = boincuser_load($user->uid, TRUE); |
|
331 | + return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -339,33 +339,33 @@ discard block |
||
339 | 339 | * |
340 | 340 | */ |
341 | 341 | function boincuser_consentto_termsofuse($user) { |
342 | - require_boinc('consent'); |
|
343 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
342 | + require_boinc('consent'); |
|
343 | + $boinc_user = boincuser_load($user->uid, TRUE); |
|
344 | 344 | |
345 | - list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
|
346 | - if ($checkct) { |
|
345 | + list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
|
346 | + if ($checkct) { |
|
347 | 347 | $rc1 = consent_to_a_policy($boinc_user, $ctid, 1, 0, 'Webform', time()); |
348 | 348 | if (!$rc1) { |
349 | - drupal_set_message( |
|
349 | + drupal_set_message( |
|
350 | 350 | bts("ERROR: Database error when attempting to INSERT into table consent with ID=@id. The @project administrators have been notified.", |
351 | 351 | array( |
352 | - '@id' => $boinc_user->id, |
|
353 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user' |
|
352 | + '@id' => $boinc_user->id, |
|
353 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user' |
|
354 | 354 | ), |
355 | 355 | 'NULL', 'boinc:consent-termsofuse'), |
356 | - 'error'); |
|
357 | - rules_invoke_event('boincuser_general_consent_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
|
356 | + 'error'); |
|
357 | + rules_invoke_event('boincuser_general_consent_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
|
358 | 358 | } |
359 | 359 | return $rc1; |
360 | - } |
|
361 | - else { |
|
360 | + } |
|
361 | + else { |
|
362 | 362 | drupal_set_message( |
363 | - bts('ERROR: Consent type for enrollment not found. The @project administrators have been nofitifed.', |
|
363 | + bts('ERROR: Consent type for enrollment not found. The @project administrators have been nofitifed.', |
|
364 | 364 | array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:consent-termsofuse'), |
365 | 365 | 'error'); |
366 | 366 | rules_invoke_event('boincuser_general_consent_type_error', CONSENT_TYPE_ENROLL, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
367 | - } |
|
368 | - return FALSE; |
|
367 | + } |
|
368 | + return FALSE; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -374,16 +374,16 @@ discard block |
||
374 | 374 | */ |
375 | 375 | function _boincuser_ignore_paths($path, $paths_to_ignore) { |
376 | 376 | |
377 | - foreach ($paths_to_ignore as $pi) { |
|
377 | + foreach ($paths_to_ignore as $pi) { |
|
378 | 378 | // @todo Currently this function uses {} as PHP regexp |
379 | 379 | // delimiters. Curly brace is not really allowed un URLs, but a |
380 | 380 | // more robust function would first check for these curly braces |
381 | 381 | // in the path_to_ignore patterms, just in case. |
382 | 382 | if (preg_match('{' . $pi . '}', $path)) { |
383 | - return TRUE; |
|
383 | + return TRUE; |
|
384 | 384 | } |
385 | - } |
|
386 | - return FALSE; |
|
385 | + } |
|
386 | + return FALSE; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -391,20 +391,20 @@ discard block |
||
391 | 391 | * Drupal's recover email path. |
392 | 392 | */ |
393 | 393 | function _boincuser_redirect_recover_email() { |
394 | - $params = array( |
|
394 | + $params = array( |
|
395 | 395 | 'boincid' => isset($_GET['id']) ? $_GET['id'] : '', |
396 | 396 | 'token' => isset($_GET['token']) ? $_GET['token'] : '' |
397 | - ); |
|
397 | + ); |
|
398 | 398 | |
399 | - // If boincid or token is not present, then go to the home page. |
|
400 | - if (empty($params['boincid']) or empty($params['token'])) { |
|
399 | + // If boincid or token is not present, then go to the home page. |
|
400 | + if (empty($params['boincid']) or empty($params['token'])) { |
|
401 | 401 | $redirect = ''; |
402 | - } |
|
403 | - else { |
|
402 | + } |
|
403 | + else { |
|
404 | 404 | $uid = boincuser_lookup_uid($params['boincid']); |
405 | 405 | $redirect = "/user/${uid}/recoveremail/${params['token']}"; |
406 | - } |
|
407 | - drupal_goto($redirect); |
|
406 | + } |
|
407 | + drupal_goto($redirect); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -415,17 +415,17 @@ discard block |
||
415 | 415 | * Require BOINC library |
416 | 416 | */ |
417 | 417 | function require_boinc($libraries) { |
418 | - if ($include_dir = boinc_get_path('html_inc')) { |
|
418 | + if ($include_dir = boinc_get_path('html_inc')) { |
|
419 | 419 | $working_dir = getcwd(); |
420 | 420 | chdir($include_dir); |
421 | 421 | if (!is_array($libraries)) { |
422 | - $libraries = array($libraries); |
|
422 | + $libraries = array($libraries); |
|
423 | 423 | } |
424 | 424 | foreach ($libraries as $library) { |
425 | - require_once("{$library}.inc"); |
|
425 | + require_once("{$library}.inc"); |
|
426 | 426 | } |
427 | 427 | chdir($working_dir); |
428 | - } |
|
428 | + } |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * The path from the BOINC html root must be included (e.g. user/file.php) |
434 | 434 | */ |
435 | 435 | function include_boinc($file) { |
436 | - if ($include_dir = boinc_get_path()) { |
|
436 | + if ($include_dir = boinc_get_path()) { |
|
437 | 437 | $include_dir .= '/html'; |
438 | 438 | $workingDir = getcwd(); |
439 | 439 | $path = dirname($file); |
@@ -441,84 +441,84 @@ discard block |
||
441 | 441 | chdir("{$include_dir}/{$path}"); |
442 | 442 | include($file); |
443 | 443 | chdir($workingDir); |
444 | - } |
|
444 | + } |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Get the BOINC include path |
449 | 449 | */ |
450 | 450 | function boinc_get_path($type = 'root') { |
451 | - $dir = "boinc_{$type}_dir"; |
|
452 | - if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
451 | + $dir = "boinc_{$type}_dir"; |
|
452 | + if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
453 | 453 | return $include_dir; |
454 | - } |
|
455 | - else { |
|
454 | + } |
|
455 | + else { |
|
456 | 456 | // Don't show errors on blacklisted pages |
457 | 457 | $page_blacklist = array( |
458 | - 'admin/boinc/environment' |
|
458 | + 'admin/boinc/environment' |
|
459 | 459 | ); |
460 | 460 | if (!in_array($_GET['q'], $page_blacklist)) { |
461 | - watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
461 | + watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
462 | 462 | !configure_it', array('!configure_it' => l(t('configure it now'), |
463 | 463 | 'admin/boinc/environment')), WATCHDOG_WARNING); |
464 | - if (user_access('administer site configuration')) { |
|
464 | + if (user_access('administer site configuration')) { |
|
465 | 465 | drupal_set_message(t('The BOINC environment is not configured. Please |
466 | 466 | !configure_it', array('!configure_it' => l(t('configure it now'), |
467 | 467 | 'admin/boinc/environment'))), 'warning', FALSE); |
468 | - } |
|
469 | - else { |
|
468 | + } |
|
469 | + else { |
|
470 | 470 | drupal_set_message(t('There is a problem with the site. Please contact |
471 | 471 | the system administrator.'), 'error', FALSE); |
472 | - } |
|
473 | - // Redirect home to display the error message and avoid fatal errors |
|
474 | - // (unless on a blacklisted page) |
|
475 | - $redirect_blacklist = array( |
|
472 | + } |
|
473 | + // Redirect home to display the error message and avoid fatal errors |
|
474 | + // (unless on a blacklisted page) |
|
475 | + $redirect_blacklist = array( |
|
476 | 476 | 'admin/settings/performance', |
477 | 477 | 'admin/boinc/environment', |
478 | 478 | 'home', |
479 | 479 | '' |
480 | - ); |
|
481 | - if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
480 | + ); |
|
481 | + if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
482 | 482 | drupal_goto(''); |
483 | - } |
|
483 | + } |
|
484 | 484 | } |
485 | 485 | else { |
486 | - // Clear the messages on the environment config page |
|
487 | - drupal_get_messages(); |
|
486 | + // Clear the messages on the environment config page |
|
487 | + drupal_get_messages(); |
|
488 | 488 | } |
489 | - } |
|
490 | - return FALSE; |
|
489 | + } |
|
490 | + return FALSE; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | /** |
494 | 494 | * Get the configured scheduler tags |
495 | 495 | */ |
496 | 496 | function boinc_get_scheduler_tags() { |
497 | - // Don't generate messages for blacklisted pages |
|
498 | - $page_blacklist = array( |
|
497 | + // Don't generate messages for blacklisted pages |
|
498 | + $page_blacklist = array( |
|
499 | 499 | 'admin/boinc/environment', |
500 | 500 | 'admin/boinc/scheduler' |
501 | - ); |
|
502 | - if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
501 | + ); |
|
502 | + if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
503 | 503 | return explode("\r\n", $url_config); |
504 | - } |
|
505 | - elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
504 | + } |
|
505 | + elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
506 | 506 | watchdog('boincuser', 'The BOINC scheduling server settings are not yet |
507 | 507 | configured. Please !verify for the settings to become effective.', |
508 | - array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
508 | + array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
509 | 509 | t('and') . '</strong> ' . t('save the configuration'), |
510 | 510 | 'admin/boinc/scheduler', array('html' => TRUE)) |
511 | - ), WATCHDOG_WARNING); |
|
511 | + ), WATCHDOG_WARNING); |
|
512 | 512 | if (user_access('administer site configuration')) { |
513 | - drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
513 | + drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
514 | 514 | configured. Please !verify for the settings to become effective', |
515 | 515 | array('!verify' => l(t('verify the default values') . ' <strong>' . |
516 | - t('and') . '</strong> ' . t('save the configuration'), |
|
517 | - 'admin/boinc/scheduler', array('html' => TRUE)) |
|
516 | + t('and') . '</strong> ' . t('save the configuration'), |
|
517 | + 'admin/boinc/scheduler', array('html' => TRUE)) |
|
518 | 518 | )), 'warning', FALSE); |
519 | 519 | } |
520 | - } |
|
521 | - return array(); |
|
520 | + } |
|
521 | + return array(); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -530,41 +530,41 @@ discard block |
||
530 | 530 | * Determine if a BOINC ID matches the logged in user |
531 | 531 | */ |
532 | 532 | function is_current_boinc_user($boinc_id) { |
533 | - global $user; |
|
534 | - if (!$user->uid) { |
|
533 | + global $user; |
|
534 | + if (!$user->uid) { |
|
535 | 535 | return FALSE; |
536 | - } |
|
537 | - // boincuser_id is not stored in the global user, so load a new instance |
|
538 | - $drupuser = user_load($user->uid); |
|
539 | - return ($boinc_id == $drupuser->boincuser_id); |
|
536 | + } |
|
537 | + // boincuser_id is not stored in the global user, so load a new instance |
|
538 | + $drupuser = user_load($user->uid); |
|
539 | + return ($boinc_id == $drupuser->boincuser_id); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
543 | 543 | * Convert a BOINC ID to a Drupal ID |
544 | 544 | */ |
545 | 545 | function boincuser_lookup_uid($boinc_id) { |
546 | - $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
547 | - return $drupal_id; |
|
546 | + $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
547 | + return $drupal_id; |
|
548 | 548 | } |
549 | 549 | function get_drupal_id($boinc_id) { |
550 | - return boincuser_lookup_uid($boinc_id); |
|
550 | + return boincuser_lookup_uid($boinc_id); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
554 | 554 | * Get a BOINC user object |
555 | 555 | */ |
556 | 556 | function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) { |
557 | - if (!$user_id) { |
|
557 | + if (!$user_id) { |
|
558 | 558 | global $user; |
559 | 559 | $user_id = $user->uid; |
560 | 560 | $is_drupal_id = TRUE; |
561 | - } |
|
562 | - if ($is_drupal_id) { |
|
561 | + } |
|
562 | + if ($is_drupal_id) { |
|
563 | 563 | $account = user_load($user_id); |
564 | 564 | $user_id = $account->boincuser_id; |
565 | - } |
|
566 | - require_boinc('boinc_db'); |
|
567 | - return BoincUser::lookup_id($user_id); |
|
565 | + } |
|
566 | + require_boinc('boinc_db'); |
|
567 | + return BoincUser::lookup_id($user_id); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -574,10 +574,10 @@ discard block |
||
574 | 574 | * page, delete button. |
575 | 575 | */ |
576 | 576 | function _boincuser_node_profile_delete_submit($form, &$form_state) { |
577 | - $node = $form['#node']; |
|
578 | - $deleteurl = 'node/'. $node->nid .'/delete'; |
|
579 | - $afterq = 'destination=account'; |
|
580 | - drupal_goto($deleteurl, $afterq); |
|
577 | + $node = $form['#node']; |
|
578 | + $deleteurl = 'node/'. $node->nid .'/delete'; |
|
579 | + $afterq = 'destination=account'; |
|
580 | + drupal_goto($deleteurl, $afterq); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | * Wrapper for boinc_version() function |
589 | 589 | */ |
590 | 590 | function get_boinc_version($x) { |
591 | - require_boinc('host'); |
|
592 | - return function_exists('boinc_version') ? boinc_version($x) : 'err!'; |
|
591 | + require_boinc('host'); |
|
592 | + return function_exists('boinc_version') ? boinc_version($x) : 'err!'; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | |
@@ -598,14 +598,14 @@ discard block |
||
598 | 598 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
599 | 599 | |
600 | 600 | /** |
601 | - * Generate the friend block header |
|
602 | - */ |
|
601 | + * Generate the friend block header |
|
602 | + */ |
|
603 | 603 | function boincuser_views_friends_block_header($context = null) { |
604 | - // Get the friend count for the user being viewed |
|
605 | - $view = views_get_current_view(); |
|
606 | - $account_id = $view->args[0]; |
|
607 | - $friend_count = flag_friend_get_friend_count($account_id); |
|
608 | - return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
604 | + // Get the friend count for the user being viewed |
|
605 | + $view = views_get_current_view(); |
|
606 | + $account_id = $view->args[0]; |
|
607 | + $friend_count = flag_friend_get_friend_count($account_id); |
|
608 | + return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
609 | 609 | array('@count' => $friend_count)) . '</h2>'; |
610 | 610 | } |
611 | 611 | |
@@ -614,13 +614,13 @@ discard block |
||
614 | 614 | * database. |
615 | 615 | */ |
616 | 616 | function _boincuser_user_name_autocomplete($string) { |
617 | - $matches = array(); |
|
618 | - db_set_active('boinc_ro'); |
|
619 | - $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
620 | - db_set_active('default'); |
|
621 | - while ($user = db_fetch_object($result)) { |
|
622 | - $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
623 | - } |
|
624 | - |
|
625 | - drupal_json((object)$matches); |
|
617 | + $matches = array(); |
|
618 | + db_set_active('boinc_ro'); |
|
619 | + $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
620 | + db_set_active('default'); |
|
621 | + while ($user = db_fetch_object($result)) { |
|
622 | + $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
623 | + } |
|
624 | + |
|
625 | + drupal_json((object)$matches); |
|
626 | 626 | } |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | }*/ |
29 | 29 | |
30 | 30 | /** |
31 | - * The BOINC environment form allows paths to be set to connect Drupal to an |
|
32 | - * existing BOINC web interface. |
|
33 | - */ |
|
31 | + * The BOINC environment form allows paths to be set to connect Drupal to an |
|
32 | + * existing BOINC web interface. |
|
33 | + */ |
|
34 | 34 | function boincuser_admin_environment(&$form_state) { |
35 | - global $base_url; |
|
36 | - $form = array(); |
|
37 | - $default = array( |
|
35 | + global $base_url; |
|
36 | + $form = array(); |
|
37 | + $default = array( |
|
38 | 38 | 'boinc_root_dir' => variable_get('boinc_root_dir', ''), |
39 | 39 | 'boinc_config_xml_dir' => variable_get('boinc_config_xml_dir', ''), |
40 | 40 | 'boinc_html_inc_dir' => variable_get('boinc_html_inc_dir', ''), |
@@ -47,303 +47,303 @@ discard block |
||
47 | 47 | 'boinc_admin_mailing_list_subject_tag' => variable_get('boinc_admin_mailing_list_subject_tag', ''), |
48 | 48 | 'boinc_debug_mode' => variable_get('boinc_debug_mode', 0), |
49 | 49 | 'boinc_project_config_keywords' => variable_get('boinc_project_config_keywords', ''), |
50 | - ); |
|
51 | - //drupal_set_message(print_r($default, true)); |
|
52 | - //drupal_set_message(print_r($form_state, true)); |
|
53 | - // Show overrides if the root dir is set and others have not been detected |
|
54 | - $show_overrides = FALSE; |
|
55 | - if ($default['boinc_root_dir']) { |
|
50 | + ); |
|
51 | + //drupal_set_message(print_r($default, true)); |
|
52 | + //drupal_set_message(print_r($form_state, true)); |
|
53 | + // Show overrides if the root dir is set and others have not been detected |
|
54 | + $show_overrides = FALSE; |
|
55 | + if ($default['boinc_root_dir']) { |
|
56 | 56 | foreach ($default as $key => $dir) { |
57 | - switch ($key) { |
|
58 | - case 'boinc_config_xml_dir': |
|
57 | + switch ($key) { |
|
58 | + case 'boinc_config_xml_dir': |
|
59 | 59 | case 'boinc_html_inc_dir': |
60 | 60 | case 'boinc_project_config_dir': |
61 | 61 | case 'boinc_user_image_dir': |
62 | 62 | // If any of these values are not set, show the overrides section |
63 | 63 | if (!$dir) { |
64 | - $default[$key] = $form_state['values'][$key]; |
|
65 | - $show_overrides = TRUE; |
|
66 | - break; |
|
64 | + $default[$key] = $form_state['values'][$key]; |
|
65 | + $show_overrides = TRUE; |
|
66 | + break; |
|
67 | 67 | } |
68 | 68 | break; |
69 | - default: |
|
69 | + default: |
|
70 | 70 | } |
71 | - if ($show_overrides) { |
|
71 | + if ($show_overrides) { |
|
72 | 72 | break; |
73 | - } |
|
73 | + } |
|
74 | + } |
|
74 | 75 | } |
75 | - } |
|
76 | - // Define the form |
|
77 | - $form['boinc_root_dir'] = array( |
|
76 | + // Define the form |
|
77 | + $form['boinc_root_dir'] = array( |
|
78 | 78 | '#type' => 'textfield', |
79 | 79 | '#title' => t('BOINC project root directory'), |
80 | 80 | '#default_value' => $default['boinc_root_dir'], |
81 | 81 | '#description' => t('The filesystem path to the BOINC project root. This |
82 | 82 | directory should contain config.xml as well as the html subdirectory, |
83 | 83 | which itself contains inc/, project/, and user_profile/.'), |
84 | - ); |
|
85 | - $form['overrides'] = array( |
|
84 | + ); |
|
85 | + $form['overrides'] = array( |
|
86 | 86 | '#title' => t('Overrides'), |
87 | 87 | '#type' => 'fieldset', |
88 | 88 | '#description' => '', |
89 | 89 | '#collapsible' => TRUE, |
90 | 90 | '#collapsed' => !$show_overrides, |
91 | 91 | '#attributes' => array('class' => 'advanced-settings') |
92 | - ); |
|
93 | - $form['overrides']['boinc_config_xml_dir'] = array( |
|
92 | + ); |
|
93 | + $form['overrides']['boinc_config_xml_dir'] = array( |
|
94 | 94 | '#type' => 'textfield', |
95 | 95 | '#title' => t('BOINC config.xml directory'), |
96 | 96 | '#default_value' => $default['boinc_config_xml_dir'], |
97 | 97 | '#description' => t('The filesystem path that contains config.xml'), |
98 | - ); |
|
99 | - $form['overrides']['boinc_html_inc_dir'] = array( |
|
98 | + ); |
|
99 | + $form['overrides']['boinc_html_inc_dir'] = array( |
|
100 | 100 | '#type' => 'textfield', |
101 | 101 | '#title' => t('BOINC web includes directory'), |
102 | 102 | '#default_value' => $default['boinc_html_inc_dir'], |
103 | 103 | '#description' => t('The filesystem path to the html/inc/ directory that |
104 | 104 | contains util.inc'), |
105 | - ); |
|
106 | - $form['overrides']['boinc_project_config_dir'] = array( |
|
105 | + ); |
|
106 | + $form['overrides']['boinc_project_config_dir'] = array( |
|
107 | 107 | '#type' => 'textfield', |
108 | 108 | '#title' => t('BOINC project config directory'), |
109 | 109 | '#default_value' => $default['boinc_project_config_dir'], |
110 | 110 | '#description' => t('The filesystem path to the project/ directory that |
111 | 111 | contains project.inc'), |
112 | - ); |
|
113 | - $form['overrides']['boinc_user_image_dir'] = array( |
|
112 | + ); |
|
113 | + $form['overrides']['boinc_user_image_dir'] = array( |
|
114 | 114 | '#type' => 'textfield', |
115 | 115 | '#title' => t('BOINC user profile image directory'), |
116 | 116 | '#default_value' => $default['boinc_user_image_dir'], |
117 | 117 | '#description' => t('The filesystem directory that contains user images'), |
118 | - ); |
|
119 | - $form['boinc_server_status_url'] = array( |
|
118 | + ); |
|
119 | + $form['boinc_server_status_url'] = array( |
|
120 | 120 | '#type' => 'textfield', |
121 | 121 | '#title' => t('BOINC server status page URL (optional)'), |
122 | 122 | '#default_value' => $default['boinc_server_status_url'], |
123 | 123 | '#description' => t('An absolute URL or path relative to the site base to the server status page (e.g. %full_url or just %relative_url).', |
124 | - array( |
|
124 | + array( |
|
125 | 125 | '%full_url' => $base_url . '/server_status.php', |
126 | 126 | '%relative_url' => 'server_status.php', |
127 | - ) |
|
127 | + ) |
|
128 | 128 | ), |
129 | - ); |
|
130 | - $form['boinc_app_list_url'] = array( |
|
129 | + ); |
|
130 | + $form['boinc_app_list_url'] = array( |
|
131 | 131 | '#type' => 'textfield', |
132 | 132 | '#title' => t('BOINC applications page URL (optional)'), |
133 | 133 | '#default_value' => $default['boinc_app_list_url'], |
134 | 134 | '#description' => t('An absolute URL or path relative to the site base to the applications page (e.g. %full_url or just %relative_url).', |
135 | - array( |
|
135 | + array( |
|
136 | 136 | '%full_url' => $base_url . '/apps.php', |
137 | 137 | '%relative_url' => 'apps.php', |
138 | - ) |
|
138 | + ) |
|
139 | 139 | ), |
140 | - ); |
|
141 | - $form['boinc_host_sched_logs_dir'] = array( |
|
140 | + ); |
|
141 | + $form['boinc_host_sched_logs_dir'] = array( |
|
142 | 142 | '#type' => 'textfield', |
143 | 143 | '#title' => t('BOINC host scheduler log directory (optional)'), |
144 | 144 | '#default_value' => $default['boinc_host_sched_logs_dir'], |
145 | 145 | '#description' => t('The filesystem directory that contains host scheduler logs'), |
146 | - ); |
|
147 | - $form['boinc_admin_mailing_list'] = array( |
|
146 | + ); |
|
147 | + $form['boinc_admin_mailing_list'] = array( |
|
148 | 148 | '#type' => 'textfield', |
149 | 149 | '#title' => t('Admin mailing list'), |
150 | 150 | '#default_value' => $default['boinc_admin_mailing_list'], |
151 | 151 | '#description' => t('Enter an email-address which will be used to contact admisistrators. If empty, the site email configured in Settings -> Site Information will be used.'), |
152 | - ); |
|
153 | - $form['boinc_admin_mailing_list_subject_tag'] = array( |
|
152 | + ); |
|
153 | + $form['boinc_admin_mailing_list_subject_tag'] = array( |
|
154 | 154 | '#type' => 'textfield', |
155 | 155 | '#title' => t('Admin mailing list - subject tag'), |
156 | 156 | '#default_value' => $default['boinc_admin_mailing_list_subject_tag'], |
157 | 157 | '#description' => t('Text which will appear at the beginning of the subject for any admin notification emails. If empty, no tag will be included. Examples: [drupal-error].'), |
158 | - ); |
|
159 | - $form['boinc_debug_mode'] = array( |
|
158 | + ); |
|
159 | + $form['boinc_debug_mode'] = array( |
|
160 | 160 | '#type' => 'checkbox', |
161 | 161 | '#title' => t('Show debug messages in system log'), |
162 | 162 | '#default_value' => $default['boinc_debug_mode'] |
163 | - ); |
|
164 | - $form['boinc_project_config_keywords'] = array( |
|
163 | + ); |
|
164 | + $form['boinc_project_config_keywords'] = array( |
|
165 | 165 | '#type' => 'textarea', |
166 | 166 | '#title' => t('Project/Job Keywords for get_project_config RPC'), |
167 | 167 | '#default_value' => $default['boinc_project_config_keywords'], |
168 | 168 | '#description' => t('XML from this text box will be appended to the XML output from the get_project_config RPC. There is no check for XML validity! See !link for more details. It is okay to leave this blank.', |
169 | 169 | array( |
170 | - '!link' => l('BOINC wiki page', 'https://boinc.berkeley.edu/trac/wiki/JobKeywords') |
|
170 | + '!link' => l('BOINC wiki page', 'https://boinc.berkeley.edu/trac/wiki/JobKeywords') |
|
171 | 171 | )), |
172 | - ); |
|
173 | - return system_settings_form($form); |
|
172 | + ); |
|
173 | + return system_settings_form($form); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Validate the BOINC environment form. |
|
178 | - */ |
|
177 | + * Validate the BOINC environment form. |
|
178 | + */ |
|
179 | 179 | function boincuser_admin_environment_validate($form, &$form_state) { |
180 | - $values = $form_state['values']; |
|
181 | - if (!$values['boinc_root_dir']) { |
|
180 | + $values = $form_state['values']; |
|
181 | + if (!$values['boinc_root_dir']) { |
|
182 | 182 | form_set_error('boinc_root_dir', t('BOINC project root directory must be |
183 | 183 | defined!')); |
184 | - } |
|
185 | - elseif (!is_dir($values['boinc_root_dir'])) { |
|
184 | + } |
|
185 | + elseif (!is_dir($values['boinc_root_dir'])) { |
|
186 | 186 | form_set_error('boinc_root_dir', t('BOINC project root not found at %directory', |
187 | - array('%directory' => $values['boinc_root_dir']) |
|
187 | + array('%directory' => $values['boinc_root_dir']) |
|
188 | 188 | )); |
189 | - } |
|
190 | - else { |
|
189 | + } |
|
190 | + else { |
|
191 | 191 | // By default, try to automatically set specific directories from the root |
192 | 192 | if (!$values['boinc_config_xml_dir']) { |
193 | - $values['boinc_config_xml_dir'] = $values['boinc_root_dir']; |
|
194 | - form_set_value($form['overrides']['boinc_config_xml_dir'], $values['boinc_config_xml_dir'], $form_state); |
|
193 | + $values['boinc_config_xml_dir'] = $values['boinc_root_dir']; |
|
194 | + form_set_value($form['overrides']['boinc_config_xml_dir'], $values['boinc_config_xml_dir'], $form_state); |
|
195 | 195 | } |
196 | 196 | if (!$values['boinc_html_inc_dir']) { |
197 | - $values['boinc_html_inc_dir'] = "{$values['boinc_root_dir']}/html/inc"; |
|
198 | - form_set_value($form['overrides']['boinc_html_inc_dir'], $values['boinc_html_inc_dir'], $form_state); |
|
197 | + $values['boinc_html_inc_dir'] = "{$values['boinc_root_dir']}/html/inc"; |
|
198 | + form_set_value($form['overrides']['boinc_html_inc_dir'], $values['boinc_html_inc_dir'], $form_state); |
|
199 | 199 | } |
200 | 200 | if (!$values['boinc_project_config_dir']) { |
201 | - $values['boinc_project_config_dir'] = "{$values['boinc_root_dir']}/html/project"; |
|
202 | - form_set_value($form['overrides']['boinc_project_config_dir'], $values['boinc_project_config_dir'], $form_state); |
|
201 | + $values['boinc_project_config_dir'] = "{$values['boinc_root_dir']}/html/project"; |
|
202 | + form_set_value($form['overrides']['boinc_project_config_dir'], $values['boinc_project_config_dir'], $form_state); |
|
203 | 203 | } |
204 | 204 | if (!$values['boinc_user_image_dir']) { |
205 | - $values['boinc_user_image_dir'] = "{$values['boinc_root_dir']}/html/user_profile/images"; |
|
206 | - form_set_value($form['overrides']['boinc_user_image_dir'], $values['boinc_user_image_dir'], $form_state); |
|
205 | + $values['boinc_user_image_dir'] = "{$values['boinc_root_dir']}/html/user_profile/images"; |
|
206 | + form_set_value($form['overrides']['boinc_user_image_dir'], $values['boinc_user_image_dir'], $form_state); |
|
207 | 207 | } |
208 | 208 | // Validate that required BOINC content is found |
209 | 209 | if (!is_readable("{$values['boinc_config_xml_dir']}/config.xml")) { |
210 | - form_set_error('boinc_config_xml_dir', t('@file not found in %directory', |
|
210 | + form_set_error('boinc_config_xml_dir', t('@file not found in %directory', |
|
211 | 211 | array( |
212 | - '@file' => 'config.xml', |
|
213 | - '%directory' => "{$values['boinc_config_xml_dir']}/" |
|
212 | + '@file' => 'config.xml', |
|
213 | + '%directory' => "{$values['boinc_config_xml_dir']}/" |
|
214 | 214 | ) |
215 | - )); |
|
215 | + )); |
|
216 | 216 | } |
217 | 217 | if (!is_readable("{$values['boinc_html_inc_dir']}/util.inc")) { |
218 | - form_set_error('boinc_html_inc_dir', t('@file not found in %directory', |
|
218 | + form_set_error('boinc_html_inc_dir', t('@file not found in %directory', |
|
219 | 219 | array( |
220 | - '@file' => 'util.inc', |
|
221 | - '%directory' => "{$values['boinc_html_inc_dir']}/" |
|
220 | + '@file' => 'util.inc', |
|
221 | + '%directory' => "{$values['boinc_html_inc_dir']}/" |
|
222 | 222 | ) |
223 | - )); |
|
223 | + )); |
|
224 | 224 | } |
225 | 225 | if (!is_readable("{$values['boinc_project_config_dir']}/project.inc")) { |
226 | - form_set_error('boinc_project_config_dir', t('@file not found in %directory', |
|
226 | + form_set_error('boinc_project_config_dir', t('@file not found in %directory', |
|
227 | 227 | array( |
228 | - '@file' => 'project.inc', |
|
229 | - '%directory' => "{$values['boinc_project_config_dir']}/" |
|
228 | + '@file' => 'project.inc', |
|
229 | + '%directory' => "{$values['boinc_project_config_dir']}/" |
|
230 | 230 | ) |
231 | - )); |
|
231 | + )); |
|
232 | 232 | } |
233 | 233 | if (!is_dir($values['boinc_user_image_dir'])) { |
234 | - form_set_error('boinc_user_image_dir', t('Profile image directory not found |
|
234 | + form_set_error('boinc_user_image_dir', t('Profile image directory not found |
|
235 | 235 | at %directory', array('%directory' => $values['boinc_user_image_dir']) |
236 | - )); |
|
236 | + )); |
|
237 | 237 | } |
238 | 238 | if ($values['boinc_host_sched_logs_dir'] |
239 | 239 | AND !is_dir($values['boinc_host_sched_logs_dir']) |
240 | - ) { |
|
241 | - form_set_error('boinc_host_sched_logs_dir', t('Host scheduler log |
|
240 | + ) { |
|
241 | + form_set_error('boinc_host_sched_logs_dir', t('Host scheduler log |
|
242 | 242 | directory not found at %directory', |
243 | 243 | array('%directory' => $values['boinc_host_sched_logs_dir']) |
244 | - )); |
|
244 | + )); |
|
245 | + } |
|
245 | 246 | } |
246 | - } |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | - * Handle post-validation submission of BOINC environment form. |
|
251 | - */ |
|
250 | + * Handle post-validation submission of BOINC environment form. |
|
251 | + */ |
|
252 | 252 | function boincuser_admin_environment_submit($form, &$form_state) { |
253 | - unset($_SESSION['boinc_env']); |
|
254 | - drupal_set_message(t('BOINC environment settings have been updated.')); |
|
253 | + unset($_SESSION['boinc_env']); |
|
254 | + drupal_set_message(t('BOINC environment settings have been updated.')); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | - * The BOINC scheduler form provides options for how scheduler tags are |
|
259 | - * inserted into the front page |
|
260 | - */ |
|
258 | + * The BOINC scheduler form provides options for how scheduler tags are |
|
259 | + * inserted into the front page |
|
260 | + */ |
|
261 | 261 | function boincuser_admin_scheduler(&$form_state) { |
262 | - $form = array(); |
|
263 | - $config_cgi_url = ''; |
|
264 | - if ($config_xml_dir = variable_get('boinc_config_xml_dir', '')) { |
|
262 | + $form = array(); |
|
263 | + $config_cgi_url = ''; |
|
264 | + if ($config_xml_dir = variable_get('boinc_config_xml_dir', '')) { |
|
265 | 265 | // Get the cgi_url option from the config file as the default scheduler URL |
266 | 266 | $xml = new DOMDocument(); |
267 | 267 | if ($xml->load("{$config_xml_dir}/config.xml")) { |
268 | - $config = xml_to_array($xml); |
|
269 | - if (isset($config['boinc']['config']['cgi_url']['@value'])) { |
|
268 | + $config = xml_to_array($xml); |
|
269 | + if (isset($config['boinc']['config']['cgi_url']['@value'])) { |
|
270 | 270 | $config_cgi_url = rtrim(trim($config['boinc']['config']['cgi_url']['@value']), '/'); |
271 | 271 | $config_cgi_url .= '/cgi'; |
272 | - } |
|
272 | + } |
|
273 | 273 | } |
274 | - } |
|
275 | - $default = array( |
|
274 | + } |
|
275 | + $default = array( |
|
276 | 276 | 'boinc_scheduler_urls' => variable_get('boinc_scheduler_urls', $config_cgi_url), |
277 | 277 | 'boinc_scheduler_tag_format_old' => variable_get('boinc_scheduler_tag_format_old', 1), |
278 | 278 | 'boinc_scheduler_tag_format_new' => variable_get('boinc_scheduler_tag_format_new', 1) |
279 | - ); |
|
279 | + ); |
|
280 | 280 | |
281 | - // Define the form |
|
282 | - $form['boinc_scheduler_urls'] = array( |
|
281 | + // Define the form |
|
282 | + $form['boinc_scheduler_urls'] = array( |
|
283 | 283 | '#type' => 'textarea', |
284 | 284 | '#title' => t('Scheduling server URLs'), |
285 | 285 | '#default_value' => $default['boinc_scheduler_urls'], |
286 | 286 | '#cols' => 60, |
287 | 287 | '#rows' => 5, |
288 | 288 | '#description' => t('If there are multiple URLs, please enter one per line.'), |
289 | - ); |
|
290 | - $form['boinc_scheduler_tag_format_old'] = array( |
|
289 | + ); |
|
290 | + $form['boinc_scheduler_tag_format_old'] = array( |
|
291 | 291 | '#type' => 'checkbox', |
292 | 292 | '#title' => t('Old format (@scheduler tag)', array('@scheduler' => '<scheduler>')), |
293 | 293 | '#default_value' => $default['boinc_scheduler_tag_format_old'] |
294 | - ); |
|
295 | - $form['boinc_scheduler_tag_format_new'] = array( |
|
294 | + ); |
|
295 | + $form['boinc_scheduler_tag_format_new'] = array( |
|
296 | 296 | '#type' => 'checkbox', |
297 | 297 | '#title' => t('New format (@link tag)', array('@link' => '<link>')), |
298 | 298 | '#default_value' => $default['boinc_scheduler_tag_format_new'] |
299 | - ); |
|
299 | + ); |
|
300 | 300 | |
301 | - return system_settings_form($form); |
|
301 | + return system_settings_form($form); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * Validate the BOINC scheduler form. |
|
306 | - */ |
|
305 | + * Validate the BOINC scheduler form. |
|
306 | + */ |
|
307 | 307 | function boincuser_admin_scheduler_validate($form, &$form_state) { |
308 | - $values = $form_state['values']; |
|
309 | - if (!$values['boinc_scheduler_urls']) { |
|
308 | + $values = $form_state['values']; |
|
309 | + if (!$values['boinc_scheduler_urls']) { |
|
310 | 310 | form_set_error('boinc_scheduler_urls', t('At least one scheduling server |
311 | 311 | URL must be specified.')); |
312 | - } |
|
313 | - else { |
|
312 | + } |
|
313 | + else { |
|
314 | 314 | $urls = explode("\r\n", $values['boinc_scheduler_urls']); |
315 | 315 | foreach ($urls as $key => $url) { |
316 | - if (!$url) { |
|
316 | + if (!$url) { |
|
317 | 317 | unset($urls[$key]); |
318 | 318 | continue; |
319 | - } |
|
320 | - if (!filter_var($url, FILTER_VALIDATE_URL)) { |
|
319 | + } |
|
320 | + if (!filter_var($url, FILTER_VALIDATE_URL)) { |
|
321 | 321 | form_set_error('boinc_scheduler_urls', t('@url is not a valid URL |
322 | 322 | format.', array('@url' => $url))); |
323 | 323 | break; |
324 | - } |
|
324 | + } |
|
325 | 325 | } |
326 | 326 | $form_state['values']['boinc_scheduler_urls'] = implode("\r\n", $urls); |
327 | - } |
|
327 | + } |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
331 | - * Handle post-validation submission of BOINC scheduler form. |
|
332 | - */ |
|
331 | + * Handle post-validation submission of BOINC scheduler form. |
|
332 | + */ |
|
333 | 333 | function boincuser_admin_scheduler_submit($form, &$form_state) { |
334 | - drupal_set_message(t('BOINC scheduling server settings have been updated.')); |
|
334 | + drupal_set_message(t('BOINC scheduling server settings have been updated.')); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
338 | 338 | /** |
339 | - * Drupal-BOINC Web site related options. |
|
340 | - */ |
|
339 | + * Drupal-BOINC Web site related options. |
|
340 | + */ |
|
341 | 341 | function boincuser_admin_weboptions(&$form_state) { |
342 | - global $base_url; |
|
343 | - $form = array(); |
|
342 | + global $base_url; |
|
343 | + $form = array(); |
|
344 | 344 | |
345 | - //form defaults |
|
346 | - $default = array( |
|
345 | + //form defaults |
|
346 | + $default = array( |
|
347 | 347 | 'boinc_weboptions_enableaccountcreateRPC' => variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE), |
348 | 348 | 'boinc_weboptions_registrationtitle' => variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), |
349 | 349 | 'boinc_weboptions_termsofuse' => variable_get('boinc_weboptions_termsofuse', ''), |
@@ -357,65 +357,65 @@ discard block |
||
357 | 357 | 'boinc_weboptions_rulespolicies' => variable_get('boinc_weboptions_rulespolicies', ''), |
358 | 358 | 'boinc_other_frontpage' => variable_get('boinc_other_frontpage', ''), |
359 | 359 | 'boinc_weboptions_blacklisted_usernames' => variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator"), |
360 | - ); |
|
360 | + ); |
|
361 | 361 | |
362 | - // Define the form |
|
363 | - $form['registrationtitle'] = array( |
|
362 | + // Define the form |
|
363 | + $form['registrationtitle'] = array( |
|
364 | 364 | '#value' => '<h3>BOINC Registration</h3>', |
365 | - ); |
|
365 | + ); |
|
366 | 366 | |
367 | - $form['boinc_weboptions_enableaccountcreateRPC'] = array( |
|
367 | + $form['boinc_weboptions_enableaccountcreateRPC'] = array( |
|
368 | 368 | '#type' => 'checkbox', |
369 | 369 | '#title' => t('Enable create_account.php RPC'), |
370 | 370 | '#default_value' => $default['boinc_weboptions_enableaccountcreateRPC'], |
371 | 371 | '#description' => t('If checked, users will be able to create an account remotely using the create_account.php RPC. This option is independent of the user regsitration option found in ') . l(t('User management -> User settings'), '/admin/user/settings') . '. If enabled, user <b>may not be able to see and agree to the terms-of-use</b> to your site\'s privacy and data retention policies!', |
372 | - ); |
|
372 | + ); |
|
373 | 373 | |
374 | - $form['boinc_weboptions_registrationtitle'] = array( |
|
374 | + $form['boinc_weboptions_registrationtitle'] = array( |
|
375 | 375 | '#type' => 'textfield', |
376 | 376 | '#title' => t('Title of regsistration page'), |
377 | 377 | '#description' => t('Title text presented above the terms of use text.'), |
378 | 378 | '#default_value' => $default['boinc_weboptions_registrationtitle'], |
379 | - ); |
|
379 | + ); |
|
380 | 380 | |
381 | - $form['boinc_weboptions_termsofuse'] = array( |
|
381 | + $form['boinc_weboptions_termsofuse'] = array( |
|
382 | 382 | '#type' => 'textarea', |
383 | 383 | '#title' => t('Terms of Use Message for User Registration Page'), |
384 | 384 | '#default_value' => $default['boinc_weboptions_termsofuse'], |
385 | 385 | '#cols' => 60, |
386 | 386 | '#rows' => 8, |
387 | 387 | '#description' => t('Text to be displayed on site\'s user registration page. Privacy policy and other data retention information goes here. If empty, there will be no terms of use message, and the title above and checkbox below will not be shown.'), |
388 | - ); |
|
388 | + ); |
|
389 | 389 | |
390 | - $form['boinc_weboptions_overrideboinctou'] = array( |
|
390 | + $form['boinc_weboptions_overrideboinctou'] = array( |
|
391 | 391 | '#type' => 'checkbox', |
392 | 392 | '#title' => t('Override BOINC terms of use.'), |
393 | 393 | '#default_value' => $default['boinc_weboptions_overrideboinctou'], |
394 | 394 | '#description' => t('Override the BOINC terms_of_use.txt file for get_profject_config.php RPC. If TRUE, the get_project_config.php RPC will use the above terms of use text entered above. Otherwise, the original terms_of_use.txt text file in the project directory is used. And you will need to be responsible for keeping both the text file and the above terms of use text up-to-date and in sync with each other.'), |
395 | - ); |
|
395 | + ); |
|
396 | 396 | |
397 | - $form['boinc_weboptions_agreequestion'] = array( |
|
397 | + $form['boinc_weboptions_agreequestion'] = array( |
|
398 | 398 | '#type' => 'textfield', |
399 | 399 | '#title' => t('Terms of use agreement question'), |
400 | 400 | '#description' => t('This text is presented to the user as the question next to the \'I agree\' checkbox.'), |
401 | 401 | '#default_value' => $default['boinc_weboptions_agreequestion'], |
402 | - ); |
|
402 | + ); |
|
403 | 403 | |
404 | - $form['boinc_weboptions_registrationtitle2'] = array( |
|
404 | + $form['boinc_weboptions_registrationtitle2'] = array( |
|
405 | 405 | '#type' => 'textfield', |
406 | 406 | '#title' => t('Instructions for username/email/password questions'), |
407 | 407 | '#description' => t('Title text presented below terms of use and above username/email/password textfields.'), |
408 | 408 | '#default_value' => $default['boinc_weboptions_registrationtitle2'], |
409 | - ); |
|
409 | + ); |
|
410 | 410 | |
411 | - $form['boinc_weboptions_existinguser_tou'] = array( |
|
411 | + $form['boinc_weboptions_existinguser_tou'] = array( |
|
412 | 412 | '#type' => 'checkbox', |
413 | 413 | '#title' => t('Are existing users forced to agree to the Terms of Use?'), |
414 | 414 | '#default_value' => $default['boinc_weboptions_existinguser_tou'], |
415 | 415 | '#description' => t('If TRUE, existing users are forced to agree to a terms of use (if present) when the login and the system has detected they have not agreed. Otherwise they may login as normal. This option has no affect on whether or not new users must agree to the terms of use.'), |
416 | - ); |
|
416 | + ); |
|
417 | 417 | |
418 | - $form['boinc_weboptions_pathstoignore'] = array( |
|
418 | + $form['boinc_weboptions_pathstoignore'] = array( |
|
419 | 419 | '#type' => 'textarea', |
420 | 420 | '#title' => t('Paths to ignore the Terms of Use page'), |
421 | 421 | '#default_value' => $default['boinc_weboptions_pathstoignore'], |
@@ -424,80 +424,80 @@ discard block |
||
424 | 424 | '#description' => t('A list of Drupal URLs/paths to ignore for Terms of Use (ToU). If the option above \'Are existing users forced to agree to the Terms of Use?\' is activated, then some paths need to be ignored when checking if a user has agreed to the ToU. A good example is the logout path, "logout", or else users will not be able to logout! |
425 | 425 | <p>There is a default list of paths that must be ignored or else the site will not function. They are not included in this box. Here you may provide additional paths to be ignored, for example the privacy policy page may be accessible so that users may read it before agreeing to the site\'s ToU. |
426 | 426 | <p>Paths should be entered one per line. All paths should be <em>lower-case</em> and should not include a leading \'/\'. Example: account/info/edit will allow the user to visit ' . $base_url . '/account/info/edit without first agreeing to the ToU. Regexp are allowed. Example: account/* will allow the user to visit any path starting with ' . $base_url . '/account/.'), |
427 | - ); |
|
427 | + ); |
|
428 | 428 | |
429 | - $form['pathtitle'] = array( |
|
429 | + $form['pathtitle'] = array( |
|
430 | 430 | '#value' => '<h3>Path Options</h3>', |
431 | - ); |
|
431 | + ); |
|
432 | 432 | |
433 | - $form['boinc_weboptions_accountfinish'] = array ( |
|
433 | + $form['boinc_weboptions_accountfinish'] = array ( |
|
434 | 434 | '#type' => 'textfield', |
435 | 435 | '#title' => t('Path to a custom account_finish.php page, should be a path to a node'), |
436 | 436 | '#description' => t('Provide a path to a node which will serve as your site\'s landing page for users create an account using the BOINC client manager. They will be directed to this page after the account is created. If blank, a default account_finish page will be used.<br>Examples: account_finish, content/welcome, node/123'), |
437 | 437 | '#default_value' => $default['boinc_weboptions_accountfinish'], |
438 | - ); |
|
439 | - $form['boinc_weboptions_moderationpage'] = array ( |
|
438 | + ); |
|
439 | + $form['boinc_weboptions_moderationpage'] = array ( |
|
440 | 440 | '#type' => 'textfield', |
441 | 441 | '#title' => t('Path to the site\'s content moderation info page, should be a path to a node'), |
442 | 442 | '#description' => t('Provide a path to a node which will serve as your site\'s page for account/content moderation information. This will be used on the default account_finish page. If blank, no link to a moderation page will be provided. If a path is provided to the custom account_finish.php page (above), this field will be ignored.<br>Examples: moderation, content/moderation, node/456'), |
443 | 443 | '#default_value' => $default['boinc_weboptions_moderationpage'], |
444 | - ); |
|
445 | - $form['boinc_weboptions_rulespolicies'] = array ( |
|
444 | + ); |
|
445 | + $form['boinc_weboptions_rulespolicies'] = array ( |
|
446 | 446 | '#type' => 'textfield', |
447 | 447 | '#title' => t('Path to the site\'s rule and policies page, should be a path to a node'), |
448 | 448 | '#description' => t('Provide a path to a node which will serve as your site\'s rules and policies page. This will be used on the Join page shown to new users. If blank, no link to a rules and policies page will be provided.<br>Examples: rules-and-policies, node/789'), |
449 | 449 | '#default_value' => $default['boinc_weboptions_rulespolicies'], |
450 | - ); |
|
451 | - $form['boinc_other_frontpage'] = array ( |
|
450 | + ); |
|
451 | + $form['boinc_other_frontpage'] = array ( |
|
452 | 452 | '#type' => 'textarea', |
453 | 453 | '#title' => bts('Message for site\'s Home Page', array(), NULL, 'boinc:admin-boinc-other-options'), |
454 | 454 | '#default_value' => $default['boinc_other_frontpage'], |
455 | 455 | '#cols' => 60, |
456 | 456 | '#rows' => 8, |
457 | 457 | '#description' => bts('Text to be displayed on the site\'s Home landing page.', array(), NULL, 'boinc:admin-boinc-other-options'), |
458 | - ); |
|
458 | + ); |
|
459 | 459 | |
460 | - $form['Othertitle'] = array( |
|
460 | + $form['Othertitle'] = array( |
|
461 | 461 | '#value' => '<h3>Other Options</h3>', |
462 | - ); |
|
462 | + ); |
|
463 | 463 | |
464 | - $form['boinc_weboptions_blacklisted_usernames'] = array ( |
|
464 | + $form['boinc_weboptions_blacklisted_usernames'] = array ( |
|
465 | 465 | '#type' => 'textarea', |
466 | 466 | '#title' => t('BOINC username blacklist'), |
467 | 467 | '#default_value' => $default['boinc_weboptions_blacklisted_usernames'], |
468 | 468 | '#cols' => 60, |
469 | 469 | '#rows' => 7, |
470 | 470 | '#description' => t('Username blacklist: List of names that users will not be able to choose as their BOINC username. This will only affect Web registration and when a user changes their name using the Web site. Names should be entered one per line.<p>All names should be <em>lower-case</em>. The comparison made is case-insensitive.<p>If you wish to <em>disable</em> this feature, remove all names from this textbox; the blacklist will be empty.'), |
471 | - ); |
|
471 | + ); |
|
472 | 472 | |
473 | - return system_settings_form($form); |
|
473 | + return system_settings_form($form); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
477 | - * Validate BOINC other form |
|
478 | - */ |
|
477 | + * Validate BOINC other form |
|
478 | + */ |
|
479 | 479 | function boincuser_admin_weboptions_validate($form, &$form_state) { |
480 | - $values = $form_state['values']; |
|
480 | + $values = $form_state['values']; |
|
481 | 481 | |
482 | - $accountfinish = $values['boinc_weboptions_accountfinish']; |
|
483 | - if ( ($accountfinish) AND (!drupal_lookup_path('source', $accountfinish)) ) { |
|
482 | + $accountfinish = $values['boinc_weboptions_accountfinish']; |
|
483 | + if ( ($accountfinish) AND (!drupal_lookup_path('source', $accountfinish)) ) { |
|
484 | 484 | form_set_error('boinc weboptions_accountfinish', t('Path to custom account finish page not found. Please provide a valid path, or leave blank to unset.')); |
485 | - } |
|
485 | + } |
|
486 | 486 | |
487 | - $moderationpage = $values['boinc_weboptions_moderationpage']; |
|
488 | - if ( ($moderationpage) AND (!drupal_lookup_path('source', $moderationpage)) ) { |
|
487 | + $moderationpage = $values['boinc_weboptions_moderationpage']; |
|
488 | + if ( ($moderationpage) AND (!drupal_lookup_path('source', $moderationpage)) ) { |
|
489 | 489 | form_set_error('boinc weboptions_moderationpage', t('Path to moderation page not found. Please provide a valid path, or leave blank to unset.')); |
490 | - } |
|
490 | + } |
|
491 | 491 | |
492 | - $rulespolicies = $values['boinc_weboptions_rulespolicies']; |
|
493 | - if ( ($rulespolicies) AND (!drupal_lookup_path('source', $rulespolicies)) ) { |
|
492 | + $rulespolicies = $values['boinc_weboptions_rulespolicies']; |
|
493 | + if ( ($rulespolicies) AND (!drupal_lookup_path('source', $rulespolicies)) ) { |
|
494 | 494 | form_set_error('boinc weboptions_rulespolicies', t('Path to rules and policies page not found. Please provide a valid path, or leave blank to unset.')); |
495 | - } |
|
495 | + } |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
499 | - * Submit BOINC other form |
|
500 | - */ |
|
499 | + * Submit BOINC other form |
|
500 | + */ |
|
501 | 501 | function boincuser_admin_weboptions_submit($form, &$form_state) { |
502 | - drupal_set_message( bts("Status: Drupa-BOINC Web site options have been updated", array(), NULL, 'boinc:admin-boinc-website-options') ); |
|
502 | + drupal_set_message( bts("Status: Drupa-BOINC Web site options have been updated", array(), NULL, 'boinc:admin-boinc-website-options') ); |
|
503 | 503 | } |
@@ -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 |