Passed
Pull Request — master (#3168)
by Christian
08:43
created
drupal/sites/default/boinc/modules/boinccore/boinccore.module 1 patch
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
  */
552 552
 function boinccore_locale($op = 'groups', $group = NULL) {
553 553
   switch ($op) {
554
-    case 'groups':
555
-        return array('boinc' => 'BOINC');
556
-    case 'info':
557
-      //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
558
-      $info['boinc']['format'] = FALSE;
559
-      return $info;
554
+  case 'groups':
555
+      return array('boinc' => 'BOINC');
556
+  case 'info':
557
+    //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
558
+    $info['boinc']['format'] = FALSE;
559
+    return $info;
560 560
   }
561 561
 }
562 562
 
@@ -1885,19 +1885,19 @@  discard block
 block discarded – undo
1885 1885
     // Transform arguments before inserting them.
1886 1886
     foreach ($args as $key => $value) {
1887 1887
       switch ($key [0]) {
1888
-        case '@':
1889
-          // Escaped only.
1890
-          $args [$key] = check_plain($value);
1891
-          break;
1892
-
1893
-        case '%':
1894
-        default:
1895
-          // Escaped and placeholder.
1896
-          $args [$key] = theme('placeholder', $value);
1897
-          break;
1898
-
1899
-        case '!':
1900
-          // Pass-through.
1888
+      case '@':
1889
+        // Escaped only.
1890
+        $args [$key] = check_plain($value);
1891
+        break;
1892
+
1893
+      case '%':
1894
+      default:
1895
+        // Escaped and placeholder.
1896
+        $args [$key] = theme('placeholder', $value);
1897
+        break;
1898
+
1899
+      case '!':
1900
+        // Pass-through.
1901 1901
       }
1902 1902
     }
1903 1903
     return strtr($string, $args);
Please login to merge, or discard this patch.
drupal/sites/default/boinc/themes/boinc/template.php 1 patch
Switch Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -626,13 +626,13 @@  discard block
 block discarded – undo
626 626
   $sender = user_load($sender->uid);
627 627
   
628 628
   switch ($status) {
629
-    case FLAG_FRIEND_FLAGGED:
630
-      // Sender accepted recipient's friend request
631
-      $email['subject'] = bts('!name accepted your friend request [!site]', array(
632
-        '!name' => $sender->boincuser_name,
633
-        '!site' => variable_get('site_name', 'Drupal-BOINC'),
634
-        ), NULL, 'boinc:friend-request-email');
635
-      $email['body'] = bts('!name confirmed you as a friend on !site.
629
+  case FLAG_FRIEND_FLAGGED:
630
+    // Sender accepted recipient's friend request
631
+    $email['subject'] = bts('!name accepted your friend request [!site]', array(
632
+      '!name' => $sender->boincuser_name,
633
+      '!site' => variable_get('site_name', 'Drupal-BOINC'),
634
+      ), NULL, 'boinc:friend-request-email');
635
+    $email['body'] = bts('!name confirmed you as a friend on !site.
636 636
 
637 637
 Follow this link to view his or her profile:
638 638
 !link
@@ -641,17 +641,17 @@  discard block
 block discarded – undo
641 641
 
642 642
 Thanks,
643 643
 The !site team', array(
644
-        '!name' => isset($sender->boincuser_name) ? $sender->boincuser_name : $sender->name,
645
-        '!site' => variable_get('site_name', 'Drupal-BOINC'),
646
-        '!message' => $flag->friend_message ? bts('Message', array(), NULL, 'boinc:friend-request-email:-1:a-private-message') . ': ' . $flag->friend_message : '',
647
-        '!link' => url('account/'. $sender->uid, array('absolute' => TRUE)),
648
-        ), array(), NULL, 'boinc:friend-request-email');
649
-      break;
644
+      '!name' => isset($sender->boincuser_name) ? $sender->boincuser_name : $sender->name,
645
+      '!site' => variable_get('site_name', 'Drupal-BOINC'),
646
+      '!message' => $flag->friend_message ? bts('Message', array(), NULL, 'boinc:friend-request-email:-1:a-private-message') . ': ' . $flag->friend_message : '',
647
+      '!link' => url('account/'. $sender->uid, array('absolute' => TRUE)),
648
+      ), array(), NULL, 'boinc:friend-request-email');
649
+    break;
650 650
 
651
-    case FLAG_FRIEND_PENDING:
652
-      // Sender is requesting to be recipient's friend
653
-      $email['subject'] = bts('Friend request from !name [!site]', array('!name' => $sender->boincuser_name, '!site' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:friend-request-email');
654
-      $email['body'] = bts('!name added you as a friend on !site. You can approve or deny this request. Denying a request will not send a notification, but will remove the request from both of your accounts.
651
+  case FLAG_FRIEND_PENDING:
652
+    // Sender is requesting to be recipient's friend
653
+    $email['subject'] = bts('Friend request from !name [!site]', array('!name' => $sender->boincuser_name, '!site' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:friend-request-email');
654
+    $email['body'] = bts('!name added you as a friend on !site. You can approve or deny this request. Denying a request will not send a notification, but will remove the request from both of your accounts.
655 655
 
656 656
 Follow the link below to view this request:
657 657
 !link
@@ -660,13 +660,13 @@  discard block
 block discarded – undo
660 660
 
661 661
 Thanks,
662 662
 The !site team', array(
663
-        '!name' => isset($sender->boincuser_name) ? $sender->boincuser_name : $sender->name,
664
-        '!site' => variable_get('site_name', 'Drupal-BOINC'),
665
-        '!message' => $flag->friend_message ? bts('Message', array(), NULL, 'boinc:friend-request-email:-1:a-private-message') . ': ' . $flag->friend_message : '',
666
-        '!link' => url('goto/friend-requests', array('absolute' => TRUE)),
667
-        ),
668
-      array(), NULL, 'boinc:friend-request-email');
669
-      break;
663
+      '!name' => isset($sender->boincuser_name) ? $sender->boincuser_name : $sender->name,
664
+      '!site' => variable_get('site_name', 'Drupal-BOINC'),
665
+      '!message' => $flag->friend_message ? bts('Message', array(), NULL, 'boinc:friend-request-email:-1:a-private-message') . ': ' . $flag->friend_message : '',
666
+      '!link' => url('goto/friend-requests', array('absolute' => TRUE)),
667
+      ),
668
+    array(), NULL, 'boinc:friend-request-email');
669
+    break;
670 670
   }
671 671
   return $email;
672 672
 }
Please login to merge, or discard this patch.
default/boinc/modules/boinctranslate/includes/boinctranslate.helpers.inc 1 patch
Switch Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1398,72 +1398,72 @@
 block discarded – undo
1398 1398
 
1399 1399
   switch ($op) {
1400 1400
     // Return stored strings
1401
-    case 'mem-report':
1402
-      return $strings;
1403
-
1404
-      // Store string in memory (only supports single strings)
1405
-    case 'mem-store':
1406
-      $strings[$value['msgid']] = $value['msgstr'];
1407
-      return;
1408
-
1409
-      // Called at end of import to inform the user
1410
-    case 'db-report':
1411
-      return array(
1412
-        $headerdone,
1413
-        $report['additions'],
1414
-        $report['updates'],
1415
-        $report['deletes'],
1416
-        $report['skips'],
1417
-      );
1401
+  case 'mem-report':
1402
+    return $strings;
1403
+
1404
+    // Store string in memory (only supports single strings)
1405
+  case 'mem-store':
1406
+    $strings[$value['msgid']] = $value['msgstr'];
1407
+    return;
1408
+
1409
+    // Called at end of import to inform the user
1410
+  case 'db-report':
1411
+    return array(
1412
+      $headerdone,
1413
+      $report['additions'],
1414
+      $report['updates'],
1415
+      $report['deletes'],
1416
+      $report['skips'],
1417
+    );
1418 1418
 
1419
-      // Store the string we got in the database.
1420
-    case 'db-store':
1421
-      // We got header information.
1422
-      if ($value['msgid'] == '') {
1423
-        $languages = language_list();
1424
-        if (($mode != LOCALE_IMPORT_KEEP) || empty($languages[$lang]->plurals)) {
1425
-          // Since we only need to parse the header if we ought to update the
1426
-          // plural formula, only run this if we don't need to keep existing
1427
-          // data untouched or if we don't have an existing plural formula.
1428
-          $header = _locale_import_parse_header($value['msgstr']);
1429
-
1430
-          // Get and store the plural formula if available.
1431
-          if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) {
1432
-            list($nplurals, $plural) = $p;
1433
-            db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang);
1434
-          }
1419
+    // Store the string we got in the database.
1420
+  case 'db-store':
1421
+    // We got header information.
1422
+    if ($value['msgid'] == '') {
1423
+      $languages = language_list();
1424
+      if (($mode != LOCALE_IMPORT_KEEP) || empty($languages[$lang]->plurals)) {
1425
+        // Since we only need to parse the header if we ought to update the
1426
+        // plural formula, only run this if we don't need to keep existing
1427
+        // data untouched or if we don't have an existing plural formula.
1428
+        $header = _locale_import_parse_header($value['msgstr']);
1429
+
1430
+        // Get and store the plural formula if available.
1431
+        if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) {
1432
+          list($nplurals, $plural) = $p;
1433
+          db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang);
1435 1434
         }
1436
-        $headerdone = TRUE;
1437 1435
       }
1436
+      $headerdone = TRUE;
1437
+    }
1438 1438
 
1439
-      else {
1440
-        // Some real string to import.
1441
-        $comments = _locale_import_shorten_comments(empty($value['#']) ? array() : $value['#']);
1442
-
1443
-        if (strpos($value['msgid'], "\0")) {
1444
-          // This string has plural versions.
1445
-          $english = explode("\0", $value['msgid'], 2);
1446
-          $entries = array_keys($value['msgstr']);
1447
-          for ($i = 3; $i <= count($entries); $i++) {
1448
-            $english[] = $english[1];
1449
-          }
1450
-          $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries);
1451
-          $english = array_map('_locale_import_append_plural', $english, $entries);
1452
-          foreach ($translation as $key => $trans) {
1453
-            if ($key == 0) {
1454
-              $plid = 0;
1455
-            }
1456
-            $plid = _boinctranslate_locale_import_one_string_db($report, $lang, $english[$key], $trans, $group, $comments, $mode, $plid, $key);
1439
+    else {
1440
+      // Some real string to import.
1441
+      $comments = _locale_import_shorten_comments(empty($value['#']) ? array() : $value['#']);
1442
+
1443
+      if (strpos($value['msgid'], "\0")) {
1444
+        // This string has plural versions.
1445
+        $english = explode("\0", $value['msgid'], 2);
1446
+        $entries = array_keys($value['msgstr']);
1447
+        for ($i = 3; $i <= count($entries); $i++) {
1448
+          $english[] = $english[1];
1449
+        }
1450
+        $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries);
1451
+        $english = array_map('_locale_import_append_plural', $english, $entries);
1452
+        foreach ($translation as $key => $trans) {
1453
+          if ($key == 0) {
1454
+            $plid = 0;
1457 1455
           }
1456
+          $plid = _boinctranslate_locale_import_one_string_db($report, $lang, $english[$key], $trans, $group, $comments, $mode, $plid, $key);
1458 1457
         }
1458
+      }
1459 1459
 
1460
-        else {
1461
-          // A simple string to import.
1462
-          $english = $value['msgid'];
1463
-          $translation = $value['msgstr'];
1464
-          _boinctranslate_locale_import_one_string_db($report, $lang, $english, $translation, $group, $comments, $mode);
1465
-        }
1460
+      else {
1461
+        // A simple string to import.
1462
+        $english = $value['msgid'];
1463
+        $translation = $value['msgstr'];
1464
+        _boinctranslate_locale_import_one_string_db($report, $lang, $english, $translation, $group, $comments, $mode);
1466 1465
       }
1466
+    }
1467 1467
   } // end of db-store operation
1468 1468
 }
1469 1469
 
Please login to merge, or discard this patch.
sites/default/boinc/modules/boinc_solr_search/boinc_solr_search.module 1 patch
Switch Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
  */
19 19
 function boinc_solr_search_block($op = 'list', $delta = 0, $edit = array()) {
20 20
   switch ($op) {
21
-    case 'list':
22
-      return boinc_solr_search_block_info();
23
-      break;
24
-    case 'view':
25
-      return boinc_solr_search_block_view($delta);
26
-      break;
27
-    case 'configure':
28
-    case 'save':
29
-    default:
21
+  case 'list':
22
+    return boinc_solr_search_block_info();
23
+    break;
24
+  case 'view':
25
+    return boinc_solr_search_block_view($delta);
26
+    break;
27
+  case 'configure':
28
+  case 'save':
29
+  default:
30 30
   }
31 31
 }
32 32
 
@@ -53,26 +53,26 @@  discard block
 block discarded – undo
53 53
 function boinc_solr_search_block_view($delta = 0) {
54 54
   $block = array();
55 55
   switch($delta) {
56
-    case 'boinc_solr_search_0':
57
-      $items = array(
58
-          bts('By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.', array(), NULL, 'boinc:search-help-sidebar-block'),
59
-          bts('You may use \'AND\' to have the search engine return results with ALL search terms.', array(), NULL, 'boinc:search-help-sidebar-block'),
60
-          bts('For example, searching for \'boinc AND client\' will only contain results with words boinc and client.', array(), NULL, 'boinc:search-help-sidebar-block')
61
-      );
56
+  case 'boinc_solr_search_0':
57
+    $items = array(
58
+        bts('By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.', array(), NULL, 'boinc:search-help-sidebar-block'),
59
+        bts('You may use \'AND\' to have the search engine return results with ALL search terms.', array(), NULL, 'boinc:search-help-sidebar-block'),
60
+        bts('For example, searching for \'boinc AND client\' will only contain results with words boinc and client.', array(), NULL, 'boinc:search-help-sidebar-block')
61
+    );
62 62
 
63
-      drupal_add_js('misc/collapse.js');
64
-      // For Drupal 7 the format of the array changes, see https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_fieldset/7.x for details.
65
-      $collapsible_item = array(
66
-        '#title' => bts('Search Help', array(), NULL, 'boinc:search-help-sidebar-block'),
67
-        '#description' => theme_item_list($items),
68
-        '#collapsible' => TRUE,
69
-        '#collapsed' => TRUE,
70
-        '#attributes' => array(
71
-          'class' => 'search-help-block',
72
-        ),
73
-      );
74
-      $block['content'] = theme('fieldset', $collapsible_item);
75
-      break;
63
+    drupal_add_js('misc/collapse.js');
64
+    // For Drupal 7 the format of the array changes, see https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_fieldset/7.x for details.
65
+    $collapsible_item = array(
66
+      '#title' => bts('Search Help', array(), NULL, 'boinc:search-help-sidebar-block'),
67
+      '#description' => theme_item_list($items),
68
+      '#collapsible' => TRUE,
69
+      '#collapsed' => TRUE,
70
+      '#attributes' => array(
71
+        'class' => 'search-help-block',
72
+      ),
73
+    );
74
+    $block['content'] = theme('fieldset', $collapsible_item);
75
+    break;
76 76
   }
77 77
   return $block;
78 78
 }
Please login to merge, or discard this patch.
html/inc/password_compat/password.inc 1 patch
Switch Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -50,47 +50,47 @@  discard block
 block discarded – undo
50 50
             }
51 51
             $resultLength = 0;
52 52
             switch ($algo) {
53
-                case PASSWORD_BCRYPT:
54
-                    $cost = PASSWORD_BCRYPT_DEFAULT_COST;
55
-                    if (isset($options['cost'])) {
56
-                        $cost = (int) $options['cost'];
57
-                        if ($cost < 4 || $cost > 31) {
58
-                            trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
59
-                            return null;
60
-                        }
53
+            case PASSWORD_BCRYPT:
54
+                $cost = PASSWORD_BCRYPT_DEFAULT_COST;
55
+                if (isset($options['cost'])) {
56
+                    $cost = (int) $options['cost'];
57
+                    if ($cost < 4 || $cost > 31) {
58
+                        trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
59
+                        return null;
61 60
                     }
62
-                    // The length of salt to generate
63
-                    $raw_salt_len = 16;
64
-                    // The length required in the final serialization
65
-                    $required_salt_len = 22;
66
-                    $hash_format = sprintf("$2y$%02d$", $cost);
67
-                    // The expected length of the final crypt() output
68
-                    $resultLength = 60;
69
-                    break;
70
-                default:
71
-                    trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
72
-                    return null;
61
+                }
62
+                // The length of salt to generate
63
+                $raw_salt_len = 16;
64
+                // The length required in the final serialization
65
+                $required_salt_len = 22;
66
+                $hash_format = sprintf("$2y$%02d$", $cost);
67
+                // The expected length of the final crypt() output
68
+                $resultLength = 60;
69
+                break;
70
+            default:
71
+                trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
72
+                return null;
73 73
             }
74 74
             $salt_req_encoding = false;
75 75
             if (isset($options['salt'])) {
76 76
                 switch (gettype($options['salt'])) {
77
-                    case 'NULL':
78
-                    case 'boolean':
79
-                    case 'integer':
80
-                    case 'double':
81
-                    case 'string':
77
+                case 'NULL':
78
+                case 'boolean':
79
+                case 'integer':
80
+                case 'double':
81
+                case 'string':
82
+                    $salt = (string) $options['salt'];
83
+                    break;
84
+                case 'object':
85
+                    if (method_exists($options['salt'], '__tostring')) {
82 86
                         $salt = (string) $options['salt'];
83 87
                         break;
84
-                    case 'object':
85
-                        if (method_exists($options['salt'], '__tostring')) {
86
-                            $salt = (string) $options['salt'];
87
-                            break;
88
-                        }
89
-                    case 'array':
90
-                    case 'resource':
91
-                    default:
92
-                        trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING);
93
-                        return null;
88
+                    }
89
+                case 'array':
90
+                case 'resource':
91
+                default:
92
+                    trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING);
93
+                    return null;
94 94
                 }
95 95
                 if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) {
96 96
                     trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING);
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
                 return true;
213 213
             }
214 214
             switch ($algo) {
215
-                case PASSWORD_BCRYPT:
216
-                    $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
217
-                    if ($cost !== $info['options']['cost']) {
218
-                        return true;
219
-                    }
220
-                    break;
215
+            case PASSWORD_BCRYPT:
216
+                $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
217
+                if ($cost !== $info['options']['cost']) {
218
+                    return true;
219
+                }
220
+                break;
221 221
             }
222 222
             return false;
223 223
         }
Please login to merge, or discard this patch.
modules/boincuser/boincuser_delete/includes/boincuser_delete.helpers.inc 1 patch
Switch Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -59,37 +59,37 @@
 block discarded – undo
