function tripal_core_init
2.x tripal_core.module | tripal_core_init() |
3.x tripal_core.module | tripal_core_init() |
1.x tripal_core.module | tripal_core_init() |
Implements hook_init(). Used to set the search_path, create default content and set default variables.
Related topics
File
- tripal_core/
tripal_core.module, line 55 - The Tripal Core module
Code
function tripal_core_init() {
global $base_url;
// create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
// only if the chado database is present.
if ($GLOBALS["chado_is_installed"]) {
// if the Tripal cv is missing then add
$results = chado_query("SELECT * FROM {cv} WHERE name = 'tripal'");
$tripal_cv = $results->fetchObject();
if (!$tripal_cv) {
$results = chado_query(
"INSERT INTO {cv} (name,definition) " .
"VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')"
);
}
// if the Tripal db is missing then add it
$results = chado_query("SELECT * FROM {db} WHERE name = 'tripal'");
$tripal_db = $results->fetchObject();
if (!$tripal_db) {
$results = chado_query(
"INSERT INTO {db} (name,description) " .
"VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')"
);
}
}
// add some variables for all javasript to use for building URLs
$clean_urls = variable_get('clean_url', 0);
drupal_add_js(
" var baseurl = '$base_url';
var isClean = $clean_urls;",
'inline', 'header');
// make sure the date time settings are the way Tripal will insert them
// otherwise PostgreSQL version that may have a different datestyle setting
// will fail when inserting or updating a date column in a table.
db_query("SET DATESTYLE TO :style", array(':style' => 'MDY'));
// If we want AHAH elements on the node forms (e.g. chado_pub form) then we need to include
// the node.pages file. Otherwise this error message is given:
//
// warning: call_user_func_array() expects parameter 1 to be a valid callback,
// function 'node_form' not found or invalid function name
// in /var/www/includes/form.inc on line 382.
module_load_include('inc', 'node', 'node.pages');
}