query:null,
recid:null
},
- state: {}
+ state: {},
+ realm: ''
};
mkdru.pz2 = new pz2( { "onshow": mkdru.pz2Show,
"showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way
- "pazpar2path": mkdru.pazpar2path,
+ "pazpar2path": mkdru.pazpar2Path,
"oninit": mkdru.pz2Init,
"onstat": mkdru.pz2Status,
"onterm": mkdru.pz2Term,
if (typeof(Drupal.settings.mkdru.query) !== "undefined") {
mkdru.state.query = Drupal.settings.mkdru.query
}
-
+ //not running against SP? init, otherwise authenticate
if (mkdru.useSessions) {
mkdru.pz2.init();
+ } else {
+ //runnin against SP
+ var user = Drupal.settings.mkdru.sp_user;
+ var pass = Drupal.settings.mkdru.sp_pass;
+ var params = {};
+ params['command'] = 'auth';
+ if (user && pass) {
+ params['action'] = 'login';
+ params['username'] = user;
+ params['password'] = pass;
+ } else {
+ params['action'] = 'ipauth';
+ }
+ var authReq = new pzHttpRequest(mkdru.pazpar2Path,
+ function (err) {
+ alert("Authentication against metasearch gateway failed: " +err);
+ }
+ );
+ authReq.get(params,
+ function (data) {
+ var s = data.getElementsByTagName('status');
+ if (s.length && Element_getTextContent(s[0]) == "OK") {
+ mkdru.realm = data.getElementsByTagName('realm');
+ mkdru.pz2Init();
+ } else {
+ alert("Malformed response when authenticating against the metasearch"
+ + " gateway");
+ }
+ }
+ );
}
- else if (mkdru.state.recid) {
+
+ //I'm not sure how this can work, it assumes the search is in a proper state?
+ if (mkdru.state.recid) {
mkdru.pz2.record(mkdru.state.recid);
}
+ //mkdru.onInit deals with this in a more proper way
else if (mkdru.state.query) {
mkdru.search();
}
'unsigned' => TRUE,
'not null' => TRUE,
),
+ 'sp_user' => array(
+ 'type' => 'text',
+ 'not null' => FALSE,
+ 'description' => t('Service Proxy username')
+ ),
+ 'sp_pass' => array(
+ 'type' => 'text',
+ 'not null' => FALSE,
+ 'description' => t('Service Proxy password')
+ ),
),
'primary key' => array('nid', 'vid'),
'unique keys' => array('vid' => array('vid')),
// Delete variables
variable_del('pz2_js_path');
}
+
+function mkdru_update_6100() {
+ $ret = array();
+ db_add_field($ret, 'mkdru', 'sp_user', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE, 'default' => '') );
+ db_add_field($ret, 'mkdru', 'sp_pass', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE, 'default' => '') );
+ return $ret;
+}
'#required' => TRUE,
'#default_value' => isset($node->mkdru->pz2_path) ? $node->mkdru->pz2_path : '/pazpar2/search.pz2',
);
+ $form['search_settings']['sp_user'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Service Proxy username (optional)'),
+ '#description' => t('Service-Proxy username'),
+ '#required' => FALSE,
+ '#default_value' => isset($node->mkdru->sp_user) ?
+ $node->mkdru->sp_user : '',
+ );
+ $form['search_settings']['sp_pass'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Service Proxy password (optional)'),
+ '#description' => t('Service-Proxy password'),
+ '#required' => FALSE,
+ '#default_value' => isset($node->mkdru->sp_pass) ?
+ $node->mkdru->sp_pass : '',
+ );
$form['search_settings']['use_sessions'] = array(
'#type' => 'checkbox',
'#title' => t('Session handling'),
* Implementation of hook_insert().
*/
function mkdru_insert($node) {
- db_query("INSERT INTO {mkdru} (nid, vid, pz2_path, use_sessions, source_max, author_max, subject_max) VALUES (%d, %d, '%s', %d, %d, %d, %d)",
- $node->nid, $node->vid, $node->pz2_path, $node->use_sessions, $node->source_max, $node->author_max, $node->subject_max);
+ db_query("INSERT INTO {mkdru} (nid, vid, pz2_path, use_sessions, source_max, author_max, subject_max, sp_user, sp_pass) ".
+ "VALUES (%d, %d, '%s', %d, %d, %d, %d, '%s', '%s')",
+ $node->nid, $node->vid, $node->pz2_path, $node->use_sessions, $node->source_max, $node->author_max, $node->subject_max, $node->sp_user, $node->sp_pass);
}
/**
mkdru_insert($node);
}
else {
- db_query("UPDATE {mkdru} SET pz2_path = '%s', use_sessions = %d, source_max = %d, author_max = %d, subject_max = %d WHERE vid = %d", $node->pz2_path, $node->use_sessions, $node->source_max, $node->author_max, $node->subject_max, $node->vid);
+ db_query("UPDATE {mkdru} SET pz2_path = '%s', use_sessions = %d, source_max = %d, author_max = %d, subject_max = %d, sp_user = '%s', sp_pass = '%s' WHERE vid = %d", $node->pz2_path, $node->use_sessions, $node->source_max, $node->author_max, $node->subject_max, $node->vid);
}
}