function weathermap_setup_table() { global $database_default; // include_once $config["library_path"] . DIRECTORY_SEPARATOR . "database.php"; $dbversion = read_config_option("weathermap_db_version"); $myversioninfo = plugin_weathermap_version(); $myversion = $myversioninfo['version']; cacti_log("WM setup_table {$myversion} vs {$dbversion}\n", true, "WEATHERMAP"); // only bother with all this if it's a new install, a new version, or we're in a development version // - saves a handful of db hits per request! if (strstr($myversion, "dev") === false && $dbversion != "" && $dbversion == $myversion) { return; } cacti_log("WM setup_table Creating Tables\n", true, "WEATHERMAP"); $tables = weathermap_get_table_list(); $sql = array(); if (!in_array('weathermap_maps', $tables)) { $sql = weathermap_setup_maps_table($sql); } else { $sql = weathermap_update_maps_table($sql); } if (!in_array('weathermap_auth', $tables)) { $sql = weathermap_setup_auth_table($sql); } if (!in_array('weathermap_groups', $tables)) { $sql = weathermap_setup_groups_table($sql); } if (!in_array('weathermap_settings', $tables)) { $sql = weathermap_setup_settings_table($sql); } if (!in_array('weathermap_data', $tables)) { $sql = weathermap_setup_data_table($sql); } else { $sql = weathermap_update_data_table($sql); } $sql[] = "update weathermap_maps set sortorder=id where sortorder is null;"; $sql[] = "update weathermap_maps set filehash=LEFT(MD5(concat(id,configfile,rand())),20) where filehash = '';"; // create the settings entries, if necessary $sql = weathermap_setup_settings($sql, $myversion); if (!empty($sql)) { foreach ($sql as $s) { db_execute($s); } } }
function weathermap_version() { return plugin_weathermap_version(); }