Merge pull request #5010 from eileenmcnaughton/rebase2
authorEileen McNaughton <eileen@mcnaughty.com>
Tue, 27 Jan 2015 04:44:25 +0000 (17:44 +1300)
committerEileen McNaughton <eileen@mcnaughty.com>
Tue, 27 Jan 2015 04:44:25 +0000 (17:44 +1300)
CRM-15798 function extraction on membership date calculation

30 files changed:
CRM/Case/BAO/Case.php
CRM/Case/Form/ActivityChangeStatus.php [deleted file]
CRM/Case/xml/Menu/Case.xml
CRM/Core/Payment/Dummy.php
CRM/Logging/ReportSummary.php
CRM/Member/BAO/Membership.php
CRM/Member/BAO/MembershipType.php
CRM/Report/Form/Contact/LoggingSummary.php
Civi/Payment/System.php
api/v3/Acl.php
api/v3/Activity.php
api/v3/Case.php
api/v3/Generic/Getlist.php
api/v3/Generic/Setvalue.php
api/v3/MembershipType.php
api/v3/Phone/Get.php
api/v3/Tag.php
templates/CRM/Case/Form/ActivityChangeStatus.tpl [deleted file]
templates/CRM/Case/Form/ActivityChangeStatusJs.tpl [deleted file]
templates/CRM/Case/Form/ActivityTab.tpl
templates/CRM/Case/Form/CaseView.tpl
templates/CRM/Case/Form/Search.tpl
templates/CRM/Case/Page/CaseDetails.tpl
templates/CRM/Case/Page/DashBoard.tpl
templates/CRM/Case/Page/DashboardSelector.tpl
templates/CRM/Case/Page/Tab.tpl
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContributionPageTest.php
tests/phpunit/api/v3/MembershipTest.php
tests/phpunit/api/v3/MembershipTypeTest.php

index a714634a0c8ab77edfc38b5c67608d42d3a2c043..7df56b3dc3ed493b59e6f98c6574d96cabf2af15 100644 (file)
@@ -1349,7 +1349,7 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
       }
 
       if ($allowEdit) {
-        $values[$dao->id]['status'] = '<a class="crm-activity-status crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . ' crm-activity-change-status crm-editable-enabled" activity_id=' . $dao->id . ' current_status=' . $dao->status . ' case_id=' . $caseID . ' href="#" title=\'' . $statusTitle . '\'>' . $values[$dao->id]['status'] . '</a>';
+        $values[$dao->id]['status'] = '<div class="crmf-status_id crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . ' crm-editable" data-type="select" data-action="create" data-refresh="true">' . $values[$dao->id]['status'] . '</div>';
       }
     }
     $dao->free();
diff --git a/CRM/Case/Form/ActivityChangeStatus.php b/CRM/Case/Form/ActivityChangeStatus.php
deleted file mode 100644 (file)
index 8c51e5f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
- */
-
-/**
- * This class generates form components for building changing activity status interface in a case
- *
- */
-class CRM_Case_Form_ActivityChangeStatus extends CRM_Core_Form {
-
-  /**
-   * Build the form object
-   *
-   * @return void
-   */
-  public function buildQuickForm() {
-    $activityStatus = CRM_Core_PseudoConstant::activityStatus();
-    $this->add('select', 'activity_change_status', ts('New Status'), $activityStatus);
-  }
-
-}
index 2fe5462c100579121ebfa3d2235d94d764d7cbb6..61bd8f28515e46c567e927c60453d9df10566908 100644 (file)
     <path>civicrm/ajax/delcaserole</path>
     <page_callback>CRM_Case_Page_AJAX::deleteCaseRoles</page_callback>
   </item>
-  <item>
-    <path>civicrm/case/changeactivitystatus</path>
-    <title>Change Activity Status</title>
-    <page_callback>CRM_Case_Form_ActivityChangeStatus</page_callback>
-  </item>
 </menu>
