Exemplo n.º 1
0
 public static function updateDupeTable($formID, $objectID, $data)
 {
     // trans begin
     $result = mfcs::$engine->openDB->transBegin("objects");
     if ($result !== TRUE) {
         errorHandle::newError(__METHOD__ . "() - unable to start database transactions", errorHandle::DEBUG);
         return FALSE;
     }
     // wipe the old dupe information
     $sql = sprintf("DELETE FROM `dupeMatching` WHERE `formID`='%s' AND `objectID`='%s'", mfcs::$engine->openDB->escape($formID), mfcs::$engine->openDB->escape($objectID));
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - removing from duplicate table: " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     //insert data
     foreach ($data as $name => $raw) {
         if (!isset(mfcs::$engine->cleanPost['MYSQL'][$name]) || isempty(mfcs::$engine->cleanPost['MYSQL'][$name])) {
             if (!isempty($raw)) {
                 http::setPost($name, $raw);
                 $postSet = TRUE;
             } else {
                 continue;
             }
         }
         $sql = sprintf("INSERT INTO `dupeMatching` (`formID`,`objectID`,`field`,`value`) VALUES('%s','%s','%s','%s')", mfcs::$engine->openDB->escape($formID), mfcs::$engine->openDB->escape($objectID), mfcs::$engine->openDB->escape($name), mfcs::$engine->cleanPost['MYSQL'][$name]);
         $sqlResult = mfcs::$engine->openDB->query($sql);
         if (isset($postSet) && $postSet === TRUE) {
             http::setPost($name, "");
         }
         if (!$sqlResult['result']) {
             mfcs::$engine->openDB->transRollback();
             mfcs::$engine->openDB->transEnd();
             errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
             return FALSE;
         }
     }
     // trans commit
     mfcs::$engine->openDB->transCommit();
     mfcs::$engine->openDB->transEnd();
     return TRUE;
 }
Exemplo n.º 2
0
 public static function add($formID, $metadata, $objectID = NULL)
 {
     if (!is_array($metadata)) {
         errorHandle::newError(__METHOD__ . "() - : metedata is not array", errorHandle::DEBUG);
         return FALSE;
     }
     if (!self::validID(FALSE, $objectID)) {
         errorHandle::newError(__METHOD__ . "() - : invalid objectID provided", errorHandle::DEBUG);
         return FALSE;
     }
     // populate cleanPost
     foreach ($metadata as $I => $V) {
         http::setPost($I, $V);
     }
     // submit to forms::submit
     return forms::submit($formID, $objectID, TRUE);
 }
Exemplo n.º 3
0
include "../public_html/includes/functions.php";
include "../public_html/includes/validator.php";
$objects = objects::get();
// Begin the transaction
if (mfcs::$engine->openDB->transBegin("objects") !== TRUE) {
    print __METHOD__ . "() - unable to start database transactions";
    exit;
}
foreach ($objects as $object) {
    // only rebuild the objects
    if ($object['metadata'] != '0') {
        continue;
    }
    // Build cleanPost
    // @TODO this should be stripped when updateDupeTable is fixed to not require cleanPost
    // Reset cleanPost
    mfcs::$engine->cleanPost['MYSQL'] = array();
    mfcs::$engine->cleanPost['HTML'] = array();
    mfcs::$engine->cleanPost['RAW'] = array();
    foreach ($object['data'] as $name => $raw) {
        http::setPost($name, $raw);
    }
    if (duplicates::updateDupeTable($object['formID'], $object['ID'], $object['data']) === FALSE) {
        mfcs::$engine->openDB->transRollback();
        mfcs::$engine->openDB->transEnd();
        print __METHOD__ . "() - updating dupe matching";
        exit;
    }
}
mfcs::$engine->openDB->transCommit();
mfcs::$engine->openDB->transEnd();