Commit 51d8bc9a authored by Penny Leach's avatar Penny Leach
Browse files

added weimportcontent setting to auth/xmlrpc

along with all the other settings
parent 9a98b044
......@@ -158,6 +158,7 @@ function find_remote_user($username, $wwwroot) {
try {
$user = new User;
$user->find_by_instanceid_username($authinstance->id, $username, true);
$user->xmlrpccurrentauth = $authinstance->id;
$candidates[$user->id] = $user;
} catch (Exception $e) {
// we don't care
......@@ -274,24 +275,32 @@ function send_content_intent($username) {
throw new ImportException("Could not find user $username for $REMOTEWWWROOT");
}
// @todo penny check for zip libraries here
if (!is_executable(get_config('pathtounzip'))) {
throw new ImportException("Cannot find unzip executable");
}
// check whatever config values we have to check
// generate a token, insert it into the queue table
$usequeue = (int)!(Importer::import_immediately_allowed());
safe_require('auth', 'xmlrpc');
if (!$authinstance = new AuthXmlrpc($user->xmlrpccurrentauth)) {
throw new ImportException('XMLRPC auth is misconfigured');
}
if (!$authinstance->weimportcontent) {
throw new ImportException('Importing content is disabled');
}
// generate a token, insert it into the queue table
$queue = new StdClass;
$queue->token = generate_token();
$queue->host = $REMOTEWWWROOT;
$queue->usr = $user->id;
$queue->queue = $usequeue;
$queue->queue = (int)!(Importer::import_immediately_allowed());
$queue->ready = 0;
$queue->expirytime = db_format_timestamp(time()+(60*60*24));
insert_record('import_queue', $queue);
return array(
'sendtype' => (($usequeue) ? 'queue' : 'immediate'),
'sendtype' => (($queue->queue) ? 'queue' : 'immediate'),
'token' => $queue->token,
);
}
......
......@@ -88,7 +88,8 @@ class User {
'staffinstitutions' => array(),
'parentuser' => null,
'loginanyway' => false,
'sesskey' => ''
'sesskey' => '',
'xmlrpccurrentauth' => null, /* used temporarily during xmlrpc pings (we don't want it written do the database!) */
);
$this->attributes = array();
......
<h3>We import content</h3>
<p>Not all network-enabled applications support this, but if they do, this will allow users of the remote site to import content here.</p>
<p>It depends on 'They SSO in' and it's sensible to also have 'We auto-create users' set as well</p>
......@@ -62,6 +62,7 @@ class AuthXmlrpc extends Auth {
$this->config['theyautocreateusers'] = 0;
$this->config['wessoout'] = 0;
$this->config['theyssoin'] = 0;
$this->config['weimportcontent'] = 0;
$this->config['parent'] = null;
$this->file = fopen('/tmp/out.txt', 'w');
if (!empty($id)) {
......@@ -547,6 +548,7 @@ class PluginAuthXmlrpc extends PluginAuth {
'theyautocreateusers' => 0,
'wessoout' => 0,
'theyssoin' => 0,
'weimportcontent' => 0,
'parent' => null
);
......@@ -794,7 +796,14 @@ class PluginAuthXmlrpc extends PluginAuth {
'defaultvalue' => self::$default_config['theyautocreateusers'],
'help' => true
);
$elements['weimportcontent'] = array(
'type' => 'checkbox',
'title' => get_string('weimportcontent', 'auth'),
'defaultvalue' => self::$default_config['weimportcontent'],
'help' => true,
);
return array(
'elements' => $elements,
'renderer' => 'table'
......@@ -905,7 +914,8 @@ class PluginAuthXmlrpc extends PluginAuth {
'theyautocreateusers' => $values['theyautocreateusers'],
'parent' => $values['parent'],
'wessoout' => $values['wessoout'],
'theyssoin' => $values['theyssoin']
'theyssoin' => $values['theyssoin'],
'weimportcontent' => $values['weimportcontent'],
);
foreach(self::$default_config as $field => $value) {
......
......@@ -52,6 +52,7 @@ $string['weautocreateusers'] = 'We auto-create users';
$string['theyautocreateusers'] = 'They auto-create users';
$string['parent'] = 'Parent authority';
$string['wessoout'] = 'We SSO out';
$string['weimportcontent'] = 'We import content (some applications only)';
$string['theyssoin'] = 'They SSO in';
$string['application'] = 'Application';
$string['cantretrievekey'] = 'An error occurred while retrieving the public key from the remote server.<br>Please ensure that the Application and WWW Root fields are correct, and that networking is enabled on the remote host.';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment