/** * Populate the history of entries for the form field if the storage module handles history. * @param I2CE_FormField $form_field * @return boolean */ public function FF_populateHistory($form_field) { $field = $form_field->getName(); $form = $form_field->getContainer(); if (!$form instanceof I2CE_Form) { return false; } $field_name = $form_field->getName(); $fields = $this->lookupField($form->getName(), $form->getId(), array($field_name), false); if (!is_array($fields) || !array_key_exists($field_name, $fields)) { //no data to populate return true; } $last_modified = I2CE_Date::blank(); $entry = new I2CE_Entry($last_modified, 1, 0, $form_field->getFromDB($fields[$field_name])); $form_field->addHistory($entry); return true; }
/** * Populate the history of entries for the form field if the storage module handles history. * @param I2CE_FormField $form_field * @return boolean */ public function FF_populateHistory($form_field) { $field = $form_field->getName(); $form = $form_field->getContainer(); if (!$form instanceof I2CE_Form) { return false; } if ($field == 'parent') { $fieldQry = $this->getRequiredFieldsQuery($form->getName(), array('last_modified', 'who'), $form->getId(), true); } else { $fieldQry = $this->getRequiredFieldsQuery($form->getName(), array($field, 'last_modified', 'who'), $form->getId()); } $result = $this->db->getRow($fieldQry); if (I2CE::pearError($result, "Error populating field {$field} of form " . $form->getName())) { return false; } $ref = $form->getName() . '+' . $field; $last_ref = $form->getName() . '+' . 'last_modified'; $who_ref = $form->getName() . '+' . 'who'; $date = null; $who = 99; if (isset($result->{$last_ref})) { $date = I2CE_Date::fromDB($result->{$last_ref}); } if (!$date instanceof I2CE_Date) { $date = I2CE_Date::blank(); } if (isset($result->{$who_ref})) { $who = $result->{$who_ref}; } if (isset($result->{$ref})) { $entry = new I2CE_Entry($date, $who, 0, $form_field->getFromDB($result->{$ref})); $form_field->addHistory($entry); } return true; }
/** * Populate the history of entries for the form field if the storage module handles history. * @param I2CE_FormField $form_field * @return boolean */ public function FF_populateHistory($form_field) { $field = $form_field->getName(); $form = $form_field->getContainer(); if (!$form instanceof I2CE_Form) { return false; } $fieldQry = $this->getRequiredFieldsQuery($form->getName(), array($field), $form->getId()); $result = $this->db->getRow($fieldQry); if (I2CE::pearError($result, "Error populating field {$field} of form " . $form->getName())) { return false; } $ref = strtolower($form->getName() . '+' . $field); $entry = new I2CE_Entry(I2CE_Date::blank(), 1, 0, $form_field->getFromDB($result->{$ref})); $form_field->addHistory($entry); return true; }
/** * Populate the history of entries for the form field if the storage module handles history. * @param I2CE_FormField $form_field * @return boolean */ public function FF_populateHistory($form_field) { if ($form_field->getName() == 'parent') { $sth = $this->db->prepare("SELECT last_modified AS date,0 AS who,0 AS change_type, CONCAT(parent_form,'|',parent_id) as value FROM record WHERE id = ? ", array("integer"), MDB2_PREPARE_RESULT); if (I2CE::pearError($sth, "Error preparing to populate history:")) { return false; } $result = $sth->execute(array($form_field->getContainer()->getId())); } else { if (!($formObj = $form_field->getContainer()) instanceof I2CE_Form) { return false; } $this->setupForm($formObj); $sth = $this->db->prepare("SELECT date,who,change_type," . $form_field->getTypeString() . "_value as value FROM entry WHERE record = ? AND form_field = ? ORDER BY date", array("integer", "integer"), MDB2_PREPARE_RESULT); if (I2CE::pearError($sth, "Error preparing to populate history:")) { return false; } $result = $sth->execute(array($form_field->getContainer()->getId(), $form_field->getAttribute("DBEntry_form_field_id"))); if (I2CE::pearError($result, "Error executing populate history: ")) { return false; } } $has_been_set = false; while ($data = $result->fetchRow()) { if (!$has_been_set && !isset($data->value)) { continue; } $has_been_set = true; $entry = new I2CE_Entry(I2CE_Date::fromDB($data->date), $data->who, $data->change_type, $form_field->getFromDB($data->value)); $form_field->addHistory($entry); } $result->free(); $sth->free(); return true; }