From b57b5aed149a492610d9bbdb563fc112eaf03203 Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Thu, 18 Jun 2015 09:58:11 -0400 Subject: [PATCH] Added wrapper for am_get_info RPC (DBOINCP-184) --- .../boinc/modules/boinccore/boinccore.module | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drupal/sites/default/boinc/modules/boinccore/boinccore.module b/drupal/sites/default/boinc/modules/boinccore/boinccore.module index 730f182534..aedee2ecd5 100644 --- a/drupal/sites/default/boinc/modules/boinccore/boinccore.module +++ b/drupal/sites/default/boinc/modules/boinccore/boinccore.module @@ -71,6 +71,13 @@ function boinccore_menu() { 'access callback' => TRUE, 'type' => MENU_CALLBACK ); + $items['am_get_info.php'] = array( + 'title' => 'Account manager get info RPC', + 'description' => 'RPC for getting assorted details of a user account.', + 'page callback' => 'boinccore_am_get_info', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK + ); return $items; } @@ -442,6 +449,33 @@ function boinccore_lookup_account() { include_boinc('user/lookup_account.php'); } +/** + * Page callback for the account manager get info RPC (am_get_info.php). + * Get assorted details for a given account + */ +function boinccore_am_get_info() { + // Remove q from the GET request or BOINC will panic + unset($_GET['q']); + // Capture the XML output of the RPC so we can override things + ob_start(); + include_boinc('user/am_get_info.php'); + $xml = ob_get_clean(); + $xml = load_configuration($xml); + // See if the account has an approved profile in Drupal + $content_profile = content_profile_load('profile', $account->uid); + $profile_is_approved = ($content_profile->status AND !$content_profile->moderate); + $country = check_plain($content_profile->field_country[0]['value']); + $website = ''; + if ($profile_is_approved) { + $website = check_plain($content_profile->field_url[0]['value']); + } + // Override BOINC values with Drupal values as needed + $xml['am_get_info_reply']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0; + $xml['am_get_info_reply']['country']['@value'] = $country; + $xml['am_get_info_reply']['url']['@value'] = $website; + print save_configuration($xml); +} + /** * Controller for handling direct linking to paginated content. * Because pagination settings are user configurable, it is impossible to know