Exemplo n.º 1
0
 /**
  * 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 instanceof I2CE_FormField_STRING_PASS) {
         return false;
     }
     if ($form_field->hasAttribute('populated_history') && $form_field->getAttribute('populated_history')) {
         return true;
     }
     $storageMechanism = self::getStorageMechanism($form_field->getContainer()->getName());
     if (!$storageMechanism) {
         return false;
     }
     $form_field->setAttribute('populated_history', 1);
     return $storageMechanism->FF_populateHistory($form_field);
 }
 /**
  * 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;
 }