}
/**
+ * Revert changes in the array of diffs in $this->diffs.
+ *
* @param $tables
*/
public function revert($tables) {
- // FIXME: split off the table → DAO mapping to a GenCode-generated class
- $daos = array(
- 'civicrm_address' => 'CRM_Core_DAO_Address',
- 'civicrm_contact' => 'CRM_Contact_DAO_Contact',
- 'civicrm_email' => 'CRM_Core_DAO_Email',
- 'civicrm_im' => 'CRM_Core_DAO_IM',
- 'civicrm_openid' => 'CRM_Core_DAO_OpenID',
- 'civicrm_phone' => 'CRM_Core_DAO_Phone',
- 'civicrm_website' => 'CRM_Core_DAO_Website',
- 'civicrm_contribution' => 'CRM_Contribute_DAO_Contribution',
- 'civicrm_note' => 'CRM_Core_DAO_Note',
- 'civicrm_relationship' => 'CRM_Contact_DAO_Relationship',
- );
// get custom data tables, columns and types
$ctypes = array();
foreach ($deletes as $table => $ids) {
CRM_Core_DAO::executeQuery("DELETE FROM `$table` WHERE id IN (" . implode(', ', array_unique($ids)) . ')');
}
-
// revert updates by updating to previous values
foreach ($reverts as $table => $row) {
switch (TRUE) {
// DAO-based tables
- case in_array($table, array_keys($daos)):
- $dao = new $daos[$table]();
+ case (($tableDAO = CRM_Core_DAO_AllCoreTables::getClassForTable($table)) != FALSE):
+ $dao = new $tableDAO ();
foreach ($row as $id => $changes) {
$dao->id = $id;
foreach ($changes as $field => $value) {