index 90fb06e5347be3034cd1b642bc0f72504d241c9e..8bcf9809f911fd6c572c1a422ac6ee2e5cf1ac85 100644 (file)
@@ -26,10 +26,19 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment {
   protected $_doDirectPaymentResult = array();
 
   /**
+   * Set result from do Direct Payment for test purposes.
+   *
    * @param array $doDirectPaymentResult
+   *  Result to be returned from test.
    */
   public function setDoDirectPaymentResult($doDirectPaymentResult) {
     $this->_doDirectPaymentResult = $doDirectPaymentResult;
+    if (empty($this->_doDirectPaymentResult['trxn_id'])) {
+      $this->_doDirectPaymentResult['trxn_id'] = array();
+    }
+    else {
+      $this->_doDirectPaymentResult['trxn_id'] = (array) $doDirectPaymentResult['trxn_id'];
+    }
   }
 
   /**
@@ -80,7 +89,9 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment {
     );
     //end of hook invocation
     if (!empty($this->_doDirectPaymentResult)) {
-      return $this->_doDirectPaymentResult;
+      $result = $this->_doDirectPaymentResult;
+      $result['trxn_id'] = array_shift($this->_doDirectPaymentResult['trxn_id']);
+      return $result;
     }
     if ($this->_mode == 'test') {
       $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test\\_%'";
@@ -115,10 +126,15 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment {
   }
 
   /**
-   * @param null $errorCode
-   * @param null $errorMessage
+   * Generate error object.
+   *
+   * Throwing exceptions is preferred over this.
+   *
+   * @param string $errorCode
+   * @param string $errorMessage
    *
-   * @return object
+   * @return CRM_Core_Error
+   *   Error object.
    */
   public function &error($errorCode = NULL, $errorMessage = NULL) {
     $e = CRM_Core_Error::singleton();
index 25f5d97ce96b26873bbe9e3a8f9a18e6fded635f..e345b0befadc0460efd851d86c0f1afc887ba88f 100644 (file)
@@ -30,7 +30,6 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
- *
  */
 class CRM_Logging_ReportSummary extends CRM_Report_Form {
   protected $cid;
@@ -40,6 +39,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form {
   protected $loggingDB;
 
   /**
+   * Class constructor.
    */
   public function __construct() {
     // don’t display the ‘Add these Contacts to Group’ button
@@ -187,16 +187,18 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form {
     $customTables = $logging->entityCustomDataLogTables('Address');
     foreach ($customTables as $table) {
       $this->_logTables[$table] = array(
-        'fk' => 'contact_id', // for join of fk_table with contact table
+        // For join of fk_table with contact table.
+        'fk' => 'contact_id',
         'joins' => array(
-          'table' => 'log_civicrm_address', // fk_table
+          // fk_table
+          'table' => 'log_civicrm_address',
           'join' => 'entity_log_civireport.entity_id = fk_table.id',
         ),
         'log_type' => 'Contact',
       );
     }
 
-    // allow log tables to be extended via report hooks
+    // Allow log tables to be extended via report hooks.
     CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
 
     parent::__construct();
@@ -345,7 +347,9 @@ ORDER BY log_civicrm_entity_log_date DESC {$this->_limit}";
   }
 
   /**
-   * @param $entity
+   * Get log type.
+   *
+   * @param string $entity
    *
    * @return string
    */
@@ -358,6 +362,8 @@ ORDER BY log_civicrm_entity_log_date DESC {$this->_limit}";
   }
 
   /**
+   * Get entity value.
+   *
    * @param int $id
    * @param $entity
    * @param $logDate
@@ -408,6 +414,8 @@ WHERE  log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1";
   }
 
   /**
+   * Get entity action.
+   *
    * @param int $id
    * @param int $connId
    * @param $entity
index 60dc5f196d40d8a4b2f14a100fcb06563998fd93..38f42056a23932304fb869f46a68b66855a3c493 100644 (file)
@@ -2200,9 +2200,9 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
    * @return CRM_Contribute_BAO_Contribution
    */
   public static function processSecondaryFinancialTransaction($contactID, &$form, $tempParams, $isTest, $lineItems, $minimumFee, $financialTypeID) {
-    $contributionType = new CRM_Financial_DAO_FinancialType();
-    $contributionType->id = $financialTypeID;
-    if (!$contributionType->find(TRUE)) {
+    $financialType = new CRM_Financial_DAO_FinancialType();
+    $financialType->id = $financialTypeID;
+    if (!$financialType->find(TRUE)) {
       CRM_Core_Error::fatal(ts("Could not find a system table"));
     }
     $tempParams['amount'] = $minimumFee;
@@ -2214,55 +2214,53 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
 
       if ($form->_contributeMode == 'express') {
         $result = $payment->doExpressCheckout($tempParams);
+        if (is_a($result, 'CRM_Core_Error')) {
+          throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result));
+        }
       }
       else {
-        $result = $payment->doDirectPayment($tempParams);
+        $result = $payment->doPayment($tempParams, 'contribute');
       }
     }
 
-    if (is_a($result, 'CRM_Core_Error')) {
-      throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result));
-    }
-    else {
-      //assign receive date when separate membership payment
-      //and contribution amount not selected.
-      if ($form->_amount == 0) {
-        $now = date('YmdHis');
-        $form->_params['receive_date'] = $now;
-        $receiveDate = CRM_Utils_Date::mysqlToIso($now);
-        $form->set('params', $form->_params);
-        $form->assign('receive_date', $receiveDate);
-      }
-
-      $form->set('membership_trx_id', $result['trxn_id']);
-      $form->set('membership_amount', $minimumFee);
-
-      $form->assign('membership_trx_id', $result['trxn_id']);
-      $form->assign('membership_amount', $minimumFee);
-
-      // we don't need to create the user twice, so lets disable cms_create_account
-      // irrespective of the value, CRM-2888
-      $tempParams['cms_create_account'] = 0;
-
-      $pending = $form->_params['is_pay_later'] ? (($minimumFee > 0.0) ? TRUE : FALSE) : FALSE;
-
-      //set this variable as we are not creating pledge for
-      //separate membership payment contribution.
-      //so for differentiating membership contribution from
-      //main contribution.
-      $form->_params['separate_membership_payment'] = 1;
-      $membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form,
-        $tempParams,
-        $result,
-        $contactID,
-        $contributionType,
-        $pending,
-        TRUE,
-        $isTest,
-        $lineItems
-      );
-      return $membershipContribution;
+    //assign receive date when separate membership payment
+    //and contribution amount not selected.
+    if ($form->_amount == 0) {
+      $now = date('YmdHis');
+      $form->_params['receive_date'] = $now;
+      $receiveDate = CRM_Utils_Date::mysqlToIso($now);
+      $form->set('params', $form->_params);
+      $form->assign('receive_date', $receiveDate);
     }
+
+    $form->set('membership_trx_id', $result['trxn_id']);
+    $form->set('membership_amount', $minimumFee);
+
+    $form->assign('membership_trx_id', $result['trxn_id']);
+    $form->assign('membership_amount', $minimumFee);
+
+    // we don't need to create the user twice, so lets disable cms_create_account
+    // irrespective of the value, CRM-2888
+    $tempParams['cms_create_account'] = 0;
+
+    $pending = $form->_params['is_pay_later'] ? (($minimumFee > 0.0) ? TRUE : FALSE) : FALSE;
+
+    //set this variable as we are not creating pledge for
+    //separate membership payment contribution.
+    //so for differentiating membership contribution from
+    //main contribution.
+    $form->_params['separate_membership_payment'] = 1;
+    $membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form,
+      $tempParams,
+      $result,
+      $contactID,
+      $financialType,
+      $pending,
+      TRUE,
+      $isTest,
+      $lineItems
+    );
+    return $membershipContribution;
   }
 
   /**
index 3dc72ad39fbf3fbc8b0b2d2004c49bf300c0a5df..20e467c80045977b68005b83b0130af94e60b9a3 100644 (file)
@@ -128,10 +128,20 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType {
     if ($id) {
       self::updateAllPriceFieldValue($id, $params);
     }
-
+    self::flush();
     return $membershipType;
   }
 
+  /**
+   * Flush anywhere that membership types might be cached
+   * @throws \CiviCRM_API3_Exception
+   */
+  public static function flush() {
+    CRM_Member_PseudoConstant::membershipType(NULL, TRUE);
+    civicrm_api3('membership', 'getfields', array('cache_clear' => 1, 'fieldname' => 'membership_type_id'));
+    civicrm_api3('profile', 'getfields', array('action' => 'submit', 'cache_clear' => 1));
+  }
+
   /**
    * Delete membership Types
    *
@@ -144,12 +154,12 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType {
     //check dependencies
     $check = FALSE;
     $status = array();
-    $dependancy = array(
+    $dependency = array(
       'Membership' => 'membership_type_id',
       'MembershipBlock' => 'membership_type_default',
     );
 
-    foreach ($dependancy as $name => $field) {
+    foreach ($dependency as $name => $field) {
       $baoString = 'CRM_Member_BAO_' . $name;
       $dao = new $baoString();
       $dao->$field = $membershipTypeId;
@@ -414,16 +424,11 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType {
       }
     }
 
-    $membershipDates = array();
-
-    $dates = array(
-      'start_date' => 'startDate',
-      'end_date' => 'endDate',
-      'join_date' => 'joinDate',
+    $membershipDates = array(
+      'start_date' => CRM_Utils_Date::customFormat($startDate, '%Y%m%d'),
+      'end_date' => CRM_Utils_Date::customFormat($endDate, '%Y%m%d'),
+      'join_date' => CRM_Utils_Date::customFormat($joinDate, '%Y%m%d'),
     );
-    foreach ($dates as $varName => $valName) {
-      $membershipDates[$varName] = CRM_Utils_Date::customFormat($$valName, '%Y%m%d');
-    }
 
     return $membershipDates;
   }
index 16fd62ac21d90e1d6ddb2dd8b303d42f9eb2b08d..c3b62f978621591d90f0c6ed3b9ed106fb82f0dd 100644 (file)
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
- *
  */
 class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
   /**
+   * Class constructor.
    */
   public function __construct() {
     parent::__construct();
@@ -125,7 +125,11 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
           ),
           'log_action' => array(
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => array('Insert' => ts('Insert'), 'Update' => ts('Update'), 'Delete' => ts('Delete')),
+            'options' => array(
+              'Insert' => ts('Insert'),
+              'Update' => ts('Update'),
+              'Delete' => ts('Delete'),
+            ),
             'title' => ts('Action'),
             'type' => CRM_Utils_Type::T_STRING,
           ),
