Remove dependencies (Hasse's patch)
[mkdru-moved-to-drupal.org.git] / mkdru.install
index a2d828a..fa08343 100644 (file)
@@ -6,54 +6,30 @@
  */
 
 /**
-* Implementation of hook_schema().
+* Implements hook_schema().
 */
 function mkdru_schema() {
   $schema['mkdru'] = array(
-    'description' => t('Stores settings for mkdru nodes.'),
-    'fields' => array (
+    'description' => 'Stores settings for mkdru nodes.',
+    'fields' => array(
       'nid' => array(
-        'description' => t('The primary identifier for a node.'),
+        'description' => 'The primary identifier for a node.',
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
         'default' => 0
        ),
       'vid' => array(
-        'description' => t('The current {node_revisions}.vid version identifier.'),
+        'description' => 'The current {node_revisions}.vid version identifier.',
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
         'default' => 0
       ),
-      'pz2_path' => array(
+      'settings' => array(
         'type' => 'text',
         'not null' => TRUE,
-        'description' => t('Path to Pazpar2 or Service Proxy.')
-      ),
-      'use_sessions' => array(
-        'description' => t('Session handling toggle.'),
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'source_max' => array(
-        'description' => t('Number of sources to display'),
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'author_max' => array(
-        'description' => t('Number of authors to display'),
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'subject_max' => array(
-        'description' => t('Number of subjects to display'),
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
+        'description' => 'Metasearch settings',
       ),
     ),
     'primary key' => array('nid', 'vid'),
@@ -64,20 +40,47 @@ function mkdru_schema() {
 }
 
 /**
-* Implementation of hook_install().
+* Implements hook_install().
 */
 function mkdru_install() {
   // Disable comments by default
-  variable_set('comment_mkdru', COMMENT_NODE_DISABLED);
-  // Create table.
-  drupal_install_schema('mkdru');
+  variable_set('comment_mkdru', defined(COMMENT_NODE_HIDDEN) ? COMMENT_NODE_HIDDEN : NULL);
+
+
+  // Default settings
+  $settings['title'] = "";
+  $settings['pz2_path'] = "/pazpar2/search.pz2";
+  $settings['use_sessions'] = 1;
+  $settings['sp']['user'] = "";
+  $settings['sp']['pass'] = "";
+  $settings['facets']['source']['displayName'] = "Source";
+  $settings['facets']['source']['pz2Name'] = "xtargets";
+  $settings['facets']['source']['limiter'] = NULL;
+  $settings['facets']['source']['multiLimit'] = NULL;
+  $settings['facets']['source']['max'] = 10;
+  $settings['facets']['source']['orderWeight'] = 1;
+  $settings['facets']['subject']['displayName'] = "Subject";
+  $settings['facets']['subject']['pz2Name'] = "subject";
+  $settings['facets']['subject']['limiter'] = "su";
+  $settings['facets']['subject']['multiLimit'] = TRUE;
+  $settings['facets']['subject']['max'] = 10;
+  $settings['facets']['subject']['orderWeight'] = 2;
+  $settings['facets']['author']['displayName'] = "Author";
+  $settings['facets']['author']['pz2Name'] = "author";
+  $settings['facets']['author']['limiter'] = "au";
+  $settings['facets']['author']['multiLimit'] = FALSE;
+  $settings['facets']['author']['max'] = 10;
+  $settings['facets']['author']['orderWeight'] = 3;
+  variable_set('mkdru_defaults', $settings);
 }
 
 /**
-* Implementation of hook_uninstall().
+* Implements hook_uninstall().
 */
 function mkdru_uninstall() {
-  // Drop table.
-  drupal_uninstall_schema('mkdru');
+  // Delete variables
+  variable_del('pz2_js_path');
+  variable_del('mkdru_defaults');
+  // Clear block visibility
+  db_delete('block_node_type')->condition('module', 'mkdru')->execute();
 }
-?>