Exemplo n.º 1
0
<?php

session_save_path('/tmp');
ini_set('memory_limit', -1);
set_time_limit(0);
require "../header.php";
if (!isCLI()) {
    print "Must be run from the command line.";
    exit;
}
// Turn off EngineAPI template engine
$engine->obCallback = FALSE;
$forms = forms::getForms(NULL);
$dupeConfirm = array(TRUE => 0, FALSE => 0);
foreach ($forms as $form) {
    print "Form: " . $form['title'] . "\n";
    $objects = objects::getAllObjectsForForm($form['ID']);
    foreach ($objects as $object) {
        unset(mfcs::$engine->cleanPost['MYSQL']);
        $return = duplicates::updateDupeTable($form['ID'], $object['ID'], $object['data']);
        $dupeConfirm[$return]++;
    }
}
print "\n\n";
var_dump($dupeConfirm);
print "Done.\n\n";
Exemplo n.º 2
0
    } else {
        if (isset($engine->cleanGet['MYSQL']['action'])) {
            switch ($engine->cleanGet['MYSQL']['action']) {
                case 'selectChoices':
                    $field = forms::getField($engine->cleanGet["MYSQL"]['formID'], $engine->cleanGet["MYSQL"]['fieldName']);
                    $fieldChoices = forms::getFieldChoices($field);
                    $result = forms::drawFieldChoices($field, $fieldChoices);
                    die($result);
                    break;
                case 'searchFormFields':
                    die(mfcsSearch::formFieldOptions($engine->cleanGet["MYSQL"]['formID']));
                    break;
                case 'paginationPerPage':
                    $result = users::setField('pagination', $engine->cleanGet["MYSQL"]['perPage']);
                    die(json_encode($result ? "TRUE" : "FALSE"));
                    break;
                case 'paginationJumpToIDNO':
                    $objects = objects::getAllObjectsForForm($engine->cleanGet['MYSQL']['formID'], "idno");
                    for ($I = 0; $I < count($objects); $I++) {
                        if (strtolower($objects[$I]['idno']) == strtolower($engine->cleanGet['MYSQL']['idno'])) {
                            header('Location: ' . localvars::get("siteroot") . "dataView/list.php?listType=form&formID=" . $engine->cleanGet['MYSQL']['formID'] . "&page=" . ceil($I / 25));
                        }
                    }
                    $result = "IDNO not found";
                    break;
            }
        }
    }
    header('Content-type: application/json');
    die(json_encode($result));
}
Exemplo n.º 3
0
 public static function submitEditTable($formID)
 {
     $form = self::get($formID);
     if ($form === FALSE) {
         return FALSE;
     }
     $engine = EngineAPI::singleton();
     // begin transactions
     $result = $engine->openDB->transBegin("objects");
     if ($result !== TRUE) {
         errorHandle::errorMsg("Database transactions could not begin.");
         errorHandle::newError(__METHOD__ . "() - unable to start database transactions", errorHandle::DEBUG);
         return FALSE;
     }
     // Do the Updates
     $objects = objects::getAllObjectsForForm($formID, NULL, FALSE);
     if (count($objects) > 0) {
         foreach ($objects as $object) {
             $values = array();
             foreach ($form['fields'] as $field) {
                 // @TODO keep an eye on this with edit tables ... this was added to help the modal inserts
                 // from being deleted because the edit table didn't have them listed.
                 if (!isset($engine->cleanPost['RAW'][$field['name'] . "_" . $object['ID']])) {
                     continue 2;
                 }
                 $value = isset($engine->cleanPost['RAW'][$field['name'] . "_" . $object['ID']]) ? $engine->cleanPost['RAW'][$field['name'] . "_" . $object['ID']] : $object['data'][$field['name']];
                 $validationTests = self::validateSubmission($formID, $field, $value, $object['ID']);
                 if (isnull($validationTests) || $validationTests === FALSE) {
                     continue 2;
                 }
                 if (strtolower($field['readonly']) == "true") {
                     // need to pull the data that loaded with the form
                     if ($newObject === TRUE) {
                         // grab it from the database
                         $oldObject = object::get($objectID);
                         $values[$field['name']] = $oldObject['data'][$field['name']];
                     } else {
                         // grab the default value from the form.
                         $values[$field['name']] = $field['value'];
                     }
                     continue;
                 }
                 if (!isset($values[$field['name']])) {
                     $values[$field['name']] = $value;
                 }
                 if (!is_empty($engine->errorStack)) {
                     $engine->openDB->transRollback();
                     $engine->openDB->transEnd();
                     return FALSE;
                 }
             }
             // Check to see if the objects data has changed. if it has, update it.
             if (encodeFields($values) != $object['data']) {
                 if (objects::update($object['ID'], $formID, $values, $form['metadata']) === FALSE) {
                     $engine->openDB->transRollback();
                     $engine->openDB->transEnd();
                     errorHandle::newError(__METHOD__ . "() - error updating edit table", errorHandle::DEBUG);
                     errorHandle::errorMsg("Error updating.");
                     return FALSE;
                 }
             }
         }
     }
     // do the deletes
     if (isset($engine->cleanPost['MYSQL']['delete']) && count($engine->cleanPost['MYSQL']['delete']) > 0) {
         foreach ($engine->cleanPost['MYSQL']['delete'] as $objectID) {
             $sql = sprintf("DELETE FROM `objects` WHERE `ID`='%s'", $objectID);
             $sqlResult = $engine->openDB->query($sql);
             if (!$sqlResult['result']) {
                 $engine->openDB->transRollback();
                 $engine->openDB->transEnd();
                 errorHandle::errorMsg("Error deleting objects.");
                 errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
                 return FALSE;
             }
             $sql = sprintf("DELETE FROM `dupeMatching` WHERE `objectID`='%s'", $objectID);
             $sqlResult = $engine->openDB->query($sql);
             if (!$sqlResult['result']) {
                 $engine->openDB->transRollback();
                 $engine->openDB->transEnd();
                 errorHandle::errorMsg("Error deleting objects.");
                 errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
                 return FALSE;
             }
             $sql = sprintf("DELETE FROM `objectsData` WHERE `objectID`='%s'", $objectID);
             $sqlResult = $engine->openDB->query($sql);
             if (!$sqlResult['result']) {
                 $engine->openDB->transRollback();
                 $engine->openDB->transEnd();
                 errorHandle::errorMsg("Error deleting objects. Objects Data table.");
                 errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
                 return FALSE;
             }
         }
     }
     // end transactions
     $engine->openDB->transCommit();
     $engine->openDB->transEnd();
     return TRUE;
 }