@@ -157,7 +161,10 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
   }
 
   /**
-   * @param $rows
+   * Alter Report Display.
+   *
+   * @param array $rows
+   *   Rows from report query.
    */
   public function alterDisplay(&$rows) {
     // cache for id → is_deleted mapping
@@ -236,7 +243,9 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
   }
 
   /**
-   * @param null $logTable
+   * Generate From Clause.
+   *
+   * @param string $logTable
    */
   public function from($logTable = NULL) {
     static $entity = NULL;
index f4f2fede0cc2e39d6eedd0c6c34a03eca80228b8..29538b64bf7d95cf75d80186c5d33048faa09229 100644 (file)
@@ -77,4 +77,14 @@ class System {
     return self::getByProcessor($processor);
   }
 
+  /**
+   * Flush processors from static cache.
+   *
+   * This is particularly used for tests.
+   *
+   */
+  public function flushProcessors() {
+    $this->cache = array();
+  }
+
 }
index 9b681f8db2136026d9c3d218626b9a24e122d336..9bc52f32fb1d2843de2bf03cceaaa1e342d14e2c 100644 (file)
@@ -30,7 +30,6 @@
  *
  * @package CiviCRM_APIv3
  * @subpackage API_acl
- *
  */
 
 /**
index 9ebad65d5a548d708abc3547632acc87715b270a..2d006ce781e392143cf94bd32a5f207b8dc3619d 100644 (file)
@@ -97,6 +97,10 @@ function civicrm_api3_activity_create($params) {
   $case_id = '';
   $createRevision = FALSE;
   $oldActivityValues = array();
+  // Lookup case id if not supplied
+  if (!isset($params['case_id']) && !empty($params['id'])) {
+    $params['case_id'] = CRM_Core_DAO::singleValueQuery("SELECT case_id FROM civicrm_case_activity WHERE activity_id = " . (int) $params['id']);
+  }
   if (!empty($params['case_id'])) {
     $case_id = $params['case_id'];
     if (!empty($params['id'])) {
index 63ac673ef7ccb7ce5da825ca98b95b952929cc5c..870e8dc5252d1f5439db5a0f51bb4da65ccdbf7f 100644 (file)
  * @package CiviCRM_APIv3
  * @subpackage API_Case
  * @copyright CiviCRM LLC (c) 2004-2014
- *
  */
 
 
 /**
- * Open a new case, add client and manager roles, and add standard timeline
+ * Open a new case, add client and manager roles, and add standard timeline.
  *
  * @param array $params
  * //REQUIRED:
@@ -125,10 +124,10 @@ function civicrm_api3_case_create($params) {
 }
 
 /**
- * Adjust Metadata for Get Action
+ * Adjust Metadata for Get Action.
  *
  * @param array $params
- *   Array or parameters determined by getfields.
+ *   Parameters determined by getfields.
  */
 function _civicrm_api3_case_get_spec(&$params) {
   $params['contact_id']['api.aliases'] = array('client_id');
@@ -136,7 +135,7 @@ function _civicrm_api3_case_get_spec(&$params) {
 }
 
 /**
- * Adjust Metadata for Create Action
+ * Adjust Metadata for Create Action.
  *
  * @param array $params
  *   Array or parameters determined by getfields.
@@ -158,7 +157,7 @@ function _civicrm_api3_case_create_spec(&$params) {
 }
 
 /**
- * Adjust Metadata for Update action
+ * Adjust Metadata for Update action.
  *
  * @param array $params
  *   Array or parameters determined by getfields.
index 8676ee6e9816d65fc31091413efc5bb08d39f4c1..86b8a653cdc838eb85afdbb12b4e17ca6b35604f 100644 (file)
 +--------------------------------------------------------------------+
  */
 /**
- * Generic api wrapper used for quicksearch and autocomplete
+ * Generic api wrapper used for quicksearch and autocomplete.
  *
  * @param array $apiRequest
+ *
  * @return mixed
  */
 function civicrm_api3_generic_getList($apiRequest) {
index 7edb1785f6b964e70405c0bdddd780e41abd0400..2da98756fcee23769c0f7154bb61cbc7c3e33711 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 /**
- * params must contain at least id=xx & {one of the fields from getfields}=value
+ * Set a single value using the api.
+ *
+ * This function is called when no specific setvalue api exists.
+ * Params must contain at least id=xx & {one of the fields from getfields}=value
  *
  * @param array $apiRequest
  *
@@ -14,7 +17,10 @@ function civicrm_api3_generic_setValue($apiRequest) {
   civicrm_api3_verify_mandatory($params, NULL, array('id', 'field', 'value'));
   $id = $params['id'];
   if (!is_numeric($id)) {
-    return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
+    return civicrm_api3_create_error(ts('Please enter a number'), array(
+      'error_code' => 'NaN',
+      'field' => "id",
+    ));
   }
 
   $field = CRM_Utils_String::munge($params['field']);
index 483fb710f789c640e389b86db2f827d908fe0b55..1fe6772f5690bf29a4c905a84588653d741ce4c0 100644 (file)
  *   newly created or updated membership type property values.
  */
 function civicrm_api3_membership_type_create($params) {
-  $ids['membershipType'] = CRM_Utils_Array::value('id', $params);
-  $ids['memberOfContact'] = CRM_Utils_Array::value('member_of_contact_id', $params);
-  $ids['contributionType'] = CRM_Utils_Array::value('financial_type_id', $params);
-
-  $membershipTypeBAO = CRM_Member_BAO_MembershipType::add($params, $ids);
-  $membershipType = array();
-  _civicrm_api3_object_to_array($membershipTypeBAO, $membershipType[$membershipTypeBAO->id]);
-  CRM_Member_PseudoConstant::membershipType(NULL, TRUE);
-  civicrm_api3('membership', 'getfields', array('cache_clear' => 1, 'fieldname' => 'membership_type_id'));
-  civicrm_api3('profile', 'getfields', array('action' => 'submit', 'cache_clear' => 1));
-  return civicrm_api3_create_success($membershipType, $params, 'membership_type', 'create', $membershipTypeBAO);
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Membership_type');
 }
 
 /**
index 403aa6bbe727af33f929c4859e523b4dd680b835..8edc255b9805a4bfe672ae8fa770651445867bb7 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Retrieve one or more phones
+ * Retrieve one or more phones.
+ *
  * This function has been declared there instead than in api/v3/Phone.php
  * for no specific reasons, beside to demonstrate this feature
  * (that might be useful in your module, eg if you want to implement a
index 06c5f18851490cf890dc8dd8f14cbbe3c80efba6..cc8036ba5445bf416d8c2be81b4e3c544f8ff167 100644 (file)
@@ -36,7 +36,9 @@
  */
 
 /**
- *  Add a Tag. Tags are used to classify CRM entities (including Contacts, Groups and Actions).
+ * Add a Tag.
+ *
+ * Tags are used to classify CRM entities (including Contacts, Groups and Actions).
  *
  * Allowed @params array keys are:
  *
@@ -53,7 +55,9 @@ function civicrm_api3_tag_create($params) {
 }
 
 /**
- * Specify Meta data for create. Note that this data is retrievable via the getfields function
+ * Specify Meta data for create.
+ *
+ * Note that this data is retrievable via the getfields function
  * and is used for pre-filling defaults and ensuring mandatory requirements are met.
  *
  * @param array $params
@@ -65,15 +69,12 @@ function _civicrm_api3_tag_create_spec(&$params) {
 }
 
 /**
- * Deletes an existing Tag
+ * Delete an existing Tag.
  *
  * @param array $params
  *
- * @example TagDelete.ph
- *
  * @return array
  *   API result array
- *   {@getfields tag_delete}
  */
 function civicrm_api3_tag_delete($params) {
   return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.tpl b/templates/CRM/Case/Form/ActivityChangeStatus.tpl
deleted file mode 100644 (file)
index b129b1f..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
-*}
-{* CiviCase - change activity status inline *}
-<div class="crm-block crm-form-block crm-case-activitychangestatus-form-block">
-  <table class="form-layout">
-    <tr class="crm-case-activitychangestatus-form-block-status">
-      <td class="label">{$form.activity_change_status.label}</td>
-      <td>{$form.activity_change_status.html}</td>
-    </tr>
-  </table>
-</div>
diff --git a/templates/CRM/Case/Form/ActivityChangeStatusJs.tpl b/templates/CRM/Case/Form/ActivityChangeStatusJs.tpl
deleted file mode 100644 (file)
index d1d57d9..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
-*}
-{* CiviCase - change activity status inline *}
-{literal}
-  <script type="text/javascript">
-    CRM.$(function($) {
-      // Elements are sometimes in a jQuery dialog box which is outside crm-container,
-      // So gotta attach this handler to the whole body - sorry.
-      $('body').off('click.changeActivityStatus');
-      $('body').on('click.changeActivityStatus', 'a.crm-activity-change-status', function() {
-        var link = $(this),
-          activityId = $(this).attr('activity_id'),
-          current_status_id = $(this).attr('current_status'),
-          caseId = $(this).attr('case_id'),
-          data = 'snippet=1&reset=1',
-          $el = $('<div class="crm-activity_change_status"></div>');
-        $el.block();
-
-        $el.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
-          $el.unblock().trigger('crmLoad');
-          $("#activity_change_status").val(current_status_id);
-        });
-
-        CRM.confirm({
-          title: {/literal}'{ts escape='js'}Change Activity Status{/ts}'{literal},
-          message: $el
-        })
-          .on('crmConfirm:yes', function() {
-            // update the status
-            var status_id = $("#activity_change_status").val();
-            if (status_id === current_status_id) {
-              return false;
-            }
-
-            var dataUrl = CRM.url('civicrm/ajax/rest');
-            var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id
-              + '&case_id=' + caseId;
-            var request = $.ajax({
-              type     : 'POST',
-              dataType : 'json',
-              url      : dataUrl,
-              data     : data,
-              success  : function(values) {
-                if (values.is_error) {
-                  CRM.alert(values.error_message, {/literal}'{ts escape='js'}Unable to change status{/ts}'{literal}, 'error');
-                  return false;
-                }
-                else {
-                  CRM.refreshParent(link);
-                }
-              },
-              error : function(jqXHR) {
-                CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
-                return false;
-              }
-            });
-            CRM.status({}, request);
-          });
-        return false;
-      });
-    });
-  </script>
-{/literal}
index 90c8089b656a50ad6827abb0808872ae6d2df209..c77fc37177504d06f02045987db6dc73c72bad09 100644 (file)
@@ -31,7 +31,7 @@
   <div id="activities" class="crm-accordion-body">
     <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed">
       <div class="crm-accordion-header">
