/** * Retrieves a configuration setting. * @param $key string The name of a configuration setting * @param $default string The default value to return if the key not found. * @return The value of the setting, or the default value if not found. */ function w2PgetConfig($key, $default = null) { global $w2Pconfig, $AppUI; if (isset($w2Pconfig[$key])) { return $w2Pconfig[$key]; } else { if (!is_null($default)) { $obj = new w2p_Core_Config(); $obj->config_name = $key; $obj->config_value = $default; $obj->store($AppUI); } return $default; } }
$q->addTable('config'); $q->addQuery("config_id"); $q->addWhere("config_name = 'cal_day_start'"); $id = $q->loadResult(); $q->clear(); $obj = new w2p_Core_Config(); $obj->load($id); $obj->config_value = $newcal_day_start; if ($msg = $obj->store($AppUI)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } } $cal_day_end = w2PgetConfig("cal_day_end"); $newcal_day_end = w2PgetParam($_POST, "cal_day_end", $cal_day_end); if ($newcal_day_end != $cal_day_end) { $q->addTable('config'); $q->addQuery("config_id"); $q->addWhere("config_name = 'cal_day_end'"); $id = $q->loadResult(); $q->clear(); $obj = new w2p_Core_Config(); $obj->load($id); $obj->config_value = $newcal_day_end; if ($msg = $obj->store($AppUI)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } } $AppUI->setMsg("Settings updated"); $AppUI->redirect();