59 59
   // hook_user() functions.
60 60
 
61 61
   switch ($action) {
62
-    case 'soft_obfuscate':
63
-      obfuscate_account($boinc_user);
64
-      _boincuser_delete_comment_reassign($account);
65
-      _boincuser_delete_node_reassign($account);
66
-      _boincuser_delete_privatemsg_delete($account);
67
-      _boincuser_delete_friends($account);
68
-      // delete the user's profile
69
-      $profile = content_profile_load('profile', $account->uid);
70
-      node_delete($profile->nid);
71
-      // Drupal account -
72
-      //  * 'block'/disable the account
73
-      //  * set name, mail, pass, and init to deleted
74
-      //  * erase signature
75
-      $myarray = array(
76
-        'status'    => 0,
77
-        'name'      => 'deleted_' . time() . '_' . random_string(),
78
-        'mail'      => 'deleted_' . time() . '_' . random_string(),
79
-        'pass'      => 'deleted_' . time() . '_' . random_string(),
80
-        'signature' => '',
81
-        'init'      => 'deleted_' . time() . '_' . random_string(),
82
-      );
83
-      user_save($account, $myarray);
84
-      break;
85
-    case 'hard_wipe':
86
-      wipe_account($boinc_user);
87
-      user_delete(array(), $account->uid);
88
-      break;
89
-    default:
90
-      watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array(
91
-        '%action' => $action,
92
-      ), WATCHDOG_ERROR);
62
+  case 'soft_obfuscate':
63
+    obfuscate_account($boinc_user);
64
+    _boincuser_delete_comment_reassign($account);
65
+    _boincuser_delete_node_reassign($account);
66
+    _boincuser_delete_privatemsg_delete($account);
67
+    _boincuser_delete_friends($account);
68
+    // delete the user's profile
69
+    $profile = content_profile_load('profile', $account->uid);
70
+    node_delete($profile->nid);
71
+    // Drupal account -
72
+    //  * 'block'/disable the account
73
+    //  * set name, mail, pass, and init to deleted
74
+    //  * erase signature
75
+    $myarray = array(
76
+      'status'    => 0,
77
+      'name'      => 'deleted_' . time() . '_' . random_string(),
78
+      'mail'      => 'deleted_' . time() . '_' . random_string(),
79
+      'pass'      => 'deleted_' . time() . '_' . random_string(),
80
+      'signature' => '',
81
+      'init'      => 'deleted_' . time() . '_' . random_string(),
82
+    );
83
+    user_save($account, $myarray);
84
+    break;
85
+  case 'hard_wipe':
86
+    wipe_account($boinc_user);
87
+    user_delete(array(), $account->uid);
88
+    break;
89
+  default:
90
+    watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array(
91
+      '%action' => $action,
92
+    ), WATCHDOG_ERROR);
93 93
   }
94 94
 }
95 95
 
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.admin.inc 1 patch
Switch Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -11,103 +11,103 @@  discard block
 block discarded – undo
11 11
   * (and other translation related settings)
12 12
   */
