Added wrapper for am_get_info RPC

(DBOINCP-184)
This commit is contained in:
Tristan Olive 2015-06-18 09:58:11 -04:00
parent efb10a49cc
commit b57b5aed14
1 changed files with 34 additions and 0 deletions

View File

@ -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