t('Saved QBF queries.'), 'fields' => array ( 'qid' => array ( 'description' => t('Query ID'), 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'uid' => array ( 'description' => t('User ID'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'type' => array ( 'description' => t('Query type'), 'type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => '', ), 'name' => array ( 'description' => t('Query name'), 'type' => 'varchar', 'length' => 60, 'not null' => TRUE, 'default' => '', ), 'query' => array ( 'description' => t('Query array'), 'type' => 'text', 'not null' => TRUE, ), 'created' => array ( 'description' => 'Query creation timestamp.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), 'updated' => array ( 'description' => 'Query update timestamp', 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), ), 'primary key' => array('qid'), 'indexes' => array ( 'query_updated' => array('updated'), 'query_created' => array('created'), 'query_per_user' => array('uid', 'type'), ), 'unique keys' => array(), ); return $schema; } /** * Implement hook_install(). * * - Install schema * - Assign initial settings * * @ingroup hooks * @return void */ function qbf_install() { drupal_install_schema('qbf'); // Initialize settings $ar_const = get_defined_constants(); $ar_const = array_keys($ar_const); $count = 0; $init_count = 0; foreach ($ar_const as $name) { if (strpos($name, 'QBF_VAR_') === 0) { $count++; $default = 'QBF_DEF_'. drupal_substr($name, drupal_strlen('QBF_VAR_')); if (defined($default)) { variable_set(constant($name), constant($default)); $init_count++; } } } drupal_set_message(t('Initialized QBF module settings (@initCount/@count parameters). You can complete setup.', array ( '@initCount' => $init_count, '@count' => $count, '!link' => url(QBF_PATH_SETTINGS), ) )); } /** * Implement hook_uninstall(). * * - Uninstall schema * - Remove nodes of all the types maintained by the module * - none * - Remove module settings * - none * - Do NOT remove module schema version from {system} * * @ingroup hooks * @return void */ function qbf_uninstall() { drupal_uninstall_schema('qbf'); // Remove settings $ar_const = get_defined_constants(); $ar_const = array_keys($ar_const); foreach ($ar_const as $name) { if (strpos($name, 'QBF_VAR_') === 0) { variable_del($name); } } drupal_set_message(t('Removed QBF module settings.')); } /** * Implement hook_update_N(). * * For 5.x, just define a proper initial schema version. * * @ingroup hooks * @return array */ function qbf_update_5000() { return array(); } /** * Implement hook_update_N(). * * 5000 to 6000 * - new "type" column * - "name" varchar(40)->varchar(60) * - "qid" int->serial * * @ingroup hooks * @return array */ function qbf_update_6000() { $ret = array(); variable_set(QBF_VAR_MAX_QUERIES, variable_get('job_max_queries', QBF_DEF_MAX_QUERIES)); variable_set(QBF_VAR_PROFILE_CATEGORY, variable_get('job_profile_category', QBF_DEF_PROFILE_CATEGORY)); variable_set(QBF_VAR_QUERY_MODE, variable_get('job_query_mode', Qbf_Query_Mode::CONTAINS)); drupal_set_message('Migrated QBF-related settings from Job 5.x to QBF 6.x settings'); db_drop_primary_key($ret, QBF_TABLE_NAME); db_drop_index($ret, QBF_TABLE_NAME, 'query_updated'); db_drop_index($ret, QBF_TABLE_NAME, 'query_created'); db_drop_index($ret, QBF_TABLE_NAME, 'query_per_user'); db_add_field($ret, QBF_TABLE_NAME, 'type', array ( 'description' => t('Query type'), 'type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => '', 'initial' => 'job_form', // Version 5 was bound to the OSInet job search )); db_change_field($ret, QBF_TABLE_NAME, 'name', 'name', array ( 'type' => 'varchar', 'length' => 60, // was 40 ) ); db_change_field($ret, QBF_TABLE_NAME, 'qid', 'qid', array ( 'type' => 'serial', ), array ( 'primary key' => array('qid'), 'indexes' => array ( 'query_updated' => array('updated'), 'query_created' => array('created'), 'query_per_user' => array('uid', 'type'), ), 'unique keys' => array(), ) ); return $ret; }