Beispiel #1
0
 public static function generateFormSelectList($objectID = NULL)
 {
     if (isnull($objectID) && ($forms = forms::getObjectForms(TRUE)) === FALSE) {
         return FALSE;
     } else {
         if (!isnull($objectID) && ($forms = forms::getObjectProjectForms($objectID)) === FALSE) {
             return FALSE;
         }
     }
     if (($currentProjects = users::loadProjects()) === FALSE) {
         return FALSE;
     }
     $currentProjectFormList = '<h1 class="pickListHeader">Current Projects:</h1> <br /><ul class="pickList">';
     $formList = '<h1 class="pickListHeader">All Other Forms:</h1> <br /><ul class="pickList">';
     foreach ($forms as $form) {
         if ($form === FALSE) {
             continue;
         }
         if (!mfcsPerms::isViewer($form['ID'])) {
             continue;
         }
         foreach ($currentProjects as $projectID => $projectName) {
             if (forms::checkFormInProject($projectID, $form['ID'])) {
                 $currentProjectFormList .= sprintf('<li><a href="object.php?formID=%s%s" class="btn">%s</a></li>', htmlSanitize($form['ID']), !isnull($objectID) ? "&amp;parentID=" . $objectID : "", forms::title($form['ID']));
                 continue 2;
             }
         }
         $formList .= sprintf('<li><a href="object.php?formID=%s%s" class="btn">%s</a></li>', htmlSanitize($form['ID']), !isnull($objectID) ? "&amp;parentID=" . $objectID : "", forms::title($form['ID']));
     }
     $formList .= "</ul>";
     $currentProjectFormList .= "</ul>";
     return $currentProjectFormList . $formList;
 }
Beispiel #2
0
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;
    }
}
// End Checks
$mfcsSearch = new mfcsSearch();
// Load the user's current projects
sessionSet('currentProject', users::loadProjects());
recurseInsert("includes/functions.php", "php");
recurseInsert("includes/validator.php", "php");
$engine->eTemplate("load", "distribution");
localVars::add("siteRoot", mfcs::config("siteRoot"));
localVars::add('pageTitle', mfcs::config("pageTitle"));
localVars::add('pageHeader', mfcs::config("pageHeader"));
Beispiel #3
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;
 }