Merge pull request #4071 from eileenmcnaughton/CRM-15259
authorEileen McNaughton <eileen@mcnaughty.com>
Mon, 29 Sep 2014 10:18:58 +0000 (23:18 +1300)
committerEileen McNaughton <eileen@mcnaughty.com>
Mon, 29 Sep 2014 10:18:58 +0000 (23:18 +1300)
CRM-15259 use same method to determine whether to show updateBilling lin...

33 files changed:
CRM/Contact/BAO/Query.php
CRM/Contact/Page/AJAX.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Core/BAO/Address.php
CRM/Core/BAO/CustomField.php
CRM/Core/DAO.php
CRM/Core/Menu.php
CRM/Core/Smarty/plugins/function.crmSigner.php [new file with mode: 0644]
CRM/Core/Smarty/plugins/function.crmVersion.php [new file with mode: 0644]
CRM/Event/Form/Registration/Register.php
CRM/Export/BAO/Export.php
CRM/Financial/BAO/FinancialAccount.php
CRM/Financial/BAO/FinancialType.php
CRM/Grant/BAO/Grant.php
CRM/Price/BAO/PriceSet.php
CRM/Price/Page/Field.php
CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl
CRM/Utils/Check/Security.php
api/v3/ActivityContact.php [new file with mode: 0644]
api/v3/Contribution.php
api/v3/FinancialAccount.php [new file with mode: 0644]
api/v3/FinancialType.php [new file with mode: 0644]
api/v3/examples/Case/Create.php [new file with mode: 0644]
bin/setup.sh
templates/CRM/Contribute/Form/Contribution/Confirm.tpl
templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
templates/CRM/Price/Page/Field.tpl
templates/CRM/common/checkUsernameAvailable.tpl
templates/CRM/common/footer.tpl
tests/phpunit/CRM/Member/BAO/MembershipTest.php
tests/phpunit/api/v3/CaseTest.php
tests/phpunit/api/v3/SyntaxConformanceTest.php
tools/scripts/phpunit

