Example #1
0
    // exit;
    // check to see if we have a digital item for object
    if (file_exists("/home/mfcs.lib.wvu.edu/data/working/uploads/" . $submitArray['idno'])) {
        $submitArray['digitalFiles'] = $submitArray['idno'];
        $submitArray['mediaRelease'] = "Yes";
    }
    if (objects::add("2", $submitArray) !== TRUE) {
        print "error adding object " . $submitArray['idno'];
        print "<pre>";
        var_dump($submitArray);
        print "</pre>";
        errorHandle::prettyPrint();
        exit;
    }
    // add the item to the pec project
    if (objects::addProject(localvars::get("newObjectID"), "1") === FALSE) {
        print "error -- add Project: \n";
        print "<pre>";
        var_dump($submitArray);
        print "</pre>";
        errorHandle::prettyPrint();
        exit;
    }
    mfcs::$engine->cleanPost['MYSQL'] = array();
    mfcs::$engine->cleanPost['HTML'] = array();
    mfcs::$engine->cleanPost['RAW'] = array();
    // make certain we don't have any data cache
    unset($submitArray);
}
print "Records: <pre>";
var_dump(count($records));
Example #2
0
 public static function create($formID, $data, $metadata, $parentID = 0, $modifiedTime = NULL, $createTime = NULL)
 {
     if (!is_array($data)) {
         errorHandle::newError(__METHOD__ . "() - : data is not array", errorHandle::DEBUG);
         return FALSE;
     }
     // Get the current Form
     if (($form = forms::get($formID)) === FALSE) {
         errorHandle::newError(__METHOD__ . "() - retrieving form by formID", errorHandle::DEBUG);
         return FALSE;
     }
     // begin transactions
     $result = mfcs::$engine->openDB->transBegin("objects");
     if ($result !== TRUE) {
         errorHandle::newError(__METHOD__ . "() - unable to start database transactions", errorHandle::DEBUG);
         return FALSE;
     }
     // Insert into the database
     $sql = sprintf("INSERT INTO `objects` (parentID,formID,data,metadata,modifiedTime,createTime,modifiedBy,createdBy) VALUES('%s','%s','%s','%s','%s','%s','%s','%s')", isset(mfcs::$engine->cleanPost['MYSQL']['parentID']) ? mfcs::$engine->cleanPost['MYSQL']['parentID'] : "0", mfcs::$engine->openDB->escape($formID), encodeFields($data), mfcs::$engine->openDB->escape($form['metadata']), time(), time(), mfcs::$engine->openDB->escape(users::user('ID')), mfcs::$engine->openDB->escape(users::user('ID')));
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - " . $sql . " -- " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     // Set the new object ID in a local variable
     $objectID = $sqlResult['id'];
     localvars::add("newObjectID", $objectID);
     // Insert into the new data table
     if (self::insertObjectData($objectID, $data, $formID) === FALSE) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - inserting objects", errorHandle::DEBUG);
         return FALSE;
     }
     // if it is an object form (not a metadata form)
     // do the IDNO stuff
     if ($form['metadata'] == "0") {
         // the form is an object form, make sure that it has an ID field defined.
         if (($idnoInfo = forms::getFormIDInfo($formID)) === FALSE) {
             errorHandle::newError(__METHOD__ . "() - no IDNO field for object form.", errorHandle::DEBUG);
             return FALSE;
         }
         // if the idno is managed by the system get a new idno
         if ($idnoInfo['managedBy'] == "system") {
             $idno = mfcs::$engine->openDB->escape(mfcs::getIDNO($formID));
         } else {
             $idno = mfcs::$engine->cleanPost['MYSQL']['idno'];
         }
         if (isempty($idno)) {
             mfcs::$engine->openDB->transRollback();
             mfcs::$engine->openDB->transEnd();
             return FALSE;
         }
         if (!self::updateIDNO($objectID, $idno)) {
             mfcs::$engine->openDB->transRollback();
             mfcs::$engine->openDB->transEnd();
             errorHandle::newError(__METHOD__ . "() - updating the IDNO: " . $sqlResult['error'], errorHandle::DEBUG);
             return FALSE;
         }
         // increment the project counter
         $sql = sprintf("UPDATE `forms` SET `count`=`count`+'1' WHERE `ID`='%s'", mfcs::$engine->openDB->escape($form['ID']));
         $sqlResult = mfcs::$engine->openDB->query($sql);
         if (!$sqlResult['result']) {
             mfcs::$engine->openDB->transRollback();
             mfcs::$engine->openDB->transEnd();
             errorHandle::newError(__METHOD__ . "() - Error incrementing form counter: " . $sqlResult['error'], errorHandle::DEBUG);
             return FALSE;
         }
     }
     // Update duplicate matching table
     if (duplicates::updateDupeTable($formID, $objectID, $data) === FALSE) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - updating dupe matching", errorHandle::DEBUG);
         return FALSE;
     }
     // Add it to the users current projects
     if (($currentProjects = users::loadProjects()) === FALSE) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         return FALSE;
     }
     foreach ($currentProjects as $projectID => $projectName) {
         if (forms::checkFormInProject($projectID, $formID) === TRUE) {
             if (objects::addProject($objectID, $projectID) === FALSE) {
                 mfcs::$engine->openDB->transRollback();
                 mfcs::$engine->openDB->transEnd();
                 return FALSE;
             }
         }
     }
     // end transactions
     mfcs::$engine->openDB->transCommit();
     mfcs::$engine->openDB->transEnd();
     return TRUE;
 }