} if (isset($engine->cleanGet['MYSQL']['parentID']) && objects::validID(TRUE, $engine->cleanGet['MYSQL']['parentID']) === FALSE) { throw new Exception("ParentID Provided is invalid."); } // if an object ID is provided make sure the object is from this form if (!isnull($engine->cleanGet['MYSQL']['objectID']) && !objects::checkObjectInForm($engine->cleanGet['MYSQL']['formID'], $engine->cleanGet['MYSQL']['objectID'])) { throw new Exception("Object not from this form."); } if (($form = forms::get($engine->cleanGet['MYSQL']['formID'])) === FALSE) { throw new Exception("Error retrieving form."); } if (forms::isProductionReady($engine->cleanGet['MYSQL']['formID']) === FALSE) { $permissions = FALSE; throw new Exception("Form is not production ready."); } if (forms::isMetadataForm($engine->cleanGet['MYSQL']['formID'])) { throw new Exception("Metadata form provided (Object forms only)."); } /* Parent Object 'Stuff' */ if (isset($engine->cleanGet['MYSQL']['parentID']) && ($parentObject = objects::get($engine->cleanGet['MYSQL']['parentID'])) === FALSE) { throw new Exception("Unable to retrieve parent object"); } /* End Parent Object 'Stuff' */ // Editor information if (!isnull($engine->cleanGet['MYSQL']['objectID'])) { $object = objects::get($engine->cleanGet['MYSQL']['objectID']); if (is_empty($object['createdBy'])) { localvars::add("createdByUsername", "Unavailable"); } else { $user = users::get($object['createdBy']); localvars::add("createdByUsername", $user['username']);
http::setGet("objectID", $engine->cleanPost['MYSQL']['objectID']); } if (objects::validID() === FALSE) { throw new Exception("ObjectID Provided is invalid."); } if (($object = objects::get($engine->cleanGet['MYSQL']['objectID'])) === FALSE) { throw new Exception("Error retrieving Object"); } if (($form = forms::get($object['formID'])) === FALSE) { throw new Exception("Error retrieving form."); } if (mfcsPerms::isAdmin($object['formID']) === FALSE) { $permissions = FALSE; throw new Exception("Permission Denied to view objects created with this form."); } if (forms::isMetadataForm($object['formID']) === FALSE) { throw new Exception("Object provided (Only Metadata can be moved)."); } // handle submission $return = NULL; if (isset($engine->cleanPost['MYSQL']['moveMetadata'])) { } if (($compatibleForms = forms::compatibleForms($form['ID'])) === FALSE) { throw new Exception("Error getting compatible forms"); } $temp = '<option value="NULL">-- Select an Item --</option>'; foreach ($compatibleForms as $cform) { $temp .= sprintf('<option value="%s">%s</option>', $cform['ID'], forms::title($cform['ID'])); } localvars::add("originalFormTitle", forms::title($form['ID'])); localvars::add("compatibleForms", $temp);
public static function buildEditTable($formID) { $form = self::get($formID); // Get all objects from this form $objects = objects::getAllObjectsForForm($formID); $objects = objects::sort($objects, $form['objectTitleField']); // If the data is too large, setup pagination if (sizeof($objects) > mfcs::config("metadataPageCount")) { $pagination = new pagination(sizeof($objects)); $pagination->itemsPerPage = mfcs::config("metadataPageCount"); $pagination->currentPage = isset(mfcs::$engine->cleanGet['MYSQL'][$pagination->urlVar]) ? mfcs::$engine->cleanGet['MYSQL'][$pagination->urlVar] : 1; $startPos = $pagination->itemsPerPage * ($pagination->currentPage - 1); $objects = array_slice($objects, $startPos, $pagination->itemsPerPage); } if (count($objects) > 0) { $headers = array(); $headers[] = "Delete"; foreach ($form['fields'] as $field) { $headers[] = $field['label']; } if (forms::isMetadataForm($formID) === TRUE) { $headers[] = "Search"; $headers[] = "Move"; } $tableRows = array(); for ($I = 0; $I < count($objects); $I++) { $temp = array(); $temp[] = sprintf('<input type="checkbox" name="delete[]" value="%s"', $objects[$I]['ID']); foreach ($form['fields'] as $field) { $temp[] = sprintf('<input type="%s" style="%s" name="%s_%s" value="%s" />', $field['type'], $field['style'], $field['name'], $objects[$I]['ID'], isset($objects[$I]['data'][$field['name']]) ? htmlSanitize($objects[$I]['data'][$field['name']]) : ""); } if (forms::isMetadataForm($formID) === TRUE) { $temp[] = sprintf('<a href="%sdataView/list.php?listType=metadataObjects&formID=%s&objectID=%s">Find Objects</a>', localvars::get('siteRoot'), htmlSanitize($formID), $objects[$I]['ID']); $temp[] = sprintf('<a href="%sdataEntry/move.php?objectID=%s">Move</a>', localvars::get('siteRoot'), $objects[$I]['ID']); } $tableRows[] = $temp; } $table = new tableObject("array"); $table->summary = "Object Listing"; $table->class = "tableObject table table-striped table-bordered"; $table->headers($headers); $output = ""; // Add in pagination bar if (isset($pagination)) { $output .= $pagination->nav_bar(); } $output .= sprintf('<form action="%s?formID=%s" method="%s" name="updateForm" data-formid="%s">', $_SERVER['PHP_SELF'], htmlSanitize($formID), "post", mfcs::$engine->openDB->escape($formID)); $output .= sessionInsertCSRF(); $output .= $table->display($tableRows); $output .= '<input type="submit" name="updateEdit" value="Update" class="btn" />'; $output .= "</form>"; // Add in pagination bar if (isset($pagination)) { $output .= $pagination->nav_bar(); } return $output; } else { return "No data entered for this Metadata Form."; } }
</ul> </form> </div> </div> </div> </div> </div> <?php if (!isnull($formID)) { ?> <?php if (!forms::isMetadataForm($formID)) { ?> <div class="tab-pane" id="projects"> <h2>Change Project Membership</h2> <form action="{phpself query="true"}" method="post"> {local var="projectOptions"} {engine name="csrf"} <input type="submit" class="btn btn-primary" name="projectForm" disabled> <noscript><p style="color:red; text-align: center; font-weight: bold;">JavaScript failed to load!</p></noscript> </form> </div> <?php } ?>