-        {ts}Search Filters{/ts}</a>
+        {ts}Search Filters{/ts}
       </div><!-- /.crm-accordion-header -->
       <div class="crm-accordion-body">
         <table class="no-border form-layout-compressed" id="searchOptions">
             </td>
             <td style="vertical-align: bottom;">
               {assign var=caseid value=$caseID}
-              <span class="crm-button"><input class="crm-form-submit default" name="_qf_Basic_refresh" value="Search" type="button" onclick="buildCaseActivities( true,{$caseid} )"; /></span>
+              <span class="crm-button crm-icon-button">
+                <span class="crm-button-icon ui-icon-check"></span>
+                <input class="crm-form-submit default" name="_qf_Basic_refresh" value="{ts}Search{/ts}" type="button" data-case-id="{$caseid}" />
+              </span>
             </td>
           </tr>
           <tr>
 {literal}
 <script type="text/javascript">
 CRM.$(function($) {
-  buildCaseActivities(false,{/literal}{$caseID}{literal});
-});
-
-function buildCaseActivities(filterSearch , CaseId) {
-  if (filterSearch) {
-    oTable.fnDestroy();
-  }
-  var count   = 0;
-  var columns = '';
-  var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}"{literal}+CaseId;
-  sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
-  sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
+  var CaseId = {/literal}{$caseID}{literal};
+  buildCaseActivities(false);
+  $('input.crm-form-submit[data-case-id=' + CaseId + ']').click(buildCaseActivities);
 
