@@ -286,11 +286,11 @@ |
||
286 | 286 | |
287 | 287 | require_once("../inc/account_ownership.inc"); |
288 | 288 | if (file_exists($account_ownership_private_key_file_path)) { |
289 | - // If the server has keys configured show the account ownership form |
|
290 | - row2( |
|
291 | - tra("Account Ownership"), |
|
292 | - "<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
|
293 | - ); |
|
289 | + // If the server has keys configured show the account ownership form |
|
290 | + row2( |
|
291 | + tra("Account Ownership"), |
|
292 | + "<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
|
293 | + ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | } |
@@ -23,15 +23,15 @@ |
||
23 | 23 | admin_page_head("Account Ownership Keys"); |
24 | 24 | |
25 | 25 | if (!file_exists($account_ownership_private_key_file_path)) { |
26 | - echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script from the command line in the BOINC web server ops directory.</p>"; |
|
26 | + echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script from the command line in the BOINC web server ops directory.</p>"; |
|
27 | 27 | } else { |
28 | - echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' exists.</p>"; |
|
28 | + echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' exists.</p>"; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | if (!file_exists($account_ownership_public_key_file_path)) { |
32 | - echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script from the command line in the BOINC web server ops directory.</p>"; |
|
32 | + echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script from the command line in the BOINC web server ops directory.</p>"; |
|
33 | 33 | } else { |
34 | - echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' exists.</p>"; |
|
34 | + echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' exists.</p>"; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | echo "<p>For more info see the related wiki page: <a href=\"https://boinc.berkeley.edu/trac/wiki/ProofOfOwnership\">ProofOfOwnership</a></p>"; |
@@ -28,140 +28,140 @@ |
||
28 | 28 | check_tokens($user->authenticator); |
29 | 29 | |
30 | 30 | function account_ownership_action($user) { |
31 | - // POST request - the user has submitted the form. |
|
32 | - page_head(tra("Proof of account ownership results"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
33 | - |
|
34 | - global $recaptcha_private_key; |
|
35 | - if ($recaptcha_private_key) { |
|
36 | - // Recaptcha is enabled on the BOINC server |
|
37 | - if (!boinc_recaptcha_isValidated($recaptcha_private_key)) { |
|
38 | - // The user failed to solve the recaptcha prompt - redirect them to an error message! |
|
39 | - error_page( |
|
40 | - tra("Your reCAPTCHA response was not correct. Please try again.") |
|
41 | - ); |
|
42 | - } |
|
43 | - } |
|
44 | - |
|
45 | - // Input is passed in from the openssl_sign_form |
|
46 | - $user_data = htmlentities(post_str("user_data", true), ENT_QUOTES, "UTF-8"); // Convert special characters to html equivelant |
|
47 | - |
|
48 | - if ((strlen($user_data) > 0) && (strlen($user_data) <= 4096)) { |
|
49 | - require_once("../inc/account_ownership.inc"); |
|
50 | - // Check that the private key file exists where specified. If not, redirect to error page. |
|
51 | - if (!file_exists($account_ownership_private_key_file_path)) { |
|
52 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
53 | - } |
|
54 | - |
|
55 | - // Check that the public key file exists where specified. If not, redirect to error page. |
|
56 | - if (!file_exists($account_ownership_public_key_file_path)) { |
|
57 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
58 | - } |
|
59 | - |
|
60 | - $privkey = fopen($account_ownership_private_key_file_path, "r"); // Opening private key file |
|
61 | - if (!isset($privkey) || empty($privkey)) { |
|
31 | + // POST request - the user has submitted the form. |
|
32 | + page_head(tra("Proof of account ownership results"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
33 | + |
|
34 | + global $recaptcha_private_key; |
|
35 | + if ($recaptcha_private_key) { |
|
36 | + // Recaptcha is enabled on the BOINC server |
|
37 | + if (!boinc_recaptcha_isValidated($recaptcha_private_key)) { |
|
38 | + // The user failed to solve the recaptcha prompt - redirect them to an error message! |
|
39 | + error_page( |
|
40 | + tra("Your reCAPTCHA response was not correct. Please try again.") |
|
41 | + ); |
|
42 | + } |
|
43 | + } |
|
44 | + |
|
45 | + // Input is passed in from the openssl_sign_form |
|
46 | + $user_data = htmlentities(post_str("user_data", true), ENT_QUOTES, "UTF-8"); // Convert special characters to html equivelant |
|
47 | + |
|
48 | + if ((strlen($user_data) > 0) && (strlen($user_data) <= 4096)) { |
|
49 | + require_once("../inc/account_ownership.inc"); |
|
50 | + // Check that the private key file exists where specified. If not, redirect to error page. |
|
51 | + if (!file_exists($account_ownership_private_key_file_path)) { |
|
52 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
53 | + } |
|
54 | + |
|
55 | + // Check that the public key file exists where specified. If not, redirect to error page. |
|
56 | + if (!file_exists($account_ownership_public_key_file_path)) { |
|
57 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
58 | + } |
|
59 | + |
|
60 | + $privkey = fopen($account_ownership_private_key_file_path, "r"); // Opening private key file |
|
61 | + if (!isset($privkey) || empty($privkey)) { |
|
62 | 62 | error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
63 | - } |
|
64 | - $privkey_contents = fread($privkey, 8192); // Reading contents of private key into var |
|
65 | - fclose($privkey); // Closing private key file |
|
63 | + } |
|
64 | + $privkey_contents = fread($privkey, 8192); // Reading contents of private key into var |
|
65 | + fclose($privkey); // Closing private key file |
|
66 | 66 | |
67 | - $userid = $user->id; // Retrieving the user's UserId |
|
68 | - $message_data = "$userid $user_data"; // Create the message which will be signed. |
|
67 | + $userid = $user->id; // Retrieving the user's UserId |
|
68 | + $message_data = "$userid $user_data"; // Create the message which will be signed. |
|
69 | 69 | |
70 | - $private_key_pem = openssl_pkey_get_private($privkey_contents); // Loading the private key into memory |
|
71 | - openssl_sign($message_data, $signature, $private_key_pem, OPENSSL_ALGO_SHA512); // Compute signature using SHA512 |
|
72 | - openssl_free_key($private_key_pem); // Free the private key from memory for additional security |
|
70 | + $private_key_pem = openssl_pkey_get_private($privkey_contents); // Loading the private key into memory |
|
71 | + openssl_sign($message_data, $signature, $private_key_pem, OPENSSL_ALGO_SHA512); // Compute signature using SHA512 |
|
72 | + openssl_free_key($private_key_pem); // Free the private key from memory for additional security |
|
73 | 73 | |
74 | - $pubkey = fopen($account_ownership_public_key_file_path, "r"); // Open public key file |
|
75 | - if ((!isset($pubkey)) || empty($pubkey)) { |
|
74 | + $pubkey = fopen($account_ownership_public_key_file_path, "r"); // Open public key file |
|
75 | + if ((!isset($pubkey)) || empty($pubkey)) { |
|
76 | 76 | error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
77 | - } |
|
78 | - $pubkey_contents = fread($pubkey, 8192); // Read contents to var |
|
79 | - fclose($pubkey); // Close pub key file |
|
80 | - |
|
81 | - $base64_sig = base64_encode($signature); // Base64 encode the generated signature to enable safe output to text file. |
|
82 | - $decoded_sig = base64_decode($base64_sig); // Decode base64 sig for use in sig_verification |
|
83 | - $pubkeyid = openssl_pkey_get_public($pubkey_contents); // fetch public key into memory |
|
84 | - $sig_verification = openssl_verify($message_data, $decoded_sig, $pubkeyid, OPENSSL_ALGO_SHA512); // Verify that the generated signature against the original data, using the public key. |
|
85 | - openssl_free_key($pubkeyid); // Free the public key from memory |
|
86 | - |
|
87 | - // Check if signature was successfully validated |
|
88 | - if ($sig_verification == 1) { |
|
89 | - $url_tokens = url_tokens($user->authenticator); |
|
90 | - // The generated signature has been successfully verified using the public key. |
|
91 | - global $master_url; // Define global master_url variable for use in output |
|
92 | - echo "<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>"; |
|
93 | - echo "<textarea rows='13' cols='50' id='result_textbox'><account_ownership_verification>\n<master_url>$master_url</master_url>\n<msg>$message_data</msg>\n<signature>$base64_sig</signature>\n</account_ownership_verification></textarea>"; |
|
94 | - echo "<br/><br/><button class='btn btn-success' onclick='copy_result_textbox()'>Copy text</button>"; |
|
95 | - echo "<a href='account_ownership.php?$url_tokens'><button class='btn btn-default'>Go back</button></a>"; |
|
96 | - echo '<script type="text/javascript">'; |
|
97 | - echo 'function copy_result_textbox() { |
|
77 | + } |
|
78 | + $pubkey_contents = fread($pubkey, 8192); // Read contents to var |
|
79 | + fclose($pubkey); // Close pub key file |
|
80 | + |
|
81 | + $base64_sig = base64_encode($signature); // Base64 encode the generated signature to enable safe output to text file. |
|
82 | + $decoded_sig = base64_decode($base64_sig); // Decode base64 sig for use in sig_verification |
|
83 | + $pubkeyid = openssl_pkey_get_public($pubkey_contents); // fetch public key into memory |
|
84 | + $sig_verification = openssl_verify($message_data, $decoded_sig, $pubkeyid, OPENSSL_ALGO_SHA512); // Verify that the generated signature against the original data, using the public key. |
|
85 | + openssl_free_key($pubkeyid); // Free the public key from memory |
|
86 | + |
|
87 | + // Check if signature was successfully validated |
|
88 | + if ($sig_verification == 1) { |
|
89 | + $url_tokens = url_tokens($user->authenticator); |
|
90 | + // The generated signature has been successfully verified using the public key. |
|
91 | + global $master_url; // Define global master_url variable for use in output |
|
92 | + echo "<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>"; |
|
93 | + echo "<textarea rows='13' cols='50' id='result_textbox'><account_ownership_verification>\n<master_url>$master_url</master_url>\n<msg>$message_data</msg>\n<signature>$base64_sig</signature>\n</account_ownership_verification></textarea>"; |
|
94 | + echo "<br/><br/><button class='btn btn-success' onclick='copy_result_textbox()'>Copy text</button>"; |
|
95 | + echo "<a href='account_ownership.php?$url_tokens'><button class='btn btn-default'>Go back</button></a>"; |
|
96 | + echo '<script type="text/javascript">'; |
|
97 | + echo 'function copy_result_textbox() { |
|
98 | 98 | var target_textbox = document.getElementById("result_textbox"); |
99 | 99 | target_textbox.select(); |
100 | 100 | document.execCommand("copy"); |
101 | 101 | alert("Copied to clipboard"); |
102 | 102 | }'; |
103 | - echo '</script>'; |
|
104 | - page_tail(); |
|
105 | - |
|
106 | - } elseif ($sig_verification == 0) { |
|
107 | - // The generated signature has not been verified. The private/public keys do not match. |
|
108 | - error_page(tra("Signature verification failed. Contact the project administrator to resolve the issue.")); |
|
109 | - } else { |
|
110 | - // Something has gone wrong & an error has occurred. |
|
111 | - error_page(tra("An error occurred during the signature verification. Contact the project administrator to resolve the issue.")); |
|
112 | - } |
|
113 | - } else { |
|
114 | - // User data input invalid |
|
115 | - error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>")); |
|
116 | - } |
|
103 | + echo '</script>'; |
|
104 | + page_tail(); |
|
105 | + |
|
106 | + } elseif ($sig_verification == 0) { |
|
107 | + // The generated signature has not been verified. The private/public keys do not match. |
|
108 | + error_page(tra("Signature verification failed. Contact the project administrator to resolve the issue.")); |
|
109 | + } else { |
|
110 | + // Something has gone wrong & an error has occurred. |
|
111 | + error_page(tra("An error occurred during the signature verification. Contact the project administrator to resolve the issue.")); |
|
112 | + } |
|
113 | + } else { |
|
114 | + // User data input invalid |
|
115 | + error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>")); |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | function account_ownership_form($user) { |
120 | - // GET request - the user has navigated to the page. |
|
121 | - page_head(tra("Generate proof of account ownership"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
122 | - |
|
123 | - if ($user) { // Verify the user is logged in |
|
124 | - require_once("../inc/account_ownership.inc"); |
|
125 | - |
|
126 | - if (!file_exists($account_ownership_private_key_file_path)) { |
|
127 | - // Check that the private key file exists where specified. If not, redirect to error page. |
|
128 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
129 | - } |
|
130 | - |
|
131 | - if (!file_exists($account_ownership_public_key_file_path)) { |
|
132 | - // Check that the public key file exists where specified. If not, redirect to error page. |
|
133 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
134 | - } |
|
135 | - |
|
136 | - echo "<p>This tool is designed to create a proof of account ownership for external systems.</p>"; |
|
137 | - |
|
138 | - global $recaptcha_public_key; |
|
139 | - if ($recaptcha_public_key) { |
|
140 | - // Recaptcha configured |
|
141 | - echo "<p>Enter a message with length less than 4096 characters into the input textbox below, solve the captcha then click the 'Generate' button.</p>"; |
|
142 | - } else { |
|
143 | - // Recaptcha not configured |
|
144 | - echo "<p>Enter a message with length less than 4096 characters into the input textbox below then click the 'Generate' button.</p>"; |
|
145 | - } |
|
146 | - echo "<p>A textbox will then appear which contains your proof of account ownership."; |
|
147 | - echo "<form method=post action=account_ownership.php>"; |
|
148 | - |
|
149 | - echo form_tokens($user->authenticator); |
|
150 | - echo "<textarea rows='4' cols='50' name=user_data type=text size=20 placeholder='Enter text'></textarea><br/><br/>"; |
|
151 | - |
|
152 | - if ($recaptcha_public_key) { |
|
153 | - // Trigger recaptcha! |
|
154 | - form_general("", boinc_recaptcha_get_html($recaptcha_public_key)); |
|
155 | - } |
|
156 | - |
|
157 | - echo "<input class=\"btn btn-success\" type=submit value='".tra("Generate")."'>"; |
|
158 | - echo "</form><br/><hr/>"; |
|
159 | - } else { |
|
160 | - // The user is not logged in! |
|
161 | - echo "<p>You need to be logged in to use this functionality.</p>"; |
|
162 | - } |
|
163 | - |
|
164 | - page_tail(); |
|
120 | + // GET request - the user has navigated to the page. |
|
121 | + page_head(tra("Generate proof of account ownership"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
122 | + |
|
123 | + if ($user) { // Verify the user is logged in |
|
124 | + require_once("../inc/account_ownership.inc"); |
|
125 | + |
|
126 | + if (!file_exists($account_ownership_private_key_file_path)) { |
|
127 | + // Check that the private key file exists where specified. If not, redirect to error page. |
|
128 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
129 | + } |
|
130 | + |
|
131 | + if (!file_exists($account_ownership_public_key_file_path)) { |
|
132 | + // Check that the public key file exists where specified. If not, redirect to error page. |
|
133 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
134 | + } |
|
135 | + |
|
136 | + echo "<p>This tool is designed to create a proof of account ownership for external systems.</p>"; |
|
137 | + |
|
138 | + global $recaptcha_public_key; |
|
139 | + if ($recaptcha_public_key) { |
|
140 | + // Recaptcha configured |
|
141 | + echo "<p>Enter a message with length less than 4096 characters into the input textbox below, solve the captcha then click the 'Generate' button.</p>"; |
|
142 | + } else { |
|
143 | + // Recaptcha not configured |
|
144 | + echo "<p>Enter a message with length less than 4096 characters into the input textbox below then click the 'Generate' button.</p>"; |
|
145 | + } |
|
146 | + echo "<p>A textbox will then appear which contains your proof of account ownership."; |
|
147 | + echo "<form method=post action=account_ownership.php>"; |
|
148 | + |
|
149 | + echo form_tokens($user->authenticator); |
|
150 | + echo "<textarea rows='4' cols='50' name=user_data type=text size=20 placeholder='Enter text'></textarea><br/><br/>"; |
|
151 | + |
|
152 | + if ($recaptcha_public_key) { |
|
153 | + // Trigger recaptcha! |
|
154 | + form_general("", boinc_recaptcha_get_html($recaptcha_public_key)); |
|
155 | + } |
|
156 | + |
|
157 | + echo "<input class=\"btn btn-success\" type=submit value='".tra("Generate")."'>"; |
|
158 | + echo "</form><br/><hr/>"; |
|
159 | + } else { |
|
160 | + // The user is not logged in! |
|
161 | + echo "<p>You need to be logged in to use this functionality.</p>"; |
|
162 | + } |
|
163 | + |
|
164 | + page_tail(); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
@@ -16,29 +16,29 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | function flag_abuse_reason_flag_default_flags() { |
19 | - $flags = array(); |
|
20 | - module_load_include('inc', 'flag_abuse_reason', 'includes/flag_abuse_reason.flag_default'); |
|
21 | - _flag_abuse_reason_abuse_node_flags($flags); |
|
22 | - _flag_abuse_reason_abuse_comment_flags($flags); |
|
23 | - _flag_abuse_reason_abuse_user_flags($flags); |
|
24 | - return $flags; |
|
19 | + $flags = array(); |
|
20 | + module_load_include('inc', 'flag_abuse_reason', 'includes/flag_abuse_reason.flag_default'); |
|
21 | + _flag_abuse_reason_abuse_node_flags($flags); |
|
22 | + _flag_abuse_reason_abuse_comment_flags($flags); |
|
23 | + _flag_abuse_reason_abuse_user_flags($flags); |
|
24 | + return $flags; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Implementation of hook_views_api(). |
29 | 29 | */ |
30 | 30 | function flag_abuse_reason_views_api() { |
31 | - return array( |
|
31 | + return array( |
|
32 | 32 | 'api' => 2.0, |
33 | 33 | 'path' => drupal_get_path('module', 'flag_abuse_reason') . '/includes', |
34 | - ); |
|
34 | + ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Implementation of hook_perm(). |
39 | 39 | */ |
40 | 40 | function flag_abuse_reason_perm() { |
41 | - return array('reset abuse flags'); |
|
41 | + return array('reset abuse flags'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * Here we change our flag event/action to 'reset'. |
48 | 48 | */ |
49 | 49 | function flag_abuse_reason_preprocess_flag(&$vars) { |
50 | - drupal_add_js(drupal_get_path('module', 'flag_abuse_reason') . "/includes/flag_abuse_reason.js"); |
|
51 | - drupal_add_css(drupal_get_path('module', 'flag_abuse_reason') . "/css/flag_abuse_reason.css"); |
|
52 | - $myuser = $vars['user']; |
|
53 | - $metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta'); |
|
50 | + drupal_add_js(drupal_get_path('module', 'flag_abuse_reason') . "/includes/flag_abuse_reason.js"); |
|
51 | + drupal_add_css(drupal_get_path('module', 'flag_abuse_reason') . "/css/flag_abuse_reason.css"); |
|
52 | + $myuser = $vars['user']; |
|
53 | + $metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta'); |
|
54 | 54 | |
55 | - // permmission check instead of a role |
|
56 | - // Is this one of our abuse flags? |
|
57 | - if (in_array($vars['flag']->name, $metaflags)) { |
|
55 | + // permmission check instead of a role |
|
56 | + // Is this one of our abuse flags? |
|
57 | + if (in_array($vars['flag']->name, $metaflags)) { |
|
58 | 58 | |
59 | 59 | // count the number of flags on this content |
60 | 60 | $count = db_result(db_query("SELECT COUNT(*) FROM {flag_content} WHERE content_id=%d AND fid=%d", $vars['content_id'], $vars['flag']->fid)); |
@@ -62,41 +62,41 @@ discard block |
||
62 | 62 | // If the variable <flagname>-<contentid> is set, then Reset |
63 | 63 | // completely. |
64 | 64 | if (variable_get($vars['flag']->name.'-'.$vars['content_id'], FALSE)) { |
65 | - if (user_access('reset abuse flags', $myuser)) { |
|
65 | + if (user_access('reset abuse flags', $myuser)) { |
|
66 | 66 | $vars['action'] = 'none'; |
67 | 67 | $vars['link_text'] = t('Reset Completely'); |
68 | 68 | $vars['link_title'] = t('Reset everying, allows users to re-flag content.'); |
69 | - } |
|
70 | - else { |
|
69 | + } |
|
70 | + else { |
|
71 | 71 | $vars['action'] = 'none'; |
72 | 72 | $vars['link_text'] = t('Locked'); |
73 | 73 | $vars['link_title'] = t('Reporting locked by moderator.'); |
74 | 74 | $vars['link'] = array(); |
75 | 75 | $vars['link_href'] = ''; |
76 | 76 | $vars['flag_classes'] = 'flag style-like-link'; |
77 | - } |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | else { |
80 | - // If there are flags on this content, clear the flags and |
|
81 | - // lock the content. |
|
82 | - if (user_access('reset abuse flags', $myuser)) { |
|
80 | + // If there are flags on this content, clear the flags and |
|
81 | + // lock the content. |
|
82 | + if (user_access('reset abuse flags', $myuser)) { |
|
83 | 83 | if ($count>0) { |
84 | - $vars['action'] = 'reset'; |
|
85 | - $vars['link_text'] = t('Clear Reports and Lock'); |
|
86 | - $vars['link_title'] = t('Remove all flags on this content and prevent any new flagging.'); |
|
84 | + $vars['action'] = 'reset'; |
|
85 | + $vars['link_text'] = t('Clear Reports and Lock'); |
|
86 | + $vars['link_title'] = t('Remove all flags on this content and prevent any new flagging.'); |
|
87 | 87 | } |
88 | 88 | // Otherwise the link is shown but has no effect. |
89 | 89 | else { |
90 | - $vars['action'] = 'none'; |
|
91 | - $vars['link_text'] = t('No abuse reports'); |
|
92 | - $vars['link_title'] = t('This content has no abuse reports. Link does nothing.'); |
|
90 | + $vars['action'] = 'none'; |
|
91 | + $vars['link_text'] = t('No abuse reports'); |
|
92 | + $vars['link_title'] = t('This content has no abuse reports. Link does nothing.'); |
|
93 | 93 | $vars['link'] = array(); |
94 | 94 | $vars['link_href'] = ''; |
95 | 95 | $vars['flag_classes'] = 'flag style-like-link'; |
96 | 96 | } |
97 | - } |
|
97 | + } |
|
98 | + } |
|
98 | 99 | } |
99 | - } |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,72 +106,72 @@ discard block |
||
106 | 106 | * we want to remove all flags. http://drupal.org/node/327901#comment-1085685 |
107 | 107 | */ |
108 | 108 | function flag_abuse_reason_flag($event, $flag, $content_id, $account) { |
109 | - $metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta'); |
|
109 | + $metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta'); |
|
110 | 110 | |
111 | - // For privileged users, check permissions and reset flags |
|
112 | - // permission check instead of a role. |
|
113 | - if (user_access('reset abuse flags', $account)) { |
|
111 | + // For privileged users, check permissions and reset flags |
|
112 | + // permission check instead of a role. |
|
113 | + if (user_access('reset abuse flags', $account)) { |
|
114 | 114 | // Is this one of our abuse flags? |
115 | 115 | if (in_array($flag->name, $metaflags)) { |
116 | 116 | |
117 | - // Reset the flags completely. |
|
118 | - if (variable_get($flag->name.'-'.$content_id, FALSE)) { |
|
117 | + // Reset the flags completely. |
|
118 | + if (variable_get($flag->name.'-'.$content_id, FALSE)) { |
|
119 | 119 | // Since the user flags the content again, we need to unflag it. |
120 | 120 | flag_reset_flag($flag, $content_id); |
121 | 121 | drupal_set_message(bts('INFO: Reset everything. Users may reflag this content.', array(), NULL, 'boinc:flag-abuse-reset'), 'info'); |
122 | 122 | // unlock flag; effectively resets flags for this content |
123 | 123 | variable_del($flag->name.'-'.$content_id); |
124 | - } |
|
125 | - else { |
|
124 | + } |
|
125 | + else { |
|
126 | 126 | // Clear and Lock all flags on this content. |
127 | 127 | $dbresult = db_query("SELECT DISTINCT fid FROM {flag_content} WHERE content_id = %d", $content_id); |
128 | 128 | $rows = 0; |
129 | 129 | while ($myfid = db_fetch_array($dbresult)) { |
130 | - $myflag = flag_get_flag(NULL, array_pop($myfid)); |
|
131 | - $rows += flag_reset_flag($myflag, $content_id); |
|
130 | + $myflag = flag_get_flag(NULL, array_pop($myfid)); |
|
131 | + $rows += flag_reset_flag($myflag, $content_id); |
|
132 | 132 | } |
133 | 133 | if ($rows) { |
134 | - // This user actually flags the content as well, so it may |
|
135 | - // confuse the user if they reset what they thought was one |
|
136 | - // flag and we report two. |
|
137 | - $rows--; |
|
138 | - drupal_set_message(bts('INFO: Cleared !rows flags. Content is now locked and may not be reflagged.', array('!rows' => $rows), NULL, 'boinc:flag-abuse-reset'), 'info'); |
|
139 | - |
|
140 | - // This is the line which sets a Drupal variable which |
|
141 | - // prevents the flag link from showing again for all |
|
142 | - // users. Effectively preventing the content from being |
|
143 | - // flagged again. |
|
144 | - variable_set($flag->name.'-'.$content_id, TRUE); |
|
134 | + // This user actually flags the content as well, so it may |
|
135 | + // confuse the user if they reset what they thought was one |
|
136 | + // flag and we report two. |
|
137 | + $rows--; |
|
138 | + drupal_set_message(bts('INFO: Cleared !rows flags. Content is now locked and may not be reflagged.', array('!rows' => $rows), NULL, 'boinc:flag-abuse-reset'), 'info'); |
|
139 | + |
|
140 | + // This is the line which sets a Drupal variable which |
|
141 | + // prevents the flag link from showing again for all |
|
142 | + // users. Effectively preventing the content from being |
|
143 | + // flagged again. |
|
144 | + variable_set($flag->name.'-'.$content_id, TRUE); |
|
145 | + } |
|
145 | 146 | } |
146 | - } |
|
147 | 147 | |
148 | 148 | } |
149 | - } |
|
150 | - // Normal users may cancel their all their reported flags on this |
|
151 | - // content. |
|
152 | - else { |
|
149 | + } |
|
150 | + // Normal users may cancel their all their reported flags on this |
|
151 | + // content. |
|
152 | + else { |
|
153 | 153 | if ( ($event=='unflag') && (in_array($flag->name, $metaflags)) ) { |
154 | - $allflags = flag_get_user_flags($flag->content_type, $content_id, $account->uid); |
|
155 | - foreach ($allflags as $subflag) { |
|
154 | + $allflags = flag_get_user_flags($flag->content_type, $content_id, $account->uid); |
|
155 | + foreach ($allflags as $subflag) { |
|
156 | 156 | $myflag = flag_get_flag(NULL, $subflag->fid); |
157 | 157 | $rc = $myflag->flag('unflag', $content_id, $account); |
158 | - } |
|
158 | + } |
|
159 | + } |
|
159 | 160 | } |
160 | - } |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Implementation of hook_form_FORM_ID_alter(). |
165 | 165 | */ |
166 | 166 | function flag_abuse_reason_form_flag_confirm_alter(&$form, &$form_state) { |
167 | - // Permmission check instead of a role. |
|
168 | - if (user_access('reset abuse flags', $account)) { |
|
167 | + // Permmission check instead of a role. |
|
168 | + if (user_access('reset abuse flags', $account)) { |
|
169 | 169 | $flag_name = $form['flag_name']['#value']; |
170 | 170 | // Is this one of our abuse flags? |
171 | 171 | if (in_array($flag_name, array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta'))) { |
172 | - drupal_set_title(t('Flag reset')); |
|
173 | - $form['description']['#value'] = t('Are you sure you want to reset all offensive flag on this content? Once doing so, users will not be able to flag this content again.'); |
|
174 | - $form['actions']['submit']['#value'] = t('Reset flags'); |
|
172 | + drupal_set_title(t('Flag reset')); |
|
173 | + $form['description']['#value'] = t('Are you sure you want to reset all offensive flag on this content? Once doing so, users will not be able to flag this content again.'); |
|
174 | + $form['actions']['submit']['#value'] = t('Reset flags'); |
|
175 | + } |
|
175 | 176 | } |
176 | - } |
|
177 | 177 | } |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * Node Flags |
24 | 24 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
25 | 25 | function _flag_abuse_reason_abuse_node_flags(&$flags) { |
26 | - // Exported flag: "Node Abuse 1 SPAM". |
|
27 | - $flags['abuse_node_1'] = array( |
|
26 | + // Exported flag: "Node Abuse 1 SPAM". |
|
27 | + $flags['abuse_node_1'] = array( |
|
28 | 28 | 'content_type' => 'node', |
29 | 29 | 'title' => 'Node Abuse 1 SPAM', |
30 | 30 | 'global' => FALSE, |
31 | 31 | 'types' => array( |
32 | - '0' => 'forum', |
|
33 | - '1' => 'news', |
|
34 | - '2' => 'team_forum', |
|
32 | + '0' => 'forum', |
|
33 | + '1' => 'news', |
|
34 | + '2' => 'team_forum', |
|
35 | 35 | ), |
36 | 36 | 'flag_short' => 'Flag as SPAM', |
37 | 37 | 'flag_long' => 'Flag this content SPAM.', |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | 'unflag_denied_text' => '', |
43 | 43 | 'link_type' => 'toggle', |
44 | 44 | 'roles' => array( |
45 | - 'flag' => array( |
|
45 | + 'flag' => array( |
|
46 | 46 | '0' => 2, |
47 | - ), |
|
48 | - 'unflag' => array( |
|
47 | + ), |
|
48 | + 'unflag' => array( |
|
49 | 49 | '0' => 2, |
50 | - ), |
|
50 | + ), |
|
51 | 51 | ), |
52 | 52 | 'weight' => 0, |
53 | 53 | 'show_on_page' => 0, |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | 'i18n' => '0', |
58 | 58 | 'module' => 'boinc_standard', |
59 | 59 | 'locked' => array( |
60 | - '0' => 'name', |
|
60 | + '0' => 'name', |
|
61 | 61 | ), |
62 | 62 | 'api_version' => 2, |
63 | - ); |
|
64 | - // Exported flag: "Node Abuse 2 Link". |
|
65 | - $flags['abuse_node_2'] = array( |
|
63 | + ); |
|
64 | + // Exported flag: "Node Abuse 2 Link". |
|
65 | + $flags['abuse_node_2'] = array( |
|
66 | 66 | 'content_type' => 'node', |
67 | 67 | 'title' => 'Node Abuse 2 Link', |
68 | 68 | 'global' => FALSE, |
69 | 69 | 'types' => array( |
70 | - '0' => 'forum', |
|
71 | - '1' => 'news', |
|
72 | - '2' => 'team_forum', |
|
70 | + '0' => 'forum', |
|
71 | + '1' => 'news', |
|
72 | + '2' => 'team_forum', |
|
73 | 73 | ), |
74 | 74 | 'flag_short' => 'Report as abusive link', |
75 | 75 | 'flag_long' => 'Flag this content as abusive link.', |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | 'unflag_denied_text' => '', |
81 | 81 | 'link_type' => 'toggle', |
82 | 82 | 'roles' => array( |
83 | - 'flag' => array( |
|
83 | + 'flag' => array( |
|
84 | 84 | '0' => 2, |
85 | - ), |
|
86 | - 'unflag' => array( |
|
85 | + ), |
|
86 | + 'unflag' => array( |
|
87 | 87 | '0' => 2, |
88 | - ), |
|
88 | + ), |
|
89 | 89 | ), |
90 | 90 | 'weight' => 0, |
91 | 91 | 'show_on_page' => 0, |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | 'i18n' => '0', |
96 | 96 | 'module' => 'boinc_standard', |
97 | 97 | 'locked' => array( |
98 | - '0' => 'name', |
|
98 | + '0' => 'name', |
|
99 | 99 | ), |
100 | 100 | 'api_version' => 2, |
101 | - ); |
|
102 | - // Exported flag: "Node Abuse 3 Hostile". |
|
103 | - $flags['abuse_node_3'] = array( |
|
101 | + ); |
|
102 | + // Exported flag: "Node Abuse 3 Hostile". |
|
103 | + $flags['abuse_node_3'] = array( |
|
104 | 104 | 'content_type' => 'node', |
105 | 105 | 'title' => 'Node Abuse 3 Hostile', |
106 | 106 | 'global' => FALSE, |
107 | 107 | 'types' => array( |
108 | - '0' => 'forum', |
|
109 | - '1' => 'news', |
|
110 | - '2' => 'team_forum', |
|
108 | + '0' => 'forum', |
|
109 | + '1' => 'news', |
|
110 | + '2' => 'team_forum', |
|
111 | 111 | ), |
112 | 112 | 'flag_short' => 'Flag as hostile', |
113 | 113 | 'flag_long' => 'Flag this content as hostile.', |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | 'unflag_denied_text' => '', |
119 | 119 | 'link_type' => 'toggle', |
120 | 120 | 'roles' => array( |
121 | - 'flag' => array( |
|
121 | + 'flag' => array( |
|
122 | 122 | '0' => 2, |
123 | - ), |
|
124 | - 'unflag' => array( |
|
123 | + ), |
|
124 | + 'unflag' => array( |
|
125 | 125 | '0' => 2, |
126 | - ), |
|
126 | + ), |
|
127 | 127 | ), |
128 | 128 | 'weight' => 0, |
129 | 129 | 'show_on_page' => 0, |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | 'i18n' => '0', |
134 | 134 | 'module' => 'boinc_standard', |
135 | 135 | 'locked' => array( |
136 | - '0' => 'name', |
|
136 | + '0' => 'name', |
|
137 | 137 | ), |
138 | 138 | 'api_version' => 2, |
139 | - ); |
|
140 | - // Exported flag: "Node Abuse 4 Not Kid Friendly". |
|
141 | - $flags['abuse_node_4'] = array( |
|
139 | + ); |
|
140 | + // Exported flag: "Node Abuse 4 Not Kid Friendly". |
|
141 | + $flags['abuse_node_4'] = array( |
|
142 | 142 | 'content_type' => 'node', |
143 | 143 | 'title' => 'Node Abuse 4 Not Kid Friendly', |
144 | 144 | 'global' => FALSE, |
145 | 145 | 'types' => array( |
146 | - '0' => 'forum', |
|
147 | - '1' => 'news', |
|
148 | - '2' => 'team_forum', |
|
146 | + '0' => 'forum', |
|
147 | + '1' => 'news', |
|
148 | + '2' => 'team_forum', |
|
149 | 149 | ), |
150 | 150 | 'flag_short' => 'Flag as not kid-friendly', |
151 | 151 | 'flag_long' => 'Flag this content as not kid-friendly.', |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | 'unflag_denied_text' => '', |
157 | 157 | 'link_type' => 'toggle', |
158 | 158 | 'roles' => array( |
159 | - 'flag' => array( |
|
159 | + 'flag' => array( |
|
160 | 160 | '0' => 2, |
161 | - ), |
|
162 | - 'unflag' => array( |
|
161 | + ), |
|
162 | + 'unflag' => array( |
|
163 | 163 | '0' => 2, |
164 | - ), |
|
164 | + ), |
|
165 | 165 | ), |
166 | 166 | 'weight' => 0, |
167 | 167 | 'show_on_page' => 0, |
@@ -171,19 +171,19 @@ discard block |
||
171 | 171 | 'i18n' => '0', |
172 | 172 | 'module' => 'boinc_standard', |
173 | 173 | 'locked' => array( |
174 | - '0' => 'name', |
|
174 | + '0' => 'name', |
|
175 | 175 | ), |
176 | 176 | 'api_version' => 2, |
177 | - ); |
|
178 | - // Exported flag: "Node Abuse 5 Other". |
|
179 | - $flags['abuse_node_5'] = array( |
|
177 | + ); |
|
178 | + // Exported flag: "Node Abuse 5 Other". |
|
179 | + $flags['abuse_node_5'] = array( |
|
180 | 180 | 'content_type' => 'node', |
181 | 181 | 'title' => 'Node Abuse 5 Other', |
182 | 182 | 'global' => FALSE, |
183 | 183 | 'types' => array( |
184 | - '0' => 'forum', |
|
185 | - '1' => 'news', |
|
186 | - '2' => 'team_forum', |
|
184 | + '0' => 'forum', |
|
185 | + '1' => 'news', |
|
186 | + '2' => 'team_forum', |
|
187 | 187 | ), |
188 | 188 | 'flag_short' => 'Flag as other', |
189 | 189 | 'flag_long' => 'Flag this content - other reason.', |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | 'unflag_denied_text' => '', |
195 | 195 | 'link_type' => 'toggle', |
196 | 196 | 'roles' => array( |
197 | - 'flag' => array( |
|
197 | + 'flag' => array( |
|
198 | 198 | '0' => 2, |
199 | - ), |
|
200 | - 'unflag' => array( |
|
199 | + ), |
|
200 | + 'unflag' => array( |
|
201 | 201 | '0' => 2, |
202 | - ), |
|
202 | + ), |
|
203 | 203 | ), |
204 | 204 | 'weight' => 0, |
205 | 205 | 'show_on_page' => 0, |
@@ -209,19 +209,19 @@ discard block |
||
209 | 209 | 'i18n' => '0', |
210 | 210 | 'module' => 'boinc_standard', |
211 | 211 | 'locked' => array( |
212 | - '0' => 'name', |
|
212 | + '0' => 'name', |
|
213 | 213 | ), |
214 | 214 | 'api_version' => 2, |
215 | - ); |
|
216 | - // Exported flag: "Node Abuse meta". |
|
217 | - $flags['abuse_node_meta'] = array( |
|
215 | + ); |
|
216 | + // Exported flag: "Node Abuse meta". |
|
217 | + $flags['abuse_node_meta'] = array( |
|
218 | 218 | 'content_type' => 'node', |
219 | 219 | 'title' => 'Node Abuse meta', |
220 | 220 | 'global' => FALSE, |
221 | 221 | 'types' => array( |
222 | - '0' => 'forum', |
|
223 | - '1' => 'news', |
|
224 | - '2' => 'team_forum', |
|
222 | + '0' => 'forum', |
|
223 | + '1' => 'news', |
|
224 | + '2' => 'team_forum', |
|
225 | 225 | ), |
226 | 226 | 'flag_short' => 'Report', |
227 | 227 | 'flag_long' => 'Report content', |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | 'unflag_denied_text' => '', |
233 | 233 | 'link_type' => 'toggle', |
234 | 234 | 'roles' => array( |
235 | - 'flag' => array( |
|
235 | + 'flag' => array( |
|
236 | 236 | '0' => 2, |
237 | - ), |
|
238 | - 'unflag' => array( |
|
237 | + ), |
|
238 | + 'unflag' => array( |
|
239 | 239 | '0' => 2, |
240 | - ), |
|
240 | + ), |
|
241 | 241 | ), |
242 | 242 | 'weight' => 0, |
243 | 243 | 'show_on_page' => 1, |
@@ -247,27 +247,27 @@ discard block |
||
247 | 247 | 'i18n' => '0', |
248 | 248 | 'module' => 'boinc_standard', |
249 | 249 | 'locked' => array( |
250 | - '0' => 'name', |
|
250 | + '0' => 'name', |
|
251 | 251 | ), |
252 | 252 | 'api_version' => 2, |
253 | - ); |
|
253 | + ); |
|
254 | 254 | |
255 | - return $flags; |
|
255 | + return $flags; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
259 | 259 | * Comment Flags |
260 | 260 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
261 | 261 | function _flag_abuse_reason_abuse_comment_flags(&$flags) { |
262 | - // Exported flag: "Comment Abuse 1 SPAM". |
|
263 | - $flags['abuse_comment_1'] = array( |
|
262 | + // Exported flag: "Comment Abuse 1 SPAM". |
|
263 | + $flags['abuse_comment_1'] = array( |
|
264 | 264 | 'content_type' => 'comment', |
265 | 265 | 'title' => 'Comment Abuse 1 SPAM', |
266 | 266 | 'global' => FALSE, |
267 | 267 | 'types' => array( |
268 | - '0' => 'forum', |
|
269 | - '1' => 'news', |
|
270 | - '2' => 'team_forum', |
|
268 | + '0' => 'forum', |
|
269 | + '1' => 'news', |
|
270 | + '2' => 'team_forum', |
|
271 | 271 | ), |
272 | 272 | 'flag_short' => 'Flag as SPAM', |
273 | 273 | 'flag_long' => 'Flag this comment as SPAM.', |
@@ -278,31 +278,31 @@ discard block |
||
278 | 278 | 'unflag_denied_text' => '', |
279 | 279 | 'link_type' => 'toggle', |
280 | 280 | 'roles' => array( |
281 | - 'flag' => array( |
|
281 | + 'flag' => array( |
|
282 | 282 | '0' => 2, |
283 | - ), |
|
284 | - 'unflag' => array( |
|
283 | + ), |
|
284 | + 'unflag' => array( |
|
285 | 285 | '0' => 2, |
286 | - ), |
|
286 | + ), |
|
287 | 287 | ), |
288 | 288 | 'weight' => 0, |
289 | 289 | 'access_author' => '', |
290 | 290 | 'show_on_comment' => 0, |
291 | 291 | 'module' => 'boinc_standard', |
292 | 292 | 'locked' => array( |
293 | - '0' => 'name', |
|
293 | + '0' => 'name', |
|
294 | 294 | ), |
295 | 295 | 'api_version' => 2, |
296 | - ); |
|
297 | - // Exported flag: "Comment Abuse 2 LINK". |
|
298 | - $flags['abuse_comment_2'] = array( |
|
296 | + ); |
|
297 | + // Exported flag: "Comment Abuse 2 LINK". |
|
298 | + $flags['abuse_comment_2'] = array( |
|
299 | 299 | 'content_type' => 'comment', |
300 | 300 | 'title' => 'Comment Abuse 2 LINK', |
301 | 301 | 'global' => FALSE, |
302 | 302 | 'types' => array( |
303 | - '0' => 'forum', |
|
304 | - '1' => 'news', |
|
305 | - '2' => 'team_forum', |
|
303 | + '0' => 'forum', |
|
304 | + '1' => 'news', |
|
305 | + '2' => 'team_forum', |
|
306 | 306 | ), |
307 | 307 | 'flag_short' => 'Flag as abusive link', |
308 | 308 | 'flag_long' => 'Flag this comment with abusive link.', |
@@ -313,31 +313,31 @@ discard block |
||
313 | 313 | 'unflag_denied_text' => '', |
314 | 314 | 'link_type' => 'toggle', |
315 | 315 | 'roles' => array( |
316 | - 'flag' => array( |
|
316 | + 'flag' => array( |
|
317 | 317 | '0' => 2, |
318 | - ), |
|
319 | - 'unflag' => array( |
|
318 | + ), |
|
319 | + 'unflag' => array( |
|
320 | 320 | '0' => 2, |
321 | - ), |
|
321 | + ), |
|
322 | 322 | ), |
323 | 323 | 'weight' => 0, |
324 | 324 | 'access_author' => '', |
325 | 325 | 'show_on_comment' => 0, |
326 | 326 | 'module' => 'boinc_standard', |
327 | 327 | 'locked' => array( |
328 | - '0' => 'name', |
|
328 | + '0' => 'name', |
|
329 | 329 | ), |
330 | 330 | 'api_version' => 2, |
331 | - ); |
|
332 | - // Exported flag: "Comment Abuse 3 Hostile". |
|
333 | - $flags['abuse_comment_3'] = array( |
|
331 | + ); |
|
332 | + // Exported flag: "Comment Abuse 3 Hostile". |
|
333 | + $flags['abuse_comment_3'] = array( |
|
334 | 334 | 'content_type' => 'comment', |
335 | 335 | 'title' => 'Comment Abuse 3 Hostile', |
336 | 336 | 'global' => FALSE, |
337 | 337 | 'types' => array( |
338 | - '0' => 'forum', |
|
339 | - '1' => 'news', |
|
340 | - '2' => 'team_forum', |
|
338 | + '0' => 'forum', |
|
339 | + '1' => 'news', |
|
340 | + '2' => 'team_forum', |
|
341 | 341 | ), |
342 | 342 | 'flag_short' => 'Flag as hostile', |
343 | 343 | 'flag_long' => 'Flag this comment as hostile.', |
@@ -348,31 +348,31 @@ discard block |
||
348 | 348 | 'unflag_denied_text' => '', |
349 | 349 | 'link_type' => 'toggle', |
350 | 350 | 'roles' => array( |
351 | - 'flag' => array( |
|
351 | + 'flag' => array( |
|
352 | 352 | '0' => 2, |
353 | - ), |
|
354 | - 'unflag' => array( |
|
353 | + ), |
|
354 | + 'unflag' => array( |
|
355 | 355 | '0' => 2, |
356 | - ), |
|
356 | + ), |
|
357 | 357 | ), |
358 | 358 | 'weight' => 0, |
359 | 359 | 'access_author' => '', |
360 | 360 | 'show_on_comment' => 0, |
361 | 361 | 'module' => 'boinc_standard', |
362 | 362 | 'locked' => array( |
363 | - '0' => 'name', |
|
363 | + '0' => 'name', |
|
364 | 364 | ), |
365 | 365 | 'api_version' => 2, |
366 | - ); |
|
367 | - // Exported flag: "Comment Abuse 4 Not Kid Friendly". |
|
368 | - $flags['abuse_comment_4'] = array( |
|
366 | + ); |
|
367 | + // Exported flag: "Comment Abuse 4 Not Kid Friendly". |
|
368 | + $flags['abuse_comment_4'] = array( |
|
369 | 369 | 'content_type' => 'comment', |
370 | 370 | 'title' => 'Comment Abuse 4 Not Kid Friendly', |
371 | 371 | 'global' => FALSE, |
372 | 372 | 'types' => array( |
373 | - '0' => 'forum', |
|
374 | - '1' => 'news', |
|
375 | - '2' => 'team_forum', |
|
373 | + '0' => 'forum', |
|
374 | + '1' => 'news', |
|
375 | + '2' => 'team_forum', |
|
376 | 376 | ), |
377 | 377 | 'flag_short' => 'Flag as not kid-friendly', |
378 | 378 | 'flag_long' => 'Flag this comment as not kid-friendly.', |
@@ -383,31 +383,31 @@ discard block |
||
383 | 383 | 'unflag_denied_text' => '', |
384 | 384 | 'link_type' => 'toggle', |
385 | 385 | 'roles' => array( |
386 | - 'flag' => array( |
|
386 | + 'flag' => array( |
|
387 | 387 | '0' => 2, |
388 | - ), |
|
389 | - 'unflag' => array( |
|
388 | + ), |
|
389 | + 'unflag' => array( |
|
390 | 390 | '0' => 2, |
391 | - ), |
|
391 | + ), |
|
392 | 392 | ), |
393 | 393 | 'weight' => 0, |
394 | 394 | 'access_author' => '', |
395 | 395 | 'show_on_comment' => 0, |
396 | 396 | 'module' => 'boinc_standard', |
397 | 397 | 'locked' => array( |
398 | - '0' => 'name', |
|
398 | + '0' => 'name', |
|
399 | 399 | ), |
400 | 400 | 'api_version' => 2, |
401 | - ); |
|
402 | - // Exported flag: "Comment Abuse 5 Other". |
|
403 | - $flags['abuse_comment_5'] = array( |
|
401 | + ); |
|
402 | + // Exported flag: "Comment Abuse 5 Other". |
|
403 | + $flags['abuse_comment_5'] = array( |
|
404 | 404 | 'content_type' => 'comment', |
405 | 405 | 'title' => 'Comment Abuse 5 Other', |
406 | 406 | 'global' => FALSE, |
407 | 407 | 'types' => array( |
408 | - '0' => 'forum', |
|
409 | - '1' => 'news', |
|
410 | - '2' => 'team_forum', |
|
408 | + '0' => 'forum', |
|
409 | + '1' => 'news', |
|
410 | + '2' => 'team_forum', |
|
411 | 411 | ), |
412 | 412 | 'flag_short' => 'Flag as other', |
413 | 413 | 'flag_long' => 'Flag this comment - other reason', |
@@ -418,31 +418,31 @@ discard block |
||
418 | 418 | 'unflag_denied_text' => '', |
419 | 419 | 'link_type' => 'toggle', |
420 | 420 | 'roles' => array( |
421 | - 'flag' => array( |
|
421 | + 'flag' => array( |
|
422 | 422 | '0' => 2, |
423 | - ), |
|
424 | - 'unflag' => array( |
|
423 | + ), |
|
424 | + 'unflag' => array( |
|
425 | 425 | '0' => 2, |
426 | - ), |
|
426 | + ), |
|
427 | 427 | ), |
428 | 428 | 'weight' => 0, |
429 | 429 | 'access_author' => '', |
430 | 430 | 'show_on_comment' => 0, |
431 | 431 | 'module' => 'boinc_standard', |
432 | 432 | 'locked' => array( |
433 | - '0' => 'name', |
|
433 | + '0' => 'name', |
|
434 | 434 | ), |
435 | 435 | 'api_version' => 2, |
436 | - ); |
|
437 | - // Exported flag: "Comment Abuse meta". |
|
438 | - $flags['abuse_comment_meta'] = array( |
|
436 | + ); |
|
437 | + // Exported flag: "Comment Abuse meta". |
|
438 | + $flags['abuse_comment_meta'] = array( |
|
439 | 439 | 'content_type' => 'comment', |
440 | 440 | 'title' => 'Comment Abuse meta', |
441 | 441 | 'global' => '0', |
442 | 442 | 'types' => array( |
443 | - '0' => 'forum', |
|
444 | - '1' => 'news', |
|
445 | - '2' => 'team_forum', |
|
443 | + '0' => 'forum', |
|
444 | + '1' => 'news', |
|
445 | + '2' => 'team_forum', |
|
446 | 446 | ), |
447 | 447 | 'flag_short' => 'Report', |
448 | 448 | 'flag_long' => 'Report comment.', |
@@ -453,32 +453,32 @@ discard block |
||
453 | 453 | 'unflag_denied_text' => '', |
454 | 454 | 'link_type' => 'toggle', |
455 | 455 | 'roles' => array( |
456 | - 'flag' => array( |
|
456 | + 'flag' => array( |
|
457 | 457 | '0' => 2, |
458 | - ), |
|
459 | - 'unflag' => array( |
|
458 | + ), |
|
459 | + 'unflag' => array( |
|
460 | 460 | '0' => 2, |
461 | - ), |
|
461 | + ), |
|
462 | 462 | ), |
463 | 463 | 'weight' => 0, |
464 | 464 | 'access_author' => '', |
465 | 465 | 'show_on_comment' => 1, |
466 | 466 | 'module' => 'boinc_standard', |
467 | 467 | 'locked' => array( |
468 | - '0' => 'name', |
|
468 | + '0' => 'name', |
|
469 | 469 | ), |
470 | 470 | 'api_version' => 2, |
471 | - ); |
|
471 | + ); |
|
472 | 472 | |
473 | - return $flags; |
|
473 | + return $flags; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
477 | 477 | * User Flags |
478 | 478 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
479 | 479 | function _flag_abuse_reason_abuse_user_flags(&$flags) { |
480 | - // Exported flag: "User Abuse 1 SPAM". |
|
481 | - $flags['abuse_user_1'] = array( |
|
480 | + // Exported flag: "User Abuse 1 SPAM". |
|
481 | + $flags['abuse_user_1'] = array( |
|
482 | 482 | 'content_type' => 'user', |
483 | 483 | 'title' => 'User Abuse 1 SPAM', |
484 | 484 | 'global' => FALSE, |
@@ -492,24 +492,24 @@ discard block |
||
492 | 492 | 'unflag_denied_text' => '', |
493 | 493 | 'link_type' => 'toggle', |
494 | 494 | 'roles' => array( |
495 | - 'flag' => array( |
|
495 | + 'flag' => array( |
|
496 | 496 | '0' => 2, |
497 | - ), |
|
498 | - 'unflag' => array( |
|
497 | + ), |
|
498 | + 'unflag' => array( |
|
499 | 499 | '0' => 2, |
500 | - ), |
|
500 | + ), |
|
501 | 501 | ), |
502 | 502 | 'weight' => 0, |
503 | 503 | 'show_on_profile' => 0, |
504 | 504 | 'access_uid' => '', |
505 | 505 | 'module' => 'boinc_standard', |
506 | 506 | 'locked' => array( |
507 | - '0' => 'name', |
|
507 | + '0' => 'name', |
|
508 | 508 | ), |
509 | 509 | 'api_version' => 2, |
510 | - ); |
|
511 | - // Exported flag: "User Abuse 2 Link". |
|
512 | - $flags['abuse_user_2'] = array( |
|
510 | + ); |
|
511 | + // Exported flag: "User Abuse 2 Link". |
|
512 | + $flags['abuse_user_2'] = array( |
|
513 | 513 | 'content_type' => 'user', |
514 | 514 | 'title' => 'User Abuse 2 Link', |
515 | 515 | 'global' => FALSE, |
@@ -523,24 +523,24 @@ discard block |
||
523 | 523 | 'unflag_denied_text' => '', |
524 | 524 | 'link_type' => 'toggle', |
525 | 525 | 'roles' => array( |
526 | - 'flag' => array( |
|
526 | + 'flag' => array( |
|
527 | 527 | '0' => 2, |
528 | - ), |
|
529 | - 'unflag' => array( |
|
528 | + ), |
|
529 | + 'unflag' => array( |
|
530 | 530 | '0' => 2, |
531 | - ), |
|
531 | + ), |
|
532 | 532 | ), |
533 | 533 | 'weight' => 0, |
534 | 534 | 'show_on_profile' => 0, |
535 | 535 | 'access_uid' => '', |
536 | 536 | 'module' => 'boinc_standard', |
537 | 537 | 'locked' => array( |
538 | - '0' => 'name', |
|
538 | + '0' => 'name', |
|
539 | 539 | ), |
540 | 540 | 'api_version' => 2, |
541 | - ); |
|
542 | - // Exported flag: "User Abuse 3 Not Kid Friendly". |
|
543 | - $flags['abuse_user_3'] = array( |
|
541 | + ); |
|
542 | + // Exported flag: "User Abuse 3 Not Kid Friendly". |
|
543 | + $flags['abuse_user_3'] = array( |
|
544 | 544 | 'content_type' => 'user', |
545 | 545 | 'title' => 'User Abuse 3 Not Kid Friendly', |
546 | 546 | 'global' => FALSE, |
@@ -554,24 +554,24 @@ discard block |
||
554 | 554 | 'unflag_denied_text' => '', |
555 | 555 | 'link_type' => 'toggle', |
556 | 556 | 'roles' => array( |
557 | - 'flag' => array( |
|
557 | + 'flag' => array( |
|
558 | 558 | '0' => 2, |
559 | - ), |
|
560 | - 'unflag' => array( |
|
559 | + ), |
|
560 | + 'unflag' => array( |
|
561 | 561 | '0' => 2, |
562 | - ), |
|
562 | + ), |
|
563 | 563 | ), |
564 | 564 | 'weight' => 0, |
565 | 565 | 'show_on_profile' => 0, |
566 | 566 | 'access_uid' => '', |
567 | 567 | 'module' => 'boinc_standard', |
568 | 568 | 'locked' => array( |
569 | - '0' => 'name', |
|
569 | + '0' => 'name', |
|
570 | 570 | ), |
571 | 571 | 'api_version' => 2, |
572 | - ); |
|
573 | - // Exported flag: "User Abuse 4 Other". |
|
574 | - $flags['abuse_user_4'] = array( |
|
572 | + ); |
|
573 | + // Exported flag: "User Abuse 4 Other". |
|
574 | + $flags['abuse_user_4'] = array( |
|
575 | 575 | 'content_type' => 'user', |
576 | 576 | 'title' => 'User Abuse 4 Other', |
577 | 577 | 'global' => FALSE, |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | 'unflag_denied_text' => '', |
586 | 586 | 'link_type' => 'toggle', |
587 | 587 | 'roles' => array( |
588 | - 'flag' => array( |
|
588 | + 'flag' => array( |
|
589 | 589 | '0' => 2, |
590 | - ), |
|
591 | - 'unflag' => array( |
|
590 | + ), |
|
591 | + 'unflag' => array( |
|
592 | 592 | '0' => 2, |
593 | - ), |
|
593 | + ), |
|
594 | 594 | ), |
595 | 595 | 'weight' => 0, |
596 | 596 | 'show_on_profile' => 0, |
597 | 597 | 'access_uid' => '', |
598 | 598 | 'module' => 'boinc_standard', |
599 | 599 | 'locked' => array( |
600 | - '0' => 'name', |
|
600 | + '0' => 'name', |
|
601 | 601 | ), |
602 | 602 | 'api_version' => 2, |
603 | - ); |
|
604 | - // Exported flag: "User Abuse Meta". |
|
605 | - $flags['abuse_user_meta'] = array( |
|
603 | + ); |
|
604 | + // Exported flag: "User Abuse Meta". |
|
605 | + $flags['abuse_user_meta'] = array( |
|
606 | 606 | 'content_type' => 'user', |
607 | 607 | 'title' => 'User Abuse Meta', |
608 | 608 | 'global' => FALSE, |
@@ -616,22 +616,22 @@ discard block |
||
616 | 616 | 'unflag_denied_text' => '', |
617 | 617 | 'link_type' => 'toggle', |
618 | 618 | 'roles' => array( |
619 | - 'flag' => array( |
|
619 | + 'flag' => array( |
|
620 | 620 | '0' => 2, |
621 | - ), |
|
622 | - 'unflag' => array( |
|
621 | + ), |
|
622 | + 'unflag' => array( |
|
623 | 623 | '0' => 2, |
624 | - ), |
|
624 | + ), |
|
625 | 625 | ), |
626 | 626 | 'weight' => 0, |
627 | 627 | 'show_on_profile' => 1, |
628 | 628 | 'access_uid' => '', |
629 | 629 | 'module' => 'boinc_standard', |
630 | 630 | 'locked' => array( |
631 | - '0' => 'name', |
|
631 | + '0' => 'name', |
|
632 | 632 | ), |
633 | 633 | 'api_version' => 2, |
634 | - ); |
|
634 | + ); |
|
635 | 635 | |
636 | - return $flags; |
|
636 | + return $flags; |
|
637 | 637 | } |
@@ -27,44 +27,44 @@ discard block |
||
27 | 27 | * with defined URL paths |
28 | 28 | */ |
29 | 29 | function boincuser_menu() { |
30 | - $items['account/posts'] = array( |
|
30 | + $items['account/posts'] = array( |
|
31 | 31 | 'title' => 'Recent posts', |
32 | 32 | 'description' => '', |
33 | 33 | 'page callback' => 'boincuser_goto_recent_posts', |
34 | 34 | 'access callback' => 'user_is_logged_in', |
35 | 35 | 'type' => MENU_CALLBACK, |
36 | - ); |
|
37 | - $items['account/profile'] = array( |
|
36 | + ); |
|
37 | + $items['account/profile'] = array( |
|
38 | 38 | 'title' => '', |
39 | 39 | 'description' => '', |
40 | 40 | 'page callback' => 'boincuser_view_profile', |
41 | 41 | 'access callback' => 'user_is_logged_in', |
42 | 42 | 'type' => MENU_NORMAL_ITEM |
43 | - ); |
|
44 | - $items['account/profile/view'] = array( |
|
43 | + ); |
|
44 | + $items['account/profile/view'] = array( |
|
45 | 45 | 'title' => 'View', |
46 | 46 | 'description' => 'Show a user profile', |
47 | 47 | 'page callback' => 'boincuser_view_profile', |
48 | 48 | 'access callback' => 'user_is_logged_in', |
49 | 49 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
50 | 50 | 'weight' => 0 |
51 | - ); |
|
52 | - $items['account/profile/edit'] = array( |
|
51 | + ); |
|
52 | + $items['account/profile/edit'] = array( |
|
53 | 53 | 'title' => 'Edit', |
54 | 54 | 'description' => 'Edit a user profile', |
55 | 55 | 'page callback' => 'boincuser_edit_profile', |
56 | 56 | 'access arguments' => array('edit own profile content'), |
57 | 57 | 'type' => MENU_LOCAL_TASK, |
58 | 58 | 'weight' => 5 |
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
59 | + ); |
|
60 | + $items['account/team'] = array( |
|
61 | 61 | 'title' => 'User team', |
62 | 62 | 'description' => '', |
63 | 63 | 'page callback' => 'boincuser_goto_team', |
64 | 64 | 'access callback' => 'user_is_logged_in', |
65 | 65 | 'type' => MENU_CALLBACK, |
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
66 | + ); |
|
67 | + $items['moderate/profile/%user/approve'] = array( |
|
68 | 68 | 'title' => 'Profile approval', |
69 | 69 | 'description' => 'Approve profile content', |
70 | 70 | 'page callback' => 'boincuser_moderate_profile_approve', |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | 'access arguments' => array('edit any profile content'), |
73 | 73 | 'type' => MENU_CALLBACK, |
74 | 74 | 'weight' => 5 |
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
75 | + ); |
|
76 | + $items['moderate/profile/%user/edit'] = array( |
|
77 | 77 | 'title' => 'Profile editor', |
78 | 78 | 'description' => 'Edit a user profile', |
79 | 79 | 'page callback' => 'boincuser_edit_profile', |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'access arguments' => array('edit any profile content'), |
82 | 82 | 'type' => MENU_CALLBACK, |
83 | 83 | 'weight' => 5 |
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
84 | + ); |
|
85 | + $items['moderate/profile/%/reject'] = array( |
|
86 | 86 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
87 | 87 | 'description' => 'Reject profile content', |
88 | 88 | 'page callback' => 'drupal_get_form', |
@@ -90,60 +90,60 @@ discard block |
||
90 | 90 | 'access arguments' => array('edit any profile content'), |
91 | 91 | 'type' => MENU_CALLBACK, |
92 | 92 | 'weight' => 5 |
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
93 | + ); |
|
94 | + $items['moderate/user/%/ban'] = array( |
|
95 | 95 | 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
96 | 96 | 'description' => 'Ban a user from using community features', |
97 | 97 | 'page callback' => 'drupal_get_form', |
98 | 98 | 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
99 | 99 | 'access callback' => 'boincuser_moderate_community_access', |
100 | 100 | 'type' => MENU_CALLBACK, |
101 | - ); |
|
102 | - $items['join'] = array( |
|
101 | + ); |
|
102 | + $items['join'] = array( |
|
103 | 103 | 'title' => '', |
104 | 104 | 'description' => '', |
105 | 105 | 'page callback' => 'join_page', |
106 | 106 | 'access arguments' => array('access content'), |
107 | 107 | 'type' => MENU_NORMAL_ITEM |
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
108 | + ); |
|
109 | + $items['join/new'] = array( |
|
110 | 110 | 'title' => bts("I'm new"), |
111 | 111 | 'page callback' => 'join_page', |
112 | 112 | 'page arguments' => array(1), |
113 | 113 | 'access arguments' => array('access content'), |
114 | 114 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
115 | 115 | 'weight' => 0 |
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
116 | + ); |
|
117 | + $items['join/boinc'] = array( |
|
118 | 118 | 'title' => bts("I'm a BOINC user"), |
119 | 119 | 'page callback' => 'join_page', |
120 | 120 | 'page arguments' => array(1), |
121 | 121 | 'access arguments' => array('access content'), |
122 | 122 | 'type' => MENU_LOCAL_TASK, |
123 | 123 | 'weight' => 5 |
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
124 | + ); |
|
125 | + $items['user/login/auth'] = array( |
|
126 | 126 | 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
127 | 127 | 'description' => 'Log in using a user authenticator', |
128 | 128 | 'page callback' => 'drupal_get_form', |
129 | 129 | 'page arguments' => array('boincuser_authloginform'), |
130 | 130 | 'access arguments' => array('access content'), |
131 | 131 | 'type' => MENU_CALLBACK, |
132 | - ); |
|
133 | - $items['user/termsofuse'] = array( |
|
132 | + ); |
|
133 | + $items['user/termsofuse'] = array( |
|
134 | 134 | 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
135 | 135 | 'description' => 'A site\'s term of use.', |
136 | 136 | 'page callback' => 'drupal_get_form', |
137 | 137 | 'page arguments' => array('boincuser_termsofuse_form'), |
138 | 138 | 'access callback' => 'user_is_logged_in', |
139 | 139 | 'type' => MENU_CALLBACK, |
140 | - ); |
|
141 | - $items['user_control'] = array( |
|
140 | + ); |
|
141 | + $items['user_control'] = array( |
|
142 | 142 | 'page callback' => 'boincuser_control', |
143 | 143 | 'access arguments' => array('access user profiles'), |
144 | 144 | 'type' => MENU_CALLBACK |
145 | - ); |
|
146 | - $items['admin/boinc'] = array( |
|
145 | + ); |
|
146 | + $items['admin/boinc'] = array( |
|
147 | 147 | 'title' => 'BOINC configuration', |
148 | 148 | 'position' => 'right', |
149 | 149 | 'weight' => -8, |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | 'access arguments' => array('administer site configuration'), |
152 | 152 | 'file' => 'system.admin.inc', |
153 | 153 | 'file path' => drupal_get_path('module', 'system'), |
154 | - ); |
|
155 | - $items['admin/boinc/environment'] = array( |
|
154 | + ); |
|
155 | + $items['admin/boinc/environment'] = array( |
|
156 | 156 | 'title' => 'Environment: General', |
157 | 157 | 'description' => 'Set paths to BOINC functions and any other necessary |
158 | 158 | variables that establish a BOINC environment.', |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | 'access arguments' => array('administer site configuration'), |
162 | 162 | 'type' => MENU_NORMAL_ITEM, |
163 | 163 | 'file' => 'boincuser.admin.inc' |
164 | - ); |
|
165 | - $items['admin/boinc/scheduler'] = array( |
|
164 | + ); |
|
165 | + $items['admin/boinc/scheduler'] = array( |
|
166 | 166 | 'title' => 'Environment: Scheduling server URLs', |
167 | 167 | 'description' => 'Set BOINC scheduler options.', |
168 | 168 | 'page callback' => 'drupal_get_form', |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | 'access arguments' => array('administer site configuration'), |
171 | 171 | 'type' => MENU_NORMAL_ITEM, |
172 | 172 | 'file' => 'boincuser.admin.inc' |
173 | - ); |
|
174 | - $items['admin/boinc/weboptions'] = array( |
|
173 | + ); |
|
174 | + $items['admin/boinc/weboptions'] = array( |
|
175 | 175 | 'title' => 'Environment: Website Options', |
176 | 176 | 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
177 | 177 | 'page callback' => 'drupal_get_form', |
@@ -179,117 +179,117 @@ discard block |
||
179 | 179 | 'access arguments' => array('administer site configuration'), |
180 | 180 | 'type' => MENU_NORMAL_ITEM, |
181 | 181 | 'file' => 'boincuser.admin.inc' |
182 | - ); |
|
182 | + ); |
|
183 | 183 | |
184 | - $items['create_account.php'] = array( |
|
184 | + $items['create_account.php'] = array( |
|
185 | 185 | 'title' => 'Create Account RPC', |
186 | 186 | 'description' => 'RPC for creating user accounts.', |
187 | 187 | 'page callback' => 'boincuser_create_account', |
188 | 188 | 'access callback' => TRUE, |
189 | 189 | 'type' => MENU_CALLBACK |
190 | - ); |
|
191 | - $items['account_finish.php'] = array( |
|
190 | + ); |
|
191 | + $items['account_finish.php'] = array( |
|
192 | 192 | 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
193 | 193 | 'description' => 'RPC for after a user has created an account.', |
194 | 194 | 'page callback' => 'boincuser_account_finish', |
195 | 195 | 'access callback' => TRUE, |
196 | 196 | 'type' => MENU_CALLBACK, |
197 | - ); |
|
198 | - $items['boincuser/autocomplete'] = array( |
|
197 | + ); |
|
198 | + $items['boincuser/autocomplete'] = array( |
|
199 | 199 | 'page callback' => '_boincuser_user_name_autocomplete', |
200 | 200 | 'access callback' => TRUE, |
201 | 201 | 'type' => MENU_CALLBACK, |
202 | - ); |
|
203 | - $items['user/%user/recoveremail/%'] = array( |
|
202 | + ); |
|
203 | + $items['user/%user/recoveremail/%'] = array( |
|
204 | 204 | 'title' => t('Recover previous email'), |
205 | 205 | 'description' => t('Form to revert email to previous address.'), |
206 | 206 | 'page callback' => 'drupal_get_form', |
207 | 207 | 'page arguments' => array('boincuser_revertemail', 3), |
208 | 208 | 'access callback' => 'user_is_logged_in', |
209 | 209 | 'type' => MENU_CALLBACK, |
210 | - ); |
|
211 | - $items['recover_email.php'] = array( |
|
210 | + ); |
|
211 | + $items['recover_email.php'] = array( |
|
212 | 212 | 'title' => t('Recover previous email'), |
213 | 213 | 'description' => t('redirect'), |
214 | 214 | 'page callback' => '_boincuser_redirect_recover_email', |
215 | 215 | 'access callback' => TRUE, |
216 | 216 | 'type' => MENU_CALLBACK, |
217 | - ); |
|
218 | - return $items; |
|
217 | + ); |
|
218 | + return $items; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Implementation of hook_init() |
223 | 223 | */ |
224 | 224 | function boincuser_init() { |
225 | - global $user; |
|
226 | - // Skip this check for charts, which are loaded separately |
|
227 | - // (may get duplicate or unexpected messages otherwise) |
|
228 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
225 | + global $user; |
|
226 | + // Skip this check for charts, which are loaded separately |
|
227 | + // (may get duplicate or unexpected messages otherwise) |
|
228 | + if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | 229 | return; |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - // If admin user, do some basic site functionality checks |
|
233 | - if (user_access('administer site configuration')) { |
|
232 | + // If admin user, do some basic site functionality checks |
|
233 | + if (user_access('administer site configuration')) { |
|
234 | 234 | // Ensure we have a configured BOINC environment |
235 | 235 | boinc_get_path(); |
236 | 236 | boinc_get_scheduler_tags(); |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | - // Check credits for the verified contributor role |
|
240 | - boincuser_check_credit_requirements(); |
|
239 | + // Check credits for the verified contributor role |
|
240 | + boincuser_check_credit_requirements(); |
|
241 | 241 | |
242 | - if (module_exists('boincteam')) { |
|
242 | + if (module_exists('boincteam')) { |
|
243 | 243 | // Display any persistent team messages |
244 | 244 | boincteam_show_messages(); |
245 | - } |
|
245 | + } |
|
246 | 246 | |
247 | - // Check if user has agreed to the terms of use. If not, send the |
|
248 | - // user to the terms-of-use form. This is only makes sense if the |
|
249 | - // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
247 | + // Check if user has agreed to the terms of use. If not, send the |
|
248 | + // user to the terms-of-use form. This is only makes sense if the |
|
249 | + // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | + if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | 253 | if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
254 | 254 | |
255 | - // Admins are exempt, otherwise the admin may not be able to |
|
256 | - // access the site! |
|
257 | - $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | - if (!isset($user->roles[$administrator_role])) { |
|
255 | + // Admins are exempt, otherwise the admin may not be able to |
|
256 | + // access the site! |
|
257 | + $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | + if (!isset($user->roles[$administrator_role])) { |
|
259 | 259 | $path = drupal_get_path_alias($_GET['q']); |
260 | 260 | |
261 | 261 | // Any paths that should NOT be redirected go here. |
262 | 262 | // The site will not function correctly if these are not exempt! |
263 | 263 | $paths0 = array( |
264 | - 'user/termsofuse', |
|
265 | - 'logout', |
|
266 | - 'account/info/edit', |
|
267 | - 'user/' . $user->uid . '/edit', |
|
268 | - 'user/' . $user->uid . '/recoveremail/*', |
|
269 | - 'recover_email.php', |
|
264 | + 'user/termsofuse', |
|
265 | + 'logout', |
|
266 | + 'account/info/edit', |
|
267 | + 'user/' . $user->uid . '/edit', |
|
268 | + 'user/' . $user->uid . '/recoveremail/*', |
|
269 | + 'recover_email.php', |
|
270 | 270 | ); |
271 | 271 | if (module_exists('boincuser_delete')) { |
272 | - $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | - $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | - $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
272 | + $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | + $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | + $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // Paths added by the admin |
278 | 278 | $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
279 | 279 | $paths2 = array(); |
280 | 280 | if (is_array($paths1)) { |
281 | - $paths2 = array_map('strtolower', $paths1); |
|
281 | + $paths2 = array_map('strtolower', $paths1); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // paths to ignore |
285 | 285 | $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
286 | 286 | |
287 | 287 | if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
288 | - drupal_goto('user/termsofuse'); |
|
288 | + drupal_goto('user/termsofuse'); |
|
289 | + } |
|
289 | 290 | } |
290 | - } |
|
291 | 291 | } |
292 | - } |
|
292 | + } |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * Drupal user operations |
298 | 298 | */ |
299 | 299 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
300 | - require_boinc('boinc_db'); |
|
301 | - require_boinc('user'); |
|
302 | - require_boinc('xml'); |
|
300 | + require_boinc('boinc_db'); |
|
301 | + require_boinc('user'); |
|
302 | + require_boinc('xml'); |
|
303 | 303 | |
304 | - require_boinc('password_compat/password'); |
|
305 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | - if (isset($account->uid) && ($account->uid > 1)) { |
|
304 | + require_boinc('password_compat/password'); |
|
305 | + // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | + if (isset($account->uid) && ($account->uid > 1)) { |
|
307 | 307 | switch($op) { |
308 | 308 | case 'load': |
309 | 309 | // User loading; insert BOINC data into the user object |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | SELECT boinc_id, penalty_expiration |
312 | 312 | FROM {boincuser} WHERE uid = %d", |
313 | 313 | $account->uid |
314 | - )); |
|
315 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
316 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
317 | - db_set_active('boinc_rw'); |
|
318 | - $boinc_user = db_fetch_object(db_query(" |
|
314 | + )); |
|
315 | + $account->boincuser_id = $drupal_user->boinc_id; |
|
316 | + $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
317 | + db_set_active('boinc_rw'); |
|
318 | + $boinc_user = db_fetch_object(db_query(" |
|
319 | 319 | SELECT |
320 | 320 | name, |
321 | 321 | authenticator, |
@@ -331,29 +331,29 @@ discard block |
||
331 | 331 | FROM {user} |
332 | 332 | WHERE id = %d", |
333 | 333 | $account->boincuser_id |
334 | - )); |
|
335 | - $account->boincuser_name = $boinc_user->name; |
|
336 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
337 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
338 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
339 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
340 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
341 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
342 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
343 | - $account->boincteam_id = $boinc_user->teamid; |
|
344 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
345 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
346 | - db_set_active('default'); |
|
347 | - // Set Drupal team ID |
|
348 | - $account->team = NULL; |
|
349 | - if ($account->boincteam_id) { |
|
334 | + )); |
|
335 | + $account->boincuser_name = $boinc_user->name; |
|
336 | + $account->boincuser_account_key = $boinc_user->authenticator; |
|
337 | + $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
338 | + $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
339 | + $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
340 | + $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
341 | + $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
342 | + $account->boincuser_default_pref_set = $boinc_user->venue; |
|
343 | + $account->boincteam_id = $boinc_user->teamid; |
|
344 | + $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
345 | + $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
346 | + db_set_active('default'); |
|
347 | + // Set Drupal team ID |
|
348 | + $account->team = NULL; |
|
349 | + if ($account->boincteam_id) { |
|
350 | 350 | $account->team = db_result(db_query(" |
351 | 351 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
352 | - $account->boincteam_id |
|
352 | + $account->boincteam_id |
|
353 | 353 | )); |
354 | - } |
|
355 | - // Set post count |
|
356 | - $account->post_count = db_result(db_query(" |
|
354 | + } |
|
355 | + // Set post count |
|
356 | + $account->post_count = db_result(db_query(" |
|
357 | 357 | SELECT COUNT(*) + |
358 | 358 | ( |
359 | 359 | SELECT COUNT(*) FROM {node} |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | WHERE comments.uid = '%d' |
367 | 367 | AND node.status = 1", |
368 | 368 | $account->uid, $account->uid |
369 | - )); |
|
370 | - break; |
|
369 | + )); |
|
370 | + break; |
|
371 | 371 | |
372 | 372 | case 'view': |
373 | 373 | // SAMPLE: Add BOINC data to the user profile |
@@ -393,74 +393,74 @@ discard block |
||
393 | 393 | case 'user_account': |
394 | 394 | // Validate data before updating user account info |
395 | 395 | boincuser_account_validate($edit, $account); |
396 | - break; |
|
396 | + break; |
|
397 | 397 | |
398 | 398 | default: |
399 | 399 | |
400 | 400 | } |
401 | 401 | // We don't want to save validation source, so remove it |
402 | 402 | $edit['validation_source'] = null; |
403 | - } |
|
404 | - break; |
|
403 | + } |
|
404 | + break; |
|
405 | 405 | |
406 | 406 | case 'insert': |
407 | 407 | // New user being added to the system |
408 | 408 | $imported = $_SESSION['importedUser']; |
409 | - unset($_SESSION['importedUser']); |
|
409 | + unset($_SESSION['importedUser']); |
|
410 | 410 | |
411 | - watchdog( |
|
411 | + watchdog( |
|
412 | 412 | 'boincuser', |
413 | 413 | 'Creating user account for %email_addr', |
414 | 414 | array('%email_addr' => $edit['mail']), |
415 | 415 | WATCHDOG_NOTICE |
416 | - ); |
|
416 | + ); |
|
417 | 417 | |
418 | - // The create_acount RPC will call this block of code when |
|
419 | - // user_save() is used. If user is registering using the Web |
|
420 | - // registration form, create a BOINC user and relationships. |
|
421 | - // Create a BOINC account unless importing from BOINC. |
|
422 | - if (!$imported) { |
|
418 | + // The create_acount RPC will call this block of code when |
|
419 | + // user_save() is used. If user is registering using the Web |
|
420 | + // registration form, create a BOINC user and relationships. |
|
421 | + // Create a BOINC account unless importing from BOINC. |
|
422 | + if (!$imported) { |
|
423 | 423 | |
424 | 424 | // set email address lower-case |
425 | 425 | $lower_email_addr = strtolower($edit['mail']); |
426 | 426 | |
427 | 427 | if ($edit['boincuser_name']) { |
428 | - $myname = $edit['boincuser_name']; |
|
428 | + $myname = $edit['boincuser_name']; |
|
429 | 429 | } |
430 | 430 | else if ($edit['name']) { |
431 | - $myname = $edit['name']; |
|
431 | + $myname = $edit['name']; |
|
432 | 432 | } |
433 | 433 | else { |
434 | - $myname = 'noname'; |
|
434 | + $myname = 'noname'; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | $user_params = array( |
438 | - 'email_addr' => $lower_email_addr, |
|
439 | - 'name' => $myname, |
|
438 | + 'email_addr' => $lower_email_addr, |
|
439 | + 'name' => $myname, |
|
440 | 440 | ); |
441 | 441 | |
442 | 442 | // If the 'pass' variable is already a hash, then don't hash it again. |
443 | 443 | if ($edit['boinchash_flag']) { |
444 | - $user_params['passwd_hash'] = $edit['pass']; |
|
444 | + $user_params['passwd_hash'] = $edit['pass']; |
|
445 | 445 | } |
446 | 446 | else { |
447 | - // The passwd_hash here is only the md5() hash. This is |
|
448 | - // because BOINC make_user(), called later, will run |
|
449 | - // password_hash() on this md5 hash. |
|
450 | - $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
447 | + // The passwd_hash here is only the md5() hash. This is |
|
448 | + // because BOINC make_user(), called later, will run |
|
449 | + // password_hash() on this md5 hash. |
|
450 | + $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $boinc_user = boincuser_register_make_user($user_params); |
454 | 454 | if (!$boinc_user) { |
455 | - // Account exists with this email addr |
|
456 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
457 | - return; |
|
455 | + // Account exists with this email addr |
|
456 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
457 | + return; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // Add user to community role by default (not banned) |
461 | 461 | $unrestricted_role = array_search('community member', user_roles(true)); |
462 | 462 | $edit['roles'] = array( |
463 | - $unrestricted_role => '' |
|
463 | + $unrestricted_role => '' |
|
464 | 464 | ); |
465 | 465 | |
466 | 466 | // Disable show_hosts flag, set to TRUE by default |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | // Cross reference Drupal account with BOINC |
472 | 472 | $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
473 | 473 | if (!$reference) { |
474 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | - return; |
|
474 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | + return; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // if terms of use exist, the user must agree. |
479 | 479 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
480 | 480 | if (!empty($termsofuse)) { |
481 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
481 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | // Don't save custom fields to the Drupal user object |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | $edit['boinchash_flag'] = null; |
487 | 487 | // Set email address to lower case in Drupal users table |
488 | 488 | if ($account) { |
489 | - user_save($account, array('mail' => $lower_email_addr)); |
|
489 | + user_save($account, array('mail' => $lower_email_addr)); |
|
490 | 490 | } |
491 | - } |
|
492 | - break; |
|
491 | + } |
|
492 | + break; |
|
493 | 493 | |
494 | 494 | case 'update': |
495 | 495 | if (isset($edit['update_source'])) { |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | // Ensure that BOINC data is altered |
501 | 501 | |
502 | 502 | $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
503 | - $changing_pass = ($edit['pass']) ? true : false; |
|
504 | - if ($changing_email OR $changing_pass) { |
|
503 | + $changing_pass = ($edit['pass']) ? true : false; |
|
504 | + if ($changing_email OR $changing_pass) { |
|
505 | 505 | // set email address to lower-case |
506 | 506 | $lower_email_addr = strtolower($edit['mail']); |
507 | 507 | |
@@ -510,70 +510,70 @@ discard block |
||
510 | 510 | $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
511 | 511 | // Algorithm for changing email and/or password |
512 | 512 | if ($changing_email) { |
513 | - // locally store current email to set as previous email |
|
514 | - $prev_email = $account->mail; |
|
515 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
516 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
513 | + // locally store current email to set as previous email |
|
514 | + $prev_email = $account->mail; |
|
515 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
516 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
517 | 517 | } |
518 | 518 | else { |
519 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
519 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | // Update user account information |
523 | 523 | $result = $boinc_user->update($querypart); |
524 | 524 | |
525 | 525 | if ($changing_email) { |
526 | - // reload account |
|
527 | - $account = user_load($account->uid); |
|
528 | - _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
526 | + // reload account |
|
527 | + $account = user_load($account->uid); |
|
528 | + _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Change email to edit to lower-case version, this sets |
532 | 532 | // email in Drupal database to the lower-case email |
533 | 533 | // address. |
534 | 534 | $edit['mail'] = strtolower($lower_email_addr); |
535 | - } |
|
535 | + } |
|
536 | 536 | |
537 | - // Change boinc username |
|
538 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
537 | + // Change boinc username |
|
538 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
539 | 539 | $boincuser_name = $edit['boincuser_name']; |
540 | 540 | $result = $boinc_user->update( |
541 | 541 | "name='{$boincuser_name}'" |
542 | 542 | ); |
543 | - } |
|
543 | + } |
|
544 | 544 | |
545 | - break; |
|
545 | + break; |
|
546 | 546 | case 'user_profile': |
547 | 547 | if ($edit['boincuser_name'] != $boinc_user->name) { |
548 | 548 | $boincuser_name = $edit['boincuser_name']; |
549 | 549 | $result = $boinc_user->update( |
550 | 550 | "name='{$boincuser_name}'" |
551 | 551 | ); |
552 | - } |
|
553 | - break; |
|
552 | + } |
|
553 | + break; |
|
554 | 554 | default: |
555 | 555 | } |
556 | 556 | // We don't want to save update source or duplicate custom fields, so |
557 | 557 | // remove them before continuing to core Drupal routines |
558 | 558 | $edit['update_source'] = null; |
559 | 559 | $edit['boincuser_name'] = null; |
560 | - } |
|
561 | - break; |
|
560 | + } |
|
561 | + break; |
|
562 | 562 | |
563 | 563 | case 'login': |
564 | 564 | // Function is forward compatible to Drupal 7 |
565 | 565 | boincuser_user_login($edit, $account); |
566 | - break; |
|
566 | + break; |
|
567 | 567 | |
568 | 568 | case 'delete': |
569 | 569 | // Function is forward compatible to Drupal 7 |
570 | 570 | boincuser_user_delete($account); |
571 | - break; |
|
571 | + break; |
|
572 | 572 | |
573 | 573 | default: |
574 | 574 | |
575 | 575 | } |
576 | - } |
|
576 | + } |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -582,39 +582,39 @@ discard block |
||
582 | 582 | *(forward compatible to Drupal 7). |
583 | 583 | */ |
584 | 584 | function boincuser_user_login(&$edit, $account) { |
585 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
586 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
587 | - |
|
588 | - // Use the same code as boincuser_form_alter(), for case |
|
589 | - // 'user_profile_form', if the refering page is the user password |
|
590 | - // reset form, then do not check for terms of use. |
|
591 | - $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
592 | - if ($reset_pass) { |
|
585 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
586 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
587 | + |
|
588 | + // Use the same code as boincuser_form_alter(), for case |
|
589 | + // 'user_profile_form', if the refering page is the user password |
|
590 | + // reset form, then do not check for terms of use. |
|
591 | + $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
592 | + if ($reset_pass) { |
|
593 | 593 | return; |
594 | - } |
|
594 | + } |
|
595 | 595 | |
596 | - // Check if user has agreed to terms of use. |
|
597 | - if ( (!empty($termsofuse)) and ($account->uid) and |
|
596 | + // Check if user has agreed to terms of use. |
|
597 | + if ( (!empty($termsofuse)) and ($account->uid) and |
|
598 | 598 | (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) { |
599 | 599 | |
600 | 600 | // Admins are exempted. |
601 | 601 | $administrator_role = array_search('administrator', user_roles(true)); |
602 | 602 | if (!isset($account->roles[$administrator_role])) { |
603 | 603 | |
604 | - // Find and save the current destination and use as an parameter |
|
605 | - // to send the user back to here he/she came from. |
|
606 | - $np = ltrim('user/termsofuse', '/'); |
|
607 | - $path_for_destination = rawurlencode($np); |
|
604 | + // Find and save the current destination and use as an parameter |
|
605 | + // to send the user back to here he/she came from. |
|
606 | + $np = ltrim('user/termsofuse', '/'); |
|
607 | + $path_for_destination = rawurlencode($np); |
|
608 | 608 | |
609 | - $query_for_destination = ''; |
|
610 | - $prevdest = $_REQUEST['destination']; |
|
611 | - if ($prevdest) { |
|
609 | + $query_for_destination = ''; |
|
610 | + $prevdest = $_REQUEST['destination']; |
|
611 | + if ($prevdest) { |
|
612 | 612 | $query_for_destination = '?destination=' . $prevdest; |
613 | - } |
|
614 | - $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
613 | + } |
|
614 | + $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
615 | 615 | |
616 | 616 | } |
617 | - } |
|
617 | + } |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -623,16 +623,16 @@ discard block |
||
623 | 623 | */ |
624 | 624 | function boincuser_user_delete($account) { |
625 | 625 | |
626 | - $boincid = $account->boincuser_id; |
|
627 | - // bug in comment module, remove user name from comments. Find all |
|
628 | - // comments with uid=0 and clear the field 'name'. |
|
629 | - $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
626 | + $boincid = $account->boincuser_id; |
|
627 | + // bug in comment module, remove user name from comments. Find all |
|
628 | + // comments with uid=0 and clear the field 'name'. |
|
629 | + $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
630 | 630 | |
631 | - // Delete entry in drupal boincuser table. |
|
632 | - $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
633 | - if (!$qrc2) { |
|
631 | + // Delete entry in drupal boincuser table. |
|
632 | + $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
633 | + if (!$qrc2) { |
|
634 | 634 | watchdog('user', 'Error deleting user account, boincuser table UID: %uid.', array('%uid' => $account->uid), WATCHDOG_ERROR); |
635 | - } |
|
635 | + } |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | * Obsolete in Drupal 7... |
642 | 642 | */ |
643 | 643 | function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) { |
644 | - // In Drupal 7, these operation cases will all exist as their own hooks, |
|
645 | - // so let's approximate that here so that this function can simply be removed |
|
646 | - // upon migration to 7 |
|
647 | - switch($op) { |
|
648 | - case 'update': |
|
644 | + // In Drupal 7, these operation cases will all exist as their own hooks, |
|
645 | + // so let's approximate that here so that this function can simply be removed |
|
646 | + // upon migration to 7 |
|
647 | + switch($op) { |
|
648 | + case 'update': |
|
649 | 649 | boincuser_node_update($node); |
650 | - } |
|
650 | + } |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | * is updated (forward compatible to Drupal 7) |
656 | 656 | */ |
657 | 657 | function boincuser_node_update($node) { |
658 | - switch($node->type) { |
|
659 | - case 'profile': |
|
658 | + switch($node->type) { |
|
659 | + case 'profile': |
|
660 | 660 | // Update the BOINC database directly |
661 | 661 | $account = user_load($node->uid); |
662 | 662 | // Save user account data |
@@ -668,11 +668,11 @@ discard block |
||
668 | 668 | UPDATE user |
669 | 669 | SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1 |
670 | 670 | WHERE id = %d", |
671 | - $country, $postal_code, $url, $account->boincuser_id |
|
671 | + $country, $postal_code, $url, $account->boincuser_id |
|
672 | 672 | ); |
673 | 673 | db_set_active('default'); |
674 | 674 | if (!$account_updated) { |
675 | - drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
675 | + drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
676 | 676 | } |
677 | 677 | // Save profile data |
678 | 678 | $response1 = $node->field_background[0]['value']; |
@@ -683,16 +683,16 @@ discard block |
||
683 | 683 | SET userid = %d, response1 = '%s', response2 = '%s' |
684 | 684 | ON DUPLICATE KEY UPDATE |
685 | 685 | response1 = '%s', response2 = '%s'", |
686 | - $account->boincuser_id, $response1, $response2, |
|
687 | - $response1, $response2 |
|
686 | + $account->boincuser_id, $response1, $response2, |
|
687 | + $response1, $response2 |
|
688 | 688 | ); |
689 | 689 | db_set_active('default'); |
690 | 690 | if (!$profile_updated) { |
691 | - drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
691 | + drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
692 | 692 | } |
693 | 693 | break; |
694 | 694 | |
695 | - default: |
|
695 | + default: |
|
696 | 696 | |
697 | 697 | } |
698 | 698 | } |
@@ -701,21 +701,21 @@ discard block |
||
701 | 701 | * Implementation of hook_views_api() |
702 | 702 | */ |
703 | 703 | function boincuser_views_api() { |
704 | - return array( |
|
704 | + return array( |
|
705 | 705 | 'api' => 2.0, |
706 | 706 | 'path' => drupal_get_path('module', 'boincuser') |
707 | - ); |
|
707 | + ); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Implementation of hook_form_alter() |
712 | 712 | */ |
713 | 713 | function boincuser_form_alter(&$form, $form_state, $form_id) { |
714 | - require_boinc('token'); |
|
714 | + require_boinc('token'); |
|
715 | 715 | |
716 | - global $user; |
|
717 | - switch ($form_id) { |
|
718 | - case 'flag_confirm': |
|
716 | + global $user; |
|
717 | + switch ($form_id) { |
|
718 | + case 'flag_confirm': |
|
719 | 719 | // The URL seems to be the only way to put any kind of context to this |
720 | 720 | // request! |
721 | 721 | $action = arg(2); |
@@ -724,25 +724,25 @@ discard block |
||
724 | 724 | |
725 | 725 | // Wrap action buttons for styling consistency |
726 | 726 | $form['form control tabs prefix'] = array( |
727 | - '#value' => '<ul class="form-control tab-list">', |
|
728 | - '#weight' => 1001, |
|
727 | + '#value' => '<ul class="form-control tab-list">', |
|
728 | + '#weight' => 1001, |
|
729 | 729 | ); |
730 | 730 | |
731 | 731 | switch ($flag_type) { |
732 | 732 | case 'friend': |
733 | 733 | $friend_id = $form['content_id']['#value']; |
734 | - $flag = flag_get_flag('friend'); |
|
735 | - $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
734 | + $flag = flag_get_flag('friend'); |
|
735 | + $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
736 | 736 | |
737 | - // General friend form overrides |
|
738 | - $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
739 | - $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
740 | - $form['flag_friend_submit']['#type'] = 'submit'; |
|
741 | - $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
742 | - $form['flag_friend_submit']['#weight'] = 1002; |
|
737 | + // General friend form overrides |
|
738 | + $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
739 | + $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
740 | + $form['flag_friend_submit']['#type'] = 'submit'; |
|
741 | + $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
742 | + $form['flag_friend_submit']['#weight'] = 1002; |
|
743 | 743 | |
744 | - switch ($friend_status) { |
|
745 | - case FLAG_FRIEND_BOTH: |
|
744 | + switch ($friend_status) { |
|
745 | + case FLAG_FRIEND_BOTH: |
|
746 | 746 | case FLAG_FRIEND_FLAGGED: |
747 | 747 | unset($form['actions']); |
748 | 748 | $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove'); |
@@ -751,53 +751,53 @@ discard block |
||
751 | 751 | $form['#submit'][] = 'boincuser_fix_unfriend_form_submit'; |
752 | 752 | $form['#submit'][] = $final_handler; |
753 | 753 | break; |
754 | - case FLAG_FRIEND_PENDING: |
|
754 | + case FLAG_FRIEND_PENDING: |
|
755 | 755 | unset($form['actions']); |
756 | 756 | $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page'); |
757 | 757 | break; |
758 | - case FLAG_FRIEND_APPROVAL: |
|
758 | + case FLAG_FRIEND_APPROVAL: |
|
759 | 759 | if ($action == 'flag') { |
760 | - $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
760 | + $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
761 | 761 | } |
762 | 762 | elseif ($action == 'unflag') { |
763 | - unset($form['actions']); |
|
764 | - $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
763 | + unset($form['actions']); |
|
764 | + $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
765 | 765 | } |
766 | 766 | break; |
767 | - case FLAG_FRIEND_UNFLAGGED: |
|
767 | + case FLAG_FRIEND_UNFLAGGED: |
|
768 | 768 | default: |
769 | 769 | $user_links[] = array( |
770 | - 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
771 | - 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
770 | + 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
771 | + 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
772 | 772 | ); |
773 | - } |
|
774 | - break; |
|
773 | + } |
|
774 | + break; |
|
775 | 775 | |
776 | 776 | default: |
777 | 777 | } |
778 | 778 | |
779 | 779 | $form['cancel'] = array( |
780 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
781 | - '#weight' => 1004, |
|
780 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
781 | + '#weight' => 1004, |
|
782 | 782 | ); |
783 | 783 | $form['form control tabs suffix'] = array( |
784 | - '#value' => '</ul>', |
|
785 | - '#weight' => 1010, |
|
784 | + '#value' => '</ul>', |
|
785 | + '#weight' => 1010, |
|
786 | 786 | ); |
787 | 787 | |
788 | 788 | break; |
789 | 789 | |
790 | - // General node edit form |
|
791 | - case 'news_node_form': |
|
790 | + // General node edit form |
|
791 | + case 'news_node_form': |
|
792 | 792 | $form['separator_bottom'] = array( |
793 | - '#value' => '<div class="separator buttons"></div>', |
|
794 | - '#weight' => 999, |
|
793 | + '#value' => '<div class="separator buttons"></div>', |
|
794 | + '#weight' => 999, |
|
795 | 795 | ); |
796 | 796 | |
797 | 797 | // Wrap action buttons for styling consistency |
798 | 798 | $form['buttons']['form control tabs prefix'] = array( |
799 | - '#value' => '<ul class="form-control tab-list">', |
|
800 | - '#weight' => 1001, |
|
799 | + '#value' => '<ul class="form-control tab-list">', |
|
800 | + '#weight' => 1001, |
|
801 | 801 | ); |
802 | 802 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
803 | 803 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
811 | 811 | $form['buttons']['preview_changes']['#weight'] = 1004; |
812 | 812 | $form['buttons']['cancel'] = array( |
813 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
814 | - '#weight' => 1005, |
|
813 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
814 | + '#weight' => 1005, |
|
815 | 815 | ); |
816 | 816 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
817 | 817 | $form['buttons']['delete']['#suffix'] = '</li>'; |
818 | 818 | $form['buttons']['delete']['#weight'] = 1006; |
819 | 819 | $form['buttons']['form control tabs suffix'] = array( |
820 | - '#value' => '</ul>', |
|
821 | - '#weight' => 1010, |
|
820 | + '#value' => '</ul>', |
|
821 | + '#weight' => 1010, |
|
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Preview is ugly, unset until it works |
@@ -826,16 +826,16 @@ discard block |
||
826 | 826 | |
827 | 827 | break; |
828 | 828 | |
829 | - case 'node_delete_confirm': |
|
829 | + case 'node_delete_confirm': |
|
830 | 830 | $form['separator_bottom'] = array( |
831 | - '#value' => '<div class="separator buttons"></div>', |
|
832 | - '#weight' => 999, |
|
831 | + '#value' => '<div class="separator buttons"></div>', |
|
832 | + '#weight' => 999, |
|
833 | 833 | ); |
834 | 834 | |
835 | 835 | // Wrap action buttons for styling consistency |
836 | 836 | $form['actions']['form control tabs prefix'] = array( |
837 | - '#value' => '<ul class="form-control tab-list">', |
|
838 | - '#weight' => 1001, |
|
837 | + '#value' => '<ul class="form-control tab-list">', |
|
838 | + '#weight' => 1001, |
|
839 | 839 | ); |
840 | 840 | $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
841 | 841 | $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete'); |
@@ -843,23 +843,23 @@ discard block |
||
843 | 843 | $form['actions']['submit']['#weight'] = 1002; |
844 | 844 | $form['actions']['cancel'] = array( |
845 | 845 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
846 | - '#weight' => 1005, |
|
846 | + '#weight' => 1005, |
|
847 | 847 | ); |
848 | 848 | $form['actions']['form control tabs suffix'] = array( |
849 | - '#value' => '</ul>', |
|
850 | - '#weight' => 1010, |
|
849 | + '#value' => '</ul>', |
|
850 | + '#weight' => 1010, |
|
851 | 851 | ); |
852 | 852 | $form['#redirect'] = 'account/profile'; |
853 | 853 | break; |
854 | 854 | |
855 | - case 'privatemsg_new': |
|
855 | + case 'privatemsg_new': |
|
856 | 856 | |
857 | 857 | $form['privatemsg']['body']['#title'] = ''; |
858 | 858 | |
859 | 859 | // Wrap action buttons for styling consistency |
860 | 860 | $form['privatemsg']['form control tabs prefix'] = array( |
861 | - '#value' => '<ul class="form-control tab-list">', |
|
862 | - '#weight' => 1001, |
|
861 | + '#value' => '<ul class="form-control tab-list">', |
|
862 | + '#weight' => 1001, |
|
863 | 863 | ); |
864 | 864 | $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">'; |
865 | 865 | $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message'); |
@@ -869,26 +869,26 @@ discard block |
||
869 | 869 | $form['privatemsg']['preview']['#suffix'] = '</li>'; |
870 | 870 | $form['privatemsg']['preview']['#weight'] = 1003; |
871 | 871 | $form['privatemsg']['cancel'] = array( |
872 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
873 | - '#weight' => 1004, |
|
872 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
873 | + '#weight' => 1004, |
|
874 | 874 | ); |
875 | 875 | $form['privatemsg']['form control tabs suffix'] = array( |
876 | - '#value' => '</ul>', |
|
877 | - '#weight' => 1010, |
|
876 | + '#value' => '</ul>', |
|
877 | + '#weight' => 1010, |
|
878 | 878 | ); |
879 | 879 | |
880 | 880 | unset($form['privatemsg']['recipient_display']); |
881 | 881 | |
882 | 882 | break; |
883 | 883 | |
884 | - // Login form |
|
885 | - case 'user_login': |
|
884 | + // Login form |
|
885 | + case 'user_login': |
|
886 | 886 | case 'user_login_block': |
887 | 887 | drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link')); |
888 | 888 | // Replace name with email in login form |
889 | 889 | unset($form['name']); |
890 | 890 | array_unshift($form, array( |
891 | - 'email' => array( |
|
891 | + 'email' => array( |
|
892 | 892 | '#type' => 'textfield', |
893 | 893 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
894 | 894 | '#size' => ($form_id == 'user_login_block') ? 15 : 60, |
@@ -896,18 +896,18 @@ discard block |
||
896 | 896 | '#required' => TRUE, |
897 | 897 | '#attributes' => array('tabindex' => '1'), |
898 | 898 | '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page') |
899 | - ), |
|
900 | - 'validation_source' => array( |
|
899 | + ), |
|
900 | + 'validation_source' => array( |
|
901 | 901 | '#type' => 'hidden', |
902 | 902 | '#value' => 'user_login' |
903 | - ) |
|
903 | + ) |
|
904 | 904 | )); |
905 | 905 | $form['#redirect'] = 'home'; |
906 | 906 | |
907 | 907 | // Wrap action buttons for styling consistency |
908 | 908 | $form['buttons']['form control tabs prefix'] = array( |
909 | - '#value' => '<ul class="form-control tab-list">', |
|
910 | - '#weight' => 1001, |
|
909 | + '#value' => '<ul class="form-control tab-list">', |
|
910 | + '#weight' => 1001, |
|
911 | 911 | ); |
912 | 912 | $form['buttons']['submit'] = $form['submit']; |
913 | 913 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | $form['buttons']['submit']['#suffix'] = '</li>'; |
916 | 916 | $form['buttons']['submit']['#weight'] = 1002; |
917 | 917 | $form['buttons']['form control tabs suffix'] = array( |
918 | - '#value' => '</ul>', |
|
919 | - '#weight' => 1010, |
|
918 | + '#value' => '</ul>', |
|
919 | + '#weight' => 1010, |
|
920 | 920 | ); |
921 | 921 | unset($form['submit']); |
922 | 922 | |
@@ -925,23 +925,23 @@ discard block |
||
925 | 925 | isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3'); |
926 | 926 | // If the user login form is being submitted, use BOINC validation handler. |
927 | 927 | if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) { |
928 | - // Find the local validation function's entry so we can replace it. |
|
929 | - $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
930 | - if ($array_key === FALSE) { |
|
928 | + // Find the local validation function's entry so we can replace it. |
|
929 | + $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
930 | + if ($array_key === FALSE) { |
|
931 | 931 | // Could not find it. Some other module must have run form_alter(). |
932 | 932 | // We will simply add our validation just before the final validator. |
933 | 933 | $final_validator = array_pop($form['#validate']); |
934 | 934 | $form['#validate'][] = 'boincuser_login_validate'; |
935 | 935 | $form['#validate'][] = $final_validator; |
936 | - } else { |
|
936 | + } else { |
|
937 | 937 | // Replace the local validation function with BOINC validation |
938 | 938 | $form['#validate'][$array_key] = 'boincuser_login_validate'; |
939 | - } |
|
939 | + } |
|
940 | 940 | } |
941 | 941 | break; |
942 | 942 | |
943 | - // User credentials form |
|
944 | - case 'user_profile_form': |
|
943 | + // User credentials form |
|
944 | + case 'user_profile_form': |
|
945 | 945 | |
946 | 946 | // Use the displaly name as the title, not the username |
947 | 947 | $account = user_load($form['#uid']); |
@@ -949,28 +949,28 @@ discard block |
||
949 | 949 | |
950 | 950 | // Message for admins |
951 | 951 | if (user_access('administer users')) { |
952 | - drupal_set_message( |
|
952 | + drupal_set_message( |
|
953 | 953 | bts('WARNING: You are editing the information for user. Please note: you may change a user\'s password by itself. But to change the user\'s email address you must change both the email address and the password simultaneously.') |
954 | - , 'warning'); |
|
954 | + , 'warning'); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | // Set special message if user has not agreed to TOU |
958 | 958 | $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
959 | 959 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
960 | 960 | if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) { |
961 | - drupal_set_message( |
|
961 | + drupal_set_message( |
|
962 | 962 | bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.', |
963 | 963 | array( |
964 | - '@project' => variable_get('site_name','Drupal-BOINC'), |
|
964 | + '@project' => variable_get('site_name','Drupal-BOINC'), |
|
965 | 965 | ), NULL, 'boinc:account-credentials-change') |
966 | - , 'info'); |
|
966 | + , 'info'); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | // A bit hackish... but don't require the user to enter his password if |
970 | 970 | // coming from the password reset function |
971 | 971 | $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1; |
972 | 972 | if ($reset_pass) { |
973 | - $_SESSION['reset_pass'] = 1; |
|
973 | + $_SESSION['reset_pass'] = 1; |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | // Adjust form elements already present |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | $form['account']['pass']['#size'] = 17; |
983 | 983 | |
984 | 984 | if (user_access('administer users')) { |
985 | - // Add BOINC username (aka displayname) |
|
986 | - $form['account']['boincuser_name'] = array( |
|
985 | + // Add BOINC username (aka displayname) |
|
986 | + $form['account']['boincuser_name'] = array( |
|
987 | 987 | '#type' => 'textfield', |
988 | 988 | '#title' => bts('BOINC Username', array(), NULL, 'boinc:user-or-team-name'), |
989 | 989 | '#default_value' => $account->boincuser_name, |
@@ -991,68 +991,68 @@ discard block |
||
991 | 991 | '#required' => TRUE, |
992 | 992 | '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), NULL, 'boinc:username-change'), |
993 | 993 | '#size' => 40, |
994 | - ); |
|
994 | + ); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | // If email address was changed less than 7 days (7 * 86400 s) |
998 | 998 | // ago, it cannot be changed again. |
999 | 999 | $duration = TOKEN_DURATION_ONE_WEEK; |
1000 | 1000 | if (($account->boincuser_email_addr_change_time + $duration) > time() and (!user_access('administer users'))) { |
1001 | - $form['account']['mail']['#required'] = FALSE; |
|
1002 | - $form['account']['mailhelp'] = array( |
|
1001 | + $form['account']['mail']['#required'] = FALSE; |
|
1002 | + $form['account']['mailhelp'] = array( |
|
1003 | 1003 | '#value' => bts("You email address was changed within the past seven (7) days. Please look for an email to !prev_email if you need to revert this change. You may change your email address on !time.", |
1004 | - array( |
|
1004 | + array( |
|
1005 | 1005 | '!prev_email' => $account->boincuser_previous_email_addr, |
1006 | 1006 | '!time' => date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration), |
1007 | - ), NULL, 'boinc:account-credentials-change'), |
|
1008 | - ); |
|
1007 | + ), NULL, 'boinc:account-credentials-change'), |
|
1008 | + ); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) { |
1012 | - // Add a password authenticator, required to change email or pw |
|
1013 | - $form['account']['current_pass'] = array( |
|
1012 | + // Add a password authenticator, required to change email or pw |
|
1013 | + $form['account']['current_pass'] = array( |
|
1014 | 1014 | '#type' => 'password', |
1015 | 1015 | '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'), |
1016 | 1016 | '#description' => bts('Enter your current password if changing your email |
1017 | 1017 | address or password.', array(), NULL, 'boinc:account-credentials-change'), |
1018 | 1018 | '#size' => 17, |
1019 | 1019 | '#attributes' => array( |
1020 | - 'autocomplete' => 'off', |
|
1020 | + 'autocomplete' => 'off', |
|
1021 | 1021 | ), |
1022 | - ); |
|
1022 | + ); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | // Add account keys, CPID, etc |
1026 | 1026 | $form['account']['boincuser_id'] = array( |
1027 | - '#value' => ' |
|
1027 | + '#value' => ' |
|
1028 | 1028 | <div class="form-item"> |
1029 | 1029 | <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1030 | 1030 | <span>' . $account->boincuser_id . '</span> |
1031 | 1031 | </div>', |
1032 | 1032 | ); |
1033 | 1033 | $form['account']['user_id'] = array( |
1034 | - '#value' => ' |
|
1034 | + '#value' => ' |
|
1035 | 1035 | <div class="form-item"> |
1036 | 1036 | <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1037 | 1037 | <span>' . $account->uid . '</span> |
1038 | 1038 | </div>', |
1039 | 1039 | ); |
1040 | 1040 | $form['account']['account_key'] = array( |
1041 | - '#value' => ' |
|
1041 | + '#value' => ' |
|
1042 | 1042 | <div class="form-item"> |
1043 | 1043 | <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1044 | 1044 | <span>' . $account->boincuser_account_key . '</span> |
1045 | 1045 | </div>', |
1046 | 1046 | ); |
1047 | 1047 | $form['account']['weak_account_key'] = array( |
1048 | - '#value' => ' |
|
1048 | + '#value' => ' |
|
1049 | 1049 | <div class="form-item"> |
1050 | 1050 | <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1051 | 1051 | <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span> |
1052 | 1052 | </div>', |
1053 | 1053 | ); |
1054 | 1054 | $form['account']['cpid'] = array( |
1055 | - '#value' => ' |
|
1055 | + '#value' => ' |
|
1056 | 1056 | <div class="form-item"> |
1057 | 1057 | <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1058 | 1058 | <span>' . $account->boincuser_cpid . '</span> |
@@ -1060,30 +1060,30 @@ discard block |
||
1060 | 1060 | ); |
1061 | 1061 | |
1062 | 1062 | $form['account']['separator_bottom'] = array( |
1063 | - '#value' => '<div class="separator buttons"></div>' |
|
1063 | + '#value' => '<div class="separator buttons"></div>' |
|
1064 | 1064 | ); |
1065 | 1065 | |
1066 | 1066 | // Wrap action buttons for styling consistency |
1067 | 1067 | $form['form control tabs prefix'] = array( |
1068 | - '#value' => '<ul class="form-control tab-list">', |
|
1069 | - '#weight' => 1001, |
|
1068 | + '#value' => '<ul class="form-control tab-list">', |
|
1069 | + '#weight' => 1001, |
|
1070 | 1070 | ); |
1071 | 1071 | $form['submit']['#prefix'] = '<li class="first tab">'; |
1072 | 1072 | $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
1073 | 1073 | $form['submit']['#suffix'] = '</li>'; |
1074 | 1074 | $form['submit']['#weight'] = 1002; |
1075 | 1075 | $form['cancel'] = array( |
1076 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1077 | - '#weight' => 1003, |
|
1076 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1077 | + '#weight' => 1003, |
|
1078 | 1078 | ); |
1079 | 1079 | if (isset($form['delete']) AND is_array($form['delete'])) { |
1080 | - $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
1081 | - $form['delete']['#suffix'] = '</li>'; |
|
1082 | - $form['delete']['#weight'] = 1004; |
|
1080 | + $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
1081 | + $form['delete']['#suffix'] = '</li>'; |
|
1082 | + $form['delete']['#weight'] = 1004; |
|
1083 | 1083 | } |
1084 | 1084 | $form['form control tabs suffix'] = array( |
1085 | - '#value' => '</ul>', |
|
1086 | - '#weight' => 1010, |
|
1085 | + '#value' => '</ul>', |
|
1086 | + '#weight' => 1010, |
|
1087 | 1087 | ); |
1088 | 1088 | |
1089 | 1089 | // Rearrange form elements |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | // Remove redundant / unnecessary form elements |
1104 | 1104 | unset($form['theme_select']); |
1105 | 1105 | if (!module_exists('boincuser_delete')) { |
1106 | - unset($form['delete']); |
|
1106 | + unset($form['delete']); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | // These are on the Community preferences form (boincwork module) |
@@ -1119,18 +1119,18 @@ discard block |
||
1119 | 1119 | |
1120 | 1120 | // Internal fields to indicate where these user changes are taking place |
1121 | 1121 | array_unshift($form, array( |
1122 | - 'validation_source' => array( |
|
1122 | + 'validation_source' => array( |
|
1123 | 1123 | '#type' => 'hidden', |
1124 | 1124 | '#value' => 'user_account' |
1125 | - ), |
|
1126 | - 'update_source' => array( |
|
1125 | + ), |
|
1126 | + 'update_source' => array( |
|
1127 | 1127 | '#type' => 'hidden', |
1128 | 1128 | '#value' => 'user_account' |
1129 | - ) |
|
1129 | + ) |
|
1130 | 1130 | )); |
1131 | 1131 | break; |
1132 | 1132 | |
1133 | - case 'profile_node_form': |
|
1133 | + case 'profile_node_form': |
|
1134 | 1134 | |
1135 | 1135 | // Use the display name as the title, not the username |
1136 | 1136 | $account = user_load($form['uid']['#value']); |
@@ -1141,22 +1141,22 @@ discard block |
||
1141 | 1141 | $form['title']['#access'] = FALSE; |
1142 | 1142 | |
1143 | 1143 | $form['separator_bottom'] = array( |
1144 | - '#value' => '<div class="separator buttons"></div>', |
|
1145 | - '#weight' => 999, |
|
1144 | + '#value' => '<div class="separator buttons"></div>', |
|
1145 | + '#weight' => 999, |
|
1146 | 1146 | ); |
1147 | 1147 | |
1148 | 1148 | if (module_exists('captcha')) { |
1149 | - // Add an optional captcha |
|
1150 | - $form['profile_captcha'] = array( |
|
1149 | + // Add an optional captcha |
|
1150 | + $form['profile_captcha'] = array( |
|
1151 | 1151 | '#type' => 'captcha', |
1152 | 1152 | '#weight' => 1000, |
1153 | - ); |
|
1153 | + ); |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | // Wrap action buttons for styling consistency |
1157 | 1157 | $form['buttons']['form control tabs prefix'] = array( |
1158 | - '#value' => '<ul class="form-control tab-list">', |
|
1159 | - '#weight' => 1001, |
|
1158 | + '#value' => '<ul class="form-control tab-list">', |
|
1159 | + '#weight' => 1001, |
|
1160 | 1160 | ); |
1161 | 1161 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
1162 | 1162 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -1169,8 +1169,8 @@ discard block |
||
1169 | 1169 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
1170 | 1170 | $form['buttons']['preview_changes']['#weight'] = 1004; |
1171 | 1171 | $form['buttons']['cancel'] = array( |
1172 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1173 | - '#weight' => 1005, |
|
1172 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1173 | + '#weight' => 1005, |
|
1174 | 1174 | ); |
1175 | 1175 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
1176 | 1176 | $form['buttons']['delete']['#suffix'] = '</li>'; |
@@ -1178,8 +1178,8 @@ discard block |
||
1178 | 1178 | $form['buttons']['delete']['#weight'] = 1006; |
1179 | 1179 | $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit'); |
1180 | 1180 | $form['buttons']['form control tabs suffix'] = array( |
1181 | - '#value' => '</ul>', |
|
1182 | - '#weight' => 1010, |
|
1181 | + '#value' => '</ul>', |
|
1182 | + '#weight' => 1010, |
|
1183 | 1183 | ); |
1184 | 1184 | |
1185 | 1185 | $form['#after_build'][] = 'boincuser_profile_node_form_after_build'; |
@@ -1192,33 +1192,33 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | // Internal fields to indicate where these user changes are taking place |
1194 | 1194 | array_unshift($form, array( |
1195 | - 'validation_source' => array( |
|
1195 | + 'validation_source' => array( |
|
1196 | 1196 | '#type' => 'hidden', |
1197 | 1197 | '#value' => 'user_profile' |
1198 | - ), |
|
1199 | - 'update_source' => array( |
|
1198 | + ), |
|
1199 | + 'update_source' => array( |
|
1200 | 1200 | '#type' => 'hidden', |
1201 | 1201 | '#value' => 'user_profile' |
1202 | - ) |
|
1202 | + ) |
|
1203 | 1203 | )); |
1204 | 1204 | break; |
1205 | 1205 | |
1206 | - // Registration form |
|
1207 | - case 'user_register': |
|
1206 | + // Registration form |
|
1207 | + case 'user_register': |
|
1208 | 1208 | array_unshift($form, array( |
1209 | - 'boincuser_name' => array( |
|
1209 | + 'boincuser_name' => array( |
|
1210 | 1210 | '#type' => 'textfield', |
1211 | 1211 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
1212 | 1212 | '#default_value' => $edit['boincuser_name'], |
1213 | 1213 | '#maxlength' => USERNAME_MAX_LENGTH, |
1214 | 1214 | '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), |
1215 | 1215 | '#required' => TRUE |
1216 | - ), |
|
1216 | + ), |
|
1217 | 1217 | )); |
1218 | 1218 | // Set name temporarily to dummy value to beat validation |
1219 | 1219 | $form['name'] = array( |
1220 | - '#type' => 'hidden', |
|
1221 | - '#value' => rand() . '.' . time() |
|
1220 | + '#type' => 'hidden', |
|
1221 | + '#value' => rand() . '.' . time() |
|
1222 | 1222 | ); |
1223 | 1223 | |
1224 | 1224 | // Add JS for submit button disabling |
@@ -1228,50 +1228,50 @@ discard block |
||
1228 | 1228 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
1229 | 1229 | if (!empty($termsofuse)) { |
1230 | 1230 | |
1231 | - $form['termsofuse'] = array( |
|
1231 | + $form['termsofuse'] = array( |
|
1232 | 1232 | '#type' => 'fieldset', |
1233 | 1233 | '#prefix' => '<div id="termsofuse-wrapper">', // This is our wrapper div. |
1234 | 1234 | '#suffix' => '</div>', |
1235 | 1235 | '#tree' => TRUE, |
1236 | 1236 | '#weight' => -15, |
1237 | - ); |
|
1237 | + ); |
|
1238 | 1238 | |
1239 | - $form['termsofuse']['title1'] = array( |
|
1239 | + $form['termsofuse']['title1'] = array( |
|
1240 | 1240 | '#weight' => -12, |
1241 | 1241 | '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>', |
1242 | 1242 | '#prefix' => '<div id="register-title1">', |
1243 | 1243 | '#suffix' => '</div>', |
1244 | - ); |
|
1244 | + ); |
|
1245 | 1245 | |
1246 | - $form['termsofuse']['body'] = array( |
|
1246 | + $form['termsofuse']['body'] = array( |
|
1247 | 1247 | '#weight' => -10, |
1248 | 1248 | '#value' => bts($termsofuse, array(), NULL, 'project:user-register'), |
1249 | 1249 | '#prefix' => '<div id="register-termsofuse">', |
1250 | 1250 | '#suffix' => '</div>', |
1251 | - ); |
|
1251 | + ); |
|
1252 | 1252 | |
1253 | - $form['termsofuse']['agreeTOU'] = array( |
|
1253 | + $form['termsofuse']['agreeTOU'] = array( |
|
1254 | 1254 | '#type' => 'checkbox', |
1255 | 1255 | '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'), |
1256 | 1256 | '#weight' => -8, |
1257 | 1257 | '#prefix' => '<div id="register-checkbox">', |
1258 | 1258 | '#suffix' => '</div>', |
1259 | - ); |
|
1259 | + ); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | $form['title2'] = array( |
1263 | - '#weight' => -6, |
|
1264 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1265 | - '#prefix' => '<div id="register-title2">', |
|
1266 | - '#suffix' => '</div>', |
|
1263 | + '#weight' => -6, |
|
1264 | + '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1265 | + '#prefix' => '<div id="register-title2">', |
|
1266 | + '#suffix' => '</div>', |
|
1267 | 1267 | ); |
1268 | 1268 | |
1269 | 1269 | if (module_exists('captcha')) { |
1270 | - // Add an optional captcha |
|
1271 | - $form['register_captcha'] = array( |
|
1270 | + // Add an optional captcha |
|
1271 | + $form['register_captcha'] = array( |
|
1272 | 1272 | '#type' => 'captcha', |
1273 | 1273 | '#weight' => 1000, |
1274 | - ); |
|
1274 | + ); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | $form['#validate'][] = 'boincuser_register_validate'; |
@@ -1279,45 +1279,45 @@ discard block |
||
1279 | 1279 | $form['submit']['#weight'] = 1001; |
1280 | 1280 | break; |
1281 | 1281 | |
1282 | - // Request new password form |
|
1283 | - case 'user_pass': |
|
1282 | + // Request new password form |
|
1283 | + case 'user_pass': |
|
1284 | 1284 | drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password')); |
1285 | 1285 | // Replace name/email text box with email only; retain "name" label |
1286 | 1286 | // for compatibility with standard Drupal submit function |
1287 | 1287 | unset($form['name']); |
1288 | 1288 | array_unshift($form, array( |
1289 | - 'name' => array( |
|
1289 | + 'name' => array( |
|
1290 | 1290 | '#type' => 'textfield', |
1291 | 1291 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
1292 | 1292 | '#size' => 60, |
1293 | 1293 | '#maxlength' => EMAIL_MAX_LENGTH, |
1294 | 1294 | '#required' => TRUE, |
1295 | 1295 | '#description' => bts( |
1296 | - 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
1297 | - array( |
|
1296 | + 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
1297 | + array( |
|
1298 | 1298 | '!authenticator_login' => l( |
1299 | - bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1300 | - 'user/login/auth' |
|
1299 | + bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1300 | + 'user/login/auth' |
|
1301 | + ) |
|
1301 | 1302 | ) |
1302 | - ) |
|
1303 | 1303 | , NULL, 'boinc:forgot-password'), |
1304 | - ), |
|
1304 | + ), |
|
1305 | 1305 | )); |
1306 | 1306 | |
1307 | 1307 | if (module_exists('captcha')) { |
1308 | - // Add an optional captcha |
|
1309 | - $form['register_captcha'] = array( |
|
1308 | + // Add an optional captcha |
|
1309 | + $form['register_captcha'] = array( |
|
1310 | 1310 | '#type' => 'captcha', |
1311 | 1311 | '#weight' => 0, |
1312 | 1312 | '#prefix' => '<div id="captcha-password-reset">', |
1313 | 1313 | '#suffix' => '</div>' |
1314 | - ); |
|
1314 | + ); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | // Wrap action buttons for styling consistency |
1318 | 1318 | $form['buttons']['form control tabs prefix'] = array( |
1319 | - '#value' => '<ul class="form-control tab-list">', |
|
1320 | - '#weight' => 1001, |
|
1319 | + '#value' => '<ul class="form-control tab-list">', |
|
1320 | + '#weight' => 1001, |
|
1321 | 1321 | ); |
1322 | 1322 | $form['buttons']['submit'] = $form['submit']; |
1323 | 1323 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -1325,26 +1325,26 @@ discard block |
||
1325 | 1325 | $form['buttons']['submit']['#suffix'] = '</li>'; |
1326 | 1326 | $form['buttons']['submit']['#weight'] = 1002; |
1327 | 1327 | $form['buttons']['cancel'] = array( |
1328 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1329 | - '#weight' => 1005, |
|
1328 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1329 | + '#weight' => 1005, |
|
1330 | 1330 | ); |
1331 | 1331 | $form['buttons']['form control tabs suffix'] = array( |
1332 | - '#value' => '</ul>', |
|
1333 | - '#weight' => 1010, |
|
1332 | + '#value' => '</ul>', |
|
1333 | + '#weight' => 1010, |
|
1334 | 1334 | ); |
1335 | 1335 | unset($form['submit']); |
1336 | 1336 | |
1337 | 1337 | // If the form is being submitted, use BOINC validation handler. |
1338 | 1338 | if (isset($form_state['post']['name'])) { |
1339 | - // Prepend the BOINC validation function to local validation |
|
1340 | - array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
1339 | + // Prepend the BOINC validation function to local validation |
|
1340 | + array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
1341 | 1341 | } |
1342 | 1342 | break; |
1343 | 1343 | |
1344 | - case 'views_exposed_form': |
|
1344 | + case 'views_exposed_form': |
|
1345 | 1345 | $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user'); |
1346 | 1346 | break; |
1347 | - } |
|
1347 | + } |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | /** |
@@ -1352,10 +1352,10 @@ discard block |
||
1352 | 1352 | * built; this is called from boincuser_form_alter() |
1353 | 1353 | */ |
1354 | 1354 | function boincuser_profile_node_form_after_build($form, &$form_state) { |
1355 | - // Move to community prefs form |
|
1356 | - $form_state['storage']['avatar'] = $form['field_image']; |
|
1357 | - unset($form['field_image']); |
|
1358 | - return $form; |
|
1355 | + // Move to community prefs form |
|
1356 | + $form_state['storage']['avatar'] = $form['field_image']; |
|
1357 | + unset($form['field_image']); |
|
1358 | + return $form; |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
@@ -1363,8 +1363,8 @@ discard block |
||
1363 | 1363 | * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6 |
1364 | 1364 | */ |
1365 | 1365 | function boincuser_elements() { |
1366 | - $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
1367 | - return $type; |
|
1366 | + $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
1367 | + return $type; |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | /** |
@@ -1372,11 +1372,11 @@ discard block |
||
1372 | 1372 | * profile form |
1373 | 1373 | */ |
1374 | 1374 | function boincuser_process_password_confirm($element) { |
1375 | - // Check if parent element is "account". |
|
1376 | - if ($element['#array_parents'][0] == 'account') { |
|
1375 | + // Check if parent element is "account". |
|
1376 | + if ($element['#array_parents'][0] == 'account') { |
|
1377 | 1377 | $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password'); |
1378 | - } |
|
1379 | - return $element; |
|
1378 | + } |
|
1379 | + return $element; |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | /** |
@@ -1384,42 +1384,42 @@ discard block |
||
1384 | 1384 | * Register theme functions for use in this module. |
1385 | 1385 | */ |
1386 | 1386 | function boincuser_theme($existing, $type, $theme, $path) { |
1387 | - return array( |
|
1387 | + return array( |
|
1388 | 1388 | 'boincuser_user_pass' => array( |
1389 | - 'arguments' => array() |
|
1389 | + 'arguments' => array() |
|
1390 | 1390 | ) |
1391 | - ); |
|
1391 | + ); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | /** |
1395 | 1395 | * Implementation of hook_token_values |
1396 | 1396 | */ |
1397 | 1397 | function boincuser_token_values($type, $object = NULL, $options = array()) { |
1398 | - if ($type == 'user') { |
|
1398 | + if ($type == 'user') { |
|
1399 | 1399 | $account = user_load($object->uid); |
1400 | 1400 | $tokens['display-name'] = $account->boincuser_name; |
1401 | 1401 | return $tokens; |
1402 | - } |
|
1402 | + } |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | /** |
1406 | 1406 | * Implementation of hook_token_list |
1407 | 1407 | */ |
1408 | 1408 | function boincuser_token_list($type = 'all') { |
1409 | - if ($type == 'user' || $type == 'all') { |
|
1409 | + if ($type == 'user' || $type == 'all') { |
|
1410 | 1410 | $tokens['user']['display-name'] = t("The user's name that should be displayed"); |
1411 | 1411 | return $tokens; |
1412 | - } |
|
1412 | + } |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | /** |
1416 | 1416 | * Implementation of hook_views_pre_execute() |
1417 | 1417 | */ |
1418 | 1418 | function boincuser_views_pre_execute(&$view) { |
1419 | - if ($view->args) { |
|
1419 | + if ($view->args) { |
|
1420 | 1420 | $account_id = $view->args[0]; |
1421 | - } |
|
1422 | - if ($view->name=="user_activity") { |
|
1421 | + } |
|
1422 | + if ($view->name=="user_activity") { |
|
1423 | 1423 | // Run the following custom query for the user_activity view |
1424 | 1424 | $view->build_info['query']= " |
1425 | 1425 | SELECT node_revisions.vid AS vid, |
@@ -1451,25 +1451,25 @@ discard block |
||
1451 | 1451 | |
1452 | 1452 | // count_query determines the pager. Do this so the right item count is returned. |
1453 | 1453 | $view->build_info['count_query'] = $view->build_info['query']; |
1454 | - } |
|
1454 | + } |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | /** |
1458 | 1458 | * Implementation of hook_cron() |
1459 | 1459 | */ |
1460 | 1460 | function boincuser_cron() { |
1461 | - // Delete expired users in the BOINC database, user_delete table. |
|
1462 | - require_boinc('boinc_db'); |
|
1463 | - $num_deleted = BoincUserDeleted::delete_expired(); |
|
1464 | - if ($num_deleted>0) { |
|
1461 | + // Delete expired users in the BOINC database, user_delete table. |
|
1462 | + require_boinc('boinc_db'); |
|
1463 | + $num_deleted = BoincUserDeleted::delete_expired(); |
|
1464 | + if ($num_deleted>0) { |
|
1465 | 1465 | watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
1466 | - } |
|
1466 | + } |
|
1467 | 1467 | |
1468 | - // Delete expired tokens from token table |
|
1469 | - $tokens_deleted = BoincToken::delete_expired(); |
|
1470 | - if ($tokens_deleted>0) { |
|
1468 | + // Delete expired tokens from token table |
|
1469 | + $tokens_deleted = BoincToken::delete_expired(); |
|
1470 | + if ($tokens_deleted>0) { |
|
1471 | 1471 | watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
1472 | - } |
|
1472 | + } |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1480,17 +1480,17 @@ discard block |
||
1480 | 1480 | * Page callback shortcut to recent posts for the logged in user |
1481 | 1481 | */ |
1482 | 1482 | function boincuser_goto_recent_posts() { |
1483 | - global $user; |
|
1484 | - drupal_goto("account/{$user->uid}/posts"); |
|
1483 | + global $user; |
|
1484 | + drupal_goto("account/{$user->uid}/posts"); |
|
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | /** |
1488 | 1488 | * Page callback shortcut to the team of the logged in user |
1489 | 1489 | */ |
1490 | 1490 | function boincuser_goto_team() { |
1491 | - global $user; |
|
1492 | - $account = user_load($user->uid); |
|
1493 | - drupal_goto("community/teams/{$account->team}"); |
|
1491 | + global $user; |
|
1492 | + $account = user_load($user->uid); |
|
1493 | + drupal_goto("community/teams/{$account->team}"); |
|
1494 | 1494 | } |
1495 | 1495 | |
1496 | 1496 | /** |
@@ -1499,93 +1499,93 @@ discard block |
||
1499 | 1499 | * user profile pages, so use a wrapper for display |
1500 | 1500 | */ |
1501 | 1501 | function boincuser_view_profile($account = null) { |
1502 | - // Create the user profile page |
|
1503 | - if (!$account) { |
|
1502 | + // Create the user profile page |
|
1503 | + if (!$account) { |
|
1504 | 1504 | global $user; |
1505 | 1505 | $account = $user; |
1506 | - } |
|
1506 | + } |
|
1507 | 1507 | |
1508 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
1509 | - $verified_contributor = array_search('verified contributor', user_roles(true)); |
|
1510 | - if (!isset($account->roles[$verified_contributor])) { |
|
1508 | + $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
1509 | + $verified_contributor = array_search('verified contributor', user_roles(true)); |
|
1510 | + if (!isset($account->roles[$verified_contributor])) { |
|
1511 | 1511 | drupal_set_message(bts( |
1512 | 1512 | 'You may only create or modify your user profile after earning @count credits.', |
1513 | 1513 | array('@count' => $min_credit_to_post), NULL, 'boinc:view-profile' |
1514 | 1514 | ), 'warning', FALSE); |
1515 | - } |
|
1515 | + } |
|
1516 | 1516 | |
1517 | - // For now, just call the user module profile view function |
|
1518 | - user_build_content($account); |
|
1519 | - return theme('user_profile', $account); |
|
1517 | + // For now, just call the user module profile view function |
|
1518 | + user_build_content($account); |
|
1519 | + return theme('user_profile', $account); |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | /** |
1523 | 1523 | * Page callback for editing a user profile |
1524 | 1524 | */ |
1525 | 1525 | function boincuser_edit_profile($account = null) { |
1526 | - // Create the user profile form |
|
1527 | - if (!$account) { |
|
1526 | + // Create the user profile form |
|
1527 | + if (!$account) { |
|
1528 | 1528 | global $user; |
1529 | 1529 | $account = $user; |
1530 | - } |
|
1531 | - // Render the form |
|
1532 | - module_load_include('pages.inc', 'node', 'node'); |
|
1533 | - return content_profile_page_edit('profile', $account); |
|
1530 | + } |
|
1531 | + // Render the form |
|
1532 | + module_load_include('pages.inc', 'node', 'node'); |
|
1533 | + return content_profile_page_edit('profile', $account); |
|
1534 | 1534 | } |
1535 | 1535 | |
1536 | 1536 | /** |
1537 | - * Join page menu callback. |
|
1538 | - * Display instructions on joining for new or existing BOINC users |
|
1539 | - */ |
|
1537 | + * Join page menu callback. |
|
1538 | + * Display instructions on joining for new or existing BOINC users |
|
1539 | + */ |
|
1540 | 1540 | function join_page($type = null) { |
1541 | - global $base_url; |
|
1542 | - /* The paths/links to the rules-and-policies page is hardcoded |
|
1541 | + global $base_url; |
|
1542 | + /* The paths/links to the rules-and-policies page is hardcoded |
|
1543 | 1543 | * here. An improvement would be admin settings for the Join Page |
1544 | 1544 | * where this path could be set. |
1545 | 1545 | */ |
1546 | - $ruleslinkA = 'rules-and-policies'; |
|
1547 | - $ruleslinkB = 'content/rules-and-policies'; |
|
1548 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1549 | - $registration_enabled = variable_get('user_register', 0); |
|
1550 | - $output = '<div class="join">'; |
|
1551 | - switch ($type) { |
|
1552 | - case 'boinc': |
|
1546 | + $ruleslinkA = 'rules-and-policies'; |
|
1547 | + $ruleslinkB = 'content/rules-and-policies'; |
|
1548 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1549 | + $registration_enabled = variable_get('user_register', 0); |
|
1550 | + $output = '<div class="join">'; |
|
1551 | + switch ($type) { |
|
1552 | + case 'boinc': |
|
1553 | 1553 | $output .= '<ol>'; |
1554 | 1554 | if ($registration_enabled) { |
1555 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1556 | - array( |
|
1555 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1556 | + array( |
|
1557 | 1557 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1558 | 1558 | '@sitename' => $site_name, |
1559 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1559 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1560 | 1560 | } |
1561 | 1561 | $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>'; |
1562 | 1562 | $output .= ' <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
1563 | 1563 | array( |
1564 | - '@sitename' => $site_name, |
|
1565 | - '@siteurl' => $base_url, |
|
1564 | + '@sitename' => $site_name, |
|
1565 | + '@siteurl' => $base_url, |
|
1566 | 1566 | ), NULL, 'boinc:join-page') . '</li>'; |
1567 | 1567 | if ($registration_enabled) { |
1568 | - $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1568 | + $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1569 | 1569 | array( |
1570 | - '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1570 | + '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1571 | 1571 | ), NULL, 'boinc:join-page') . '</li>'; |
1572 | 1572 | } |
1573 | 1573 | else { |
1574 | - $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1574 | + $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1575 | 1575 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
1576 | 1576 | array( |
1577 | - '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1577 | + '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1578 | 1578 | ), NULL, 'boinc:join-page') . '</li>'; |
1579 | 1579 | } |
1580 | 1580 | $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please |
1581 | 1581 | upgrade to a more recent version of BOINC to create an account |
1582 | 1582 | at @this_project.", |
1583 | - array( |
|
1583 | + array( |
|
1584 | 1584 | '@this_project' => $site_name, |
1585 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1585 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1586 | 1586 | $output .= '</ol>'; |
1587 | 1587 | break; |
1588 | - case 'new': |
|
1588 | + case 'new': |
|
1589 | 1589 | default: |
1590 | 1590 | // Determine if there is a link to rules-and-policies |
1591 | 1591 | //$ruleslink=''; |
@@ -1600,16 +1600,16 @@ discard block |
||
1600 | 1600 | // Join page output |
1601 | 1601 | $output .= '<ol>'; |
1602 | 1602 | if ($registration_enabled) { |
1603 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1604 | - array( |
|
1603 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1604 | + array( |
|
1605 | 1605 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1606 | 1606 | '@sitename' => $site_name, |
1607 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1607 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1608 | 1608 | } |
1609 | 1609 | else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
1610 | - $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1610 | + $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1611 | 1611 | '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
1612 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1612 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1613 | 1613 | } |
1614 | 1614 | $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
1615 | 1615 | $output .= ' <p>'; |
@@ -1619,73 +1619,73 @@ discard block |
||
1619 | 1619 | $output .= ' </li>'; |
1620 | 1620 | $output .= ' <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>'; |
1621 | 1621 | $output .= ' <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array( |
1622 | - '@sitename' => $site_name, |
|
1623 | - '@siteurl' => $base_url, |
|
1622 | + '@sitename' => $site_name, |
|
1623 | + '@siteurl' => $base_url, |
|
1624 | 1624 | ), NULL, 'boinc:join-page') . '</li>'; |
1625 | 1625 | $output .= '</ol>'; |
1626 | - } |
|
1627 | - $output .= '</div>'; |
|
1628 | - return $output; |
|
1626 | + } |
|
1627 | + $output .= '</div>'; |
|
1628 | + return $output; |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | /** |
1632 | - * Home page content for embedding in Panels page |
|
1633 | - */ |
|
1632 | + * Home page content for embedding in Panels page |
|
1633 | + */ |
|
1634 | 1634 | function boincuser_home_page() { |
1635 | - global $user; |
|
1636 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1637 | - // get the front page message from database; this is set in the admin interface under BOINC Other |
|
1638 | - $site_message = variable_get('boinc_other_frontpage',''); |
|
1635 | + global $user; |
|
1636 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1637 | + // get the front page message from database; this is set in the admin interface under BOINC Other |
|
1638 | + $site_message = variable_get('boinc_other_frontpage',''); |
|
1639 | 1639 | |
1640 | - // Determine the user of the day |
|
1641 | - $current_uotd = db_fetch_object(db_query(" |
|
1640 | + // Determine the user of the day |
|
1641 | + $current_uotd = db_fetch_object(db_query(" |
|
1642 | 1642 | SELECT |
1643 | 1643 | uid, |
1644 | 1644 | uotd_time |
1645 | 1645 | FROM {boincuser} |
1646 | 1646 | ORDER BY uotd_time DESC |
1647 | 1647 | LIMIT 1" |
1648 | - )); |
|
1649 | - if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
1648 | + )); |
|
1649 | + if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
1650 | 1650 | $uotd = boincuser_select_user_of_the_day(); |
1651 | - } |
|
1652 | - else { |
|
1651 | + } |
|
1652 | + else { |
|
1653 | 1653 | $uotd = user_load($current_uotd->uid); |
1654 | - } |
|
1655 | - $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1656 | - $output = '<h2 class="pane-title">'; |
|
1657 | - $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1658 | - $output .= '</h2>'; |
|
1659 | - $output .= '<div class="boinc-overview balance-height-front">'; |
|
1660 | - $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1661 | - if ($user->uid) { |
|
1654 | + } |
|
1655 | + $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1656 | + $output = '<h2 class="pane-title">'; |
|
1657 | + $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1658 | + $output .= '</h2>'; |
|
1659 | + $output .= '<div class="boinc-overview balance-height-front">'; |
|
1660 | + $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1661 | + if ($user->uid) { |
|
1662 | 1662 | $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1663 | - } |
|
1664 | - else { |
|
1663 | + } |
|
1664 | + else { |
|
1665 | 1665 | $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1666 | - } |
|
1667 | - $output .= '</div>'; |
|
1668 | - $output .= '<div class="boinc-overview-details">'; |
|
1669 | - $output .= ' <div class="detail-container">'; |
|
1670 | - $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1671 | - $output .= ' <div class="picture">'; |
|
1672 | - $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
1666 | + } |
|
1667 | + $output .= '</div>'; |
|
1668 | + $output .= '<div class="boinc-overview-details">'; |
|
1669 | + $output .= ' <div class="detail-container">'; |
|
1670 | + $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1671 | + $output .= ' <div class="picture">'; |
|
1672 | + $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
1673 | 1673 | $uotd_image['alt'], array(), FALSE); |
1674 | - $output .= ' </div>'; |
|
1675 | - $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1676 | - $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1677 | - $output .= ' </a>'; |
|
1678 | - $output .= ' <div class="volunteers">'; |
|
1679 | - $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1680 | - $output .= ' <div class="platforms">'; |
|
1681 | - $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1682 | - $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1683 | - $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1684 | - $output .= ' </div>'; |
|
1685 | - $output .= ' </div>'; |
|
1686 | - $output .= ' </div>'; |
|
1687 | - $output .= '</div>'; |
|
1688 | - return $output; |
|
1674 | + $output .= ' </div>'; |
|
1675 | + $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1676 | + $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1677 | + $output .= ' </a>'; |
|
1678 | + $output .= ' <div class="volunteers">'; |
|
1679 | + $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1680 | + $output .= ' <div class="platforms">'; |
|
1681 | + $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1682 | + $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1683 | + $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1684 | + $output .= ' </div>'; |
|
1685 | + $output .= ' </div>'; |
|
1686 | + $output .= ' </div>'; |
|
1687 | + $output .= '</div>'; |
|
1688 | + return $output; |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | /** |
@@ -1693,81 +1693,81 @@ discard block |
||
1693 | 1693 | * Create a new user account based on supplied parameters. |
1694 | 1694 | */ |
1695 | 1695 | function boincuser_create_account() { |
1696 | - global $base_url; |
|
1696 | + global $base_url; |
|
1697 | 1697 | |
1698 | - require_boinc('boinc_db'); |
|
1699 | - require_boinc('user_util'); |
|
1700 | - require_boinc('xml'); |
|
1701 | - $params = array( |
|
1698 | + require_boinc('boinc_db'); |
|
1699 | + require_boinc('user_util'); |
|
1700 | + require_boinc('xml'); |
|
1701 | + $params = array( |
|
1702 | 1702 | 'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '', |
1703 | 1703 | 'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '', |
1704 | 1704 | 'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : '' |
1705 | - ); |
|
1705 | + ); |
|
1706 | 1706 | |
1707 | - // Begin output |
|
1708 | - xml_header(); |
|
1707 | + // Begin output |
|
1708 | + xml_header(); |
|
1709 | 1709 | |
1710 | - // Account creation disabled |
|
1711 | - $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1712 | - if (!$enablethisRPC) { |
|
1710 | + // Account creation disabled |
|
1711 | + $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1712 | + if (!$enablethisRPC) { |
|
1713 | 1713 | $mess = bts('Account creation is done through our Web site. Please register at @url', array( |
1714 | - '@url' => $base_url . '/user/registration', |
|
1714 | + '@url' => $base_url . '/user/registration', |
|
1715 | 1715 | ), |
1716 | 1716 | NULL, 'boinc:create_account'); |
1717 | 1717 | xml_error(-208, $mess); |
1718 | - } |
|
1719 | - // Invalid invite code |
|
1718 | + } |
|
1719 | + // Invalid invite code |
|
1720 | 1720 | |
1721 | - // Validate input |
|
1722 | - if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
1721 | + // Validate input |
|
1722 | + if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
1723 | 1723 | xml_error(-205); |
1724 | - } |
|
1724 | + } |
|
1725 | 1725 | |
1726 | - // Make sure user_name is unique and cleaned |
|
1727 | - $unique_name = create_proper_drupalname($params['user_name']); |
|
1728 | - if ($error = user_validate_name($unique_name)) { |
|
1726 | + // Make sure user_name is unique and cleaned |
|
1727 | + $unique_name = create_proper_drupalname($params['user_name']); |
|
1728 | + if ($error = user_validate_name($unique_name)) { |
|
1729 | 1729 | xml_error(-188, $error); |
1730 | - } |
|
1731 | - if (strlen($params['passwd_hash']) != 32) { |
|
1730 | + } |
|
1731 | + if (strlen($params['passwd_hash']) != 32) { |
|
1732 | 1732 | xml_error(-1, 'password hash length not 32'); |
1733 | - } |
|
1733 | + } |
|
1734 | 1734 | |
1735 | - // Process input |
|
1736 | - // Check this email against previous email addresses. |
|
1737 | - $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
1738 | - if ($tmpuser) { |
|
1735 | + // Process input |
|
1736 | + // Check this email against previous email addresses. |
|
1737 | + $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
1738 | + if ($tmpuser) { |
|
1739 | 1739 | xml_error(-137); |
1740 | - } |
|
1740 | + } |
|
1741 | 1741 | |
1742 | - // Check this email on current email addresses. |
|
1743 | - $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
1744 | - if ($boinc_user) { |
|
1742 | + // Check this email on current email addresses. |
|
1743 | + $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
1744 | + if ($boinc_user) { |
|
1745 | 1745 | // Return authenticator for existing users |
1746 | 1746 | if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or |
1747 | 1747 | password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) { |
1748 | - $output = array('authenticator' => $boinc_user->authenticator); |
|
1748 | + $output = array('authenticator' => $boinc_user->authenticator); |
|
1749 | 1749 | } |
1750 | 1750 | else { |
1751 | - xml_error(-137); |
|
1751 | + xml_error(-137); |
|
1752 | 1752 | } |
1753 | - } |
|
1754 | - else { |
|
1753 | + } |
|
1754 | + else { |
|
1755 | 1755 | // Verify that there isn't somehow a Drupal user already (not possible with proper function) |
1756 | 1756 | if ($existing_user = user_load(array('mail' => $params['email_addr']))) { |
1757 | - xml_error(-137, 'account error'); |
|
1757 | + xml_error(-137, 'account error'); |
|
1758 | 1758 | } |
1759 | 1759 | // Create new account |
1760 | 1760 | $unrestricted_role = array_search('community member', user_roles(true)); |
1761 | 1761 | |
1762 | 1762 | $newUser = array( |
1763 | - 'name' => $unique_name, |
|
1764 | - 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
1765 | - 'mail' => $params['email_addr'], |
|
1766 | - 'status' => 1, |
|
1767 | - 'init' => $params['email_addr'], |
|
1768 | - 'roles' => array($unrestricted_role => ''), |
|
1769 | - 'boincuser_name' => $params['user_name'], |
|
1770 | - 'boinchash_flag' => TRUE, |
|
1763 | + 'name' => $unique_name, |
|
1764 | + 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
1765 | + 'mail' => $params['email_addr'], |
|
1766 | + 'status' => 1, |
|
1767 | + 'init' => $params['email_addr'], |
|
1768 | + 'roles' => array($unrestricted_role => ''), |
|
1769 | + 'boincuser_name' => $params['user_name'], |
|
1770 | + 'boinchash_flag' => TRUE, |
|
1771 | 1771 | ); |
1772 | 1772 | |
1773 | 1773 | // Create the drupal user. If the drupal user cannot be created, |
@@ -1775,17 +1775,17 @@ discard block |
||
1775 | 1775 | // The user is created in the 'insert' op in hook_user. |
1776 | 1776 | $user = user_save(null, $newUser); |
1777 | 1777 | if (!$user) { |
1778 | - watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
1779 | - xml_error(-137, 'error creating BOINC account'); |
|
1778 | + watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
1779 | + xml_error(-137, 'error creating BOINC account'); |
|
1780 | 1780 | }// if drupal user created. |
1781 | 1781 | |
1782 | 1782 | $output = array('authenticator' => $user->boincuser_account_key); |
1783 | - }// if existing user found. |
|
1783 | + }// if existing user found. |
|
1784 | 1784 | |
1785 | - // Output authenticator |
|
1786 | - echo " <account_out>\n"; |
|
1787 | - echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
1788 | - echo "</account_out>\n"; |
|
1785 | + // Output authenticator |
|
1786 | + echo " <account_out>\n"; |
|
1787 | + echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
1788 | + echo "</account_out>\n"; |
|
1789 | 1789 | } |
1790 | 1790 | |
1791 | 1791 | /** |
@@ -1793,166 +1793,166 @@ discard block |
||
1793 | 1793 | * account is created using the BOINC clinet. |
1794 | 1794 | */ |
1795 | 1795 | function boincuser_account_finish() { |
1796 | - global $user; |
|
1796 | + global $user; |
|
1797 | 1797 | |
1798 | - $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
1798 | + $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
1799 | 1799 | |
1800 | - // Ensure there is a authentication token before continuing |
|
1801 | - if (empty($authtoken)) { |
|
1800 | + // Ensure there is a authentication token before continuing |
|
1801 | + if (empty($authtoken)) { |
|
1802 | 1802 | drupal_not_found(); |
1803 | 1803 | return ; |
1804 | - } |
|
1804 | + } |
|
1805 | 1805 | |
1806 | - if (strlen($authtoken) != 32) { |
|
1806 | + if (strlen($authtoken) != 32) { |
|
1807 | 1807 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
1808 | 1808 | drupal_goto(); |
1809 | - } |
|
1809 | + } |
|
1810 | 1810 | |
1811 | - require_boinc('boinc_db'); |
|
1812 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
1813 | - if (!$boinc_user) { |
|
1811 | + require_boinc('boinc_db'); |
|
1812 | + $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
1813 | + if (!$boinc_user) { |
|
1814 | 1814 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
1815 | 1815 | drupal_goto(); |
1816 | - } |
|
1817 | - $user = user_load(get_drupal_id($boinc_user->id)); |
|
1816 | + } |
|
1817 | + $user = user_load(get_drupal_id($boinc_user->id)); |
|
1818 | 1818 | |
1819 | - if (!$user) { |
|
1819 | + if (!$user) { |
|
1820 | 1820 | drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), NULL, 'boinc:account-finish'), 'error'); |
1821 | 1821 | drupal_goto(); |
1822 | - } |
|
1822 | + } |
|
1823 | 1823 | |
1824 | - // Lookup path to custom account finish page |
|
1825 | - $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1826 | - if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1824 | + // Lookup path to custom account finish page |
|
1825 | + $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1826 | + if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1827 | 1827 | $node = menu_get_object('node', 1, $customaccountfinishpath); |
1828 | 1828 | if ($node) { |
1829 | - return node_page_view($node); |
|
1829 | + return node_page_view($node); |
|
1830 | + } |
|
1830 | 1831 | } |
1831 | - } |
|
1832 | 1832 | |
1833 | - // open links in new window |
|
1834 | - $options = array( |
|
1833 | + // open links in new window |
|
1834 | + $options = array( |
|
1835 | 1835 | 'attributes' => array( 'target' => '_blank' ), |
1836 | - ); |
|
1836 | + ); |
|
1837 | 1837 | |
1838 | - // Check moderation page exists |
|
1839 | - $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1840 | - if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1838 | + // Check moderation page exists |
|
1839 | + $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1840 | + if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1841 | 1841 | $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish'); |
1842 | - } else { |
|
1842 | + } else { |
|
1843 | 1843 | $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish'); |
1844 | - } |
|
1844 | + } |
|
1845 | 1845 | |
1846 | - $username = $user->boincuser_name; |
|
1847 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1848 | - $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1849 | - array( |
|
1846 | + $username = $user->boincuser_name; |
|
1847 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1848 | + $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1849 | + array( |
|
1850 | 1850 | '@user_name' => $username, |
1851 | 1851 | '@site_name' => $site_name, |
1852 | - ), NULL, 'boinc:account-finish') . "</p>"; |
|
1852 | + ), NULL, 'boinc:account-finish') . "</p>"; |
|
1853 | 1853 | |
1854 | - $links = array( |
|
1854 | + $links = array( |
|
1855 | 1855 | array( |
1856 | - 'data' => bts('Change your username at !community_preferences.', array( |
|
1856 | + 'data' => bts('Change your username at !community_preferences.', array( |
|
1857 | 1857 | '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options), |
1858 | - ), NULL, 'boinc:account-finish'), |
|
1859 | - 'children' => array( |
|
1858 | + ), NULL, 'boinc:account-finish'), |
|
1859 | + 'children' => array( |
|
1860 | 1860 | bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'), |
1861 | 1861 | bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'), |
1862 | - ), |
|
1862 | + ), |
|
1863 | 1863 | ), |
1864 | 1864 | array( |
1865 | - 'data' => bts('Change your !computing_preferences.', array( |
|
1865 | + 'data' => bts('Change your !computing_preferences.', array( |
|
1866 | 1866 | '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options), |
1867 | - ), NULL, 'boinc:account-finish'), |
|
1868 | - 'children' => array( |
|
1867 | + ), NULL, 'boinc:account-finish'), |
|
1868 | + 'children' => array( |
|
1869 | 1869 | bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), NULL, 'boinc:account-finish'), |
1870 | 1870 | bts('By default, you will run @site_name tasks without any additional configuration.', array( |
1871 | - '@site_name' => $site_name, |
|
1871 | + '@site_name' => $site_name, |
|
1872 | 1872 | ), NULL, 'boinc:account-finish'), |
1873 | 1873 | bts('It is recommended new volunteers leave the default settings until they gain experience running some tasks. Ask questions in the !forums to get advice before making changes to a setting you don\'t understand.', array( |
1874 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1874 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1875 | 1875 | ), NULL, 'boinc:account-finish'), |
1876 | - ), |
|
1876 | + ), |
|
1877 | 1877 | ), |
1878 | 1878 | array( |
1879 | 1879 | 'data' => bts('Create a !user_profile.', array( |
1880 | - '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1880 | + '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1881 | 1881 | ), NULL, 'boinc:account-finish'), |
1882 | - 'children' => array( |
|
1882 | + 'children' => array( |
|
1883 | 1883 | bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array( |
1884 | - '@site_name' => $site_name, |
|
1884 | + '@site_name' => $site_name, |
|
1885 | 1885 | ), NULL, 'boinc:account-finish'), |
1886 | 1886 | $modsentence, |
1887 | - ), |
|
1887 | + ), |
|
1888 | 1888 | ), |
1889 | 1889 | array( |
1890 | - 'data' => bts('Join a !team.', array( |
|
1890 | + 'data' => bts('Join a !team.', array( |
|
1891 | 1891 | '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options), |
1892 | - ), NULL, 'boinc:account-finish'), |
|
1893 | - 'children' => array( |
|
1892 | + ), NULL, 'boinc:account-finish'), |
|
1893 | + 'children' => array( |
|
1894 | 1894 | bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'), |
1895 | - ), |
|
1895 | + ), |
|
1896 | 1896 | ), |
1897 | 1897 | array( |
1898 | - 'data' => bts('Go to your !account_dashboard.', array( |
|
1898 | + 'data' => bts('Go to your !account_dashboard.', array( |
|
1899 | 1899 | '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options), |
1900 | - ), NULL, 'boinc:account-finish'), |
|
1901 | - 'children' => array( |
|
1900 | + ), NULL, 'boinc:account-finish'), |
|
1901 | + 'children' => array( |
|
1902 | 1902 | bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'), |
1903 | - ), |
|
1903 | + ), |
|
1904 | 1904 | ), |
1905 | 1905 | array( |
1906 | - 'data' => bts('Visit our !help pages.', array( |
|
1906 | + 'data' => bts('Visit our !help pages.', array( |
|
1907 | 1907 | '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options) |
1908 | - ), NULL, 'boinc:account-finish'), |
|
1909 | - 'children' => array( |
|
1908 | + ), NULL, 'boinc:account-finish'), |
|
1909 | + 'children' => array( |
|
1910 | 1910 | bts('Ask for help in our community\'s !forums.', array( |
1911 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1911 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1912 | 1912 | ), NULL, 'boinc:account-finish'), |
1913 | - ), |
|
1913 | + ), |
|
1914 | 1914 | ), |
1915 | - ); |
|
1915 | + ); |
|
1916 | 1916 | |
1917 | - //List of links |
|
1918 | - $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1917 | + //List of links |
|
1918 | + $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1919 | 1919 | |
1920 | - return $output; |
|
1920 | + return $output; |
|
1921 | 1921 | } |
1922 | 1922 | |
1923 | 1923 | /** |
1924 | 1924 | * Determine if the user has permission to control community access |
1925 | 1925 | */ |
1926 | 1926 | function boincuser_moderate_community_access() { |
1927 | - if (user_access('assign community member role') |
|
1927 | + if (user_access('assign community member role') |
|
1928 | 1928 | OR user_access('assign all roles')) { |
1929 | 1929 | return TRUE; |
1930 | - } |
|
1931 | - return FALSE; |
|
1930 | + } |
|
1931 | + return FALSE; |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | 1934 | /** |
1935 | 1935 | * Get the count of items in the moderation queue |
1936 | 1936 | */ |
1937 | 1937 | function boincuser_moderation_queue_count($caller = 'user') { |
1938 | - $allowed = FALSE; |
|
1939 | - switch ($caller) { |
|
1940 | - case 'cron': |
|
1938 | + $allowed = FALSE; |
|
1939 | + switch ($caller) { |
|
1940 | + case 'cron': |
|
1941 | 1941 | $allowed = TRUE; |
1942 | 1942 | break; |
1943 | - case 'user': |
|
1943 | + case 'user': |
|
1944 | 1944 | default: |
1945 | 1945 | $allowed = user_access('edit any profile content'); |
1946 | - } |
|
1947 | - if ($allowed) { |
|
1946 | + } |
|
1947 | + if ($allowed) { |
|
1948 | 1948 | return db_result(db_query(" |
1949 | 1949 | SELECT COUNT(*) |
1950 | 1950 | FROM {node} |
1951 | 1951 | WHERE type = 'profile' |
1952 | 1952 | AND moderate = 1" |
1953 | 1953 | )); |
1954 | - } |
|
1955 | - return NULL; |
|
1954 | + } |
|
1955 | + return NULL; |
|
1956 | 1956 | } |
1957 | 1957 | |
1958 | 1958 | /** |
@@ -1961,43 +1961,43 @@ discard block |
||
1961 | 1961 | * than through the user account info form. |
1962 | 1962 | */ |
1963 | 1963 | function boincuser_control($uid = NULL, $action = NULL) { |
1964 | - if (!$uid OR !$account = user_load($uid)) { |
|
1964 | + if (!$uid OR !$account = user_load($uid)) { |
|
1965 | 1965 | // What are you even doing here... |
1966 | 1966 | return FALSE; |
1967 | - } |
|
1968 | - switch ($action) { |
|
1969 | - case 'ban': |
|
1967 | + } |
|
1968 | + switch ($action) { |
|
1969 | + case 'ban': |
|
1970 | 1970 | if (boincuser_moderate_community_access()) { |
1971 | - $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
1972 | - $boincuser_record = array( |
|
1971 | + $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
1972 | + $boincuser_record = array( |
|
1973 | 1973 | 'uid' => $uid, |
1974 | 1974 | 'penalty_expiration' => time() + $penalty_period, |
1975 | - ); |
|
1976 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1977 | - $community_role = array_search('community member', user_roles(true)); |
|
1978 | - if (isset($account->roles[$community_role])) { |
|
1975 | + ); |
|
1976 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1977 | + $community_role = array_search('community member', user_roles(true)); |
|
1978 | + if (isset($account->roles[$community_role])) { |
|
1979 | 1979 | unset($account->roles[$community_role]); |
1980 | 1980 | user_save($account, array('roles' => $account->roles)); |
1981 | - } |
|
1981 | + } |
|
1982 | 1982 | } |
1983 | 1983 | break; |
1984 | - case 'lift-ban': |
|
1984 | + case 'lift-ban': |
|
1985 | 1985 | if (boincuser_moderate_community_access()) { |
1986 | - $boincuser_record = array( |
|
1986 | + $boincuser_record = array( |
|
1987 | 1987 | 'uid' => $uid, |
1988 | 1988 | 'penalty_expiration' => 0, |
1989 | - ); |
|
1990 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1991 | - $community_role = array_search('community member', user_roles(true)); |
|
1992 | - if (!isset($account->roles[$community_role])) { |
|
1989 | + ); |
|
1990 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1991 | + $community_role = array_search('community member', user_roles(true)); |
|
1992 | + if (!isset($account->roles[$community_role])) { |
|
1993 | 1993 | $account->roles[$community_role] = 'community member'; |
1994 | 1994 | user_save($account, array('roles' => $account->roles)); |
1995 | - } |
|
1995 | + } |
|
1996 | 1996 | } |
1997 | 1997 | break; |
1998 | - default: |
|
1998 | + default: |
|
1999 | 1999 | } |
2000 | - drupal_goto("account/{$account->uid}"); |
|
2000 | + drupal_goto("account/{$account->uid}"); |
|
2001 | 2001 | } |
2002 | 2002 | |
2003 | 2003 | /** |
@@ -2005,29 +2005,29 @@ discard block |
||
2005 | 2005 | * moderation flag. |
2006 | 2006 | */ |
2007 | 2007 | function boincuser_moderate_profile_approve($account) { |
2008 | - $node = new stdClass; |
|
2009 | - $node->type = 'profile'; |
|
2010 | - $node->language = ''; |
|
2011 | - $nid = content_profile_profile_exists($node, $account->uid); |
|
2012 | - $profile = node_load($nid); |
|
2013 | - $profile->moderate = 0; |
|
2014 | - $profile->status = 1; |
|
2015 | - node_save($profile); |
|
2016 | - drupal_set_message('This profile has been marked as approved.'); |
|
2017 | - drupal_goto(); |
|
2008 | + $node = new stdClass; |
|
2009 | + $node->type = 'profile'; |
|
2010 | + $node->language = ''; |
|
2011 | + $nid = content_profile_profile_exists($node, $account->uid); |
|
2012 | + $profile = node_load($nid); |
|
2013 | + $profile->moderate = 0; |
|
2014 | + $profile->status = 1; |
|
2015 | + node_save($profile); |
|
2016 | + drupal_set_message('This profile has been marked as approved.'); |
|
2017 | + drupal_goto(); |
|
2018 | 2018 | } |
2019 | 2019 | |
2020 | 2020 | /** |
2021 | 2021 | * Mark a user profile as rejected and notify the user of the reason. |
2022 | 2022 | */ |
2023 | 2023 | function boincuser_moderate_profile_reject($uid, $reason = '') { |
2024 | - $account = user_load($uid); |
|
2025 | - $node = new stdClass; |
|
2026 | - $node->type = 'profile'; |
|
2027 | - $node->language = ''; |
|
2028 | - $nid = content_profile_profile_exists($node, $uid); |
|
2029 | - $profile = node_load($nid); |
|
2030 | - if ($profile->nid) { |
|
2024 | + $account = user_load($uid); |
|
2025 | + $node = new stdClass; |
|
2026 | + $node->type = 'profile'; |
|
2027 | + $node->language = ''; |
|
2028 | + $nid = content_profile_profile_exists($node, $uid); |
|
2029 | + $profile = node_load($nid); |
|
2030 | + if ($profile->nid) { |
|
2031 | 2031 | global $user; |
2032 | 2032 | global $base_url; |
2033 | 2033 | global $base_path; |
@@ -2038,64 +2038,64 @@ discard block |
||
2038 | 2038 | $profile->status = 0; |
2039 | 2039 | node_save($profile); |
2040 | 2040 | $settings = array( |
2041 | - 'from' => '', |
|
2042 | - 'subject' => "Profile moderation at {$site_name}", |
|
2043 | - 'message' => '' |
|
2044 | - . "{$account->boincuser_name},\n" |
|
2045 | - . "\n" |
|
2046 | - . "{$moderator->boincuser_name} has rejected your profile at" |
|
2047 | - . " {$site_name} for the following reason: \n" |
|
2048 | - . "\n" |
|
2049 | - . "{$reason}\n" |
|
2050 | - . "\n" |
|
2051 | - . "\n" |
|
2052 | - . "Since it has not been approved, your profile is not visible to other" |
|
2053 | - . " {$site_name} users. Please make the needed changes here:\n" |
|
2054 | - . "\n" |
|
2055 | - . "{$site_url}account/profile \n" |
|
2056 | - . "\n" |
|
2057 | - . "Thanks, \n" |
|
2058 | - . "\n" |
|
2059 | - . "{$site_name} support team", |
|
2041 | + 'from' => '', |
|
2042 | + 'subject' => "Profile moderation at {$site_name}", |
|
2043 | + 'message' => '' |
|
2044 | + . "{$account->boincuser_name},\n" |
|
2045 | + . "\n" |
|
2046 | + . "{$moderator->boincuser_name} has rejected your profile at" |
|
2047 | + . " {$site_name} for the following reason: \n" |
|
2048 | + . "\n" |
|
2049 | + . "{$reason}\n" |
|
2050 | + . "\n" |
|
2051 | + . "\n" |
|
2052 | + . "Since it has not been approved, your profile is not visible to other" |
|
2053 | + . " {$site_name} users. Please make the needed changes here:\n" |
|
2054 | + . "\n" |
|
2055 | + . "{$site_url}account/profile \n" |
|
2056 | + . "\n" |
|
2057 | + . "Thanks, \n" |
|
2058 | + . "\n" |
|
2059 | + . "{$site_name} support team", |
|
2060 | 2060 | ); |
2061 | 2061 | rules_action_mail_to_user($account, $settings); |
2062 | 2062 | drupal_set_message('This profile has been marked as rejected.'); |
2063 | - } |
|
2064 | - drupal_goto(); |
|
2063 | + } |
|
2064 | + drupal_goto(); |
|
2065 | 2065 | } |
2066 | 2066 | |
2067 | 2067 | /** |
2068 | 2068 | * Ban a user and send a notification of the reason. |
2069 | 2069 | */ |
2070 | 2070 | function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') { |
2071 | - if (user_access('assign community member role') |
|
2071 | + if (user_access('assign community member role') |
|
2072 | 2072 | OR user_access('assign all roles')) { |
2073 | 2073 | $account = user_load($uid); |
2074 | 2074 | if ($account->uid) { |
2075 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2076 | - if ($duration === '') { |
|
2075 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2076 | + if ($duration === '') { |
|
2077 | 2077 | $duration = variable_get('boinc_penalty_period', 7*24*60*60); |
2078 | - } |
|
2079 | - $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
2080 | - $boincuser_record = array( |
|
2078 | + } |
|
2079 | + $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
2080 | + $boincuser_record = array( |
|
2081 | 2081 | 'uid' => $uid, |
2082 | 2082 | 'penalty_expiration' => $penalty_expiration, |
2083 | - ); |
|
2084 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
2083 | + ); |
|
2084 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
2085 | 2085 | |
2086 | - $community_role = array_search('community member', user_roles(true)); |
|
2087 | - if (isset($account->roles[$community_role])) { |
|
2086 | + $community_role = array_search('community member', user_roles(true)); |
|
2087 | + if (isset($account->roles[$community_role])) { |
|
2088 | 2088 | unset($account->roles[$community_role]); |
2089 | 2089 | user_save($account, array('roles' => $account->roles)); |
2090 | - } |
|
2090 | + } |
|
2091 | 2091 | |
2092 | - global $user; |
|
2093 | - global $base_url; |
|
2094 | - global $base_path; |
|
2095 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
2096 | - $site_url = $base_url . $base_path; |
|
2097 | - $moderator = user_load($user->uid); |
|
2098 | - $settings = array( |
|
2092 | + global $user; |
|
2093 | + global $base_url; |
|
2094 | + global $base_path; |
|
2095 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
2096 | + $site_url = $base_url . $base_path; |
|
2097 | + $moderator = user_load($user->uid); |
|
2098 | + $settings = array( |
|
2099 | 2099 | 'from' => '', |
2100 | 2100 | 'subject' => "User moderation at {$site_name}", |
2101 | 2101 | 'message' => '' |
@@ -2116,12 +2116,12 @@ discard block |
||
2116 | 2116 | . "Thanks, \n" |
2117 | 2117 | . "\n" |
2118 | 2118 | . "{$site_name} support team", |
2119 | - ); |
|
2120 | - rules_action_mail_to_user($account, $settings); |
|
2121 | - drupal_set_message('This user has been banned.'); |
|
2119 | + ); |
|
2120 | + rules_action_mail_to_user($account, $settings); |
|
2121 | + drupal_set_message('This user has been banned.'); |
|
2122 | 2122 | } |
2123 | - } |
|
2124 | - drupal_goto(); |
|
2123 | + } |
|
2124 | + drupal_goto(); |
|
2125 | 2125 | } |
2126 | 2126 | |
2127 | 2127 | |
@@ -2133,15 +2133,15 @@ discard block |
||
2133 | 2133 | * |
2134 | 2134 | */ |
2135 | 2135 | function boincuser_get_weak_auth($boinc_id = null) { |
2136 | - if (!$boinc_id) { |
|
2136 | + if (!$boinc_id) { |
|
2137 | 2137 | global $user; |
2138 | 2138 | $account = user_load($user->uid); |
2139 | 2139 | $boinc_id = $account->boincuser_id; |
2140 | - } |
|
2140 | + } |
|
2141 | 2141 | |
2142 | - $boinc_user = boincuser_load($account->boincuser_id); |
|
2142 | + $boinc_user = boincuser_load($account->boincuser_id); |
|
2143 | 2143 | |
2144 | - return weak_auth($boinc_user); |
|
2144 | + return weak_auth($boinc_user); |
|
2145 | 2145 | } |
2146 | 2146 | |
2147 | 2147 | /** |
@@ -2150,75 +2150,75 @@ discard block |
||
2150 | 2150 | * Drupal User so must be inserted into comments, etc. (not so by default) |
2151 | 2151 | */ |
2152 | 2152 | function boincuser_get_user_profile_image($uid, $avatar = TRUE) { |
2153 | - // Though the function name implies otherwise, get the avatar by default |
|
2154 | - $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
2155 | - $image_fid = db_result(db_query(" |
|
2153 | + // Though the function name implies otherwise, get the avatar by default |
|
2154 | + $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
2155 | + $image_fid = db_result(db_query(" |
|
2156 | 2156 | SELECT ctp.%s |
2157 | 2157 | FROM {content_type_profile} ctp |
2158 | 2158 | INNER JOIN {node} n ON ctp.nid = n.nid |
2159 | 2159 | WHERE n.uid = %d AND n.type = '%s'", |
2160 | 2160 | $image_field, $uid, 'profile')); |
2161 | - $user_image['image'] = field_file_load($image_fid); |
|
2162 | - if (!$user_image['image']['filepath']) { |
|
2161 | + $user_image['image'] = field_file_load($image_fid); |
|
2162 | + if (!$user_image['image']['filepath']) { |
|
2163 | 2163 | // Load the default image if one does not exist |
2164 | 2164 | $account = user_load($uid); |
2165 | 2165 | if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) { |
2166 | - // Use a Gravatar rather than the system default image |
|
2167 | - $options = array( |
|
2166 | + // Use a Gravatar rather than the system default image |
|
2167 | + $options = array( |
|
2168 | 2168 | 'size' => 100, |
2169 | 2169 | 'rating' => 'G', |
2170 | - ); |
|
2171 | - // Get the Gravatar URL and see if the image exists |
|
2172 | - $url = gravatar_get_gravatar($account->mail, $options); |
|
2173 | - $headers = @get_headers($url); |
|
2174 | - if (preg_match("|200|", $headers[0])) { |
|
2170 | + ); |
|
2171 | + // Get the Gravatar URL and see if the image exists |
|
2172 | + $url = gravatar_get_gravatar($account->mail, $options); |
|
2173 | + $headers = @get_headers($url); |
|
2174 | + if (preg_match("|200|", $headers[0])) { |
|
2175 | 2175 | return $url; |
2176 | - } |
|
2176 | + } |
|
2177 | 2177 | } |
2178 | 2178 | // Get default image if nothing else works |
2179 | 2179 | $content_node_widget_settings = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s'", ($avatar ? 'field_image' : 'field_profile_image'))); |
2180 | 2180 | $content_node_widget_settings = unserialize($content_node_widget_settings); |
2181 | 2181 | $user_image['image'] = $content_node_widget_settings['default_image']; |
2182 | - } |
|
2183 | - $user = user_load($uid); |
|
2184 | - // Use boinc username for image alt/title attributes |
|
2185 | - $user_image['alt'] = $user->boincuser_name; |
|
2186 | - return $user_image; |
|
2182 | + } |
|
2183 | + $user = user_load($uid); |
|
2184 | + // Use boinc username for image alt/title attributes |
|
2185 | + $user_image['alt'] = $user->boincuser_name; |
|
2186 | + return $user_image; |
|
2187 | 2187 | } |
2188 | 2188 | |
2189 | 2189 | /** |
2190 | 2190 | * Generate a table of a user's projects |
2191 | 2191 | */ |
2192 | 2192 | function boincuser_get_projects_table($account = null) { |
2193 | - if ($account AND is_numeric($account)) { |
|
2193 | + if ($account AND is_numeric($account)) { |
|
2194 | 2194 | $account = user_load($account); |
2195 | - } |
|
2196 | - $projects = boincuser_get_projects($account); |
|
2197 | - if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2195 | + } |
|
2196 | + $projects = boincuser_get_projects($account); |
|
2197 | + if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2198 | 2198 | |
2199 | - $output = ''; |
|
2200 | - $output .= '<table class="user-projects">' . "\n"; |
|
2201 | - $output .= '<thead>' . "\n"; |
|
2202 | - $output .= ' <tr>' . "\n"; |
|
2203 | - $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2204 | - $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2205 | - $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2206 | - $output .= ' </tr>' . "\n"; |
|
2207 | - $output .= '</thead>' . "\n"; |
|
2208 | - $output .= '<tbody>' . "\n"; |
|
2209 | - foreach ($projects AS $project) { |
|
2199 | + $output = ''; |
|
2200 | + $output .= '<table class="user-projects">' . "\n"; |
|
2201 | + $output .= '<thead>' . "\n"; |
|
2202 | + $output .= ' <tr>' . "\n"; |
|
2203 | + $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2204 | + $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2205 | + $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2206 | + $output .= ' </tr>' . "\n"; |
|
2207 | + $output .= '</thead>' . "\n"; |
|
2208 | + $output .= '<tbody>' . "\n"; |
|
2209 | + foreach ($projects AS $project) { |
|
2210 | 2210 | $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id; |
2211 | 2211 | $output .= ' <tr>' . "\n"; |
2212 | 2212 | $output .= ' <td>' . l($project->name, $url) . '</td>' . "\n"; |
2213 | 2213 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; |
2214 | 2214 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n"; |
2215 | 2215 | $output .= ' </tr>' . "\n"; |
2216 | - } |
|
2217 | - $output .= '</tbody>' . "\n"; |
|
2218 | - $output .= '</table>' . "\n"; |
|
2219 | - $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
2220 | - //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
2221 | - return $output; |
|
2216 | + } |
|
2217 | + $output .= '</tbody>' . "\n"; |
|
2218 | + $output .= '</table>' . "\n"; |
|
2219 | + $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
2220 | + //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
2221 | + return $output; |
|
2222 | 2222 | } |
2223 | 2223 | |
2224 | 2224 | /** |
@@ -2226,25 +2226,25 @@ discard block |
||
2226 | 2226 | */ |
2227 | 2227 | function boincuser_get_stats_user_data($cpid = null) { |
2228 | 2228 | |
2229 | - // [TODO] Set this stuff in site config! |
|
2230 | - $stats_server = 'stats.gridrepublic.org'; |
|
2231 | - $stats_rpc = 'rpc/get_user.php'; |
|
2229 | + // [TODO] Set this stuff in site config! |
|
2230 | + $stats_server = 'stats.gridrepublic.org'; |
|
2231 | + $stats_rpc = 'rpc/get_user.php'; |
|
2232 | 2232 | |
2233 | - // Construct query string |
|
2234 | - $get = array( |
|
2233 | + // Construct query string |
|
2234 | + $get = array( |
|
2235 | 2235 | 'cpid' => $cpid |
2236 | - ); |
|
2237 | - $args = array(); |
|
2238 | - foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2239 | - $query = '?' . implode('&', $args); |
|
2236 | + ); |
|
2237 | + $args = array(); |
|
2238 | + foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2239 | + $query = '?' . implode('&', $args); |
|
2240 | 2240 | |
2241 | - // Load XML from RPC |
|
2242 | - $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
2243 | - $result = drupal_http_request($target_url); |
|
2244 | - if (in_array($result->code, array(200, 304))) { |
|
2241 | + // Load XML from RPC |
|
2242 | + $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
2243 | + $result = drupal_http_request($target_url); |
|
2244 | + if (in_array($result->code, array(200, 304))) { |
|
2245 | 2245 | return simplexml_load_string($result->data); |
2246 | - } |
|
2247 | - return NULL; |
|
2246 | + } |
|
2247 | + return NULL; |
|
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | /** |
@@ -2252,15 +2252,15 @@ discard block |
||
2252 | 2252 | */ |
2253 | 2253 | function boincuser_get_projects($account = null) { |
2254 | 2254 | |
2255 | - // Use the current user by default |
|
2256 | - if (!$account) { |
|
2255 | + // Use the current user by default |
|
2256 | + if (!$account) { |
|
2257 | 2257 | global $user; |
2258 | 2258 | $account = user_load($user->uid); |
2259 | - } |
|
2259 | + } |
|
2260 | 2260 | |
2261 | - $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
2261 | + $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
2262 | 2262 | |
2263 | - return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2263 | + return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2264 | 2264 | } |
2265 | 2265 | |
2266 | 2266 | |
@@ -2268,11 +2268,11 @@ discard block |
||
2268 | 2268 | * Get the links to display under the user profile |
2269 | 2269 | */ |
2270 | 2270 | function boincuser_get_profile_links($uid) { |
2271 | - global $user; |
|
2272 | - $account = user_load($uid); |
|
2273 | - $profile = content_profile_load('profile', $account->uid); |
|
2274 | - $output = ''; |
|
2275 | - if ($profile) { |
|
2271 | + global $user; |
|
2272 | + $account = user_load($uid); |
|
2273 | + $profile = content_profile_load('profile', $account->uid); |
|
2274 | + $output = ''; |
|
2275 | + if ($profile) { |
|
2276 | 2276 | $profile_is_approved = ($profile->status AND !$profile->moderate); |
2277 | 2277 | $user_is_moderator = user_access('edit any profile content'); |
2278 | 2278 | $is_own_profile = ($user->uid == $account->uid); |
@@ -2280,15 +2280,15 @@ discard block |
||
2280 | 2280 | $links = array(); |
2281 | 2281 | |
2282 | 2282 | if ($profile->moderate AND $user_is_moderator) { |
2283 | - $links['approve_profile'] = array( |
|
2283 | + $links['approve_profile'] = array( |
|
2284 | 2284 | 'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'), |
2285 | 2285 | 'href' => "{$profile_moderation_path}/approve", |
2286 | 2286 | 'attributes' => array( |
2287 | - 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2288 | - 'class' => 'first primary tab', |
|
2287 | + 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2288 | + 'class' => 'first primary tab', |
|
2289 | 2289 | ) |
2290 | - ); |
|
2291 | - /*$links['edit_profile'] = array( |
|
2290 | + ); |
|
2291 | + /*$links['edit_profile'] = array( |
|
2292 | 2292 | 'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'), |
2293 | 2293 | 'href' => "{$profile_moderation_path}/edit", |
2294 | 2294 | 'attributes' => array( |
@@ -2296,27 +2296,27 @@ discard block |
||
2296 | 2296 | 'class' => 'tab', |
2297 | 2297 | ) |
2298 | 2298 | );*/ |
2299 | - $links['reject_profile'] = array( |
|
2299 | + $links['reject_profile'] = array( |
|
2300 | 2300 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
2301 | 2301 | 'href' => "{$profile_moderation_path}/reject", |
2302 | 2302 | 'attributes' => array( |
2303 | - 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2304 | - 'class' => 'tab', |
|
2303 | + 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2304 | + 'class' => 'tab', |
|
2305 | 2305 | ) |
2306 | - ); |
|
2306 | + ); |
|
2307 | 2307 | } |
2308 | 2308 | $output .= '<ul class="tab-list">'; |
2309 | 2309 | $count = 0; |
2310 | 2310 | foreach ($links as $key => $link) { |
2311 | - $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2312 | - $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
2313 | - $output .= '</li>'; |
|
2314 | - $count++; |
|
2311 | + $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2312 | + $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
2313 | + $output .= '</li>'; |
|
2314 | + $count++; |
|
2315 | 2315 | } |
2316 | 2316 | $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user_meta', $account->uid) . '</li>'; |
2317 | 2317 | $output .= '</ul>'; |
2318 | - } |
|
2319 | - return $output; |
|
2318 | + } |
|
2319 | + return $output; |
|
2320 | 2320 | /* |
2321 | 2321 | <ul class="tab-list"> |
2322 | 2322 | <li class="primary first tab"> |
@@ -2353,36 +2353,36 @@ discard block |
||
2353 | 2353 | */ |
2354 | 2354 | function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
2355 | 2355 | |
2356 | - foreach ($documents as $document) { |
|
2356 | + foreach ($documents as $document) { |
|
2357 | 2357 | if ( $document->entity_type=='node' AND $document->bundle=='profile' ) { |
2358 | - // Node information. |
|
2359 | - $nid = $document->entity_id; |
|
2360 | - $node = node_load($nid); |
|
2361 | - $account = user_load($node->uid); |
|
2362 | - |
|
2363 | - // Use boincuser name and not drupal user name |
|
2364 | - $document->label = apachesolr_clean_text($account->boincuser_name); |
|
2365 | - // Author information |
|
2366 | - if ($node->uid == 0 || strlen($node->name) == 0) { |
|
2358 | + // Node information. |
|
2359 | + $nid = $document->entity_id; |
|
2360 | + $node = node_load($nid); |
|
2361 | + $account = user_load($node->uid); |
|
2362 | + |
|
2363 | + // Use boincuser name and not drupal user name |
|
2364 | + $document->label = apachesolr_clean_text($account->boincuser_name); |
|
2365 | + // Author information |
|
2366 | + if ($node->uid == 0 || strlen($node->name) == 0) { |
|
2367 | 2367 | // @see user_validate_name(). !'0' === TRUE. |
2368 | 2368 | $document->ss_name = '0'; |
2369 | - } |
|
2370 | - else { |
|
2369 | + } |
|
2370 | + else { |
|
2371 | 2371 | $document->ss_name = $account->boincuser_name; |
2372 | 2372 | // We want the name to be searchable for keywords. |
2373 | 2373 | $document->tos_name = $account->boincuser_name; |
2374 | - } |
|
2374 | + } |
|
2375 | 2375 | |
2376 | - // Rename "Profle" to "User" |
|
2377 | - $document->bundle = "User"; |
|
2378 | - $document->bundle_name = "User"; |
|
2376 | + // Rename "Profle" to "User" |
|
2377 | + $document->bundle = "User"; |
|
2378 | + $document->bundle_name = "User"; |
|
2379 | 2379 | |
2380 | - // Replace the Solr document's created field with the date the user |
|
2381 | - // account was created. This replaces the node creation date typically |
|
2382 | - // used for indexing nodes. |
|
2383 | - $document->ds_created = apachesolr_date_iso($account->created); |
|
2380 | + // Replace the Solr document's created field with the date the user |
|
2381 | + // account was created. This replaces the node creation date typically |
|
2382 | + // used for indexing nodes. |
|
2383 | + $document->ds_created = apachesolr_date_iso($account->created); |
|
2384 | + } |
|
2384 | 2385 | } |
2385 | - } |
|
2386 | 2386 | |
2387 | 2387 | } |
2388 | 2388 | |
@@ -2394,23 +2394,23 @@ discard block |
||
2394 | 2394 | * Implementation of hook_privatemsg_name_lookup(); |
2395 | 2395 | */ |
2396 | 2396 | function boincuser_privatemsg_name_lookup($string) { |
2397 | - // Get the BOINC ID from the name string, and lookup the |
|
2398 | - // corresponding drupal user. |
|
2399 | - $boincname = substr($string, 0, strrpos($string, '_')); |
|
2400 | - $boincid = substr($string, strrpos($string, '_') + 1); |
|
2401 | - $drupalid = get_drupal_id($boincid); |
|
2402 | - |
|
2403 | - // Name has spaced replaced with special UTF-8 characters in |
|
2404 | - // privatemsg module. We need to convert them back to spaces for the |
|
2405 | - // check below. |
|
2406 | - $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
2407 | - if ($drupalid>0) { |
|
2397 | + // Get the BOINC ID from the name string, and lookup the |
|
2398 | + // corresponding drupal user. |
|
2399 | + $boincname = substr($string, 0, strrpos($string, '_')); |
|
2400 | + $boincid = substr($string, strrpos($string, '_') + 1); |
|
2401 | + $drupalid = get_drupal_id($boincid); |
|
2402 | + |
|
2403 | + // Name has spaced replaced with special UTF-8 characters in |
|
2404 | + // privatemsg module. We need to convert them back to spaces for the |
|
2405 | + // check below. |
|
2406 | + $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
2407 | + if ($drupalid>0) { |
|
2408 | 2408 | if ($recipient = user_load(array('uid' => $drupalid))) { |
2409 | - // Double-check that the loaded user matches both boincuser_id |
|
2410 | - // and boincuser_name. |
|
2411 | - if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2409 | + // Double-check that the loaded user matches both boincuser_id |
|
2410 | + // and boincuser_name. |
|
2411 | + if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2412 | 2412 | return $recipient; |
2413 | - } |
|
2413 | + } |
|
2414 | + } |
|
2414 | 2415 | } |
2415 | - } |
|
2416 | 2416 | } |
@@ -106,7 +106,7 @@ |
||
106 | 106 | } |
107 | 107 | if (!$checkct) { |
108 | 108 | error_log("Project configuration error! " . |
109 | - "'CONSENT_TYPE_ENROLL' disabled while 'account_creation_rpc_require_consent' enabled!" |
|
109 | + "'CONSENT_TYPE_ENROLL' disabled while 'account_creation_rpc_require_consent' enabled!" |
|
110 | 110 | ); |
111 | 111 | } |
112 | 112 |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | * The structure of the general preferences form |
16 | 16 | */ |
17 | 17 | function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) { |
18 | - $form = array(); |
|
19 | - $prefs = null; |
|
20 | - $established = TRUE; |
|
18 | + $form = array(); |
|
19 | + $prefs = null; |
|
20 | + $established = TRUE; |
|
21 | 21 | |
22 | - // Enable AHAH form support for dynamically updating content based on preset |
|
23 | - ahah_helper_register($form, $form_state); |
|
22 | + // Enable AHAH form support for dynamically updating content based on preset |
|
23 | + ahah_helper_register($form, $form_state); |
|
24 | 24 | |
25 | - if (!$prefs_preset) { |
|
25 | + if (!$prefs_preset) { |
|
26 | 26 | if (isset($form_state['storage']['prefs']['preset'])) { |
27 | - $prefs_preset = $form_state['storage']['prefs']['preset']; |
|
27 | + $prefs_preset = $form_state['storage']['prefs']['preset']; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // Load preferences from BOINC account |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // Take note if this is not an established preference set on the account |
34 | 34 | if (isset($prefs['@attributes']['cleared'])) { |
35 | - $established = FALSE; |
|
35 | + $established = FALSE; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Determine if a preset is selected or if these are custom settings |
@@ -47,45 +47,45 @@ discard block |
||
47 | 47 | $prefs_preset = $prefs['preset']['@value']; |
48 | 48 | } |
49 | 49 | }// if !$prefs_preset |
50 | - } |
|
51 | - // Extract mod_time tag if present, because it will be erased with |
|
52 | - // boincwork_get_preset_prefs() below. |
|
53 | - $mod_time = null; |
|
54 | - if (isset($prefs['mod_time']['@value'])) { |
|
55 | - $mod_time = $prefs['mod_time']['@value']; |
|
56 | - } |
|
57 | - |
|
58 | - if (isset($form_state['storage']['wip'])) { |
|
59 | - switch ($prefs_preset) { |
|
60 | - case 'standard': |
|
50 | + } |
|
51 | + // Extract mod_time tag if present, because it will be erased with |
|
52 | + // boincwork_get_preset_prefs() below. |
|
53 | + $mod_time = null; |
|
54 | + if (isset($prefs['mod_time']['@value'])) { |
|
55 | + $mod_time = $prefs['mod_time']['@value']; |
|
56 | + } |
|
57 | + |
|
58 | + if (isset($form_state['storage']['wip'])) { |
|
59 | + switch ($prefs_preset) { |
|
60 | + case 'standard': |
|
61 | 61 | case 'maximum': |
62 | 62 | case 'green': |
63 | 63 | case 'minimum': |
64 | 64 | $prefs = boincwork_get_preset_prefs($prefs_preset); |
65 | - break; |
|
66 | - case 'custom': |
|
65 | + break; |
|
66 | + case 'custom': |
|
67 | 67 | default: |
68 | 68 | // Just keeps prefs as they are |
69 | 69 | unset($prefs['preset']); |
70 | - break; |
|
71 | - }// switch |
|
72 | - } else { |
|
73 | - $form_state['storage']['wip'] = TRUE; |
|
74 | - if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) { |
|
75 | - if ($established) { |
|
76 | - $prefs_preset = 'custom'; |
|
77 | - } else { |
|
78 | - $prefs_preset = 'standard'; |
|
79 | - $prefs = boincwork_get_preset_prefs($prefs_preset); |
|
80 | - }// if $established |
|
81 | - }// if $prefs_preset |
|
82 | - }// if WIP |
|
83 | - |
|
84 | - // This set of preferences is used in the form if no preferences |
|
85 | - // have been set above, in variable $prefs. |
|
86 | - require_boinc(array('db', 'prefs')); |
|
87 | - $disk_space_config = get_disk_space_config(); |
|
88 | - $default = array( |
|
70 | + break; |
|
71 | + }// switch |
|
72 | + } else { |
|
73 | + $form_state['storage']['wip'] = TRUE; |
|
74 | + if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) { |
|
75 | + if ($established) { |
|
76 | + $prefs_preset = 'custom'; |
|
77 | + } else { |
|
78 | + $prefs_preset = 'standard'; |
|
79 | + $prefs = boincwork_get_preset_prefs($prefs_preset); |
|
80 | + }// if $established |
|
81 | + }// if $prefs_preset |
|
82 | + }// if WIP |
|
83 | + |
|
84 | + // This set of preferences is used in the form if no preferences |
|
85 | + // have been set above, in variable $prefs. |
|
86 | + require_boinc(array('db', 'prefs')); |
|
87 | + $disk_space_config = get_disk_space_config(); |
|
88 | + $default = array( |
|
89 | 89 | 'preset' => $prefs_preset, |
90 | 90 | // Processing... |
91 | 91 | 'run_on_batteries' => 0, |
@@ -120,385 +120,385 @@ discard block |
||
120 | 120 | 'daily_xfer_limit_mb' => 0, |
121 | 121 | 'daily_xfer_period_days' => 0, |
122 | 122 | 'dont_verify_images' => 0 |
123 | - ); |
|
124 | - foreach ($default as $name => $value) { |
|
123 | + ); |
|
124 | + foreach ($default as $name => $value) { |
|
125 | 125 | if (isset($prefs[$name])) { |
126 | - if (is_array($prefs[$name])) { |
|
126 | + if (is_array($prefs[$name])) { |
|
127 | 127 | if (isset($prefs[$name]['@value'])) { |
128 | - $default[$name] = $prefs[$name]['@value']; |
|
128 | + $default[$name] = $prefs[$name]['@value']; |
|
129 | + } |
|
129 | 130 | } |
130 | - } |
|
131 | - else { |
|
131 | + else { |
|
132 | 132 | $default[$name] = $prefs[$name]; |
133 | - } |
|
133 | + } |
|
134 | + } |
|
134 | 135 | } |
135 | - } |
|
136 | 136 | |
137 | - // Standard option sets |
|
138 | - $form['boolean_options'] = array( |
|
137 | + // Standard option sets |
|
138 | + $form['boolean_options'] = array( |
|
139 | 139 | '#type' => 'value', |
140 | 140 | '#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')) |
141 | - ); |
|
142 | - $form['hour_options'] = array( |
|
141 | + ); |
|
142 | + $form['hour_options'] = array( |
|
143 | 143 | '#type' => 'value', |
144 | 144 | '#value' => array('0:00','1:00','2:00','3:00','4:00', |
145 | - '5:00','6:00','7:00','8:00','9:00','10:00','11:00', |
|
146 | - '12:00','13:00','14:00','15:00','16:00','17:00', |
|
147 | - '18:00','19:00','20:00','21:00','22:00','23:00') |
|
148 | - ); |
|
149 | - |
|
150 | - // Identify preference sets that are established to distinguish what has been |
|
151 | - // saved to the database from what is just showing default values |
|
152 | - $form['#established'] = $established; |
|
145 | + '5:00','6:00','7:00','8:00','9:00','10:00','11:00', |
|
146 | + '12:00','13:00','14:00','15:00','16:00','17:00', |
|
147 | + '18:00','19:00','20:00','21:00','22:00','23:00') |
|
148 | + ); |
|
149 | + |
|
150 | + // Identify preference sets that are established to distinguish what has been |
|
151 | + // saved to the database from what is just showing default values |
|
152 | + $form['#established'] = $established; |
|
153 | 153 | |
154 | - // Set up the preference container for AHAH |
|
155 | - $form['prefs'] = array( |
|
154 | + // Set up the preference container for AHAH |
|
155 | + $form['prefs'] = array( |
|
156 | 156 | '#title' => '', |
157 | 157 | '#type' => 'fieldset', |
158 | 158 | '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div. |
159 | 159 | '#attributes' => array('class' => 'ahah-container'), |
160 | 160 | '#suffix' => '</div>', |
161 | 161 | '#tree' => TRUE |
162 | - ); |
|
163 | - //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>'); |
|
162 | + ); |
|
163 | + //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>'); |
|
164 | 164 | |
165 | - // Hidden elements |
|
166 | - $form['prefs']['modified'] = array( |
|
165 | + // Hidden elements |
|
166 | + $form['prefs']['modified'] = array( |
|
167 | 167 | '#type' => 'hidden', |
168 | 168 | '#value' => $mod_time |
169 | - ); |
|
170 | - $form['prefs']['venue'] = array( |
|
169 | + ); |
|
170 | + $form['prefs']['venue'] = array( |
|
171 | 171 | '#type' => 'hidden', |
172 | 172 | '#value' => $venue |
173 | - ); |
|
173 | + ); |
|
174 | 174 | |
175 | - $form['prefs']['separator_top'] = array( |
|
175 | + $form['prefs']['separator_top'] = array( |
|
176 | 176 | '#value' => '<div class="separator"></div>' |
177 | - ); |
|
177 | + ); |
|
178 | 178 | |
179 | - // Simplified selectors |
|
180 | - $form['prefs']['preset'] = array( |
|
181 | - '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'), |
|
179 | + // Simplified selectors |
|
180 | + $form['prefs']['preset'] = array( |
|
181 | + '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'), |
|
182 | 182 | '#type' => 'radios', |
183 | 183 | '#description' => ' ', |
184 | 184 | '#options' => array( |
185 | - 'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'), |
|
186 | - 'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'), |
|
187 | - 'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'), |
|
188 | - 'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'), |
|
189 | - 'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset') |
|
185 | + 'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'), |
|
186 | + 'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'), |
|
187 | + 'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'), |
|
188 | + 'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'), |
|
189 | + 'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset') |
|
190 | 190 | ), |
191 | 191 | '#prefix' => '<div class="simple-form-controls">', |
192 | 192 | '#suffix' => '</div>', |
193 | 193 | '#default_value' => $default['preset'], |
194 | 194 | '#ahah' => array( |
195 | - 'event' => 'change', |
|
196 | - 'path' => ahah_helper_path(array('prefs')), |
|
197 | - 'wrapper' => 'prefs-wrapper' |
|
195 | + 'event' => 'change', |
|
196 | + 'path' => ahah_helper_path(array('prefs')), |
|
197 | + 'wrapper' => 'prefs-wrapper' |
|
198 | 198 | ) |
199 | - ); |
|
200 | - $form['prefs']['select preset'] = array( |
|
199 | + ); |
|
200 | + $form['prefs']['select preset'] = array( |
|
201 | 201 | '#type' => 'submit', |
202 | 202 | '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'), |
203 | 203 | '#submit' => array('ahah_helper_generic_submit'), |
204 | 204 | // The 'no-js' class only displays this button if javascript is disabled |
205 | 205 | '#attributes' => array('class' => 'no-js'), |
206 | - ); |
|
206 | + ); |
|
207 | 207 | |
208 | - // Advanced preferences |
|
209 | - $form['prefs']['advanced'] = array( |
|
208 | + // Advanced preferences |
|
209 | + $form['prefs']['advanced'] = array( |
|
210 | 210 | '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'), |
211 | 211 | '#type' => 'fieldset', |
212 | 212 | '#description' => '', |
213 | 213 | '#collapsible' => TRUE, |
214 | 214 | '#collapsed' => !$advanced, |
215 | 215 | '#attributes' => array('class' => 'advanced-settings'), |
216 | - ); |
|
216 | + ); |
|
217 | 217 | |
218 | - // Processing preferences |
|
218 | + // Processing preferences |
|
219 | 219 | |
220 | - $form['prefs']['advanced']['anchor'] = array( |
|
220 | + $form['prefs']['advanced']['anchor'] = array( |
|
221 | 221 | '#value' => '<a name="advanced"></a>' |
222 | - ); |
|
222 | + ); |
|
223 | 223 | |
224 | - $form['prefs']['advanced']['separator_top'] = array( |
|
224 | + $form['prefs']['advanced']['separator_top'] = array( |
|
225 | 225 | '#value' => '<div class="separator"></div>' |
226 | - ); |
|
226 | + ); |
|
227 | 227 | |
228 | - $form['prefs']['advanced']['processor'] = array( |
|
228 | + $form['prefs']['advanced']['processor'] = array( |
|
229 | 229 | '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'), |
230 | 230 | '#type' => 'fieldset', |
231 | 231 | '#description' => '', |
232 | 232 | '#collapsible' => FALSE, |
233 | 233 | '#collapsed' => FALSE |
234 | - ); |
|
235 | - $form['prefs']['advanced']['processor']['run_on_batteries'] = array( |
|
234 | + ); |
|
235 | + $form['prefs']['advanced']['processor']['run_on_batteries'] = array( |
|
236 | 236 | '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'), |
237 | 237 | '#type' => 'radios', |
238 | 238 | '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'), |
239 | 239 | '#options' => $form['boolean_options']['#value'], |
240 | 240 | '#attributes' => array('class' => 'fancy'), |
241 | 241 | '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting |
242 | - ); |
|
243 | - $form['prefs']['advanced']['processor']['run_if_user_active'] = array( |
|
242 | + ); |
|
243 | + $form['prefs']['advanced']['processor']['run_if_user_active'] = array( |
|
244 | 244 | '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'), |
245 | 245 | '#type' => 'radios', |
246 | 246 | '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'), |
247 | 247 | '#options' => $form['boolean_options']['#value'], |
248 | 248 | '#attributes' => array('class' => 'fancy'), |
249 | 249 | '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting |
250 | - ); |
|
251 | - $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array( |
|
250 | + ); |
|
251 | + $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array( |
|
252 | 252 | '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'), |
253 | 253 | '#type' => 'radios', |
254 | 254 | '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'), |
255 | 255 | '#options' => $form['boolean_options']['#value'], |
256 | 256 | '#attributes' => array('class' => 'fancy'), |
257 | 257 | '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting |
258 | - ); |
|
259 | - $form['prefs']['advanced']['processor']['idle_time_to_run'] = array( |
|
260 | - '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
|
258 | + ); |
|
259 | + $form['prefs']['advanced']['processor']['idle_time_to_run'] = array( |
|
260 | + '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
|
261 | 261 | '#type' => 'textfield', |
262 | 262 | '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
263 | 263 | '#default_value' => $default['idle_time_to_run'], |
264 | 264 | '#size' => 1, |
265 | 265 | '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing') |
266 | - ); |
|
267 | - $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array( |
|
266 | + ); |
|
267 | + $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array( |
|
268 | 268 | '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
269 | 269 | '#type' => 'textfield', |
270 | 270 | '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
271 | 271 | '#default_value' => $default['suspend_if_no_recent_input'], |
272 | 272 | '#size' => 1, |
273 | 273 | '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing') |
274 | - ); |
|
275 | - $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array( |
|
274 | + ); |
|
275 | + $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array( |
|
276 | 276 | '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'), |
277 | 277 | '#type' => 'textfield', |
278 | 278 | '#field_suffix' => '%', |
279 | 279 | '#default_value' => $default['suspend_cpu_usage'], |
280 | 280 | '#size' => 1, |
281 | 281 | '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'), |
282 | - ); |
|
283 | - $form['prefs']['advanced']['processor']['hour_label'] = array( |
|
282 | + ); |
|
283 | + $form['prefs']['advanced']['processor']['hour_label'] = array( |
|
284 | 284 | '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
285 | - ); |
|
286 | - $form['prefs']['advanced']['processor']['start_hour'] = array( |
|
285 | + ); |
|
286 | + $form['prefs']['advanced']['processor']['start_hour'] = array( |
|
287 | 287 | '#type' => 'select', |
288 | 288 | '#options' => $form['hour_options']['#value'], |
289 | 289 | '#default_value' => $default['start_hour'] |
290 | - ); |
|
291 | - $form['prefs']['advanced']['processor']['hour_delimiter'] = array( |
|
290 | + ); |
|
291 | + $form['prefs']['advanced']['processor']['hour_delimiter'] = array( |
|
292 | 292 | '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
293 | - ); |
|
294 | - $form['prefs']['advanced']['processor']['end_hour'] = array( |
|
293 | + ); |
|
294 | + $form['prefs']['advanced']['processor']['end_hour'] = array( |
|
295 | 295 | '#type' => 'select', |
296 | 296 | '#options' => $form['hour_options']['#value'], |
297 | 297 | '#default_value' => $default['end_hour'] |
298 | - ); |
|
299 | - $form['prefs']['advanced']['processor']['hour_description'] = array( |
|
298 | + ); |
|
299 | + $form['prefs']['advanced']['processor']['hour_description'] = array( |
|
300 | 300 | '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
301 | - ); |
|
302 | - $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array( |
|
301 | + ); |
|
302 | + $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array( |
|
303 | 303 | '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'), |
304 | 304 | '#type' => 'radios', |
305 | 305 | '#options' => $form['boolean_options']['#value'], |
306 | 306 | '#attributes' => array('class' => 'fancy'), |
307 | 307 | '#default_value' => $default['leave_apps_in_memory'], |
308 | 308 | '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), NULL, 'boinc:account-preferences-computing') |
309 | - ); |
|
310 | - $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array( |
|
309 | + ); |
|
310 | + $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array( |
|
311 | 311 | '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'), |
312 | 312 | '#type' => 'textfield', |
313 | 313 | '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
314 | 314 | '#default_value' => $default['cpu_scheduling_period_minutes'], |
315 | 315 | '#size' => 1, |
316 | 316 | '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing') |
317 | - ); |
|
318 | - $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array( |
|
317 | + ); |
|
318 | + $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array( |
|
319 | 319 | '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'), |
320 | 320 | '#type' => 'textfield', |
321 | 321 | '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'), |
322 | 322 | '#default_value' => $default['max_ncpus_pct'], |
323 | 323 | '#size' => 1, |
324 | 324 | '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'), |
325 | - ); |
|
326 | - $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array( |
|
325 | + ); |
|
326 | + $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array( |
|
327 | 327 | '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'), |
328 | 328 | '#type' => 'textfield', |
329 | 329 | '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'), |
330 | 330 | '#default_value' => $default['cpu_usage_limit'], |
331 | 331 | '#size' => 1, |
332 | 332 | '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), NULL, 'boinc:account-preferences-computing') |
333 | - ); |
|
333 | + ); |
|
334 | 334 | |
335 | - // Disk and memory preferences |
|
336 | - $form['prefs']['advanced']['storage'] = array( |
|
335 | + // Disk and memory preferences |
|
336 | + $form['prefs']['advanced']['storage'] = array( |
|
337 | 337 | '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'), |
338 | 338 | '#type' => 'fieldset', |
339 | 339 | '#description' => '', |
340 | 340 | '#collapsible' => FALSE, |
341 | 341 | '#collapsed' => FALSE |
342 | - ); |
|
343 | - $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array( |
|
342 | + ); |
|
343 | + $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array( |
|
344 | 344 | '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'), |
345 | 345 | '#type' => 'textfield', |
346 | 346 | '#field_suffix' => 'GB', |
347 | 347 | '#default_value' => $default['disk_max_used_gb'], |
348 | 348 | '#size' => 1, |
349 | 349 | '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'), |
350 | - ); |
|
351 | - $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array( |
|
350 | + ); |
|
351 | + $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array( |
|
352 | 352 | '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'), |
353 | 353 | '#type' => 'textfield', |
354 | 354 | '#field_suffix' => 'GB free', |
355 | 355 | '#default_value' => $default['disk_min_free_gb'], |
356 | 356 | '#size' => 1, |
357 | 357 | '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'), |
358 | - ); |
|
359 | - $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array( |
|
358 | + ); |
|
359 | + $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array( |
|
360 | 360 | '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'), |
361 | 361 | '#type' => 'textfield', |
362 | 362 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
363 | 363 | '#default_value' => $default['disk_max_used_pct'], |
364 | 364 | '#size' => 1, |
365 | 365 | '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing') |
366 | - ); |
|
367 | - $form['prefs']['advanced']['storage']['disk_interval'] = array( |
|
366 | + ); |
|
367 | + $form['prefs']['advanced']['storage']['disk_interval'] = array( |
|
368 | 368 | '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'), |
369 | 369 | '#type' => 'textfield', |
370 | 370 | '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'), |
371 | 371 | '#default_value' => $default['disk_interval'], |
372 | 372 | '#size' => 1, |
373 | 373 | '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing') |
374 | - ); |
|
375 | - $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array( |
|
374 | + ); |
|
375 | + $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array( |
|
376 | 376 | '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'), |
377 | 377 | '#type' => 'textfield', |
378 | 378 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
379 | 379 | '#default_value' => $default['vm_max_used_pct'], |
380 | 380 | '#size' => 1, |
381 | 381 | '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing') |
382 | - ); |
|
383 | - $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array( |
|
382 | + ); |
|
383 | + $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array( |
|
384 | 384 | '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'), |
385 | 385 | '#type' => 'textfield', |
386 | 386 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
387 | 387 | '#default_value' => $default['ram_max_used_busy_pct'], |
388 | 388 | '#size' => 1, |
389 | 389 | '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing') |
390 | - ); |
|
391 | - $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array( |
|
390 | + ); |
|
391 | + $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array( |
|
392 | 392 | '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'), |
393 | 393 | '#type' => 'textfield', |
394 | 394 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
395 | 395 | '#default_value' => $default['ram_max_used_idle_pct'], |
396 | 396 | '#size' => 1, |
397 | 397 | '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing') |
398 | - ); |
|
398 | + ); |
|
399 | 399 | |
400 | - // Network preferences |
|
401 | - $form['prefs']['advanced']['network'] = array( |
|
400 | + // Network preferences |
|
401 | + $form['prefs']['advanced']['network'] = array( |
|
402 | 402 | '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'), |
403 | 403 | '#type' => 'fieldset', |
404 | 404 | '#description' => '', |
405 | 405 | '#collapsible' => FALSE, |
406 | 406 | '#collapsed' => FALSE |
407 | - ); |
|
408 | - $form['prefs']['advanced']['network']['work_buf_min_days'] = array( |
|
407 | + ); |
|
408 | + $form['prefs']['advanced']['network']['work_buf_min_days'] = array( |
|
409 | 409 | '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'), |
410 | 410 | '#type' => 'textfield', |
411 | 411 | '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'), |
412 | 412 | '#default_value' => $default['work_buf_min_days'], |
413 | 413 | '#size' => 1, |
414 | 414 | '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing') |
415 | - ); |
|
416 | - $form['prefs']['advanced']['network']['work_buf_additional_days'] = array( |
|
415 | + ); |
|
416 | + $form['prefs']['advanced']['network']['work_buf_additional_days'] = array( |
|
417 | 417 | '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'), |
418 | 418 | '#type' => 'textfield', |
419 | 419 | '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'), |
420 | 420 | '#default_value' => $default['work_buf_additional_days'], |
421 | 421 | '#size' => 1, |
422 | 422 | '#description' => bts('Store additional tasks above the minimum level. Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing') |
423 | - ); |
|
424 | - $form['prefs']['advanced']['network']['confirm_before_connecting'] = array( |
|
423 | + ); |
|
424 | + $form['prefs']['advanced']['network']['confirm_before_connecting'] = array( |
|
425 | 425 | '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'), |
426 | 426 | '#type' => 'radios', |
427 | 427 | '#options' => $form['boolean_options']['#value'], |
428 | 428 | '#attributes' => array('class' => 'fancy'), |
429 | 429 | '#default_value' => $default['confirm_before_connecting'], |
430 | 430 | '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing') |
431 | - ); |
|
432 | - $form['prefs']['advanced']['network']['hangup_if_dialed'] = array( |
|
431 | + ); |
|
432 | + $form['prefs']['advanced']['network']['hangup_if_dialed'] = array( |
|
433 | 433 | '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'), |
434 | 434 | '#type' => 'radios', |
435 | 435 | '#options' => $form['boolean_options']['#value'], |
436 | 436 | '#attributes' => array('class' => 'fancy'), |
437 | 437 | '#default_value' => $default['hangup_if_dialed'], |
438 | 438 | '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing') |
439 | - ); |
|
440 | - $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array( |
|
439 | + ); |
|
440 | + $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array( |
|
441 | 441 | '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'), |
442 | 442 | '#type' => 'textfield', |
443 | 443 | '#field_suffix' => 'Kbytes/sec', |
444 | 444 | '#default_value' => $default['max_bytes_sec_down']/1000, |
445 | 445 | '#size' => 1, |
446 | 446 | '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
447 | - ); |
|
448 | - $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array( |
|
447 | + ); |
|
448 | + $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array( |
|
449 | 449 | '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'), |
450 | 450 | '#type' => 'textfield', |
451 | 451 | '#field_suffix' => 'Kbytes/sec', |
452 | 452 | '#default_value' => $default['max_bytes_sec_up']/1000, |
453 | 453 | '#size' => 1, |
454 | 454 | '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
455 | - ); |
|
456 | - $form['prefs']['advanced']['network']['hour_label'] = array( |
|
455 | + ); |
|
456 | + $form['prefs']['advanced']['network']['hour_label'] = array( |
|
457 | 457 | '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
458 | - ); |
|
459 | - $form['prefs']['advanced']['network']['net_start_hour'] = array( |
|
458 | + ); |
|
459 | + $form['prefs']['advanced']['network']['net_start_hour'] = array( |
|
460 | 460 | '#type' => 'select', |
461 | 461 | '#options' => $form['hour_options']['#value'], |
462 | 462 | '#default_value' => $default['net_start_hour'] |
463 | - ); |
|
464 | - $form['prefs']['advanced']['network']['hour_delimiter'] = array( |
|
463 | + ); |
|
464 | + $form['prefs']['advanced']['network']['hour_delimiter'] = array( |
|
465 | 465 | '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
466 | - ); |
|
467 | - $form['prefs']['advanced']['network']['net_end_hour'] = array( |
|
466 | + ); |
|
467 | + $form['prefs']['advanced']['network']['net_end_hour'] = array( |
|
468 | 468 | '#type' => 'select', |
469 | 469 | '#options' => $form['hour_options']['#value'], |
470 | 470 | '#default_value' => $default['net_end_hour'] |
471 | - ); |
|
472 | - $form['prefs']['advanced']['network']['hour_description'] = array( |
|
471 | + ); |
|
472 | + $form['prefs']['advanced']['network']['hour_description'] = array( |
|
473 | 473 | '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
474 | - ); |
|
475 | - $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array( |
|
474 | + ); |
|
475 | + $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array( |
|
476 | 476 | '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'), |
477 | 477 | '#type' => 'textfield', |
478 | 478 | '#field_suffix' => 'Mbytes', |
479 | 479 | '#default_value' => $default['daily_xfer_limit_mb'], |
480 | 480 | '#size' => 1 |
481 | - ); |
|
482 | - $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array( |
|
481 | + ); |
|
482 | + $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array( |
|
483 | 483 | '#field_prefix' => 'every', |
484 | 484 | '#type' => 'textfield', |
485 | 485 | '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'), |
486 | 486 | '#default_value' => $default['daily_xfer_period_days'], |
487 | 487 | '#size' => 1, |
488 | 488 | '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'), |
489 | - ); |
|
490 | - $form['prefs']['advanced']['network']['dont_verify_images'] = array( |
|
489 | + ); |
|
490 | + $form['prefs']['advanced']['network']['dont_verify_images'] = array( |
|
491 | 491 | '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'), |
492 | 492 | '#type' => 'radios', |
493 | 493 | '#options' => $form['boolean_options']['#value'], |
494 | 494 | '#attributes' => array('class' => 'fancy'), |
495 | 495 | '#default_value' => $default['dont_verify_images'], |
496 | 496 | '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing') |
497 | - ); |
|
497 | + ); |
|
498 | 498 | |
499 | - // The "fancy radios" are made via javascript on document load. In order for |
|
500 | - // these to work with AHAH, we need this crazy setTimeout() call. |
|
501 | - $form['prefs']['fancy-radios'] = array( |
|
499 | + // The "fancy radios" are made via javascript on document load. In order for |
|
500 | + // these to work with AHAH, we need this crazy setTimeout() call. |
|
501 | + $form['prefs']['fancy-radios'] = array( |
|
502 | 502 | '#value' => ' |
503 | 503 | <script> |
504 | 504 | setTimeout( |
@@ -509,177 +509,177 @@ discard block |
||
509 | 509 | 300 |
510 | 510 | ) |
511 | 511 | </script>' |
512 | - ); |
|
513 | - $form['prefs']['view advanced'] = array( |
|
512 | + ); |
|
513 | + $form['prefs']['view advanced'] = array( |
|
514 | 514 | '#type' => 'hidden', |
515 | 515 | '#value' => 1 |
516 | - ); |
|
516 | + ); |
|
517 | 517 | |
518 | - $form['prefs']['separator_bottom'] = array( |
|
518 | + $form['prefs']['separator_bottom'] = array( |
|
519 | 519 | '#value' => '<div class="separator buttons"></div>' |
520 | - ); |
|
520 | + ); |
|
521 | 521 | |
522 | - // Form control |
|
523 | - $form['prefs']['form control tabs prefix'] = array( |
|
522 | + // Form control |
|
523 | + $form['prefs']['form control tabs prefix'] = array( |
|
524 | 524 | '#value' => '<ul class="form-control tab-list">' |
525 | - ); |
|
526 | - $form['prefs']['submit'] = array( |
|
525 | + ); |
|
526 | + $form['prefs']['submit'] = array( |
|
527 | 527 | '#prefix' => '<li class="first tab">', |
528 | 528 | '#type' => 'submit', |
529 | 529 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
530 | 530 | '#suffix' => '</li>' |
531 | - ); |
|
532 | - $form['prefs']['form control tabs'] = array( |
|
531 | + ); |
|
532 | + $form['prefs']['form control tabs'] = array( |
|
533 | 533 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>' |
534 | - ); |
|
535 | - if ($venue AND $venue != 'generic') { |
|
534 | + ); |
|
535 | + if ($venue AND $venue != 'generic') { |
|
536 | 536 | global $base_path; |
537 | 537 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
538 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
|
538 | + l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
|
539 | 539 | array( |
540 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
|
541 | - 'attributes' => array( |
|
540 | + 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
|
541 | + 'attributes' => array( |
|
542 | 542 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
543 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
544 | - ) |
|
543 | + array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
544 | + ) |
|
545 | 545 | ) |
546 | - ) . '</li>'; |
|
547 | - } |
|
548 | - $form['prefs']['view control'] = array( |
|
546 | + ) . '</li>'; |
|
547 | + } |
|
548 | + $form['prefs']['view control'] = array( |
|
549 | 549 | '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>' |
550 | - ); |
|
551 | - $form['prefs']['form control tabs suffix'] = array( |
|
550 | + ); |
|
551 | + $form['prefs']['form control tabs suffix'] = array( |
|
552 | 552 | '#value' => '</ul>' |
553 | - ); |
|
554 | - $form['#submit'][] = 'boincwork_generalprefs_form_submit'; |
|
553 | + ); |
|
554 | + $form['#submit'][] = 'boincwork_generalprefs_form_submit'; |
|
555 | 555 | |
556 | - return $form; |
|
556 | + return $form; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
560 | - * Validate the general preferences form. |
|
561 | - */ |
|
560 | + * Validate the general preferences form. |
|
561 | + */ |
|
562 | 562 | function boincwork_generalprefs_form_validate($form, &$form_state) { |
563 | - require_boinc('util'); |
|
564 | - $values = $form_state['values']['prefs']['advanced']; |
|
565 | - |
|
566 | - //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>'); |
|
567 | - // Verify all non-boolean user input values and notify form API of failures |
|
568 | - |
|
569 | - // Processing preferences |
|
570 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
571 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
572 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
573 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
574 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
575 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
576 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
577 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
578 | - |
|
579 | - // Storage preferences |
|
580 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
581 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
582 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
583 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
584 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
585 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
586 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
587 | - |
|
588 | - // Network preferences |
|
589 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
590 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
591 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
592 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
593 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing')); |
|
594 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
595 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
596 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
563 | + require_boinc('util'); |
|
564 | + $values = $form_state['values']['prefs']['advanced']; |
|
565 | + |
|
566 | + //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>'); |
|
567 | + // Verify all non-boolean user input values and notify form API of failures |
|
568 | + |
|
569 | + // Processing preferences |
|
570 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
571 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
572 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
573 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
574 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
575 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
576 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
577 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
578 | + |
|
579 | + // Storage preferences |
|
580 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
581 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
582 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
583 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
584 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
585 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
586 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
587 | + |
|
588 | + // Network preferences |
|
589 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
590 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
591 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
592 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
593 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing')); |
|
594 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
595 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
596 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
600 | - * Handle post-validation submission of general preferences form. |
|
601 | - */ |
|
600 | + * Handle post-validation submission of general preferences form. |
|
601 | + */ |
|
602 | 602 | function boincwork_generalprefs_form_submit($form, &$form_state) { |
603 | - global $user; |
|
604 | - $account = user_load($user->uid); |
|
605 | - |
|
606 | - $values = $form_state['values']['prefs']['advanced']; |
|
607 | - $venue = $form_state['values']['prefs']['venue']; |
|
608 | - $preset = $form_state['values']['prefs']['preset']; |
|
609 | - |
|
610 | - // Load preferences from BOINC account |
|
611 | - $prefs = boincwork_load_prefs('general', $venue); |
|
612 | - |
|
613 | - // Processing preferences |
|
614 | - $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
615 | - $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
616 | - $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1; |
|
617 | - $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
618 | - $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
619 | - $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
620 | - $prefs['start_hour'] = $values['processor']['start_hour']; |
|
621 | - $prefs['end_hour'] = $values['processor']['end_hour']; |
|
622 | - $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
623 | - $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
624 | - $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
625 | - $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
626 | - |
|
627 | - // Storage preferences |
|
628 | - $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
629 | - $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
630 | - $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
631 | - $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
632 | - $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
633 | - $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
634 | - $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
635 | - |
|
636 | - // Network preferences |
|
637 | - $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
638 | - $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
639 | - $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
640 | - $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
641 | - $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
642 | - $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
643 | - $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
644 | - $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
645 | - $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
646 | - $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
647 | - $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
648 | - |
|
649 | - // transform old way to store the preset into new way |
|
650 | - // ideally this should already have happened in boincwork_generalprefs_form() |
|
651 | - if (isset($prefs['@attributes']['preset'])) { |
|
603 | + global $user; |
|
604 | + $account = user_load($user->uid); |
|
605 | + |
|
606 | + $values = $form_state['values']['prefs']['advanced']; |
|
607 | + $venue = $form_state['values']['prefs']['venue']; |
|
608 | + $preset = $form_state['values']['prefs']['preset']; |
|
609 | + |
|
610 | + // Load preferences from BOINC account |
|
611 | + $prefs = boincwork_load_prefs('general', $venue); |
|
612 | + |
|
613 | + // Processing preferences |
|
614 | + $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
615 | + $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
616 | + $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1; |
|
617 | + $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
618 | + $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
619 | + $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
620 | + $prefs['start_hour'] = $values['processor']['start_hour']; |
|
621 | + $prefs['end_hour'] = $values['processor']['end_hour']; |
|
622 | + $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
623 | + $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
624 | + $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
625 | + $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
626 | + |
|
627 | + // Storage preferences |
|
628 | + $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
629 | + $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
630 | + $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
631 | + $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
632 | + $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
633 | + $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
634 | + $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
635 | + |
|
636 | + // Network preferences |
|
637 | + $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
638 | + $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
639 | + $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
640 | + $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
641 | + $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
642 | + $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
643 | + $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
644 | + $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
645 | + $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
646 | + $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
647 | + $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
648 | + |
|
649 | + // transform old way to store the preset into new way |
|
650 | + // ideally this should already have happened in boincwork_generalprefs_form() |
|
651 | + if (isset($prefs['@attributes']['preset'])) { |
|
652 | 652 | $prefs['preset'] = $prefs['@attributes']['preset']; |
653 | 653 | unset($prefs['@attributes']['preset']); |
654 | - } |
|
655 | - // Save the preset selection (or lack thereof) |
|
656 | - if (!$preset OR $preset == 'custom') { |
|
654 | + } |
|
655 | + // Save the preset selection (or lack thereof) |
|
656 | + if (!$preset OR $preset == 'custom') { |
|
657 | 657 | $prefs['preset'] = 'custom'; |
658 | - } |
|
659 | - else { |
|
658 | + } |
|
659 | + else { |
|
660 | 660 | $prefs['preset'] = $preset; |
661 | - } |
|
661 | + } |
|
662 | 662 | |
663 | - // If this is a new preference set, be sure to unset the "cleared" attribute |
|
664 | - if (isset($prefs['@attributes']['cleared'])) { |
|
663 | + // If this is a new preference set, be sure to unset the "cleared" attribute |
|
664 | + if (isset($prefs['@attributes']['cleared'])) { |
|
665 | 665 | unset($prefs['@attributes']['cleared']); |
666 | - } |
|
666 | + } |
|
667 | 667 | |
668 | - // Update database |
|
669 | - $result = boincwork_save_prefs($prefs, 'general', $venue); |
|
668 | + // Update database |
|
669 | + $result = boincwork_save_prefs($prefs, 'general', $venue); |
|
670 | 670 | |
671 | - if (!$result) { |
|
671 | + if (!$result) { |
|
672 | 672 | watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
673 | 673 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
674 | - } |
|
675 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
674 | + } |
|
675 | + elseif (!drupal_get_messages('status', FALSE)) { |
|
676 | 676 | // Show this message if the set wasn't created automatically (in which case |
677 | 677 | // there is a message tailored to that) { |
678 | 678 | drupal_set_message(t('Your preferences have been updated. |
679 | 679 | Client-related preferences will take effect when your computer |
680 | 680 | communicates with @project or you issue the "Update" |
681 | 681 | command from the BOINC client.', array('@project' => PROJECT))); |
682 | - } |
|
682 | + } |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | |
@@ -691,116 +691,116 @@ discard block |
||
691 | 691 | * Find compatible hosts for merging |
692 | 692 | */ |
693 | 693 | function boincwork_host_get_compatible_hosts($host_id) { |
694 | - require_boinc('host'); |
|
695 | - global $user; |
|
696 | - $account = user_load($user->uid); |
|
697 | - $compatible_hosts = array(); |
|
698 | - $host_count = 0; |
|
699 | - db_set_active('boinc_ro'); |
|
700 | - $current_host = db_fetch_object(db_query(" |
|
694 | + require_boinc('host'); |
|
695 | + global $user; |
|
696 | + $account = user_load($user->uid); |
|
697 | + $compatible_hosts = array(); |
|
698 | + $host_count = 0; |
|
699 | + db_set_active('boinc_ro'); |
|
700 | + $current_host = db_fetch_object(db_query(" |
|
701 | 701 | SELECT id, domain_name, create_time, total_credit, rpc_time, os_name, |
702 | 702 | p_vendor, p_model |
703 | 703 | FROM {host} |
704 | 704 | WHERE userid = '%d' AND id = '%d'", |
705 | 705 | $account->boincuser_id, $host_id |
706 | - )); |
|
707 | - db_set_active('default'); |
|
708 | - $current_host->task_count = boincwork_host_get_task_count($current_host->id); |
|
709 | - $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count; |
|
710 | - // Get the list of all other hosts owned by this user for comparison |
|
711 | - db_set_active('boinc_ro'); |
|
712 | - $all_other_hosts = db_query(" |
|
706 | + )); |
|
707 | + db_set_active('default'); |
|
708 | + $current_host->task_count = boincwork_host_get_task_count($current_host->id); |
|
709 | + $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count; |
|
710 | + // Get the list of all other hosts owned by this user for comparison |
|
711 | + db_set_active('boinc_ro'); |
|
712 | + $all_other_hosts = db_query(" |
|
713 | 713 | SELECT id, domain_name, create_time, total_credit, rpc_time, os_name, |
714 | 714 | p_vendor, p_model |
715 | 715 | FROM {host} |
716 | 716 | WHERE userid = '%d' AND id <> '%d'", |
717 | 717 | $account->boincuser_id, $host_id |
718 | - ); |
|
719 | - db_set_active('default'); |
|
720 | - // Compare all hosts to see if any are plausible duplicates |
|
721 | - while ($other_host = db_fetch_object($all_other_hosts)) { |
|
718 | + ); |
|
719 | + db_set_active('default'); |
|
720 | + // Compare all hosts to see if any are plausible duplicates |
|
721 | + while ($other_host = db_fetch_object($all_other_hosts)) { |
|
722 | 722 | // First, disqualify if hosts were active at the same time |
723 | 723 | if (!$current_host->is_new) { |
724 | - $other_host->task_count = boincwork_host_get_task_count($other_host->id); |
|
725 | - $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count; |
|
726 | - if (!$other_host->is_new) { |
|
724 | + $other_host->task_count = boincwork_host_get_task_count($other_host->id); |
|
725 | + $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count; |
|
726 | + if (!$other_host->is_new) { |
|
727 | 727 | // If both hosts being compared are not new, see if times overlap |
728 | 728 | if (!times_disjoint($current_host, $other_host)) { |
729 | - // Hosts were active at the same time; can't be a duplicate |
|
730 | - continue; |
|
729 | + // Hosts were active at the same time; can't be a duplicate |
|
730 | + continue; |
|
731 | + } |
|
731 | 732 | } |
732 | - } |
|
733 | 733 | } |
734 | 734 | // Next, disqualify if hosts have different OS platforms |
735 | 735 | if (!os_compatible($current_host, $other_host)) { |
736 | - // Hosts have different OS platforms; not really a duplicate |
|
737 | - continue; |
|
736 | + // Hosts have different OS platforms; not really a duplicate |
|
737 | + continue; |
|
738 | 738 | } |
739 | 739 | // Finally, disqualify if hosts have different CPUs |
740 | 740 | if (!cpus_compatible($current_host, $other_host)) { |
741 | - // CPUs don't match; not a duplicate |
|
742 | - continue; |
|
741 | + // CPUs don't match; not a duplicate |
|
742 | + continue; |
|
743 | 743 | } |
744 | 744 | // If not disqualified, this host is available for merging |
745 | 745 | $hosts[] = $other_host; |
746 | 746 | $host_count++; |
747 | 747 | if ($host_count == 500) { |
748 | - // This is enough! |
|
749 | - break; |
|
748 | + // This is enough! |
|
749 | + break; |
|
750 | + } |
|
750 | 751 | } |
751 | - } |
|
752 | - return $hosts; |
|
752 | + return $hosts; |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Perform the database updates to merge the old host into the new host |
757 | 757 | */ |
758 | 758 | function boincwork_host_merge($old_host, $new_host, &$message = NULL) { |
759 | - // Decay the average credit of the two hosts |
|
760 | - require_boinc('credit'); |
|
761 | - $now = time(); |
|
762 | - update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time); |
|
763 | - update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time); |
|
759 | + // Decay the average credit of the two hosts |
|
760 | + require_boinc('credit'); |
|
761 | + $now = time(); |
|
762 | + update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time); |
|
763 | + update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time); |
|
764 | 764 | |
765 | - // Update the database: |
|
766 | - // - add credit from old host to new host |
|
767 | - // - change results to refer to the new host |
|
768 | - // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id]) |
|
765 | + // Update the database: |
|
766 | + // - add credit from old host to new host |
|
767 | + // - change results to refer to the new host |
|
768 | + // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id]) |
|
769 | 769 | |
770 | - $total_credit = $old_host->total_credit + $new_host->total_credit; |
|
771 | - $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit; |
|
770 | + $total_credit = $old_host->total_credit + $new_host->total_credit; |
|
771 | + $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit; |
|
772 | 772 | |
773 | - if ($new_host->rpc_seqno == $old_host->id) { |
|
773 | + if ($new_host->rpc_seqno == $old_host->id) { |
|
774 | 774 | rules_invoke_event('boincwork_circular_merge_error', $old_host->id, $new_host->id, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
775 | 775 | watchdog('boincwork', |
776 | - 'Circular merge attempted, target host rpc_seqno is equal to old host\'s id: old host id=%old_host, target host id=%new_host', |
|
777 | - array( |
|
776 | + 'Circular merge attempted, target host rpc_seqno is equal to old host\'s id: old host id=%old_host, target host id=%new_host', |
|
777 | + array( |
|
778 | 778 | '%old_host' => $old_host->id, |
779 | 779 | '%new_host' => $new_host->id, |
780 | - ), |
|
781 | - WATCHDOG_WARNING |
|
780 | + ), |
|
781 | + WATCHDOG_WARNING |
|
782 | 782 | ); |
783 | 783 | $message = 'Could not merge due to a circular merge error. The site administrators have been contacted about this issue, and will investigate further.'; |
784 | 784 | return FALSE; |
785 | - } |
|
785 | + } |
|
786 | 786 | |
787 | - if ($new_host->userid==0) { |
|
787 | + if ($new_host->userid==0) { |
|
788 | 788 | rules_invoke_event('boincwork_zombie_merge_error', $old_host->id, $new_host->id, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
789 | 789 | watchdog('boincwork', |
790 | - 'Zombie merge attempted, target host has userid=0: old host id=%old_host, target host id=%new_host', |
|
791 | - array( |
|
790 | + 'Zombie merge attempted, target host has userid=0: old host id=%old_host, target host id=%new_host', |
|
791 | + array( |
|
792 | 792 | '%old_host' => $old_host->id, |
793 | 793 | '%new_host' => $new_host->id, |
794 | - ), |
|
795 | - WATCHDOG_WARNING |
|
794 | + ), |
|
795 | + WATCHDOG_WARNING |
|
796 | 796 | ); |
797 | 797 | $message = 'Could not merge because the target host has userid=0. The site administrators have been contacted about this issue, and will investigate further.'; |
798 | 798 | return FALSE; |
799 | - } |
|
799 | + } |
|
800 | 800 | |
801 | - // Move credit from the old host to the new host |
|
802 | - db_set_active('boinc_rw'); |
|
803 | - $credit_updated = db_query(" |
|
801 | + // Move credit from the old host to the new host |
|
802 | + db_set_active('boinc_rw'); |
|
803 | + $credit_updated = db_query(" |
|
804 | 804 | UPDATE {host} |
805 | 805 | SET |
806 | 806 | total_credit = '%d', |
@@ -808,34 +808,34 @@ discard block |
||
808 | 808 | expavg_time = '%d' |
809 | 809 | WHERE id = '%d'", |
810 | 810 | $total_credit, $recent_credit, $now, $new_host->id |
811 | - ); |
|
812 | - db_set_active('default'); |
|
813 | - if (!$credit_updated) { |
|
811 | + ); |
|
812 | + db_set_active('default'); |
|
813 | + if (!$credit_updated) { |
|
814 | 814 | if ($message !== NULL) { |
815 | - $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
815 | + $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
816 | 816 | } |
817 | 817 | return FALSE; |
818 | - } |
|
818 | + } |
|
819 | 819 | |
820 | - // Move results from the old host to the new host |
|
821 | - db_set_active('boinc_rw'); |
|
822 | - $results_updated = db_query(" |
|
820 | + // Move results from the old host to the new host |
|
821 | + db_set_active('boinc_rw'); |
|
822 | + $results_updated = db_query(" |
|
823 | 823 | UPDATE {result} |
824 | 824 | SET hostid = '%d' |
825 | 825 | WHERE hostid = '%d'", |
826 | 826 | $new_host->id, $old_host->id |
827 | - ); |
|
828 | - db_set_active('default'); |
|
829 | - if (!$results_updated) { |
|
827 | + ); |
|
828 | + db_set_active('default'); |
|
829 | + if (!$results_updated) { |
|
830 | 830 | if ($message !== NULL) { |
831 | - $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
831 | + $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
832 | 832 | } |
833 | 833 | return FALSE; |
834 | - } |
|
834 | + } |
|
835 | 835 | |
836 | - // Retire the old host |
|
837 | - db_set_active('boinc_rw'); |
|
838 | - $old_host_retired = db_query(" |
|
836 | + // Retire the old host |
|
837 | + db_set_active('boinc_rw'); |
|
838 | + $old_host_retired = db_query(" |
|
839 | 839 | UPDATE {host} |
840 | 840 | SET |
841 | 841 | total_credit = '0', |
@@ -844,16 +844,16 @@ discard block |
||
844 | 844 | rpc_seqno = '%d' |
845 | 845 | WHERE id = '%d'", |
846 | 846 | $new_host->id, $old_host->id |
847 | - ); |
|
848 | - db_set_active('default'); |
|
849 | - if (!$old_host_retired) { |
|
847 | + ); |
|
848 | + db_set_active('default'); |
|
849 | + if (!$old_host_retired) { |
|
850 | 850 | if ($message !== NULL) { |
851 | - $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
851 | + $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
852 | 852 | } |
853 | 853 | return FALSE; |
854 | - } |
|
854 | + } |
|
855 | 855 | |
856 | - return TRUE; |
|
856 | + return TRUE; |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -861,75 +861,75 @@ discard block |
||
861 | 861 | */ |
862 | 862 | function boincwork_host_merge_form(&$form_state, $host_id) { |
863 | 863 | |
864 | - if (!boincwork_host_user_is_owner($host_id)) { |
|
864 | + if (!boincwork_host_user_is_owner($host_id)) { |
|
865 | 865 | drupal_goto("host/{$host_id}"); |
866 | - } |
|
866 | + } |
|
867 | 867 | |
868 | - $form = array(); |
|
869 | - $form_state['storage']['current_host_id'] = $host_id; |
|
870 | - $current_host = boincwork_host_get_info($host_id); |
|
868 | + $form = array(); |
|
869 | + $form_state['storage']['current_host_id'] = $host_id; |
|
870 | + $current_host = boincwork_host_get_info($host_id); |
|
871 | 871 | |
872 | - // Get hosts that could be merged with this one |
|
873 | - $hosts = boincwork_host_get_compatible_hosts($host_id); |
|
872 | + // Get hosts that could be merged with this one |
|
873 | + $hosts = boincwork_host_get_compatible_hosts($host_id); |
|
874 | 874 | |
875 | - if (!$hosts) { |
|
875 | + if (!$hosts) { |
|
876 | 876 | drupal_set_message(t('There are no computers eligible for merging with this |
877 | 877 | one'), 'warning' |
878 | 878 | ); |
879 | 879 | drupal_goto("host/{$host_id}"); |
880 | - } |
|
880 | + } |
|
881 | 881 | |
882 | - $form['overview'] = array( |
|
882 | + $form['overview'] = array( |
|
883 | 883 | '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to' |
884 | - . ' the same computer by mistake. You can correct this by merging old' |
|
885 | - . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
886 | - . '<p>' |
|
887 | - . bts('Check the computers that are the same as @name' |
|
888 | - . ' (created on @date at @time with computer ID @id)', |
|
884 | + . ' the same computer by mistake. You can correct this by merging old' |
|
885 | + . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
886 | + . '<p>' |
|
887 | + . bts('Check the computers that are the same as @name' |
|
888 | + . ' (created on @date at @time with computer ID @id)', |
|
889 | 889 | array( |
890 | - '@name' => $current_host->domain_name, |
|
891 | - '@date' => date('j M Y', $current_host->create_time), |
|
892 | - '@time' => date('G:i:s T', $current_host->create_time), |
|
893 | - '@id' => $current_host->id, |
|
890 | + '@name' => $current_host->domain_name, |
|
891 | + '@date' => date('j M Y', $current_host->create_time), |
|
892 | + '@time' => date('G:i:s T', $current_host->create_time), |
|
893 | + '@id' => $current_host->id, |
|
894 | 894 | ), |
895 | 895 | NULL, 'boinc:account-host-merge') . '</p>', |
896 | - ); |
|
896 | + ); |
|
897 | 897 | |
898 | - $options = array(); |
|
899 | - foreach ($hosts as $host) { |
|
898 | + $options = array(); |
|
899 | + foreach ($hosts as $host) { |
|
900 | 900 | $options[$host->id] = array( |
901 | - $host->domain_name, |
|
902 | - date('j M Y G:i:s T', $host->create_time), |
|
903 | - $host->id, |
|
901 | + $host->domain_name, |
|
902 | + date('j M Y G:i:s T', $host->create_time), |
|
903 | + $host->id, |
|
904 | 904 | ); |
905 | - } |
|
905 | + } |
|
906 | 906 | |
907 | - $form['merge'] = array( |
|
907 | + $form['merge'] = array( |
|
908 | 908 | '#title' => '', |
909 | 909 | '#type' => 'tableselect', |
910 | 910 | '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')), |
911 | 911 | '#options' => $options, |
912 | - ); |
|
912 | + ); |
|
913 | 913 | |
914 | - $form['prefs']['separator_bottom'] = array( |
|
915 | - // '#value' => '<div class="separator buttons"></div>' |
|
916 | - ); |
|
914 | + $form['prefs']['separator_bottom'] = array( |
|
915 | + // '#value' => '<div class="separator buttons"></div>' |
|
916 | + ); |
|
917 | 917 | |
918 | - // Form control |
|
919 | - $form['prefs']['form control tabs prefix'] = array( |
|
918 | + // Form control |
|
919 | + $form['prefs']['form control tabs prefix'] = array( |
|
920 | 920 | '#value' => '<ul class="form-control tab-list">' |
921 | - ); |
|
922 | - $form['prefs']['submit'] = array( |
|
921 | + ); |
|
922 | + $form['prefs']['submit'] = array( |
|
923 | 923 | '#prefix' => '<li class="first tab">', |
924 | 924 | '#type' => 'submit', |
925 | 925 | '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'), |
926 | 926 | '#suffix' => '</li>' |
927 | - ); |
|
928 | - $form['prefs']['form control tabs'] = array( |
|
927 | + ); |
|
928 | + $form['prefs']['form control tabs'] = array( |
|
929 | 929 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
930 | - ); |
|
930 | + ); |
|
931 | 931 | |
932 | - return $form; |
|
932 | + return $form; |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -942,76 +942,76 @@ discard block |
||
942 | 942 | * Handle submission of the merge host form |
943 | 943 | */ |
944 | 944 | function boincwork_host_merge_form_submit($form, &$form_state) { |
945 | - $merged = array(); |
|
946 | - $errors = array(); |
|
947 | - $current_host_id = $form_state['storage']['current_host_id']; |
|
948 | - $current_host = boincwork_host_get_info($current_host_id); |
|
949 | - $selected_hosts = array_filter($form_state['values']['merge']); |
|
945 | + $merged = array(); |
|
946 | + $errors = array(); |
|
947 | + $current_host_id = $form_state['storage']['current_host_id']; |
|
948 | + $current_host = boincwork_host_get_info($current_host_id); |
|
949 | + $selected_hosts = array_filter($form_state['values']['merge']); |
|
950 | 950 | |
951 | - foreach ($selected_hosts as $host_id) { |
|
951 | + foreach ($selected_hosts as $host_id) { |
|
952 | 952 | // Attempt to merge each host, noting the results |
953 | 953 | $message = ''; |
954 | 954 | $old_host = boincwork_host_get_info($host_id); |
955 | 955 | if (boincwork_host_merge($old_host, $current_host, $message)) { |
956 | - $merged[$old_host->id] = $old_host->id; |
|
957 | - $current_host = boincwork_host_get_info($current_host_id); |
|
956 | + $merged[$old_host->id] = $old_host->id; |
|
957 | + $current_host = boincwork_host_get_info($current_host_id); |
|
958 | 958 | } |
959 | 959 | else { |
960 | - $errors[$old_host->id] = $message; |
|
960 | + $errors[$old_host->id] = $message; |
|
961 | + } |
|
961 | 962 | } |
962 | - } |
|
963 | 963 | |
964 | - if ($merged) { |
|
964 | + if ($merged) { |
|
965 | 965 | // Generate a natural language list of IDs that were merged |
966 | 966 | $oxford_comma = ','; |
967 | 967 | $conjunction = bts('and', array(), NULL, 'boinc:account-preference'); |
968 | 968 | $list = array_keys($merged); |
969 | 969 | $last = array_pop($list); |
970 | 970 | if ($list) { |
971 | - if (count($merged) == 2) { |
|
971 | + if (count($merged) == 2) { |
|
972 | 972 | $oxford_comma = ''; |
973 | - } |
|
974 | - $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
973 | + } |
|
974 | + $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
975 | 975 | } |
976 | 976 | else { |
977 | - $list = $last; |
|
977 | + $list = $last; |
|
978 | 978 | } |
979 | 979 | if (count($merged) == 1) { |
980 | - drupal_set_message(bts( |
|
980 | + drupal_set_message(bts( |
|
981 | 981 | 'Computer @old_id has been merged successfully into @id.', |
982 | 982 | array( |
983 | - '@old_id' => $list, |
|
984 | - '@id' => $current_host_id |
|
983 | + '@old_id' => $list, |
|
984 | + '@id' => $current_host_id |
|
985 | 985 | ), |
986 | 986 | NULL, 'boinc:account-host-merge')); |
987 | 987 | } |
988 | 988 | else { |
989 | - drupal_set_message(bts( |
|
989 | + drupal_set_message(bts( |
|
990 | 990 | 'Computers @old_ids have been merged successfully into @id.', |
991 | 991 | array( |
992 | - '@old_ids' => $list, |
|
993 | - '@id' => $current_host_id |
|
992 | + '@old_ids' => $list, |
|
993 | + '@id' => $current_host_id |
|
994 | 994 | ), |
995 | 995 | NULL, 'boinc:account-host-merge')); |
996 | 996 | } |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | - if ($errors) { |
|
999 | + if ($errors) { |
|
1000 | 1000 | // Report any hosts that failed to merge |
1001 | 1001 | foreach ($errors as $id => $error) { |
1002 | - drupal_set_message( |
|
1002 | + drupal_set_message( |
|
1003 | 1003 | bts('Computer @old_id failed to merge: @message', |
1004 | - array( |
|
1004 | + array( |
|
1005 | 1005 | '@old_id' => $id, |
1006 | 1006 | '@message' => $error, |
1007 | - ), |
|
1008 | - NULL, 'boinc:account-host-merge'), |
|
1007 | + ), |
|
1008 | + NULL, 'boinc:account-host-merge'), |
|
1009 | 1009 | 'warning' |
1010 | - ); |
|
1010 | + ); |
|
1011 | + } |
|
1011 | 1012 | } |
1012 | - } |
|
1013 | 1013 | |
1014 | - drupal_goto("host/{$current_host_id}"); |
|
1014 | + drupal_goto("host/{$current_host_id}"); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1023,44 +1023,44 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | function boincwork_projectprefs_form(&$form_state, $venue) { |
1025 | 1025 | |
1026 | - global $user; |
|
1027 | - $account = user_load($user->uid); |
|
1026 | + global $user; |
|
1027 | + $account = user_load($user->uid); |
|
1028 | 1028 | |
1029 | - $established = TRUE; |
|
1029 | + $established = TRUE; |
|
1030 | 1030 | |
1031 | - // Get availability of special BOINC preferences |
|
1032 | - require_boinc(array('util')); |
|
1033 | - $app_types = get_app_types(); |
|
1031 | + // Get availability of special BOINC preferences |
|
1032 | + require_boinc(array('util')); |
|
1033 | + $app_types = get_app_types(); |
|
1034 | 1034 | |
1035 | - // Load any existing preferences from BOINC account |
|
1036 | - $prefs = boincwork_load_prefs('project', $venue); |
|
1035 | + // Load any existing preferences from BOINC account |
|
1036 | + $prefs = boincwork_load_prefs('project', $venue); |
|
1037 | 1037 | |
1038 | - // Take note if this is not an established preference set on the account |
|
1039 | - if (isset($prefs['@attributes']['cleared'])) { |
|
1038 | + // Take note if this is not an established preference set on the account |
|
1039 | + if (isset($prefs['@attributes']['cleared'])) { |
|
1040 | 1040 | $established = FALSE; |
1041 | - } |
|
1041 | + } |
|
1042 | 1042 | |
1043 | - // Extract modified tag if present |
|
1044 | - $modified = NULL; |
|
1045 | - if (isset($prefs['modified']['@value'])) { |
|
1043 | + // Extract modified tag if present |
|
1044 | + $modified = NULL; |
|
1045 | + if (isset($prefs['modified']['@value'])) { |
|
1046 | 1046 | $modified = $prefs['modified']['@value']; |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | |
1049 | - $venue_is_default = FALSE; |
|
1050 | - if ($account->boincuser_default_pref_set) { |
|
1049 | + $venue_is_default = FALSE; |
|
1050 | + if ($account->boincuser_default_pref_set) { |
|
1051 | 1051 | if ($account->boincuser_default_pref_set == $venue) { |
1052 | - $venue_is_default = TRUE; |
|
1052 | + $venue_is_default = TRUE; |
|
1053 | + } |
|
1053 | 1054 | } |
1054 | - } |
|
1055 | - elseif (!$venue OR $venue == 'generic') { |
|
1055 | + elseif (!$venue OR $venue == 'generic') { |
|
1056 | 1056 | $venue_is_default = TRUE; |
1057 | - } |
|
1058 | - else { |
|
1057 | + } |
|
1058 | + else { |
|
1059 | 1059 | $venue_is_default = FALSE; |
1060 | - } |
|
1060 | + } |
|
1061 | 1061 | |
1062 | - // Define form defaults |
|
1063 | - $default = array( |
|
1062 | + // Define form defaults |
|
1063 | + $default = array( |
|
1064 | 1064 | 'resource_share' => 100, |
1065 | 1065 | 'no_cpu' => 0, |
1066 | 1066 | 'no_cuda' => 0, |
@@ -1068,333 +1068,333 @@ discard block |
||
1068 | 1068 | 'no_intel_gpu' => 0, |
1069 | 1069 | 'default_venue' => $venue_is_default, |
1070 | 1070 | 'allow_beta_work' => $prefs['allow_beta_work'], |
1071 | - ); |
|
1072 | - foreach ($default as $name => $value) { |
|
1071 | + ); |
|
1072 | + foreach ($default as $name => $value) { |
|
1073 | 1073 | if (isset($prefs[$name])) { |
1074 | - if (is_array($prefs[$name])) { |
|
1074 | + if (is_array($prefs[$name])) { |
|
1075 | 1075 | if (isset($prefs[$name]['@value'])) { |
1076 | - $default[$name] = $prefs[$name]['@value']; |
|
1076 | + $default[$name] = $prefs[$name]['@value']; |
|
1077 | 1077 | } |
1078 | - } |
|
1079 | - else { |
|
1078 | + } |
|
1079 | + else { |
|
1080 | 1080 | $default[$name] = $prefs[$name]; |
1081 | - } |
|
1081 | + } |
|
1082 | + } |
|
1082 | 1083 | } |
1083 | - } |
|
1084 | 1084 | |
1085 | - // Standard option sets |
|
1086 | - $form['boolean_options'] = array( |
|
1085 | + // Standard option sets |
|
1086 | + $form['boolean_options'] = array( |
|
1087 | 1087 | '#type' => 'value', |
1088 | 1088 | '#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')) |
1089 | - ); |
|
1089 | + ); |
|
1090 | 1090 | |
1091 | - // Identify preference sets that are established to distinguish what has been |
|
1092 | - // saved to the database from what is just showing default values |
|
1093 | - $form['#established'] = $established; |
|
1091 | + // Identify preference sets that are established to distinguish what has been |
|
1092 | + // saved to the database from what is just showing default values |
|
1093 | + $form['#established'] = $established; |
|
1094 | 1094 | |
1095 | - // Top level form options |
|
1096 | - $form['#tree'] = TRUE; |
|
1095 | + // Top level form options |
|
1096 | + $form['#tree'] = TRUE; |
|
1097 | 1097 | |
1098 | - // Hidden elements |
|
1099 | - $form['modified'] = array( |
|
1098 | + // Hidden elements |
|
1099 | + $form['modified'] = array( |
|
1100 | 1100 | '#type' => 'hidden', |
1101 | 1101 | '#value' => $modified, |
1102 | - ); |
|
1103 | - $form['venue'] = array( |
|
1102 | + ); |
|
1103 | + $form['venue'] = array( |
|
1104 | 1104 | '#type' => 'hidden', |
1105 | 1105 | '#value' => $venue, |
1106 | - ); |
|
1106 | + ); |
|
1107 | 1107 | |
1108 | - $form['separator_top'] = array( |
|
1108 | + $form['separator_top'] = array( |
|
1109 | 1109 | '#value' => '<div class="separator"></div>' |
1110 | - ); |
|
1110 | + ); |
|
1111 | 1111 | |
1112 | - // Common project preferences |
|
1113 | - $form['resource'] = array( |
|
1112 | + // Common project preferences |
|
1113 | + $form['resource'] = array( |
|
1114 | 1114 | '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'), |
1115 | 1115 | '#type' => 'fieldset', |
1116 | 1116 | '#description' => null, |
1117 | 1117 | '#collapsible' => TRUE, |
1118 | 1118 | '#collapsed' => FALSE |
1119 | - ); |
|
1120 | - $form['resource']['resource_share'] = array( |
|
1119 | + ); |
|
1120 | + $form['resource']['resource_share'] = array( |
|
1121 | 1121 | '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'), |
1122 | 1122 | '#type' => 'textfield', |
1123 | 1123 | '#default_value' => $default['resource_share'], |
1124 | 1124 | '#size' => 5, |
1125 | 1125 | '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), NULL, 'boinc:account-preferences-project') |
1126 | - ); |
|
1127 | - if ($app_types->count > 1) { |
|
1126 | + ); |
|
1127 | + if ($app_types->count > 1) { |
|
1128 | 1128 | if ($app_types->cpu) { |
1129 | - $form['resource']['no_cpu'] = array( |
|
1129 | + $form['resource']['no_cpu'] = array( |
|
1130 | 1130 | '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'), |
1131 | 1131 | '#type' => 'radios', |
1132 | 1132 | '#options' => $form['boolean_options']['#value'], |
1133 | 1133 | '#attributes' => array('class' => 'fancy'), |
1134 | 1134 | '#default_value' => $default['no_cpu'] ? 0 : 1, |
1135 | 1135 | '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1136 | - ); |
|
1136 | + ); |
|
1137 | 1137 | } |
1138 | 1138 | if ($app_types->cuda) { |
1139 | - $form['resource']['no_cuda'] = array( |
|
1139 | + $form['resource']['no_cuda'] = array( |
|
1140 | 1140 | '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'), |
1141 | 1141 | '#type' => 'radios', |
1142 | 1142 | '#options' => $form['boolean_options']['#value'], |
1143 | 1143 | '#attributes' => array('class' => 'fancy'), |
1144 | 1144 | '#default_value' => $default['no_cuda'] ? 0 : 1, |
1145 | 1145 | '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1146 | - ); |
|
1146 | + ); |
|
1147 | 1147 | } |
1148 | 1148 | if ($app_types->ati) { |
1149 | - $form['resource']['no_ati'] = array( |
|
1149 | + $form['resource']['no_ati'] = array( |
|
1150 | 1150 | '#title' => bts('Use AMD GPU', array(), NULL, 'boinc:account-preferences-project'), |
1151 | 1151 | '#type' => 'radios', |
1152 | 1152 | '#options' => $form['boolean_options']['#value'], |
1153 | 1153 | '#attributes' => array('class' => 'fancy'), |
1154 | 1154 | '#default_value' => $default['no_ati'] ? 0 : 1, |
1155 | 1155 | '#description' => bts('Request AMD GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1156 | - ); |
|
1156 | + ); |
|
1157 | 1157 | } |
1158 | 1158 | if ($app_types->intel_gpu) { |
1159 | - $form['resource']['no_intel_gpu'] = array( |
|
1159 | + $form['resource']['no_intel_gpu'] = array( |
|
1160 | 1160 | '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'), |
1161 | 1161 | '#type' => 'radios', |
1162 | 1162 | '#options' => $form['boolean_options']['#value'], |
1163 | 1163 | '#attributes' => array('class' => 'fancy'), |
1164 | 1164 | '#default_value' => $default['no_intel_gpu'] ? 0 : 1, |
1165 | 1165 | '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1166 | - ); |
|
1166 | + ); |
|
1167 | + } |
|
1167 | 1168 | } |
1168 | - } |
|
1169 | 1169 | |
1170 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1170 | + if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1171 | 1171 | $form['beta'] = array( |
1172 | - '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1173 | - '#type' => 'fieldset', |
|
1174 | - '#description' => null, |
|
1175 | - '#collapsible' => TRUE, |
|
1176 | - '#collapsed' => FALSE |
|
1172 | + '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1173 | + '#type' => 'fieldset', |
|
1174 | + '#description' => null, |
|
1175 | + '#collapsible' => TRUE, |
|
1176 | + '#collapsed' => FALSE |
|
1177 | 1177 | ); |
1178 | 1178 | $form['beta']['allow_beta_work'] = array( |
1179 | - '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1180 | - '#type' => 'radios', |
|
1181 | - '#options' => $form['boolean_options']['#value'], |
|
1182 | - '#attributes' => array('class' => 'fancy'), |
|
1183 | - '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
|
1184 | - '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1179 | + '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1180 | + '#type' => 'radios', |
|
1181 | + '#options' => $form['boolean_options']['#value'], |
|
1182 | + '#attributes' => array('class' => 'fancy'), |
|
1183 | + '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
|
1184 | + '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1185 | 1185 | ); |
1186 | - } |
|
1186 | + } |
|
1187 | 1187 | |
1188 | - // Add project specific prefs to the form |
|
1189 | - boincwork_add_project_specific_prefs($form, $prefs); |
|
1188 | + // Add project specific prefs to the form |
|
1189 | + boincwork_add_project_specific_prefs($form, $prefs); |
|
1190 | 1190 | |
1191 | - // Set whether to use this preference set by default for new computers |
|
1192 | - $form['default_set'] = array( |
|
1191 | + // Set whether to use this preference set by default for new computers |
|
1192 | + $form['default_set'] = array( |
|
1193 | 1193 | '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'), |
1194 | 1194 | '#type' => 'fieldset', |
1195 | 1195 | '#description' => null, |
1196 | 1196 | '#collapsible' => TRUE, |
1197 | 1197 | '#collapsed' => FALSE |
1198 | - ); |
|
1199 | - $form['default_set']['default_venue'] = array( |
|
1198 | + ); |
|
1199 | + $form['default_set']['default_venue'] = array( |
|
1200 | 1200 | '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'), |
1201 | 1201 | '#type' => 'radios', |
1202 | 1202 | '#options' => $form['boolean_options']['#value'], |
1203 | 1203 | '#attributes' => array('class' => 'fancy'), |
1204 | 1204 | '#default_value' => $default['default_venue'] ? 1 : 0, |
1205 | 1205 | '#description' => '' |
1206 | - ); |
|
1206 | + ); |
|
1207 | 1207 | |
1208 | - $form['prefs']['separator_bottom'] = array( |
|
1208 | + $form['prefs']['separator_bottom'] = array( |
|
1209 | 1209 | '#value' => '<div class="separator buttons"></div>' |
1210 | - ); |
|
1210 | + ); |
|
1211 | 1211 | |
1212 | - // Form control |
|
1213 | - $form['prefs']['form control tabs prefix'] = array( |
|
1212 | + // Form control |
|
1213 | + $form['prefs']['form control tabs prefix'] = array( |
|
1214 | 1214 | '#value' => '<ul class="form-control tab-list">' |
1215 | - ); |
|
1216 | - $form['prefs']['submit'] = array( |
|
1215 | + ); |
|
1216 | + $form['prefs']['submit'] = array( |
|
1217 | 1217 | '#prefix' => '<li class="first tab">', |
1218 | 1218 | '#type' => 'submit', |
1219 | 1219 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1220 | 1220 | '#suffix' => '</li>' |
1221 | - ); |
|
1222 | - $form['prefs']['form control tabs'] = array( |
|
1221 | + ); |
|
1222 | + $form['prefs']['form control tabs'] = array( |
|
1223 | 1223 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
1224 | - ); |
|
1225 | - if ($venue AND $venue != 'generic') { |
|
1224 | + ); |
|
1225 | + if ($venue AND $venue != 'generic') { |
|
1226 | 1226 | global $base_path; |
1227 | 1227 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
1228 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1228 | + l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1229 | 1229 | array( |
1230 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1231 | - 'attributes' => array( |
|
1230 | + 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1231 | + 'attributes' => array( |
|
1232 | 1232 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
1233 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1234 | - ) |
|
1233 | + array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1234 | + ) |
|
1235 | 1235 | ) |
1236 | - ) . '</li>'; |
|
1237 | - } |
|
1238 | - $form['prefs']['view control'] = array( |
|
1239 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1240 | - ); |
|
1241 | - $form['prefs']['form control tabs suffix'] = array( |
|
1236 | + ) . '</li>'; |
|
1237 | + } |
|
1238 | + $form['prefs']['view control'] = array( |
|
1239 | + '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1240 | + ); |
|
1241 | + $form['prefs']['form control tabs suffix'] = array( |
|
1242 | 1242 | '#value' => '</ul>' |
1243 | - ); |
|
1243 | + ); |
|
1244 | 1244 | |
1245 | - return $form; |
|
1245 | + return $form; |
|
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | /** |
1249 | 1249 | * Add project specific preferences to the project preferences form |
1250 | 1250 | */ |
1251 | 1251 | function boincwork_add_project_specific_prefs(&$form, $prefs) { |
1252 | - // Load project specific preferences from XML config |
|
1253 | - $xml = boincwork_get_project_specific_config(); |
|
1252 | + // Load project specific preferences from XML config |
|
1253 | + $xml = boincwork_get_project_specific_config(); |
|
1254 | 1254 | |
1255 | - // Respect the order of the top level elements |
|
1256 | - $ordered_array = array(); |
|
1257 | - $unordered_array = array(); |
|
1258 | - foreach ($xml['project_specific_preferences'] as $type => $element) { |
|
1255 | + // Respect the order of the top level elements |
|
1256 | + $ordered_array = array(); |
|
1257 | + $unordered_array = array(); |
|
1258 | + foreach ($xml['project_specific_preferences'] as $type => $element) { |
|
1259 | 1259 | if (is_array($element) AND is_numeric(key($element))) { |
1260 | - foreach ($element as $ordered_element) { |
|
1260 | + foreach ($element as $ordered_element) { |
|
1261 | 1261 | if (isset($ordered_element['@position'])) { |
1262 | - $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
|
1262 | + $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
|
1263 | 1263 | } |
1264 | 1264 | else { |
1265 | - $unordered_array[] = array($type => $ordered_element); |
|
1265 | + $unordered_array[] = array($type => $ordered_element); |
|
1266 | + } |
|
1266 | 1267 | } |
1267 | - } |
|
1268 | 1268 | } |
1269 | 1269 | elseif (isset($element['@position'])) { |
1270 | - $ordered_array[$element['@position']] = array($type => $element); |
|
1270 | + $ordered_array[$element['@position']] = array($type => $element); |
|
1271 | 1271 | } |
1272 | 1272 | else { |
1273 | - $unordered_array[] = array($type => $element); |
|
1273 | + $unordered_array[] = array($type => $element); |
|
1274 | 1274 | } |
1275 | - } |
|
1276 | - ksort($ordered_array); |
|
1277 | - $primed_array = array_merge($ordered_array, $unordered_array); |
|
1278 | - $xml = array('project_specific_preferences' => $primed_array); |
|
1275 | + } |
|
1276 | + ksort($ordered_array); |
|
1277 | + $primed_array = array_merge($ordered_array, $unordered_array); |
|
1278 | + $xml = array('project_specific_preferences' => $primed_array); |
|
1279 | 1279 | |
1280 | - foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
|
1280 | + foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
|
1281 | 1281 | $type = key($wrapped_element); |
1282 | 1282 | $element= reset($wrapped_element); |
1283 | 1283 | boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']); |
1284 | - } |
|
1284 | + } |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | /** |
1288 | - * Validate the project preferences form. |
|
1289 | - */ |
|
1288 | + * Validate the project preferences form. |
|
1289 | + */ |
|
1290 | 1290 | function boincwork_projectprefs_form_validate($form, &$form_state) { |
1291 | 1291 | |
1292 | - // Verify all text user input values and notify form API of failures |
|
1293 | - $validation_rules = array( |
|
1292 | + // Verify all text user input values and notify form API of failures |
|
1293 | + $validation_rules = array( |
|
1294 | 1294 | 'resource' => array( |
1295 | - 'resource_share' => array( |
|
1295 | + 'resource_share' => array( |
|
1296 | 1296 | 'datatype' => 'integer', |
1297 | 1297 | 'min' => 0 |
1298 | - ), |
|
1298 | + ), |
|
1299 | 1299 | ), |
1300 | - ); |
|
1300 | + ); |
|
1301 | 1301 | |
1302 | - // Add validation rules for project specific settings |
|
1303 | - $validation_rules += boincwork_get_project_specific_config_validation_rules(); |
|
1302 | + // Add validation rules for project specific settings |
|
1303 | + $validation_rules += boincwork_get_project_specific_config_validation_rules(); |
|
1304 | 1304 | |
1305 | - // Perform validation |
|
1306 | - boincwork_validate_form($validation_rules, $form_state['values']); |
|
1305 | + // Perform validation |
|
1306 | + boincwork_validate_form($validation_rules, $form_state['values']); |
|
1307 | 1307 | |
1308 | - // Check for app validation |
|
1309 | - if (isset($validation_rules['apps'])) { |
|
1308 | + // Check for app validation |
|
1309 | + if (isset($validation_rules['apps'])) { |
|
1310 | 1310 | if (isset($validation_rules['apps']['minimum selected']) |
1311 | 1311 | AND $validation_rules['apps']['minimum selected'] > 0) { |
1312 | - $apps_selected = 0; |
|
1313 | - foreach ($validation_rules['apps']['list'] as $app) { |
|
1312 | + $apps_selected = 0; |
|
1313 | + foreach ($validation_rules['apps']['list'] as $app) { |
|
1314 | 1314 | if ($form_state['values']['applications'][$app]) $apps_selected++; |
1315 | - } |
|
1316 | - if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
|
1315 | + } |
|
1316 | + if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
|
1317 | 1317 | form_set_error( |
1318 | - 'applications', |
|
1319 | - bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1318 | + 'applications', |
|
1319 | + bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1320 | 1320 | ); |
1321 | - } |
|
1322 | - if ($apps_selected == count($validation_rules['apps']['list'])) { |
|
1321 | + } |
|
1322 | + if ($apps_selected == count($validation_rules['apps']['list'])) { |
|
1323 | 1323 | foreach ($validation_rules['apps']['list'] as $app) { |
1324 | - unset($form_state['values']['applications'][$app]); |
|
1324 | + unset($form_state['values']['applications'][$app]); |
|
1325 | 1325 | } |
1326 | 1326 | $form_state['storage']['all apps selected'] = TRUE; |
1327 | - } |
|
1327 | + } |
|
1328 | + } |
|
1328 | 1329 | } |
1329 | - } |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | /** |
1333 | - * Handle post-validation submission of project preferences form. |
|
1334 | - */ |
|
1333 | + * Handle post-validation submission of project preferences form. |
|
1334 | + */ |
|
1335 | 1335 | function boincwork_projectprefs_form_submit($form, &$form_state) { |
1336 | - global $user; |
|
1337 | - global $site_name; |
|
1336 | + global $user; |
|
1337 | + global $site_name; |
|
1338 | 1338 | |
1339 | - require_boinc(array('util')); |
|
1340 | - $app_types = get_app_types(); |
|
1339 | + require_boinc(array('util')); |
|
1340 | + $app_types = get_app_types(); |
|
1341 | 1341 | |
1342 | - $account = user_load($user->uid); |
|
1343 | - $edit = $form_state['values']; |
|
1344 | - $venue = $edit['venue']; |
|
1342 | + $account = user_load($user->uid); |
|
1343 | + $edit = $form_state['values']; |
|
1344 | + $venue = $edit['venue']; |
|
1345 | 1345 | |
1346 | - // Load preferences from BOINC account |
|
1347 | - $prefs = boincwork_load_prefs('project', $venue); |
|
1346 | + // Load preferences from BOINC account |
|
1347 | + $prefs = boincwork_load_prefs('project', $venue); |
|
1348 | 1348 | |
1349 | - // Resource preferences |
|
1350 | - $prefs['resource_share'] = $edit['resource']['resource_share']; |
|
1351 | - if ($app_types->count > 1) { |
|
1349 | + // Resource preferences |
|
1350 | + $prefs['resource_share'] = $edit['resource']['resource_share']; |
|
1351 | + if ($app_types->count > 1) { |
|
1352 | 1352 | if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1; |
1353 | 1353 | if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1; |
1354 | 1354 | if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1; |
1355 | 1355 | if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1; |
1356 | - } |
|
1356 | + } |
|
1357 | 1357 | |
1358 | - // Beta preferences |
|
1359 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1358 | + // Beta preferences |
|
1359 | + if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1360 | 1360 | $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0; |
1361 | - } |
|
1361 | + } |
|
1362 | 1362 | |
1363 | - // Load project specific preferences from XML config |
|
1364 | - $xml = boincwork_get_project_specific_config(); |
|
1365 | - $updated_prefs = array( |
|
1363 | + // Load project specific preferences from XML config |
|
1364 | + $xml = boincwork_get_project_specific_config(); |
|
1365 | + $updated_prefs = array( |
|
1366 | 1366 | 'project_specific' => boincwork_format_project_specific_prefs_data($edit) |
1367 | - ); |
|
1368 | - $prefs = $updated_prefs + $prefs; |
|
1367 | + ); |
|
1368 | + $prefs = $updated_prefs + $prefs; |
|
1369 | 1369 | |
1370 | - // Don't specify apps if all are selected |
|
1371 | - if (isset($form_state['storage']['all apps selected'])) { |
|
1370 | + // Don't specify apps if all are selected |
|
1371 | + if (isset($form_state['storage']['all apps selected'])) { |
|
1372 | 1372 | unset($prefs['project_specific']['app_id']); |
1373 | 1373 | unset($form_state['storage']['all apps selected']); |
1374 | - } |
|
1374 | + } |
|
1375 | 1375 | |
1376 | - // If this is a new preference set, be sure to unset the "cleared" attribute |
|
1377 | - if (isset($prefs['@attributes']['cleared'])) { |
|
1376 | + // If this is a new preference set, be sure to unset the "cleared" attribute |
|
1377 | + if (isset($prefs['@attributes']['cleared'])) { |
|
1378 | 1378 | unset($prefs['@attributes']['cleared']); |
1379 | - } |
|
1379 | + } |
|
1380 | 1380 | |
1381 | - // Save preferences back to the BOINC account |
|
1382 | - $result = boincwork_save_prefs($prefs, 'project', $venue); |
|
1381 | + // Save preferences back to the BOINC account |
|
1382 | + $result = boincwork_save_prefs($prefs, 'project', $venue); |
|
1383 | 1383 | |
1384 | - // Update the user's default preference set |
|
1385 | - if ($edit['default_set']['default_venue']) { |
|
1384 | + // Update the user's default preference set |
|
1385 | + if ($edit['default_set']['default_venue']) { |
|
1386 | 1386 | boincwork_set_default_venue($venue); |
1387 | - } |
|
1388 | - elseif ($venue == $account->boincuser_default_pref_set) { |
|
1387 | + } |
|
1388 | + elseif ($venue == $account->boincuser_default_pref_set) { |
|
1389 | 1389 | // User has cleared out the default venue setting |
1390 | 1390 | boincwork_set_default_venue(); |
1391 | - } |
|
1391 | + } |
|
1392 | 1392 | |
1393 | - if (!$result) { |
|
1393 | + if (!$result) { |
|
1394 | 1394 | watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
1395 | 1395 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
1396 | - } |
|
1397 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
1396 | + } |
|
1397 | + elseif (!drupal_get_messages('status', FALSE)) { |
|
1398 | 1398 | // Show this message if the set wasn't created automatically (in which case |
1399 | 1399 | // there is a message tailored to that) |
1400 | 1400 | drupal_set_message(t('Your preferences have been updated. |
@@ -1402,53 +1402,53 @@ discard block |
||
1402 | 1402 | communicates with @project or you issue the "Update" |
1403 | 1403 | command from the BOINC client.', |
1404 | 1404 | array('@project' => $site_name))); |
1405 | - } |
|
1405 | + } |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | /** |
1409 | 1409 | * The structure of the community preferences form |
1410 | 1410 | */ |
1411 | 1411 | function communityprefs_form(&$form_state) { |
1412 | - global $user; |
|
1413 | - $account = user_load($user->uid); |
|
1414 | - $form = array(); |
|
1415 | - |
|
1416 | - // Pull in some elements from the profile form |
|
1417 | - $profile_form_state = array(); |
|
1418 | - $profile = new stdClass(); |
|
1419 | - $profile->type = 'profile'; |
|
1420 | - $profile->language = ''; |
|
1421 | - if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
|
1412 | + global $user; |
|
1413 | + $account = user_load($user->uid); |
|
1414 | + $form = array(); |
|
1415 | + |
|
1416 | + // Pull in some elements from the profile form |
|
1417 | + $profile_form_state = array(); |
|
1418 | + $profile = new stdClass(); |
|
1419 | + $profile->type = 'profile'; |
|
1420 | + $profile->language = ''; |
|
1421 | + if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
|
1422 | 1422 | $profile_node = node_load($profile_nid); |
1423 | 1423 | $form_state['storage']['profile_node'] = $profile_node; |
1424 | 1424 | module_load_include('inc', 'node', 'node.pages'); |
1425 | 1425 | $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node); |
1426 | 1426 | drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state); |
1427 | - } |
|
1427 | + } |
|
1428 | 1428 | |
1429 | - // Standard option sets |
|
1430 | - $form['boolean_options'] = array( |
|
1429 | + // Standard option sets |
|
1430 | + $form['boolean_options'] = array( |
|
1431 | 1431 | '#type' => 'value', |
1432 | 1432 | '#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')) |
1433 | - ); |
|
1433 | + ); |
|
1434 | 1434 | |
1435 | - $default = array( |
|
1435 | + $default = array( |
|
1436 | 1436 | 'pm_send_notification' => '', // This is set already in pm_email_notify_user |
1437 | 1437 | 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, |
1438 | 1438 | 'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50), |
1439 | 1439 | 'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
1440 | - ); |
|
1440 | + ); |
|
1441 | 1441 | |
1442 | - // General options |
|
1443 | - $form['general'] = array( |
|
1442 | + // General options |
|
1443 | + $form['general'] = array( |
|
1444 | 1444 | '#type' => 'fieldset', |
1445 | 1445 | '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'), |
1446 | 1446 | '#weight' => 0, |
1447 | 1447 | '#collapsible' => TRUE, |
1448 | 1448 | '#collapsed' => FALSE |
1449 | - ); |
|
1450 | - // Add the BOINC user name (non-unique, user editable) |
|
1451 | - $form['general']['boincuser_name'] = array( |
|
1449 | + ); |
|
1450 | + // Add the BOINC user name (non-unique, user editable) |
|
1451 | + $form['general']['boincuser_name'] = array( |
|
1452 | 1452 | '#type' => 'textfield', |
1453 | 1453 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
1454 | 1454 | '#default_value' => $account->boincuser_name, |
@@ -1456,252 +1456,252 @@ discard block |
||
1456 | 1456 | '#required' => TRUE, |
1457 | 1457 | '#description' => '', |
1458 | 1458 | '#size' => 40 |
1459 | - ); |
|
1460 | - // Time zone |
|
1461 | - if (variable_get('configurable_timezones', 1)) { |
|
1459 | + ); |
|
1460 | + // Time zone |
|
1461 | + if (variable_get('configurable_timezones', 1)) { |
|
1462 | 1462 | $zones = _system_zonelist(); |
1463 | 1463 | $form['general']['timezone'] = array( |
1464 | - '#type' => 'select', |
|
1465 | - '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1466 | - '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1467 | - '#options' => $zones, |
|
1468 | - '#description' => '', |
|
1464 | + '#type' => 'select', |
|
1465 | + '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1466 | + '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1467 | + '#options' => $zones, |
|
1468 | + '#description' => '', |
|
1469 | 1469 | ); |
1470 | - } |
|
1470 | + } |
|
1471 | 1471 | |
1472 | - // Notification options |
|
1473 | - $form['notifications'] = array( |
|
1472 | + // Notification options |
|
1473 | + $form['notifications'] = array( |
|
1474 | 1474 | '#type' => 'fieldset', |
1475 | 1475 | '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'), |
1476 | 1476 | '#weight' => 5, |
1477 | 1477 | '#collapsible' => TRUE, |
1478 | 1478 | '#collapsed' => FALSE |
1479 | - ); |
|
1480 | - // Pull in private message notification handling and tweak the form |
|
1481 | - $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
|
1482 | - $form['notifications']['pm_send_notifications'] = array_replace( |
|
1479 | + ); |
|
1480 | + // Pull in private message notification handling and tweak the form |
|
1481 | + $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
|
1482 | + $form['notifications']['pm_send_notifications'] = array_replace( |
|
1483 | 1483 | $pm_notify['enable_pm_mail']['pm_send_notifications'], |
1484 | 1484 | array( |
1485 | - '#type' => 'radios', |
|
1486 | - '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1487 | - '#description' => ' ', |
|
1488 | - '#options' => $form['boolean_options']['#value'], |
|
1489 | - '#attributes' => array('class' => 'fancy') |
|
1485 | + '#type' => 'radios', |
|
1486 | + '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1487 | + '#description' => ' ', |
|
1488 | + '#options' => $form['boolean_options']['#value'], |
|
1489 | + '#attributes' => array('class' => 'fancy') |
|
1490 | 1490 | ) |
1491 | - ); |
|
1492 | - $form['notifications']['friend_notification'] = array( |
|
1491 | + ); |
|
1492 | + $form['notifications']['friend_notification'] = array( |
|
1493 | 1493 | '#type' => 'radios', |
1494 | 1494 | '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'), |
1495 | 1495 | '#description' => ' ', |
1496 | 1496 | '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
1497 | 1497 | '#attributes' => array('class' => 'fancy'), |
1498 | 1498 | '#default_value' => $default['friend_notification'] |
1499 | - ); |
|
1499 | + ); |
|
1500 | 1500 | |
1501 | - // Internationalization options |
|
1502 | - if (module_exists('internationalization')) { |
|
1501 | + // Internationalization options |
|
1502 | + if (module_exists('internationalization')) { |
|
1503 | 1503 | $languages = language_list('enabled'); |
1504 | 1504 | $languages = $languages[1]; |
1505 | 1505 | $names = array(); |
1506 | 1506 | foreach ($languages as $langcode => $item) { |
1507 | - $name = t($item->name); |
|
1508 | - $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1507 | + $name = t($item->name); |
|
1508 | + $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1509 | 1509 | } |
1510 | 1510 | $form['locale'] = array( |
1511 | - '#type' => 'fieldset', |
|
1512 | - '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1513 | - '#weight' => 10, |
|
1514 | - '#collapsible' => TRUE, |
|
1515 | - '#collapsed' => FALSE, |
|
1511 | + '#type' => 'fieldset', |
|
1512 | + '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1513 | + '#weight' => 10, |
|
1514 | + '#collapsible' => TRUE, |
|
1515 | + '#collapsed' => FALSE, |
|
1516 | 1516 | ); |
1517 | 1517 | |
1518 | 1518 | // Get language negotiation settings. |
1519 | 1519 | $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); |
1520 | 1520 | $user_preferred_language = user_preferred_language($account); |
1521 | 1521 | $form['locale']['language'] = array( |
1522 | - '#type' => 'select', |
|
1523 | - '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1524 | - '#default_value' => check_plain($user_preferred_language->language), |
|
1525 | - '#options' => $names, |
|
1526 | - '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'), |
|
1522 | + '#type' => 'select', |
|
1523 | + '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1524 | + '#default_value' => check_plain($user_preferred_language->language), |
|
1525 | + '#options' => $names, |
|
1526 | + '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'), |
|
1527 | 1527 | ); |
1528 | - } |
|
1528 | + } |
|
1529 | 1529 | |
1530 | - // Avatar options |
|
1531 | - $form['gravatar'] = array( |
|
1530 | + // Avatar options |
|
1531 | + $form['gravatar'] = array( |
|
1532 | 1532 | '#type' => 'item', |
1533 | 1533 | '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
1534 | 1534 | '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'), |
1535 | - ); |
|
1536 | - if (user_access('disable own gravatar', $account)) { |
|
1535 | + ); |
|
1536 | + if (user_access('disable own gravatar', $account)) { |
|
1537 | 1537 | $form['gravatar'] = array( |
1538 | - '#type' => 'checkbox', |
|
1539 | - '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1540 | - '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1541 | - '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
|
1542 | - '#disabled' => !empty($account->picture), |
|
1543 | - ); |
|
1544 | - } |
|
1545 | - $form['gravatar']['#weight'] = 15; |
|
1546 | - $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1547 | - // Upload an avatar (pulled from profile_node_form): |
|
1548 | - if (!empty($profile_form['field_image'])) { |
|
1538 | + '#type' => 'checkbox', |
|
1539 | + '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1540 | + '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1541 | + '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
|
1542 | + '#disabled' => !empty($account->picture), |
|
1543 | + ); |
|
1544 | + } |
|
1545 | + $form['gravatar']['#weight'] = 15; |
|
1546 | + $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1547 | + // Upload an avatar (pulled from profile_node_form): |
|
1548 | + if (!empty($profile_form['field_image'])) { |
|
1549 | 1549 | $form['field_image'] = $profile_form['field_image']; |
1550 | - } |
|
1551 | - else { |
|
1550 | + } |
|
1551 | + else { |
|
1552 | 1552 | $form['field_image'] = array( |
1553 | - '#value' => '<div class="form-item">' |
|
1553 | + '#value' => '<div class="form-item">' |
|
1554 | 1554 | . '<label class="placeholder">' |
1555 | 1555 | . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community') |
1556 | 1556 | . '</label>' |
1557 | 1557 | . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
1558 | 1558 | . '</div>', |
1559 | 1559 | ); |
1560 | - } |
|
1561 | - $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1562 | - $form['field_image']['#weight'] = 20; |
|
1563 | - $form['field_image']['#suffix'] = '</fieldset>'; |
|
1560 | + } |
|
1561 | + $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1562 | + $form['field_image']['#weight'] = 20; |
|
1563 | + $form['field_image']['#suffix'] = '</fieldset>'; |
|
1564 | 1564 | |
1565 | - // Forum options |
|
1566 | - $form['forums'] = array( |
|
1565 | + // Forum options |
|
1566 | + $form['forums'] = array( |
|
1567 | 1567 | '#type' => 'fieldset', |
1568 | 1568 | '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'), |
1569 | 1569 | '#weight' => 25, |
1570 | 1570 | '#collapsible' => TRUE, |
1571 | 1571 | '#collapsed' => FALSE |
1572 | - ); |
|
1573 | - $form['forums']['comments_per_page'] = array( |
|
1572 | + ); |
|
1573 | + $form['forums']['comments_per_page'] = array( |
|
1574 | 1574 | '#type' => 'select', |
1575 | 1575 | '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'), |
1576 | 1576 | '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100), |
1577 | 1577 | '#default_value' => $default['comments_per_page'] |
1578 | - ); |
|
1579 | - // Can't have a typical Drupal form suffix on a select box? |
|
1580 | - $form['forums']['comments_per_page_suffix'] = array( |
|
1578 | + ); |
|
1579 | + // Can't have a typical Drupal form suffix on a select box? |
|
1580 | + $form['forums']['comments_per_page_suffix'] = array( |
|
1581 | 1581 | '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>' |
1582 | - ); |
|
1583 | - $form['forums']['comments_order'] = array( |
|
1582 | + ); |
|
1583 | + $form['forums']['comments_order'] = array( |
|
1584 | 1584 | '#type' => 'select', |
1585 | 1585 | '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'), |
1586 | 1586 | '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')), |
1587 | 1587 | '#default_value' => $default['comments_order'] |
1588 | - ); |
|
1589 | - // Signature (pulled from user_edit_form): |
|
1590 | - if (variable_get('user_signatures', 0) && module_exists('comment')) { |
|
1588 | + ); |
|
1589 | + // Signature (pulled from user_edit_form): |
|
1590 | + if (variable_get('user_signatures', 0) && module_exists('comment')) { |
|
1591 | 1591 | $form['forums']['signature'] = array( |
1592 | - '#type' => 'textarea', |
|
1593 | - '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1594 | - '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1595 | - '#default_value' => $account->signature |
|
1596 | - ); |
|
1592 | + '#type' => 'textarea', |
|
1593 | + '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1594 | + '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1595 | + '#default_value' => $account->signature |
|
1596 | + ); |
|
1597 | 1597 | // Prevent a "validation error" message when the user attempts to save with a default value they |
1598 | 1598 | // do not have access to. |
1599 | 1599 | if (!filter_access($account->signature_format) && empty($_POST)) { |
1600 | - drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page.")); |
|
1601 | - $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
|
1600 | + drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page.")); |
|
1601 | + $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
|
1602 | 1602 | } |
1603 | 1603 | $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format')); |
1604 | 1604 | // Optionally hide signatures from comments |
1605 | 1605 | $form['forums']['hide_signatures'] = array( |
1606 | - '#type' => 'radios', |
|
1607 | - '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1608 | - '#description' => ' ', |
|
1609 | - '#options' => $form['boolean_options']['#value'], |
|
1610 | - '#attributes' => array('class' => 'fancy'), |
|
1611 | - '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0, |
|
1606 | + '#type' => 'radios', |
|
1607 | + '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1608 | + '#description' => ' ', |
|
1609 | + '#options' => $form['boolean_options']['#value'], |
|
1610 | + '#attributes' => array('class' => 'fancy'), |
|
1611 | + '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0, |
|
1612 | 1612 | ); |
1613 | - } |
|
1613 | + } |
|
1614 | 1614 | |
1615 | - //Bottom separator |
|
1616 | - $form['separator_bottom'] = array( |
|
1615 | + //Bottom separator |
|
1616 | + $form['separator_bottom'] = array( |
|
1617 | 1617 | '#value' => '<div class="separator buttons"></div>', |
1618 | 1618 | '#weight' => 999, |
1619 | - ); |
|
1619 | + ); |
|
1620 | 1620 | |
1621 | - // Form control |
|
1622 | - $form['form control tabs prefix'] = array( |
|
1621 | + // Form control |
|
1622 | + $form['form control tabs prefix'] = array( |
|
1623 | 1623 | '#value' => '<ul class="form-control tab-list">', |
1624 | 1624 | '#weight' => 1001, |
1625 | - ); |
|
1626 | - $form['submit'] = array( |
|
1625 | + ); |
|
1626 | + $form['submit'] = array( |
|
1627 | 1627 | '#prefix' => '<li class="first tab">', |
1628 | 1628 | '#type' => 'submit', |
1629 | 1629 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1630 | 1630 | '#suffix' => '</li>', |
1631 | 1631 | '#weight' => 1002, |
1632 | - ); |
|
1633 | - $form['form control tabs'] = array( |
|
1632 | + ); |
|
1633 | + $form['form control tabs'] = array( |
|
1634 | 1634 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
1635 | 1635 | '#weight' => 1003, |
1636 | - ); |
|
1637 | - $form['form control tabs suffix'] = array( |
|
1636 | + ); |
|
1637 | + $form['form control tabs suffix'] = array( |
|
1638 | 1638 | '#value' => '</ul>', |
1639 | 1639 | '#weight' => 1004, |
1640 | - ); |
|
1641 | - return $form; |
|
1640 | + ); |
|
1641 | + return $form; |
|
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | /** |
1645 | - * Handle validation submission of community preferences form. |
|
1646 | - */ |
|
1645 | + * Handle validation submission of community preferences form. |
|
1646 | + */ |
|
1647 | 1647 | function communityprefs_form_validate($form, &$form_state) { |
1648 | - // require_boinc(); |
|
1649 | - global $user; |
|
1650 | - $account = user_load($user->uid); |
|
1651 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1652 | - $edit = $form_state['values']; |
|
1648 | + // require_boinc(); |
|
1649 | + global $user; |
|
1650 | + $account = user_load($user->uid); |
|
1651 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1652 | + $edit = $form_state['values']; |
|
1653 | 1653 | |
1654 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1654 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1655 | 1655 | $blacklist1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator")); |
1656 | 1656 | $blacklist2 = array(); |
1657 | 1657 | if (is_array($blacklist1)) { |
1658 | - $blacklist2 = array_map('strtolower', $blacklist1); |
|
1658 | + $blacklist2 = array_map('strtolower', $blacklist1); |
|
1659 | 1659 | } |
1660 | 1660 | if (in_array(strtolower($edit['boincuser_name']), $blacklist2)) { |
1661 | - form_set_error('boincuser_name', |
|
1661 | + form_set_error('boincuser_name', |
|
1662 | 1662 | bts('You may not use username @blname, as that name is not allowed. Please choose another name.', |
1663 | 1663 | array('@blname' => $edit['boincuser_name']), |
1664 | 1664 | NULL, 'boinc:account-preferences-community')); |
1665 | - return false; |
|
1665 | + return false; |
|
1666 | + } |
|
1666 | 1667 | } |
1667 | - } |
|
1668 | 1668 | |
1669 | - return true; |
|
1669 | + return true; |
|
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | /** |
1673 | - * Handle post-validation submission of community preferences form. |
|
1674 | - */ |
|
1673 | + * Handle post-validation submission of community preferences form. |
|
1674 | + */ |
|
1675 | 1675 | function communityprefs_form_submit($form, &$form_state) { |
1676 | - require_boinc('boinc_db'); |
|
1677 | - global $user; |
|
1678 | - $account = user_load($user->uid); |
|
1679 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1680 | - $edit = $form_state['values']; |
|
1681 | - $profile_node = $form_state['storage']['profile_node']; |
|
1682 | - |
|
1683 | - // Display name |
|
1684 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1676 | + require_boinc('boinc_db'); |
|
1677 | + global $user; |
|
1678 | + $account = user_load($user->uid); |
|
1679 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1680 | + $edit = $form_state['values']; |
|
1681 | + $profile_node = $form_state['storage']['profile_node']; |
|
1682 | + |
|
1683 | + // Display name |
|
1684 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1685 | 1685 | $boincuser_name = $edit['boincuser_name']; |
1686 | 1686 | $result = $boinc_user->update( |
1687 | 1687 | "name='{$boincuser_name}'" |
1688 | 1688 | ); |
1689 | - } |
|
1689 | + } |
|
1690 | 1690 | |
1691 | - // Private message settings |
|
1692 | - pm_email_notify_user('submit', $edit, $user); |
|
1691 | + // Private message settings |
|
1692 | + pm_email_notify_user('submit', $edit, $user); |
|
1693 | 1693 | |
1694 | - // Avatar settings - only set if profile_node exists. |
|
1695 | - if ($profile_node) { |
|
1694 | + // Avatar settings - only set if profile_node exists. |
|
1695 | + if ($profile_node) { |
|
1696 | 1696 | if (!$edit['field_image']) $edit['field_image'] = array(); |
1697 | 1697 | $profile_node->field_image = $edit['field_image']; |
1698 | 1698 | node_save($profile_node); |
1699 | 1699 | // Flush this from the node cache or changes won't show up immediately! |
1700 | 1700 | $profile_node = node_load($profile_node->nid, NULL, TRUE); |
1701 | - } |
|
1701 | + } |
|
1702 | 1702 | |
1703 | - // All other settings |
|
1704 | - $settings = array( |
|
1703 | + // All other settings |
|
1704 | + $settings = array( |
|
1705 | 1705 | 'signature' => $edit['signature'], |
1706 | 1706 | 'signature_format' => $edit['signature_format'], |
1707 | 1707 | 'timezone' => $edit['timezone'], |
@@ -1710,197 +1710,197 @@ discard block |
||
1710 | 1710 | 'hide_signatures' => $edit['hide_signatures'], |
1711 | 1711 | 'sort' => $edit['comments_order'], |
1712 | 1712 | 'gravatar' => $edit['gravatar'], |
1713 | - ); |
|
1714 | - if (module_exists('internationalization')) { |
|
1713 | + ); |
|
1714 | + if (module_exists('internationalization')) { |
|
1715 | 1715 | $settings['language'] = $edit['language']; |
1716 | 1716 | global $language; |
1717 | 1717 | if ($user->language != $edit['language']) { |
1718 | - global $base_url; |
|
1719 | - if ($edit['language'] != language_default('language')) { |
|
1718 | + global $base_url; |
|
1719 | + if ($edit['language'] != language_default('language')) { |
|
1720 | 1720 | $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q']; |
1721 | - } |
|
1722 | - else { |
|
1721 | + } |
|
1722 | + else { |
|
1723 | 1723 | $form_state['redirect'] = $base_url . '/' . $_GET['q']; |
1724 | - } |
|
1724 | + } |
|
1725 | + } |
|
1725 | 1726 | } |
1726 | - } |
|
1727 | - user_save($user, $settings); |
|
1727 | + user_save($user, $settings); |
|
1728 | 1728 | |
1729 | - drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1729 | + drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1730 | 1730 | |
1731 | - // Form will not redirect if storage is set; not good if language changes |
|
1732 | - unset($form_state['storage']); |
|
1731 | + // Form will not redirect if storage is set; not good if language changes |
|
1732 | + unset($form_state['storage']); |
|
1733 | 1733 | } |
1734 | 1734 | |
1735 | 1735 | /** |
1736 | 1736 | * The structure of the privacy preferences form |
1737 | 1737 | */ |
1738 | 1738 | function boincwork_privacyprefs_form(&$form_state) { |
1739 | - require_boinc(array('user', 'prefs', 'util', 'consent')); |
|
1739 | + require_boinc(array('user', 'prefs', 'util', 'consent')); |
|
1740 | 1740 | |
1741 | - global $user; |
|
1742 | - $account = user_load($user->uid); |
|
1743 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1741 | + global $user; |
|
1742 | + $account = user_load($user->uid); |
|
1743 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1744 | 1744 | |
1745 | - // Load preferences from BOINC account |
|
1746 | - $prefs = boincwork_load_prefs('project'); |
|
1745 | + // Load preferences from BOINC account |
|
1746 | + $prefs = boincwork_load_prefs('project'); |
|
1747 | 1747 | |
1748 | - //if (!$prefs AND !$initialize_if_empty) return null; |
|
1748 | + //if (!$prefs AND !$initialize_if_empty) return null; |
|
1749 | 1749 | |
1750 | - $privacy_consent_types = boincwork_load_privacyconsenttypes(); |
|
1750 | + $privacy_consent_types = boincwork_load_privacyconsenttypes(); |
|
1751 | 1751 | |
1752 | - // Define form defaults |
|
1753 | - $default = array( |
|
1752 | + // Define form defaults |
|
1753 | + $default = array( |
|
1754 | 1754 | 'privacy' => array( |
1755 | - 'send_email' => ($boincuser->send_email) ? 1 : 0, |
|
1756 | - 'show_hosts' => ($boincuser->show_hosts) ? 1 : 0 |
|
1755 | + 'send_email' => ($boincuser->send_email) ? 1 : 0, |
|
1756 | + 'show_hosts' => ($boincuser->show_hosts) ? 1 : 0 |
|
1757 | 1757 | ) |
1758 | - ); |
|
1758 | + ); |
|
1759 | 1759 | |
1760 | - // Standard option sets |
|
1761 | - $form['boolean_options'] = array( |
|
1760 | + // Standard option sets |
|
1761 | + $form['boolean_options'] = array( |
|
1762 | 1762 | '#type' => 'value', |
1763 | 1763 | '#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')) |
1764 | - ); |
|
1764 | + ); |
|
1765 | 1765 | |
1766 | - $form['privacy'] = array( |
|
1766 | + $form['privacy'] = array( |
|
1767 | 1767 | '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'), |
1768 | 1768 | '#type' => 'fieldset', |
1769 | 1769 | '#description' => null, |
1770 | 1770 | '#collapsible' => TRUE, |
1771 | 1771 | '#collapsed' => FALSE |
1772 | - ); |
|
1773 | - $form['privacy']['send_email'] = array( |
|
1772 | + ); |
|
1773 | + $form['privacy']['send_email'] = array( |
|
1774 | 1774 | '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
1775 | 1775 | '#type' => 'radios', |
1776 | 1776 | '#options' => $form['boolean_options']['#value'], |
1777 | 1777 | '#attributes' => array('class' => 'fancy'), |
1778 | 1778 | '#default_value' => $default['privacy']['send_email'] |
1779 | - ); |
|
1780 | - $form['privacy']['show_hosts'] = array( |
|
1779 | + ); |
|
1780 | + $form['privacy']['show_hosts'] = array( |
|
1781 | 1781 | '#title' => bts('Should @project show your computers on its website?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
1782 | 1782 | '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), NULL, 'boinc:account-preferences-privacy'), |
1783 | 1783 | '#type' => 'radios', |
1784 | 1784 | '#options' => $form['boolean_options']['#value'], |
1785 | 1785 | '#attributes' => array('class' => 'fancy'), |
1786 | 1786 | '#default_value' => $default['privacy']['show_hosts'] |
1787 | - ); |
|
1787 | + ); |
|
1788 | 1788 | |
1789 | - // Loop over privacy consent types and create form question for each |
|
1790 | - // option that deals with privacy. |
|
1791 | - foreach ($privacy_consent_types as $ct) { |
|
1789 | + // Loop over privacy consent types and create form question for each |
|
1790 | + // option that deals with privacy. |
|
1791 | + foreach ($privacy_consent_types as $ct) { |
|
1792 | 1792 | |
1793 | 1793 | $currstate = (check_user_consent($boincuser, $ct['shortname'])) ? 1 : 0 ; |
1794 | 1794 | // Set name to 'privacyconsent_SHORTNAME', which can be parsed |
1795 | 1795 | // later in the submit function. |
1796 | 1796 | $form['privacy']['privacyconsent_'.$ct['shortname']] = array( |
1797 | - '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1798 | - '#type' => 'radios', |
|
1799 | - '#options' => $form['boolean_options']['#value'], |
|
1800 | - '#attributes' => array('class' => 'fancy'), |
|
1801 | - '#default_value' => $currstate, |
|
1797 | + '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1798 | + '#type' => 'radios', |
|
1799 | + '#options' => $form['boolean_options']['#value'], |
|
1800 | + '#attributes' => array('class' => 'fancy'), |
|
1801 | + '#default_value' => $currstate, |
|
1802 | 1802 | ); |
1803 | 1803 | |
1804 | 1804 | // Add a description with link to the question 'Do you consent to |
1805 | 1805 | // exporting your data...'. |
1806 | 1806 | $mypatt = '/Do you consent to exporting your data/'; |
1807 | 1807 | if (preg_match($mypatt, $ct['description']) ) { |
1808 | - $form['privacy']['privacyconsent_'.$ct['shortname']]['#description'] = bts('See our !privacy_policy_link for the current list of statistics exports.', |
|
1809 | - array( |
|
1808 | + $form['privacy']['privacyconsent_'.$ct['shortname']]['#description'] = bts('See our !privacy_policy_link for the current list of statistics exports.', |
|
1809 | + array( |
|
1810 | 1810 | '!privacy_policy_link' => l( |
1811 | - bts('privacy policy', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1812 | - '/privacy' |
|
1811 | + bts('privacy policy', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1812 | + '/privacy' |
|
1813 | 1813 | ) |
1814 | - ), |
|
1815 | - NULL, 'boinc:account-preferences-privacy'); |
|
1814 | + ), |
|
1815 | + NULL, 'boinc:account-preferences-privacy'); |
|
1816 | + } |
|
1816 | 1817 | } |
1817 | - } |
|
1818 | 1818 | |
1819 | - // Ignore and block users |
|
1820 | - if (module_exists('ignore_user')) { |
|
1819 | + // Ignore and block users |
|
1820 | + if (module_exists('ignore_user')) { |
|
1821 | 1821 | $form['ignoreblock'] = array( |
1822 | - '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1823 | - '#type' => 'fieldset', |
|
1824 | - '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'), |
|
1825 | - '#collapsible' => TRUE, |
|
1826 | - '#collapsed' => FALSE |
|
1822 | + '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1823 | + '#type' => 'fieldset', |
|
1824 | + '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'), |
|
1825 | + '#collapsible' => TRUE, |
|
1826 | + '#collapsed' => FALSE |
|
1827 | 1827 | ); |
1828 | 1828 | |
1829 | 1829 | // Table for ignored users |
1830 | 1830 | $form['ignoreblock']['current_ignore_section'] = array( |
1831 | - '#type' => 'item', |
|
1832 | - '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1833 | - '#prefix' => '<h4>', |
|
1834 | - '#suffix' => '</h4>', |
|
1835 | - '#weight' => -20, |
|
1831 | + '#type' => 'item', |
|
1832 | + '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1833 | + '#prefix' => '<h4>', |
|
1834 | + '#suffix' => '</h4>', |
|
1835 | + '#weight' => -20, |
|
1836 | 1836 | ); |
1837 | 1837 | |
1838 | 1838 | $ignored_users = _ignore_user_ignored_users(); |
1839 | 1839 | foreach ($ignored_users as $ignored_user) { |
1840 | - $form['ignoreblock']['username'][$ignored_user['iuid']] = array( |
|
1840 | + $form['ignoreblock']['username'][$ignored_user['iuid']] = array( |
|
1841 | 1841 | '#value' => $ignored_user['username'], |
1842 | - ); |
|
1843 | - $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
|
1842 | + ); |
|
1843 | + $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
|
1844 | 1844 | '#value' => l( |
1845 | - bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1846 | - 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1847 | - array() |
|
1845 | + bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1846 | + 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1847 | + array() |
|
1848 | 1848 | ), |
1849 | - ); |
|
1849 | + ); |
|
1850 | 1850 | } |
1851 | 1851 | $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0)); |
1852 | 1852 | |
1853 | 1853 | // Sub-form to add user to ignore list |
1854 | 1854 | $form['ignoreblock']['add_ignore_user_section'] = array( |
1855 | - '#type' => 'item', |
|
1856 | - '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1857 | - '#prefix' => '<h4>', |
|
1858 | - '#suffix' => '</h4>', |
|
1859 | - '#weight' => 10, |
|
1855 | + '#type' => 'item', |
|
1856 | + '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1857 | + '#prefix' => '<h4>', |
|
1858 | + '#suffix' => '</h4>', |
|
1859 | + '#weight' => 10, |
|
1860 | 1860 | ); |
1861 | 1861 | |
1862 | 1862 | $form['ignoreblock']['addusername_toignorelist'] = array( |
1863 | - '#type' => 'textfield', |
|
1864 | - '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1865 | - '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'), |
|
1866 | - '#weight' => 11, |
|
1867 | - '#size' => 50, |
|
1868 | - '#autocomplete_path' => 'boincuser/autocomplete', |
|
1863 | + '#type' => 'textfield', |
|
1864 | + '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1865 | + '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'), |
|
1866 | + '#weight' => 11, |
|
1867 | + '#size' => 50, |
|
1868 | + '#autocomplete_path' => 'boincuser/autocomplete', |
|
1869 | 1869 | ); |
1870 | 1870 | |
1871 | 1871 | $form['ignoreblock']['addusername_submit'] = array( |
1872 | - '#type' => 'submit', |
|
1873 | - '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1874 | - '#submit' => array('_boincwork_ignore_list_form_submit'), |
|
1875 | - '#weight' => 12, |
|
1876 | - '#attributes' => array('class' => 'add_ignore_user'), |
|
1872 | + '#type' => 'submit', |
|
1873 | + '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1874 | + '#submit' => array('_boincwork_ignore_list_form_submit'), |
|
1875 | + '#weight' => 12, |
|
1876 | + '#attributes' => array('class' => 'add_ignore_user'), |
|
1877 | 1877 | ); |
1878 | - }// endif module_exists |
|
1878 | + }// endif module_exists |
|
1879 | 1879 | |
1880 | - $form['prefs']['separator_bottom'] = array( |
|
1880 | + $form['prefs']['separator_bottom'] = array( |
|
1881 | 1881 | '#value' => '<div class="separator buttons"></div>' |
1882 | - ); |
|
1882 | + ); |
|
1883 | 1883 | |
1884 | - // Form control |
|
1885 | - $form['prefs']['form control tabs prefix'] = array( |
|
1884 | + // Form control |
|
1885 | + $form['prefs']['form control tabs prefix'] = array( |
|
1886 | 1886 | '#value' => '<ul class="form-control tab-list">' |
1887 | - ); |
|
1888 | - $form['prefs']['submit'] = array( |
|
1887 | + ); |
|
1888 | + $form['prefs']['submit'] = array( |
|
1889 | 1889 | '#prefix' => '<li class="first tab">', |
1890 | 1890 | '#type' => 'submit', |
1891 | 1891 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1892 | 1892 | '#validate' => array('boincwork_privacyprefs_form_validate'), |
1893 | 1893 | '#submit' => array('boincwork_privacyprefs_form_submit'), |
1894 | 1894 | '#suffix' => '</li>' |
1895 | - ); |
|
1896 | - $form['prefs']['form control tabs'] = array( |
|
1895 | + ); |
|
1896 | + $form['prefs']['form control tabs'] = array( |
|
1897 | 1897 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
1898 | - ); |
|
1899 | - $form['prefs']['form control tabs suffix'] = array( |
|
1898 | + ); |
|
1899 | + $form['prefs']['form control tabs suffix'] = array( |
|
1900 | 1900 | '#value' => '</ul>' |
1901 | - ); |
|
1901 | + ); |
|
1902 | 1902 | |
1903 | - return $form; |
|
1903 | + return $form; |
|
1904 | 1904 | } |
1905 | 1905 | |
1906 | 1906 | /** |
@@ -1908,93 +1908,93 @@ discard block |
||
1908 | 1908 | */ |
1909 | 1909 | function theme_boincwork_privacyprefs_form($form) { |
1910 | 1910 | |
1911 | - $output = ''; |
|
1912 | - $output .= drupal_render($form['privacy']); |
|
1911 | + $output = ''; |
|
1912 | + $output .= drupal_render($form['privacy']); |
|
1913 | 1913 | |
1914 | - $header = array( |
|
1914 | + $header = array( |
|
1915 | 1915 | bts('Username', array(), NULL, 'boinc:ignore-user-list'), |
1916 | 1916 | bts('Operations', array(), NULL, 'boinc:ignore-user-list') |
1917 | - ); |
|
1917 | + ); |
|
1918 | 1918 | |
1919 | - $rows = array(); |
|
1920 | - if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) { |
|
1919 | + $rows = array(); |
|
1920 | + if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) { |
|
1921 | 1921 | foreach (element_children($form['ignoreblock']['username']) as $key) { |
1922 | - $row = array(); |
|
1923 | - $row[] = drupal_render($form['ignoreblock']['username'][$key]); |
|
1924 | - $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
|
1925 | - $rows[] = $row; |
|
1922 | + $row = array(); |
|
1923 | + $row[] = drupal_render($form['ignoreblock']['username'][$key]); |
|
1924 | + $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
|
1925 | + $rows[] = $row; |
|
1926 | 1926 | } |
1927 | - } |
|
1928 | - else { |
|
1927 | + } |
|
1928 | + else { |
|
1929 | 1929 | $rows[] = array( |
1930 | - array( |
|
1930 | + array( |
|
1931 | 1931 | 'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'), |
1932 | 1932 | 'colspan' => '2', |
1933 | - ) |
|
1933 | + ) |
|
1934 | 1934 | ); |
1935 | - } |
|
1935 | + } |
|
1936 | 1936 | |
1937 | - $attr = array('class' => 'ignore_user'); |
|
1938 | - $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr); |
|
1939 | - $output .= drupal_render($form['current_list']); |
|
1937 | + $attr = array('class' => 'ignore_user'); |
|
1938 | + $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr); |
|
1939 | + $output .= drupal_render($form['current_list']); |
|
1940 | 1940 | |
1941 | - if ($form['pager']['#value']) { |
|
1941 | + if ($form['pager']['#value']) { |
|
1942 | 1942 | $output .= drupal_render($form['pager']); |
1943 | - } |
|
1943 | + } |
|
1944 | 1944 | |
1945 | - $output .= drupal_render($form); |
|
1945 | + $output .= drupal_render($form); |
|
1946 | 1946 | |
1947 | - return $output; |
|
1947 | + return $output; |
|
1948 | 1948 | } |
1949 | 1949 | |
1950 | 1950 | /** |
1951 | - * Validate the privacy preferences form. |
|
1952 | - */ |
|
1951 | + * Validate the privacy preferences form. |
|
1952 | + */ |
|
1953 | 1953 | function boincwork_privacyprefs_form_validate($form, &$form_state) { |
1954 | - require_boinc('util'); |
|
1954 | + require_boinc('util'); |
|
1955 | 1955 | |
1956 | - // Verify all non-boolean user input values and notify form API of failures |
|
1957 | - // ... currently there are no non-boolean values! |
|
1956 | + // Verify all non-boolean user input values and notify form API of failures |
|
1957 | + // ... currently there are no non-boolean values! |
|
1958 | 1958 | } |
1959 | 1959 | |
1960 | 1960 | /** |
1961 | - * Handle post-validation submission of privacy preferences form. |
|
1962 | - */ |
|
1961 | + * Handle post-validation submission of privacy preferences form. |
|
1962 | + */ |
|
1963 | 1963 | function boincwork_privacyprefs_form_submit($form, &$form_state) { |
1964 | - require_boinc(array('user', 'prefs', 'consent')); |
|
1964 | + require_boinc(array('user', 'prefs', 'consent')); |
|
1965 | 1965 | |
1966 | - global $user; |
|
1967 | - $account = user_load($user->uid); |
|
1966 | + global $user; |
|
1967 | + $account = user_load($user->uid); |
|
1968 | 1968 | |
1969 | - // Load BOINC account |
|
1970 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1969 | + // Load BOINC account |
|
1970 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1971 | 1971 | |
1972 | - // Privacy preferences |
|
1973 | - $boincuser->send_email = ($form_state['values']['send_email']) ? true : false; |
|
1974 | - $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false; |
|
1972 | + // Privacy preferences |
|
1973 | + $boincuser->send_email = ($form_state['values']['send_email']) ? true : false; |
|
1974 | + $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false; |
|
1975 | 1975 | |
1976 | - // Privacy consent options, extract the 'privacyconsent_SHORTNAME' |
|
1977 | - // from values array, and loop over them; each is checked with |
|
1978 | - // check_consent_type(). Also check the current state of the option |
|
1979 | - // in the database. If the form value is a new state, then set it. |
|
1980 | - $result = preg_grep("/^privacyconsent/", array_keys($form_state['values'])); |
|
1981 | - $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
|
1982 | - foreach ($privacyconsent_prefs as $name => $newstate) { |
|
1976 | + // Privacy consent options, extract the 'privacyconsent_SHORTNAME' |
|
1977 | + // from values array, and loop over them; each is checked with |
|
1978 | + // check_consent_type(). Also check the current state of the option |
|
1979 | + // in the database. If the form value is a new state, then set it. |
|
1980 | + $result = preg_grep("/^privacyconsent/", array_keys($form_state['values'])); |
|
1981 | + $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
|
1982 | + foreach ($privacyconsent_prefs as $name => $newstate) { |
|
1983 | 1983 | $subname = explode('_', $name)[1]; |
1984 | 1984 | $currstate = (check_user_consent($boincuser, $subname)) ? 1 : 0 ; |
1985 | 1985 | list($checkct, $ctid) = check_consent_type($subname); |
1986 | 1986 | if ($checkct && ($currstate != $newstate)) { |
1987 | - consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
|
1987 | + consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
|
1988 | + } |
|
1988 | 1989 | } |
1989 | - } |
|
1990 | 1990 | |
1991 | - //project_prefs_update($boincuser, $main_prefs); |
|
1991 | + //project_prefs_update($boincuser, $main_prefs); |
|
1992 | 1992 | |
1993 | - db_set_active('boinc_rw'); |
|
1994 | - db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'"); |
|
1995 | - db_set_active('default'); |
|
1993 | + db_set_active('boinc_rw'); |
|
1994 | + db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'"); |
|
1995 | + db_set_active('default'); |
|
1996 | 1996 | |
1997 | - drupal_set_message(t('Your privacy preferences have been updated.')); |
|
1997 | + drupal_set_message(t('Your privacy preferences have been updated.')); |
|
1998 | 1998 | } |
1999 | 1999 | |
2000 | 2000 | /** |
@@ -2002,14 +2002,14 @@ discard block |
||
2002 | 2002 | * ignore list. |
2003 | 2003 | */ |
2004 | 2004 | function _boincwork_ignore_list_form_submit($form, $form_state) { |
2005 | - boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']); |
|
2006 | - drupal_set_message( |
|
2005 | + boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']); |
|
2006 | + drupal_set_message( |
|
2007 | 2007 | bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
2008 | - array( |
|
2008 | + array( |
|
2009 | 2009 | '@username' => $form_state['values']['addusername_toignorelist'], |
2010 | 2010 | '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
2011 | - ), |
|
2012 | - NULL, 'boinc:ignore-user-add'), |
|
2011 | + ), |
|
2012 | + NULL, 'boinc:ignore-user-add'), |
|
2013 | 2013 | 'status'); |
2014 | 2014 | } |
2015 | 2015 | |
@@ -2018,37 +2018,37 @@ discard block |
||
2018 | 2018 | */ |
2019 | 2019 | function boincwork_selectapp_form(&$form_state, $apps, $current_app) { |
2020 | 2020 | |
2021 | - $form['selectapp'] = array( |
|
2021 | + $form['selectapp'] = array( |
|
2022 | 2022 | '#type' => 'select', |
2023 | 2023 | '#attributes' => array( |
2024 | - 'class' => 'task-app-filter', |
|
2025 | - 'onchange' => 'this.form.submit();', |
|
2024 | + 'class' => 'task-app-filter', |
|
2025 | + 'onchange' => 'this.form.submit();', |
|
2026 | 2026 | ), |
2027 | 2027 | '#default_value' => $current_app, |
2028 | 2028 | '#options' => $apps, |
2029 | 2029 | '#post_render' => array('_boincwork_selectapp_form_callback'), |
2030 | - ); |
|
2030 | + ); |
|
2031 | 2031 | |
2032 | - // Class task-app-filter-submit for this form is used in |
|
2033 | - // theming. CSS sets 'display:none' if javascript is present. Thus |
|
2034 | - // only non-js users/browsers will see the Apply Filter button. |
|
2035 | - $form['submit'] = array( |
|
2032 | + // Class task-app-filter-submit for this form is used in |
|
2033 | + // theming. CSS sets 'display:none' if javascript is present. Thus |
|
2034 | + // only non-js users/browsers will see the Apply Filter button. |
|
2035 | + $form['submit'] = array( |
|
2036 | 2036 | '#type' => 'submit', |
2037 | 2037 | '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'), |
2038 | 2038 | '#attributes' => array('class' => 'js-hide',), |
2039 | - ); |
|
2039 | + ); |
|
2040 | 2040 | |
2041 | - return $form; |
|
2041 | + return $form; |
|
2042 | 2042 | } |
2043 | 2043 | |
2044 | 2044 | /** |
2045 | 2045 | * Submit function for select appliacation form. |
2046 | 2046 | */ |
2047 | 2047 | function boincwork_selectapp_form_submit($form, &$form_state) { |
2048 | - $myargs = arg(); |
|
2049 | - array_pop($myargs); |
|
2050 | - $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2051 | - $form_state['redirect'] = $newpath; |
|
2048 | + $myargs = arg(); |
|
2049 | + array_pop($myargs); |
|
2050 | + $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2051 | + $form_state['redirect'] = $newpath; |
|
2052 | 2052 | } |
2053 | 2053 | |
2054 | 2054 | /** |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | * 'title' for the Application drop down box. |
2059 | 2059 | */ |
2060 | 2060 | function _boincwork_selectapp_form_callback($theContent, $theElement) { |
2061 | - $disabled = '<option value="-1" disabled hidden'; |
|
2062 | - $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent); |
|
2063 | - return $newContent; |
|
2061 | + $disabled = '<option value="-1" disabled hidden'; |
|
2062 | + $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent); |
|
2063 | + return $newContent; |
|
2064 | 2064 | } |
@@ -4,621 +4,621 @@ |
||
4 | 4 | * Implementation of hook_user_default_permissions(). |
5 | 5 | */ |
6 | 6 | function boinc_standard_user_default_permissions() { |
7 | - $permissions = array(); |
|
7 | + $permissions = array(); |
|
8 | 8 | |
9 | - // Exported permission: Use PHP input for field settings (dangerous - grant with care) |
|
10 | - $permissions['Use PHP input for field settings (dangerous - grant with care)'] = array( |
|
9 | + // Exported permission: Use PHP input for field settings (dangerous - grant with care) |
|
10 | + $permissions['Use PHP input for field settings (dangerous - grant with care)'] = array( |
|
11 | 11 | 'name' => 'Use PHP input for field settings (dangerous - grant with care)', |
12 | 12 | 'roles' => array( |
13 | - '0' => 'administrator', |
|
13 | + '0' => 'administrator', |
|
14 | 14 | ), |
15 | - ); |
|
15 | + ); |
|
16 | 16 | |
17 | - // Exported permission: access administration pages |
|
18 | - $permissions['access administration pages'] = array( |
|
17 | + // Exported permission: access administration pages |
|
18 | + $permissions['access administration pages'] = array( |
|
19 | 19 | 'name' => 'access administration pages', |
20 | 20 | 'roles' => array( |
21 | - '0' => 'administrator', |
|
21 | + '0' => 'administrator', |
|
22 | 22 | ), |
23 | - ); |
|
23 | + ); |
|
24 | 24 | |
25 | - // Exported permission: access all views |
|
26 | - $permissions['access all views'] = array( |
|
25 | + // Exported permission: access all views |
|
26 | + $permissions['access all views'] = array( |
|
27 | 27 | 'name' => 'access all views', |
28 | 28 | 'roles' => array( |
29 | - '0' => 'administrator', |
|
29 | + '0' => 'administrator', |
|
30 | 30 | ), |
31 | - ); |
|
31 | + ); |
|
32 | 32 | |
33 | - // Exported permission: access ckeditor |
|
34 | - $permissions['access ckeditor'] = array( |
|
33 | + // Exported permission: access ckeditor |
|
34 | + $permissions['access ckeditor'] = array( |
|
35 | 35 | 'name' => 'access ckeditor', |
36 | 36 | 'roles' => array( |
37 | - '0' => 'administrator', |
|
38 | - '1' => 'anonymous user', |
|
39 | - '2' => 'authenticated user', |
|
40 | - '3' => 'community member', |
|
41 | - '4' => 'content editor', |
|
42 | - '5' => 'moderator', |
|
43 | - '6' => 'verified contributor', |
|
37 | + '0' => 'administrator', |
|
38 | + '1' => 'anonymous user', |
|
39 | + '2' => 'authenticated user', |
|
40 | + '3' => 'community member', |
|
41 | + '4' => 'content editor', |
|
42 | + '5' => 'moderator', |
|
43 | + '6' => 'verified contributor', |
|
44 | 44 | ), |
45 | - ); |
|
45 | + ); |
|
46 | 46 | |
47 | - // Exported permission: access content |
|
48 | - $permissions['access content'] = array( |
|
47 | + // Exported permission: access content |
|
48 | + $permissions['access content'] = array( |
|
49 | 49 | 'name' => 'access content', |
50 | 50 | 'roles' => array( |
51 | - '0' => 'administrator', |
|
52 | - '1' => 'anonymous user', |
|
53 | - '2' => 'authenticated user', |
|
51 | + '0' => 'administrator', |
|
52 | + '1' => 'anonymous user', |
|
53 | + '2' => 'authenticated user', |
|
54 | 54 | ), |
55 | - ); |
|
55 | + ); |
|
56 | 56 | |
57 | - // Exported permission: access site reports |
|
58 | - $permissions['access site reports'] = array( |
|
57 | + // Exported permission: access site reports |
|
58 | + $permissions['access site reports'] = array( |
|
59 | 59 | 'name' => 'access site reports', |
60 | 60 | 'roles' => array( |
61 | - '0' => 'administrator', |
|
61 | + '0' => 'administrator', |
|
62 | 62 | ), |
63 | - ); |
|
63 | + ); |
|
64 | 64 | |
65 | - // Exported permission: administer actions |
|
66 | - $permissions['administer actions'] = array( |
|
65 | + // Exported permission: administer actions |
|
66 | + $permissions['administer actions'] = array( |
|
67 | 67 | 'name' => 'administer actions', |
68 | 68 | 'roles' => array( |
69 | - '0' => 'administrator', |
|
69 | + '0' => 'administrator', |
|
70 | 70 | ), |
71 | - ); |
|
71 | + ); |
|
72 | 72 | |
73 | - // Exported permission: administer advanced pane settings |
|
74 | - $permissions['administer advanced pane settings'] = array( |
|
73 | + // Exported permission: administer advanced pane settings |
|
74 | + $permissions['administer advanced pane settings'] = array( |
|
75 | 75 | 'name' => 'administer advanced pane settings', |
76 | 76 | 'roles' => array( |
77 | - '0' => 'administrator', |
|
77 | + '0' => 'administrator', |
|
78 | 78 | ), |
79 | - ); |
|
79 | + ); |
|
80 | 80 | |
81 | - // Exported permission: administer blocks |
|
82 | - $permissions['administer blocks'] = array( |
|
81 | + // Exported permission: administer blocks |
|
82 | + $permissions['administer blocks'] = array( |
|
83 | 83 | 'name' => 'administer blocks', |
84 | 84 | 'roles' => array( |
85 | - '0' => 'administrator', |
|
85 | + '0' => 'administrator', |
|
86 | 86 | ), |
87 | - ); |
|
87 | + ); |
|
88 | 88 | |
89 | - // Exported permission: administer ckeditor |
|
90 | - $permissions['administer ckeditor'] = array( |
|
89 | + // Exported permission: administer ckeditor |
|
90 | + $permissions['administer ckeditor'] = array( |
|
91 | 91 | 'name' => 'administer ckeditor', |
92 | 92 | 'roles' => array( |
93 | - '0' => 'administrator', |
|
93 | + '0' => 'administrator', |
|
94 | 94 | ), |
95 | - ); |
|
95 | + ); |
|
96 | 96 | |
97 | - // Exported permission: administer content types |
|
98 | - $permissions['administer content types'] = array( |
|
97 | + // Exported permission: administer content types |
|
98 | + $permissions['administer content types'] = array( |
|
99 | 99 | 'name' => 'administer content types', |
100 | 100 | 'roles' => array( |
101 | - '0' => 'administrator', |
|
101 | + '0' => 'administrator', |
|
102 | 102 | ), |
103 | - ); |
|
103 | + ); |
|
104 | 104 | |
105 | - // Exported permission: administer elysia_cron |
|
106 | - $permissions['administer elysia_cron'] = array( |
|
105 | + // Exported permission: administer elysia_cron |
|
106 | + $permissions['administer elysia_cron'] = array( |
|
107 | 107 | 'name' => 'administer elysia_cron', |
108 | 108 | 'roles' => array( |
109 | - '0' => 'administrator', |
|
109 | + '0' => 'administrator', |
|
110 | 110 | ), |
111 | - ); |
|
111 | + ); |
|
112 | 112 | |
113 | - // Exported permission: administer features |
|
114 | - $permissions['administer features'] = array( |
|
113 | + // Exported permission: administer features |
|
114 | + $permissions['administer features'] = array( |
|
115 | 115 | 'name' => 'administer features', |
116 | 116 | 'roles' => array( |
117 | - '0' => 'administrator', |
|
117 | + '0' => 'administrator', |
|
118 | 118 | ), |
119 | - ); |
|
119 | + ); |
|
120 | 120 | |
121 | - // Exported permission: administer files |
|
122 | - $permissions['administer files'] = array( |
|
121 | + // Exported permission: administer files |
|
122 | + $permissions['administer files'] = array( |
|
123 | 123 | 'name' => 'administer files', |
124 | 124 | 'roles' => array( |
125 | - '0' => 'administrator', |
|
125 | + '0' => 'administrator', |
|
126 | 126 | ), |
127 | - ); |
|
127 | + ); |
|
128 | 128 | |
129 | - // Exported permission: administer filters |
|
130 | - $permissions['administer filters'] = array( |
|
129 | + // Exported permission: administer filters |
|
130 | + $permissions['administer filters'] = array( |
|
131 | 131 | 'name' => 'administer filters', |
132 | 132 | 'roles' => array( |
133 | - '0' => 'administrator', |
|
133 | + '0' => 'administrator', |
|
134 | 134 | ), |
135 | - ); |
|
135 | + ); |
|
136 | 136 | |
137 | - // Exported permission: administer flags |
|
138 | - $permissions['administer flags'] = array( |
|
137 | + // Exported permission: administer flags |
|
138 | + $permissions['administer flags'] = array( |
|
139 | 139 | 'name' => 'administer flags', |
140 | 140 | 'roles' => array( |
141 | - '0' => 'administrator', |
|
141 | + '0' => 'administrator', |
|
142 | 142 | ), |
143 | - ); |
|
143 | + ); |
|
144 | 144 | |
145 | - // Exported permission: administer imce(execute PHP) |
|
146 | - $permissions['administer imce(execute PHP)'] = array( |
|
145 | + // Exported permission: administer imce(execute PHP) |
|
146 | + $permissions['administer imce(execute PHP)'] = array( |
|
147 | 147 | 'name' => 'administer imce(execute PHP)', |
148 | 148 | 'roles' => array( |
149 | - '0' => 'administrator', |
|
149 | + '0' => 'administrator', |
|
150 | 150 | ), |
151 | - ); |
|
151 | + ); |
|
152 | 152 | |
153 | - // Exported permission: administer menu |
|
154 | - $permissions['administer menu'] = array( |
|
153 | + // Exported permission: administer menu |
|
154 | + $permissions['administer menu'] = array( |
|
155 | 155 | 'name' => 'administer menu', |
156 | 156 | 'roles' => array( |
157 | - '0' => 'administrator', |
|
158 | - '1' => 'content editor', |
|
157 | + '0' => 'administrator', |
|
158 | + '1' => 'content editor', |
|
159 | 159 | ), |
160 | - ); |
|
160 | + ); |
|
161 | 161 | |
162 | - // Exported permission: administer mini panels |
|
163 | - $permissions['administer mini panels'] = array( |
|
162 | + // Exported permission: administer mini panels |
|
163 | + $permissions['administer mini panels'] = array( |
|
164 | 164 | 'name' => 'administer mini panels', |
165 | 165 | 'roles' => array( |
166 | - '0' => 'administrator', |
|
166 | + '0' => 'administrator', |
|
167 | 167 | ), |
168 | - ); |
|
168 | + ); |
|
169 | 169 | |
170 | - // Exported permission: administer nodes |
|
171 | - $permissions['administer nodes'] = array( |
|
170 | + // Exported permission: administer nodes |
|
171 | + $permissions['administer nodes'] = array( |
|
172 | 172 | 'name' => 'administer nodes', |
173 | 173 | 'roles' => array( |
174 | - '0' => 'administrator', |
|
174 | + '0' => 'administrator', |
|
175 | 175 | ), |
176 | - ); |
|
176 | + ); |
|
177 | 177 | |
178 | - // Exported permission: administer page manager |
|
179 | - $permissions['administer page manager'] = array( |
|
178 | + // Exported permission: administer page manager |
|
179 | + $permissions['administer page manager'] = array( |
|
180 | 180 | 'name' => 'administer page manager', |
181 | 181 | 'roles' => array( |
182 | - '0' => 'administrator', |
|
182 | + '0' => 'administrator', |
|
183 | 183 | ), |
184 | - ); |
|
184 | + ); |
|
185 | 185 | |
186 | - // Exported permission: administer pane access |
|
187 | - $permissions['administer pane access'] = array( |
|
186 | + // Exported permission: administer pane access |
|
187 | + $permissions['administer pane access'] = array( |
|
188 | 188 | 'name' => 'administer pane access', |
189 | 189 | 'roles' => array( |
190 | - '0' => 'administrator', |
|
190 | + '0' => 'administrator', |
|
191 | 191 | ), |
192 | - ); |
|
192 | + ); |
|
193 | 193 | |
194 | - // Exported permission: administer pane visibility |
|
195 | - $permissions['administer pane visibility'] = array( |
|
194 | + // Exported permission: administer pane visibility |
|
195 | + $permissions['administer pane visibility'] = array( |
|
196 | 196 | 'name' => 'administer pane visibility', |
197 | 197 | 'roles' => array( |
198 | - '0' => 'administrator', |
|
198 | + '0' => 'administrator', |
|
199 | 199 | ), |
200 | - ); |
|
200 | + ); |
|
201 | 201 | |
202 | - // Exported permission: administer panel-nodes |
|
203 | - $permissions['administer panel-nodes'] = array( |
|
202 | + // Exported permission: administer panel-nodes |
|
203 | + $permissions['administer panel-nodes'] = array( |
|
204 | 204 | 'name' => 'administer panel-nodes', |
205 | 205 | 'roles' => array( |
206 | - '0' => 'administrator', |
|
206 | + '0' => 'administrator', |
|
207 | 207 | ), |
208 | - ); |
|
208 | + ); |
|
209 | 209 | |
210 | - // Exported permission: administer panels layouts |
|
211 | - $permissions['administer panels layouts'] = array( |
|
210 | + // Exported permission: administer panels layouts |
|
211 | + $permissions['administer panels layouts'] = array( |
|
212 | 212 | 'name' => 'administer panels layouts', |
213 | 213 | 'roles' => array( |
214 | - '0' => 'administrator', |
|
214 | + '0' => 'administrator', |
|
215 | 215 | ), |
216 | - ); |
|
216 | + ); |
|
217 | 217 | |
218 | - // Exported permission: administer pathauto |
|
219 | - $permissions['administer pathauto'] = array( |
|
218 | + // Exported permission: administer pathauto |
|
219 | + $permissions['administer pathauto'] = array( |
|
220 | 220 | 'name' => 'administer pathauto', |
221 | 221 | 'roles' => array( |
222 | - '0' => 'administrator', |
|
222 | + '0' => 'administrator', |
|
223 | 223 | ), |
224 | - ); |
|
224 | + ); |
|
225 | 225 | |
226 | - // Exported permission: administer permissions |
|
227 | - $permissions['administer permissions'] = array( |
|
226 | + // Exported permission: administer permissions |
|
227 | + $permissions['administer permissions'] = array( |
|
228 | 228 | 'name' => 'administer permissions', |
229 | 229 | 'roles' => array( |
230 | - '0' => 'administrator', |
|
230 | + '0' => 'administrator', |
|
231 | 231 | ), |
232 | - ); |
|
232 | + ); |
|
233 | 233 | |
234 | - // Exported permission: administer rules |
|
235 | - $permissions['administer rules'] = array( |
|
234 | + // Exported permission: administer rules |
|
235 | + $permissions['administer rules'] = array( |
|
236 | 236 | 'name' => 'administer rules', |
237 | 237 | 'roles' => array( |
238 | - '0' => 'administrator', |
|
238 | + '0' => 'administrator', |
|
239 | 239 | ), |
240 | - ); |
|
240 | + ); |
|
241 | 241 | |
242 | - // Exported permission: administer site configuration |
|
243 | - $permissions['administer site configuration'] = array( |
|
242 | + // Exported permission: administer site configuration |
|
243 | + $permissions['administer site configuration'] = array( |
|
244 | 244 | 'name' => 'administer site configuration', |
245 | 245 | 'roles' => array( |
246 | - '0' => 'administrator', |
|
246 | + '0' => 'administrator', |
|
247 | 247 | ), |
248 | - ); |
|
248 | + ); |
|
249 | 249 | |
250 | - // Exported permission: administer smtp module |
|
251 | - $permissions['administer smtp module'] = array( |
|
250 | + // Exported permission: administer smtp module |
|
251 | + $permissions['administer smtp module'] = array( |
|
252 | 252 | 'name' => 'administer smtp module', |
253 | 253 | 'roles' => array( |
254 | - '0' => 'administrator', |
|
254 | + '0' => 'administrator', |
|
255 | 255 | ), |
256 | - ); |
|
256 | + ); |
|
257 | 257 | |
258 | - // Exported permission: administer tabtamer |
|
259 | - $permissions['administer tabtamer'] = array( |
|
258 | + // Exported permission: administer tabtamer |
|
259 | + $permissions['administer tabtamer'] = array( |
|
260 | 260 | 'name' => 'administer tabtamer', |
261 | 261 | 'roles' => array( |
262 | - '0' => 'administrator', |
|
262 | + '0' => 'administrator', |
|
263 | 263 | ), |
264 | - ); |
|
264 | + ); |
|
265 | 265 | |
266 | - // Exported permission: administer taxonomy |
|
267 | - $permissions['administer taxonomy'] = array( |
|
266 | + // Exported permission: administer taxonomy |
|
267 | + $permissions['administer taxonomy'] = array( |
|
268 | 268 | 'name' => 'administer taxonomy', |
269 | 269 | 'roles' => array( |
270 | - '0' => 'administrator', |
|
270 | + '0' => 'administrator', |
|
271 | 271 | ), |
272 | - ); |
|
272 | + ); |
|
273 | 273 | |
274 | - // Exported permission: administer url aliases |
|
275 | - $permissions['administer url aliases'] = array( |
|
274 | + // Exported permission: administer url aliases |
|
275 | + $permissions['administer url aliases'] = array( |
|
276 | 276 | 'name' => 'administer url aliases', |
277 | 277 | 'roles' => array( |
278 | - '0' => 'administrator', |
|
278 | + '0' => 'administrator', |
|
279 | 279 | ), |
280 | - ); |
|
280 | + ); |
|
281 | 281 | |
282 | - // Exported permission: administer users |
|
283 | - $permissions['administer users'] = array( |
|
282 | + // Exported permission: administer users |
|
283 | + $permissions['administer users'] = array( |
|
284 | 284 | 'name' => 'administer users', |
285 | 285 | 'roles' => array( |
286 | - '0' => 'administrator', |
|
286 | + '0' => 'administrator', |
|
287 | 287 | ), |
288 | - ); |
|
288 | + ); |
|
289 | 289 | |
290 | - // Exported permission: administer views |
|
291 | - $permissions['administer views'] = array( |
|
290 | + // Exported permission: administer views |
|
291 | + $permissions['administer views'] = array( |
|
292 | 292 | 'name' => 'administer views', |
293 | 293 | 'roles' => array( |
294 | - '0' => 'administrator', |
|
294 | + '0' => 'administrator', |
|
295 | 295 | ), |
296 | - ); |
|
296 | + ); |
|
297 | 297 | |
298 | - // Exported permission: assign all roles |
|
299 | - $permissions['assign all roles'] = array( |
|
298 | + // Exported permission: assign all roles |
|
299 | + $permissions['assign all roles'] = array( |
|
300 | 300 | 'name' => 'assign all roles', |
301 | 301 | 'roles' => array( |
302 | - '0' => 'administrator', |
|
302 | + '0' => 'administrator', |
|
303 | 303 | ), |
304 | - ); |
|
304 | + ); |
|
305 | 305 | |
306 | - // Exported permission: change own username |
|
307 | - $permissions['change own username'] = array( |
|
306 | + // Exported permission: change own username |
|
307 | + $permissions['change own username'] = array( |
|
308 | 308 | 'name' => 'change own username', |
309 | 309 | 'roles' => array( |
310 | - '0' => 'administrator', |
|
310 | + '0' => 'administrator', |
|
311 | 311 | ), |
312 | - ); |
|
312 | + ); |
|
313 | 313 | |
314 | - // Exported permission: create mini panels |
|
315 | - $permissions['create mini panels'] = array( |
|
314 | + // Exported permission: create mini panels |
|
315 | + $permissions['create mini panels'] = array( |
|
316 | 316 | 'name' => 'create mini panels', |
317 | 317 | 'roles' => array( |
318 | - '0' => 'administrator', |
|
318 | + '0' => 'administrator', |
|
319 | 319 | ), |
320 | - ); |
|
320 | + ); |
|
321 | 321 | |
322 | - // Exported permission: create page content |
|
323 | - $permissions['create page content'] = array( |
|
322 | + // Exported permission: create page content |
|
323 | + $permissions['create page content'] = array( |
|
324 | 324 | 'name' => 'create page content', |
325 | 325 | 'roles' => array( |
326 | - '0' => 'administrator', |
|
327 | - '1' => 'content editor', |
|
326 | + '0' => 'administrator', |
|
327 | + '1' => 'content editor', |
|
328 | 328 | ), |
329 | - ); |
|
329 | + ); |
|
330 | 330 | |
331 | - // Exported permission: create panel-nodes |
|
332 | - $permissions['create panel-nodes'] = array( |
|
331 | + // Exported permission: create panel-nodes |
|
332 | + $permissions['create panel-nodes'] = array( |
|
333 | 333 | 'name' => 'create panel-nodes', |
334 | 334 | 'roles' => array( |
335 | - '0' => 'administrator', |
|
335 | + '0' => 'administrator', |
|
336 | 336 | ), |
337 | - ); |
|
337 | + ); |
|
338 | 338 | |
339 | - // Exported permission: create story content |
|
340 | - $permissions['create story content'] = array( |
|
339 | + // Exported permission: create story content |
|
340 | + $permissions['create story content'] = array( |
|
341 | 341 | 'name' => 'create story content', |
342 | 342 | 'roles' => array( |
343 | - '0' => 'administrator', |
|
343 | + '0' => 'administrator', |
|
344 | 344 | ), |
345 | - ); |
|
345 | + ); |
|
346 | 346 | |
347 | - // Exported permission: create url aliases |
|
348 | - $permissions['create url aliases'] = array( |
|
347 | + // Exported permission: create url aliases |
|
348 | + $permissions['create url aliases'] = array( |
|
349 | 349 | 'name' => 'create url aliases', |
350 | 350 | 'roles' => array( |
351 | - '0' => 'administrator', |
|
351 | + '0' => 'administrator', |
|
352 | 352 | ), |
353 | - ); |
|
353 | + ); |
|
354 | 354 | |
355 | - // Exported permission: delete any page content |
|
356 | - $permissions['delete any page content'] = array( |
|
355 | + // Exported permission: delete any page content |
|
356 | + $permissions['delete any page content'] = array( |
|
357 | 357 | 'name' => 'delete any page content', |
358 | 358 | 'roles' => array( |
359 | - '0' => 'administrator', |
|
360 | - '1' => 'content editor', |
|
359 | + '0' => 'administrator', |
|
360 | + '1' => 'content editor', |
|
361 | 361 | ), |
362 | - ); |
|
362 | + ); |
|
363 | 363 | |
364 | - // Exported permission: delete any panel-nodes |
|
365 | - $permissions['delete any panel-nodes'] = array( |
|
364 | + // Exported permission: delete any panel-nodes |
|
365 | + $permissions['delete any panel-nodes'] = array( |
|
366 | 366 | 'name' => 'delete any panel-nodes', |
367 | 367 | 'roles' => array( |
368 | - '0' => 'administrator', |
|
368 | + '0' => 'administrator', |
|
369 | 369 | ), |
370 | - ); |
|
370 | + ); |
|
371 | 371 | |
372 | - // Exported permission: delete any story content |
|
373 | - $permissions['delete any story content'] = array( |
|
372 | + // Exported permission: delete any story content |
|
373 | + $permissions['delete any story content'] = array( |
|
374 | 374 | 'name' => 'delete any story content', |
375 | 375 | 'roles' => array( |
376 | - '0' => 'administrator', |
|
376 | + '0' => 'administrator', |
|
377 | 377 | ), |
378 | - ); |
|
378 | + ); |
|
379 | 379 | |
380 | - // Exported permission: delete own account |
|
381 | - $permissions['delete own account'] = array( |
|
380 | + // Exported permission: delete own account |
|
381 | + $permissions['delete own account'] = array( |
|
382 | 382 | 'name' => 'delete own account', |
383 | 383 | 'roles' => array( |
384 | - '0' => 'administrator', |
|
385 | - '1' => 'authenticated user', |
|
384 | + '0' => 'administrator', |
|
385 | + '1' => 'authenticated user', |
|
386 | 386 | ), |
387 | - ); |
|
387 | + ); |
|
388 | 388 | |
389 | - // Exported permission: delete own page content |
|
390 | - $permissions['delete own page content'] = array( |
|
389 | + // Exported permission: delete own page content |
|
390 | + $permissions['delete own page content'] = array( |
|
391 | 391 | 'name' => 'delete own page content', |
392 | 392 | 'roles' => array( |
393 | - '0' => 'administrator', |
|
393 | + '0' => 'administrator', |
|
394 | 394 | ), |
395 | - ); |
|
395 | + ); |
|
396 | 396 | |
397 | - // Exported permission: delete own panel-nodes |
|
398 | - $permissions['delete own panel-nodes'] = array( |
|
397 | + // Exported permission: delete own panel-nodes |
|
398 | + $permissions['delete own panel-nodes'] = array( |
|
399 | 399 | 'name' => 'delete own panel-nodes', |
400 | 400 | 'roles' => array( |
401 | - '0' => 'administrator', |
|
401 | + '0' => 'administrator', |
|
402 | 402 | ), |
403 | - ); |
|
403 | + ); |
|
404 | 404 | |
405 | - // Exported permission: delete own story content |
|
406 | - $permissions['delete own story content'] = array( |
|
405 | + // Exported permission: delete own story content |
|
406 | + $permissions['delete own story content'] = array( |
|
407 | 407 | 'name' => 'delete own story content', |
408 | 408 | 'roles' => array( |
409 | - '0' => 'administrator', |
|
409 | + '0' => 'administrator', |
|
410 | 410 | ), |
411 | - ); |
|
411 | + ); |
|
412 | 412 | |
413 | - // Exported permission: delete revisions |
|
414 | - $permissions['delete revisions'] = array( |
|
413 | + // Exported permission: delete revisions |
|
414 | + $permissions['delete revisions'] = array( |
|
415 | 415 | 'name' => 'delete revisions', |
416 | 416 | 'roles' => array( |
417 | - '0' => 'administrator', |
|
418 | - '1' => 'content editor', |
|
417 | + '0' => 'administrator', |
|
418 | + '1' => 'content editor', |
|
419 | 419 | ), |
420 | - ); |
|
420 | + ); |
|
421 | 421 | |
422 | - // Exported permission: edit any page content |
|
423 | - $permissions['edit any page content'] = array( |
|
422 | + // Exported permission: edit any page content |
|
423 | + $permissions['edit any page content'] = array( |
|
424 | 424 | 'name' => 'edit any page content', |
425 | 425 | 'roles' => array( |
426 | - '0' => 'administrator', |
|
427 | - '1' => 'content editor', |
|
426 | + '0' => 'administrator', |
|
427 | + '1' => 'content editor', |
|
428 | 428 | ), |
429 | - ); |
|
429 | + ); |
|
430 | 430 | |
431 | - // Exported permission: edit any panel-nodes |
|
432 | - $permissions['edit any panel-nodes'] = array( |
|
431 | + // Exported permission: edit any panel-nodes |
|
432 | + $permissions['edit any panel-nodes'] = array( |
|
433 | 433 | 'name' => 'edit any panel-nodes', |
434 | 434 | 'roles' => array( |
435 | - '0' => 'administrator', |
|
435 | + '0' => 'administrator', |
|
436 | 436 | ), |
437 | - ); |
|
437 | + ); |
|
438 | 438 | |
439 | - // Exported permission: edit any story content |
|
440 | - $permissions['edit any story content'] = array( |
|
439 | + // Exported permission: edit any story content |
|
440 | + $permissions['edit any story content'] = array( |
|
441 | 441 | 'name' => 'edit any story content', |
442 | 442 | 'roles' => array( |
443 | - '0' => 'administrator', |
|
443 | + '0' => 'administrator', |
|
444 | 444 | ), |
445 | - ); |
|
445 | + ); |
|
446 | 446 | |
447 | - // Exported permission: edit own page content |
|
448 | - $permissions['edit own page content'] = array( |
|
447 | + // Exported permission: edit own page content |
|
448 | + $permissions['edit own page content'] = array( |
|
449 | 449 | 'name' => 'edit own page content', |
450 | 450 | 'roles' => array( |
451 | - '0' => 'administrator', |
|
451 | + '0' => 'administrator', |
|
452 | 452 | ), |
453 | - ); |
|
453 | + ); |
|
454 | 454 | |
455 | - // Exported permission: edit own panel-nodes |
|
456 | - $permissions['edit own panel-nodes'] = array( |
|
455 | + // Exported permission: edit own panel-nodes |
|
456 | + $permissions['edit own panel-nodes'] = array( |
|
457 | 457 | 'name' => 'edit own panel-nodes', |
458 | 458 | 'roles' => array( |
459 | - '0' => 'administrator', |
|
459 | + '0' => 'administrator', |
|
460 | 460 | ), |
461 | - ); |
|
461 | + ); |
|
462 | 462 | |
463 | - // Exported permission: edit own story content |
|
464 | - $permissions['edit own story content'] = array( |
|
463 | + // Exported permission: edit own story content |
|
464 | + $permissions['edit own story content'] = array( |
|
465 | 465 | 'name' => 'edit own story content', |
466 | 466 | 'roles' => array( |
467 | - '0' => 'administrator', |
|
467 | + '0' => 'administrator', |
|
468 | 468 | ), |
469 | - ); |
|
469 | + ); |
|
470 | 470 | |
471 | - // Exported permission: ignore user |
|
472 | - $permissions['ignore user'] = array( |
|
471 | + // Exported permission: ignore user |
|
472 | + $permissions['ignore user'] = array( |
|
473 | 473 | 'name' => 'ignore user', |
474 | 474 | 'roles' => array( |
475 | - '0' => 'authenticated user', |
|
475 | + '0' => 'authenticated user', |
|
476 | 476 | ), |
477 | - ); |
|
477 | + ); |
|
478 | 478 | |
479 | - // Exported permission: import input formats |
|
480 | - $permissions['import input formats'] = array( |
|
479 | + // Exported permission: import input formats |
|
480 | + $permissions['import input formats'] = array( |
|
481 | 481 | 'name' => 'import input formats', |
482 | 482 | 'roles' => array(), |
483 | - ); |
|
483 | + ); |
|
484 | 484 | |
485 | - // Exported permission: manage features |
|
486 | - $permissions['manage features'] = array( |
|
485 | + // Exported permission: manage features |
|
486 | + $permissions['manage features'] = array( |
|
487 | 487 | 'name' => 'manage features', |
488 | 488 | 'roles' => array( |
489 | - '0' => 'administrator', |
|
489 | + '0' => 'administrator', |
|
490 | 490 | ), |
491 | - ); |
|
491 | + ); |
|
492 | 492 | |
493 | - // Exported permission: notify of path changes |
|
494 | - $permissions['notify of path changes'] = array( |
|
493 | + // Exported permission: notify of path changes |
|
494 | + $permissions['notify of path changes'] = array( |
|
495 | 495 | 'name' => 'notify of path changes', |
496 | 496 | 'roles' => array( |
497 | - '0' => 'administrator', |
|
497 | + '0' => 'administrator', |
|
498 | 498 | ), |
499 | - ); |
|
499 | + ); |
|
500 | 500 | |
501 | - // Exported permission: reset abuse flags |
|
502 | - $permissions['reset abuse flags'] = array( |
|
501 | + // Exported permission: reset abuse flags |
|
502 | + $permissions['reset abuse flags'] = array( |
|
503 | 503 | 'name' => 'reset abuse flags', |
504 | 504 | 'roles' => array( |
505 | - '0' => 'administrator', |
|
506 | - '1' => 'moderator', |
|
505 | + '0' => 'administrator', |
|
506 | + '1' => 'moderator', |
|
507 | 507 | ), |
508 | - ); |
|
508 | + ); |
|
509 | 509 | |
510 | - // Exported permission: revert revisions |
|
511 | - $permissions['revert revisions'] = array( |
|
510 | + // Exported permission: revert revisions |
|
511 | + $permissions['revert revisions'] = array( |
|
512 | 512 | 'name' => 'revert revisions', |
513 | 513 | 'roles' => array( |
514 | - '0' => 'administrator', |
|
515 | - '1' => 'content editor', |
|
514 | + '0' => 'administrator', |
|
515 | + '1' => 'content editor', |
|
516 | 516 | ), |
517 | - ); |
|
517 | + ); |
|
518 | 518 | |
519 | - // Exported permission: select different theme |
|
520 | - $permissions['select different theme'] = array( |
|
519 | + // Exported permission: select different theme |
|
520 | + $permissions['select different theme'] = array( |
|
521 | 521 | 'name' => 'select different theme', |
522 | 522 | 'roles' => array( |
523 | - '0' => 'administrator', |
|
523 | + '0' => 'administrator', |
|
524 | 524 | ), |
525 | - ); |
|
525 | + ); |
|
526 | 526 | |
527 | - // Exported permission: upload files |
|
528 | - $permissions['upload files'] = array( |
|
527 | + // Exported permission: upload files |
|
528 | + $permissions['upload files'] = array( |
|
529 | 529 | 'name' => 'upload files', |
530 | 530 | 'roles' => array( |
531 | - '0' => 'administrator', |
|
532 | - '1' => 'content editor', |
|
531 | + '0' => 'administrator', |
|
532 | + '1' => 'content editor', |
|
533 | 533 | ), |
534 | - ); |
|
534 | + ); |
|
535 | 535 | |
536 | - // Exported permission: view uploaded files |
|
537 | - $permissions['view uploaded files'] = array( |
|
536 | + // Exported permission: view uploaded files |
|
537 | + $permissions['view uploaded files'] = array( |
|
538 | 538 | 'name' => 'view uploaded files', |
539 | 539 | 'roles' => array(), |
540 | - ); |
|
540 | + ); |
|
541 | 541 | |
542 | - // Exported permission: use PHP for block visibility |
|
543 | - $permissions['use PHP for block visibility'] = array( |
|
542 | + // Exported permission: use PHP for block visibility |
|
543 | + $permissions['use PHP for block visibility'] = array( |
|
544 | 544 | 'name' => 'use PHP for block visibility', |
545 | 545 | 'roles' => array( |
546 | - '0' => 'administrator', |
|
546 | + '0' => 'administrator', |
|
547 | 547 | ), |
548 | - ); |
|
548 | + ); |
|
549 | 549 | |
550 | - // Exported permission: use PHP for me alias paths |
|
551 | - $permissions['use PHP for me alias paths'] = array( |
|
550 | + // Exported permission: use PHP for me alias paths |
|
551 | + $permissions['use PHP for me alias paths'] = array( |
|
552 | 552 | 'name' => 'use PHP for me alias paths', |
553 | 553 | 'roles' => array( |
554 | - '0' => 'administrator', |
|
554 | + '0' => 'administrator', |
|
555 | 555 | ), |
556 | - ); |
|
556 | + ); |
|
557 | 557 | |
558 | - // Exported permission: use flag import |
|
559 | - $permissions['use flag import'] = array( |
|
558 | + // Exported permission: use flag import |
|
559 | + $permissions['use flag import'] = array( |
|
560 | 560 | 'name' => 'use flag import', |
561 | 561 | 'roles' => array( |
562 | - '0' => 'administrator', |
|
562 | + '0' => 'administrator', |
|
563 | 563 | ), |
564 | - ); |
|
564 | + ); |
|
565 | 565 | |
566 | - // Exported permission: use page manager |
|
567 | - $permissions['use page manager'] = array( |
|
566 | + // Exported permission: use page manager |
|
567 | + $permissions['use page manager'] = array( |
|
568 | 568 | 'name' => 'use page manager', |
569 | 569 | 'roles' => array( |
570 | - '0' => 'administrator', |
|
570 | + '0' => 'administrator', |
|
571 | 571 | ), |
572 | - ); |
|
572 | + ); |
|
573 | 573 | |
574 | - // Exported permission: use panels caching features |
|
575 | - $permissions['use panels caching features'] = array( |
|
574 | + // Exported permission: use panels caching features |
|
575 | + $permissions['use panels caching features'] = array( |
|
576 | 576 | 'name' => 'use panels caching features', |
577 | 577 | 'roles' => array( |
578 | - '0' => 'administrator', |
|
578 | + '0' => 'administrator', |
|
579 | 579 | ), |
580 | - ); |
|
580 | + ); |
|
581 | 581 | |
582 | - // Exported permission: use panels dashboard |
|
583 | - $permissions['use panels dashboard'] = array( |
|
582 | + // Exported permission: use panels dashboard |
|
583 | + $permissions['use panels dashboard'] = array( |
|
584 | 584 | 'name' => 'use panels dashboard', |
585 | 585 | 'roles' => array( |
586 | - '0' => 'administrator', |
|
586 | + '0' => 'administrator', |
|
587 | 587 | ), |
588 | - ); |
|
588 | + ); |
|
589 | 589 | |
590 | - // Exported permission: use panels in place editing |
|
591 | - $permissions['use panels in place editing'] = array( |
|
590 | + // Exported permission: use panels in place editing |
|
591 | + $permissions['use panels in place editing'] = array( |
|
592 | 592 | 'name' => 'use panels in place editing', |
593 | 593 | 'roles' => array( |
594 | - '0' => 'administrator', |
|
594 | + '0' => 'administrator', |
|
595 | 595 | ), |
596 | - ); |
|
596 | + ); |
|
597 | 597 | |
598 | - // Exported permission: view all panes |
|
599 | - $permissions['view all panes'] = array( |
|
598 | + // Exported permission: view all panes |
|
599 | + $permissions['view all panes'] = array( |
|
600 | 600 | 'name' => 'view all panes', |
601 | 601 | 'roles' => array( |
602 | - '0' => 'administrator', |
|
602 | + '0' => 'administrator', |
|
603 | 603 | ), |
604 | - ); |
|
604 | + ); |
|
605 | 605 | |
606 | - // Exported permission: view pane admin links |
|
607 | - $permissions['view pane admin links'] = array( |
|
606 | + // Exported permission: view pane admin links |
|
607 | + $permissions['view pane admin links'] = array( |
|
608 | 608 | 'name' => 'view pane admin links', |
609 | 609 | 'roles' => array( |
610 | - '0' => 'administrator', |
|
610 | + '0' => 'administrator', |
|
611 | 611 | ), |
612 | - ); |
|
612 | + ); |
|
613 | 613 | |
614 | - // Exported permission: view revisions |
|
615 | - $permissions['view revisions'] = array( |
|
614 | + // Exported permission: view revisions |
|
615 | + $permissions['view revisions'] = array( |
|
616 | 616 | 'name' => 'view revisions', |
617 | 617 | 'roles' => array( |
618 | - '0' => 'administrator', |
|
619 | - '1' => 'content editor', |
|
618 | + '0' => 'administrator', |
|
619 | + '1' => 'content editor', |
|
620 | 620 | ), |
621 | - ); |
|
621 | + ); |
|
622 | 622 | |
623 | - return $permissions; |
|
623 | + return $permissions; |
|
624 | 624 | } |