index f86c25ef944e3e5f60e0b475a5e85e8840580de8..546d1ceb56a9ba94a9a8df8af0438101a6b21a26 100644 (file)
@@ -1244,12 +1244,16 @@ class CRM_Contact_BAO_Query {
    * @param boolean $count
    * @param boolean $sortByChar
    * @param boolean $groupContacts
+   * @param boolean $onlyDeleted
    *
    * @return the sql string for that query (this will most likely
    * change soon)
    * @access public
    */
-  function query($count = FALSE, $sortByChar = FALSE, $groupContacts = FALSE) {
+  function query($count = FALSE, $sortByChar = FALSE, $groupContacts = FALSE, $onlyDeleted = FALSE) {
+    // build permission clause
+    $this->generatePermissionClause($onlyDeleted, $count);
+
     if ($count) {
       if (isset($this->_distinctComponentClause)) {
         // we add distinct to get the right count for components
@@ -1324,6 +1328,15 @@ class CRM_Contact_BAO_Query {
       $where = "WHERE {$this->_whereClause}";
     }
 
+    if (!empty($this->_permissionWhereClause)) {
+      if (empty($where)) {
+        $where = "WHERE $this->_permissionWhereClause";
+      }
+      else {
+        $where = "$where AND $this->_permissionWhereClause";
+      }
+    }
+
     $having = '';
     if (!empty($this->_having)) {
       foreach ($this->_having as $havingsets) {
@@ -4267,7 +4280,6 @@ civicrm_relationship.is_permission_a_b = 0
         break;
       }
     }
-    $this->generatePermissionClause($onlyDeleted, $count);
 
     // building the query string
     $groupBy = NULL;
@@ -4366,16 +4378,7 @@ civicrm_relationship.is_permission_a_b = 0
     // note : this modifies _fromClause and _simpleFromClause
     $this->includePseudoFieldsJoin($sort);
 
-    list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts);
-
-    if(!empty($this->_permissionWhereClause)){
-      if (empty($where)) {
-        $where = "WHERE $this->_permissionWhereClause";
-      }
-      else {
-        $where = "$where AND $this->_permissionWhereClause";
-      }
-    }
+    list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted);
 
     if ($additionalWhereClause) {
       $where = $where . ' AND ' . $additionalWhereClause;
index 90fc183330e4eb72d32dc9b6a250c7c762d264b6..ddf9e41ed5e4e27425daf1efda2d760f9b8f4c50 100644 (file)
  * This class contains all contact related functions that are called using AJAX (jQuery)
  */
 class CRM_Contact_Page_AJAX {
+  /**
+   * When a user chooses a username, CHECK_USERNAME_TTL
+   * is the time window in which they can check usernames
+   * (without reloading the overall form).
+   */
+  const CHECK_USERNAME_TTL = 10800; // 3hr; 3*60*60
+
+  const AUTOCOMPLETE_TTL = 21600; // 6hr; 6*60*60
+
   static function getContactList() {
     // if context is 'customfield'
     if (CRM_Utils_Array::value('context', $_GET) == 'customfield') {
@@ -253,6 +262,13 @@ class CRM_Contact_Page_AJAX {
    * Function to fetch the values
    */
   static function autocomplete() {
+    $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('cfid', 'ogid', 'sigts'));
+    if (CRM_Utils_Time::getTimeRaw() > $_REQUEST['sigts'] + self::AUTOCOMPLETE_TTL
+      || !$signer->validate($_REQUEST['sig'], $_REQUEST)
+    ) {
+      CRM_Utils_System::civiExit();
+    }
+
     $fieldID       = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
     $optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
     $label         = CRM_Utils_Type::escape($_GET['s'], 'String');
@@ -615,6 +631,17 @@ WHERE sort_name LIKE '%$name%'";
      *
     */
   static public function checkUserName() {
+    $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
+    if (
+      CRM_Utils_Time::getTimeRaw() > $_REQUEST['ts'] + self::CHECK_USERNAME_TTL
+      || $_REQUEST['for'] != 'civicrm/ajax/cmsuser'
+      || !$signer->validate($_REQUEST['sig'], $_REQUEST)
+    ) {
+      $user = array('name' => 'error');
+      echo json_encode($user);
+      CRM_Utils_System::civiExit();
+    }
+
     $config = CRM_Core_Config::singleton();
     $username = trim($_REQUEST['cms_name']);
 
@@ -642,6 +669,9 @@ WHERE sort_name LIKE '%$name%'";
   static function getContactEmail() {
     if (CRM_Utils_Array::value('contact_id', $_REQUEST)) {
       $contactID = CRM_Utils_Type::escape($_REQUEST['contact_id'], 'Positive');
+      if (!CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
+        return;
+      }
       list($displayName,
         $userEmail
       ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
index c6a13d20749c4db538338be617646ca294a1118a..cdc7ea57e1d516f69a14352e2f3b921429ec72d2 100644 (file)
@@ -844,7 +844,11 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
 
             if (CRM_Utils_Array::value('options', $value)) {
               foreach ($value['options'] as $val) {
-                if (CRM_Utils_Array::value('membership_type_id', $val)) {
+                if (CRM_Utils_Array::value('membership_type_id', $val) && (
+                    ($fields['price_' . $priceId] == $val['id']) ||
+                    (isset($fields['price_' . $priceId]) && !empty($fields['price_' . $priceId][$val['id']]))
+                  )
+                ) {
                   $priceFieldMemTypes[] = $val['membership_type_id'];
                 }
               }
index 5285d7811c551261ff366ab3470108ff34f5a877..4482d3b5d20a674cd8e19c028cc6a2e008c376b8 100644 (file)
@@ -1185,7 +1185,7 @@ SELECT is_primary,
             $props['country_id'] = $config->defaultContactCountry;
           }
         }
-        if (!empty($props['country_id'])) {
+        if (!empty($props['country_id']) && $context !== 'validate') {
           $params['condition'] = 'country_id IN (' . implode(',', (array) $props['country_id']) . ')';
         }
         break;
@@ -1207,4 +1207,4 @@ SELECT is_primary,
     }
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
   }
-}
\ No newline at end of file
+}
index 0801e2a2bca884a80761983cf669f6ce1afc7bfe..9cde814573e8ea5a2b5ef5d050a5015252123415 100644 (file)
@@ -1023,10 +1023,15 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
           $qf->addRule($elementName, ts('Select a valid contact for %1.', array(1 => $label)), 'validContact', $actualElementValue);
         }
         else {
-          $customUrls[$elementName] = CRM_Utils_System::url('civicrm/ajax/auto',
-            "reset=1&ogid={$field->option_group_id}&cfid={$field->id}",
-            FALSE, NULL, FALSE
+          $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('cfid','ogid','sigts'));
+          $signParams = array(
+            'reset' => 1,
+            'sigts' => CRM_Utils_Time::getTimeRaw(),
+            'ogid' => $field->option_group_id,
+            'cfid' => $field->id,
           );
+          $signParams['sig'] = $signer->sign($signParams);
+          $customUrls[$elementName] = CRM_Utils_System::url('civicrm/ajax/auto', $signParams, FALSE, NULL, FALSE);
           $qf->addRule($elementName, ts('Select a valid value for %1.', array(1 => $label)),
             'autocomplete', array(
               'fieldID' => $field->id,
index 9dea4c8676c42c669c29ef1ff6012a5e55c7a365..ab84572a1afc320d10af7e88c9d51a6e8f749f45 100644 (file)
@@ -1341,7 +1341,13 @@ SELECT contact_id
             case CRM_Utils_Type::T_INT:
             case CRM_Utils_Type::T_FLOAT:
             case CRM_Utils_Type::T_MONEY:
-              $object->$dbName = $counter;
+              //4.4 hack do not merge
+              if ($dbName == 'tax_rate') {
+                $object->$dbName = 10;
+              }
+              else {
+                $object->$dbName = $counter;
+              }
               break;
 
             case CRM_Utils_Type::T_BOOLEAN:
index a18006f062f76d5d067fbbbec5a8a5f61b0f5b56..0cb7b299655bc5f632f15a7058a7f85d5221d246 100644 (file)
@@ -285,7 +285,13 @@ class CRM_Core_Menu {
             ',' => '_', '/' => '_',
           )
         ),
-        'url' => CRM_Utils_System::url($path, $query, FALSE),
+        'url' => CRM_Utils_System::url($path, $query, 
+            FALSE, // absolute
+            NULL, // fragment
+            TRUE, // htmlize
+            FALSE, // frontend
+            TRUE // forceBackend; CRM-14439 work-around; acceptable for now because we don't display breadcrumbs on frontend
+        ),
         'icon' => CRM_Utils_Array::value('icon', $item),
         'extra' => CRM_Utils_Array::value('extra', $item),
       );
diff --git a/CRM/Core/Smarty/plugins/function.crmSigner.php b/CRM/Core/Smarty/plugins/function.crmSigner.php
new file mode 100644 (file)
index 0000000..f023811
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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
+ * $Id$
+ *
+ */
+
+/**
+ * Generate a secure signature
+ *
+ * {code}
+ * {crmSigner var=mySig extra=123}
+ * var urlParams = ts={$mySig.ts}&extra={$mySig.extra}&sig={$mySig.signature}
+ * {endcode}
+ *
+ * @param $params array with keys:
+ *   - var: string, a smarty variable to generate
+ *   - ts: int, the current time (if omitted, autogenerated)
+ *   - any other vars are put into the signature (sorted)
+ */
+function smarty_function_crmSigner($params, &$smarty) {
+  $var = $params['var'];
+  unset($params['var']);
+  $params['ts'] = CRM_Utils_Time::getTimeRaw();
+
+  $fields = array_keys($params);
+  sort($fields);
+
+  $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), $fields);
+  $params['signature'] = $signer->sign($params);
+  $smarty->assign($var, $params);
+}
diff --git a/CRM/Core/Smarty/plugins/function.crmVersion.php b/CRM/Core/Smarty/plugins/function.crmVersion.php
new file mode 100644 (file)
index 0000000..18ab67a
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | 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 TTTP
+ * $Id$
+ *
+ */
+
+/**
+ * Display the CiviCRM version
+ *
+ * @code
+ * The version is {crmVersion}.
+ *
+ * {crmVersion redact=auto assign=ver}The version is {$ver}.
+ * @endcode
+ */
+function smarty_function_crmVersion($params, &$smarty) {
+  $version = CRM_Utils_System::version();
+
+  $redact = !CRM_Core_Permission::check('access CiviCRM');
+  if ($redact) {
+    $parts = explode('.', $version);
+    $version = $parts[0] . '.' . $parts[1] . '.x';
+  }
+
+  if (isset($params['assign'])) {
+    $smarty->assign($params['assign'], $version);
+  }
+  else {
+    return $version;
+  }
+}
index 3438149ab0488dd7708585abaab4a2681832f15b..bc26ae04e3fdf7122b219ccb4ade221036a9930f 100644 (file)
@@ -547,12 +547,6 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    * @static
    */
   static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) {
-    // build amount only when needed, skip incase of event full and waitlisting is enabled
-    // and few other conditions check preProcess()
-    if (!empty($form->_noFees)) {
-      return;
-    }
-
     //if payment done, no need to build the fee block.
     if (!empty($form->_paymentId)) {
       //fix to display line item in update mode.
index 8930ebe46911c21c7576c0ffee19549c1cf9c02c..cbbd3183553219a3d9e85063fa30c2bec51eb0e8 100644 (file)
@@ -78,9 +78,7 @@ class CRM_Export_BAO_Export {
     $headerRows = $returnProperties = array();
     $primary    = $paymentFields    = $selectedPaymentFields = FALSE;
     $origFields = $fields;
-    $queryMode  = $relationField = NULL;
-
-    $allCampaigns = array();
+    $relationField = NULL;
 
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
@@ -604,7 +602,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
           $addPaymentHeader = TRUE;
         }
       }
-      // If we have seleted specific payment fields, leave the payment headers
+      // If we have selected specific payment fields, leave the payment headers
       // as an empty array; the headers for each selected field will be added
       // elsewhere.
       else {
@@ -613,21 +611,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
       $nullContributionDetails = array_fill_keys(array_keys($paymentHeaders), NULL);
     }
 
-    // Split campaign into 2 fields for id and title
-    $campaignReturnProperties = array();
-    foreach ($returnProperties as $fld => $true) {
-      $campaignReturnProperties[$fld] = $true;
-      if (substr($fld, -11) == 'campaign_id') {
-        $exportCampaign = TRUE;
-        $campaignReturnProperties[substr($fld, 0, -3)] = 1;
-      }
-    }
-    $returnProperties = $campaignReturnProperties;
-    //get all campaigns.
-    if (isset($exportCampaign)) {
-      $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
-    }
-
     $componentDetails = $headerRows = $sqlColumns = array();
     $setHeader = TRUE;
 
@@ -640,7 +623,17 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
 
     // for CRM-3157 purposes
     $i18n = CRM_Core_I18n::singleton();
-
+    $outputColumns = array();
+    //@todo - it would be clearer to start defining output columns earlier in this function rather than stick with return properties until this point
+    // as the array is not actually 'returnProperties' after the sql query is formed - making the alterations to it confusing
+    foreach ($returnProperties as $key => $value) {
+      $outputColumns[$key] = $value;
+      if (substr($key, -11) == 'campaign_id') {
+        // the field $dao->x_campaign_id_id holds the id whereas the field $dao->campaign_id
+        // we want to insert it directly after campaign id
+        $outputColumns[$key . '_id'] = 1;
+      }
+    }
     while (1) {
       $limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
       $dao = CRM_Core_DAO::executeQuery($limitQuery);
@@ -653,19 +646,29 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
         $row = array();
 
         //convert the pseudo constants
-        $query->convertToPseudoNames($dao);
-
-        //first loop through returnproperties so that we return what is required, and in same order.
+        // CRM-14398 there is problem in this architecture that is not easily solved. For now we are using the cloned
+        // temporary iterationDAO object to get around it.
+        // the issue is that the convertToPseudoNames function is adding additional properties (e.g for campaign) to the DAO object
+        // these additional properties are NOT reset when the $dao cycles through the while loop
+        // nor are they overwritten as they are not in the loop
+        // the convertToPseudoNames will not adequately over-write them either as it doesn't 'kick-in' unless the
+        // relevant property is set.
+        // It may be that a long-term fix could be introduced there - however, it's probably necessary to figure out how to test the
+        // export class before tackling a better architectural fix
+        $iterationDAO = clone $dao;
+        $query->convertToPseudoNames($iterationDAO);
+
+        //first loop through output columns so that we return what is required, and in same order.
         $relationshipField = 0;
-        foreach ($returnProperties as $field => $value) {
+        foreach ($outputColumns as $field => $value) {
           //we should set header only once
           if ($setHeader) {
             $sqlDone = FALSE;
             // Split campaign into 2 fields for id and title
-            if (substr($field, -8) == 'campaign') {
+            if (substr($field, -11) == 'campaign_id') {
               $headerRows[] = ts('Campaign Title');
             }
-            elseif (substr($field, -11) == 'campaign_id') {
+            elseif (substr($field, -14) == 'campaign_id_id') {
               $headerRows[] = ts('Campaign ID');
             }
             elseif (isset($query->_fields[$field]['title'])) {
@@ -779,14 +782,14 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
           }
 
           // add im_provider to $dao object
-          if ($field == 'im_provider' && property_exists($dao, 'provider_id')) {
-            $dao->im_provider = $dao->provider_id;
+          if ($field == 'im_provider' && property_exists($iterationDAO, 'provider_id')) {
+            $iterationDAO->im_provider = $iterationDAO->provider_id;
           }
 
           //build row values (data)
           $fieldValue = NULL;
-          if (property_exists($dao, $field)) {
-            $fieldValue = $dao->$field;
+          if (property_exists($iterationDAO, $field)) {
+            $fieldValue = $iterationDAO->$field;
             // to get phone type from phone type id
             if ($field == 'phone_type_id' && isset($phoneTypes[$fieldValue])) {
               $fieldValue = $phoneTypes[$fieldValue];
@@ -796,36 +799,36 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
             }
             elseif ($field == 'participant_role_id') {
               $participantRoles = CRM_Event_PseudoConstant::participantRole();
-              $sep              = CRM_Core_DAO::VALUE_SEPARATOR;
-              $viewRoles        = array();
-              foreach (explode($sep, $dao->$field) as $k => $v) {
+              $sep = CRM_Core_DAO::VALUE_SEPARATOR;
+              $viewRoles = array();
+              foreach (explode($sep, $iterationDAO->$field) as $k => $v) {
                 $viewRoles[] = $participantRoles[$v];
               }
               $fieldValue = implode(',', $viewRoles);
             }
             elseif ($field == 'master_id') {
               $masterAddressId = NULL;
-              if (isset($dao->master_id)) {
-                $masterAddressId = $dao->master_id;
+              if (isset($iterationDAO->master_id)) {
+                $masterAddressId = $iterationDAO->master_id;
               }
               // get display name of contact that address is shared.
-              $fieldValue = CRM_Contact_BAO_Contact::getMasterDisplayName($masterAddressId, $dao->contact_id);
+              $fieldValue = CRM_Contact_BAO_Contact::getMasterDisplayName($masterAddressId, $iterationDAO->contact_id);
             }
           }
 
           if ($field == 'id') {
-            $row[$field] = $dao->contact_id;
+            $row[$field] = $iterationDAO->contact_id;
             // special case for calculated field
           }
           elseif ($field == 'source_contact_id') {
-            $row[$field] = $dao->contact_id;
+            $row[$field] = $iterationDAO->contact_id;
           }
           elseif ($field == 'pledge_balance_amount') {
-            $row[$field] = $dao->pledge_amount - $dao->pledge_total_paid;
+            $row[$field] = $iterationDAO->pledge_amount - $iterationDAO->pledge_total_paid;
             // special case for calculated field
           }
           elseif ($field == 'pledge_next_pay_amount') {
-            $row[$field] = $dao->pledge_next_pay_amount + $dao->pledge_outstanding_amount;
+            $row[$field] = $iterationDAO->pledge_next_pay_amount + $iterationDAO->pledge_outstanding_amount;
           }
           elseif (is_array($value) && $field == 'location') {
             // fix header for location type case
@@ -846,27 +849,27 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
                 switch ($fld) {
                   case 'country':
                   case 'world_region':
-                    $row[$fldValue] = $i18n->crm_translate($dao->$daoField, array('context' => 'country'));
+                    $row[$fldValue] = $i18n->crm_translate($iterationDAO->$daoField, array('context' => 'country'));
                     break;
 
                   case 'state_province':
-                    $row[$fldValue] = $i18n->crm_translate($dao->$daoField, array('context' => 'province'));
+                    $row[$fldValue] = $i18n->crm_translate($iterationDAO->$daoField, array('context' => 'province'));
                     break;
 
                   case 'im_provider':
                     $imFieldvalue = $daoField . "-provider_id";
-                    $row[$fldValue] = CRM_Utils_Array::value($dao->$imFieldvalue, $imProviders);
+                    $row[$fldValue] = CRM_Utils_Array::value($iterationDAO->$imFieldvalue, $imProviders);
                     break;
 
                   default:
-                    $row[$fldValue] = $dao->$daoField;
+                    $row[$fldValue] = $iterationDAO->$daoField;
                     break;
                 }
               }
             }
           }
           elseif (array_key_exists($field, $contactRelationshipTypes)) {
-            $relDAO = CRM_Utils_Array::value($dao->contact_id, $allRelContactArray[$field]);
+            $relDAO = CRM_Utils_Array::value($iterationDAO->contact_id, $allRelContactArray[$field]);
             foreach ($value as $relationField => $relationValue) {
               if (is_object($relDAO) && property_exists($relDAO, $relationField)) {
                 $fieldValue = $relDAO->$relationField;
@@ -898,7 +901,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
               if (is_object($relDAO) && $relationField == 'id') {
                 $row[$field . $relationField] = $relDAO->contact_id;
               }
-              elseif ( is_object( $relDAO ) && is_array( $relationValue ) && $relationField == 'location' ) {
+              elseif (is_array( $relationValue ) && $relationField == 'location') {
                 foreach ($relationValue as $ltype => $val) {
                   foreach (array_keys($val) as $fld) {
                     $type = explode('-', $fld);
@@ -988,11 +991,12 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
               CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
               $row[$field] = $paramsNew[$field];
             }
+
             elseif (in_array($field, array(
               'email_greeting', 'postal_greeting', 'addressee'))) {
               //special case for greeting replacement
               $fldValue = "{$field}_display";
-              $row[$field] = $dao->$fldValue;
+              $row[$field] = $iterationDAO->$fldValue;
             }
             else {
               //normal fields with a touch of CRM-3157
@@ -1018,12 +1022,8 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
               }
             }
           }
-          elseif (substr($field, -8) == 'campaign') {
-            $campIdFld = "{$field}_id";
-            $row[$field] = CRM_Utils_Array::value($dao->$campIdFld, $allCampaigns, '');
-          }
           elseif ($selectedPaymentFields && array_key_exists($field, self::componentPaymentFields())) {
-            $paymentData = CRM_Utils_Array::value($dao->$paymentTableId, $paymentDetails);
+            $paymentData = CRM_Utils_Array::value($iterationDAO->$paymentTableId, $paymentDetails);
             $payFieldMapper = array(
               'componentPaymentField_total_amount'        => 'total_amount',
               'componentPaymentField_contribution_status' => 'contribution_status',
@@ -1274,6 +1274,13 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
       return;
     }
 
+    if (substr($fieldName, -11) == 'campaign_id') {
+      // CRM-14398
+      $sqlColumns[$fieldName] = "$fieldName varchar(128)";
+      $sqlColumns[$fieldName . '_id'] = "{$fieldName}_id varchar(16)";
+      return;
+    }
+
     // set the sql columns
     if (isset($query->_fields[$field]['type'])) {
       switch ($query->_fields[$field]['type']) {
index f2528f70bbd0148a61e897d9999857a0ffe47296..44112d0b3fc77a01856de40ee6949d9c44a4a053 100644 (file)
@@ -95,7 +95,7 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco
    * @static
    * @return object
    */
-  static function add(&$params, &$ids) {
+  static function add(&$params, &$ids = array()) {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, FALSE);
     $params['is_tax'] = CRM_Utils_Array::value('is_tax', $params, FALSE);
index 1c40b7359beaa999f63303e72c4481bc35df0126..5b1d71c5e922127aecfa1d4b3f63dde3e5503293 100644 (file)
@@ -95,7 +95,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
    * @static
    * @return object
    */
-  static function add(&$params, &$ids) {
+  static function add(&$params, &$ids = array()) {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
     $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, false);
     $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, false);
index f0a91cfbb4e3ac654256c68bb3e562db5c722af8..de5356adcb9b43736c31ce28fc9e8559724cd20d 100644 (file)
@@ -269,7 +269,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
     if (!$id) {
       $id = CRM_Utils_Array::value('contact_id', $params);
     }
-    if (CRM_Utils_Array::value('note', $params) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note',$ids))) {
+    if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) {
       $noteParams = array(
         'entity_table' => 'civicrm_grant',
         'note' => $params['note'] = $params['note'] ? $params['note'] : "null",
@@ -278,7 +278,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
         'modified_date' => date('Ymd'),
       );
 
-      CRM_Core_BAO_Note::add($noteParams, $ids['note']);
+      CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids));
     }
     // Log the information on successful add/edit of Grant
     $logParams = array(
index 1c4ed9675a3f11a171c8e0761d3af1ab8dcef2b6..621f2aac281089e5c29ca782950da7b0ec4941bb 100644 (file)
@@ -658,9 +658,10 @@ WHERE  id = %1";
 
       switch ($field['html_type']) {
         case 'Text':
-          $params["price_{$id}"] = array(key($field['options']) => $params["price_{$id}"]);
+          $firstOption = reset($field['options']);
+          $params["price_{$id}"] = array($firstOption['id'] => $params["price_{$id}"]);
           CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-          $totalPrice += $lineItem[key($field['options'])]['line_total'];
+          $totalPrice += $lineItem[$firstOption['id']]['line_total'];
           break;
 
         case 'Radio':
index 9c0f6aa4f54f34b06cc9130b971878d2ae54b59e..dae7188aae0fb50d5901b2a475ee3e3547669474 100644 (file)
@@ -170,7 +170,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page {
 
       // need to translate html types from the db
       $htmlTypes = CRM_Price_BAO_PriceField::htmlTypes();
-      $priceField[$priceFieldBAO->id]['html_type'] = $htmlTypes[$priceField[$priceFieldBAO->id]['html_type']];
+      $priceField[$priceFieldBAO->id]['html_type_display'] = $htmlTypes[$priceField[$priceFieldBAO->id]['html_type']];
       $priceField[$priceFieldBAO->id]['order'] = $priceField[$priceFieldBAO->id]['weight'];
       $priceField[$priceFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action,
         array(
index d82c8ae125f3bba2acc5c85e0970123ceb1b2a6c..c3c3c63f3d19d6538a8a486aa72f8225c9a99b50 100644 (file)
@@ -67,9 +67,11 @@ ALTER TABLE `civicrm_custom_group`
   ADD COLUMN `is_reserved` tinyint(4) DEFAULT '0' COMMENT 'Is this a reserved Custom Group?';
 
 --CRM-12986 fix event_id & contact_id to NOT NULL fields on participant table
+SET foreign_key_checks = 0;
 ALTER TABLE `civicrm_participant`
   CHANGE COLUMN `event_id` `event_id` INT(10) UNSIGNED NOT NULL,
   CHANGE COLUMN `contact_id` `contact_id` INT(10) UNSIGNED NOT NULL;
+SET foreign_key_checks = 1;
 
 -- CRM-12964 civicrm_print_label table creation
 CREATE TABLE IF NOT EXISTS `civicrm_print_label` (
index da8e706f58444aa8d27a38fc030c13c80ea46539..a6de3924a51611a5f697150c601908f1b62dfd35 100644 (file)
@@ -88,7 +88,7 @@ class CRM_Utils_Check_Security {
     $config = CRM_Core_Config::singleton();
 
     $log = CRM_Core_Error::createDebugLogger();
-    $log_filename = $log->_filename;
+    $log_filename = str_replace('\\', '/', $log->_filename);
 
     $filePathMarker = $this->getFilePathMarker();
 
@@ -282,7 +282,7 @@ class CRM_Utils_Check_Security {
     $config = CRM_Core_Config::singleton();
 
     list ($heuristicBaseUrl, $ignore) = explode($filePathMarker, $config->imageUploadURL);
-    list ($ignore, $heuristicSuffix) = explode($filePathMarker, $targetDir);
+    list ($ignore, $heuristicSuffix) = explode($filePathMarker, str_replace('\\', '/', $targetDir));
     return $heuristicBaseUrl . $filePathMarker . $heuristicSuffix;
   }
 }
diff --git a/api/v3/ActivityContact.php b/api/v3/ActivityContact.php
new file mode 100644 (file)
index 0000000..c180ae9
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 activity contact functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_ActivityContact
+ *
+ * @copyright CiviCRM LLC (c) 2004-2014
+ * @version $Id: ActivityContact.php 2014-04-01 elcapo $
+ */
+
+/**
+ *  Add a record relating a contact with an activity
+ *
+ * Allowed @params array keys are:
+ *
+ * @example ActivityContact.php
+ *
+ * @param $params
+ *
+ * @return array of newly created activity contact records.
+ * @access public
+ */
+function civicrm_api3_activity_contact_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust Metadata for Create action
+ *
+ * The metadata is used for setting defaults, documentation & validation
+ * @param array $params array or parameters determined by getfields
+ */
+function _civicrm_api3_activity_contact_create_spec(&$params) {
+  $params['contact_id']['api.required'] = 1;
+  $params['activity_id']['api.required'] = 1;
+}
+
+/**
+ * Deletes an existing ActivityContact record
+ *
+ * @param  array  $params
+ *
+ * @return array Api Result
+ *
+ * @example ActivityContact.php
+ * @access public
+ */
+function civicrm_api3_activity_contact_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Get a ActivityContact.
+ *
+ * @example ActivityContact.php
+ *
+ * @param  array $params  an associative array of name/value pairs.
+ *
+ * @return  array details of found tags else error
+ *
+ * @access public
+ */
+function civicrm_api3_activity_contact_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
index cd9f8f79d317a59fce43b5878749053889b40660..1385765a32f558163db74ed1d207fc1fb6d55b3a 100644 (file)
@@ -295,7 +295,7 @@ function civicrm_api3_contribution_transact($params) {
       return CRM_Core_Error::createApiError($last_error['message']);
     }
   }
-
+  $params['payment_instrument_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', $paymentProcessor['payment_processor_type_id'], 'payment_type') == 1 ? 'Credit Card' : 'Debit Card';
   return civicrm_api('contribution', 'create', $params);
 }
 /**
diff --git a/api/v3/FinancialAccount.php b/api/v3/FinancialAccount.php
new file mode 100644 (file)
index 0000000..c39f061
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.5                                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 financial_account functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_financial_account
+ *
+ */
+
+/**
+ * Save a financial_account
+ *
+ * Allowed @params array keys are:
+ * {@getfields financial_account_create}
+ * @example financial_accountCreate.php
+ *
+ * @param $params
+ *
+ * @return array of newly created financial_account property values.
+ * @access public
+ */
+function civicrm_api3_financial_account_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Get a financial_account
+ *
+ * Allowed @params array keys are:
+ * {@getfields financial_account_get}
+ * @example financial_accountCreate.php
+ *
+ * @param $params
+ *
+ * @return array of retrieved financial_account property values.
+ * @access public
+ */
+function civicrm_api3_financial_account_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Delete a financial_account
+ *
+ * Allowed @params array keys are:
+ * {@getfields financial_account_delete}
+ * @example financial_accountCreate.php
+ *
+ * @param $params
+ *
+ * @return array of deleted values.
+ * @access public
+ */
+function civicrm_api3_financial_account_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
diff --git a/api/v3/FinancialType.php b/api/v3/FinancialType.php
new file mode 100644 (file)
index 0000000..c0cb44c
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.5                                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 financial_type functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_financial_type
+ *
+ */
+
+/**
+ * Save a financial_type
+ *
+ * Allowed @params array keys are:
+ * {@getfields financial_type_create}
+ * @example financial_typeCreate.php
+ *
+ * @param $params
+ *
+ * @return array of newly created financial_type property values.
+ * @access public
+ */
+function civicrm_api3_financial_type_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Get a financial_type
+ *
+ * Allowed @params array keys are:
+ * {@getfields financial_type_get}
+ * @example financial_typeCreate.php
+ *
+ * @param $params
+ *
+ * @return array of retrieved financial_type property values.
+ * @access public
+ */
+function civicrm_api3_financial_type_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Delete a financial_type
+ *
+ * Allowed @params array keys are:
+ * {@getfields financial_type_delete}
+ * @example financial_typeCreate.php
+ *
+ * @param $params
+ *
+ * @return array of deleted values.
+ * @access public
+ */
+function civicrm_api3_financial_type_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
diff --git a/api/v3/examples/Case/Create.php b/api/v3/examples/Case/Create.php
new file mode 100644 (file)
index 0000000..9397a33
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Test Generated example of using case create API
+ * *
+ */
+function case_create_example(){
+$params = array(
+  'subject' => 'Test case',
+  'contact_id' => 17,
+  'case_type' => 'Housing Support',
+);
+
+try{
+  $result = civicrm_api3('case', 'create', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
+
+return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function
+ */
+function case_create_expectedresult(){
+
+  $expectedResult = array(
+  'is_error' => 0,
+  'version' => 3,
+  'count' => 1,
+  'id' => 1,
+  'values' => array(
+      '1' => array(
+          'id' => '1',
+          'case_type_id' => '4',
+          'subject' => 'Test case',
+          'start_date' => '2013-07-29 00:00:00',
+          'end_date' => '',
+          'details' => '',
+          'status_id' => '1',
+          'is_deleted' => '',
+        ),
+    ),
+);
+
+  return $expectedResult;
+}
+
+
+/*
+* This example has been generated from the API test suite. The test that created it is called
+*
+* testCaseCreate and can be found in
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CaseTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api/explorer
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
index 1d5435622e1d29069b3006dc18b7d40d4a3d9476..989e33b5d740ae14bbd79c239716bb4cb76e2d44 100755 (executable)
@@ -19,7 +19,7 @@ fi
 source "$CALLEDPATH/setup.conf"
 
 if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
-  echo; echo Usage: setup.sh [schema file] [database data file] [database name] [database user] [database password] [additional args]; echo
+  echo; echo Usage: setup.sh [schema file] [database data file] [database name] [database user] [database password] [database host] [database port] [additional args]; echo
   exit 0
 fi
 
@@ -30,6 +30,8 @@ if [ ! -z "$2" ] ; then DBLOAD="$2"; fi
 if [ ! -z "$3" ] ; then DBNAME="$3"; fi
 if [ ! -z "$4" ] ; then DBUSER="$4"; fi
 if [ ! -z "$5" ] ; then DBPASS="$5"; fi
+if [ ! -z "$6" ] ; then DBHOST="$6"; fi
+if [ ! -z "$7" ] ; then DBPORT="$7"; fi
 
 # verify if we have at least DBNAME given
 if [ -z $DBNAME ] ; then
@@ -60,10 +62,20 @@ else
   PASSWDSECTION="-p$DBPASS"
 fi
 
+HOSTSECTTION=""
+if [ ! -z "$DBHOST" ]; then
+  HOSTSECTION="-h $DBHOST"
+fi
+
+PORTSECTION=""
+if [ ! -z "$DBPORT" ]; then
+  PORTSECTION="-P $DBPORT"
+fi
+
 cd "$CALLEDPATH/../sql"
 echo; echo "Dropping civicrm_* tables from database $DBNAME"
 # mysqladmin -f -u $DBUSER $PASSWDSECTION $DBARGS drop $DBNAME
-MYSQLCMD="mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME"
+MYSQLCMD="mysql -u$DBUSER $PASSWDSECTION $HOSTSECTION $PORTSECTION $DBARGS $DBNAME"
 echo "SELECT table_name FROM information_schema.TABLES  WHERE TABLE_SCHEMA='${DBNAME}' AND TABLE_TYPE = 'VIEW'" \
   | $MYSQLCMD \
   | grep '^\(civicrm_\|log_civicrm_\)' \
@@ -77,23 +89,23 @@ echo "SELECT table_name FROM information_schema.TABLES  WHERE TABLE_SCHEMA='${DB
 
 
 echo; echo Creating database structure
-mysql -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm.mysql
+$MYSQLCMD < civicrm.mysql
 
 # load civicrm_generated.mysql sample data unless special DBLOAD is passed
 if [ -z $DBLOAD ]; then
     echo; echo Populating database with example data - civicrm_generated.mysql
-    mysql -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm_generated.mysql
+    $MYSQLCMD < civicrm_generated.mysql
 else
     echo; echo Populating database with required data - civicrm_data.mysql
-    mysql -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm_data.mysql
+    $MYSQLCMD < civicrm_data.mysql
     echo; echo Populating database with $DBLOAD data
-    mysql -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME < $DBLOAD
+    $MYSQLCMD < $DBLOAD
 fi
 
 # load additional script if DBADD defined
 if [ ! -z $DBADD ]; then
     echo; echo Loading $DBADD
-    mysql -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME < $DBADD
+    $MYSQLCMD < $DBADD
 fi
 
 # run the cli script to build the menu and the triggers
@@ -102,7 +114,7 @@ cd "$CALLEDPATH/.."
 
 # reset config_backend and userFrameworkResourceURL which gets set
 # when config object is initialized
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME -e "UPDATE civicrm_domain SET config_backend = NULL; UPDATE civicrm_setting SET value = NULL WHERE name = 'userFrameworkResourceURL';"
+$MYSQLCMD -e "UPDATE civicrm_domain SET config_backend = NULL; UPDATE civicrm_setting SET value = NULL WHERE name = 'userFrameworkResourceURL';"
 
 echo; echo "Setup Complete. Logout from your CMS to avoid session conflicts."
 
index e00f7da8f17bae6932b180904db0a0f1549b6283..da5a885760b797d564aad869973aa10635964377 100644 (file)
@@ -92,7 +92,7 @@
 {crmRegion name="contribution-confirm-recur-membership"}
                     <br />
                     <strong>{ts 1=$frequency_interval 2=$frequency_unit}I want this membership to be renewed automatically every %1 %2(s).{/ts}</strong></p>
-                    <div class="description crm-auto-renew-cancel-info">({ts}Your initial membership fee will be processed once you complete the confirmation step. You will be able to cancel the auto-renwal option by visiting the web page link that will be included in your receipt.{/ts})</div>
+                    <div class="description crm-auto-renew-cancel-info">({ts}Your initial membership fee will be processed once you complete the confirmation step. You will be able to cancel the auto-renewal option by visiting the web page link that will be included in your receipt.{/ts})</div>
 {/crmRegion}
                 {else}
 {crmRegion name="contribution-confirm-recur"}
index 70e2ab89341670262d70e4833516023efa3a9318..598a604859679b3fb3746be7d16ba5cba5f02563 100644 (file)
 {crmRegion name="contribution-thankyou-recur-membership"}
                     <br />
                     <strong>{ts 1=$frequency_interval 2=$frequency_unit}This membership will be renewed automatically every %1 %2(s).{/ts}</strong>
-                    <div class="description crm-auto-renew-cancel-info">({ts}You will receive an email receipt which includes information about how to cancel the auto-renwal option.{/ts})</div>
+                    <div class="description crm-auto-renew-cancel-info">({ts}You will receive an email receipt which includes information about how to cancel the auto-renewal option.{/ts})</div>
 {/crmRegion}
                 {else}
 {crmRegion name="contribution-thankyou-recur"}
index e84f34e9e12792a10a68bab8b93b7c84f45cbab5..d5ec72cefa165d03c6c86e35d269143c3dd5280d 100644 (file)
         {foreach from=$priceField key=fid item=row}
       <tr id="row_{$row.id}"class="{cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
             <td>{$row.label}</td>
-            <td>{$row.html_type}</td>
+            <td>{$row.html_type_display}</td>
             <td class="nowrap">{$row.order}</td>
             <td>{if $row.is_required eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
             <td id="row_{$row.id}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
             <td>{if $row.active_on}{$row.active_on|date_format:"%Y-%m-%d %T"}{/if}</td>
             <td>{if $row.expire_on}{$row.expire_on|date_format:"%Y-%m-%d %T"}{/if}</td>
-            <td>{if $row.html_type eq "Text / Numeric Quantity"}{$row.price|crmMoney}{else}<a href="{crmURL p="civicrm/admin/price/field/option" q="action=browse&reset=1&sid=$sid&fid=$fid"}">{if $isReserved}{ts}View Price Options{/ts}{else}{ts}Edit Price Options{/ts}{/if}</a>{/if}</td>
+            <td>{if $row.html_type eq "Text"}{$row.price|crmMoney}{else}<a href="{crmURL p="civicrm/admin/price/field/option" q="action=browse&reset=1&sid=$sid&fid=$fid"}">{if $isReserved}{ts}View Price Options{/ts}{else}{ts}Edit Price Options{/ts}{/if}</a>{/if}</td>
             <td class="field-action">{$row.action|replace:'xx':$row.id}</td>
             <td class="order hiddenElement">{$row.weight}</td>
         </tr>
index 0647851f05305a050daca02090285986fa1a3330..fec2099a1e6b4191c1b6796f186c2e8fb2054147 100644 (file)
@@ -24,6 +24,7 @@
  +--------------------------------------------------------------------+
 *}
 {* This included tpl checks if a given username is taken or available. *}
+{crmSigner var=checkUserSig for=civicrm/ajax/cmsuser}
 {literal}
 var lastName = null;
 cj("#checkavailability").click(function() {
@@ -56,6 +57,7 @@ cj("#checkavailability").click(function() {
    var check        = "{/literal}{ts escape='js'}Checking...{/ts}{literal}";
    var available    = "{/literal}{ts escape='js'}This username is currently available.{/ts}{literal}";
    var notavailable = "{/literal}{ts escape='js'}This username is taken.{/ts}{literal}";
+   var errorMsg     = "{/literal}{ts escape='js'}Error checking username. Please reload the form and try again.{/ts}{literal}";
 
       //remove all the class add the messagebox classes and start fading
       cj("#msgbox").removeClass().addClass('cmsmessagebox').css({"color":"#000","backgroundColor":"#FFC","border":"1px solid #c93"}).text(check).fadeIn("slow");
@@ -63,11 +65,21 @@ cj("#checkavailability").click(function() {
       //check the username exists or not from ajax
    var contactUrl = {/literal}"{crmURL p='civicrm/ajax/cmsuser' h=0 }"{literal};
 
-   cj.post(contactUrl,{ cms_name:cj("#cms_name").val() } ,function(data) {
+   var checkUserParams = {
+       cms_name: cj("#cms_name").val(),
+       ts: {/literal}"{$checkUserSig.ts}"{literal},
+       sig: {/literal}"{$checkUserSig.signature}"{literal},
+       for: 'civicrm/ajax/cmsuser'
+   };
+   cj.post(contactUrl, checkUserParams ,function(data) {
       if ( data.name == "no") {/*if username not avaiable*/
          cj("#msgbox").fadeTo(200,0.1,function() {
       cj(this).html(notavailable).addClass('cmsmessagebox').css({"color":"#CC0000","backgroundColor":"#F7CBCA","border":"1px solid #CC0000"}).fadeTo(900,1);
          });
+      } else if ( data.name == "error") {/*if username not avaiable*/
+         cj("#msgbox").fadeTo(200,0.1,function() {
+             cj(this).html(errorMsg).addClass('cmsmessagebox').css({"color":"#CC0000","backgroundColor":"#F7CBCA","border":"1px solid #CC0000"}).fadeTo(900,1);
+         });
       } else {
          cj("#msgbox").fadeTo(200,0.1,function() {
       cj(this).html(available).addClass('cmsmessagebox').css({"color":"#008000","backgroundColor":"#C9FFCA", "border": "1px solid #349534"}).fadeTo(900,1);
index abb4bf6f0c4e67c3a13ecaab47952de0cd7965de..454eb0179124158fdd913f06dbfebab305702543 100644 (file)
@@ -29,7 +29,7 @@
 {/if}
 
 <div class="crm-footer" id="civicrm-footer">
-  {include file="CRM/common/version.tpl" assign=version}
+  {crmVersion assign=version}
   {ts 1=$version}Powered by CiviCRM %1.{/ts}
   {if !empty($newer_civicrm_version)}
     <span class="status">{ts 1=$newer_civicrm_version}A newer version (%1){/ts}
index 26238035f05810d2fbc7f16bd39faba040ba166b..ef4592a7f8c4437677e3b75c2d8a1e26b89aa928 100644 (file)
@@ -549,8 +549,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'membership_id',
       'Database checked on membershiplog record.'
     );
-    $this->assertEquals($MembershipRenew->membership_type_id, $this->_membershipTypeID, 'Verify membership type is changed during renewal.');
-    $this->assertEquals($MembershipRenew->end_date, $endDate, 'Verify correct end date is calculated after membership renewal');
+    $this->assertEquals($this->_membershipTypeID, $MembershipRenew->membership_type_id, 'Verify membership type is changed during renewal.');
+    $this->assertEquals($endDate, $MembershipRenew->end_date, 'Verify correct end date is calculated after membership renewal');
 
     $this->membershipDelete($membershipId);
     Contact::delete($contactId);
index b1a2fd908a303d241edfd3eff7c3c7d27c965858..091ac02595f5f5794e6db4eda0b406f88e27a755 100644 (file)
@@ -270,7 +270,7 @@ class api_v3_CaseTest extends CiviUnitTestCase {
     // Test using label instead of value
     unset($params['case_type_id']);
     $params['case_type'] = 'Housing Support';
-    $result = $this->callAPISuccess('case', 'create', $params);
+    $result = $this->callAPIAndDocument('case', 'create', $params, __FUNCTION__, __FILE__);
     $id = $result['id'];
 
     // Check result
index 7527b27ec40125fd653ba98f1a1f85fe9701c1a7..bdaa8fb5efc7afa35cb7ff1ecd0de286f81092a6 100644 (file)
@@ -248,6 +248,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
       'MailSettings',
       'Setting',
       'MailingContact',
+      //temporary for 4.4 - do not merge to 4.5
+      'FinancialType',
+      'FinancialAccount',
     );
     if ($sequential === TRUE) {
       return $entitiesWithout;
@@ -286,6 +289,11 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
           'group_id',
         ),
       ),
+      'ActivityContact' => array(
+        'cant_update' => array(
+          'activity_id', //we have an FK on activity_id + contact_id + record id so if we don't leave this one distinct we get an FK constraint error
+        ),
+      ),
       'Address' => array(
         'cant_update' => array(
           'state_province_id', //issues with country id - need to ensure same country
index 5eaed2dfc01cf3dac673c982f7476978b9e6f4b7..827cd944841c3d7a41e217cf3778062e0831b233 100755 (executable)
@@ -47,6 +47,11 @@ ini_set('include_path',
         "$civi_pkgs_dir"        . PATH_SEPARATOR
         . ini_get( 'include_path') );
 
+if (!is_dir("$civi_pkgs_dir/PHPUnit")) {
+  fwrite(STDERR, "PHPUnit is not embedded with this copy of CiviCRM. Perhaps you should use the standalone phpunit command?\n\nExample: \"phpunit tests/phpunit/CRM/Core/RegionTest.php\"\n");
+  exit(1);
+}
+
 #  Relying on system timezone setting produces a warning,
 #  doing the following prevents the warning message
 if ( file_exists( '/etc/timezone' ) ) {