Exemplo n.º 4
0
$outFile = "./dlxsXmlImageClass/" . $outFileName;
$outDigitalFileName = "pec-files_" . time() . ".tar.gz";
$outDigitalFile = "./dlxsXmlImageClass/" . $outDigitalFileName;
localvars::add("outFile", $outFile);
localvars::add("outFileName", $outFileName);
localvars::add("outDigitalFile", $outDigitalFile);
localvars::add("outDigitalFileName", $outDigitalFileName);
$sql = sprintf("SELECT MAX(`date`) FROM exports WHERE `formID`='2'");
$sqlResult = $engine->openDB->query($sql);
if (!$sqlResult['result']) {
    errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
    die("error getting max.");
}
$row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC);
$lastExportDate = isnull($row['MAX(`date`)']) ? 0 : $row['MAX(`date`)'];
$objects = objects::getAllObjectsForForm("2");
$xml = '<?xml version="1.0" encoding="UTF-8" ?><!-- This grammar has been deprecated - use FMPXMLRESULT instead --><FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult"><ERRORCODE>0</ERRORCODE><DATABASE>iai_data.fp7</DATABASE><LAYOUT></LAYOUT>';
$count = 0;
foreach ($objects as $object) {
    $mergedCreators = array_merge((array) $object['data']['creatorPersName'], (array) $object['data']['creatorCorpName'], (array) $object['data']['creatorMeetName'], (array) $object['data']['creatorUniformTitle']);
    $mergedSubjects = array_merge((array) $object['data']['subjectPersName'], (array) $object['data']['subjectCorpName'], (array) $object['data']['subjectMeetingName'], (array) $object['data']['subjectUniformTitle'], (array) $object['data']['subjectTopical'], (array) $object['data']['subjectGeoName']);
    $creators = array();
    $subjects = array();
    foreach ($mergedCreators as $headingID) {
        $creators[] = getHeadingByID($headingID);
    }
    foreach ($mergedSubjects as $headingID) {
        $subjects[] = getHeadingByID($headingID);
    }
    sort($creators);
    sort($subjects);
Exemplo n.º 5
0
foreach ($objects as $I => $object) {
    $totalMediaItems += isset($object['data']['digitalFiles']['uuid']) ? 1 : 0;
    $totalMediaItemsPublic += isset($object['data']['digitalFiles']['uuid']) && $object['data']['publicRelease'] == "Yes" ? 1 : 0;
    $totalPECObjectsPublic += $object['data']['publicRelease'] == "Yes" ? 1 : 0;
    $totalItemCount += (int) $object['data']['itemCount'] > 0 ? (int) $object['data']['itemCount'] : 0;
    $totalItemCountPublic += (int) $object['data']['itemCount'] > 0 && $object['data']['publicRelease'] == "Yes" ? (int) $object['data']['itemCount'] : 0;
}
localvars::add("totalMediaItems", $totalMediaItems);
localvars::add("totalMediaItemsPublic", $totalMediaItemsPublic);
localvars::add("totalPECObjectsPublic", $totalPECObjectsPublic);
localvars::add("totalItemCount", $totalItemCount);
localvars::add("totalItemCountPublic", $totalItemCountPublic);
$metadataForms = forms::getObjectFormMetaForms("2");
$metaInformation = "<table>";
foreach ($metadataForms as $form) {
    $metaInformation .= sprintf("<tr><td><strong>%s</strong></td><td>%d</td></tr>", $form['displayTitle'], count(objects::getAllObjectsForForm($form['ID'])));
}
$metaInformation .= "</table>";
localvars::add("metaInformation", $metaInformation);
$engine->eTemplate("include", "header");
?>

<h1>Stats for PEC</h1>

<table id="statsTable" width="600">

	<tr style="background-color: #EEEEFF;">
		<th align="left">
			Type
		</th>
		<th align="right">
Exemplo n.º 6
0
 public static function metadataObjects($formID, $objectID)
 {
     // get all the object forms that have this metadata form linked to it
     $forms = forms::getFormsLinkedTo($formID);
     $data = array();
     foreach ($forms as $formID => $field) {
         $objects = objects::getAllObjectsForForm($formID);
         $form = forms::get($formID);
         foreach ($objects as $object) {
             if (strtolower($field['type']) == "select") {
                 if ($object['data'][$field['name']] == $objectID) {
                     $data[] = array($object['ID'], $object['idno'], $object['data'][$form['objectTitleField']], self::genLinkURLs("view", $object['ID']), self::genLinkURLs("edit", $object['ID']), self::genLinkURLs("revisions", $object['ID']));
                 }
             } else {
                 if (strtolower($field['type']) == "multiselect") {
                     if (in_array($objectID, $object['data'][$field['name']])) {
                         $data[] = array($object['ID'], $object['idno'], $object['data'][$form['objectTitleField']], self::genLinkURLs("view", $object['ID']), self::genLinkURLs("edit", $object['ID']), self::genLinkURLs("revisions", $object['ID']));
                     }
                 }
             }
         }
     }
     return self::createTable($data);
     return;
 }
Exemplo n.º 7
0
 public static function search($post)
 {
     if (isempty($post['formList'])) {
         return FALSE;
     }
     // Save the post for later use (like pagination pages)
     sessionSet('searchPOST', $post);
     if (!isempty($post['startDate']) && !isempty($post['endDate'])) {
         $date = TRUE;
         // @tODO build where clause for date here
     } else {
         $date = FALSE;
     }
     // build query for idno searches
     if ($post['fieldList'] == "idno" && preg_match('/^\\\\"(.+?)\\\\"/', trim($post['query']), $matches)) {
         $queryString = sprintf("LOWER(`idno`)='%s'", strtolower($matches[1]));
     } else {
         if ($post['fieldList'] == "idno" && preg_match('/^(.+?)\\*$/', trim($post['query']), $matches)) {
             $queryString = sprintf("LOWER(`idno`) LIKE '%s%%'", strtolower($matches[1]));
         } else {
             if ($post['fieldList'] == "idno" && preg_match('/^\\*(.+?)$/', trim($post['query']), $matches)) {
                 $queryString = sprintf("LOWER(`idno`) LIKE '%%%s'", strtolower($matches[1]));
             } else {
                 $queryString = sprintf("LOWER(`idno`) LIKE '%%%s%%'", strtolower($post['query']));
             }
         }
     }
     // if idno search, build mysql here and search
     if ($post['fieldList'] == "idno" && $date === TRUE) {
         $sql = sprintf("SELECT * FROM `objects` WHERE `idno` LIKE '%%%s%%' AND `formID`='%s' AND `createTime` >= '%s' AND `createTime` <= '%s' ORDER BY LENGTH(idno), `idno`", $post['query'], $post['formList'], strtotime($post['startDate']), strtotime($post['endDate']));
         $objects = objects::getObjectsForSQL($sql);
     } else {
         if ($post['fieldList'] == "idno") {
             $sql = sprintf("SELECT * FROM `objects` WHERE %s AND `formID`='%s' ORDER BY LENGTH(idno), `idno`", $queryString, $post['formList']);
             $objects = objects::getObjectsForSQL($sql);
         } else {
             if ($date === TRUE) {
                 $sql = sprintf("SELECT * FROM `objects` WHERE AND `formID`='%s' AND `createTime` >= '%s' AND `createTime` <= '%s' ORDER BY LENGTH(idno), `idno`", $post['formList'], strtotime($post['startDate']), strtotime($post['endDate']));
                 $objects = objects::getObjectsForSQL($sql);
             } else {
                 $objects = objects::getAllObjectsForForm($post['formList'], "idno", TRUE);
             }
         }
     }
     $results = array();
     foreach ($objects as $object) {
         // check that the item is in the date range, if a date range is specified.
         // if ($date === TRUE && ($object['createTime'] < strtotime($post['startDate']) || $object['createTime'] > strtotime($post['endDate']))) {
         // 	continue;
         // }
         $found = FALSE;
         if (!isempty($post['query'])) {
             if ($post['fieldList'] == "idno") {
                 $found = TRUE;
             } else {
                 if (isset($object['data'][$post['fieldList']]) && stripos($object['data'][$post['fieldList']], $post['query']) !== FALSE) {
                     $found = TRUE;
                 }
             }
         } else {
             if (is_empty($post['query'])) {
                 $found = TRUE;
             }
         }
         if ($found === TRUE) {
             $results[$object['ID']] = $object;
         }
     }
     return $results;
 }