Commit 0cf22e59 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Reimplement handling of configuration data

parent 944ede83
......@@ -4,8 +4,6 @@ if (!defined('W2P_BASE_DIR')) {
}
include_once 'helpdesk.functions.php';
/* This file will write a php config file to be included during execution of
* all helpdesk files which require the configuration options. */
// Deny all but system admins
if (!canView('system')) {
......@@ -15,7 +13,7 @@ if (!canView('system')) {
@include_once( "./functions/admin_func.php" );
$HELPDESK_CONFIG = array();
$HELPDESK_CONFIG = loadConfiguration();
$HELPDESK_CONFIG = loadConfig();
// get a list of permitted companies
$company = new CCompany();
......@@ -232,7 +230,7 @@ $config_options = array(
//if this is a submitted page, overwrite the config file.
if(w2PgetParam( $_POST, "Save", '' )!=''){
$q = new w2p_Database_Query;
$q = new w2p_Database_Query();
if (!$q) {
$AppUI->setMsg($AppUI->_('Configuration table not accessible.'), UI_MSG_ERROR );
} else {
......@@ -266,9 +264,9 @@ if(w2PgetParam( $_POST, "Save", '' )!=''){
break;
}
$q->addTable('helpdesk_config');
$q->addUpdate('helpdesk_config', $key);
$q->addUpdate('helpdesk_value', $_POST[$val]);
$q->addWhere('helpdesk_config = "$key"');
$q->addUpdate('config', $key);
$q->addUpdate('value', $val);
$q->addWhere('config = "' . $key . '"');
if (!$q->exec()) {
$AppUI->setMsg(db_error(), UI_MSG_ERROR);
}
......@@ -280,7 +278,8 @@ if(w2PgetParam( $_POST, "Save", '' )!=''){
$AppUI->redirect("m=system&a=viewmods");
}
//Read the current config values from the config file and update the array.
//Read the current config values from the config table and update the array.
$HELPDESK_CONFIG = loadConfig();
foreach ($config_options as $key=>$value){
if(isset($HELPDESK_CONFIG[$key])){
......
......@@ -18,12 +18,29 @@ function loadConfig()
return null;
}
while ($row = $q->fetchRow()) {
$config[$row['helpdesk_config']] = $row['helpdesk_value'];
$config[$row['config']] = $row['value'];
}
$q->clear();
return $config;
}
function storeConfig($confdata=0)
{
$q = new w2p_Database_Query();
foreach($confdata as $key=>$value) {
$q->addTable('helpdesk_config');
$q->addUpdate('config', $key);
$q->addUpdate('value', $value);
$q->addWhere('config = "'. $key . '"');
if (!$q->exec()) {
db_error();
return false;
}
$q->clear();
}
return true;
}
function getAllowedUsers($companyid=0,$activeOnly=0)
{
global $HELPDESK_CONFIG, $AppUI, $m;
......
......@@ -361,9 +361,9 @@ class CSetupHelpDesk extends w2p_System_Setup
private function _createConfigurationTable() {
$q = new w2p_Database_Query();
$sql = "( " .
" `helpdesk_config` varchar(25) NOT NULL, " .
" `helpdesk_value` varchar(256), " .
" PRIMARY KEY (`helpdesk_config`) " .
" `config` varchar(50) NOT NULL, " .
" `value` varchar(256), " .
" PRIMARY KEY (`config`) " .
") ENGINE = MYISAM DEFAULT CHARSET = utf8";
$q->createTable('helpdesk_config');
$q->createDefinition($sql);
......@@ -372,73 +372,51 @@ class CSetupHelpDesk extends w2p_System_Setup
}
private function _insertConfigurationData() {
$data = array(
'items_per_page' => '30',
'status_log_items_per_page' => '15',
'pages_per_side' => '5',
'the_company' => '0',
'no_company_editable' => '0',
'minimum_edit_level' => '0',
'use_project_perms' => '0',
'minimum_report_level' => '0',
'new_hd_item_title_prefix' => 'HD-%05d',
'default_assigned_to_current_user' => '-1',
'default_company_current_company' => '1',
'default_watcher' => '1',
'default_watcher_list' => '0',
'search_criteria_search' => '1',
'search_criteria_call_type' => '1',
'search_criteria_company' => '1',
'search_criteria_status' => '1',
'search_criteria_call_source' => '1',
'search_criteria_project' => '1',
'search_criteria_assigned_to' => '1',
'search_criteria_priority' => '1',
'search_criteria_application' => '1',
'search_criteria_requestor' => '1',
'search_criteria_severity' => '1',
'search_criteria_service' => '1',
'default_notify_by_email' => '1',
'task_watchers_notification' => '1',
'task_requestor_notification' => '1',
'notify_email_address' => 'support@yourcompany.com',
'email_subject' => 'Your Company registered your recent request',
'email_header' =>'Your Company Management Registry'
);
$q = new w2p_Database_Query();
$q->addTable('helpdesk_config');
$q->addInsert('helpdesk_config', 'items_per_page');
$q->addInsert('helpdesk_value', '30');
$q->addInsert('helpdesk_config', 'status_log_items_per_page');
$q->addInsert('helpdesk_value', '15');
$q->addInsert('helpdesk_config', 'pages_per_side');
$q->addInsert('helpdesk_value', '5');
$q->addInsert('helpdesk_config', 'the_company');
$q->addInsert('helpdesk_value', '0');
$q->addInsert('helpdesk_config', 'no_company_editable');
$q->addInsert('helpdesk_value', '0');
$q->addInsert('helpdesk_config', 'minimum_edit_level');
$q->addInsert('helpdesk_value', '0');
$q->addInsert('helpdesk_config','use_project_perms');
$q->addInsert('helpdesk_value', '0');
$q->addInsert('helpdesk_config', 'minimum_report_level');
$q->addInsert('helpdesk_value', '0');
$q->addInsert('helpdesk_config', 'new_hd_item_title_prefix');
$q->addInsert('helpdesk_value', 'HD-%05d');
$q->addInsert('helpdesk_config', 'default_assigned_to_current_user');
$q->addInsert('helpdesk_value', '-1');
$q->addInsert('helpdesk_config', 'default_company_current_company');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'default_watcher');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'default_watcher_list');
$q->addInsert('helpdesk_value', '0');
$q->addInsert('helpdesk_config', 'search_criteria_search');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_call_type');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_company');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_status');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_call_source');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_project');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_assigned_to');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_priority');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_application');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_requestor');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_severity');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'search_criteria_service');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'default_notify_by_email');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'task_watchers_notification');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'task_requestor_notification');
$q->addInsert('helpdesk_value', '1');
$q->addInsert('helpdesk_config', 'notify_email_address');
$q->addInsert('helpdesk_value', 'support@yourcomapany.com');
$q->addInsert('helpdesk_config', 'email_subject');
$q->addInsert('helpdesk_value', 'Your Company registered your recent request');
$q->addInsert('helpdesk_config','email_header');
$q->addInsert('helpdesk_value', 'Your Company Management Registry');
$result = $q->exec();
return $result;
foreach ($data as $key=>$value) {
$q->addTable('helpdesk_config');
$q->addInsert('config', $key);
$q->addInsert('value', $value);
if (!$q->exec()) {
db_error();
return false;
}
$q->clear();
}
return true;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment