95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
/** \file include\db_help.php
|
|
* \brief DI webinterface database help functions
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version 1.0
|
|
* \date 17-10-2008
|
|
*
|
|
* This file contains the help database functions. This file is always included.
|
|
*/
|
|
|
|
/**
|
|
* Fetch help info
|
|
*
|
|
* Inputs:
|
|
* - help_menu: Specific help menu
|
|
* - i18n: Internationalisation
|
|
*
|
|
* Return: Array containing help info
|
|
*/
|
|
function db_fetch_help($help_menu = "", $i18n = "") {
|
|
// Initial return value
|
|
$result = "";
|
|
|
|
// Fetch help info
|
|
$query = "SELECT * FROM helptekst";
|
|
|
|
// Specific menu
|
|
if (strlen($help_menu)) {
|
|
$query .= " WHERE menu='" . $help_menu . "'";
|
|
}
|
|
|
|
// Specific i18n
|
|
if (strlen($i18n)) {
|
|
if (!strlen($help_menu)) {
|
|
$query .= " WHERE";
|
|
}
|
|
else {
|
|
$query .= " AND";
|
|
}
|
|
$query .= " i18n='" . $i18n . "'";
|
|
}
|
|
|
|
// Execute query
|
|
$help_info = db_fetch_data($query);
|
|
|
|
// Parse into result
|
|
if (!empty($help_info)) {
|
|
$result = $help_info;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
/**
|
|
* Store new help info
|
|
*
|
|
* Inputs:
|
|
* - help_menu: Specific help menu
|
|
* - i18n: Internationalisation
|
|
* - text: New help text
|
|
*
|
|
* Return: 1 (OK)/ 0(Error)
|
|
*/
|
|
function db_store_help($help_menu, $i18n, $text) {
|
|
// Initial return value
|
|
$result = 0;
|
|
|
|
// Start transaction
|
|
db_start_transaction();
|
|
|
|
// Delete old info
|
|
$query = "DELETE FROM helptekst WHERE menu='" . $help_menu . "' and i18n='" . $i18n . "'";
|
|
db_store_data($query);
|
|
|
|
// Commit transaction
|
|
if (db_commit_transaction()) {
|
|
// Parse result
|
|
$result = 1;
|
|
}
|
|
|
|
// Query storing new help info
|
|
$query = "INSERT INTO helptekst (menu,i18n,tekst) VALUES (";
|
|
$query .= "'" . addslashes($help_menu) . "',";
|
|
$query .= "'" . addslashes($i18n) . "',";
|
|
$query .= "'" . addslashes($text) . "')";
|
|
|
|
if (db_store_data($query)) {
|
|
// Result OK
|
|
$result = 1;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
?>
|