Class: I2CE FormStorage (4.0.19)

From IHRIS Wiki
Revision as of 15:55, 18 October 2011 by Litlfred (talk | contribs) (Created page with "{{otherversions|Class: I2CE_FormStorage}} This article describes the class ''I2CE_FormStorage'' . *Extends the class: I2CE_Module. *Location: Pa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This article describes the class I2CE_FormStorage .

I2CE_Module_FormStorage

Variables

$lastListCount

A list of forms with the last count returned for listDisplayFields

$componentized_forms

A cached list of componentized forms. array of string, the form names

$storage

An array with a cache of the storage type for a form.

$storageMechs

An array with a cache of the storage mechanisms

$store_stmt

Insert statment for storing form history

Methods

FF_IG_save()

Save the FormField to the database.

FF_IG_setSequence()

Set the value of this field to the next sequence for the form field.

FF_SP_save()

Save the FormField_STRING_PASS to the database.

FF_populateHistory()

Populate the history of entries for the form field if the storage module handles history.

FF_save()

Save the FormField to the database.

_populate()

Internal worker method to populate a form object.

_save()

Internal worker method to save a form object.

action_initialize()

Method called when the module is enabled for the first time. @param boolean -- returns true on success. false on error.

addChild()

add the given child to the form for this object.

changeFormID()

Change the id of the given form

changeID()

Change the id of the given form @param I2CE_Form $formObj

delete()

Delete a form object.

exportData()

Move data for a form from one storage mechansim to another

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 376
  • Signature: static public function exportData($form,$target,$user,$ids)
  • Parameters:
    • string $form
      The form
    • I2CE_FormStorage_Mechansim $target
    • I2CE_User $user
      The user object used to save the data to the target storage mechanism
    • mixed $ids
      An id or an array of the ids we wish to move. Defaults to null, in which case all id's are moved
      • Default Value: null
  • Returns: boolean.
    true on success

getCLIHooks()

getChildIds()

Gets the id's for the given child for this form.

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 1208
  • Signature: public function getChildIds($form,$child_form_name,$order_by,$where,$limit)
  • Parameters:
    • I2CE_Form $form
    • string $child_form_name
      the child form name
    • mixed $order_by
      A string or array of strings. The fields to oreder by . defaults to empty array.
      • Default Value: array()
    • $where
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
  • Returns: array

getComponentizedForms()

static function which gets a list of all componentized forms

getHooks()

getLastListCount()

Return the last results from a search query for a form.

getMechanismByStorage()

Returns the storage mechanism for the given storage type.

getMethods()

getMigratedValue()

Get the new value for a field that has been migrated.

getNewMigratedValue()

Get the new migrated value for from the old value. @param mixed $old_id

getOldMigratedValue()

Get the old value for a field that has been migrated.

getRecords()

Return an array of all the record ids for a given form.

getStorage()

Return the storage class for the given form.

getStorageMechanism()

globalChangeParent()

method to remap a given id

globalChangeParent_hook()

Hooked method update all all parent fields refering to a given id

globalFieldUpdate()

method to remap all instances of given field on a given form and field @param $fieldObj I2CE_FormField

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 186
  • Signature: public function globalFieldUpdate($fieldObj,$where,$set_func,$set_sql)
  • Parameters:
    • $fieldObj
    • array $where
      Array of where data
    • callable $set_func
      the php used to update the field
    • string $set_sql
      Optional. sql used to update the field. Defaults to false. If present used by DB like form storage mechansims to do a global update rather than a record by record
      • Default Value: false

hasRecord()

Checks if the given record exists.

importData()

Move data for a form from one storage mechansim to another @param I2CE_FormStorage_Mechansim $target

isComponentized()

static function to determine if a form is componentized

isComponentizedForm()

Fuzzy method to check if a form instance is componentized

isWritable()

Check to see if this form is considered to be writable.

listDisplayFields()

Lists the display values for a field

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 1022
  • Signature: static public function listDisplayFields($form,$fields,$parent,$where_data,$ordering,$limit,$mod_time)
  • Parameters:
    • string $form
      The form name
    • array $fields
      of string. The fields we want returned Can include the special field 'last_modified' to get the last modification time for any of the fields of that form which is returned in the format "Y-m-d H:i:s"
    • boolean $parent
      Defaults to false. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id.
      • Default Value: false
    • mixed $where_data
      Either I2CE_MagicDataNode or array. contains the where clause information about this form or a nested
      • Default Value: array()
    • array $ordering
      An array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
    • integer $mod_time
      Defaults to -1. If non-negative, we only list the requested fields for an id if at least one of them has a modification time greater than or equal to $mod_time. If the form storage has no way of tracking modifucation time, all entries are listed.
      • Default Value: -1
  • Returns: mixed
    an array with key id's and value and array of values. the array of values has as keys the fields with their corresponding value.

listFields()

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 995
  • Signature: static public function listFields($form,$fields,$parent,$where_data,$ordering,$limit,$mod_time)
  • Parameters:
    • string $form
      The form name
    • array $fields
      of string. The fields we want returned. Can include the special field 'last_modified' to get the last modification time for any of the fields of that form which is returned in the format "Y-m-d H:i:s"
    • boolean $parent
      Defaults to false. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id.
      • Default Value: false
    • mixed $where_data
      Either I2CE_MagicDataNode or array. contains the where clause information about this form or a nested
      • Default Value: array()
    • array $ordering
      An array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
    • integer $mod_time
      Defaults to -1. If non-negative, we only list the requested fields for an id if at least one of them has a modification time greater than or equal to $mod_time. If the form storage has no way of tracking modifucation time, all entries are listed.
      • Default Value: -1
  • Returns: mixed
    an array with key id's and value and array of values. the array of values has as keys the fields with their corresponding value.

lookupDisplayField()

Looks up the display value of the item based on the code. This is the default method that most implementations of lookup () use. It finds the description of the object based on the code and saves it in the cache and returns it.

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 966
  • Signature: static public function lookupDisplayField($form,$id,$fields,$delim)
  • Parameters:
    • string $form
      The name of the form in the database.
    • integer $id
      The code of the entry to lookup.
    • mixed $fields
      A field or an array of fields to look up and return. Defaults to 'name'
      • Default Value: array('name')
    • string $delim
      The delimiter to put between returned fields if there are more than one. If false , then we return as an array. Defaults to '-'
      • Default Value: ' - '
  • Returns: string
    or false on failure

lookupField()

Looks up the dbvalue of the item based on the code. This is the default method that most implementations of lookup () use. It finds the description of the object based on the code and saves it in the cache and returns it.

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 939
  • Signature: static public function lookupField($form,$id,$fields,$delim)
  • Parameters:
    • string $form
      The name of the form in the database.
    • integer $id
      The code of the entry to lookup.
    • mixed $fields
      A field or an array of fields to look up and return. Defaults to 'name'
      • Default Value: array('name')
    • string $delim
      The delimiter to put between returned fields if there are more than one. If false , then we return as an array. Defaults to '-'
      • Default Value: '-'
  • Returns: string
    or false on failure

migrateField()

Migrate field data from an old setMap reference to a new MAP form field type. The old data should have been saved in a migrate_data magic data (see storeMigrateData ).

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 826
  • Signature: static public function migrateField($form_name,$field_list,$migrate_path,$user)
  • Parameters:
    • string $form_name
    • array $field_list
      The list of fields that need to be changed as an array of field => map_form. Optionally the field list can be: array( "field" => array( "prev_field" => "prev_map_form" ) ) The field will get the old value from the list of fields (with mapped forms) for when the field name was changed.
    • string $migrate_path
      Where the migrate data has been saved.
    • I2CE_User $user
      The user to save the new form field.
  • Returns: boolean

migrateForm()

Migrate a given form from one storage method to the current storage method. This should only be used when upgrading a module that moved a form storage from one type to another.

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 661
  • Signature: static public function migrateForm($form_name,$storage,$user,$migrate_path,$id_field,$skip_fields,$migrate_fields,$callback)
  • Parameters:
    • string $form_name
    • string $storage
      The old storage mechanism
    • I2CE_User $user
      The user object to use to save the new forms.
    • string $migrate_path
      The full path in MagicData to save the old to new mappings.
      • Default Value: false
    • string $id_field
      The old field name to use the value of for the new form id.
      • Default Value: false
    • array $skip_fields
      A list of fields to not migrate to the new form.
      • Default Value: array()
    • array $migrate_fields
      A list of fields that have already been migrated and need to use the migrate path to convert the data. Format is array( "field" => "map_form" ) These forms and fields should have already been passed to storeMigrateData so the data can be retrieved from there.
      • Default Value: array()
    • $callback
      • Default Value: null
  • Returns: boolean

moveData()

Move data for a form from one storage mechansim to another

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 327
  • Signature: static public function moveData($form,$source,$target,$user,$ids)
  • Parameters:
    • string $form
      The form
    • I2CE_FormStorage_Mechansim $source
    • I2CE_FormStorage_Mechansim $target
    • I2CE_User $user
      The user object used to save the data to the target storage mechanism
    • mixed $ids
      An id or an array of the ids we wish to move. Defaults to null, in which case all id's are moved
      • Default Value: null
  • Returns: boolean.
    true on success

populate()

Use method to populate a form object.

populateChild()

Populate all instances of the given child form for this object.

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 1250
  • Signature: public function populateChild($form,$form_name,$order_by,$where,$type)
  • Parameters:
    • I2CE_Form $form
    • string $form_name
      The form name to populate
    • mixed $order_by
      A field or array of fields to sort by. Preceded by "-" to sort in reverse order. - array( "-start_date", "name" ). Defaults to null in which case if get the default sort order that is registered for the type (which defaults to none) @param mixed @where an aarray of where information to limit getting the child id's by. If null, we get the default limits for the type (which defaults to none)
      • Default Value: null
    • $where
      • Default Value: null
    • string $type
      Defaults to 'default'
      • Default Value: 'default'

populateChildren()

Populate the given child form for this object.

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 1293
  • Signature: public function populateChildren($form,$forms,$orderBy)
  • Parameters:
    • I2CE_Form $form
    • mixed $forms
      A string or an array such, the form names (the child forms to populate) - array( "demographic", "contact" )
    • array $orderBy
      An associative array of form names with an array of either string, field to sort by or an array of the fields Defaults to empty array - array( "contact" => "contact_type" )
      • Default Value: array()

populateFirst()

Populate the first child of a form object based on the given field

populateHistory()

Populate Last of a form object.

populateLast()

Populate the last child of a form object based on the given field

save()

User method to save a form object.

search()

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 898
  • Signature: static public function search($form,$parent,$where_data,$ordering,$limit)
  • Parameters:
    • string $form
      The form name.
    • boolean $parent
      Defaults to false. If it is scalar and non-boolean, it is consider to be the ID of the parent, and then we get all forms with parent the given id.
      • Default Value: false
    • mixed $where_data
      array or class implementing ArrayAccess, Iterator, and Countable (e.g. MagicDataNode) . the where data.
      • Default Value: array()
    • mixed $ordering
      An field or an array of fields to order by. Defaults to the empty array. Prepend a - to order by in descending order.
      • Default Value: array()
    • mixed $limit
      Defaults to false. It true, returns only one result. If an integer it is the numeber of records to limit to. If it is as an array of two integers, it is the offset and then number of results to limit to.
      • Default Value: false
  • Returns: mixed
    an array of matching form ids. However, ff $limit_one is true or 1 or array ($offset,1) then then we return either the id or false, if none found or there was an error.

setChangeType()

Set the change type for the given form. If this method isn't called then the change type will be I2CE_FormStorage::CHANGE_UPDATE

  • Defined in i2ce/modules/Forms/modules/FormStorage/lib/I2CE_FormStorage.php on line 1326
  • Signature: public function setChangeType($form,$change_type,$field)
  • Parameters:
    • I2CE_Form $form
    • integer $change_type
      the change type to set Defautls to I2CE_FormStorage::CHANGE_UPDATE
      • Default Value: I2CE_FormStorage_Mechanism::CHANGE_UPDATE
    • string $field
      Defaults to 'default'. optional field name to set the change type to.
      • Default Value: 'default'

setLastListCount()

Add the last results from a search query for a form.

storeHistory()

Store the history for a form I2CE_Form $form

storeMigrateData()

Save the given fields to the given magic data node so it can later be referenced when migrating the form.

upgrade()

Upgrade module method

validate_formfield()

Hooked Function to check if a field is unique or unique restricted to a certain field

Inherited Methods

__construct()

This public method is inherited from I2CE_Module->__construct()

action_configure()

This public method is inherited from I2CE_Module->action_configure()

action_disable()

This public method is inherited from I2CE_Module->action_disable()

action_enable()

This public method is inherited from I2CE_Module->action_enable()

getCLIMethods()

This public method is inherited from I2CE_Module->getCLIMethods()

getConfig()

This public method is inherited from I2CE_Module->getConfig()

post_update()

This public method is inherited from I2CE_Module->post_update()

pre_upgrade()

This public method is inherited from I2CE_Module->pre_upgrade()

_hasMethod()

This public method is inherited from I2CE_Fuzzy->_hasMethod()

Inherited Fuzzy Methods

launchBackgroundProcess()

This method is inherited from I2CE_Module->launchBackgroundProcess()

launchBackgroundPHPScript()

This method is inherited from I2CE_Module->launchBackgroundPHPScript()

launchBackgroundPage()

This method is inherited from I2CE_Module->launchBackgroundPage()

userMessage()

This method is inherited from I2CE_Fuzzy->userMessage()