@@ -551,12 +551,12 @@ discard block |
||
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 |
||
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); |
@@ -626,13 +626,13 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -1398,72 +1398,72 @@ |
||
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 |
@@ -18,15 +18,15 @@ discard block |
||
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 |
||
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 | } |
@@ -13,255 +13,255 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function boincuser_views_data() { |
15 | 15 | |
16 | - // ----------------------------------------------------------------------------------------------- |
|
17 | - // Definition for user table |
|
18 | - // ----------------------------------------------------------------------------------------------- |
|
16 | +// ----------------------------------------------------------------------------------------------- |
|
17 | +// Definition for user table |
|
18 | +// ----------------------------------------------------------------------------------------------- |
|
19 | 19 | |
20 | - $data['user']['table']['group'] = t('BOINC'); |
|
20 | +$data['user']['table']['group'] = t('BOINC'); |
|
21 | 21 | |
22 | - $data['user']['table']['base'] = array( |
|
23 | - 'field' => 'id', |
|
24 | - 'title' => t('BOINC user'), |
|
25 | - 'help' => t('BOINC account data for a user'), |
|
26 | - 'database' => 'boinc_ro' |
|
27 | - ); |
|
22 | +$data['user']['table']['base'] = array( |
|
23 | + 'field' => 'id', |
|
24 | + 'title' => t('BOINC user'), |
|
25 | + 'help' => t('BOINC account data for a user'), |
|
26 | + 'database' => 'boinc_ro' |
|
27 | +); |
|
28 | 28 | |
29 | - // Describe each of the individual fields in this table to Views. For |
|
30 | - // each field, you may define what field, sort, argument, and/or filter |
|
31 | - // handlers it supports. This will determine where in the Views interface you |
|
32 | - // may use the field. |
|
29 | +// Describe each of the individual fields in this table to Views. For |
|
30 | +// each field, you may define what field, sort, argument, and/or filter |
|
31 | +// handlers it supports. This will determine where in the Views interface you |
|
32 | +// may use the field. |
|
33 | 33 | |
34 | - // Primary keys allowed as arguments |
|
34 | +// Primary keys allowed as arguments |
|
35 | 35 | |
36 | - $data['user']['id'] = array( |
|
37 | - 'title' => bts('Id', array(), NULL, 'boinc:user-id'), |
|
38 | - 'help' => t('The BOINC ID of the user account.'), |
|
39 | - 'field' => array( |
|
40 | - 'handler' => 'views_handler_field_numeric', |
|
41 | - 'click sortable' => TRUE |
|
42 | - ), |
|
43 | - 'argument' => array( |
|
44 | - 'handler' => 'views_handler_argument_boincuser_id', // custom handler |
|
45 | - 'name field' => 'title', // the field to display in the summary. |
|
46 | - 'numeric' => TRUE, |
|
47 | - 'validate type' => 'id' |
|
48 | - ), |
|
49 | - 'filter' => array( |
|
50 | - 'handler' => 'views_handler_filter_numeric' |
|
51 | - ), |
|
52 | - 'sort' => array( |
|
53 | - 'handler' => 'views_handler_sort_numeric' |
|
54 | - ) |
|
55 | - ); |
|
56 | - $data['user']['teamid'] = array( |
|
57 | - 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
|
58 | - 'help' => t('The ID of the user\'s team.'), |
|
59 | - 'field' => array( |
|
60 | - 'handler' => 'views_handler_field_numeric', |
|
61 | - 'click sortable' => TRUE, |
|
62 | - ), |
|
63 | - 'argument' => array( |
|
64 | - 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
65 | - 'name field' => 'title', // the field to display in the summary. |
|
66 | - 'numeric' => TRUE, |
|
67 | - 'validate type' => 'id' |
|
68 | - ), |
|
69 | - 'filter' => array( |
|
70 | - 'handler' => 'views_handler_filter_numeric' |
|
71 | - ), |
|
72 | - 'sort' => array( |
|
73 | - 'handler' => 'views_handler_sort_numeric' |
|
74 | - ) |
|
75 | - ); |
|
36 | +$data['user']['id'] = array( |
|
37 | +'title' => bts('Id', array(), NULL, 'boinc:user-id'), |
|
38 | +'help' => t('The BOINC ID of the user account.'), |
|
39 | +'field' => array( |
|
40 | + 'handler' => 'views_handler_field_numeric', |
|
41 | + 'click sortable' => TRUE |
|
42 | +), |
|
43 | +'argument' => array( |
|
44 | + 'handler' => 'views_handler_argument_boincuser_id', // custom handler |
|
45 | + 'name field' => 'title', // the field to display in the summary. |
|
46 | + 'numeric' => TRUE, |
|
47 | + 'validate type' => 'id' |
|
48 | +), |
|
49 | +'filter' => array( |
|
50 | + 'handler' => 'views_handler_filter_numeric' |
|
51 | +), |
|
52 | +'sort' => array( |
|
53 | + 'handler' => 'views_handler_sort_numeric' |
|
54 | +) |
|
55 | +); |
|
56 | +$data['user']['teamid'] = array( |
|
57 | +'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
|
58 | +'help' => t('The ID of the user\'s team.'), |
|
59 | +'field' => array( |
|
60 | + 'handler' => 'views_handler_field_numeric', |
|
61 | + 'click sortable' => TRUE, |
|
62 | +), |
|
63 | +'argument' => array( |
|
64 | + 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
65 | + 'name field' => 'title', // the field to display in the summary. |
|
66 | + 'numeric' => TRUE, |
|
67 | + 'validate type' => 'id' |
|
68 | +), |
|
69 | +'filter' => array( |
|
70 | + 'handler' => 'views_handler_filter_numeric' |
|
71 | +), |
|
72 | +'sort' => array( |
|
73 | + 'handler' => 'views_handler_sort_numeric' |
|
74 | +) |
|
75 | +); |
|
76 | 76 | |
77 | - // Descriptions of general host fields (alphabetized) |
|
77 | +// Descriptions of general host fields (alphabetized) |
|
78 | 78 | |
79 | - $data['user']['authenticator'] = array( |
|
80 | - 'title' => bts('Account Key', array(), NULL, 'boinc:user-info'), |
|
81 | - 'help' => t('The BOINC account key of the user.'), |
|
82 | - 'field' => array( |
|
83 | - 'handler' => 'views_handler_field', |
|
84 | - 'click sortable' => TRUE |
|
85 | - ), |
|
86 | - 'filter' => array( |
|
87 | - 'handler' => 'views_handler_filter_string' |
|
88 | - ), |
|
89 | - 'sort' => array( |
|
90 | - 'handler' => 'views_handler_sort_string' |
|
91 | - ) |
|
92 | - ); |
|
93 | - $data['user']['country'] = array( |
|
94 | - 'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
|
95 | - 'help' => t('The country of the user.'), |
|
96 | - 'field' => array( |
|
97 | - 'handler' => 'views_handler_field', |
|
98 | - 'click sortable' => TRUE |
|
99 | - ), |
|
100 | - 'filter' => array( |
|
101 | - 'handler' => 'views_handler_filter_string' |
|
102 | - ), |
|
103 | - 'sort' => array( |
|
104 | - 'handler' => 'views_handler_sort_string' |
|
105 | - ) |
|
106 | - ); |
|
107 | - $data['user']['create_time'] = array( |
|
108 | - 'title' => bts('Member since', array(), NULL, 'boinc:user-info'), |
|
109 | - 'help' => t('When the BOINC account was created.'), |
|
110 | - 'field' => array( |
|
111 | - 'handler' => 'views_handler_field_date', |
|
112 | - 'click sortable' => TRUE |
|
113 | - ), |
|
114 | - 'filter' => array( |
|
115 | - 'handler' => 'views_handler_filter_date' |
|
116 | - ), |
|
117 | - 'sort' => array( |
|
118 | - 'handler' => 'views_handler_sort_date' |
|
119 | - ) |
|
120 | - ); |
|
121 | - $data['user']['cross_project_id'] = array( |
|
122 | - 'title' => bts('CPID', array(), NULL, 'boinc:user-info'), |
|
123 | - 'help' => t('The cross project user identifier.'), |
|
124 | - 'field' => array( |
|
125 | - 'handler' => 'views_handler_field', |
|
126 | - 'click sortable' => TRUE |
|
127 | - ), |
|
128 | - 'filter' => array( |
|
129 | - 'handler' => 'views_handler_filter_string' |
|
130 | - ), |
|
131 | - 'sort' => array( |
|
132 | - 'handler' => 'views_handler_sort_string' |
|
133 | - ) |
|
134 | - ); |
|
135 | - $data['user']['email_addr'] = array( |
|
136 | - 'title' => bts('Email Address', array(), NULL, 'boinc:user-info'), |
|
137 | - 'help' => t('The BOINC account email address.'), |
|
138 | - 'field' => array( |
|
139 | - 'handler' => 'views_handler_field', |
|
140 | - 'click sortable' => TRUE |
|
141 | - ), |
|
142 | - 'filter' => array( |
|
143 | - 'handler' => 'views_handler_filter_string' |
|
144 | - ), |
|
145 | - 'sort' => array( |
|
146 | - 'handler' => 'views_handler_sort_string' |
|
147 | - ) |
|
148 | - ); |
|
149 | - $data['user']['expavg_credit'] = array( |
|
150 | - 'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'), |
|
151 | - 'help' => t('A decaying average of credit per day for the user.'), |
|
152 | - 'field' => array( |
|
153 | - 'handler' => 'views_handler_field_numeric', |
|
154 | - 'click sortable' => TRUE, |
|
155 | - 'float' => TRUE |
|
156 | - ), |
|
157 | - 'filter' => array( |
|
158 | - 'handler' => 'views_handler_filter_numeric' |
|
159 | - ), |
|
160 | - 'sort' => array( |
|
161 | - 'handler' => 'views_handler_sort_numeric' |
|
162 | - ) |
|
163 | - ); |
|
164 | - $data['user']['name'] = array( |
|
165 | - 'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
|
166 | - 'help' => t('The BOINC account user name.'), |
|
167 | - 'field' => array( |
|
168 | - 'handler' => 'views_handler_field', |
|
169 | - 'click sortable' => TRUE |
|
170 | - ), |
|
171 | - 'filter' => array( |
|
172 | - 'handler' => 'views_handler_filter_string' |
|
173 | - ), |
|
174 | - 'sort' => array( |
|
175 | - 'handler' => 'views_handler_sort_string' |
|
176 | - ) |
|
177 | - ); |
|
178 | - $data['user']['passwd_hash'] = array( |
|
179 | - 'title' => bts('Password Hash', array(), NULL, 'boinc:user-info'), |
|
180 | - 'help' => t('The user password hash'), |
|
181 | - 'field' => array( |
|
182 | - 'handler' => 'views_handler_field', |
|
183 | - 'click sortable' => TRUE |
|
184 | - ), |
|
185 | - 'filter' => array( |
|
186 | - 'handler' => 'views_handler_filter_string' |
|
187 | - ), |
|
188 | - 'sort' => array( |
|
189 | - 'handler' => 'views_handler_sort_string' |
|
190 | - ) |
|
191 | - ); |
|
192 | - $data['user']['postal_code'] = array( |
|
193 | - 'title' => bts('Postal Code', array(), NULL, 'boinc:user-info'), |
|
194 | - 'help' => t('The postal code of the user.'), |
|
195 | - 'field' => array( |
|
196 | - 'handler' => 'views_handler_field', |
|
197 | - 'click sortable' => TRUE |
|
198 | - ), |
|
199 | - 'filter' => array( |
|
200 | - 'handler' => 'views_handler_filter_string' |
|
201 | - ), |
|
202 | - 'sort' => array( |
|
203 | - 'handler' => 'views_handler_sort_string' |
|
204 | - ) |
|
205 | - ); |
|
206 | - $data['user']['send_email'] = array( |
|
207 | - 'title' => bts('Send Email', array(), NULL, 'boinc:user-info'), |
|
208 | - 'help' => t('User preference to allow email communications.'), |
|
209 | - 'field' => array( |
|
210 | - 'handler' => 'views_handler_field_numeric', |
|
211 | - 'click sortable' => TRUE |
|
212 | - ), |
|
213 | - 'filter' => array( |
|
214 | - 'handler' => 'views_handler_filter_numeric' |
|
215 | - ), |
|
216 | - 'sort' => array( |
|
217 | - 'handler' => 'views_handler_sort_numeric' |
|
218 | - ) |
|
219 | - ); |
|
220 | - $data['user']['show_hosts'] = array( |
|
221 | - 'title' => bts('Show Hosts', array(), NULL, 'boinc:user-info'), |
|
222 | - 'help' => t('User preference to display owned computers.'), |
|
223 | - 'field' => array( |
|
224 | - 'handler' => 'views_handler_field_numeric', |
|
225 | - 'click sortable' => TRUE |
|
226 | - ), |
|
227 | - 'filter' => array( |
|
228 | - 'handler' => 'views_handler_filter_numeric' |
|
229 | - ), |
|
230 | - 'sort' => array( |
|
231 | - 'handler' => 'views_handler_sort_numeric' |
|
232 | - ) |
|
233 | - ); |
|
234 | - $data['user']['total_credit'] = array( |
|
235 | - 'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
|
236 | - 'help' => t('The total accumulated BOINC credit for the user.'), |
|
237 | - 'field' => array( |
|
238 | - 'handler' => 'views_handler_field_numeric', |
|
239 | - 'click sortable' => TRUE, |
|
240 | - 'float' => TRUE |
|
241 | - ), |
|
242 | - 'filter' => array( |
|
243 | - 'handler' => 'views_handler_filter_numeric' |
|
244 | - ), |
|
245 | - 'sort' => array( |
|
246 | - 'handler' => 'views_handler_sort_numeric' |
|
247 | - ) |
|
248 | - ); |
|
249 | - $data['user']['url'] = array( |
|
250 | - 'title' => bts('URL', array(), NULL, 'boinc:website-of-user-or-team'), |
|
251 | - 'help' => t('The URL provided by the user'), |
|
252 | - 'field' => array( |
|
253 | - 'handler' => 'views_handler_field', |
|
254 | - 'click sortable' => TRUE |
|
255 | - ), |
|
256 | - 'filter' => array( |
|
257 | - 'handler' => 'views_handler_filter_string' |
|
258 | - ), |
|
259 | - 'sort' => array( |
|
260 | - 'handler' => 'views_handler_sort_string' |
|
261 | - ) |
|
262 | - ); |
|
79 | +$data['user']['authenticator'] = array( |
|
80 | +'title' => bts('Account Key', array(), NULL, 'boinc:user-info'), |
|
81 | +'help' => t('The BOINC account key of the user.'), |
|
82 | +'field' => array( |
|
83 | + 'handler' => 'views_handler_field', |
|
84 | + 'click sortable' => TRUE |
|
85 | +), |
|
86 | +'filter' => array( |
|
87 | + 'handler' => 'views_handler_filter_string' |
|
88 | +), |
|
89 | +'sort' => array( |
|
90 | + 'handler' => 'views_handler_sort_string' |
|
91 | +) |
|
92 | +); |
|
93 | +$data['user']['country'] = array( |
|
94 | +'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
|
95 | +'help' => t('The country of the user.'), |
|
96 | +'field' => array( |
|
97 | + 'handler' => 'views_handler_field', |
|
98 | + 'click sortable' => TRUE |
|
99 | +), |
|
100 | +'filter' => array( |
|
101 | + 'handler' => 'views_handler_filter_string' |
|
102 | +), |
|
103 | +'sort' => array( |
|
104 | + 'handler' => 'views_handler_sort_string' |
|
105 | +) |
|
106 | +); |
|
107 | +$data['user']['create_time'] = array( |
|
108 | +'title' => bts('Member since', array(), NULL, 'boinc:user-info'), |
|
109 | +'help' => t('When the BOINC account was created.'), |
|
110 | +'field' => array( |
|
111 | + 'handler' => 'views_handler_field_date', |
|
112 | + 'click sortable' => TRUE |
|
113 | +), |
|
114 | +'filter' => array( |
|
115 | + 'handler' => 'views_handler_filter_date' |
|
116 | +), |
|
117 | +'sort' => array( |
|
118 | + 'handler' => 'views_handler_sort_date' |
|
119 | +) |
|
120 | +); |
|
121 | +$data['user']['cross_project_id'] = array( |
|
122 | +'title' => bts('CPID', array(), NULL, 'boinc:user-info'), |
|
123 | +'help' => t('The cross project user identifier.'), |
|
124 | +'field' => array( |
|
125 | + 'handler' => 'views_handler_field', |
|
126 | + 'click sortable' => TRUE |
|
127 | +), |
|
128 | +'filter' => array( |
|
129 | + 'handler' => 'views_handler_filter_string' |
|
130 | +), |
|
131 | +'sort' => array( |
|
132 | + 'handler' => 'views_handler_sort_string' |
|
133 | +) |
|
134 | +); |
|
135 | +$data['user']['email_addr'] = array( |
|
136 | + 'title' => bts('Email Address', array(), NULL, 'boinc:user-info'), |
|
137 | +'help' => t('The BOINC account email address.'), |
|
138 | +'field' => array( |
|
139 | + 'handler' => 'views_handler_field', |
|
140 | + 'click sortable' => TRUE |
|
141 | +), |
|
142 | +'filter' => array( |
|
143 | + 'handler' => 'views_handler_filter_string' |
|
144 | +), |
|
145 | +'sort' => array( |
|
146 | + 'handler' => 'views_handler_sort_string' |
|
147 | +) |
|
148 | +); |
|
149 | +$data['user']['expavg_credit'] = array( |
|
150 | +'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'), |
|
151 | +'help' => t('A decaying average of credit per day for the user.'), |
|
152 | +'field' => array( |
|
153 | + 'handler' => 'views_handler_field_numeric', |
|
154 | + 'click sortable' => TRUE, |
|
155 | + 'float' => TRUE |
|
156 | +), |
|
157 | +'filter' => array( |
|
158 | + 'handler' => 'views_handler_filter_numeric' |
|
159 | +), |
|
160 | +'sort' => array( |
|
161 | + 'handler' => 'views_handler_sort_numeric' |
|
162 | +) |
|
163 | +); |
|
164 | +$data['user']['name'] = array( |
|
165 | +'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
|
166 | +'help' => t('The BOINC account user name.'), |
|
167 | +'field' => array( |
|
168 | + 'handler' => 'views_handler_field', |
|
169 | + 'click sortable' => TRUE |
|
170 | +), |
|
171 | +'filter' => array( |
|
172 | + 'handler' => 'views_handler_filter_string' |
|
173 | +), |
|
174 | +'sort' => array( |
|
175 | + 'handler' => 'views_handler_sort_string' |
|
176 | +) |
|
177 | +); |
|
178 | +$data['user']['passwd_hash'] = array( |
|
179 | +'title' => bts('Password Hash', array(), NULL, 'boinc:user-info'), |
|
180 | +'help' => t('The user password hash'), |
|
181 | +'field' => array( |
|
182 | + 'handler' => 'views_handler_field', |
|
183 | + 'click sortable' => TRUE |
|
184 | +), |
|
185 | +'filter' => array( |
|
186 | + 'handler' => 'views_handler_filter_string' |
|
187 | +), |
|
188 | +'sort' => array( |
|
189 | + 'handler' => 'views_handler_sort_string' |
|
190 | +) |
|
191 | +); |
|
192 | +$data['user']['postal_code'] = array( |
|
193 | +'title' => bts('Postal Code', array(), NULL, 'boinc:user-info'), |
|
194 | +'help' => t('The postal code of the user.'), |
|
195 | +'field' => array( |
|
196 | + 'handler' => 'views_handler_field', |
|
197 | + 'click sortable' => TRUE |
|
198 | +), |
|
199 | +'filter' => array( |
|
200 | + 'handler' => 'views_handler_filter_string' |
|
201 | +), |
|
202 | +'sort' => array( |
|
203 | + 'handler' => 'views_handler_sort_string' |
|
204 | +) |
|
205 | +); |
|
206 | +$data['user']['send_email'] = array( |
|
207 | +'title' => bts('Send Email', array(), NULL, 'boinc:user-info'), |
|
208 | +'help' => t('User preference to allow email communications.'), |
|
209 | +'field' => array( |
|
210 | + 'handler' => 'views_handler_field_numeric', |
|
211 | + 'click sortable' => TRUE |
|
212 | +), |
|
213 | +'filter' => array( |
|
214 | + 'handler' => 'views_handler_filter_numeric' |
|
215 | +), |
|
216 | +'sort' => array( |
|
217 | + 'handler' => 'views_handler_sort_numeric' |
|
218 | +) |
|
219 | +); |
|
220 | +$data['user']['show_hosts'] = array( |
|
221 | +'title' => bts('Show Hosts', array(), NULL, 'boinc:user-info'), |
|
222 | +'help' => t('User preference to display owned computers.'), |
|
223 | +'field' => array( |
|
224 | + 'handler' => 'views_handler_field_numeric', |
|
225 | + 'click sortable' => TRUE |
|
226 | +), |
|
227 | +'filter' => array( |
|
228 | + 'handler' => 'views_handler_filter_numeric' |
|
229 | +), |
|
230 | +'sort' => array( |
|
231 | + 'handler' => 'views_handler_sort_numeric' |
|
232 | +) |
|
233 | +); |
|
234 | +$data['user']['total_credit'] = array( |
|
235 | +'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
|
236 | +'help' => t('The total accumulated BOINC credit for the user.'), |
|
237 | +'field' => array( |
|
238 | + 'handler' => 'views_handler_field_numeric', |
|
239 | + 'click sortable' => TRUE, |
|
240 | + 'float' => TRUE |
|
241 | +), |
|
242 | +'filter' => array( |
|
243 | + 'handler' => 'views_handler_filter_numeric' |
|
244 | +), |
|
245 | +'sort' => array( |
|
246 | + 'handler' => 'views_handler_sort_numeric' |
|
247 | +) |
|
248 | +); |
|
249 | +$data['user']['url'] = array( |
|
250 | +'title' => bts('URL', array(), NULL, 'boinc:website-of-user-or-team'), |
|
251 | +'help' => t('The URL provided by the user'), |
|
252 | +'field' => array( |
|
253 | + 'handler' => 'views_handler_field', |
|
254 | + 'click sortable' => TRUE |
|
255 | +), |
|
256 | +'filter' => array( |
|
257 | + 'handler' => 'views_handler_filter_string' |
|
258 | +), |
|
259 | +'sort' => array( |
|
260 | + 'handler' => 'views_handler_sort_string' |
|
261 | +) |
|
262 | +); |
|
263 | 263 | |
264 | - return $data; |
|
264 | +return $data; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /* |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | */ |
273 | 273 | |
274 | 274 | function boincuser_views_handlers() { |
275 | - return array( |
|
276 | - 'info' => array( |
|
277 | - 'path' => drupal_get_path('module', 'boincuser') . '/views', |
|
278 | - ), |
|
279 | - 'handlers' => array( |
|
280 | - 'views_handler_argument_boincuser_id' => array( |
|
281 | - 'parent' => 'views_handler_argument_numeric' |
|
282 | - ), |
|
283 | - 'views_handler_argument_boincteam_id' => array( |
|
284 | - 'parent' => 'views_handler_argument_numeric' |
|
285 | - ), |
|
286 | - ) |
|
287 | - ); |
|
275 | +return array( |
|
276 | +'info' => array( |
|
277 | + 'path' => drupal_get_path('module', 'boincuser') . '/views', |
|
278 | +), |
|
279 | +'handlers' => array( |
|
280 | + 'views_handler_argument_boincuser_id' => array( |
|
281 | + 'parent' => 'views_handler_argument_numeric' |
|
282 | + ), |
|
283 | + 'views_handler_argument_boincteam_id' => array( |
|
284 | + 'parent' => 'views_handler_argument_numeric' |
|
285 | + ), |
|
286 | +) |
|
287 | +); |
|
288 | 288 | } |
@@ -50,47 +50,47 @@ discard block |
||
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 |
||
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 | } |
@@ -59,37 +59,37 @@ |
||
59 | 59 | // hook_user() functions. |
60 | 60 | |
61 | 61 | switch ($action) { |
62 | - case 'soft_obfuscate': |
|
63 | - obfuscate_account($boinc_user); |
|
64 | - _boincuser_delete_comment_reassign($account); |
|
65 | - _boincuser_delete_node_reassign($account); |
|
66 | - _boincuser_delete_privatemsg_delete($account); |
|
67 | - _boincuser_delete_friends($account); |
|
68 | - // delete the user's profile |
|
69 | - $profile = content_profile_load('profile', $account->uid); |
|
70 | - node_delete($profile->nid); |
|
71 | - // Drupal account - |
|
72 | - // * 'block'/disable the account |
|
73 | - // * set name, mail, pass, and init to deleted |
|
74 | - // * erase signature |
|
75 | - $myarray = array( |
|
76 | - 'status' => 0, |
|
77 | - 'name' => 'deleted_' . time() . '_' . random_string(), |
|
78 | - 'mail' => 'deleted_' . time() . '_' . random_string(), |
|
79 | - 'pass' => 'deleted_' . time() . '_' . random_string(), |
|
80 | - 'signature' => '', |
|
81 | - 'init' => 'deleted_' . time() . '_' . random_string(), |
|
82 | - ); |
|
83 | - user_save($account, $myarray); |
|
84 | - break; |
|
85 | - case 'hard_wipe': |
|
86 | - wipe_account($boinc_user); |
|
87 | - user_delete(array(), $account->uid); |
|
88 | - break; |
|
89 | - default: |
|
90 | - watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array( |
|
91 | - '%action' => $action, |
|
92 | - ), WATCHDOG_ERROR); |
|
62 | + case 'soft_obfuscate': |
|
63 | + obfuscate_account($boinc_user); |
|
64 | + _boincuser_delete_comment_reassign($account); |
|
65 | + _boincuser_delete_node_reassign($account); |
|
66 | + _boincuser_delete_privatemsg_delete($account); |
|
67 | + _boincuser_delete_friends($account); |
|
68 | + // delete the user's profile |
|
69 | + $profile = content_profile_load('profile', $account->uid); |
|
70 | + node_delete($profile->nid); |
|
71 | + // Drupal account - |
|
72 | + // * 'block'/disable the account |
|
73 | + // * set name, mail, pass, and init to deleted |
|
74 | + // * erase signature |
|
75 | + $myarray = array( |
|
76 | + 'status' => 0, |
|
77 | + 'name' => 'deleted_' . time() . '_' . random_string(), |
|
78 | + 'mail' => 'deleted_' . time() . '_' . random_string(), |
|
79 | + 'pass' => 'deleted_' . time() . '_' . random_string(), |
|
80 | + 'signature' => '', |
|
81 | + 'init' => 'deleted_' . time() . '_' . random_string(), |
|
82 | + ); |
|
83 | + user_save($account, $myarray); |
|
84 | + break; |
|
85 | + case 'hard_wipe': |
|
86 | + wipe_account($boinc_user); |
|
87 | + user_delete(array(), $account->uid); |
|
88 | + break; |
|
89 | + default: |
|
90 | + watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array( |
|
91 | + '%action' => $action, |
|
92 | + ), WATCHDOG_ERROR); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -15,59 +15,59 @@ discard block |
||
15 | 15 | * Form validation handler for login |
16 | 16 | */ |
17 | 17 | function boincuser_login_validate($form, &$form_state) { |
18 | - /* // SAMPLE: To try validation with Drupal first... |
|
18 | +/* // SAMPLE: To try validation with Drupal first... |
|
19 | 19 | global $user; |
20 | 20 | if (!empty($user->uid)) { |
21 | 21 | // Authentication with Drupal was successful |
22 | 22 | return; |
23 | 23 | }*/ |
24 | 24 | |
25 | - // Set name for logging purposes |
|
26 | - $form_state['values']['name'] = $form_state['values']['email']; |
|
25 | +// Set name for logging purposes |
|
26 | +$form_state['values']['name'] = $form_state['values']['email']; |
|
27 | 27 | |
28 | - // Bypass BOINC validation if passed the name of user 1 |
|
29 | - $user_1 = user_load(1); |
|
30 | - if ($form_state['values']['email'] == $user_1->name) { |
|
31 | - user_authenticate($form_state['values']); |
|
32 | - return; |
|
33 | - } |
|
28 | +// Bypass BOINC validation if passed the name of user 1 |
|
29 | +$user_1 = user_load(1); |
|
30 | +if ($form_state['values']['email'] == $user_1->name) { |
|
31 | +user_authenticate($form_state['values']); |
|
32 | +return; |
|
33 | +} |
|
34 | 34 | |
35 | - // Call our custom authentication function to check for an existing BOINC user |
|
36 | - if (!boincuser_login_authenticate($form_state['values'])) { |
|
37 | - // Authentication failed; set an error accordingly |
|
38 | - form_set_error('name', bts('Sorry, unrecognized email address or password.', array(), NULL, 'boinc:forgot-password') . ' ' . l(bts('Have you forgotten your password?', array(), NULL, 'boinc:forgot-password'), 'user/password')); |
|
39 | - } |
|
35 | +// Call our custom authentication function to check for an existing BOINC user |
|
36 | +if (!boincuser_login_authenticate($form_state['values'])) { |
|
37 | +// Authentication failed; set an error accordingly |
|
38 | +form_set_error('name', bts('Sorry, unrecognized email address or password.', array(), NULL, 'boinc:forgot-password') . ' ' . l(bts('Have you forgotten your password?', array(), NULL, 'boinc:forgot-password'), 'user/password')); |
|
39 | +} |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Custom authentication function to check BOINC account information |
44 | 44 | */ |
45 | 45 | function boincuser_login_authenticate($form_values) { |
46 | - global $boincuser_authenticated; |
|
47 | - $lower_email_addr = strtolower($form_values['email']); |
|
48 | - $passwd = $form_values['pass']; |
|
49 | - $passwd_hash = md5($passwd.$lower_email_addr); |
|
46 | +global $boincuser_authenticated; |
|
47 | +$lower_email_addr = strtolower($form_values['email']); |
|
48 | +$passwd = $form_values['pass']; |
|
49 | +$passwd_hash = md5($passwd.$lower_email_addr); |
|
50 | 50 | |
51 | - // Include BOINC user library |
|
52 | - require_boinc('boinc_db'); |
|
53 | - require_boinc('user_util'); |
|
51 | +// Include BOINC user library |
|
52 | +require_boinc('boinc_db'); |
|
53 | +require_boinc('user_util'); |
|
54 | 54 | |
55 | - // Get the BOINC user and check credentials |
|
56 | - $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
57 | - if (!$boinc_user) return false; |
|
55 | +// Get the BOINC user and check credentials |
|
56 | +$boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
57 | +if (!$boinc_user) return false; |
|
58 | 58 | |
59 | - if (!check_passwd_hash($boinc_user, $passwd_hash)) { |
|
60 | - return false; |
|
61 | - } |
|
59 | +if (!check_passwd_hash($boinc_user, $passwd_hash)) { |
|
60 | +return false; |
|
61 | +} |
|
62 | 62 | |
63 | - // BOINC authentication successful; log in and synchronize accounts |
|
64 | - boincuser_login_register($boinc_user); |
|
65 | - // Write session, update timestamp, run user 'login' hook. |
|
66 | - user_authenticate_finalize($form_values); |
|
67 | - // Use a global variable to save the fact that we did authentication. |
|
68 | - $boincuser_authenticated = true; |
|
63 | +// BOINC authentication successful; log in and synchronize accounts |
|
64 | +boincuser_login_register($boinc_user); |
|
65 | +// Write session, update timestamp, run user 'login' hook. |
|
66 | +user_authenticate_finalize($form_values); |
|
67 | +// Use a global variable to save the fact that we did authentication. |
|
68 | +$boincuser_authenticated = true; |
|
69 | 69 | |
70 | - return true; |
|
70 | +return true; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | * Drupal accounts |
76 | 76 | */ |
77 | 77 | function boincuser_login_register($boinc_user) { |
78 | - global $user; |
|
79 | - require_boinc('boinc_db'); |
|
80 | - // If a Drupal account already exists, log in |
|
81 | - $existing_user = user_load(array('mail' => $boinc_user->email_addr)); |
|
82 | - if (!empty($existing_user->uid)) { |
|
83 | - $user = $existing_user; |
|
84 | - } else { |
|
85 | - // Create a Drupal user from the BOINC user |
|
86 | - if ($user = boincuser_register_make_drupal_user($boinc_user)) { |
|
87 | - watchdog('user', 'New external user: %email using module %module.', array('%email' => $email_addr, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit')); |
|
88 | - } |
|
89 | - } |
|
78 | +global $user; |
|
79 | +require_boinc('boinc_db'); |
|
80 | +// If a Drupal account already exists, log in |
|
81 | +$existing_user = user_load(array('mail' => $boinc_user->email_addr)); |
|
82 | +if (!empty($existing_user->uid)) { |
|
83 | +$user = $existing_user; |
|
84 | +} else { |
|
85 | +// Create a Drupal user from the BOINC user |
|
86 | +if ($user = boincuser_register_make_drupal_user($boinc_user)) { |
|
87 | + watchdog('user', 'New external user: %email using module %module.', array('%email' => $email_addr, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit')); |
|
88 | +} |
|
89 | +} |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,277 +98,277 @@ discard block |
||
98 | 98 | * New user registration validation handler. |
99 | 99 | */ |
100 | 100 | function boincuser_register_validate($form, &$form_state) { |
101 | - // Include BOINC database objects library |
|
102 | - require_boinc('boinc_db'); |
|
103 | - |
|
104 | - // Check terms of use agreement |
|
105 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
106 | - if (!empty($termsofuse)) { |
|
107 | - if (!$form_state['values']['agreeTOU']) { |
|
108 | - form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', NULL, 'boinc:register-new-user')); |
|
109 | - return false; |
|
110 | - } |
|
111 | - } |
|
101 | +// Include BOINC database objects library |
|
102 | +require_boinc('boinc_db'); |
|
103 | + |
|
104 | +// Check terms of use agreement |
|
105 | +$termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
106 | +if (!empty($termsofuse)) { |
|
107 | +if (!$form_state['values']['agreeTOU']) { |
|
108 | + form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', NULL, 'boinc:register-new-user')); |
|
109 | + return false; |
|
110 | +} |
|
111 | +} |
|
112 | 112 | |
113 | - // Lower-case the email address |
|
114 | - $lower_email_addr = strtolower($form_state['values']['mail']); |
|
115 | - $tmp_user = BoincUser::lookup_prev_email_addr($lower_email_addr); |
|
116 | - if ($tmp_user) { |
|
117 | - // User already exists |
|
118 | - form_set_error('mail', bts('An account already exists for @email. Contact the administrators for @project for additional help.', |
|
119 | - array( |
|
120 | - '@email' => $lower_email_addr, |
|
121 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user', |
|
122 | - ) |
|
123 | - , NULL, 'boinc:register-new-user')); |
|
124 | - } |
|
113 | +// Lower-case the email address |
|
114 | +$lower_email_addr = strtolower($form_state['values']['mail']); |
|
115 | +$tmp_user = BoincUser::lookup_prev_email_addr($lower_email_addr); |
|
116 | +if ($tmp_user) { |
|
117 | +// User already exists |
|
118 | +form_set_error('mail', bts('An account already exists for @email. Contact the administrators for @project for additional help.', |
|
119 | + array( |
|
120 | + '@email' => $lower_email_addr, |
|
121 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user', |
|
122 | + ) |
|
123 | +, NULL, 'boinc:register-new-user')); |
|
124 | +} |
|
125 | 125 | |
126 | - // Check for an existing BOINC user |
|
127 | - // This is somewhat redundent as Drupal will also check if the email |
|
128 | - // is a duplicate. However, in the case where there is no Drupal |
|
129 | - // account, but a BOINC account exists with this email, the check |
|
130 | - // will fail. |
|
131 | - $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
132 | - if ($boinc_user) { |
|
133 | - // User already exists |
|
134 | - form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $lower_email_addr, '@project' => PROJECT), NULL, 'boinc:add-new-user')); |
|
135 | - return false; |
|
136 | - } |
|
126 | +// Check for an existing BOINC user |
|
127 | +// This is somewhat redundent as Drupal will also check if the email |
|
128 | +// is a duplicate. However, in the case where there is no Drupal |
|
129 | +// account, but a BOINC account exists with this email, the check |
|
130 | +// will fail. |
|
131 | +$boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
132 | +if ($boinc_user) { |
|
133 | +// User already exists |
|
134 | +form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $lower_email_addr, '@project' => PROJECT), NULL, 'boinc:add-new-user')); |
|
135 | +return false; |
|
136 | +} |
|
137 | 137 | |
138 | - // Check Drupal name is not a duplicate, and create a proper drupal |
|
139 | - // name from the boinc username. |
|
140 | - $form_state['values']['name'] = create_proper_drupalname($form_state['values']['boincuser_name']); |
|
138 | +// Check Drupal name is not a duplicate, and create a proper drupal |
|
139 | +// name from the boinc username. |
|
140 | +$form_state['values']['name'] = create_proper_drupalname($form_state['values']['boincuser_name']); |
|
141 | 141 | |
142 | - return true; |
|
142 | +return true; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Create BOINC account |
147 | 147 | */ |
148 | 148 | function boincuser_register_make_user($params) { |
149 | - // Include BOINC user library |
|
150 | - require_boinc('user_util'); |
|
151 | - // Create the BOINC user |
|
152 | - $boinc_user = make_user($params['email_addr'], $params['name'], $params['passwd_hash'], $params['country'], $params['postal_code']); |
|
153 | - return $boinc_user; |
|
149 | +// Include BOINC user library |
|
150 | +require_boinc('user_util'); |
|
151 | +// Create the BOINC user |
|
152 | +$boinc_user = make_user($params['email_addr'], $params['name'], $params['passwd_hash'], $params['country'], $params['postal_code']); |
|
153 | +return $boinc_user; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Create Drupal account from existing BOINC account |
158 | 158 | */ |
159 | 159 | function boincuser_register_make_drupal_user($boinc_user) { |
160 | - $account = null; |
|
161 | - if (is_numeric($boinc_user)) { |
|
162 | - $boinc_user = boincuser_load($boinc_user); |
|
163 | - } |
|
164 | - if ($boinc_user) { |
|
165 | - $account = boincuser_create_drupal_user($boinc_user); |
|
166 | - if ($account) { |
|
167 | - boincuser_create_drupal_profile($account, $boinc_user); |
|
168 | - } |
|
169 | - } |
|
170 | - return $account; |
|
160 | +$account = null; |
|
161 | +if (is_numeric($boinc_user)) { |
|
162 | +$boinc_user = boincuser_load($boinc_user); |
|
163 | +} |
|
164 | +if ($boinc_user) { |
|
165 | +$account = boincuser_create_drupal_user($boinc_user); |
|
166 | +if ($account) { |
|
167 | + boincuser_create_drupal_profile($account, $boinc_user); |
|
168 | +} |
|
169 | +} |
|
170 | +return $account; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function boincuser_create_drupal_user($boinc_user) { |
174 | - require_boinc('forum_db'); |
|
175 | - BoincForumPrefs::lookup($boinc_user); |
|
176 | - $account = NULL; |
|
177 | - $module = 'boincuser'; |
|
174 | +require_boinc('forum_db'); |
|
175 | +BoincForumPrefs::lookup($boinc_user); |
|
176 | +$account = NULL; |
|
177 | +$module = 'boincuser'; |
|
178 | 178 | |
179 | - // Verify that this account has not already been imported |
|
180 | - $already_imported = db_result(db_query(' |
|
179 | +// Verify that this account has not already been imported |
|
180 | +$already_imported = db_result(db_query(' |
|
181 | 181 | SELECT COUNT(*) FROM {boincuser} WHERE boinc_id = %d', |
182 | - $boinc_user->id) |
|
183 | - ); |
|
184 | - if ($already_imported) { |
|
185 | - return NULL; |
|
186 | - } |
|
182 | +$boinc_user->id) |
|
183 | +); |
|
184 | +if ($already_imported) { |
|
185 | +return NULL; |
|
186 | +} |
|
187 | 187 | |
188 | - // Email is limited to 64 characters... |
|
189 | - $boinc_email = substr($boinc_user->email_addr, 0, 64); |
|
188 | +// Email is limited to 64 characters... |
|
189 | +$boinc_email = substr($boinc_user->email_addr, 0, 64); |
|
190 | 190 | |
191 | - // Email should be unique |
|
192 | - $already_imported = db_result(db_query(" |
|
191 | +// Email should be unique |
|
192 | +$already_imported = db_result(db_query(" |
|
193 | 193 | SELECT COUNT(*) FROM {users} WHERE mail = '%s'", |
194 | - $boinc_email) |
|
195 | - ); |
|
196 | - if ($already_imported) { |
|
197 | - drupal_set_message(t('An account for @email already exists', array('@email' => $boinc_email)), 'warning'); |
|
198 | - watchdog('boincimport', 'An account for @email already exists', array('@email' => $boinc_email), WATCHDOG_WARNING); |
|
199 | - return NULL; |
|
200 | - } |
|
201 | - |
|
202 | - // Make sure name is unique |
|
203 | - $unique_name = create_proper_drupalname($boinc_user->name); |
|
204 | - |
|
205 | - $userinfo = array( |
|
206 | - 'name' => $unique_name, |
|
207 | - 'pass' => $boinc_user->passwd_hash, |
|
208 | - 'mail' => $boinc_email, |
|
209 | - 'signature' => $boinc_user->prefs->signature, |
|
210 | - 'created' => $boinc_user->create_time, |
|
211 | - 'init' => $boinc_email, |
|
212 | - 'status' => 1, |
|
213 | - "authname_{$module}" => $boinc_email, |
|
214 | - 'access' => time() |
|
215 | - ); |
|
216 | - |
|
217 | - $in_penalty = ($boinc_user->prefs->banished_until > time()); |
|
194 | +$boinc_email) |
|
195 | +); |
|
196 | +if ($already_imported) { |
|
197 | +drupal_set_message(t('An account for @email already exists', array('@email' => $boinc_email)), 'warning'); |
|
198 | +watchdog('boincimport', 'An account for @email already exists', array('@email' => $boinc_email), WATCHDOG_WARNING); |
|
199 | +return NULL; |
|
200 | +} |
|
218 | 201 | |
219 | - // Add user to community member role (if no current penalty) |
|
220 | - if (!$in_penalty) { |
|
221 | - $community_role = array_search('community member', user_roles(true)); |
|
222 | - $userinfo['roles'] = array( |
|
223 | - $community_role => '' |
|
224 | - ); |
|
225 | - } |
|
202 | +// Make sure name is unique |
|
203 | +$unique_name = create_proper_drupalname($boinc_user->name); |
|
204 | + |
|
205 | +$userinfo = array( |
|
206 | +'name' => $unique_name, |
|
207 | +'pass' => $boinc_user->passwd_hash, |
|
208 | +'mail' => $boinc_email, |
|
209 | +'signature' => $boinc_user->prefs->signature, |
|
210 | +'created' => $boinc_user->create_time, |
|
211 | +'init' => $boinc_email, |
|
212 | +'status' => 1, |
|
213 | +"authname_{$module}" => $boinc_email, |
|
214 | +'access' => time() |
|
215 | +); |
|
216 | + |
|
217 | +$in_penalty = ($boinc_user->prefs->banished_until > time()); |
|
218 | + |
|
219 | +// Add user to community member role (if no current penalty) |
|
220 | +if (!$in_penalty) { |
|
221 | +$community_role = array_search('community member', user_roles(true)); |
|
222 | +$userinfo['roles'] = array( |
|
223 | + $community_role => '' |
|
224 | +); |
|
225 | +} |
|
226 | 226 | |
227 | - // Mark account as imported so a BOINC account is not created on Insert (i.e. user_save) |
|
228 | - $_SESSION['importedUser'] = true; |
|
229 | - $account = user_save('', $userinfo); |
|
227 | +// Mark account as imported so a BOINC account is not created on Insert (i.e. user_save) |
|
228 | +$_SESSION['importedUser'] = true; |
|
229 | +$account = user_save('', $userinfo); |
|
230 | 230 | |
231 | - // Drupal overrides the original registration date, so update to the correct date |
|
232 | - $account = user_save($account, array('created' => $userinfo['created'])); |
|
231 | +// Drupal overrides the original registration date, so update to the correct date |
|
232 | +$account = user_save($account, array('created' => $userinfo['created'])); |
|
233 | 233 | |
234 | - // Terminate if an error occured during user_save(). |
|
235 | - if (!$account) { |
|
236 | - drupal_set_message(t("Error saving user account."), 'error'); |
|
237 | - return NULL; |
|
238 | - } |
|
234 | +// Terminate if an error occured during user_save(). |
|
235 | +if (!$account) { |
|
236 | +drupal_set_message(t("Error saving user account."), 'error'); |
|
237 | +return NULL; |
|
238 | +} |
|
239 | 239 | |
240 | - // Cross reference the Drupal and BOINC accounts |
|
241 | - boincuser_account_cross_reference($account->uid, $boinc_user->id); |
|
240 | +// Cross reference the Drupal and BOINC accounts |
|
241 | +boincuser_account_cross_reference($account->uid, $boinc_user->id); |
|
242 | 242 | |
243 | - if ($in_penalty) { |
|
244 | - // Import the timestamp of when the penalty period will be over |
|
245 | - $boincuser_record = array( |
|
246 | - 'uid' => $account->uid, |
|
247 | - 'penalty_expiration' => $boinc_user->prefs->banished_until, |
|
248 | - ); |
|
249 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
250 | - } |
|
243 | +if ($in_penalty) { |
|
244 | +// Import the timestamp of when the penalty period will be over |
|
245 | +$boincuser_record = array( |
|
246 | + 'uid' => $account->uid, |
|
247 | + 'penalty_expiration' => $boinc_user->prefs->banished_until, |
|
248 | +); |
|
249 | +drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
250 | +} |
|
251 | 251 | |
252 | - return $account; |
|
252 | +return $account; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | function boincuser_create_drupal_profile($account, $boinc_user) { |
256 | 256 | |
257 | - require_boinc('forum_db'); |
|
258 | - BoincForumPrefs::lookup($boinc_user); |
|
259 | - |
|
260 | - $image_dir = boinc_get_path('user_image'); |
|
261 | - |
|
262 | - // Automatically create a content profile |
|
263 | - $now = time(); |
|
264 | - $profile_background = null; |
|
265 | - $profile_opinions = null; |
|
266 | - $profile_image = null; |
|
267 | - $avatar_image = null; |
|
268 | - $profile_approved = NULL; |
|
269 | - |
|
270 | - // Load the BOINC profile, if available |
|
271 | - if ($boinc_user->has_profile) { |
|
272 | - $boinc_profile = BoincProfile::lookup("userid={$boinc_user->id}"); |
|
273 | - $profile_background = $boinc_profile->response1; |
|
274 | - $profile_opinions = $boinc_profile->response2; |
|
275 | - if ($boinc_profile->has_picture) { |
|
276 | - // Load picture; load validators; determine where to store it in Drupal |
|
277 | - $image_path = "{$image_dir}/{$boinc_user->id}.jpg"; |
|
278 | - $profile_image = get_cck_image_object($image_path, 'field_profile_image', 'profile', TRUE); |
|
279 | - // If the user does not have a different image as an avatar, use this one |
|
280 | - if (!$boinc_user->prefs->avatar) { |
|
281 | - $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
|
282 | - } |
|
283 | - } |
|
284 | - if ($boinc_user->prefs->avatar) { |
|
285 | - $image_path = "{$image_dir}/{$boinc_user->id}_avatar.jpg"; |
|
286 | - $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
|
287 | - } |
|
288 | - $profile_approved = $boinc_profile->verification ? TRUE : FALSE; |
|
257 | +require_boinc('forum_db'); |
|
258 | +BoincForumPrefs::lookup($boinc_user); |
|
259 | + |
|
260 | +$image_dir = boinc_get_path('user_image'); |
|
261 | + |
|
262 | +// Automatically create a content profile |
|
263 | +$now = time(); |
|
264 | +$profile_background = null; |
|
265 | +$profile_opinions = null; |
|
266 | +$profile_image = null; |
|
267 | +$avatar_image = null; |
|
268 | +$profile_approved = NULL; |
|
269 | + |
|
270 | +// Load the BOINC profile, if available |
|
271 | +if ($boinc_user->has_profile) { |
|
272 | +$boinc_profile = BoincProfile::lookup("userid={$boinc_user->id}"); |
|
273 | +$profile_background = $boinc_profile->response1; |
|
274 | +$profile_opinions = $boinc_profile->response2; |
|
275 | +if ($boinc_profile->has_picture) { |
|
276 | + // Load picture; load validators; determine where to store it in Drupal |
|
277 | + $image_path = "{$image_dir}/{$boinc_user->id}.jpg"; |
|
278 | + $profile_image = get_cck_image_object($image_path, 'field_profile_image', 'profile', TRUE); |
|
279 | + // If the user does not have a different image as an avatar, use this one |
|
280 | + if (!$boinc_user->prefs->avatar) { |
|
281 | + $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
|
289 | 282 | } |
290 | - $default_input_format = db_result(db_query(" |
|
283 | +} |
|
284 | +if ($boinc_user->prefs->avatar) { |
|
285 | + $image_path = "{$image_dir}/{$boinc_user->id}_avatar.jpg"; |
|
286 | + $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE); |
|
287 | +} |
|
288 | +$profile_approved = $boinc_profile->verification ? TRUE : FALSE; |
|
289 | +} |
|
290 | +$default_input_format = db_result(db_query(" |
|
291 | 291 | SELECT format FROM {filter_formats} WHERE name = '%s'", 'Rich text')); |
292 | - if (!$default_input_format) $default_input_format = 1; |
|
293 | - |
|
294 | - // Populate the profile object |
|
295 | - $profile_node = new stdClass(); |
|
296 | - $profile_node->title = $boinc_user->name; |
|
297 | - $profile_node->uid = $account->uid; |
|
298 | - $profile_node->body = ''; |
|
299 | - $profile_node->type = 'profile'; |
|
300 | - $profile_node->created = $now; |
|
301 | - $profile_node->changed = $now; |
|
302 | - $profile_node->status = 1; |
|
303 | - $profile_node->promote = 0; |
|
304 | - $profile_node->sticky = 0; |
|
305 | - $profile_node->format = $default_input_format; |
|
306 | - $profile_node->name = $account->name; // Set to link profile to account uid! |
|
307 | - $profile_node->field_country[]['value'] = $boinc_user->country; |
|
308 | - $profile_node->field_zip[]['value'] = $boinc_user->postal_code; |
|
309 | - $profile_node->field_url[]['value'] = $boinc_user->url; |
|
310 | - $profile_node->field_background[]['value'] = $profile_background; |
|
311 | - $profile_node->field_opinions[]['value'] = $profile_opinions; |
|
312 | - $profile_node->field_image[] = $avatar_image; |
|
313 | - $profile_node->field_profile_image[] = $profile_image; |
|
314 | - |
|
315 | - // Save the profile object to the database |
|
316 | - // This will automatically set the author uid if node->name has been set |
|
317 | - $profile_node = node_submit($profile_node); |
|
318 | - node_save($profile_node); |
|
319 | - |
|
320 | - // Mark profile as approved if it has already been vetted somehow |
|
321 | - if ($profile_approved OR !$boinc_user->has_profile) { |
|
322 | - $profile_node->moderate = 0; |
|
323 | - node_save($profile_node); |
|
324 | - } |
|
292 | +if (!$default_input_format) $default_input_format = 1; |
|
293 | + |
|
294 | +// Populate the profile object |
|
295 | +$profile_node = new stdClass(); |
|
296 | +$profile_node->title = $boinc_user->name; |
|
297 | +$profile_node->uid = $account->uid; |
|
298 | +$profile_node->body = ''; |
|
299 | +$profile_node->type = 'profile'; |
|
300 | +$profile_node->created = $now; |
|
301 | +$profile_node->changed = $now; |
|
302 | +$profile_node->status = 1; |
|
303 | +$profile_node->promote = 0; |
|
304 | +$profile_node->sticky = 0; |
|
305 | +$profile_node->format = $default_input_format; |
|
306 | +$profile_node->name = $account->name; // Set to link profile to account uid! |
|
307 | +$profile_node->field_country[]['value'] = $boinc_user->country; |
|
308 | +$profile_node->field_zip[]['value'] = $boinc_user->postal_code; |
|
309 | +$profile_node->field_url[]['value'] = $boinc_user->url; |
|
310 | +$profile_node->field_background[]['value'] = $profile_background; |
|
311 | +$profile_node->field_opinions[]['value'] = $profile_opinions; |
|
312 | +$profile_node->field_image[] = $avatar_image; |
|
313 | +$profile_node->field_profile_image[] = $profile_image; |
|
314 | + |
|
315 | +// Save the profile object to the database |
|
316 | +// This will automatically set the author uid if node->name has been set |
|
317 | +$profile_node = node_submit($profile_node); |
|
318 | +node_save($profile_node); |
|
319 | + |
|
320 | +// Mark profile as approved if it has already been vetted somehow |
|
321 | +if ($profile_approved OR !$boinc_user->has_profile) { |
|
322 | +$profile_node->moderate = 0; |
|
323 | +node_save($profile_node); |
|
324 | +} |
|
325 | 325 | |
326 | - return; |
|
326 | +return; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | function boincuser_account_cross_reference($uid, $boinc_id) { |
330 | - // Cross reference Drupal account with BOINC |
|
331 | - $reference = db_query("INSERT INTO {boincuser} SET uid=%d, boinc_id=%d", $uid, $boinc_id); |
|
332 | - if (!$reference) { |
|
333 | - drupal_set_message(t("Error connecting BOINC account."), 'error'); |
|
334 | - return false; |
|
335 | - } |
|
336 | - return true; |
|
330 | +// Cross reference Drupal account with BOINC |
|
331 | +$reference = db_query("INSERT INTO {boincuser} SET uid=%d, boinc_id=%d", $uid, $boinc_id); |
|
332 | +if (!$reference) { |
|
333 | + drupal_set_message(t("Error connecting BOINC account."), 'error'); |
|
334 | + return false; |
|
335 | +} |
|
336 | +return true; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | 340 | * Convert any BOINC forum thread subscriptions to Drupal flag subscriptions |
341 | 341 | */ |
342 | 342 | function boincuser_pull_subscriptions($account = NULL) { |
343 | - if (!$account) { |
|
344 | - global $user; |
|
345 | - $account = user_load($user->id); |
|
346 | - } |
|
347 | - elseif (is_numeric($account)) { |
|
348 | - $account = user_load($account); |
|
349 | - } |
|
343 | +if (!$account) { |
|
344 | +global $user; |
|
345 | +$account = user_load($user->id); |
|
346 | +} |
|
347 | +elseif (is_numeric($account)) { |
|
348 | +$account = user_load($account); |
|
349 | +} |
|
350 | 350 | |
351 | - // Get any subscriptions for this user |
|
352 | - db_set_active('boinc_rw'); |
|
353 | - $subscriptions = db_query(' |
|
351 | +// Get any subscriptions for this user |
|
352 | +db_set_active('boinc_rw'); |
|
353 | +$subscriptions = db_query(' |
|
354 | 354 | SELECT threadid FROM {subscriptions} |
355 | 355 | WHERE userid = %d', $account->boincuser_id); |
356 | - db_set_active('default'); |
|
356 | +db_set_active('default'); |
|
357 | 357 | |
358 | - $flag = flag_get_flag('subscriptions') or die('no "subscriptions" flag defined'); |
|
359 | - $count = 0; |
|
360 | - while ($thread_id = db_result($subscriptions)) { |
|
361 | - // For each BOINC thread ID subscribed, look up the corresponding node ID |
|
362 | - $nid = db_result(db_query(' |
|
358 | +$flag = flag_get_flag('subscriptions') or die('no "subscriptions" flag defined'); |
|
359 | +$count = 0; |
|
360 | +while ($thread_id = db_result($subscriptions)) { |
|
361 | +// For each BOINC thread ID subscribed, look up the corresponding node ID |
|
362 | +$nid = db_result(db_query(' |
|
363 | 363 | SELECT nid FROM {boincimport_temp_topic} |
364 | 364 | WHERE topic_id = %d', $thread_id)); |
365 | - // Flag this node for the user |
|
366 | - if ($nid > 0) { |
|
367 | - $flag->flag('flag', $nid, $account); |
|
368 | - $count++; |
|
369 | - } |
|
370 | - } |
|
371 | - return $count; |
|
365 | +// Flag this node for the user |
|
366 | +if ($nid > 0) { |
|
367 | + $flag->flag('flag', $nid, $account); |
|
368 | + $count++; |
|
369 | +} |
|
370 | +} |
|
371 | +return $count; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,66 +380,66 @@ discard block |
||
380 | 380 | * User account update validation handler. |
381 | 381 | */ |
382 | 382 | function boincuser_account_validate($edit, $account) { |
383 | - // Include BOINC database objects library, load BOINC account data |
|
384 | - require_boinc('boinc_db'); |
|
385 | - $boinc_user = BoincUser::lookup_email_addr($account->mail); |
|
386 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $account->mail) ? true : false; |
|
387 | - $changing_pass = ($edit['pass']) ? true : false; |
|
388 | - if ($changing_email) { |
|
389 | - // E-mail address is set to change; check for an existing BOINC user |
|
390 | - // Check previous email addresses as well, this user's current |
|
391 | - // email cannot be the same as another user's previous email |
|
392 | - // address. |
|
393 | - |
|
394 | - // set email address lower-case |
|
395 | - $edit['mail'] = strtolower($edit['mail']); |
|
396 | - |
|
397 | - $boinc_user_already_exists = ( BoincUser::lookup_email_addr($edit['mail']) || BoincUser::lookup_prev_email_addr($edit['mail']) ); |
|
398 | - if ($boinc_user_already_exists) { |
|
399 | - form_set_error('mail', bts('A BOINC account already exists for @email.', array('@email' => $edit['mail']), NULL, 'boinc:add-new-user')); |
|
400 | - } |
|
401 | - |
|
402 | - // Check email has not been changed in last X days (default X=7). |
|
403 | - $duration = 86400 * 7; |
|
404 | - if ( (($boinc_user->email_addr_change_time + $duration) > time()) and (!(user_access('administer users'))) ) { |
|
405 | - form_set_error('email_addr_change_time', |
|
406 | - bts('Your email address was changed within the past seven (7) days. You must wait until !futuredate to change your email again. If you need to reverse this change, please look for an email sent to !prev_email_addr.', |
|
407 | - array( |
|
408 | - '!futuredate' => date('F j, Y \a\t H:i T', $boinc_user->email_addr_change_time + $duration), |
|
409 | - '!prev_email_addr' => $boinc_user->previous_email_addr, |
|
410 | - ), |
|
411 | - NULL, 'boinc:account-credentials-change') |
|
412 | - ); |
|
413 | - } |
|
414 | - } |
|
383 | +// Include BOINC database objects library, load BOINC account data |
|
384 | +require_boinc('boinc_db'); |
|
385 | +$boinc_user = BoincUser::lookup_email_addr($account->mail); |
|
386 | +$changing_email = ($edit['mail'] AND $edit['mail'] != $account->mail) ? true : false; |
|
387 | +$changing_pass = ($edit['pass']) ? true : false; |
|
388 | +if ($changing_email) { |
|
389 | +// E-mail address is set to change; check for an existing BOINC user |
|
390 | +// Check previous email addresses as well, this user's current |
|
391 | +// email cannot be the same as another user's previous email |
|
392 | +// address. |
|
393 | + |
|
394 | +// set email address lower-case |
|
395 | +$edit['mail'] = strtolower($edit['mail']); |
|
396 | + |
|
397 | +$boinc_user_already_exists = ( BoincUser::lookup_email_addr($edit['mail']) || BoincUser::lookup_prev_email_addr($edit['mail']) ); |
|
398 | +if ($boinc_user_already_exists) { |
|
399 | + form_set_error('mail', bts('A BOINC account already exists for @email.', array('@email' => $edit['mail']), NULL, 'boinc:add-new-user')); |
|
400 | +} |
|
415 | 401 | |
416 | - // If user is changing email or password, require that the current |
|
417 | - // password has been given as well. |
|
418 | - if (($changing_email OR $changing_pass) AND !user_access('administer users')) { |
|
419 | - // If changing email or password, require current password |
|
420 | - // (except in cases where password is being reset) |
|
421 | - if (isset($_SESSION['reset_pass'])) { |
|
422 | - unset($_SESSION['reset_pass']); |
|
423 | - } |
|
424 | - else { |
|
425 | - $given_hash = md5($edit['current_pass'] . strtolower($account->mail)); |
|
426 | - if (!$edit['current_pass']) { |
|
427 | - form_set_error('current_pass', bts('Authentication is required when changing E-mail address or setting new password.', array(), NULL, 'boinc:account-credentials-change')); |
|
428 | - } |
|
429 | - elseif ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
430 | - form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:account-credentials-change')); |
|
431 | - } |
|
432 | - |
|
433 | - } |
|
434 | - } |
|
402 | +// Check email has not been changed in last X days (default X=7). |
|
403 | +$duration = 86400 * 7; |
|
404 | +if ( (($boinc_user->email_addr_change_time + $duration) > time()) and (!(user_access('administer users'))) ) { |
|
405 | + form_set_error('email_addr_change_time', |
|
406 | + bts('Your email address was changed within the past seven (7) days. You must wait until !futuredate to change your email again. If you need to reverse this change, please look for an email sent to !prev_email_addr.', |
|
407 | + array( |
|
408 | + '!futuredate' => date('F j, Y \a\t H:i T', $boinc_user->email_addr_change_time + $duration), |
|
409 | + '!prev_email_addr' => $boinc_user->previous_email_addr, |
|
410 | + ), |
|
411 | + NULL, 'boinc:account-credentials-change') |
|
412 | + ); |
|
413 | +} |
|
414 | +} |
|
435 | 415 | |
436 | - // If an admin tries to change the email and NOT the password, show |
|
437 | - // error message. BOINC requires both to be changed together. |
|
438 | - if ($changing_email AND !$changing_pass AND user_access('administer users')) { |
|
439 | - form_set_error('pass', bts('If changing a user\'s email, you must also change the password simultaneously.', array(), NULL, 'boinc:account-credentials-change')); |
|
416 | +// If user is changing email or password, require that the current |
|
417 | +// password has been given as well. |
|
418 | +if (($changing_email OR $changing_pass) AND !user_access('administer users')) { |
|
419 | +// If changing email or password, require current password |
|
420 | +// (except in cases where password is being reset) |
|
421 | +if (isset($_SESSION['reset_pass'])) { |
|
422 | + unset($_SESSION['reset_pass']); |
|
423 | +} |
|
424 | +else { |
|
425 | + $given_hash = md5($edit['current_pass'] . strtolower($account->mail)); |
|
426 | + if (!$edit['current_pass']) { |
|
427 | + form_set_error('current_pass', bts('Authentication is required when changing E-mail address or setting new password.', array(), NULL, 'boinc:account-credentials-change')); |
|
428 | + } |
|
429 | + elseif ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
430 | + form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:account-credentials-change')); |
|
440 | 431 | } |
432 | + |
|
433 | +} |
|
434 | +} |
|
435 | + |
|
436 | +// If an admin tries to change the email and NOT the password, show |
|
437 | +// error message. BOINC requires both to be changed together. |
|
438 | +if ($changing_email AND !$changing_pass AND user_access('administer users')) { |
|
439 | +form_set_error('pass', bts('If changing a user\'s email, you must also change the password simultaneously.', array(), NULL, 'boinc:account-credentials-change')); |
|
440 | +} |
|
441 | 441 | |
442 | - // Expansion required to allow account key in place of passwd...? |
|
442 | +// Expansion required to allow account key in place of passwd...? |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | |
@@ -452,125 +452,125 @@ discard block |
||
452 | 452 | * Password request validation handler. |
453 | 453 | */ |
454 | 454 | function boincuser_request_pass_validate($form, &$form_state) { |
455 | - $edit = $form_state['values']; |
|
456 | - // The Drupal submit function expects a "name" field, even though |
|
457 | - // it contains an email address and we will not allow a user name |
|
458 | - if (!$edit['name']) form_set_error('name', bts('Please enter your email address', array(), NULL, 'boinc:forgot-password')); |
|
459 | - elseif (!valid_email_address($edit['name'])) form_set_error('name', bts('@email is not a well formed email address, please verify', array('@email' => $edit['name']), NULL, 'boinc:forgot-password')); |
|
460 | - else { |
|
461 | - // set email addrress to lower case |
|
462 | - $lower_email_addr = strtolower($edit['name']); |
|
463 | - |
|
464 | - // First look for an existing Drupal account |
|
465 | - if ($account = user_load_by_mail($lower_email_addr)) return; |
|
466 | - // Otherwise, check the BOINC db for this email address |
|
467 | - require_boinc('boinc_db'); |
|
468 | - $boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
469 | - if ($boinc_user) { |
|
470 | - // If the user is in BOINC but not Drupal, bring them over... |
|
471 | - boincuser_register_make_drupal_user($boinc_user); |
|
472 | - } else { |
|
473 | - // If there is no existing BOINC user either, show an error |
|
474 | - form_set_error('name', bts('No account exists for @email -- please create an account using a BOINC client -- !instructions', |
|
475 | - array( |
|
476 | - '@email' => $edit['name'], |
|
477 | - '!instructions' => l(bts('Instructions', array(), NULL, 'boinc:forgot-password'), 'join') |
|
478 | - ), NULL, 'boinc:forgot-password')); |
|
479 | - } |
|
480 | - } |
|
455 | +$edit = $form_state['values']; |
|
456 | +// The Drupal submit function expects a "name" field, even though |
|
457 | +// it contains an email address and we will not allow a user name |
|
458 | +if (!$edit['name']) form_set_error('name', bts('Please enter your email address', array(), NULL, 'boinc:forgot-password')); |
|
459 | +elseif (!valid_email_address($edit['name'])) form_set_error('name', bts('@email is not a well formed email address, please verify', array('@email' => $edit['name']), NULL, 'boinc:forgot-password')); |
|
460 | +else { |
|
461 | +// set email addrress to lower case |
|
462 | +$lower_email_addr = strtolower($edit['name']); |
|
463 | + |
|
464 | +// First look for an existing Drupal account |
|
465 | +if ($account = user_load_by_mail($lower_email_addr)) return; |
|
466 | +// Otherwise, check the BOINC db for this email address |
|
467 | +require_boinc('boinc_db'); |
|
468 | +$boinc_user = BoincUser::lookup_email_addr($lower_email_addr); |
|
469 | +if ($boinc_user) { |
|
470 | + // If the user is in BOINC but not Drupal, bring them over... |
|
471 | + boincuser_register_make_drupal_user($boinc_user); |
|
472 | +} else { |
|
473 | + // If there is no existing BOINC user either, show an error |
|
474 | + form_set_error('name', bts('No account exists for @email -- please create an account using a BOINC client -- !instructions', |
|
475 | + array( |
|
476 | + '@email' => $edit['name'], |
|
477 | + '!instructions' => l(bts('Instructions', array(), NULL, 'boinc:forgot-password'), 'join') |
|
478 | + ), NULL, 'boinc:forgot-password')); |
|
479 | +} |
|
480 | +} |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
484 | 484 | * The definition of the authenticator login form. |
485 | 485 | */ |
486 | 486 | function boincuser_authloginform() { |
487 | - $headers = apache_request_headers(); |
|
488 | - $project_name = variable_get('site_name', 'Drupal-BOINC'); |
|
489 | - $project_domain = $headers['Host']; |
|
490 | - $form['heading'] = array( |
|
491 | - '#type' => 'markup', |
|
492 | - '#value' => '<h3>' . bts("If you forgot your account's email address, or you can't receive email there:", array(), NULL, 'boinc:authenticator-login-page') . '</h3>' |
|
493 | - ); |
|
494 | - $form['instructions'] = array( |
|
495 | - '#type' => 'markup', |
|
496 | - '#value' => '' . |
|
497 | - '<p>' . bts("If you have run BOINC under the account, you can still access it. Here's how:", array(), NULL, 'boinc:authenticator-login-page') . |
|
498 | - ' <ul>' . |
|
499 | - ' <li>' . bts('Go to the BOINC data directory on your computer (see !boinc_wiki for help finding this).', array('!boinc_wiki' => l(bts('BOINC documentation', array(), NULL, 'boinc:authenticator-login-page'), 'http://boinc.berkeley.edu/wiki/BOINC_Data_directory')), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
500 | - ' <li>' . bts('Find your account file for this project; it will have a name like %file (where the project URL is %url).', array('%file' => "account_{$project_domain}.xml", '%url' => "http://{$project_domain}"), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
501 | - ' <li>' . bts("Open the file in a text editor like Notepad. You'll see something like:", array(), NULL, 'boinc:authenticator-login-page') . |
|
502 | - ' <pre>' . |
|
503 | - '<account>' . "\n" . |
|
504 | - " <master_url>http://{$project_domain}/</master_url>" . "\n" . |
|
505 | - ' <authenticator>8b8496fdd26df7dc0423ecd43c09a56b</authenticator>' . "\n" . |
|
506 | - " <project_name>{$project_name}</project_name>" . "\n" . |
|
507 | - ' ...' . "\n" . |
|
508 | - '</account>' . |
|
509 | - ' </pre>' . |
|
510 | - ' </li>' . |
|
511 | - ' <li>' . bts('Select and Copy the string between <authenticator> and </authenticator> (%auth in the above example).', array('%auth' => '8b8496fdd26df7dc0423ecd43c09a56b'), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
512 | - ' <li>' . bts('Paste the string into the field below, and click OK.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
513 | - ' <li>' . bts('You will now be logged in to your account; update the email and password of your account.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
514 | - ' </ul>' . |
|
515 | - '</p>' |
|
516 | - ); |
|
517 | - $form['authenticator'] = array( |
|
518 | - '#title' => bts('Log in with authenticator', array(), NULL, 'boinc:authenticator-login-page'), |
|
519 | - '#type' => 'textfield', |
|
520 | - '#size' => 60, |
|
521 | - '#maxlength' => 32, |
|
522 | - '#required' => TRUE, |
|
523 | - '#description' => null |
|
524 | - ); |
|
525 | - |
|
526 | - // Form control |
|
527 | - $form['form control tabs prefix'] = array( |
|
528 | - '#value' => '<ul class="form-control tab-list">', |
|
529 | - '#weight' => 1001, |
|
530 | - ); |
|
531 | - $form['submit'] = array( |
|
532 | - '#prefix' => '<li class="first tab">', |
|
533 | - '#type' => 'submit', |
|
534 | - '#value' => bts('OK', array(), NULL, 'boinc:form-ok'), |
|
535 | - '#suffix' => '</li>', |
|
536 | - '#weight' => 1002, |
|
537 | - ); |
|
538 | - $form['form control tabs'] = array( |
|
539 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/password') . '</li>', |
|
540 | - '#weight' => 1003, |
|
541 | - ); |
|
542 | - $form['form control tabs suffix'] = array( |
|
543 | - '#value' => '</ul>', |
|
544 | - '#weight' => 1004, |
|
545 | - ); |
|
546 | - return $form; |
|
487 | +$headers = apache_request_headers(); |
|
488 | +$project_name = variable_get('site_name', 'Drupal-BOINC'); |
|
489 | +$project_domain = $headers['Host']; |
|
490 | +$form['heading'] = array( |
|
491 | +'#type' => 'markup', |
|
492 | +'#value' => '<h3>' . bts("If you forgot your account's email address, or you can't receive email there:", array(), NULL, 'boinc:authenticator-login-page') . '</h3>' |
|
493 | +); |
|
494 | +$form['instructions'] = array( |
|
495 | +'#type' => 'markup', |
|
496 | +'#value' => '' . |
|
497 | + '<p>' . bts("If you have run BOINC under the account, you can still access it. Here's how:", array(), NULL, 'boinc:authenticator-login-page') . |
|
498 | + ' <ul>' . |
|
499 | + ' <li>' . bts('Go to the BOINC data directory on your computer (see !boinc_wiki for help finding this).', array('!boinc_wiki' => l(bts('BOINC documentation', array(), NULL, 'boinc:authenticator-login-page'), 'http://boinc.berkeley.edu/wiki/BOINC_Data_directory')), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
500 | + ' <li>' . bts('Find your account file for this project; it will have a name like %file (where the project URL is %url).', array('%file' => "account_{$project_domain}.xml", '%url' => "http://{$project_domain}"), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
501 | + ' <li>' . bts("Open the file in a text editor like Notepad. You'll see something like:", array(), NULL, 'boinc:authenticator-login-page') . |
|
502 | + ' <pre>' . |
|
503 | + '<account>' . "\n" . |
|
504 | + " <master_url>http://{$project_domain}/</master_url>" . "\n" . |
|
505 | + ' <authenticator>8b8496fdd26df7dc0423ecd43c09a56b</authenticator>' . "\n" . |
|
506 | + " <project_name>{$project_name}</project_name>" . "\n" . |
|
507 | + ' ...' . "\n" . |
|
508 | + '</account>' . |
|
509 | + ' </pre>' . |
|
510 | + ' </li>' . |
|
511 | + ' <li>' . bts('Select and Copy the string between <authenticator> and </authenticator> (%auth in the above example).', array('%auth' => '8b8496fdd26df7dc0423ecd43c09a56b'), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
512 | + ' <li>' . bts('Paste the string into the field below, and click OK.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
513 | + ' <li>' . bts('You will now be logged in to your account; update the email and password of your account.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' . |
|
514 | + ' </ul>' . |
|
515 | + '</p>' |
|
516 | +); |
|
517 | +$form['authenticator'] = array( |
|
518 | +'#title' => bts('Log in with authenticator', array(), NULL, 'boinc:authenticator-login-page'), |
|
519 | +'#type' => 'textfield', |
|
520 | +'#size' => 60, |
|
521 | +'#maxlength' => 32, |
|
522 | +'#required' => TRUE, |
|
523 | +'#description' => null |
|
524 | +); |
|
525 | + |
|
526 | +// Form control |
|
527 | +$form['form control tabs prefix'] = array( |
|
528 | +'#value' => '<ul class="form-control tab-list">', |
|
529 | +'#weight' => 1001, |
|
530 | +); |
|
531 | +$form['submit'] = array( |
|
532 | +'#prefix' => '<li class="first tab">', |
|
533 | +'#type' => 'submit', |
|
534 | +'#value' => bts('OK', array(), NULL, 'boinc:form-ok'), |
|
535 | +'#suffix' => '</li>', |
|
536 | +'#weight' => 1002, |
|
537 | +); |
|
538 | +$form['form control tabs'] = array( |
|
539 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/password') . '</li>', |
|
540 | +'#weight' => 1003, |
|
541 | +); |
|
542 | +$form['form control tabs suffix'] = array( |
|
543 | +'#value' => '</ul>', |
|
544 | +'#weight' => 1004, |
|
545 | +); |
|
546 | +return $form; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
550 | 550 | * The authenticator login validation handler |
551 | 551 | */ |
552 | 552 | function boincuser_authloginform_validate($form, &$form_state) { |
553 | - $authenticator = $form_state['values']['authenticator']; |
|
554 | - if (strlen($authenticator) != 32) { |
|
555 | - // We notify the form API that this field has failed validation. |
|
556 | - form_set_error('authenticator', bts('That authenticator is not valid.', array(), NULL, 'boinc:authenticator-login-page')); |
|
557 | - } else { |
|
558 | - require_boinc('boinc_db'); |
|
559 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
|
560 | - if (!$boinc_user) form_set_error('authenticator', bts('There is no account with that authenticator.', array(), NULL, 'boinc:authenticator-login-page')); |
|
561 | - } |
|
553 | +$authenticator = $form_state['values']['authenticator']; |
|
554 | +if (strlen($authenticator) != 32) { |
|
555 | +// We notify the form API that this field has failed validation. |
|
556 | +form_set_error('authenticator', bts('That authenticator is not valid.', array(), NULL, 'boinc:authenticator-login-page')); |
|
557 | +} else { |
|
558 | +require_boinc('boinc_db'); |
|
559 | +$boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
|
560 | +if (!$boinc_user) form_set_error('authenticator', bts('There is no account with that authenticator.', array(), NULL, 'boinc:authenticator-login-page')); |
|
561 | +} |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
565 | 565 | * The authenticator login submit handler |
566 | 566 | */ |
567 | 567 | function boincuser_authloginform_submit($form, &$form_state) { |
568 | - global $user; |
|
569 | - $authenticator = $form_state['values']['authenticator']; |
|
570 | - require_boinc('boinc_db'); |
|
571 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
|
572 | - if (!$user = user_load(get_drupal_id($boinc_user->id))) drupal_set_message(t('An unresolved error occurred while logging into this account.')); |
|
573 | - else $form_state['redirect'] = 'account/info/edit'; |
|
568 | +global $user; |
|
569 | +$authenticator = $form_state['values']['authenticator']; |
|
570 | +require_boinc('boinc_db'); |
|
571 | +$boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'"); |
|
572 | +if (!$user = user_load(get_drupal_id($boinc_user->id))) drupal_set_message(t('An unresolved error occurred while logging into this account.')); |
|
573 | +else $form_state['redirect'] = 'account/info/edit'; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | |
@@ -578,44 +578,44 @@ discard block |
||
578 | 578 | * The definition of the moderator reject user profile form. |
579 | 579 | */ |
580 | 580 | function boincuser_moderate_profile_reject_form(&$form_state, $uid) { |
581 | - $form_state['storage']['reject_profile_uid'] = $uid; |
|
582 | - $form['reason'] = array( |
|
583 | - '#title' => bts('Reason for rejecting this profile', array(), NULL, 'boinc:moderate-user'), |
|
584 | - '#type' => 'textarea', |
|
585 | - '#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of the problem and how to fix it.', array(), NULL, 'boinc:moderate-user'), |
|
586 | - '#default_value' => '', |
|
587 | - ); |
|
588 | - |
|
589 | - // Form control |
|
590 | - $form['form control tabs prefix'] = array( |
|
591 | - '#value' => '<ul class="form-control tab-list">', |
|
592 | - '#weight' => 1001, |
|
593 | - ); |
|
594 | - $form['submit'] = array( |
|
595 | - '#prefix' => '<li class="first tab">', |
|
596 | - '#type' => 'submit', |
|
597 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
598 | - '#suffix' => '</li>', |
|
599 | - '#weight' => 1002, |
|
600 | - ); |
|
601 | - $form['form control tabs'] = array( |
|
602 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>', |
|
603 | - '#weight' => 1003, |
|
604 | - ); |
|
605 | - $form['form control tabs suffix'] = array( |
|
606 | - '#value' => '</ul>', |
|
607 | - '#weight' => 1004, |
|
608 | - ); |
|
609 | - return $form; |
|
581 | +$form_state['storage']['reject_profile_uid'] = $uid; |
|
582 | +$form['reason'] = array( |
|
583 | +'#title' => bts('Reason for rejecting this profile', array(), NULL, 'boinc:moderate-user'), |
|
584 | +'#type' => 'textarea', |
|
585 | +'#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of the problem and how to fix it.', array(), NULL, 'boinc:moderate-user'), |
|
586 | +'#default_value' => '', |
|
587 | +); |
|
588 | + |
|
589 | +// Form control |
|
590 | +$form['form control tabs prefix'] = array( |
|
591 | +'#value' => '<ul class="form-control tab-list">', |
|
592 | +'#weight' => 1001, |
|
593 | +); |
|
594 | +$form['submit'] = array( |
|
595 | +'#prefix' => '<li class="first tab">', |
|
596 | +'#type' => 'submit', |
|
597 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
598 | +'#suffix' => '</li>', |
|
599 | +'#weight' => 1002, |
|
600 | +); |
|
601 | +$form['form control tabs'] = array( |
|
602 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>', |
|
603 | +'#weight' => 1003, |
|
604 | +); |
|
605 | +$form['form control tabs suffix'] = array( |
|
606 | +'#value' => '</ul>', |
|
607 | +'#weight' => 1004, |
|
608 | +); |
|
609 | +return $form; |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
613 | 613 | * The moderator reject user profile submit handler |
614 | 614 | */ |
615 | 615 | function boincuser_moderate_profile_reject_form_submit($form, &$form_state) { |
616 | - $uid = $form_state['storage']['reject_profile_uid']; |
|
617 | - $reason = $form_state['values']['reason']; |
|
618 | - boincuser_moderate_profile_reject($uid, $reason); |
|
616 | +$uid = $form_state['storage']['reject_profile_uid']; |
|
617 | +$reason = $form_state['values']['reason']; |
|
618 | +boincuser_moderate_profile_reject($uid, $reason); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -623,52 +623,52 @@ discard block |
||
623 | 623 | * The definition of the ban user form. |
624 | 624 | */ |
625 | 625 | function boincuser_moderate_user_ban_form(&$form_state, $uid) { |
626 | - $form_state['storage']['ban_user_uid'] = $uid; |
|
627 | - $form['reason'] = array( |
|
628 | - '#title' => bts('Reason for banning this user', array(), NULL, 'boinc:moderate-user'), |
|
629 | - '#type' => 'textarea', |
|
630 | - '#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of why the user is being banned.', array(), NULL, 'boinc:moderate-user'), |
|
631 | - '#default_value' => '', |
|
632 | - ); |
|
633 | - $form['duration'] = array( |
|
634 | - '#title' => bts('Duration of the ban', array(), NULL, 'boinc:moderate-user'), |
|
635 | - '#type' => 'textfield', |
|
636 | - '#description' => bts('The number of days until the ban expires. Set to 0 to ban permanently.', array(), NULL, 'boinc:moderate-user'), |
|
637 | - '#default_value' => '', |
|
638 | - ); |
|
639 | - |
|
640 | - // Form control |
|
641 | - $form['form control tabs prefix'] = array( |
|
642 | - '#value' => '<ul class="form-control tab-list">', |
|
643 | - '#weight' => 1001, |
|
644 | - ); |
|
645 | - $form['submit'] = array( |
|
646 | - '#prefix' => '<li class="first tab">', |
|
647 | - '#type' => 'submit', |
|
648 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
649 | - '#suffix' => '</li>', |
|
650 | - '#weight' => 1002, |
|
651 | - ); |
|
652 | - $form['form control tabs'] = array( |
|
653 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>', |
|
654 | - '#weight' => 1003, |
|
655 | - ); |
|
656 | - $form['form control tabs suffix'] = array( |
|
657 | - '#value' => '</ul>', |
|
658 | - '#weight' => 1004, |
|
659 | - ); |
|
660 | - return $form; |
|
626 | +$form_state['storage']['ban_user_uid'] = $uid; |
|
627 | +$form['reason'] = array( |
|
628 | +'#title' => bts('Reason for banning this user', array(), NULL, 'boinc:moderate-user'), |
|
629 | +'#type' => 'textarea', |
|
630 | +'#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of why the user is being banned.', array(), NULL, 'boinc:moderate-user'), |
|
631 | +'#default_value' => '', |
|
632 | +); |
|
633 | +$form['duration'] = array( |
|
634 | +'#title' => bts('Duration of the ban', array(), NULL, 'boinc:moderate-user'), |
|
635 | +'#type' => 'textfield', |
|
636 | +'#description' => bts('The number of days until the ban expires. Set to 0 to ban permanently.', array(), NULL, 'boinc:moderate-user'), |
|
637 | +'#default_value' => '', |
|
638 | +); |
|
639 | + |
|
640 | +// Form control |
|
641 | +$form['form control tabs prefix'] = array( |
|
642 | +'#value' => '<ul class="form-control tab-list">', |
|
643 | +'#weight' => 1001, |
|
644 | +); |
|
645 | +$form['submit'] = array( |
|
646 | +'#prefix' => '<li class="first tab">', |
|
647 | +'#type' => 'submit', |
|
648 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
649 | +'#suffix' => '</li>', |
|
650 | +'#weight' => 1002, |
|
651 | +); |
|
652 | +$form['form control tabs'] = array( |
|
653 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>', |
|
654 | +'#weight' => 1003, |
|
655 | +); |
|
656 | +$form['form control tabs suffix'] = array( |
|
657 | +'#value' => '</ul>', |
|
658 | +'#weight' => 1004, |
|
659 | +); |
|
660 | +return $form; |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
664 | 664 | * The ban user submit handler |
665 | 665 | */ |
666 | 666 | function boincuser_moderate_user_ban_form_submit($form, &$form_state) { |
667 | - $uid = $form_state['storage']['ban_user_uid']; |
|
668 | - $reason = $form_state['values']['reason']; |
|
669 | - $duration = $form_state['values']['duration']; |
|
670 | - if ($duration) $duration = $duration * 24*60*60; |
|
671 | - boincuser_moderate_user_ban($uid, $reason, $duration); |
|
667 | +$uid = $form_state['storage']['ban_user_uid']; |
|
668 | +$reason = $form_state['values']['reason']; |
|
669 | +$duration = $form_state['values']['duration']; |
|
670 | +if ($duration) $duration = $duration * 24*60*60; |
|
671 | +boincuser_moderate_user_ban($uid, $reason, $duration); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | |
@@ -676,10 +676,10 @@ discard block |
||
676 | 676 | * Hack to fix submission of the flag friend unfriend form |
677 | 677 | */ |
678 | 678 | function boincuser_fix_unfriend_form_submit($form, &$form_state) { |
679 | - // Leaving action as "unfriend" causes problems |
|
680 | - if ($form_state['values']['action'] == 'unfriend') { |
|
681 | - $form_state['values']['action'] = 'unflag'; |
|
682 | - } |
|
679 | +// Leaving action as "unfriend" causes problems |
|
680 | +if ($form_state['values']['action'] == 'unfriend') { |
|
681 | +$form_state['values']['action'] = 'unflag'; |
|
682 | +} |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -687,90 +687,90 @@ discard block |
||
687 | 687 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
688 | 688 | |
689 | 689 | function boincuser_termsofuse_form() { |
690 | - global $user; |
|
691 | - |
|
692 | - // If user has already signed terms of use, and got to this form in error, send them to site home. |
|
693 | - if (boincuser_check_termsofuse($user)) { |
|
694 | - drupal_goto(); |
|
695 | - } |
|
696 | - |
|
697 | - drupal_set_message( bts('WARNING: You have not agreed to our terms of use. Please agree to the terms of use before continuing.', array(), NULL, 'boinc:termsofuse-form'), 'warning' ); |
|
690 | +global $user; |
|
698 | 691 | |
699 | - $form = array(); |
|
700 | - |
|
701 | - // Terms of use section |
|
702 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
703 | - $form['title1'] = array( |
|
704 | - '#weight' => -12, |
|
705 | - '#value' => '<h2>' . bts( variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:termsofuse-form' ) . '</h2>', |
|
706 | - '#prefix' => '<div id="register-title1">', |
|
707 | - '#suffix' => '</div>', |
|
708 | - ); |
|
709 | - |
|
710 | - $form['termsofuse'] = array( |
|
711 | - '#weight' => -10, |
|
712 | - '#value' => bts($termsofuse, array(), NULL, 'project:termsofuse-form'), |
|
713 | - '#prefix' => '<div id="register-termsofuse">', |
|
714 | - '#suffix' => '</div>', |
|
715 | - ); |
|
716 | - |
|
717 | - $form['agreeTOU'] = array( |
|
718 | - '#type' => 'checkbox', |
|
719 | - '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:termsofuse-form'), |
|
720 | - '#weight' => -8, |
|
721 | - '#prefix' => '<div id="register-checkbox">', |
|
722 | - '#suffix' => '</div>', |
|
723 | - ); |
|
724 | - |
|
725 | - $form['spacer'] = array( |
|
726 | - '#prefix' => '<div id="register-title2">', |
|
727 | - '#value' => ' ', |
|
728 | - '#suffix' => '</div>', |
|
729 | - ); |
|
692 | +// If user has already signed terms of use, and got to this form in error, send them to site home. |
|
693 | +if (boincuser_check_termsofuse($user)) { |
|
694 | +drupal_goto(); |
|
695 | +} |
|
730 | 696 | |
731 | - // Form Control |
|
732 | - $form['submit'] = array( |
|
733 | - '#prefix' => '<p><p><p><li class="first tab">', |
|
734 | - '#type' => 'submit', |
|
735 | - '#value' => bts('Yes', array(), NULL, 'boinc:form-submit'), |
|
736 | - '#suffix' => '</li>', |
|
737 | - ); |
|
738 | - $form['form control tabs'] = array( |
|
739 | - '#value' => '<li class="tab">' . l(bts('NO - LOGOUT', array(), NULL, 'boinc:form-cancel'), '/logout') . '</li>', |
|
740 | - ); |
|
741 | - if (module_exists('boincuser_delete')) { |
|
742 | - $deletelink = '/user/' . $user->uid . '/delete'; |
|
743 | - $form['deleteaccount'] = array( |
|
744 | - '#value' => '<li class="tab">' . l(bts('NO - DELETE ACCOUNT', array(), NULL, 'boinc:form-delete-user'), $deletelink) . '</li>', |
|
745 | - ); |
|
746 | - } |
|
697 | +drupal_set_message( bts('WARNING: You have not agreed to our terms of use. Please agree to the terms of use before continuing.', array(), NULL, 'boinc:termsofuse-form'), 'warning' ); |
|
698 | + |
|
699 | +$form = array(); |
|
700 | + |
|
701 | +// Terms of use section |
|
702 | +$termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
703 | +$form['title1'] = array( |
|
704 | +'#weight' => -12, |
|
705 | +'#value' => '<h2>' . bts( variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:termsofuse-form' ) . '</h2>', |
|
706 | +'#prefix' => '<div id="register-title1">', |
|
707 | +'#suffix' => '</div>', |
|
708 | +); |
|
709 | + |
|
710 | +$form['termsofuse'] = array( |
|
711 | +'#weight' => -10, |
|
712 | +'#value' => bts($termsofuse, array(), NULL, 'project:termsofuse-form'), |
|
713 | +'#prefix' => '<div id="register-termsofuse">', |
|
714 | +'#suffix' => '</div>', |
|
715 | +); |
|
716 | + |
|
717 | +$form['agreeTOU'] = array( |
|
718 | +'#type' => 'checkbox', |
|
719 | +'#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:termsofuse-form'), |
|
720 | +'#weight' => -8, |
|
721 | +'#prefix' => '<div id="register-checkbox">', |
|
722 | +'#suffix' => '</div>', |
|
723 | +); |
|
724 | + |
|
725 | +$form['spacer'] = array( |
|
726 | +'#prefix' => '<div id="register-title2">', |
|
727 | +'#value' => ' ', |
|
728 | +'#suffix' => '</div>', |
|
729 | +); |
|
730 | + |
|
731 | +// Form Control |
|
732 | +$form['submit'] = array( |
|
733 | +'#prefix' => '<p><p><p><li class="first tab">', |
|
734 | +'#type' => 'submit', |
|
735 | +'#value' => bts('Yes', array(), NULL, 'boinc:form-submit'), |
|
736 | +'#suffix' => '</li>', |
|
737 | +); |
|
738 | +$form['form control tabs'] = array( |
|
739 | +'#value' => '<li class="tab">' . l(bts('NO - LOGOUT', array(), NULL, 'boinc:form-cancel'), '/logout') . '</li>', |
|
740 | +); |
|
741 | +if (module_exists('boincuser_delete')) { |
|
742 | +$deletelink = '/user/' . $user->uid . '/delete'; |
|
743 | +$form['deleteaccount'] = array( |
|
744 | + '#value' => '<li class="tab">' . l(bts('NO - DELETE ACCOUNT', array(), NULL, 'boinc:form-delete-user'), $deletelink) . '</li>', |
|
745 | +); |
|
746 | +} |
|
747 | 747 | |
748 | - // Set form redirect |
|
749 | - $form['#redirect'] = $_REQUEST['destination']; |
|
748 | +// Set form redirect |
|
749 | +$form['#redirect'] = $_REQUEST['destination']; |
|
750 | 750 | |
751 | - // Add the current user's data into the form |
|
752 | - $form['#account'] = $user; |
|
751 | +// Add the current user's data into the form |
|
752 | +$form['#account'] = $user; |
|
753 | 753 | |
754 | - return $form; |
|
754 | +return $form; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | function boincuser_termsofuse_form_validate($form, &$form_state) { |
758 | - // Check TOU agreement |
|
759 | - if (!$form_state['values']['agreeTOU']) { |
|
760 | - form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', array(), NULL, 'boinc:termsofuse-form')); |
|
761 | - } |
|
758 | +// Check TOU agreement |
|
759 | +if (!$form_state['values']['agreeTOU']) { |
|
760 | +form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', array(), NULL, 'boinc:termsofuse-form')); |
|
761 | +} |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | function boincuser_termsofuse_form_submit($form, &$form_state) { |
765 | - $user = $form['#account']; |
|
766 | - if (!boincuser_consentto_termsofuse($user)) { |
|
767 | - form_set_error('termsofuse', bts('There was an error in agreeing to the terms of use. Please contact the site administrators.', array(), NULL, 'boinc:termsofuse-form')); |
|
768 | - } |
|
765 | +$user = $form['#account']; |
|
766 | +if (!boincuser_consentto_termsofuse($user)) { |
|
767 | +form_set_error('termsofuse', bts('There was an error in agreeing to the terms of use. Please contact the site administrators.', array(), NULL, 'boinc:termsofuse-form')); |
|
768 | +} |
|
769 | 769 | |
770 | - // Delete session messages |
|
771 | - if ($_SESSION['messages']['warning']) { |
|
772 | - unset($_SESSION['messages']['warning']); |
|
773 | - } |
|
770 | +// Delete session messages |
|
771 | +if ($_SESSION['messages']['warning']) { |
|
772 | +unset($_SESSION['messages']['warning']); |
|
773 | +} |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | /** |
@@ -779,88 +779,88 @@ discard block |
||
779 | 779 | * removed after used. |
780 | 780 | */ |
781 | 781 | function boincuser_revertemail(&$form_state, $token) { |
782 | - require_boinc('token'); |
|
783 | - require_boinc('util'); |
|
784 | - |
|
785 | - global $user; |
|
786 | - $form = array(); |
|
787 | - |
|
788 | - // drupal JS for dynamic password validation |
|
789 | - _user_password_dynamic_validation(); |
|
790 | - |
|
791 | - // check BOINC user exists |
|
792 | - $account = user_load(array('uid' => $user->uid)); |
|
793 | - $uid = $user->uid; |
|
794 | - $boincid = $account->boincuser_id; |
|
795 | - // check $token is valid |
|
796 | - if (!is_valid_token($boincid, $token, 'E')) { |
|
797 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your email address.', |
|
798 | - array( |
|
799 | - '!link' => l(bts('changing', array(), NULL, 'boinc:revert-email-change'), "/account/info/edit"), |
|
800 | - ), |
|
801 | - NULL, 'boinc:revert-email-change'), 'error'); |
|
802 | - drupal_goto(); |
|
803 | - } |
|
804 | - |
|
805 | - // Attach account and token to this form. |
|
806 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
807 | - $form['_token'] = array('#type' => 'value', '#value' => $token); |
|
808 | - |
|
809 | - // Instructions |
|
810 | - $form['main']['instructions1'] = array( |
|
811 | - '#value' => '<p>'. |
|
812 | - bts('In order to change your email back to your previous email address, <strong>!prev_email</strong>, you must also change your password.', |
|
813 | - array( |
|
814 | - '!prev_email' => $account->boincuser_previous_email_addr, |
|
815 | - ), |
|
816 | - NULL, 'boinc:revert-email-change'). |
|
817 | - '</p>', |
|
818 | - ); |
|
819 | - |
|
820 | - $form['main']['pass'] = array( |
|
821 | - '#type' => 'password_confirm', |
|
822 | - '#description' => 'Enter a new password in both fields', |
|
823 | - '#size' => 17, |
|
824 | - ); |
|
825 | - |
|
826 | - // Wrap action buttons for styling consistency |
|
827 | - $form['buttons']['form control tabs prefix'] = array( |
|
828 | - '#value' => '<ul class="form-control tab-list">', |
|
829 | - '#weight' => 1001, |
|
830 | - ); |
|
831 | - $form['buttons']['submit']['#type'] = 'submit'; |
|
832 | - $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
|
833 | - $form['buttons']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
834 | - $form['buttons']['submit']['#suffix'] = '</li>'; |
|
835 | - $form['buttons']['submit']['#weight'] = 1002; |
|
836 | - $form['buttons']['cancel'] = array( |
|
837 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/info/edit') . '</li>', |
|
838 | - '#weight' => 1005, |
|
839 | - ); |
|
840 | - $form['buttons']['form control tabs suffix'] = array( |
|
841 | - '#value' => '</ul>', |
|
842 | - '#weight' => 1010, |
|
843 | - ); |
|
782 | +require_boinc('token'); |
|
783 | +require_boinc('util'); |
|
784 | + |
|
785 | +global $user; |
|
786 | +$form = array(); |
|
787 | + |
|
788 | +// drupal JS for dynamic password validation |
|
789 | +_user_password_dynamic_validation(); |
|
790 | + |
|
791 | +// check BOINC user exists |
|
792 | +$account = user_load(array('uid' => $user->uid)); |
|
793 | +$uid = $user->uid; |
|
794 | +$boincid = $account->boincuser_id; |
|
795 | +// check $token is valid |
|
796 | +if (!is_valid_token($boincid, $token, 'E')) { |
|
797 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your email address.', |
|
798 | +array( |
|
799 | + '!link' => l(bts('changing', array(), NULL, 'boinc:revert-email-change'), "/account/info/edit"), |
|
800 | +), |
|
801 | +NULL, 'boinc:revert-email-change'), 'error'); |
|
802 | +drupal_goto(); |
|
803 | +} |
|
844 | 804 | |
845 | - return $form; |
|
805 | +// Attach account and token to this form. |
|
806 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
807 | +$form['_token'] = array('#type' => 'value', '#value' => $token); |
|
808 | + |
|
809 | +// Instructions |
|
810 | +$form['main']['instructions1'] = array( |
|
811 | +'#value' => '<p>'. |
|
812 | +bts('In order to change your email back to your previous email address, <strong>!prev_email</strong>, you must also change your password.', |
|
813 | + array( |
|
814 | + '!prev_email' => $account->boincuser_previous_email_addr, |
|
815 | + ), |
|
816 | + NULL, 'boinc:revert-email-change'). |
|
817 | +'</p>', |
|
818 | +); |
|
819 | + |
|
820 | +$form['main']['pass'] = array( |
|
821 | +'#type' => 'password_confirm', |
|
822 | +'#description' => 'Enter a new password in both fields', |
|
823 | +'#size' => 17, |
|
824 | +); |
|
825 | + |
|
826 | +// Wrap action buttons for styling consistency |
|
827 | +$form['buttons']['form control tabs prefix'] = array( |
|
828 | + '#value' => '<ul class="form-control tab-list">', |
|
829 | + '#weight' => 1001, |
|
830 | +); |
|
831 | +$form['buttons']['submit']['#type'] = 'submit'; |
|
832 | +$form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
|
833 | +$form['buttons']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
834 | +$form['buttons']['submit']['#suffix'] = '</li>'; |
|
835 | +$form['buttons']['submit']['#weight'] = 1002; |
|
836 | +$form['buttons']['cancel'] = array( |
|
837 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/info/edit') . '</li>', |
|
838 | + '#weight' => 1005, |
|
839 | +); |
|
840 | +$form['buttons']['form control tabs suffix'] = array( |
|
841 | + '#value' => '</ul>', |
|
842 | + '#weight' => 1010, |
|
843 | +); |
|
844 | + |
|
845 | +return $form; |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
849 | 849 | * Validation handler for revertemail form |
850 | 850 | */ |
851 | 851 | function boincuser_revertemail_validate($form, &$form_state) { |
852 | - // Load account and boincuser |
|
853 | - $account = $form_state['values']['_account']; |
|
854 | - $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
855 | - |
|
856 | - if (BoincUser::lookup_email_addr($boinc_user->previous_email_addr)) { |
|
857 | - form_set_error('mail', bts('An account already exists for @email. Please contact admins for @project. Previous email address cannot be used because another account is using it as their email address.', |
|
858 | - array( |
|
859 | - '@email' => $boinc_user->previous_email_addr, |
|
860 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
861 | - ), |
|
862 | - NULL, 'boinc:add-new-user')); |
|
863 | - } |
|
852 | +// Load account and boincuser |
|
853 | +$account = $form_state['values']['_account']; |
|
854 | +$boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
855 | + |
|
856 | +if (BoincUser::lookup_email_addr($boinc_user->previous_email_addr)) { |
|
857 | +form_set_error('mail', bts('An account already exists for @email. Please contact admins for @project. Previous email address cannot be used because another account is using it as their email address.', |
|
858 | + array( |
|
859 | + '@email' => $boinc_user->previous_email_addr, |
|
860 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
861 | + ), |
|
862 | +NULL, 'boinc:add-new-user')); |
|
863 | +} |
|
864 | 864 | |
865 | 865 | } |
866 | 866 | |
@@ -868,25 +868,25 @@ discard block |
||
868 | 868 | * Submit handler for revertemail form |
869 | 869 | */ |
870 | 870 | function boincuser_revertemail_submit($form, &$form_state) { |
871 | - require_boinc('password_compat/password'); |
|
871 | +require_boinc('password_compat/password'); |
|
872 | 872 | |
873 | - // Load account and boincuser |
|
874 | - $account = $form_state['values']['_account']; |
|
875 | - $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
873 | +// Load account and boincuser |
|
874 | +$account = $form_state['values']['_account']; |
|
875 | +$boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id); |
|
876 | 876 | |
877 | - $pem = strtolower($boinc_user->previous_email_addr); |
|
877 | +$pem = strtolower($boinc_user->previous_email_addr); |
|
878 | 878 | |
879 | - // Set new password based on previous email address and entered |
|
880 | - // password. |
|
881 | - $new_passwd_hash = password_hash( md5($form_state['values']['pass'].$pem), PASSWORD_DEFAULT); |
|
879 | +// Set new password based on previous email address and entered |
|
880 | +// password. |
|
881 | +$new_passwd_hash = password_hash( md5($form_state['values']['pass'].$pem), PASSWORD_DEFAULT); |
|
882 | 882 | |
883 | - $boinc_user->update("email_addr='${pem}', previous_email_addr='', email_addr_change_time=0, passwd_hash='${new_passwd_hash}'"); |
|
883 | +$boinc_user->update("email_addr='${pem}', previous_email_addr='', email_addr_change_time=0, passwd_hash='${new_passwd_hash}'"); |
|
884 | 884 | |
885 | - // Set email in drupal database to previous email |
|
886 | - user_save($account, array('mail' => $pem)); |
|
885 | +// Set email in drupal database to previous email |
|
886 | +user_save($account, array('mail' => $pem)); |
|
887 | 887 | |
888 | - // delete the token |
|
889 | - $result = delete_token($account->boincuser_id, $form_state['values']['_token'], 'E'); |
|
888 | +// delete the token |
|
889 | +$result = delete_token($account->boincuser_id, $form_state['values']['_token'], 'E'); |
|
890 | 890 | |
891 | - drupal_goto('account'); |
|
891 | +drupal_goto('account'); |
|
892 | 892 | } |
@@ -27,295 +27,295 @@ discard block |
||
27 | 27 | * with defined URL paths |
28 | 28 | */ |
29 | 29 | function boincuser_menu() { |
30 | - $items['account/posts'] = array( |
|
31 | - 'title' => 'Recent posts', |
|
32 | - 'description' => '', |
|
33 | - 'page callback' => 'boincuser_goto_recent_posts', |
|
34 | - 'access callback' => 'user_is_logged_in', |
|
35 | - 'type' => MENU_CALLBACK, |
|
36 | - ); |
|
37 | - $items['account/profile'] = array( |
|
38 | - 'title' => '', |
|
39 | - 'description' => '', |
|
40 | - 'page callback' => 'boincuser_view_profile', |
|
41 | - 'access callback' => 'user_is_logged_in', |
|
42 | - 'type' => MENU_NORMAL_ITEM |
|
43 | - ); |
|
44 | - $items['account/profile/view'] = array( |
|
45 | - 'title' => 'View', |
|
46 | - 'description' => 'Show a user profile', |
|
47 | - 'page callback' => 'boincuser_view_profile', |
|
48 | - 'access callback' => 'user_is_logged_in', |
|
49 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | - 'weight' => 0 |
|
51 | - ); |
|
52 | - $items['account/profile/edit'] = array( |
|
53 | - 'title' => 'Edit', |
|
54 | - 'description' => 'Edit a user profile', |
|
55 | - 'page callback' => 'boincuser_edit_profile', |
|
56 | - 'access arguments' => array('edit own profile content'), |
|
57 | - 'type' => MENU_LOCAL_TASK, |
|
58 | - 'weight' => 5 |
|
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
61 | - 'title' => 'User team', |
|
62 | - 'description' => '', |
|
63 | - 'page callback' => 'boincuser_goto_team', |
|
64 | - 'access callback' => 'user_is_logged_in', |
|
65 | - 'type' => MENU_CALLBACK, |
|
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
68 | - 'title' => 'Profile approval', |
|
69 | - 'description' => 'Approve profile content', |
|
70 | - 'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | - 'page arguments' => array(2), |
|
72 | - 'access arguments' => array('edit any profile content'), |
|
73 | - 'type' => MENU_CALLBACK, |
|
74 | - 'weight' => 5 |
|
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
77 | - 'title' => 'Profile editor', |
|
78 | - 'description' => 'Edit a user profile', |
|
79 | - 'page callback' => 'boincuser_edit_profile', |
|
80 | - 'page arguments' => array(2), |
|
81 | - 'access arguments' => array('edit any profile content'), |
|
82 | - 'type' => MENU_CALLBACK, |
|
83 | - 'weight' => 5 |
|
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
86 | - 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | - 'description' => 'Reject profile content', |
|
88 | - 'page callback' => 'drupal_get_form', |
|
89 | - 'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | - 'access arguments' => array('edit any profile content'), |
|
91 | - 'type' => MENU_CALLBACK, |
|
92 | - 'weight' => 5 |
|
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
95 | - 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | - 'description' => 'Ban a user from using community features', |
|
97 | - 'page callback' => 'drupal_get_form', |
|
98 | - 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | - 'access callback' => 'boincuser_moderate_community_access', |
|
100 | - 'type' => MENU_CALLBACK, |
|
101 | - ); |
|
102 | - $items['join'] = array( |
|
103 | - 'title' => '', |
|
104 | - 'description' => '', |
|
105 | - 'page callback' => 'join_page', |
|
106 | - 'access arguments' => array('access content'), |
|
107 | - 'type' => MENU_NORMAL_ITEM |
|
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
110 | - 'title' => bts("I'm new"), |
|
111 | - 'page callback' => 'join_page', |
|
112 | - 'page arguments' => array(1), |
|
113 | - 'access arguments' => array('access content'), |
|
114 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | - 'weight' => 0 |
|
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
118 | - 'title' => bts("I'm a BOINC user"), |
|
119 | - 'page callback' => 'join_page', |
|
120 | - 'page arguments' => array(1), |
|
121 | - 'access arguments' => array('access content'), |
|
122 | - 'type' => MENU_LOCAL_TASK, |
|
123 | - 'weight' => 5 |
|
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
126 | - 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | - 'description' => 'Log in using a user authenticator', |
|
128 | - 'page callback' => 'drupal_get_form', |
|
129 | - 'page arguments' => array('boincuser_authloginform'), |
|
130 | - 'access arguments' => array('access content'), |
|
131 | - 'type' => MENU_CALLBACK, |
|
132 | - ); |
|
133 | - $items['user/termsofuse'] = array( |
|
134 | - 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
135 | - 'description' => 'A site\'s term of use.', |
|
136 | - 'page callback' => 'drupal_get_form', |
|
137 | - 'page arguments' => array('boincuser_termsofuse_form'), |
|
138 | - 'access callback' => 'user_is_logged_in', |
|
139 | - 'type' => MENU_CALLBACK, |
|
140 | - ); |
|
141 | - $items['user_control'] = array( |
|
142 | - 'page callback' => 'boincuser_control', |
|
143 | - 'access arguments' => array('access user profiles'), |
|
144 | - 'type' => MENU_CALLBACK |
|
145 | - ); |
|
146 | - $items['admin/boinc'] = array( |
|
147 | - 'title' => 'BOINC configuration', |
|
148 | - 'position' => 'right', |
|
149 | - 'weight' => -8, |
|
150 | - 'page callback' => 'system_admin_menu_block_page', |
|
151 | - 'access arguments' => array('administer site configuration'), |
|
152 | - 'file' => 'system.admin.inc', |
|
153 | - 'file path' => drupal_get_path('module', 'system'), |
|
154 | - ); |
|
155 | - $items['admin/boinc/environment'] = array( |
|
156 | - 'title' => 'Environment: General', |
|
157 | - 'description' => 'Set paths to BOINC functions and any other necessary |
|
30 | +$items['account/posts'] = array( |
|
31 | +'title' => 'Recent posts', |
|
32 | +'description' => '', |
|
33 | +'page callback' => 'boincuser_goto_recent_posts', |
|
34 | +'access callback' => 'user_is_logged_in', |
|
35 | +'type' => MENU_CALLBACK, |
|
36 | +); |
|
37 | +$items['account/profile'] = array( |
|
38 | +'title' => '', |
|
39 | +'description' => '', |
|
40 | +'page callback' => 'boincuser_view_profile', |
|
41 | +'access callback' => 'user_is_logged_in', |
|
42 | +'type' => MENU_NORMAL_ITEM |
|
43 | +); |
|
44 | +$items['account/profile/view'] = array( |
|
45 | +'title' => 'View', |
|
46 | +'description' => 'Show a user profile', |
|
47 | +'page callback' => 'boincuser_view_profile', |
|
48 | +'access callback' => 'user_is_logged_in', |
|
49 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | +'weight' => 0 |
|
51 | +); |
|
52 | +$items['account/profile/edit'] = array( |
|
53 | +'title' => 'Edit', |
|
54 | +'description' => 'Edit a user profile', |
|
55 | +'page callback' => 'boincuser_edit_profile', |
|
56 | +'access arguments' => array('edit own profile content'), |
|
57 | +'type' => MENU_LOCAL_TASK, |
|
58 | +'weight' => 5 |
|
59 | +); |
|
60 | +$items['account/team'] = array( |
|
61 | +'title' => 'User team', |
|
62 | +'description' => '', |
|
63 | +'page callback' => 'boincuser_goto_team', |
|
64 | +'access callback' => 'user_is_logged_in', |
|
65 | +'type' => MENU_CALLBACK, |
|
66 | +); |
|
67 | +$items['moderate/profile/%user/approve'] = array( |
|
68 | +'title' => 'Profile approval', |
|
69 | +'description' => 'Approve profile content', |
|
70 | +'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | +'page arguments' => array(2), |
|
72 | +'access arguments' => array('edit any profile content'), |
|
73 | +'type' => MENU_CALLBACK, |
|
74 | +'weight' => 5 |
|
75 | +); |
|
76 | +$items['moderate/profile/%user/edit'] = array( |
|
77 | +'title' => 'Profile editor', |
|
78 | +'description' => 'Edit a user profile', |
|
79 | +'page callback' => 'boincuser_edit_profile', |
|
80 | +'page arguments' => array(2), |
|
81 | +'access arguments' => array('edit any profile content'), |
|
82 | +'type' => MENU_CALLBACK, |
|
83 | +'weight' => 5 |
|
84 | +); |
|
85 | +$items['moderate/profile/%/reject'] = array( |
|
86 | +'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | +'description' => 'Reject profile content', |
|
88 | +'page callback' => 'drupal_get_form', |
|
89 | +'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | +'access arguments' => array('edit any profile content'), |
|
91 | +'type' => MENU_CALLBACK, |
|
92 | +'weight' => 5 |
|
93 | +); |
|
94 | +$items['moderate/user/%/ban'] = array( |
|
95 | +'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | +'description' => 'Ban a user from using community features', |
|
97 | +'page callback' => 'drupal_get_form', |
|
98 | +'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | +'access callback' => 'boincuser_moderate_community_access', |
|
100 | +'type' => MENU_CALLBACK, |
|
101 | +); |
|
102 | +$items['join'] = array( |
|
103 | +'title' => '', |
|
104 | +'description' => '', |
|
105 | +'page callback' => 'join_page', |
|
106 | +'access arguments' => array('access content'), |
|
107 | +'type' => MENU_NORMAL_ITEM |
|
108 | +); |
|
109 | +$items['join/new'] = array( |
|
110 | +'title' => bts("I'm new"), |
|
111 | +'page callback' => 'join_page', |
|
112 | +'page arguments' => array(1), |
|
113 | +'access arguments' => array('access content'), |
|
114 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | +'weight' => 0 |
|
116 | +); |
|
117 | +$items['join/boinc'] = array( |
|
118 | +'title' => bts("I'm a BOINC user"), |
|
119 | +'page callback' => 'join_page', |
|
120 | +'page arguments' => array(1), |
|
121 | +'access arguments' => array('access content'), |
|
122 | +'type' => MENU_LOCAL_TASK, |
|
123 | +'weight' => 5 |
|
124 | +); |
|
125 | +$items['user/login/auth'] = array( |
|
126 | +'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | +'description' => 'Log in using a user authenticator', |
|
128 | +'page callback' => 'drupal_get_form', |
|
129 | +'page arguments' => array('boincuser_authloginform'), |
|
130 | +'access arguments' => array('access content'), |
|
131 | +'type' => MENU_CALLBACK, |
|
132 | +); |
|
133 | +$items['user/termsofuse'] = array( |
|
134 | +'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
135 | +'description' => 'A site\'s term of use.', |
|
136 | +'page callback' => 'drupal_get_form', |
|
137 | +'page arguments' => array('boincuser_termsofuse_form'), |
|
138 | +'access callback' => 'user_is_logged_in', |
|
139 | +'type' => MENU_CALLBACK, |
|
140 | +); |
|
141 | +$items['user_control'] = array( |
|
142 | +'page callback' => 'boincuser_control', |
|
143 | +'access arguments' => array('access user profiles'), |
|
144 | +'type' => MENU_CALLBACK |
|
145 | +); |
|
146 | +$items['admin/boinc'] = array( |
|
147 | +'title' => 'BOINC configuration', |
|
148 | +'position' => 'right', |
|
149 | +'weight' => -8, |
|
150 | +'page callback' => 'system_admin_menu_block_page', |
|
151 | +'access arguments' => array('administer site configuration'), |
|
152 | +'file' => 'system.admin.inc', |
|
153 | +'file path' => drupal_get_path('module', 'system'), |
|
154 | +); |
|
155 | +$items['admin/boinc/environment'] = array( |
|
156 | +'title' => 'Environment: General', |
|
157 | +'description' => 'Set paths to BOINC functions and any other necessary |
|
158 | 158 | variables that establish a BOINC environment.', |
159 | - 'page callback' => 'drupal_get_form', |
|
160 | - 'page arguments' => array('boincuser_admin_environment'), |
|
161 | - 'access arguments' => array('administer site configuration'), |
|
162 | - 'type' => MENU_NORMAL_ITEM, |
|
163 | - 'file' => 'boincuser.admin.inc' |
|
164 | - ); |
|
165 | - $items['admin/boinc/scheduler'] = array( |
|
166 | - 'title' => 'Environment: Scheduling server URLs', |
|
167 | - 'description' => 'Set BOINC scheduler options.', |
|
168 | - 'page callback' => 'drupal_get_form', |
|
169 | - 'page arguments' => array('boincuser_admin_scheduler'), |
|
170 | - 'access arguments' => array('administer site configuration'), |
|
171 | - 'type' => MENU_NORMAL_ITEM, |
|
172 | - 'file' => 'boincuser.admin.inc' |
|
173 | - ); |
|
174 | - $items['admin/boinc/weboptions'] = array( |
|
175 | - 'title' => 'Environment: Website Options', |
|
176 | - 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
177 | - 'page callback' => 'drupal_get_form', |
|
178 | - 'page arguments' => array('boincuser_admin_weboptions'), |
|
179 | - 'access arguments' => array('administer site configuration'), |
|
180 | - 'type' => MENU_NORMAL_ITEM, |
|
181 | - 'file' => 'boincuser.admin.inc' |
|
182 | - ); |
|
159 | +'page callback' => 'drupal_get_form', |
|
160 | +'page arguments' => array('boincuser_admin_environment'), |
|
161 | +'access arguments' => array('administer site configuration'), |
|
162 | +'type' => MENU_NORMAL_ITEM, |
|
163 | +'file' => 'boincuser.admin.inc' |
|
164 | +); |
|
165 | +$items['admin/boinc/scheduler'] = array( |
|
166 | +'title' => 'Environment: Scheduling server URLs', |
|
167 | +'description' => 'Set BOINC scheduler options.', |
|
168 | +'page callback' => 'drupal_get_form', |
|
169 | +'page arguments' => array('boincuser_admin_scheduler'), |
|
170 | +'access arguments' => array('administer site configuration'), |
|
171 | +'type' => MENU_NORMAL_ITEM, |
|
172 | +'file' => 'boincuser.admin.inc' |
|
173 | +); |
|
174 | +$items['admin/boinc/weboptions'] = array( |
|
175 | +'title' => 'Environment: Website Options', |
|
176 | +'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
177 | +'page callback' => 'drupal_get_form', |
|
178 | +'page arguments' => array('boincuser_admin_weboptions'), |
|
179 | +'access arguments' => array('administer site configuration'), |
|
180 | +'type' => MENU_NORMAL_ITEM, |
|
181 | +'file' => 'boincuser.admin.inc' |
|
182 | +); |
|
183 | 183 | |
184 | - $items['create_account.php'] = array( |
|
185 | - 'title' => 'Create Account RPC', |
|
186 | - 'description' => 'RPC for creating user accounts.', |
|
187 | - 'page callback' => 'boincuser_create_account', |
|
188 | - 'access callback' => TRUE, |
|
189 | - 'type' => MENU_CALLBACK |
|
190 | - ); |
|
191 | - $items['account_finish.php'] = array( |
|
192 | - 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
193 | - 'description' => 'RPC for after a user has created an account.', |
|
194 | - 'page callback' => 'boincuser_account_finish', |
|
195 | - 'access callback' => TRUE, |
|
196 | - 'type' => MENU_CALLBACK, |
|
197 | - ); |
|
198 | - $items['boincuser/autocomplete'] = array( |
|
199 | - 'page callback' => '_boincuser_user_name_autocomplete', |
|
200 | - 'access callback' => TRUE, |
|
201 | - 'type' => MENU_CALLBACK, |
|
202 | - ); |
|
203 | - $items['user/%user/recoveremail/%'] = array( |
|
204 | - 'title' => t('Recover previous email'), |
|
205 | - 'description' => t('Form to revert email to previous address.'), |
|
206 | - 'page callback' => 'drupal_get_form', |
|
207 | - 'page arguments' => array('boincuser_revertemail', 3), |
|
208 | - 'access callback' => 'user_is_logged_in', |
|
209 | - 'type' => MENU_CALLBACK, |
|
210 | - ); |
|
211 | - $items['recover_email.php'] = array( |
|
212 | - 'title' => t('Recover previous email'), |
|
213 | - 'description' => t('redirect'), |
|
214 | - 'page callback' => '_boincuser_redirect_recover_email', |
|
215 | - 'access callback' => TRUE, |
|
216 | - 'type' => MENU_CALLBACK, |
|
217 | - ); |
|
218 | - return $items; |
|
184 | +$items['create_account.php'] = array( |
|
185 | +'title' => 'Create Account RPC', |
|
186 | +'description' => 'RPC for creating user accounts.', |
|
187 | +'page callback' => 'boincuser_create_account', |
|
188 | +'access callback' => TRUE, |
|
189 | +'type' => MENU_CALLBACK |
|
190 | +); |
|
191 | +$items['account_finish.php'] = array( |
|
192 | +'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
193 | +'description' => 'RPC for after a user has created an account.', |
|
194 | +'page callback' => 'boincuser_account_finish', |
|
195 | +'access callback' => TRUE, |
|
196 | +'type' => MENU_CALLBACK, |
|
197 | +); |
|
198 | +$items['boincuser/autocomplete'] = array( |
|
199 | +'page callback' => '_boincuser_user_name_autocomplete', |
|
200 | +'access callback' => TRUE, |
|
201 | +'type' => MENU_CALLBACK, |
|
202 | +); |
|
203 | +$items['user/%user/recoveremail/%'] = array( |
|
204 | +'title' => t('Recover previous email'), |
|
205 | +'description' => t('Form to revert email to previous address.'), |
|
206 | +'page callback' => 'drupal_get_form', |
|
207 | +'page arguments' => array('boincuser_revertemail', 3), |
|
208 | +'access callback' => 'user_is_logged_in', |
|
209 | +'type' => MENU_CALLBACK, |
|
210 | +); |
|
211 | +$items['recover_email.php'] = array( |
|
212 | +'title' => t('Recover previous email'), |
|
213 | +'description' => t('redirect'), |
|
214 | +'page callback' => '_boincuser_redirect_recover_email', |
|
215 | +'access callback' => TRUE, |
|
216 | +'type' => MENU_CALLBACK, |
|
217 | +); |
|
218 | +return $items; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Implementation of hook_init() |
223 | 223 | */ |
224 | 224 | function boincuser_init() { |
225 | - global $user; |
|
226 | - // Skip this check for charts, which are loaded separately |
|
227 | - // (may get duplicate or unexpected messages otherwise) |
|
228 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | - return; |
|
230 | - } |
|
225 | +global $user; |
|
226 | +// Skip this check for charts, which are loaded separately |
|
227 | +// (may get duplicate or unexpected messages otherwise) |
|
228 | +if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | +return; |
|
230 | +} |
|
231 | 231 | |
232 | - // If admin user, do some basic site functionality checks |
|
233 | - if (user_access('administer site configuration')) { |
|
234 | - // Ensure we have a configured BOINC environment |
|
235 | - boinc_get_path(); |
|
236 | - boinc_get_scheduler_tags(); |
|
237 | - } |
|
232 | +// If admin user, do some basic site functionality checks |
|
233 | +if (user_access('administer site configuration')) { |
|
234 | +// Ensure we have a configured BOINC environment |
|
235 | +boinc_get_path(); |
|
236 | +boinc_get_scheduler_tags(); |
|
237 | +} |
|
238 | 238 | |
239 | - // Check credits for the verified contributor role |
|
240 | - boincuser_check_credit_requirements(); |
|
239 | +// Check credits for the verified contributor role |
|
240 | +boincuser_check_credit_requirements(); |
|
241 | 241 | |
242 | - if (module_exists('boincteam')) { |
|
243 | - // Display any persistent team messages |
|
244 | - boincteam_show_messages(); |
|
245 | - } |
|
242 | +if (module_exists('boincteam')) { |
|
243 | +// Display any persistent team messages |
|
244 | +boincteam_show_messages(); |
|
245 | +} |
|
246 | 246 | |
247 | - // Check if user has agreed to the terms of use. If not, send the |
|
248 | - // user to the terms-of-use form. This is only makes sense if the |
|
249 | - // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | - if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
254 | - |
|
255 | - // Admins are exempt, otherwise the admin may not be able to |
|
256 | - // access the site! |
|
257 | - $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | - if (!isset($user->roles[$administrator_role])) { |
|
259 | - $path = drupal_get_path_alias($_GET['q']); |
|
260 | - |
|
261 | - // Any paths that should NOT be redirected go here. |
|
262 | - // The site will not function correctly if these are not exempt! |
|
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', |
|
270 | - ); |
|
271 | - if (module_exists('boincuser_delete')) { |
|
272 | - $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | - $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | - $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | - } |
|
247 | +// Check if user has agreed to the terms of use. If not, send the |
|
248 | +// user to the terms-of-use form. This is only makes sense if the |
|
249 | +// termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | +$existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | +$termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | +if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | +if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
254 | + |
|
255 | + // Admins are exempt, otherwise the admin may not be able to |
|
256 | + // access the site! |
|
257 | + $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | + if (!isset($user->roles[$administrator_role])) { |
|
259 | + $path = drupal_get_path_alias($_GET['q']); |
|
260 | + |
|
261 | + // Any paths that should NOT be redirected go here. |
|
262 | + // The site will not function correctly if these are not exempt! |
|
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', |
|
270 | + ); |
|
271 | + if (module_exists('boincuser_delete')) { |
|
272 | + $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | + $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | + $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | + } |
|
276 | 276 | |
277 | - // Paths added by the admin |
|
278 | - $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
|
279 | - $paths2 = array(); |
|
280 | - if (is_array($paths1)) { |
|
281 | - $paths2 = array_map('strtolower', $paths1); |
|
282 | - } |
|
277 | + // Paths added by the admin |
|
278 | + $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
|
279 | + $paths2 = array(); |
|
280 | + if (is_array($paths1)) { |
|
281 | + $paths2 = array_map('strtolower', $paths1); |
|
282 | + } |
|
283 | 283 | |
284 | - // paths to ignore |
|
285 | - $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
|
284 | + // paths to ignore |
|
285 | + $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
|
286 | 286 | |
287 | - if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
288 | - drupal_goto('user/termsofuse'); |
|
289 | - } |
|
290 | - } |
|
287 | + if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
288 | + drupal_goto('user/termsofuse'); |
|
291 | 289 | } |
292 | 290 | } |
293 | 291 | } |
292 | +} |
|
293 | +} |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Implementation of hook_user(); add custom actions to standard |
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'); |
|
303 | - |
|
304 | - require_boinc('password_compat/password'); |
|
305 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | - if ($account->uid > 1) { |
|
307 | - switch($op) { |
|
308 | - case 'load': |
|
309 | - // User loading; insert BOINC data into the user object |
|
310 | - $drupal_user = db_fetch_object(db_query(" |
|
300 | +require_boinc('boinc_db'); |
|
301 | +require_boinc('user'); |
|
302 | +require_boinc('xml'); |
|
303 | + |
|
304 | +require_boinc('password_compat/password'); |
|
305 | +// Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | +if ($account->uid > 1) { |
|
307 | +switch($op) { |
|
308 | +case 'load': |
|
309 | +// User loading; insert BOINC data into the user object |
|
310 | +$drupal_user = db_fetch_object(db_query(" |
|
311 | 311 | SELECT boinc_id, penalty_expiration |
312 | 312 | FROM {boincuser} WHERE uid = %d", |
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(" |
|
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(" |
|
319 | 319 | SELECT |
320 | 320 | name, |
321 | 321 | authenticator, |
@@ -330,30 +330,30 @@ discard block |
||
330 | 330 | email_addr_change_time |
331 | 331 | FROM {user} |
332 | 332 | WHERE id = %d", |
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) { |
|
350 | - $account->team = db_result(db_query(" |
|
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) { |
|
350 | +$account->team = db_result(db_query(" |
|
351 | 351 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
352 | - $account->boincteam_id |
|
353 | - )); |
|
354 | - } |
|
355 | - // Set post count |
|
356 | - $account->post_count = db_result(db_query(" |
|
352 | +$account->boincteam_id |
|
353 | +)); |
|
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} |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | INNER JOIN node ON comments.nid = node.nid |
366 | 366 | WHERE comments.uid = '%d' |
367 | 367 | AND node.status = 1", |
368 | - $account->uid, $account->uid |
|
369 | - )); |
|
370 | - break; |
|
368 | +$account->uid, $account->uid |
|
369 | +)); |
|
370 | +break; |
|
371 | 371 | |
372 | - case 'view': |
|
373 | - // SAMPLE: Add BOINC data to the user profile |
|
374 | - /*$account->content['summary']['boinc_id'] = array( |
|
372 | +case 'view': |
|
373 | +// SAMPLE: Add BOINC data to the user profile |
|
374 | +/*$account->content['summary']['boinc_id'] = array( |
|
375 | 375 | '#type' => 'user_profile_item', |
376 | 376 | '#title' => bts('BIONC ID'), |
377 | 377 | '#value' => $account->boincuser_id, |
@@ -385,174 +385,174 @@ discard block |
||
385 | 385 | '#attributes' => array('class' => 'boinc-data'), |
386 | 386 | '#weight' => 10 |
387 | 387 | );*/ |
388 | - break; |
|
388 | +break; |
|
389 | 389 | |
390 | - case 'validate': |
|
391 | - if (isset($edit['validation_source'])) { |
|
392 | - switch ($edit['validation_source']) { |
|
393 | - case 'user_account': |
|
394 | - // Validate data before updating user account info |
|
395 | - boincuser_account_validate($edit, $account); |
|
396 | - break; |
|
390 | +case 'validate': |
|
391 | +if (isset($edit['validation_source'])) { |
|
392 | +switch ($edit['validation_source']) { |
|
393 | +case 'user_account': |
|
394 | +// Validate data before updating user account info |
|
395 | +boincuser_account_validate($edit, $account); |
|
396 | +break; |
|
397 | 397 | |
398 | - default: |
|
398 | +default: |
|
399 | 399 | |
400 | - } |
|
401 | - // We don't want to save validation source, so remove it |
|
402 | - $edit['validation_source'] = null; |
|
403 | - } |
|
404 | - break; |
|
400 | +} |
|
401 | + // We don't want to save validation source, so remove it |
|
402 | + $edit['validation_source'] = null; |
|
403 | + } |
|
404 | + break; |
|
405 | 405 | |
406 | - case 'insert': |
|
407 | - // New user being added to the system |
|
408 | - $imported = $_SESSION['importedUser']; |
|
409 | - unset($_SESSION['importedUser']); |
|
406 | +case 'insert': |
|
407 | + // New user being added to the system |
|
408 | + $imported = $_SESSION['importedUser']; |
|
409 | + unset($_SESSION['importedUser']); |
|
410 | 410 | |
411 | - watchdog( |
|
412 | - 'boincuser', |
|
413 | - 'Creating user account for %email_addr', |
|
414 | - array('%email_addr' => $edit['mail']), |
|
415 | - WATCHDOG_NOTICE |
|
416 | - ); |
|
411 | + watchdog( |
|
412 | + 'boincuser', |
|
413 | + 'Creating user account for %email_addr', |
|
414 | + array('%email_addr' => $edit['mail']), |
|
415 | + WATCHDOG_NOTICE |
|
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 | - // set email address lower-case |
|
425 | - $lower_email_addr = strtolower($edit['mail']); |
|
424 | + // set email address lower-case |
|
425 | + $lower_email_addr = strtolower($edit['mail']); |
|
426 | 426 | |
427 | - if ($edit['boincuser_name']) { |
|
428 | - $myname = $edit['boincuser_name']; |
|
429 | - } |
|
430 | - else if ($edit['name']) { |
|
431 | - $myname = $edit['name']; |
|
432 | - } |
|
433 | - else { |
|
434 | - $myname = 'noname'; |
|
435 | - } |
|
427 | + if ($edit['boincuser_name']) { |
|
428 | + $myname = $edit['boincuser_name']; |
|
429 | + } |
|
430 | + else if ($edit['name']) { |
|
431 | + $myname = $edit['name']; |
|
432 | + } |
|
433 | + else { |
|
434 | + $myname = 'noname'; |
|
435 | + } |
|
436 | 436 | |
437 | - $user_params = array( |
|
438 | - 'email_addr' => $lower_email_addr, |
|
439 | - 'name' => $myname, |
|
440 | - ); |
|
437 | + $user_params = array( |
|
438 | + 'email_addr' => $lower_email_addr, |
|
439 | + 'name' => $myname, |
|
440 | + ); |
|
441 | 441 | |
442 | - // If the 'pass' variable is already a hash, then don't hash it again. |
|
443 | - if ($edit['boinchash_flag']) { |
|
444 | - $user_params['passwd_hash'] = $edit['pass']; |
|
445 | - } |
|
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); |
|
451 | - } |
|
442 | + // If the 'pass' variable is already a hash, then don't hash it again. |
|
443 | + if ($edit['boinchash_flag']) { |
|
444 | + $user_params['passwd_hash'] = $edit['pass']; |
|
445 | + } |
|
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); |
|
451 | + } |
|
452 | 452 | |
453 | - $boinc_user = boincuser_register_make_user($user_params); |
|
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; |
|
458 | - } |
|
453 | + $boinc_user = boincuser_register_make_user($user_params); |
|
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; |
|
458 | + } |
|
459 | 459 | |
460 | - // Add user to community role by default (not banned) |
|
461 | - $unrestricted_role = array_search('community member', user_roles(true)); |
|
462 | - $edit['roles'] = array( |
|
463 | - $unrestricted_role => '' |
|
464 | - ); |
|
460 | + // Add user to community role by default (not banned) |
|
461 | + $unrestricted_role = array_search('community member', user_roles(true)); |
|
462 | + $edit['roles'] = array( |
|
463 | + $unrestricted_role => '' |
|
464 | + ); |
|
465 | 465 | |
466 | - // Disable show_hosts flag, set to TRUE by default |
|
467 | - db_set_active('boinc_rw'); |
|
468 | - db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
469 | - db_set_active('default'); |
|
466 | + // Disable show_hosts flag, set to TRUE by default |
|
467 | + db_set_active('boinc_rw'); |
|
468 | + db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
469 | + db_set_active('default'); |
|
470 | 470 | |
471 | - // Cross reference Drupal account with BOINC |
|
472 | - $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
473 | - if (!$reference) { |
|
474 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | - return; |
|
476 | - } |
|
471 | + // Cross reference Drupal account with BOINC |
|
472 | + $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
473 | + if (!$reference) { |
|
474 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | + return; |
|
476 | + } |
|
477 | 477 | |
478 | - // if terms of use exist, the user must agree. |
|
479 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
480 | - if (!empty($termsofuse)) { |
|
481 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
482 | - } |
|
478 | + // if terms of use exist, the user must agree. |
|
479 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
480 | + if (!empty($termsofuse)) { |
|
481 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
482 | + } |
|
483 | 483 | |
484 | - // Don't save custom fields to the Drupal user object |
|
485 | - $edit['boincuser_name'] = null; |
|
486 | - $edit['boinchash_flag'] = null; |
|
487 | - // Set email address to lower case in Drupal users table |
|
488 | - if ($account) { |
|
489 | - user_save($account, array('mail' => $lower_email_addr)); |
|
490 | - } |
|
491 | - } |
|
492 | - break; |
|
484 | + // Don't save custom fields to the Drupal user object |
|
485 | + $edit['boincuser_name'] = null; |
|
486 | + $edit['boinchash_flag'] = null; |
|
487 | + // Set email address to lower case in Drupal users table |
|
488 | + if ($account) { |
|
489 | + user_save($account, array('mail' => $lower_email_addr)); |
|
490 | + } |
|
491 | + } |
|
492 | + break; |
|
493 | 493 | |
494 | - case 'update': |
|
495 | - if (isset($edit['update_source'])) { |
|
496 | - require_boinc('boinc_db'); |
|
497 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
498 | - switch ($edit['update_source']) { |
|
499 | - case 'user_account': |
|
500 | - // Ensure that BOINC data is altered |
|
501 | - |
|
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) { |
|
505 | - // set email address to lower-case |
|
506 | - $lower_email_addr = strtolower($edit['mail']); |
|
507 | - |
|
508 | - // Set password hash appropriately |
|
509 | - $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
510 | - $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
|
511 | - // Algorithm for changing email and/or password |
|
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"; |
|
517 | - } |
|
518 | - else { |
|
519 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
520 | - } |
|
521 | - |
|
522 | - // Update user account information |
|
523 | - $result = $boinc_user->update($querypart); |
|
524 | - |
|
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')); |
|
529 | - } |
|
530 | - |
|
531 | - // Change email to edit to lower-case version, this sets |
|
532 | - // email in Drupal database to the lower-case email |
|
533 | - // address. |
|
534 | - $edit['mail'] = strtolower($lower_email_addr); |
|
535 | - } |
|
536 | - |
|
537 | - // Change boinc username |
|
538 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
539 | - $boincuser_name = $edit['boincuser_name']; |
|
540 | - $result = $boinc_user->update( |
|
541 | - "name='{$boincuser_name}'" |
|
542 | - ); |
|
543 | - } |
|
544 | - |
|
545 | - break; |
|
546 | - case 'user_profile': |
|
547 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
548 | - $boincuser_name = $edit['boincuser_name']; |
|
549 | - $result = $boinc_user->update( |
|
550 | - "name='{$boincuser_name}'" |
|
551 | - ); |
|
552 | - } |
|
553 | - break; |
|
554 | - default: |
|
555 | - } |
|
494 | +case 'update': |
|
495 | + if (isset($edit['update_source'])) { |
|
496 | + require_boinc('boinc_db'); |
|
497 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
498 | + switch ($edit['update_source']) { |
|
499 | + case 'user_account': |
|
500 | + // Ensure that BOINC data is altered |
|
501 | + |
|
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) { |
|
505 | + // set email address to lower-case |
|
506 | + $lower_email_addr = strtolower($edit['mail']); |
|
507 | + |
|
508 | + // Set password hash appropriately |
|
509 | + $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
510 | + $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
|
511 | + // Algorithm for changing email and/or password |
|
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"; |
|
517 | + } |
|
518 | + else { |
|
519 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
520 | + } |
|
521 | + |
|
522 | + // Update user account information |
|
523 | + $result = $boinc_user->update($querypart); |
|
524 | + |
|
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')); |
|
529 | + } |
|
530 | + |
|
531 | + // Change email to edit to lower-case version, this sets |
|
532 | + // email in Drupal database to the lower-case email |
|
533 | + // address. |
|
534 | + $edit['mail'] = strtolower($lower_email_addr); |
|
535 | + } |
|
536 | + |
|
537 | + // Change boinc username |
|
538 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
539 | + $boincuser_name = $edit['boincuser_name']; |
|
540 | + $result = $boinc_user->update( |
|
541 | + "name='{$boincuser_name}'" |
|
542 | + ); |
|
543 | + } |
|
544 | + |
|
545 | + break; |
|
546 | + case 'user_profile': |
|
547 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
548 | + $boincuser_name = $edit['boincuser_name']; |
|
549 | + $result = $boinc_user->update( |
|
550 | + "name='{$boincuser_name}'" |
|
551 | + ); |
|
552 | + } |
|
553 | + break; |
|
554 | + default: |
|
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; |
@@ -560,17 +560,17 @@ discard block |
||
560 | 560 | } |
561 | 561 | break; |
562 | 562 | |
563 | - case 'login': |
|
564 | - // Function is forward compatible to Drupal 7 |
|
565 | - boincuser_user_login($edit, $account); |
|
566 | - break; |
|
563 | +case 'login': |
|
564 | + // Function is forward compatible to Drupal 7 |
|
565 | + boincuser_user_login($edit, $account); |
|
566 | + break; |
|
567 | 567 | |
568 | - case 'delete': |
|
569 | - // Function is forward compatible to Drupal 7 |
|
570 | - boincuser_user_delete($account); |
|
571 | - break; |
|
568 | +case 'delete': |
|
569 | + // Function is forward compatible to Drupal 7 |
|
570 | + boincuser_user_delete($account); |
|
571 | + break; |
|
572 | 572 | |
573 | - default: |
|
573 | +default: |
|
574 | 574 | |
575 | 575 | } |
576 | 576 | } |