13 13
 function boinctranslate_admin_settings(&$form_state) {
14
-  $form = array();
15
-  $initialized = FALSE;
16
-  $import_enabled = FALSE;
17
-  $default = array(
18
-    'transifex_user' => variable_get('boinc_translate_transifex_user', ''),
19
-    'transifex_pass' => variable_get('boinc_translate_transifex_pass', ''),
20
-    'transifex_boinc_name' => variable_get(
21
-      'boinc_translate_transifex_standard_name', 'boinc'
22
-    ),
23
-    'transifex_boinc_resources' => variable_get(
24
-      'boinc_translate_transifex_standard_resources',
25
-      "project-generic\nweb"
26
-    ),
27
-    'transifex_boinc_drupal_resource' => variable_get(
28
-      'boinc_translate_transifex_boinc_drupal_resource',
29
-      'drupal'
30
-    ), 
31
-    'transifex_project_name' => variable_get(
32
-      'boinc_translate_transifex_project_name', ''
33
-    ),
34
-    'transifex_project_resources' => variable_get(
35
-      'boinc_translate_transifex_project_resources', ''
36
-    ), 
37
-  );
14
+$form = array();
15
+$initialized = FALSE;
16
+$import_enabled = FALSE;
17
+$default = array(
18
+'transifex_user' => variable_get('boinc_translate_transifex_user', ''),
19
+'transifex_pass' => variable_get('boinc_translate_transifex_pass', ''),
20
+'transifex_boinc_name' => variable_get(
21
+  'boinc_translate_transifex_standard_name', 'boinc'
22
+),
23
+'transifex_boinc_resources' => variable_get(
24
+  'boinc_translate_transifex_standard_resources',
25
+  "project-generic\nweb"
26
+),
27
+'transifex_boinc_drupal_resource' => variable_get(
28
+  'boinc_translate_transifex_boinc_drupal_resource',
29
+  'drupal'
30
+), 
31
+'transifex_project_name' => variable_get(
32
+  'boinc_translate_transifex_project_name', ''
33
+),
34
+'transifex_project_resources' => variable_get(
35
+  'boinc_translate_transifex_project_resources', ''
36
+), 
37
+);
38 38
   
39
-  if ($default['transifex_user'] AND $default['transifex_pass']) {
40
-    if (trim($default['transifex_boinc_resources'])
41
-    OR trim($default['transifex_project_resources'])) {
42
-      $import_enabled = TRUE;
43
-    }
44
-    if ($default['transifex_boinc_name']
45
-    AND $default['transifex_project_name']
46
-    AND trim($default['transifex_boinc_resources'])
47
-    AND trim($default['transifex_project_resources'])) {
48
-      $initialized = TRUE;
49
-    }
50
-  }
39
+if ($default['transifex_user'] AND $default['transifex_pass']) {
40
+if (trim($default['transifex_boinc_resources'])
41
+OR trim($default['transifex_project_resources'])) {
42
+  $import_enabled = TRUE;
43
+}
44
+if ($default['transifex_boinc_name']
45
+AND $default['transifex_project_name']
46
+AND trim($default['transifex_boinc_resources'])
47
+AND trim($default['transifex_project_resources'])) {
48
+  $initialized = TRUE;
49
+}
50
+}
51 51
   
52
-  // Define the form
52
+// Define the form
53 53
   
54
-  $form['transifex'] = array(
55
-    '#title' => t('Transifex settings'),
56
-    '#type' => 'fieldset',
57
-    '#description' => '',
58
-    '#collapsible' => TRUE,
59
-    '#collapsed' => $initialized,
60
-    '#attributes' => array('class' => '')
61
-  );
62
-  $form['transifex']['boinc_translate_transifex_user'] = array(
63
-    '#type' => 'textfield',
64
-    '#title' => t('User name'),
65
-    '#default_value' => $default['transifex_user'],
66
-  );
67
-  $form['transifex']['boinc_translate_transifex_pass'] = array(
68
-    '#type' => 'password',
69
-    '#title' => t('Password'),
70
-    '#attributes' => array(
71
-      'placeholder' => $default['transifex_pass'] ? '********' : '',
72
-    ),
73
-  );
74
-  $form['transifex']['boinc_translate_transifex_standard_name'] = array(
75
-    '#type' => 'textfield',
76
-    '#title' => t('BOINC Transifex project'),
77
-    '#default_value' => $default['transifex_boinc_name'],
78
-    '#description' => t('The portion of the Transifex URL that identifies BOINC.'),
79
-  );
80
-  $form['transifex']['boinc_translate_transifex_boinc_drupal_resource'] = array(
81
-    '#type' => 'textfield',
82
-    '#title' => t('Official BOINC Drupal Resource'),
83
-    '#default_value' => $default['transifex_boinc_drupal_resource'],
84
-    '#description' => t('The portion of the Transifex URL that identifies
54
+$form['transifex'] = array(
55
+'#title' => t('Transifex settings'),
56
+'#type' => 'fieldset',
57
+'#description' => '',
58
+'#collapsible' => TRUE,
59
+'#collapsed' => $initialized,
60
+'#attributes' => array('class' => '')
61
+);
62
+$form['transifex']['boinc_translate_transifex_user'] = array(
63
+'#type' => 'textfield',
64
+'#title' => t('User name'),
65
+'#default_value' => $default['transifex_user'],
66
+);
67
+$form['transifex']['boinc_translate_transifex_pass'] = array(
68
+'#type' => 'password',
69
+'#title' => t('Password'),
70
+'#attributes' => array(
71
+  'placeholder' => $default['transifex_pass'] ? '********' : '',
72
+),
73
+);
74
+$form['transifex']['boinc_translate_transifex_standard_name'] = array(
75
+'#type' => 'textfield',
76
+'#title' => t('BOINC Transifex project'),
77
+'#default_value' => $default['transifex_boinc_name'],
78
+'#description' => t('The portion of the Transifex URL that identifies BOINC.'),
79
+);
80
+$form['transifex']['boinc_translate_transifex_boinc_drupal_resource'] = array(
81
+'#type' => 'textfield',
82
+'#title' => t('Official BOINC Drupal Resource'),
83
+'#default_value' => $default['transifex_boinc_drupal_resource'],
84
+'#description' => t('The portion of the Transifex URL that identifies
85 85
       the standard BOINC Resource to use for translation of the public
86 86
       content defined in the Drupal system.'),
87
-  );
88
-  $form['transifex']['boinc_translate_transifex_standard_resources'] = array(
89
-    '#type' => 'textarea',
90
-    '#title' => t('Additional BOINC Resources'),
91
-    '#default_value' => $default['transifex_boinc_resources'],
92
-    '#description' => t('List additional BOINC Transifex Resources to be used
87
+);
88
+$form['transifex']['boinc_translate_transifex_standard_resources'] = array(
89
+'#type' => 'textarea',
90
+'#title' => t('Additional BOINC Resources'),
91
+'#default_value' => $default['transifex_boinc_resources'],
92
+'#description' => t('List additional BOINC Transifex Resources to be used
93 93
       for translating strings on this site (one Resource string per line).
94 94
       Resources will be imported in the order they are given, so
95 95
       translations from the Resources at the top of the list will be overridden
96 96
       by any matching translations found in Resources further down the list.
97 97
       Note that strings from the Official BOINC Drupal Resource will override
98 98
       any strings from these additional Resources.'),
99
-  );
100
-  $form['transifex']['boinc_translate_transifex_project_name'] = array(
101
-    '#type' => 'textfield',
102
-    '#title' => t('Project-specific Transifex project'),
103
-    '#default_value' => $default['transifex_project_name'],
104
-    '#description' => t('The portion of the Transifex URL that identifies this project.'),
105
-  );
106
-  $form['transifex']['boinc_translate_transifex_project_resources'] = array(
107
-    '#type' => 'textarea',
108
-    '#title' => t('Project-specific Resources'),
109
-    '#default_value' => $default['transifex_project_resources'],
110
-    '#description' => t('List project-specific Transifex Resources to be used
99
+);
100
+$form['transifex']['boinc_translate_transifex_project_name'] = array(
101
+'#type' => 'textfield',
102
+'#title' => t('Project-specific Transifex project'),
103
+'#default_value' => $default['transifex_project_name'],
104
+'#description' => t('The portion of the Transifex URL that identifies this project.'),
105
+);
106
+$form['transifex']['boinc_translate_transifex_project_resources'] = array(
107
+'#type' => 'textarea',
108
+'#title' => t('Project-specific Resources'),
109
+'#default_value' => $default['transifex_project_resources'],
110
+'#description' => t('List project-specific Transifex Resources to be used
111 111
       for translating strings on this site (one Resource string per line).
112 112
       Resources will be imported in the order they are given, so
113 113
       translations from the Resources at the top of the list will be overridden
@@ -116,123 +116,123 @@  discard block
 block discarded – undo
116 116
       NOTE: The first Resource listed here is considered the primary Resource
117 117
       for project-specific translations and will be updated by the "Update
118 118
       project-specific Resources" button below!'),
119
-  );
120
-  $form['transifex']['buttons']['submit'] = array(
121
-    '#type' => 'submit',
122
-    '#value' => t('Save configuration'),
123
-  );
119
+);
120
+$form['transifex']['buttons']['submit'] = array(
121
+'#type' => 'submit',
122
+'#value' => t('Save configuration'),
123
+);
124 124
   
125
-  $form['tools'] = array(
126
-    '#title' => t('Tools'),
127
-    '#type' => 'fieldset',
128
-    '#description' => '',
129
-    '#collapsible' => TRUE,
130
-    '#collapsed' => FALSE,
131
-    '#attributes' => array('class' => '')
132
-  );
133
-  $form['tools']['initialize_languages_text'] = array(
134
-    '#type' => 'item',
135
-    '#title' => t('Install official BOINC languages'),
136
-    '#value' => t('Installs all languages from the BOINC Transifex project. Also installs missing languages in Drupal. <br>Languages must be enabled manually in Administer > Site configuration > Languages.'),
137
-  );
138
-  $form['tools']['initialize_languages'] = array(
139
-    '#type' => 'button',
140
-    '#value' => t('Install official BOINC languages'),
141
-    '#executes_submit_callback' => TRUE,
142
-    '#submit' => array('boinctranslate_admin_settings_initialize_languages'),
143
-    '#disabled' => !$initialized,
144
-  );
145
-  $form['tools']['import_now_text'] = array(
146
-    '#type' => 'item',
147
-    '#title' => t('Import all translations'),
148
-    '#value' => t('Imports from Tranifex all configured Resources into their respective text groups.'),
149
-  );
150
-  $form['tools']['import_now'] = array(
151
-    '#type' => 'button',
152
-    '#value' => t('Import all translations'),
153
-    '#executes_submit_callback' => TRUE,
154
-    '#submit' => array('boinctranslate_admin_settings_import_now'),
155
-    '#disabled' => !$import_enabled,
156
-  );
157
-  $form['tools']['download_boinc_pot_text'] = array(
158
-    '#type' => 'item',
159
-    '#title' => t('Download official BOINC-Drupal .pot'),
160
-    '#value' => t('Downloads the generic BOINC-Drupal .pot file. This is the template file for the boinc text group.'),
161
-  );
162
-  $form['tools']['download_boinc_pot'] = array(
163
-    '#type' => 'button',
164
-    '#value' => t('Download official BOINC-Drupal .pot'),
165
-    '#executes_submit_callback' => TRUE,
166
-    '#submit' => array('boinctranslate_admin_settings_download_boinc_pot'),
167
-    '#disabled' => !$import_enabled,
168
-  );
169
-  $form['tools']['download_project_pot_text'] = array(
170
-    '#type' => 'item',
171
-    '#title' => t('Download project-specific .pot'),
172
-    '#value' => t('Downloads the project-specific .pot file. This is the template file for the project text group.'),
173
-  );
174
-  $form['tools']['download_project_pot'] = array(
175
-    '#type' => 'button',
176
-    '#value' => t('Download project-specific .pot'),
177
-    '#executes_submit_callback' => TRUE,
178
-    '#submit' => array('boinctranslate_admin_settings_download_project_pot'),
179
-    '#disabled' => !$import_enabled,
180
-  );
181
-  if (user_access('update official BOINC translations')) {
182
-    $form['tools']['update_official_boinc_text'] = array(
183
-      '#type' => 'item',
184
-      '#title' => t('Update official BOINC translations'),
185
-      '#value' => t('Updates the official BOINC-Drupal Resource (translatable strings templates) to the BOINC Transifex project, based on the consolidated imported translations.<br><b>WARNING: Do not use unless you have write-access to the BOINC Transifex project.</b>'),
186
-    );
187
-    $form['tools']['update_official_boinc'] = array(
188
-      '#type' => 'button',
189
-      '#value' => t('Update official BOINC translations'),
190
-      '#executes_submit_callback' => TRUE,
191
-      '#submit' => array('boinctranslate_admin_settings_update_official_boinc'),
192
-      '#disabled' => !$import_enabled,
193
-    );
194
-  }
195
-  $form['tools']['export_now_text'] = array(
196
-    '#type' => 'item',
197
-    '#title' => t('Update project-specific Resources'),
198
-    '#value' => t('Updates the configured Resources (translatable strings templates) to the project\'s Transifex project.<br><b>WARNING: Do not use unless you have write-access to your project\'s Transifex project.</b>'),
199
-  );
200
-  $form['tools']['export_now'] = array(
201
-    '#type' => 'button',
202
-    '#value' => t('Update project-specific Resources'),
203
-    '#executes_submit_callback' => TRUE,
204
-    '#submit' => array('boinctranslate_admin_settings_export_now'),
205
-    '#disabled' => !$import_enabled,
206
-  );
125
+$form['tools'] = array(
126
+'#title' => t('Tools'),
127
+'#type' => 'fieldset',
128
+'#description' => '',
129
+'#collapsible' => TRUE,
130
+'#collapsed' => FALSE,
131
+'#attributes' => array('class' => '')
132
+);
133
+$form['tools']['initialize_languages_text'] = array(
134
+'#type' => 'item',
135
+'#title' => t('Install official BOINC languages'),
136
+'#value' => t('Installs all languages from the BOINC Transifex project. Also installs missing languages in Drupal. <br>Languages must be enabled manually in Administer > Site configuration > Languages.'),
137
+);
138
+$form['tools']['initialize_languages'] = array(
139
+'#type' => 'button',
140
+'#value' => t('Install official BOINC languages'),
141
+'#executes_submit_callback' => TRUE,
142
+'#submit' => array('boinctranslate_admin_settings_initialize_languages'),
143
+'#disabled' => !$initialized,
144
+);
145
+$form['tools']['import_now_text'] = array(
146
+'#type' => 'item',
147
+'#title' => t('Import all translations'),
148
+'#value' => t('Imports from Tranifex all configured Resources into their respective text groups.'),
149
+);
150
+$form['tools']['import_now'] = array(
151
+'#type' => 'button',
152
+'#value' => t('Import all translations'),
153
+'#executes_submit_callback' => TRUE,
154
+'#submit' => array('boinctranslate_admin_settings_import_now'),
155
+'#disabled' => !$import_enabled,
156
+);
157
+$form['tools']['download_boinc_pot_text'] = array(
158
+'#type' => 'item',
159
+'#title' => t('Download official BOINC-Drupal .pot'),
160
+'#value' => t('Downloads the generic BOINC-Drupal .pot file. This is the template file for the boinc text group.'),
161
+);
162
+$form['tools']['download_boinc_pot'] = array(
163
+'#type' => 'button',
164
+'#value' => t('Download official BOINC-Drupal .pot'),
165
+'#executes_submit_callback' => TRUE,
166
+'#submit' => array('boinctranslate_admin_settings_download_boinc_pot'),
167
+'#disabled' => !$import_enabled,
168
+);
169
+$form['tools']['download_project_pot_text'] = array(
170
+'#type' => 'item',
171
+'#title' => t('Download project-specific .pot'),
172
+'#value' => t('Downloads the project-specific .pot file. This is the template file for the project text group.'),
173
+);
174
+$form['tools']['download_project_pot'] = array(
175
+'#type' => 'button',
176
+'#value' => t('Download project-specific .pot'),
177
+'#executes_submit_callback' => TRUE,
178
+'#submit' => array('boinctranslate_admin_settings_download_project_pot'),
179
+'#disabled' => !$import_enabled,
180
+);
181
+if (user_access('update official BOINC translations')) {
182
+$form['tools']['update_official_boinc_text'] = array(
183
+  '#type' => 'item',
184
+  '#title' => t('Update official BOINC translations'),
185
+  '#value' => t('Updates the official BOINC-Drupal Resource (translatable strings templates) to the BOINC Transifex project, based on the consolidated imported translations.<br><b>WARNING: Do not use unless you have write-access to the BOINC Transifex project.</b>'),
186
+);
187
+$form['tools']['update_official_boinc'] = array(
188
+  '#type' => 'button',
189
+  '#value' => t('Update official BOINC translations'),
190
+  '#executes_submit_callback' => TRUE,
191
+  '#submit' => array('boinctranslate_admin_settings_update_official_boinc'),
192
+  '#disabled' => !$import_enabled,
193
+);
194
+}
195
+$form['tools']['export_now_text'] = array(
196
+'#type' => 'item',
197
+'#title' => t('Update project-specific Resources'),
198
+'#value' => t('Updates the configured Resources (translatable strings templates) to the project\'s Transifex project.<br><b>WARNING: Do not use unless you have write-access to your project\'s Transifex project.</b>'),
199
+);
200
+$form['tools']['export_now'] = array(
201
+'#type' => 'button',
202
+'#value' => t('Update project-specific Resources'),
203
+'#executes_submit_callback' => TRUE,
204
+'#submit' => array('boinctranslate_admin_settings_export_now'),
205
+'#disabled' => !$import_enabled,
206
+);
207 207
   
208
-  $form['#submit'][] = 'system_settings_form_submit';
209
-  $form['#theme'] = 'system_settings_form'; 
208
+$form['#submit'][] = 'system_settings_form_submit';
209
+$form['#theme'] = 'system_settings_form'; 
210 210
   
211
-  return $form;
211
+return $form;
212 212
 }
213 213
 
214 214
 function boinctranslate_admin_settings_export_now() {
215
-  drupal_goto('admin/boinc/translation/export');
215
+drupal_goto('admin/boinc/translation/export');
216 216
 }
217 217
 
218 218
 function boinctranslate_admin_settings_import_now() {
219
-  drupal_goto('admin/boinc/translation/import');
219
+drupal_goto('admin/boinc/translation/import');
220 220
 }
221 221
 
222 222
 function boinctranslate_admin_settings_initialize_languages() {
223
-  drupal_goto('admin/boinc/translation/initialize-languages');
223
+drupal_goto('admin/boinc/translation/initialize-languages');
224 224
 }
225 225
 
226 226
 function boinctranslate_admin_settings_update_official_boinc() {
227
-  drupal_goto('admin/boinc/translation/update-official-boinc');
227
+drupal_goto('admin/boinc/translation/update-official-boinc');
228 228
 }
229 229
 
230 230
 function boinctranslate_admin_settings_download_boinc_pot() {
231
-  drupal_goto('admin/boinc/translation/download-pot/boinc');
231
+drupal_goto('admin/boinc/translation/download-pot/boinc');
232 232
 }
233 233
 
234 234
 function boinctranslate_admin_settings_download_project_pot() {
235
-  drupal_goto('admin/boinc/translation/download-pot/project');
235
+drupal_goto('admin/boinc/translation/download-pot/project');
236 236
 }
237 237
 
238 238
 
@@ -240,117 +240,117 @@  discard block
 block discarded – undo
240 240
   * Validate the BOINC translation settings form.
241 241
   */
242 242
 function boinctranslate_admin_settings_validate($form, &$form_state) {
243
-  $values = $form_state['values'];
244
-  $errors = array();
245
-  $api_base_url = 'https://www.transifex.com/api/2';
243
+$values = $form_state['values'];
244
+$errors = array();
245
+$api_base_url = 'https://www.transifex.com/api/2';
246
+  
247
+if (!$values['boinc_translate_transifex_user']) {
248
+form_set_error('boinc_translate_transifex_user', t('User name is required.'));
249
+}
250
+if (!$values['boinc_translate_transifex_pass']) {
251
+if (!variable_get('boinc_translate_transifex_pass', '')) {
252
+  form_set_error('boinc_translate_transifex_pass', t('Password is required.'));
253
+}
254
+else {
255
+  unset($form_state['values']['boinc_translate_transifex_pass']);
256
+}
257
+}
258
+if (!$values['boinc_translate_transifex_standard_name']) {
259
+form_set_error('boinc_translate_transifex_standard_name', 
260
+  t('BOINC Transifex project name is required.')
261
+);
262
+}
263
+if (!$values['boinc_translate_transifex_standard_resources']) {
264
+form_set_error('boinc_translate_transifex_standard_resources',
265
+  t('At least one BOINC Transifex project Resource is required.')
266
+);
267
+}
268
+if (!$values['boinc_translate_transifex_project_resources']) {
269
+form_set_error('boinc_translate_transifex_project_resources',
270
+  t('At least one project-specific Transifex Resource is required.')
271
+);
272
+}
246 273
   
247
-  if (!$values['boinc_translate_transifex_user']) {
248
-    form_set_error('boinc_translate_transifex_user', t('User name is required.'));
274
+$username = $values['boinc_translate_transifex_user'];
275
+$password = ($values['boinc_translate_transifex_pass']) ? $values['boinc_translate_transifex_pass'] : variable_get('boinc_translate_transifex_pass', '');
276
+$boinc_name = $values['boinc_translate_transifex_standard_name'];
277
+$boinc_resources = boinctranslate_parse_resources(
278
+$values['boinc_translate_transifex_standard_resources']
279
+);
280
+  
281
+if ($username AND $password AND $boinc_name AND $boinc_resources) {
282
+// Test authentication
283
+$authenticated = FALSE;
284
+$path = "project/{$boinc_name}/resource/{$boinc_resources[0]}/translation/en";
285
+$response = boinctranslate_transifex_request($path, NULL, TRUE, FALSE, $username, $password);
286
+    
287
+if ($response) {
288
+  if ($response == '401 UNAUTHORIZED') {
289
+    form_set_error(
290
+      'boinc_translate_transifex_pass',
291
+      t('Transifex authentication failed.')
292
+    );
249 293
   }
250
-  if (!$values['boinc_translate_transifex_pass']) {
251
-    if (!variable_get('boinc_translate_transifex_pass', '')) {
252
-      form_set_error('boinc_translate_transifex_pass', t('Password is required.'));
253
-    }
254
-    else {
255
-      unset($form_state['values']['boinc_translate_transifex_pass']);
256
-    }
294
+  else {
295
+    $authenticated = TRUE;
257 296
   }
258
-  if (!$values['boinc_translate_transifex_standard_name']) {
259
-    form_set_error('boinc_translate_transifex_standard_name', 
260
-      t('BOINC Transifex project name is required.')
261
-    );
297
+}
298
+    
299
+if ($authenticated) {
300
+  // Prepare list of resources to validate
301
+  $transifex_resources = array(
302
+    'boinc' => $boinc_resources,
303
+  );
304
+  // Parse project-specific resources
305
+  $project_name = trim($values['boinc_translate_transifex_project_name']);
306
+  $project_resources = boinctranslate_parse_resources(
307
+    $values['boinc_translate_transifex_project_resources']
308
+  );
309
+  if ($project_name AND $project_resources) {
310
+    $transifex_resources[$project_name] = $project_resources;
262 311
   }
263
-  if (!$values['boinc_translate_transifex_standard_resources']) {
264
-    form_set_error('boinc_translate_transifex_standard_resources',
265
-      t('At least one BOINC Transifex project Resource is required.')
312
+  elseif ($project_name AND !$project_resources) {
313
+    drupal_set_message(
314
+      t('No project-specific resources were provided'),
315
+      'warning'
266 316
     );
267 317
   }
268
-  if (!$values['boinc_translate_transifex_project_resources']) {
269
-    form_set_error('boinc_translate_transifex_project_resources',
270
-      t('At least one project-specific Transifex Resource is required.')
318
+  elseif ($project_resources AND !$project_name) {
319
+    drupal_set_message(
320
+      t('No project-specific Transifex project name was provided'),
321
+      'warning'
271 322
     );
272 323
   }
273
-  
274
-  $username = $values['boinc_translate_transifex_user'];
275
-  $password = ($values['boinc_translate_transifex_pass']) ? $values['boinc_translate_transifex_pass'] : variable_get('boinc_translate_transifex_pass', '');
276
-  $boinc_name = $values['boinc_translate_transifex_standard_name'];
277
-  $boinc_resources = boinctranslate_parse_resources(
278
-    $values['boinc_translate_transifex_standard_resources']
279
-  );
280
-  
281
-  if ($username AND $password AND $boinc_name AND $boinc_resources) {
282
-    // Test authentication
283
-    $authenticated = FALSE;
284
-    $path = "project/{$boinc_name}/resource/{$boinc_resources[0]}/translation/en";
285
-    $response = boinctranslate_transifex_request($path, NULL, TRUE, FALSE, $username, $password);
286
-    
287
-    if ($response) {
288
-      if ($response == '401 UNAUTHORIZED') {
289
-        form_set_error(
290
-          'boinc_translate_transifex_pass',
291
-          t('Transifex authentication failed.')
292
-        );
293
-      }
294
-      else {
295
-        $authenticated = TRUE;
296
-      }
297
-    }
298
-    
299
-    if ($authenticated) {
300
-      // Prepare list of resources to validate
301
-      $transifex_resources = array(
302
-        'boinc' => $boinc_resources,
303
-      );
304
-      // Parse project-specific resources
305
-      $project_name = trim($values['boinc_translate_transifex_project_name']);
306
-      $project_resources = boinctranslate_parse_resources(
307
-        $values['boinc_translate_transifex_project_resources']
308
-      );
309
-      if ($project_name AND $project_resources) {
310
-        $transifex_resources[$project_name] = $project_resources;
311
-      }
312
-      elseif ($project_name AND !$project_resources) {
313
-        drupal_set_message(
314
-          t('No project-specific resources were provided'),
315
-          'warning'
316
-        );
317
-      }
318
-      elseif ($project_resources AND !$project_name) {
319
-        drupal_set_message(
320
-          t('No project-specific Transifex project name was provided'),
321
-          'warning'
322
-        );
323
-      }
324 324
       
325
-      // Try to access the given resources
326
-      foreach ($transifex_resources as $project => $resources) {
327
-        foreach ($resources as $resource) {
325
+  // Try to access the given resources
326
+  foreach ($transifex_resources as $project => $resources) {
327
+    foreach ($resources as $resource) {
328 328
           
329
-          $path = "project/{$project}/resource/{$resource}/translation/en";
330
-          $response = boinctranslate_transifex_request($path);
329
+      $path = "project/{$project}/resource/{$resource}/translation/en";
330
+      $response = boinctranslate_transifex_request($path);
331 331
           
332
-          if ($response == '404 NOT FOUND') {
333
-            form_set_error(
334
-              'boinc_translate_transifex_' . ($project == $boinc_name ? 'standard' : 'project') . '_resources',
335
-              t('Resource %name not found in %project.',
336
-                array(
337
-                  '%name' => $resource,
338
-                  '%project' => $project,
339
-                )
340
-              )
341
-            );
342
-          }
343
-        }
332
+      if ($response == '404 NOT FOUND') {
333
+        form_set_error(
334
+          'boinc_translate_transifex_' . ($project == $boinc_name ? 'standard' : 'project') . '_resources',
335
+          t('Resource %name not found in %project.',
336
+            array(
337
+              '%name' => $resource,
338
+              '%project' => $project,
339
+            )
340
+          )
341
+        );
344 342
       }
345 343
     }
346 344
   }
347 345
 }
346
+}
347
+}
348 348
 
349 349
 /**
350 350
   * Handle post-validation submission of BOINC translation settings form.
351 351
   */
352 352
 function boinctranslate_admin_settings_submit($form, &$form_state) {
353
-  drupal_set_message(t('BOINC translation settings have been updated.'));
353
+drupal_set_message(t('BOINC translation settings have been updated.'));
354 354
 }
355 355
 
356 356
 
Please login to merge, or discard this patch.
default/boinc/modules/boincuser/boincuser_delete/boincuser_delete.module 1 patch
Switch Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -94,69 +94,69 @@  discard block
 block discarded – undo
94 94
   global $user;
95 95
 
96 96
   switch($form_id) {
97
-    case 'user_profile_form':
98
-      if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) {
99
-        $form['delete'] = array(
100
-          '#type' => 'submit',
101
-          '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
102
-          '#weight' => 1009,
103
-          '#submit' => array('user_edit_delete_submit'),
104
-          '#prefix' => '<li class="tab">',
105
-          '#suffix' => '</li>',
106
-        );
107
-      }
108
-      else if ( user_access('administer users') ) {
109
-        $form['delete'] = array(
110
-          '#type' => 'submit',
111
-          '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
112
-          '#weight' => 1009,
113
-          '#submit' => array('_boincuser_delete_goto_admindelete'),
114
-          '#prefix' => '<li class="tab">',
115
-          '#suffix' => '</li>',
116
-        );
117
-      }
118
-      else {
119
-        unset($form['delete']);
120
-      }
121
-      break;
122
-    case 'user_confirm_delete':
123
-
124
-      $disable_delete = FALSE;
125
-      // If email address was changed less than 7 days (7 * 86400 s)
126
-      // ago, it cannot be changed again.
127
-      $duration = TOKEN_DURATION_ONE_WEEK;
128
-      if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) {
129
-        drupal_set_message(
130
-          bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.",
131
-            array(
132
-              '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration),
133
-            ), NULL, 'boinc:account-credentials-change')
134
-        , 'info');
135
-        $disable_delete = TRUE;
136
-      }
137
-
138
-      // Configure radio options
139
-      $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. Your user profile will be deleted. Your host information will be deleted. And you will be removed from any team you are a member of.", array(), NULL, 'boinc:delete-user-account');
140
-
141
-      $deleteoptions = array(
142
-        'boincuser_delete_softdelete' => bts('<b>Soft delete</b> your account. Your account will be disabled. ', array(), NULL, 'boinc:delete-user-account'),
143
-        'boincuser_delete_delete' => bts('<b>Delete</b> your account. ', array(), NULL, 'boinc:delete-user-account'),
97
+  case 'user_profile_form':
98
+    if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) {
99
+      $form['delete'] = array(
100
+        '#type' => 'submit',
101
+        '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
102
+        '#weight' => 1009,
103
+        '#submit' => array('user_edit_delete_submit'),
104
+        '#prefix' => '<li class="tab">',
105
+        '#suffix' => '</li>',
106
+      );
107
+    }
108
+    else if ( user_access('administer users') ) {
109
+      $form['delete'] = array(
110
+        '#type' => 'submit',
111
+        '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
112
+        '#weight' => 1009,
113
+        '#submit' => array('_boincuser_delete_goto_admindelete'),
114
+        '#prefix' => '<li class="tab">',
115
+        '#suffix' => '</li>',
144 116
       );
117
+    }
118
+    else {
119
+      unset($form['delete']);
120
+    }
121
+    break;
122
+  case 'user_confirm_delete':
123
+
124
+    $disable_delete = FALSE;
125
+    // If email address was changed less than 7 days (7 * 86400 s)
126
+    // ago, it cannot be changed again.
127
+    $duration = TOKEN_DURATION_ONE_WEEK;
128
+    if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) {
129
+      drupal_set_message(
130
+        bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.",
131
+          array(
132
+            '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration),
133
+          ), NULL, 'boinc:account-credentials-change')
134
+      , 'info');
135
+      $disable_delete = TRUE;
136
+    }
137
+
138
+    // Configure radio options
139
+    $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. Your user profile will be deleted. Your host information will be deleted. And you will be removed from any team you are a member of.", array(), NULL, 'boinc:delete-user-account');
140
+
141
+    $deleteoptions = array(
142
+      'boincuser_delete_softdelete' => bts('<b>Soft delete</b> your account. Your account will be disabled. ', array(), NULL, 'boinc:delete-user-account'),
143
+      'boincuser_delete_delete' => bts('<b>Delete</b> your account. ', array(), NULL, 'boinc:delete-user-account'),
144
+    );
145 145
 
146
-      $dtypes = variable_get('boincuser_delete_type', 'user_decides');
147
-      // Unset the other option if dtype is set. i.e., if dtype is set
148
-      // to soft delete, unset the hard delete option.  Likewise, add
149
-      // the 'common_acts' sentences to the option that remains.
150
-      switch ($dtypes) {
151
-        case 'soft_obfuscate':
152
-          unset($deleteoptions['boincuser_delete_delete']);
153
-          $deleteoptions['boincuser_delete_softdelete'] .= $common_acts;
154
-          break;
155
-        case 'hard_wipe':
156
-          unset($deleteoptions['boincuser_delete_softdelete']);
157
-          $deleteoptions['boincuser_delete_delete'] .= $common_acts;
158
-          break;
159
-      }
146
+    $dtypes = variable_get('boincuser_delete_type', 'user_decides');
147
+    // Unset the other option if dtype is set. i.e., if dtype is set
148
+    // to soft delete, unset the hard delete option.  Likewise, add
149
+    // the 'common_acts' sentences to the option that remains.
150
+    switch ($dtypes) {
151
+    case 'soft_obfuscate':
152
+    unset($deleteoptions['boincuser_delete_delete']);
153
+    $deleteoptions['boincuser_delete_softdelete'] .= $common_acts;
154
+    break;
155
+    case 'hard_wipe':
156
+    unset($deleteoptions['boincuser_delete_softdelete']);
157
+    $deleteoptions['boincuser_delete_delete'] .= $common_acts;
158
+    break;
159
+    }
160 160
 
161 161
       $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?';
162 162
       drupal_set_title($question);
@@ -324,56 +324,56 @@  discard block
 block discarded – undo
324 324
   // create token with 1 day/24 hour expiration
325 325
   $mytoken = create_token($account->boincuser_id, 'D', 24*60*60);
326 326
   switch ($op) {
327
-    case 'boincuser_delete_softdelete':
328
-      $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken";
327
+  case 'boincuser_delete_softdelete':
328
+    $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken";
329 329
       break;
330
-    case 'boincuser_delete_delete':
331
-      $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken";
332
-      break;
333
-  }
334
-
335
-  $mysubject = "Instructions for account deletion at {$site_name}";
336
-  $mymessage = ''
337
-    . "{$account->boincuser_name},\n"
338
-    . "\n"
339
-    . "We have received a request to DELETE your user account at "
340
-    . "${site_name}. Below in this email is a one-time token you must "
341
-    . "use. Either click on the link or copy-and-paste the URL into your "
342
-    . "browser address bar. Then you will be required to enter your password "
343
-    . "again to confirm your identity.\n"
344
-    . "\n"
345
-    . "${myurl}\n"
346
-    . "\n"
347
-    . "This one-time token will expire in 24 hours. Afterwards you must "
348
-    . "re-request deletion of your account in order to generate a new token.\n"
349
-    . "\n"
350
-    . "If you did not initiate this request, please login to the "
351
-    . "${site_name} Web site (${site_url}) and "
352
-    . "then contact the administrators.\n"
353
-    . "\n"
354
-    . "Thanks, \n"
355
-    . "\n"
356
-    . "{$site_name} support team";
357
-
358
-  // Create array for sending email to user to notify account is being
359
-  // disabled/deleted. Then send email.
360
-  $settings = array(
361
-    'from' => '',
362
-    'subject' => $mysubject,
363
-    'message' => $mymessage,
364
-  );
365
-  rules_action_mail_to_user($account, $settings);
366
-
367
-  drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info');
330
+case 'boincuser_delete_delete':
331
+  $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken";
332
+  break;
333
+}
368 334
 
369
-  $redirect = variable_get('boincuser_delete_redirect', '<front>');
370
-  // Redirect
371
-  if (!empty($redirect)) {
372
-    drupal_goto($redirect);
373
-  }
374
-  else {
375
-    drupal_goto();
376
-  }
335
+$mysubject = "Instructions for account deletion at {$site_name}";
336
+$mymessage = ''
337
+. "{$account->boincuser_name},\n"
338
+. "\n"
339
+. "We have received a request to DELETE your user account at "
340
+. "${site_name}. Below in this email is a one-time token you must "
341
+. "use. Either click on the link or copy-and-paste the URL into your "
342
+. "browser address bar. Then you will be required to enter your password "
343
+. "again to confirm your identity.\n"
344
+. "\n"
345
+. "${myurl}\n"
346
+. "\n"
347
+. "This one-time token will expire in 24 hours. Afterwards you must "
348
+. "re-request deletion of your account in order to generate a new token.\n"
349
+. "\n"
350
+. "If you did not initiate this request, please login to the "
351
+. "${site_name} Web site (${site_url}) and "
352
+. "then contact the administrators.\n"
353
+. "\n"
354
+. "Thanks, \n"
355
+. "\n"
356
+. "{$site_name} support team";
357
+
358
+// Create array for sending email to user to notify account is being
359
+// disabled/deleted. Then send email.
360
+$settings = array(
361
+'from' => '',
362
+'subject' => $mysubject,
363
+'message' => $mymessage,
364
+);
365
+rules_action_mail_to_user($account, $settings);
366
+
367
+drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info');
368
+
369
+$redirect = variable_get('boincuser_delete_redirect', '<front>');
370
+// Redirect
371
+if (!empty($redirect)) {
372
+drupal_goto($redirect);
373
+}
374
+else {
375
+drupal_goto();
376
+}
377 377
 }
378 378
 
379 379
 
@@ -385,88 +385,88 @@  discard block
 block discarded – undo
385 385
  * The final confirmation form for the user to delete their account.
386 386
  */
387 387
 function boincuser_delete_finalconfirmation(&$form_state, $token) {
388
-  require_boinc('token');
389
-
390
-  global $user;
391
-  $form = array();
392
-
393
-  // check BOINC user exists
394
-  $account = user_load(array('uid' => $user->uid));
395
-  $uid = $user->uid;
396
-  $boincid = $account->boincuser_id;
397
-  // check $token is valid
398
-  if (!is_valid_token($boincid, $token, 'D')) {
399
-    drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
400
-    array(
401
-      '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
402
-    ),
403
-    NULL, 'boinc:delete-user-account'), 'error');
404
-    drupal_goto();
405
-  }
406
-
407
-  // Attach account to this form.
408
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
409
-
410
-  // This form is for hard/wipe delete
411
-  $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe');
412
-
413
-  // Instructions
414
-  $form['main']['fs1'] = array(
415
-    '#type' => 'fieldset',
416
-    '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
417
-    '#weight' => 10,
418
-    '#collapsible' => TRUE,
419
-    '#collapsed' => TRUE,
420
-  );
421
-  $form['main']['fs1']['instructions1'] = array(
422
-    '#value' => '<p>'.
423
-    bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
424
-    '</p>',
425
-    '#prefix' => "<div id='delete-instructions'>",
426
-    '#suffix' => "</div>",
427
-  );
428
-
429
-  $form['main']['fs1']['instructions2'] = array(
430
-    '#value' => '<p>'.
431
-    bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
432
-    '</p>',
433
-    '#prefix' => "<div id='delete-instructions'>",
434
-    '#suffix' => "</div>",
435
-  );
436
-
437
-  // Password field
438
-  $form['main']['current_pass'] = array(
439
-    '#type' => 'password',
440
-    '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
441
-    '#size' => 17,
442
-    '#attributes' => array(
443
-      'autocomplete' => 'off',
444
-    ),
445
-    '#weight' => 25,
446
-  );
447
-
448
-  // Form control
449
-  $form['form control tabs prefix'] = array(
450
-    '#value' => '<ul class="form-control tab-list">',
451
-    '#weight' => 1001,
452
-  );
453
-  $form['submit'] = array(
454
-    '#prefix' => '<li class="first tab">',
455
-    '#type' => 'submit',
456
-    '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
457
-    '#suffix' => '</li>',
458
-    '#weight' => 1002,
459
-  );
460
-  $form['form control tabs'] = array(
461
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
462
-    '#weight' => 1003,
463
-  );
464
-  $form['form control tabs suffix'] = array(
465
-    '#value' => '</ul>',
466
-    '#weight' => 1004,
467
-  );
388
+require_boinc('token');
389
+
390
+global $user;
391
+$form = array();
392
+
393
+// check BOINC user exists
394
+$account = user_load(array('uid' => $user->uid));
395
+$uid = $user->uid;
396
+$boincid = $account->boincuser_id;
397
+// check $token is valid
398
+if (!is_valid_token($boincid, $token, 'D')) {
399
+drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
400
+array(
401
+  '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
402
+),
403
+NULL, 'boinc:delete-user-account'), 'error');
404
+drupal_goto();
405
+}
468 406
 
469
-  return $form;
407
+// Attach account to this form.
408
+$form['_account'] = array('#type' => 'value', '#value' => $account);
409
+
410
+// This form is for hard/wipe delete
411
+$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe');
412
+
413
+// Instructions
414
+$form['main']['fs1'] = array(
415
+'#type' => 'fieldset',
416
+'#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
417
+'#weight' => 10,
418
+'#collapsible' => TRUE,
419
+'#collapsed' => TRUE,
420
+);
421
+$form['main']['fs1']['instructions1'] = array(
422
+'#value' => '<p>'.
423
+bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
424
+'</p>',
425
+'#prefix' => "<div id='delete-instructions'>",
426
+'#suffix' => "</div>",
427
+);
428
+
429
+$form['main']['fs1']['instructions2'] = array(
430
+'#value' => '<p>'.
431
+bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
432
+'</p>',
433
+'#prefix' => "<div id='delete-instructions'>",
434
+'#suffix' => "</div>",
435
+);
436
+
437
+// Password field
438
+$form['main']['current_pass'] = array(
439
+'#type' => 'password',
440
+'#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
441
+'#size' => 17,
442
+'#attributes' => array(
443
+  'autocomplete' => 'off',
444
+),
445
+'#weight' => 25,
446
+);
447
+
448
+// Form control
449
+$form['form control tabs prefix'] = array(
450
+'#value' => '<ul class="form-control tab-list">',
451
+'#weight' => 1001,
452
+);
453
+$form['submit'] = array(
454
+'#prefix' => '<li class="first tab">',
455
+'#type' => 'submit',
456
+'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
457
+'#suffix' => '</li>',
458
+'#weight' => 1002,
459
+);
460
+$form['form control tabs'] = array(
461
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
462
+'#weight' => 1003,
463
+);
464
+$form['form control tabs suffix'] = array(
465
+'#value' => '</ul>',
466
+'#weight' => 1004,
467
+);
468
+
469
+return $form;
470 470
 }
471 471
 
472 472
 /**
@@ -474,133 +474,133 @@  discard block
 block discarded – undo
474 474
  * the soft/obfuscate method.
475 475
  */
476 476
 function boincuser_delete_softdelconfirmation(&$form_state, $token) {
477
-  require_boinc('token');
478
-
479
-  global $user;
480
-  $form = array();
481
-
482
-  // check BOINC user exists
483
-  $account = user_load(array('uid' => $user->uid));
484
-  $uid = $user->uid;
485
-  $boincid = $account->boincuser_id;
486
-
487
-  // check $token is valid
488
-  if (!is_valid_token($boincid, $token, 'D')) {
489
-    drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
490
-    array(
491
-      '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
492
-    ),
493
-    NULL, 'boinc:delete-user-account'), 'error');
494
-    drupal_goto();
495
-  }
496
-
497
-  // Attach account to this form.
498
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
499
-
500
-  // This form is for hard/wipe delete
501
-  $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate');
502
-
503
-  // Instructions
504
-  $form['main']['fs1'] = array(
505
-    '#type' => 'fieldset',
506
-    '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
507
-    '#weight' => 10,
508
-    '#collapsible' => TRUE,
509
-    '#collapsed' => TRUE,
510
-  );
511
-  $form['main']['fs1']['instructions1'] = array(
512
-    '#value' => '<p>'.
513
-    bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
514
-    '</p>',
515
-    '#prefix' => "<div id='delete-instructions'>",
516
-    '#suffix' => "</div>",
517
-  );
518
-
519
-  $form['main']['fs1']['instructions2'] = array(
520
-    '#value' => '<p>'.
521
-    bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
522
-    '</p>',
523
-    '#prefix' => "<div id='delete-instructions'>",
524
-    '#suffix' => "</div>",
525
-  );
526
-
527
-  // Password field
528
-  $form['main']['current_pass'] = array(
529
-    '#type' => 'password',
530
-    '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
531
-    '#size' => 17,
532
-    '#attributes' => array(
533
-      'autocomplete' => 'off',
534
-    ),
535
-    '#weight' => 25,
536
-  );
537
-
538
-  // Form control
539
-  $form['form control tabs prefix'] = array(
540
-    '#value' => '<ul class="form-control tab-list">',
541
-    '#weight' => 1001,
542
-  );
543
-  $form['submit'] = array(
544
-    '#prefix' => '<li class="first tab">',
545
-    '#type' => 'submit',
546
-    '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
547
-    '#suffix' => '</li>',
548
-    '#weight' => 1002,
549
-  );
550
-  $form['form control tabs'] = array(
551
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
552
-    '#weight' => 1003,
553
-  );
554
-  $form['form control tabs suffix'] = array(
555
-    '#value' => '</ul>',
556
-    '#weight' => 1004,
557
-  );
477
+require_boinc('token');
478
+
479
+global $user;
480
+$form = array();
481
+
482
+// check BOINC user exists
483
+$account = user_load(array('uid' => $user->uid));
484
+$uid = $user->uid;
485
+$boincid = $account->boincuser_id;
486
+
487
+// check $token is valid
488
+if (!is_valid_token($boincid, $token, 'D')) {
489
+drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
490
+array(
491
+  '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
492
+),
493
+NULL, 'boinc:delete-user-account'), 'error');
494
+drupal_goto();
495
+}
558 496
 
559
-  //set validation and submit to the functions below
560
-  $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate';
561
-  $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit';
562
-  return $form;
497
+// Attach account to this form.
498
+$form['_account'] = array('#type' => 'value', '#value' => $account);
499
+
500
+// This form is for hard/wipe delete
501
+$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate');
502
+
503
+// Instructions
504
+$form['main']['fs1'] = array(
505
+'#type' => 'fieldset',
506
+'#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
507
+'#weight' => 10,
508
+'#collapsible' => TRUE,
509
+'#collapsed' => TRUE,
510
+);
511
+$form['main']['fs1']['instructions1'] = array(
512
+'#value' => '<p>'.
513
+bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
514
+'</p>',
515
+'#prefix' => "<div id='delete-instructions'>",
516
+'#suffix' => "</div>",
517
+);
518
+
519
+$form['main']['fs1']['instructions2'] = array(
520
+'#value' => '<p>'.
521
+bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
522
+'</p>',
523
+'#prefix' => "<div id='delete-instructions'>",
524
+'#suffix' => "</div>",
525
+);
526
+
527
+// Password field
528
+$form['main']['current_pass'] = array(
529
+'#type' => 'password',
530
+'#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
531
+'#size' => 17,
532
+'#attributes' => array(
533
+  'autocomplete' => 'off',
534
+),
535
+'#weight' => 25,
536
+);
537
+
538
+// Form control
539
+$form['form control tabs prefix'] = array(
540
+'#value' => '<ul class="form-control tab-list">',
541
+'#weight' => 1001,
542
+);
543
+$form['submit'] = array(
544
+'#prefix' => '<li class="first tab">',
545
+'#type' => 'submit',
546
+'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
547
+'#suffix' => '</li>',
548
+'#weight' => 1002,
549
+);
550
+$form['form control tabs'] = array(
551
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
552
+'#weight' => 1003,
553
+);
554
+$form['form control tabs suffix'] = array(
555
+'#value' => '</ul>',
556
+'#weight' => 1004,
557
+);
558
+
559
+//set validation and submit to the functions below
560
+$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate';
561
+$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit';
562
+return $form;
563 563
 }
564 564
 
565 565
 /**
566 566
  * Validation for final confirmation
567 567
  */
568 568
 function boincuser_delete_finalconfirmation_validate($form, &$form_state) {
569
-  $account = $form_state['values']['_account'];
570
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
569
+$account = $form_state['values']['_account'];
570
+$boinc_user = BoincUser::lookup_id($account->boincuser_id);
571 571
 
572
-  if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
573
-    return true;
574
-  }
572
+if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
573
+return true;
574
+}
575 575
 }
576 576
 
577 577
 /**
578 578
  * Submit for final confirmation
579 579
  */
580 580
 function boincuser_delete_finalconfirmation_submit($form, &$form_state) {
581
-  global $user;
582
-
583
-  // Delete the user
584
-  $account = $form_state['values']['_account'];
585
-  $action = $form_state['values']['_action'];
586
-  _boincuser_delete_deleteuser($account, $action);
587
-
588
-  // Destroy the current session:
589
-  session_destroy();
590
-  // Only variables can be passed by reference workaround.
591
-  $null = NULL;
592
-  user_module_invoke('logout', $null, $user);
593
-
594
-  // Load the anonymous user
595
-  $user = drupal_anonymous_user();
596
-
597
-  $redirect = variable_get('boincuser_delete_redirect', '<front>');
598
-  // Redirect
599
-  if (!empty($redirect)) {
600
-    drupal_goto($redirect);
601
-  }
602
-  else {
603
-    drupal_goto();
604
-  }
581
+global $user;
582
+
583
+// Delete the user
584
+$account = $form_state['values']['_account'];
585
+$action = $form_state['values']['_action'];
586
+_boincuser_delete_deleteuser($account, $action);
587
+
588
+// Destroy the current session:
589
+session_destroy();
590
+// Only variables can be passed by reference workaround.
591
+$null = NULL;
592
+user_module_invoke('logout', $null, $user);
593
+
594
+// Load the anonymous user
595
+$user = drupal_anonymous_user();
596
+
597
+$redirect = variable_get('boincuser_delete_redirect', '<front>');
598
+// Redirect
599
+if (!empty($redirect)) {
600
+drupal_goto($redirect);
601
+}
602
+else {
603
+drupal_goto();
604
+}
605 605
 
606 606
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 1 patch
Switch Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
     }
