Eileen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/282085

Change subject: NFC preliminary tidy up for CRM-18332
......................................................................

NFC preliminary tidy up for CRM-18332

Change-Id: I5d01d193e0560f501eedf94531ba53a6f62350fd
---
M CRM/Logging/ReportDetail.php
M CRM/Logging/Reverter.php
2 files changed, 36 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm/civicrm 
refs/changes/85/282085/1

diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php
index 1077dd2..20a5290 100644
--- a/CRM/Logging/ReportDetail.php
+++ b/CRM/Logging/ReportDetail.php
@@ -28,9 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2016
  */
 class CRM_Logging_ReportDetail extends CRM_Report_Form {
   protected $cid;
@@ -50,13 +48,18 @@
   protected $summary;
 
   /**
+   * Don't display the Add these contacts to Group button.
+   *
+   * @var bool
+   */
+  protected $_add2groupSupported = FALSE;
+
+  /**
+   * Class constructor.
    */
   public function __construct() {
-    // don’t display the ‘Add these Contacts to Group’ button
-    $this->_add2groupSupported = FALSE;
 
-    $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) 
: DB::parseDSN(CIVICRM_DSN);
-    $this->db = $dsn['database'];
+    $this->setDB();
 
     $this->getPropertiesFromUrl();
 
@@ -83,16 +86,8 @@
     );
     CRM_Utils_System::appendBreadCrumb($breadcrumb);
 
-    if (CRM_Utils_Request::retrieve('revert', 'Boolean', 
CRM_Core_DAO::$_nullObject)) {
-      $reverter = new CRM_Logging_Reverter($this->log_conn_id, 
$this->log_date);
-      $reverter->revert($this->tables);
-      CRM_Core_Session::setStatus(ts('The changes have been reverted.'), 
ts('Reverted'), 'success');
-      if ($this->cid) {
-        
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));
-      }
+    if (CRM_Utils_Request::retrieve('revert', 'Boolean')) {
+      $this->revert();
     }
 
     // make sure the report works even without the params
@@ -218,11 +213,6 @@
   public function buildQuickForm() {
     parent::buildQuickForm();
 
-    $params = array(
-      1 => array($this->log_conn_id, 'String'),
-      2 => array($this->log_date, 'String'),
-    );
-
     $this->assign('whom_url', CRM_Utils_System::url('civicrm/contact/view', 
"reset=1&cid={$this->cid}"));
     $this->assign('who_url', CRM_Utils_System::url('civicrm/contact/view', 
"reset=1&cid={$this->altered_by_id}"));
     $this->assign('whom_name', $this->altered_name);
@@ -247,6 +237,29 @@
     $this->altered_name = CRM_Utils_Request::retrieve('alteredName', 'String', 
CRM_Core_DAO::$_nullObject);
     $this->altered_by = CRM_Utils_Request::retrieve('alteredBy', 'String', 
CRM_Core_DAO::$_nullObject);
     $this->altered_by_id = CRM_Utils_Request::retrieve('alteredById', 
'Integer', CRM_Core_DAO::$_nullObject);
+   }
+
+   /**
+   * Store the dsn for the logging database in $this->db.
+   */
+  protected function setDB() {
+    $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) 
: DB::parseDSN(CIVICRM_DSN);
+    $this->db = $dsn['database'];
+  }
+
+  /**
+   * Revert the changes defined by the parameters.
+   */
+  protected function revert() {
+    $reverter = new CRM_Logging_Reverter($this->log_conn_id, $this->log_date);
+    $reverter->revert($this->tables);
+    CRM_Core_Session::setStatus(ts('The changes have been reverted.'), 
ts('Reverted'), 'success');
+    if ($this->cid) {
+      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));
+    }
   }
 
 }
diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php
index 4ad0663..411b823 100644
--- a/CRM/Logging/Reverter.php
+++ b/CRM/Logging/Reverter.php
@@ -28,9 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2016
  */
 class CRM_Logging_Reverter {
   private $db;

-- 
To view, visit https://gerrit.wikimedia.org/r/282085
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d01d193e0560f501eedf94531ba53a6f62350fd
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm/civicrm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to