View source
<?php
function account_sync_menu() {
$items = array();
$items['admin/user/account_sync'] = array(
'title' => 'Account sync',
'description' => 'Setup accounts to sync across multiple drupal sites.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'account_sync_settings',
),
'access arguments' => array(
'administer account sync',
),
'file' => 'account_sync.admin.inc',
'type' => NORMAL_MENU_ITEM,
);
$items['admin/user/account_sync/global'] = array(
'title' => 'Global settings',
'description' => 'Setup accounts to sync across multiple drupal sites.',
'access arguments' => array(
'administer account sync',
),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/user/account_sync/sender'] = array(
'title' => 'Sender settings',
'description' => 'Settings for sending the account data to a remote server',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'account_sync_sender_settings',
),
'access arguments' => array(
'administer account sync',
),
'file' => 'account_sync.admin.inc',
'weight' => 1,
'type' => MENU_LOCAL_TASK,
);
$items['admin/user/account_sync/receiver'] = array(
'title' => 'Receiver settings',
'description' => 'Settings for receiving the account data from a remote server',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'account_sync_receiver_settings',
),
'access arguments' => array(
'administer account sync',
),
'file' => 'account_sync.admin.inc',
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
function account_sync_perm() {
return array(
'administer account sync',
'sync account',
);
}
function account_sync_xmlrpc() {
module_load_include('inc', 'account_sync', 'account_sync.receiver');
return array(
array(
'account_sync.updateUser',
'account_sync_update_user',
array(
'struct',
'string',
'string',
'struct',
'struct',
'string',
'struct',
),
t('Update the given user account'),
),
);
}
function account_sync_user($op, &$edit, &$account, $category = NULL) {
module_load_include('inc', 'account_sync', 'account_sync.sender');
return account_sync_send_update($op, &$edit, &$account, $category);
}
function account_sync_servers($account) {
$servers = array();
$all_servers = explode("\n", variable_get('account_sync_servers', ''));
$all_servers = array_filter($all_servers);
foreach ($all_servers as $server) {
$results = module_invoke_all('account_sync_servers', $server, $account);
if (!in_array(FALSE, $results)) {
$servers[] = $server;
}
}
return $servers;
}
function account_sync_allowed_roles() {
$result = db_query("SELECT r.name, p.perm FROM {permission} p LEFT JOIN {role} r ON r.rid = p.rid AND r.rid <> %d", DRUPAL_ANONYMOUS_RID);
$roles = array();
while ($row = db_fetch_object($result)) {
$perms = explode(', ', $row->perm);
if (in_array('sync account', $perms)) {
$roles[$row->rid] = $row->name;
}
}
return empty($roles) ? FALSE : $roles;
}
function _account_sync_get_profile_categories() {
$categories = array();
if (module_exists('profile')) {
$result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
while ($category = db_fetch_object($result)) {
$categories[$category->category] = $category->category;
}
}
return $categories;
}