-  CRM.$('#case_id_'+CaseId+' th').each(function( ) {
-    if (CRM.$(this).attr('id') != 'nosort') {
-      columns += '{"sClass": "' + CRM.$(this).attr('class') +'"},';
-    }
-    else {
-      columns += '{ "bSortable": false },';
+  function buildCaseActivities(filterSearch) {
+    if (filterSearch) {
+      oTable.fnDestroy();
     }
-    count++;
-  });
+    var count = 0;
+    var columns = '';
+    var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}"{literal}+CaseId;
+    sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
+    sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
 
-  columns    = columns.substring(0, columns.length - 1 );
-  eval('columns =[' + columns + ']');
+    $('#case_id_'+CaseId+' th').each(function( ) {
+      if ($(this).attr('id') != 'nosort') {
+        columns += '{"sClass": "' + $(this).attr('class') +'"},';
+      }
+      else {
+        columns += '{ "bSortable": false },';
+      }
+      count++;
+    });
 
-  oTable = CRM.$('#case_id_'+CaseId).dataTable({
-    "bFilter"    : false,
-    "bAutoWidth" : false,
-    "aaSorting"  : [],
-    "aoColumns"  : columns,
-    "bProcessing": true,
-    "bJQueryUI": true,
-    "asStripClasses" : [ "odd-row", "even-row" ],
-    "sPaginationType": "full_numbers",
-    "sDom"       : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
-    "bServerSide": true,
-    "sAjaxSource": sourceUrl,
-    "iDisplayLength": 10,
-    "bDestroy": true,
-    "fnDrawCallback": function() { setSelectorClass(CaseId); },
-    "fnServerData": function ( sSource, aoData, fnCallback ) {
+    columns = columns.substring(0, columns.length - 1 );
+    eval('columns =[' + columns + ']');
 
-      if ( filterSearch ) {
-        var activity_deleted = 0;
-        if ( CRM.$("#activity_deleted_"+CaseId+":checked").val() == 1 ) {
-          activity_deleted = 1;
+    oTable = $('#case_id_'+CaseId).dataTable({
+      "bFilter"    : false,
+      "bAutoWidth" : false,
+      "aaSorting"  : [],
+      "aoColumns"  : columns,
+      "bProcessing": true,
+      "bJQueryUI": true,
+      "asStripClasses" : [ "odd-row", "even-row" ],
+      "sPaginationType": "full_numbers",
+      "sDom"       : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
+      "bServerSide": true,
+      "sAjaxSource": sourceUrl,
+      "iDisplayLength": 10,
+      "bDestroy": true,
+      "fnDrawCallback": function() {
+        setSelectorClass();
+        setRowIds();
+        // FIXME: trigger crmLoad and crmEditable would happen automatically
+        $('.crm-editable', '#case_id_'+CaseId).crmEditable();
+      },
+      "fnServerData": function ( sSource, aoData, fnCallback ) {
+
+        if ( filterSearch ) {
+          var activity_deleted = 0;
+          if ( $("#activity_deleted_"+CaseId+":checked").val() == 1 ) {
+            activity_deleted = 1;
+          }
+          aoData.push(
+            {name:'status_id', value: $("select#status_id_"+CaseId).val()},
+            {name:'reporter_id', value: $("select#reporter_id_"+CaseId).val()},
+            {name:'activity_type_id', value: $("select#activity_type_filter_id_"+CaseId).val()},
+            {name:'activity_date_low', value: $("#activity_date_low_"+CaseId).val()},
+            {name:'activity_date_high', value: $("#activity_date_high_"+CaseId).val() },
+            {name:'activity_deleted', value: activity_deleted }
+          );
         }
-        aoData.push(
-          {name:'status_id', value: CRM.$("select#status_id_"+CaseId).val()},
-          {name:'reporter_id', value: CRM.$("select#reporter_id_"+CaseId).val()},
-          {name:'activity_type_id', value: CRM.$("select#activity_type_filter_id_"+CaseId).val()},
-          {name:'activity_date_low', value: CRM.$("#activity_date_low_"+CaseId).val()},
-          {name:'activity_date_high', value: CRM.$("#activity_date_high_"+CaseId).val() },
-          {name:'activity_deleted', value: activity_deleted }
-        );
+        $.ajax( {
+          "dataType": 'json',
+          "type": "POST",
+          "url": sSource,
+          "data": aoData,
+          "success": fnCallback
+        } );
       }
-      CRM.$.ajax( {
-        "dataType": 'json',
-        "type": "POST",
-        "url": sSource,
-        "data": aoData,
-        "success": fnCallback
-      } );
-    }
-  });
-}
+    });
+  }
 
-function setSelectorClass(CaseId) {
-  CRM.$("#case_id_"+CaseId+" td:last-child").each( function( ) {
-    CRM.$(this).parent().addClass(CRM.$(this).text() );
-  });
-}
+  function setRowIds() {
+    $("#case_id_"+CaseId+" tbody tr").each(function() {
+      var link, id;
+      link = $('a.action-item', this).attr('href');
+      if (link) {
+        id = link.match(/&id=(\d+)/);
+      }
+      if (id) {
+        $(this)
+          .addClass('crm-entity')
+          .data('entity', 'activity')
+          .data('id', id[1]);
+      }
+    });
+  }
+
+  function setSelectorClass() {
+    $("#case_id_"+CaseId+" td:last-child").each(function() {
+      $(this).parent().addClass($(this).text());
+    });
+  }
+});
 </script>
 {/literal}
