952 days continuous production uptime, 40k+ tp/s single node. Original corpo Bitbucket history not included — clean archive commit.
91 lines
3.2 KiB
PHP
91 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* fetchSysData.php
|
|
*
|
|
* Stub program that's invoked by gaAdmin utility.
|
|
*
|
|
* This program stub connects to the admin mongo resource and pulls all (the whole one record) of system data from
|
|
* the system-data collection. (There should be either zero (edge case) or one record stored.)
|
|
*
|
|
* The program will store any user-level error messages in an array named $formErrors which will be displayed to the
|
|
* user in the next page load.
|
|
*
|
|
* There is an edge case to be accommodated -- when you request to edit a new Namaste installation and there is no
|
|
* data stored in the system-table.
|
|
*
|
|
* todo: write a program that populates the systemData collection during installation
|
|
*
|
|
* If data exists in the table, it's stored as an associative array in a variable called: $systemData.
|
|
* If data doesn't exist in the table, and if no errors were generated, we're going to assume it's a new (unpopulated)
|
|
* table. In both of the previous cases, a boolean value: $sysDataLoad is set to true.
|
|
*
|
|
*
|
|
* @author mike@givingassistant.org
|
|
* @version 1.0
|
|
*
|
|
* HISTORY:
|
|
* ========
|
|
* 08-07-18 mks CORE-1113: original coding
|
|
*
|
|
*/
|
|
$meta = [
|
|
META_TEMPLATE => TEMPLATE_CLASS_SYS_EVENTS,
|
|
META_CLIENT => CLIENT_SYSTEM,
|
|
META_CLIENT_IP => STRING_SESSION_HOME,
|
|
];
|
|
if (!isset($data['c'])) {
|
|
$systemMessage[] = 'Choice (C) data not loaded!';
|
|
return;
|
|
}
|
|
$whichConstant = intval($data['c']);
|
|
|
|
// this script may only execute locally on the namaste admin service
|
|
// todo -- remove the "true or" when done debugging
|
|
//if (true or intval(gasConfig::$settings[CONFIG_DATABASE][CONFIG_DATABASE_MONGODB][CONFIG_DATABASE_MONGODB_ADMIN][CONFIG_IS_LOCAL]) != 1) {
|
|
if (intval(gasConfig::$settings[CONFIG_DATABASE][CONFIG_DATABASE_MONGODB][CONFIG_DATABASE_MONGODB_ADMIN][CONFIG_IS_LOCAL]) != 1) {
|
|
$formErrors[] = ERROR_LOCAL_NOT_ADMIN;
|
|
return;
|
|
}
|
|
|
|
// instantiate the systemData class object
|
|
try {
|
|
$obj = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, basename(__FILE__) . AT . __LINE__, $formErrors);
|
|
} catch (TypeError $t) {
|
|
$formErrors[] = ERROR_TYPE_EXCEPTION . COLON . $t->getMessage();
|
|
return;
|
|
}
|
|
|
|
// ensure that the systemData class object successfully instantiated
|
|
if (!$obj->status) {
|
|
$formErrors = $obj->eventMessages;
|
|
if (is_object($obj->widget)) $obj->widget->__destruct();
|
|
if (is_object($obj)) $obj->__destruct();
|
|
unset($obj);
|
|
return;
|
|
}
|
|
|
|
// fetch the systemData
|
|
$query = [null];
|
|
$obj->widget->_fetchRecords([STRING_QUERY_DATA => $query]);
|
|
if (!$obj->status) {
|
|
$formErrors = $obj->widget->eventMessages;
|
|
if (is_object($obj->widget)) $obj->widget->__destruct();
|
|
if (is_object($obj)) $obj->__destruct();
|
|
unset($obj);
|
|
return;
|
|
}
|
|
|
|
// get the data array
|
|
$obj->widget->eventMessages = null;
|
|
$systemData = $obj->widget->getData();
|
|
if (is_array($systemData)) $systemData = $systemData[0];
|
|
$sysDataLoad = (empty($obj->widget->eventMessages)) ? true : false;
|
|
if (is_null($systemData) and $sysDataLoad) {
|
|
$systemMessage[] = 'The system data table has not been created yet; the table will be created when the new data is saved.';
|
|
} elseif (!$sysDataLoad) {
|
|
$formErrors[] = $obj->widget->eventMessages;
|
|
}
|
|
if (is_object($obj->widget)) $obj->widget->__destruct();
|
|
if (is_object($obj)) $obj->__destruct();
|
|
unset($obj);
|