Exemple #1
0
 public static function get($formID = NULL, $productionOnly = FALSE)
 {
     if (isnull($formID)) {
         return self::getForms();
     }
     $mfcs = mfcs::singleton();
     $cachID = "getForm:" . $formID;
     $cache = $mfcs->cache("get", $cachID);
     if (!isnull($cache)) {
         return $cache;
     }
     $engine = EngineAPI::singleton();
     $sql = sprintf("SELECT * FROM `forms` WHERE `ID`='%s'%s", $engine->openDB->escape($formID), $productionOnly === TRUE ? " AND `production`='1'" : "");
     $sqlResult = $engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     if ($sqlResult['numrows'] == 0) {
         return FALSE;
     }
     $form = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC);
     if (($form['fields'] = decodeFields($form['fields'])) === FALSE) {
         errorHandle::newError(__METHOD__ . "() - fields", errorHandle::DEBUG);
         errorHandle::errorMsg("Error retrieving form.");
         return FALSE;
     }
     if (($form['idno'] = decodeFields($form['idno'])) === FALSE) {
         errorHandle::newError(__METHOD__ . "() - idno", errorHandle::DEBUG);
         errorHandle::errorMsg("Error retrieving form.");
         return FALSE;
     }
     if (!isempty($form['navigation']) && ($form['navigation'] = decodeFields($form['navigation'])) === FALSE) {
         errorHandle::newError(__METHOD__ . "() - navigation!", errorHandle::DEBUG);
         errorHandle::errorMsg("Error retrieving form.");
         return FALSE;
     }
     if ($mfcs->cache("create", $cachID, $form) === FALSE) {
         errorHandle::newError(__METHOD__ . "() - unable to cache form", errorHandle::DEBUG);
     }
     return $form;
 }
Exemple #2
0
<?php

require "engineInclude.php";
if (!isCLI()) {
    recurseInsert("acl.php", "php");
}
recurseInsert("dbTableList.php", "php");
$engine->dbConnect("database", "mfcs", TRUE);
// Load the mfcs class
require_once "includes/index.php";
mfcs::singleton();
// Quick and dirty Checks check
// @TODO this needs to be more formalized in a class to easily include other checks as well
if (!isCLI()) {
    $sql_check = sprintf("SELECT `value` FROM `checks` WHERE `name`='uniqueIDCheck'");
    $sqlResult_check = mfcs::$engine->openDB->query($sql_check);
    if (!$sqlResult_check['result']) {
        errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
        print "<p>Error checking MFCS sanity. Aborting.</p>";
        exit;
    }
    $row_check = mysql_fetch_array($sqlResult_check['result'], MYSQL_ASSOC);
    if ($row_check['value'] == "0") {
        // notify systems via email
        print "<h1>ERROR!</h1>";
        print "<p>MFCS Failed idno sanity check. Please contact systems Immediately.</p>";
        print "<p>Please jot down the steps you took getting to this point. Be as specific as possible.</p>";
        print "<p>Aborting.</p>";
        exit;
    }
}
Exemple #3
0
 public static function buildObject($row, $ignoreCache = FALSE, $metadata = TRUE)
 {
     if (!is_array($row)) {
         return FALSE;
     }
     if (!$ignoreCache) {
         $mfcs = mfcs::singleton();
         $cachID = "getObject:" . $row['ID'];
         $cache = $mfcs->cache("get", $cachID);
         if (!isnull($cache)) {
             return $cache;
         }
     }
     // @TODO sanity checking
     // we might want to do a little more sanity cheecking here.
     // does $data['data'] exist?
     // does it have the proper structure?
     // etc ...
     if ($metadata !== FALSE) {
         // **** Original way of getting data
         if (($row['data'] = decodeFields($row['data'])) === FALSE) {
             errorHandle::errorMsg("Error retrieving object.");
             return FALSE;
         }
         // **** objectsData table method for getting data
         // if (($row['data'] = self::retrieveObjectData($row['ID'])) === FALSE) {
         // 	errorHandle::errorMsg("Error retrieving object.");
         // 	return FALSE;
         // }
         // **** objectsData, single query
         // $object = $row[0];
         // $data = array();
         // foreach ($row as $fragment) {
         // 	$data[$fragment['fieldName']] = ($fragment['encoded'] == "1")?decodeFields($fragment['value']):$fragment['value'];
         // }
         // $object['data'] = $data;
         // unset($object['fieldName']);
         // unset($object['value']);
         // $row = $object;
     }
     if (!$ignoreCache) {
         $cache = $mfcs->cache("create", $cachID, $row);
         if ($cache === FALSE) {
             errorHandle::newError(__METHOD__ . "() - unable to cache object", errorHandle::DEBUG);
         }
     }
     return $row;
 }