644 644
     break;
645 645
     
646
-    default:
647
-      // Don't generate form elements for things that aren't explicitly form
648
-      // elements (i.e. 'title', '@attributes' keys, and the like)
646
+  default:
647
+    // Don't generate form elements for things that aren't explicitly form
648
+    // elements (i.e. 'title', '@attributes' keys, and the like)
649 649
   }
650 650
 }
651 651
 
@@ -1990,29 +1990,29 @@  discard block
 block discarded – undo
1990 1990
  */
1991 1991
 function pretty_application_version($appverid, $vernum, $plan_class, $plfm) {
1992 1992
   switch ($appverid) {
1993
-    case ANON_PLATFORM_UNKNOWN:
1994
-      return "Anonymous platform";
1995
-    case ANON_PLATFORM_CPU:
1996
-      return "Anonymous platform CPU";
1997
-    case ANON_PLATFORM_NVIDIA:
1998
-      return "Anonymous platform NVIDIA GPU";
1999
-    case ANON_PLATFORM_ATI:
2000
-      return "Anonymous platform AMD GPU";
2001
-    case ANON_PLATFORM_INTEL:
2002
-      return "Anonymous platform Intel GPU";
2003
-    case 0:
2004
-      return "---";
2005
-    default:
2006
-      // Handle the case where the appversid is still negative. This
2007
-      // may be cause BOINC has introduced a new anonymous platform
2008
-      // that is not handled by the above case statements.
2009
-      if ($appverid < 0) {
2010
-        return "Unknown Anonymous platform";
2011
-      }
2012
-      else {
2013
-        $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2014
-        $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2015
-        return "v$prettyv $prettyc $plfm";
2016
-      }
1993
+  case ANON_PLATFORM_UNKNOWN:
1994
+    return "Anonymous platform";
1995
+  case ANON_PLATFORM_CPU:
1996
+    return "Anonymous platform CPU";
1997
+  case ANON_PLATFORM_NVIDIA:
1998
+    return "Anonymous platform NVIDIA GPU";
1999
+  case ANON_PLATFORM_ATI:
2000
+    return "Anonymous platform AMD GPU";
2001
+  case ANON_PLATFORM_INTEL:
2002
+    return "Anonymous platform Intel GPU";
2003
+  case 0:
2004
+    return "---";
2005
+  default:
2006
+    // Handle the case where the appversid is still negative. This
2007
+    // may be cause BOINC has introduced a new anonymous platform
2008
+    // that is not handled by the above case statements.
2009
+    if ($appverid < 0) {
2010
+      return "Unknown Anonymous platform";
2011
+    }
2012
+    else {
2013
+      $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2014
+      $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2015
+      return "v$prettyv $prettyc $plfm";
2016
+    }
2017 2017
   }
2018 2018
 }
Please login to merge, or discard this patch.