/** * display the form */ public function display() { global $mod_strings, $current_user, $current_language; $this->ss->assign("MOD", $mod_strings); $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']); // lookup this module's $mod_strings to get the correct module name $old_mod_strings = $mod_strings; $module_mod_strings = return_module_language($current_language, $_REQUEST['import_module']); $this->ss->assign("MODULENAME", $module_mod_strings['LBL_MODULE_NAME']); // reset old ones afterwards $mod_strings = $old_mod_strings; $last_import = new UsersLastImport(); $this->ss->assign('UNDO_SUCCESS', $last_import->undo($_REQUEST['import_module'])); $this->ss->assign("JAVASCRIPT", $this->_getJS()); $this->ss->display('modules/Import/tpls/undo.tpl'); }
} if (!isset($_REQUEST['return_id'])) { $_REQUEST['return_id'] = ''; } if (!isset($_REQUEST['return_module'])) { $_REQUEST['return_module'] = ''; } if (!isset($_REQUEST['return_action'])) { $_REQUEST['return_action'] = ''; } $parenttab = getParenttab(); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $log->info("Import Undo"); $last_import = new UsersLastImport(); $ret_value = $last_import->undo($current_user->id); // vtlib customization: Invoke undo import function of the module. $module = $_REQUEST['module']; $undo_focus = CRMEntity::getInstance($module); if (method_exists($undo_focus, 'undo_import')) { $ret_value += $undo_focus->undo_import($module, $current_user->id); } // END ?> <br> <table align="center" cellpadding="5" cellspacing="0" width="95%" class="mailClient importLeadUI small"> <tr> <td bgcolor="#FFFFFF" height="50" valign="middle" align="left" class="mailClientBg genHeaderSmall"> <?php
/** * @ticket 21828 */ public function testUndoRemovedAddedEmailAddresses() { $time = date('Y-m-d H:i:s'); $unid = uniqid(); $focus = new Account(); $focus->id = "Account_" . $unid; $focus->save(); $last_import = new UsersLastImport(); $last_import->assigned_user_id = $GLOBALS['current_user']->id; $last_import->import_module = 'Accounts'; $last_import->bean_type = 'Account'; $last_import->bean_id = $focus->id; $last_import->save(); $this->email_addr_bean_rel_id = 'email_addr_bean_rel_' . $unid; $this->email_address_id = 'email_address_id_' . $unid; $GLOBALS['db']->query("insert into email_addr_bean_rel (id , email_address_id, bean_id, bean_module, primary_address, date_created , date_modified) values ('{$this->email_addr_bean_rel_id}', '{$this->email_address_id}', '{$focus->id}', 'Accounts', 1, '{$time}', '{$time}')"); $GLOBALS['db']->query("insert into email_addresses (id , email_address, email_address_caps, date_created, date_modified) values ('{$this->email_address_id}', '*****@*****.**', '*****@*****.**', '{$time}', '{$time}')"); // setup require 'include/modules.php'; $GLOBALS['beanList'] = $beanList; $GLOBALS['beanFiles'] = $beanFiles; $this->assertTrue($last_import->undo($last_import->import_module)); // teardown unset($GLOBALS['beanList']); unset($GLOBALS['beanFiles']); $result = $GLOBALS['db']->query("SELECT * FROM email_addr_bean_rel where id = '{$this->email_addr_bean_rel_id}'"); $rows = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse($rows); $result = $GLOBALS['db']->query("SELECT * FROM email_addresses where id = '{$this->email_address_id}'"); $rows = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse($rows); $GLOBALS['db']->query("DELETE FROM users_last_import WHERE id = '{$last_import->id}'"); }
/** * If a bean save is not done for some reason, this method will undo any of the beans that were created * * @param array $ids ids of user_last_import records created */ protected function _undoCreatedBeans(array $ids) { $focus = new UsersLastImport(); foreach ($ids as $id) { $focus->undo($id); } }