/** * Save the FormField to the database. * @param I2CE_FormField $form_field * @param boolean $do_check : A flag to determine if a check should be made for the same value being saved. * @param I2CE_User $user: The user saving this data. * @return boolean */ public function FF_save($form_field, $do_check, $user) { if (!$form_field->isInDB()) { return true; } if ($form_field->getDBValue() != "" && !$form_field->isValid()) { return true; } $form_config = $this->getFormConfig($form_field, true); if (!$form_config instanceof I2CE_MagicDataNode) { return false; } $fields_config = $form_config->fields; if (!$fields_config instanceof I2CE_MagicDataNode) { return false; } $field_name = $form_field->getName(); if (!is_string($field_name) || strlen($field_name) == 0) { return false; } $fields_config->{$field_name} = $form_field->getDBValue(); return true; }
/** * Save the FormField to the database. * @param I2CE_FormField $form_field * @param boolean $do_check : A flag to determine if a check should be made for the same value being saved. * @param I2CE_User $user: The user saving this data. * @return boolean */ public function FF_save($form_field, $do_check, $user) { if (!$form_field->isInDB()) { return true; } if ($form_field->getDBValue() != "" && !$form_field->isValid()) { return true; } $form_config = $this->getFormConfig($form_field, true); if (!$form_config instanceof I2CE_MagicDataNode) { return false; } $fields_config = $form_config->fields; if (!$fields_config instanceof I2CE_MagicDataNode) { return false; } $field_name = $form_field->getName(); if (!I2CE_MagicDataNode::checkKey($field_name)) { return false; } $field_config = $fields_config->traverse($field_name, true, false); if (!$field_config instanceof I2CE_MagicDataNode) { return false; } if ($form_field->getMDB2Type() == 'blob') { $field_config->setAttribute('binary', 1); $field_config->setAttribute('encoding', 'base64'); $field_config->setValue(base64_encode($form_field->getDBValue())); } else { $field_config->setValue($form_field->getDBValue()); } return true; }