Beispiel #1
0
/**
 * Revert a log change.
 *
 * @param array $params
 *
 * @return array
 *    API Success Array
 * @throws \API_Exception
 * @throws \Civi\API\Exception\UnauthorizedException
 */
function civicrm_api3_logging_revert($params)
{
    $schema = new CRM_Logging_Schema();
    $reverter = new CRM_Logging_Reverter($params['log_conn_id'], CRM_Utils_Array::value('log_date', $params));
    $reverter->calculateDiffsFromLogConnAndDate($schema->getLogTablesForContact());
    $reverter->revert();
    return civicrm_api3_create_success(1);
}
 /**
  * Revert the changes defined by the parameters.
  */
 protected function revert()
 {
     $reverter = new CRM_Logging_Reverter($this->log_conn_id, $this->log_date);
     $reverter->calculateDiffsFromLogConnAndDate($this->tables);
     $reverter->revert();
     CRM_Core_Session::setStatus(ts('The changes have been reverted.'), ts('Reverted'), 'success');
     if ($this->cid) {
         if ($this->oid) {
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/merge', "reset=1&cid={$this->cid}&oid={$this->oid}", FALSE, NULL, FALSE));
         } else {
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE));
         }
     } else {
         CRM_Utils_System::redirect(CRM_Report_Utils_Report::getNextUrl($this->summary, 'reset=1', FALSE, TRUE));
     }
 }