index 48add0ae57d6d18840868f051f1401420a72dad8..78d72865fd805f3b4ace1db5f88c966c0ceba326 100644 (file)
 {include file="CRM/Case/Form/ActivityTab.tpl"}
 
 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
-
-  {include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
 {/if} {* view related cases if end *}
 </div>
 
index 5adf01ca2163a2476dc3b60e3797bcd764e0d1b0..aa1161a8eb734539cad56b1409c4b2ba15c42569 100644 (file)
@@ -81,5 +81,3 @@
 </div>
 {/if}
 {/if}
-
-{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
index 9af31c0b7deb697e90408d17448702912625f921..89a6ec9bb46aba939c9b5e009571228e8a9bdc1e 100644 (file)
@@ -38,7 +38,7 @@
 
     {counter start=0 skip=1 print=false}
     {foreach from=$rows item=row}
-    <tr class="{$row.class}">
+    <tr class="crm-entity {$row.class}" data-entity="activity" data-id="{$row.id}">
       <td class="crm-case-display_date">{$row.display_date}</td>
       <td class="crm-case-subject">{$row.subject}</td>
       <td class="crm-case-type">{$row.type}</td>
index 42f8d5326a0b285d287029b21ca5875570974b2a..1893c2ed593ecd7c3b5220c792cb082d3d107678 100644 (file)
     {/if}
 {/if}
 </div>
-
-{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
index 3dddbdd597210c732d06fa82310834b66ed4e0ae..3b4329e4650cc9a7328761dbac528a4654002557 100644 (file)
 <script type="text/javascript">
 function {/literal}{$context}{$list}{literal}CaseDetails( caseId, contactId, type, context )
 {
-    var dataUrl = {/literal}"{crmURL p='civicrm/case/details' h=0 q='snippet=4&caseId='}{literal}" + caseId +'&cid=' + contactId + '&type=' + type;
-    cj.ajax({
-            url     : dataUrl,
-            dataType: "html",
-            timeout : 5000, //Time in milliseconds
-            success : function( data ){
-                  cj( '#'+ context + '-' + type +'-casedetails-' + caseId ).html( data );
-                      },
-            error   : function( XMLHttpRequest, textStatus, errorThrown ) {
-                        CRM.console('error', 'Error: ', textStatus);
-                      }
-         });
+    var dataUrl = CRM.url('civicrm/case/details', {caseId: caseId, cid: contactId, type: type});
+    CRM.loadPage(dataUrl, {target: '#'+ context + '-' + type +'-casedetails-' + caseId});
 }
 
 function showCaseActivities( caseId, type, context ) {
@@ -146,5 +136,3 @@ function hideCaseActivities( caseId , type, context ) {
 
 </script>
 {/literal}
-
-{include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
index 91ed78ca9836034443fcbd601cfdcf0e0529ed6a..d3bd158ef1099f9c9b99d91b953593b159dcad5f 100644 (file)
@@ -66,7 +66,6 @@
 
     {if $rows}
           {include file="CRM/Case/Form/Selector.tpl"}
-          {include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"}
     {else}
        <div class="messages status no-popup">
           <div class="icon inform-icon"></div>
index 0fdbf562baf07545b4b72555143f13d2a47d3d85..26f40ea2e68aeb00569ec671c8fdd021b19af72d 100755 (executable)
@@ -26,6 +26,8 @@
  *   <http://www.gnu.org/licenses/>.
  */
 
+use Civi\Payment\System;
+
 /**
  *  Include configuration
  */
@@ -2580,6 +2582,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $this->restoreDefaultPriceSetConfig();
     $var = TRUE;
     CRM_Member_BAO_Membership::createRelatedMemberships($var, $var, TRUE);
+    Civi\Payment\System::singleton()->flushProcessors();
   }
 
   public function restoreDefaultPriceSetConfig() {
index 7c2263f300a9da61793e28c79f90eeb16169ce38..fec64080e9db9d89398e2d5f0d9ed7cf62f3d489 100644 (file)
@@ -258,7 +258,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
   /**
    * Test submit recurring membership with immediate confirmation (IATS style)
    * - we process 2 membership transactions against with a recurring contribution against a contribution page with an immediate
-   * processor (IASTS style - denoted by returning trxn_id)
+   * processor (IATS style - denoted by returning trxn_id)
    * - the first creates a new membership, completed contribution, in progress recurring. Check these
    * - create another - end date should be extended
    */
index d5eb12c08f3824ddc4b019eb86d6c8aa9bb6dd23..8ed9bc10c4163e99093afb30b35f5642fb1cc056 100644 (file)
@@ -1019,7 +1019,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase {
 
 
   /**
-   * Test that if datesdate are not set they not over-ridden if id is passed in
+   * Test that if dates are set they not over-ridden if id is passed in
    */
   public function testMembershipDatesNotOverridden() {
     $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
index 5ee2dd1b5ff4c558a400436cb6c52fd6b66468d7..e6603dd1960d05d2985c219c427f7a7629e24c70 100644 (file)
@@ -203,20 +203,22 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'visibility' => 'public',
     );
 
-    $membershiptype = $this->callAPIAndDocument('membership_type', 'create', $params, __FUNCTION__, __FILE__);
-    $this->assertNotNull($membershiptype['values']);
-    $this->membershipTypeDelete(array('id' => $membershiptype['id']));
+    $membershipType = $this->callAPIAndDocument('membership_type', 'create', $params, __FUNCTION__, __FILE__);
+    $this->assertNotNull($membershipType['values']);
+    $this->membershipTypeDelete(array('id' => $membershipType['id']));
   }
 
 
+  /**
+   * Test mandatory parameter check.
+   */
   public function testUpdateWithEmptyParams() {
-    $params = array();
-    $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
-    $this->assertEquals($membershiptype['error_message'],
-      'Mandatory key(s) missing from params array: domain_id, member_of_contact_id, financial_type_id, duration_unit, duration_interval, name'
-                       );
+    $this->callAPIFailure('membership_type', 'create', array());
   }
 
+  /**
+   * Test update fails with no ID.
+   */
   public function testUpdateWithoutId() {
     $params = array(
       'name' => '60+ Membership',
@@ -230,8 +232,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'visibility' => 'public',
     );
 
-    $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
-    $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: domain_id');
+    $membershipType = $this->callAPIFailure('membership_type', 'create', $params);
+    $this->assertEquals($membershipType['error_message'], 'Mandatory key(s) missing from params array: domain_id');
   }
 
   public function testUpdate() {
@@ -260,13 +262,16 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $this->getAndCheck($params, $id, $this->_entity);
   }
 
+  /**
+   * Test for failure when id is not valid.
+   */
   public function testDeleteNotExists() {
     $params = array(
       'id' => 'doesNotExist',
     );
-    $membershiptype = $this->callAPIFailure('membership_type', 'delete', $params,
-                      'Error while deleting membership type. id : ' . $params['id']
-                                           );
+    $this->callAPIFailure('membership_type', 'delete', $params,
+      'Error while deleting membership type. id : ' . $params['id']
+    );
   }
 
   public function testDelete() {
@@ -276,7 +281,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'id' => $membershipTypeID,
     );
 
-    $result = $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
 }