Merge pull request #2288 from eileenmcnaughton/CRM-14043
authorKurund Jalmi <kurund@civicrm.org>
Wed, 8 Jan 2014 20:31:07 +0000 (12:31 -0800)
committerKurund Jalmi <kurund@civicrm.org>
Wed, 8 Jan 2014 20:31:07 +0000 (12:31 -0800)
CRM-14043 - cid=0 contribution form giving contribution to logged in use...

42 files changed:
CRM/Activity/BAO/Activity.php
CRM/Contact/BAO/Query.php
CRM/Contact/BAO/Relationship.php
CRM/Contact/Form/Edit/CommunicationPreferences.php
CRM/Contact/Form/Inline/CommunicationPreferences.php
CRM/Contact/Form/Search/Custom/Group.php
CRM/Contact/Page/View/Email.php [deleted file]
CRM/Contact/Page/View/SMS.php [deleted file]
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/ContributionBase.php
CRM/Contribute/Form/SoftCredit.php
CRM/Contribute/Page/Tab.php
CRM/Core/BAO/Setting.php
CRM/Core/Page/Inline/Help.php
CRM/Core/Smarty/plugins/function.help.php
CRM/Event/Cart/BAO/MerParticipant.php
CRM/Export/BAO/Export.php
CRM/Mailing/Page/View.php
CRM/Member/BAO/Membership.php
CRM/Report/Form/Activity.php
CRM/Upgrade/Incremental/php/FourFour.php
CRM/Upgrade/TwoTwo/Form/Step3.php
api/v3/examples/Setting/CreateAllDomains.php
api/v3/examples/Setting/CreateSettingCurrentDomain.php
api/v3/examples/Setting/CreateSpecifiedDomains.php
api/v3/examples/Setting/GetAllDomains.php
api/v3/examples/Setting/GetDefaults.php
api/v3/examples/Setting/GetSettingCurrentDomain.php
api/v3/examples/Setting/GetSpecifiedDomains.php
api/v3/examples/SettingCreate.php
api/v3/examples/SettingGet.php
api/v3/examples/SettingGetValue.php
api/v3/examples/SettingGetfields.php
api/v3/examples/SettingRevert.php
templates/CRM/Contact/Form/Search/Criteria/ChangeLog.tpl
templates/CRM/Contribute/Form/Selector.tpl
templates/CRM/Price/Form/Calculate.tpl
templates/CRM/common/contactFooter.tpl
tests/phpunit/WebTest/Event/AddEventTest.php
tests/phpunit/api/v3/SettingTest.php
tests/phpunit/api/v3/settings/test.setting.php [new file with mode: 0644]

index 8ab5ad2e29925b609f4ef6e298c36f86fdabdefe..684fc06bfc116f8f06adbcda4c1092b292200afa 100644 (file)
@@ -2361,7 +2361,7 @@ INNER JOIN  civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n
 
         //get the assignee contacts.
         if ($allow) {
-          $assigneeContacts = CRM_Activity_BAO_Contact::retrieveContactIdsByActivityId($activity->id, $assigneeID);
+          $assigneeContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activity->id, $assigneeID);
           foreach ($assigneeContacts as $cnt => $contactId) {
             if (!CRM_Contact_BAO_Contact_Permission::allow($contactId, $permission)) {
               $allow = FALSE;
index f875fcee64551f70f5fbf5c9d4d9b4d0df31018a..341b293af397bff2a8f94bb651a9f1378a78c899 100644 (file)
@@ -2444,8 +2444,8 @@ class CRM_Contact_BAO_Query {
           continue;
 
         case 'civicrm_log':
-          $from .= " $side JOIN civicrm_log ON (civicrm_log.entity_id = contact_a.id AND civicrm_log.entity_table = 'civicrm_contact')";
-          $from .= " $side JOIN civicrm_contact contact_b_log ON (civicrm_log.modified_id = contact_b_log.id)";
+          $from .= " INNER JOIN civicrm_log ON (civicrm_log.entity_id = contact_a.id AND civicrm_log.entity_table = 'civicrm_contact')";
+          $from .= " INNER JOIN civicrm_contact contact_b_log ON (civicrm_log.modified_id = contact_b_log.id)";
           continue;
 
         case 'civicrm_tag':
@@ -3653,7 +3653,7 @@ WHERE  id IN ( $groupIDs )
     $name = $targetName[4] ? "%$name%" : $name;
     $this->_where[$grouping][] = "contact_b_log.sort_name LIKE '%$name%'";
     $this->_tables['civicrm_log'] = $this->_whereTables['civicrm_log'] = 1;
-    $this->_qill[$grouping][] = ts('Changed by') . ": $name";
+    $this->_qill[$grouping][] = ts('Modified by') . ": $name";
   }
 
   function modifiedDates($values) {
@@ -3661,18 +3661,20 @@ WHERE  id IN ( $groupIDs )
 
     // CRM-11281, default to added date if not set
     $fieldTitle = ts('Added Date');
-
+    $fieldName = 'created_date';
     foreach (array_keys($this->_params) as $id) {
       if ($this->_params[$id][0] == 'log_date') {
         if ($this->_params[$id][2] == 2) {
           $fieldTitle = ts('Modified Date');
+          $fieldName = 'modified_date';
         }
       }
     }
 
-    $this->dateQueryBuilder($values,
-      'civicrm_log', 'log_date', 'modified_date', $fieldTitle
-    );
+
+    $this->dateQueryBuilder($values, 'contact_a', 'log_date', $fieldName, $fieldTitle);
+
+    self::$_openedPanes[ts('Change Log')] = TRUE;
   }
 
   function demographics(&$values) {
@@ -4751,16 +4753,6 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count,
       $this->_tables[$tableName] = $this->_whereTables[$tableName] = 1;
       $this->_qill[$grouping][] = "$fieldTitle - $phrase \"$format\"";
     }
-
-    if (
-      $tableName == 'civicrm_log' &&
-      $fieldTitle == ts('Added Date')
-    ) {
-      //CRM-6903 --hack to check modified date of first record.
-      //as added date means first modified date of object.
-      $addedDateQuery = 'select id from civicrm_log group by entity_id order by id';
-      $this->_where[$grouping][] = "civicrm_log.id IN ( {$addedDateQuery} )";
-    }
   }
 
   function numberRangeBuilder(&$values,
index 4f40d5015a2a501fe7db78e8dcb9a044534e5109..2085564ad34920047c25af67883983c38c8016d6 100644 (file)
@@ -1449,7 +1449,7 @@ WHERE id IN ( {$contacts} )
   * Function to return list of permissioned contacts for a given contact and relationship type
   *
   * @param $contactID int contact id whose permissioned contacts are to be found.
-  * @param $relTypeId relationship type id
+  * @param $relTypeId string one or more relationship type id's
   * @param $name string
   *
   * @static
@@ -1465,7 +1465,7 @@ SELECT cc.id as id, cc.sort_name as name
 FROM civicrm_relationship cr, civicrm_contact cc
 WHERE
 cr.contact_id_a         = %1 AND
-cr.relationship_type_id = %2 AND
+cr.relationship_type_id IN (%2) AND
 cr.is_permission_a_b    = 1 AND
 IF(cr.end_date IS NULL, 1, (DATEDIFF( CURDATE( ), cr.end_date ) <= 0)) AND
 cr.is_active = 1 AND
@@ -1477,7 +1477,7 @@ cc.id = cr.contact_id_b";
 AND cc.sort_name LIKE '%$name%'";
       }
 
-      $args = array(1 => array($contactID, 'Integer'), 2 => array($relTypeId, 'Integer'));
+      $args = array(1 => array($contactID, 'Integer'), 2 => array($relTypeId, 'String'));
       $dao  = CRM_Core_DAO::executeQuery($query, $args);
 
       while ($dao->fetch()) {
index 207fb2d9d5acc9b4b6b758397e5b5972700b2ea9..a57f66d3fed7491afd500ea7d5d7dfadde613a0b 100644 (file)
@@ -162,9 +162,8 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
   static function setDefaultValues(&$form, &$defaults) {
 
     if (!empty($defaults['preferred_language'])) {
-      $defaults['preferred_language'] = CRM_Utils_Array::key($defaults['preferred_language'],
-        CRM_Contact_BAO_Contact::buildOptions('preferred_language')
-      );
+      $languages = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
+      $defaults['preferred_language'] = CRM_Utils_Array::key($defaults['preferred_language'], $languages);
     }
 
     // CRM-7119: set preferred_language to default if unset
index 6c1804b4dcf0799797319b0969795b0865cd2eac..3ce08e9cd35148b2211c606a97c88717b8bfc847 100644 (file)
@@ -60,9 +60,8 @@ class CRM_Contact_Form_Inline_CommunicationPreferences extends CRM_Contact_Form_
     $defaults = parent::setDefaultValues();
 
     if (!empty($defaults['preferred_language'])) {
-      $defaults['preferred_language'] = CRM_Utils_Array::key($defaults['preferred_language'],
-        CRM_Contact_BAO_Contact::buildOptions('preferred_language')
-      );
+      $languages = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
+      $defaults['preferred_language'] = CRM_Utils_Array::key($defaults['preferred_language'], $languages);
     }
 
     // CRM-7119: set preferred_language to default if unset
index b40d55f122f2058c722178a2af378efd2fa026e0..8982da93c23b73785f483e75dba3ace39d917216 100644 (file)
@@ -303,16 +303,19 @@ class CRM_Contact_Form_Search_Custom_Group
         //search for smart group contacts
         foreach ($this->_excludeGroups as $keys => $values) {
           if (in_array($values, $smartGroup)) {
-            $ssId = CRM_Utils_Array::key($values, $smartGroup);
-
-            $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId);
-
-            $smartSql = $smartSql . " AND contact_a.id NOT IN (
-                              SELECT contact_id FROM civicrm_group_contact
-                              WHERE civicrm_group_contact.group_id = {$values} AND civicrm_group_contact.status = 'Removed')";
-
+            $ssGroup = new CRM_Contact_DAO_Group();
+            $ssGroup->id = $values;
+            if (!$ssGroup->find(TRUE)) {
+              CRM_Core_Error::fatal();
+            }
+            CRM_Contact_BAO_GroupContactCache::load($ssGroup);
+
+            $smartSql = "
+SELECT gcc.contact_id
+FROM   civicrm_group_contact_cache gcc
+WHERE  gcc.group_id = {$ssGroup->id}
+";
             $smartGroupQuery = " INSERT IGNORE INTO Xg_{$this->_tableName}(contact_id) $smartSql";
-
             CRM_Core_DAO::executeQuery($smartGroupQuery);
           }
         }
@@ -366,18 +369,22 @@ class CRM_Contact_Form_Search_Custom_Group
 
       foreach ($this->_includeGroups as $keys => $values) {
         if (in_array($values, $smartGroup)) {
+          $ssGroup = new CRM_Contact_DAO_Group();
+          $ssGroup->id = $values;
+          if (!$ssGroup->find(TRUE)) {
+            CRM_Core_Error::fatal();
+          }
+          CRM_Contact_BAO_GroupContactCache::load($ssGroup);
 
-          $ssId = CRM_Utils_Array::key($values, $smartGroup);
-
-          $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId);
-
-          $smartSql .= " AND contact_a.id NOT IN (
-                              SELECT contact_id FROM civicrm_group_contact
-                              WHERE civicrm_group_contact.group_id = {$values} AND civicrm_group_contact.status = 'Removed')";
+          $smartSql = "
+SELECT gcc.contact_id
+FROM   civicrm_group_contact_cache gcc
+WHERE  gcc.group_id = {$ssGroup->id}
+";
 
           //used only when exclude group is selected
           if ($xGroups != 0) {
-            $smartSql .= " AND contact_a.id NOT IN (SELECT contact_id FROM  Xg_{$this->_tableName})";
+            $smartSql .= " AND gcc.contact_id NOT IN (SELECT contact_id FROM  Xg_{$this->_tableName})";
           }
 
           $smartGroupQuery = " INSERT IGNORE INTO Ig_{$this->_tableName}(contact_id)
diff --git a/CRM/Contact/Page/View/Email.php b/CRM/Contact/Page/View/Email.php
deleted file mode 100644 (file)
index 99065b7..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?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 (c) 2004-2013
- * $Id$
- *
- */
-
-/**
- * Dummy page for details of Email
- *
- */
-class CRM_Contact_Page_View_Email extends CRM_Core_Page {
-
-  /**
-   * Run the page.
-   *
-   * This method is called after the page is created.
-   *
-   * @return void
-   * @access public
-   *
-   */
-  function run() {
-    // get the callback, module and activity id
-    $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse' );
-    $id = CRM_Utils_Request::retrieve('id', 'Positive', $this );
-
-    $dao                = new CRM_Core_DAO_ActivityHistory();
-    $dao->activity_id   = $id;
-    $dao->activity_type = ts('Email Sent');
-    if ($dao->find(TRUE)) {
-      $cid = $dao->entity_id;
-    }
-
-    $dao = new CRM_Core_DAO_EmailHistory();
-    $dao->id = $id;
-
-    if ($dao->find(TRUE)) {
-      // get the display name and email for the contact
-      list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
-
-      if (!trim($toContactName)) {
-        $toContactName = $toContactEmail;
-      }
-
-      if (trim($toContactEmail)) {
-        $toContactName = "\"$toContactName\" <$toContactEmail>";
-      }
-
-      $this->assign('toName', $toContactName);
-
-      // get the display name and email for the contact
-      list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
-
-      if (!trim($fromContactEmail)) {
-        CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
-      }
-
-      if (!trim($fromContactName)) {
-        $fromContactName = $fromContactEmail;
-      }
-
-      $this->assign('fromName', "\"$fromContactName\" <$fromContactEmail>");
-
-      $this->assign('sentDate', $dao->sent_date);
-      $this->assign('subject', $dao->subject);
-      $this->assign('message', $dao->message);
-
-      // get the display name and images for the contact
-      list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
-
-      CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
-      // also add the cid params to the Menu array
-      CRM_Core_Menu::addParam('cid', $cid);
-    }
-    return parent::run();
-  }
-}
-
diff --git a/CRM/Contact/Page/View/SMS.php b/CRM/Contact/Page/View/SMS.php
deleted file mode 100644 (file)
index 48ede7f..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?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 (c) 2004-2013
- * $Id$
- *
- */
-
-/**
- * Dummy page for details of SMS
- *
- */
-class CRM_Contact_Page_View_SMS extends CRM_Core_Page {
-
-  /**
-   * Run the page.
-   *
-   * This method is called after the page is created.
-   *
-   * @return void
-   * @access public
-   *
-   */
-  function run() {
-    // get the callback, module and activity id
-    $action = CRM_Utils_Request::retrieve('action', 'String',
-      $this, FALSE, 'browse'
-    );
-    $id = CRM_Utils_Request::retrieve('id', 'Positive',
-      $this
-    );
-
-    $dao                = new CRM_Core_DAO_ActivityHistory();
-    $dao->activity_id   = $id;
-    $dao->activity_type = ts('SMS Sent');
-    if ($dao->find(TRUE)) {
-      $cid = $dao->entity_id;
-    }
-
-    $dao = new CRM_SMS_DAO_History();
-    $dao->id = $id;
-
-    if ($dao->find(TRUE)) {
-      $this->assign('fromName',
-        CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
-          $dao->contact_id,
-          'display_name'
-        )
-      );
-      $this->assign('toName',
-        CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
-          $cid,
-          'display_name'
-        )
-      );
-      $this->assign('sentDate', $dao->sent_date);
-      $this->assign('message', $dao->message);
-
-      // get the display name and images for the contact
-      list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
-
-      CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
-
-      // also add the cid params to the Menu array
-      CRM_Core_Menu::addParam('cid', $cid);
-    }
-    return parent::run();
-  }
-}
-
index 180fd19f2f40afd040552652c2e1626816f9617b..6dd36b9930806746868fa005568490e6aa323792 100644 (file)
@@ -920,7 +920,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       }
     }
 
-    $softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields);
+    $softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
 
     if (CRM_Utils_Array::value('total_amount', $fields) && (CRM_Utils_Array::value('net_amount', $fields) || CRM_Utils_Array::value('fee_amount', $fields))) {
       $sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
index 1bf2237ddba6bffb1e513dbd6ac37b68766418a3..68918da67f3ac9f4b627c5f1845fee03545f5c33 100644 (file)
@@ -977,7 +977,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       }
       elseif (CRM_Utils_Array::value('is_pledge', $fields)) {
         if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_installments', $fields)) == FALSE) {
-          $errors['pledge_installments'] = ts('Please enter a valid pledge installment.');
+          $errors['pledge_installments'] = ts('Please enter a valid number of pledge installments.');
         }
         else {
           if (CRM_Utils_Array::value('pledge_installments', $fields) == NULL) {
index e92bdf45c1cd341035654df73d3788d05a488ab5..f4d409e18ad368f4324fdb130ba5e8af667510c4 100644 (file)
@@ -230,6 +230,9 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
               $membershipType = new CRM_Member_BAO_MembershipType();
               $membershipType->id = $membership->membership_type_id;
               if ($membershipType->find(TRUE)) {
+                // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
+                // Convert to commma separated list.
+                $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
                 $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
                 if (array_key_exists($membership->contact_id, $permContacts)) {
                   $this->_membershipContactID = $membership->contact_id;
index bb1686d410d347519054efe5f363f036ca2bcb35..96490e260d4e8b6803eaa118677c4953d08001b3 100644 (file)
@@ -130,7 +130,7 @@ class CRM_Contribute_Form_SoftCredit {
    * @access public
    * @static
    */
-  static function formRule($fields) {
+  static function formRule($fields, $errors, $self) {
     $errors = array();
 
     // if honor roll fields are populated but no PCP is selected
@@ -150,7 +150,7 @@ class CRM_Contribute_Form_SoftCredit {
           if ($repeat[$fields['soft_credit_contact_select_id'][$key]] > 1) {
             $errors["soft_credit_contact_select_id[$key]"] = ts('You cannot enter multiple soft credits for the same contact.');
           }
-          if ($fields['soft_credit_amount'][$key]
+          if ($self->_action == CRM_Core_Action::ADD && $fields['soft_credit_amount'][$key]
             && (CRM_Utils_Rule::cleanMoney($fields['soft_credit_amount'][$key]) > CRM_Utils_Rule::cleanMoney($fields['total_amount']))) {
             $errors["soft_credit_amount[$key]"] = ts('Soft credit amount cannot be more than the total amount.');
           }
index 9ccdb57df3746d0cdb33556555a4edb3b66cf1ef..f6fc59983e2d48867aa6ca576fb50165b3c45c89 100644 (file)
@@ -167,6 +167,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
     $controller->set('cid', $this->_contactId);
     $controller->set('crid', $this->_crid);
     $controller->set('context', 'contribution');
+    $controller->set('limit', 50);
     $controller->process();
     $controller->run();
 
index 5638032038cbd8b541d8a952e285c2275cbb2eec..87a5fdd3790e0822166380646e6a6e86abd6863c 100644 (file)
@@ -630,6 +630,8 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
       $cacheString .= "_{$filterField}_{$filterString}";
     }
     $cached = 1;
+    // the caching into 'All' seems to be a duplicate of caching to
+    // settingsMetadata__ - I think the reason was to cache all settings as defined & then those altered by a hook
     $settingsMetadata = CRM_Core_BAO_Cache::getItem('CiviCRM setting Specs', $cacheString, $componentID);
     if ($settingsMetadata === NULL) {
       $settingsMetadata = CRM_Core_BAO_Cache::getItem('CiviCRM setting Spec', 'All', $componentID);
index 5a4c5b2ede487c5fa9dfc1f0097a741fc4167d8e..c09e5550c8659c11b20ef25c2d828db2f07ad138 100644 (file)
@@ -41,6 +41,7 @@ class CRM_Core_Page_Inline_Help {
     $args = $_REQUEST;
     if (!empty($args['file']) && strpos($args['file'], '..') === FALSE) {
       $file = $args['file'] . '.hlp';
+      $additionalTPLFile = $args['file'] . '.extra.hlp';
       $smarty = CRM_Core_Smarty::singleton();
       $smarty->assign('id', $args['id']);
       CRM_Utils_Array::remove($args, 'file', 'class_name', 'type', 'q', 'id');
@@ -48,7 +49,15 @@ class CRM_Core_Page_Inline_Help {
         $arg = strip_tags($arg);
       }
       $smarty->assign('params', $args);
-      exit($smarty->fetch($file));
+
+      $extraoutput = '';
+      if ($smarty->template_exists($additionalTPLFile)) {
+        //@todo hook has been put here as a conservative approach
+        // but probably should always run. It doesn't run otherwise because of the exit
+        CRM_Utils_Hook::pageRun($this);
+        $extraoutput .= trim($smarty->fetch($additionalTPLFile));
+      }
+      exit($smarty->fetch($file) . $extraoutput);
     }
   }
 }
index b3e79bb53008432defb1606e257f191aaa884941..f369d6d01118b9d59e483e422bc38dd6d19b3694 100644 (file)
@@ -51,7 +51,7 @@ function smarty_function_help($params, &$smarty) {
     $params['file'] = $smarty->_tpl_vars['tplFile'];
   }
   elseif (empty($params['file'])) {
-    return $help;
+    return NULL;
   }
 
   $params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
@@ -61,11 +61,16 @@ function smarty_function_help($params, &$smarty) {
     $oldID = $smarty->get_template_vars('id');
     $smarty->assign('id', $params['id'] . '-title');
     $name = trim($smarty->fetch($params['file'] . '.hlp'));
+    $additionalTPLFile = $params['file'] . '.extra.hlp';
+    if ($smarty->template_exists($additionalTPLFile)) {
+      $name .= trim($smarty->fetch($additionalTPLFile));
+    }
     $smarty->assign('id', $oldID);
   }
   else {
     $name = trim(strip_tags($params['title']));
   }
+
   // Escape for html
   $title = htmlspecialchars(ts('%1 Help', array(1 => $name)));
   // Escape for html and js
index a95347908a4a222ef37fca389af260838b7e80d4..0e6929ad382961e3091f710fab291ac633e18e60 100644 (file)
@@ -39,7 +39,7 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant {
     $this->email = CRM_Utils_Array::value('email', $participant);
   }
 
-  public static function &create(&$params) {
+  public static function &create($params) {
     $participantParams = array(
       'id' => CRM_Utils_Array::value('id', $params),
       'role_id' => self::get_attendee_role_id(),
index 3a5ab9c2317614dd3f95e3762b645f48fa4fbfcb..e1fbe289bff3cd542a7ab04fdc41b51318159571 100644 (file)
@@ -554,6 +554,20 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
       $groupBy = " GROUP BY contact_a.id";
     }
 
+    switch ($exportMode) {
+      case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
+        $groupBy = 'GROUP BY civicrm_contribution.id';
+        break;
+
+      case CRM_Export_Form_Select::EVENT_EXPORT:
+        $groupBy = 'GROUP BY civicrm_participant.id';
+        break;
+
+      case CRM_Export_Form_Select::MEMBER_EXPORT:
+        $groupBy = " GROUP BY civicrm_membership.id";
+        break;
+    }
+
     if ($queryMode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
       $groupBy = " GROUP BY civicrm_activity.id ";
     }
@@ -856,13 +870,28 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
                   $fieldValue = CRM_Utils_Array::value($relationValue, $imProviders);
                 }
               }
+              // CRM-13995
+              elseif (is_object($relDAO) && in_array($relationField, array(
+                'email_greeting', 'postal_greeting', 'addressee'))) {
+                //special case for greeting replacement
+                $fldValue = "{$relationField}_display";
+                $fieldValue = $relDAO->$fldValue;
+              }
+              elseif ( is_object($relDAO) && $relationField == 'state_province' ) {
+                $fieldValue = CRM_Core_PseudoConstant::stateProvince($relDAO->state_province_id);
+              }
+              elseif ( is_object($relDAO) && $relationField == 'country' ) {
+                $fieldValue = CRM_Core_PseudoConstant::country($relDAO->country_id);
+              }
               else {
                 $fieldValue = '';
               }
               $field = $field . '_';
+
               if (is_object($relDAO) && $relationField == 'id') {
                 $row[$field . $relationField] = $relDAO->contact_id;
-                            } else  if ( is_object( $relDAO ) && is_array( $relationValue ) && $relationField == 'location' ) {
+              }
+              elseif ( is_object( $relDAO ) && is_array( $relationValue ) && $relationField == 'location' ) {
                 foreach ($relationValue as $ltype => $val) {
                   foreach (array_keys($val) as $fld) {
                     $type = explode('-', $fld);
@@ -904,12 +933,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
                     $relationQuery[$field]->_options
                   );
                 }
-                elseif (in_array($relationField, array(
-                  'email_greeting', 'postal_greeting', 'addressee'))) {
-                  //special case for greeting replacement
-                  $fldValue = "{$relationField}_display";
-                  $row[$field . $relationField] = $relDAO->$fldValue;
-                }
                 else {
                   //normal relationship fields
                   // CRM-3157: localise country, region (both have â€˜country’ context) and state_province (‘province’ context)
index 3581427a0661106bbeaa4b59f50e636a0407e51d..42cb594f20606b35ae414bcf035a4de95834d24e 100644 (file)
@@ -117,19 +117,21 @@ class CRM_Mailing_Page_View extends CRM_Core_Page {
     if (isset($this->_contactID)) {
       //get details of contact with token value including Custom Field Token Values.CRM-3734
       $returnProperties = $this->_mailing->getReturnProperties();
-      $params           = array('contact_id' => $this->_contactID);
-      $details          = CRM_Utils_Token::getTokenDetails($params,
+      $params = array('contact_id' => $this->_contactID);
+      $details = CRM_Utils_Token::getTokenDetails($params,
         $returnProperties,
-        TRUE, TRUE, NULL,
+        FALSE, TRUE, NULL,
         $this->_mailing->getFlattenedTokens(),
         get_class($this)
       );
       $details = $details[0][$this->_contactID];
+      $contactId = $this->_contactID;
     }
     else {
       $details = array('test');
+      $contactId = 0;
     }
-    $mime = &$this->_mailing->compose(NULL, NULL, NULL, 0,
+    $mime = &$this->_mailing->compose(NULL, NULL, NULL, $contactId,
       $this->_mailing->from_email,
       $this->_mailing->from_email,
       TRUE, $details, $attachments
index a7cddea3ddf0d0577bda46d556c89757f3950cc7..9ee8b864ec8c8c766f64034fccdb0223dd7c9da4 100644 (file)
@@ -105,7 +105,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
 
     //get the log start date.
     //it is set during renewal of membership.
-    $logStartDate = CRM_Utils_array::value('log_start_date', $params);
+    $logStartDate = CRM_Utils_Array::value('log_start_date', $params);
     $logStartDate = ($logStartDate) ? CRM_Utils_Date::isoToMysql($logStartDate) : CRM_Utils_Date::isoToMysql($membership->start_date);
     $values       = self::getStatusANDTypeValues($membership->id);
 
@@ -235,6 +235,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
       !CRM_Utils_Array::value('skipStatusCal', $params)
     ) {
       $dates = array('start_date', 'end_date', 'join_date');
+      $start_date = $end_date = $join_date = NULL; // declare these out of courtesy as IDEs don't pick up the setting of them below
       foreach ($dates as $date) {
         $$date = $params[$date] = CRM_Utils_Date::processDate(CRM_Utils_Array::value($date, $params), NULL, TRUE, 'Ymd');
       }
@@ -333,6 +334,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
       CRM_Utils_Array::value('createActivity', $params)
     ) {
       if (CRM_Utils_Array::value('membership', $ids)) {
+        $data = array();
         CRM_Core_DAO::commonRetrieveAll('CRM_Member_DAO_Membership',
           'id',
           $membership->id,
@@ -966,7 +968,7 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
     if ($onlySameParentOrg && $memType) {
       // require the same parent org as the $memType
       $params = array('id' => $memType);
-      $defaults = array();
+      $defaults = $membershipType = array();
       if (CRM_Member_BAO_MembershipType::retrieve($params, $membershipType)) {
         $memberTypesSameParentOrg = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($membershipType['member_of_contact_id']);
         $memberTypesSameParentOrgList = implode(',', array_keys($memberTypesSameParentOrg));
@@ -2400,7 +2402,7 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
   function processPriceSet($membershipId, $lineItem) {
     //FIXME : need to move this too
     if (!$membershipId || !is_array($lineItem)
-      || CRM_Utils_system::isNull($lineItem)
+      || CRM_Utils_System::isNull($lineItem)
     ) {
       return;
     }
index dbb643ce867c0bf7490124fa94825393557639d4..4fe312a39169da1107406e52c085b2989c6f7dec 100644 (file)
@@ -558,7 +558,7 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}";
       if ($dao->addtogroup_contact_id) {
         $contact_id = explode(';', $dao->addtogroup_contact_id);
         if ($contact_id[0]) {
-          $contactIDs[] = $contact_id[0];
+          $contactIDs[$contact_id[0]] = $contact_id[0];
         }
       }
     }
index ca7665724ce1b28bbc709c6bf543d24c4f0e347e..dcfffb667456289f94e14873c1604e1a7152f54d 100644 (file)
@@ -215,6 +215,38 @@ VALUES {$insertStatus}";
   }
 
   function upgrade_4_4_4($rev) {
+    $fkConstraint = array();
+    if (!CRM_Core_DAO::checkFKConstraintInFormat('civicrm_activity_contact', 'activity_id')) {
+      $fkConstraint[] = "ADD CONSTRAINT `FK_civicrm_activity_contact_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE CASCADE";
+    }
+    if (!CRM_Core_DAO::checkFKConstraintInFormat('civicrm_activity_contact', 'contact_id')) {
+      $fkConstraint[] = "ADD CONSTRAINT `FK_civicrm_activity_contact_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE;
+";
+    }
+
+    if (!empty($fkConstraint)) {
+      $fkConstraint = implode(',', $fkConstraint);
+      $sql = "ALTER TABLE `civicrm_activity_contact`
+{$fkConstraint}
+";
+      // CRM-14036 : delete entries of un-mapped contacts
+        CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
+LEFT JOIN civicrm_contact c
+ON c.id = ac.contact_id
+WHERE c.id IS NULL;
+");
+        // delete entries of un-mapped activities
+        CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
+LEFT JOIN civicrm_activity a
+ON a.id = ac.activity_id
+WHERE a.id IS NULL;
+");
+
+      CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS=0;");
+      CRM_Core_DAO::executeQuery($sql);
+      CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS=1;");
+    }
+
     // task to process sql
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.4')), 'task_4_4_x_runSql', $rev);
 
@@ -256,6 +288,7 @@ ALTER TABLE civicrm_dashboard
     ";
 
     CRM_Core_DAO::executeQuery($query);
+    return TRUE;
   }
 
   /**
index f3f45079036214679f624e661b93dffb08aff41f..544885bd9344ee306259f78d821aeb160575c3c3 100644 (file)
@@ -287,7 +287,8 @@ ALTER TABLE `civicrm_domain`
       $domain->config_backend = serialize($backendValues);
       $domain->save();
 
-      $mailingDomain = new CRM_Core_DAO_Preferences();
+      $sql = 'SELECT id, mailing_backend FROM civicrm_preferences';
+      $mailingDomain = CRM_Core_DAO::executeQuery($sql);
       $mailingDomain->find(TRUE);
       $mailingDomain->mailing_backend = serialize($mailerValues);
       $mailingDomain->save();
index fb82eb3c7ff5dc58821f6c3be003bb7b93664d60..8e1cc71ffa5d7c53f055cef142587f59641b2c89 100644 (file)
@@ -69,4 +69,4 @@ function setting_create_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 78d29eeb58966b8e8a29b45dba36215d4891b86f..95c6a3e748a9e0cfd64e6d647fb51e05c28d8658 100644 (file)
@@ -63,4 +63,4 @@ function setting_create_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 4cc871247012fd75aa87fb586502928fbd3bef79..ced6602f96390ccb76fa088b335ec758827666cf 100644 (file)
@@ -69,4 +69,4 @@ function setting_create_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 32af9a1a66cb80301261f4d8f6e97a1ebfed29a9..dcf1fa8ac58d38dfc2d2d0f76e6bbf06a21df100 100644 (file)
@@ -69,4 +69,4 @@ function setting_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 5084c159cee6aacd1edf3a98d75819fdc3ffa40a..4a9a404b3f3e8bd3f7a7d356552483f1874c8fa2 100644 (file)
@@ -68,4 +68,4 @@ function setting_getdefaults_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index b5b43f9741dc054beea8e7cc13f8f71da0d15f2a..c689047385b841fac3d58720354d1f5d68d4c759 100644 (file)
@@ -63,4 +63,4 @@ function setting_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index f839e0934cddb963dcefa254dbda829c802b0145..afa2601993c5e076f75a1b5ceeb460dfb5f652c3 100644 (file)
@@ -71,4 +71,4 @@ function setting_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 146335553228b993943126892670eaa62c2c7f13..b5a337a50040ca88212e39a00d2a869a88b890b0 100644 (file)
@@ -64,4 +64,4 @@ function setting_create_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 714ae6d338ef6c8258e9863136a78cd30d0694e3..e00ef28be324b21fec3dbf789fdcd12a5c420bb0 100644 (file)
@@ -64,4 +64,4 @@ function setting_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index c48517dd99822070ac3c2087fdf89842ebc5412f..6455fa9e377f1e24cd1db9d4d346adaa90df5105 100644 (file)
@@ -54,4 +54,4 @@ function setting_getvalue_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index bdbf0569548ed1a4b882c8304cb5a5ca870ab7fb..cff321c4d83d4cdca50341dd21dbc693e552b640 100644 (file)
@@ -28,7 +28,7 @@ function setting_getfields_expectedresult(){
   $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
-  'count' => 81,
+  'count' => 82,
   'values' => array(
       'address_standardization_provider' => array(
           'group_name' => 'Address Preferences',
@@ -654,6 +654,27 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
           'description' => '',
           'help_text' => '',
         ),
+      'blogUrl' => array(
+          'group_name' => 'CiviCRM Preferences',
+          'group' => 'core',
+          'name' => 'blogUrl',
+          'prefetch' => 0,
+          'config_only' => 0,
+          'type' => 'String',
+          'quick_form_type' => 'Element',
+          'html_type' => 'Text',
+          'html_attributes' => array(
+              'size' => 64,
+              'maxlength' => 128,
+            ),
+          'default' => '*default*',
+          'add' => '4.3',
+          'title' => 'Blog Feed URL',
+          'is_domain' => 1,
+          'is_contact' => 0,
+          'description' => 'Blog feed URL used by the blog dashlet',
+          'help_text' => 'Use \"*default*\" for the system default or override with a custom URL',
+        ),
       'communityMessagesUrl' => array(
           'group_name' => 'CiviCRM Preferences',
           'group' => 'core',
@@ -768,6 +789,16 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
           'is_contact' => 0,
           'description' => '',
           'help_text' => '',
+          'on_change' => array(
+              '0' => array(
+                  '0' => 'CRM_Case_Info',
+                  '1' => 'onToggleComponents',
+                ),
+              '1' => array(
+                  '0' => 'CRM_Core_Component',
+                  '1' => 'flushEnabledComponents',
+                ),
+            ),
         ),
       'disable_core_css' => array(
           'group_name' => 'CiviCRM Preferences',
index ffacc49fd4145844e53e54defcb7d646a51f0dec..5ae0d9d05aca0326e07ba59fc0d0102370e346d6 100644 (file)
@@ -74,4 +74,4 @@ function setting_revert_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
index 698f8073cf6b62a7a96f5ce5d6c11d714101fbab..d441ccd98e5b49293d2d0775c1ffc2830cb76e99 100644 (file)
  +--------------------------------------------------------------------+
 *}
 <div id="changelog" class="form-item">
-   <table class="form-layout">
-     <tr>
-        <td>
-          {$form.changed_by.label}<br />
-          {$form.changed_by.html}
-        </td>
-  <td width="100%">
-    {$form.log_date.html}<span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('log_date', '{$form.formName}'); return false;" >{ts}clear{/ts}</a>)</span><br />
-        </td>
-     </tr>
-     <tr>
-  <td>
-     <label>{ts}Modified Between{/ts}</label>
-  </td>
-     </tr>
-     <tr>
-  {include file="CRM/Core/DateRange.tpl" fieldName="log_date" from='_low' to='_high'}
-     </tr>
-   </table>
- </div>
+  <table class="form-layout">
+    <tr>
+      <td>
+        <span class="modifiedBy"><label>{ts}Modified By{/ts}</label></span>
+        <span class="hiddenElement addedBy"><label>{ts}Added By{/ts}</label></span>
+        <br/>
+        {$form.changed_by.html}
+      </td>
+      <td width="100%">
+        {$form.log_date.html}
+        <span class="crm-clear-link">(<a href="#" title="unselect"
+                                         onclick="unselectRadio('log_date', '{$form.formName}');
+                                           return false;">{ts}clear{/ts}</a>)
+        </span>
+        <br/>
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <span class="modifiedBy"><label>{ts}Modified Between{/ts}</label></span>
+        <span class="hiddenElement addedBy"><label>{ts}Added Between{/ts}</label></span>
+      </td>
+    </tr>
+    <tr>
+      {include file="CRM/Core/DateRange.tpl" fieldName="log_date" from='_low' to='_high'}
+    </tr>
+  </table>
+</div>
+
+{literal}
+  <script type="text/javascript">
+    cj(function () {
+      updateChangeLogLabels();
+    });
+
+    cj('[name=log_date]:input').change(function () {
+      updateChangeLogLabels();
+    });
+
+    function updateChangeLogLabels() {
+      var changeType = cj('input[name=log_date]:checked').val();
+      if (changeType == 2) {
+        cj('.addedBy').hide();
+        cj('.modifiedBy').show();
+      }
+      else {
+        if (changeType == 1) {
+          cj('.addedBy').show();
+          cj('.modifiedBy').hide();
+        }
+      }
+    }
+  </script>
+{/literal}
index 211a3bda27f12ab5e70602d4ed5ea62025bbd7e4..cf9dde368db711ced3ecb00147d5c6dce9cf999e 100644 (file)
@@ -86,7 +86,7 @@
       </tr>
   {elseif $context eq 'contribution' }
       <tr class="even-row">
-      <td colspan="8"><a href="{crmURL p='civicrm/contact/view' q="reset=1&force=1&selectedChild=contribute&cid=$contactId"}">&raquo; {ts}View all contributions from this contact{/ts}... </a></td>
+      <td colspan="8"><a href="{crmURL p='civicrm/contribute/search' q="reset=1&force=1&cid=$contactId"}">&raquo; {ts}View all contributions from this contact{/ts}... </a></td>
       </tr>
   {/if}
 {/if}
index 37b8713a1abd2c54ec5db054dce30e03b9e68b85..5b232aea5113e5f7366284c2a8d15a3a2c036195 100644 (file)
@@ -25,9 +25,9 @@
 *}
 <div id="pricesetTotal" class="crm-section section-pricesetTotal">
   <div class="label" id="pricelabel"><label>
-         {if ( $extends eq 'Contribution' ) || ( $extends eq 'Membership' )}
-           {ts}Total Amount{/ts}{else}{ts}Total Fee(s){/ts}
-         {/if}</label></div>
+    {if ( $extends eq 'Contribution' ) || ( $extends eq 'Membership' )}
+      {ts}Total Amount{/ts}{else}{ts}Total Fee(s) for this participant{/ts}
+    {/if}</label></div>
   <div class="content calc-value" id="pricevalue" ></div>
 </div>
 
@@ -74,10 +74,6 @@ cj("input,#priceset select,#priceset").each(function () {
       }
       display( totalfee );
     });
-    cj('#additional_participants').change( function( ) {
-      display( totalfee );
-    });
-
     display( totalfee );
     break;
 
@@ -104,11 +100,6 @@ cj("input,#priceset select,#priceset").each(function () {
 
       display( totalfee );
     });
-
-    cj('#additional_participants').change( function( ) {
-      display( totalfee );
-    });
-
     display( totalfee );
     break;
 
@@ -135,11 +126,6 @@ cj("input,#priceset select,#priceset").each(function () {
     cj(this).bind( 'keyup', function() { calculateText( this );
     }).bind( 'blur' , function() { calculateText( this );
     });
-
-    cj('#additional_participants').change( function( ) {
-      display( totalfee );
-    });
-
     display( totalfee );
     break;
 
@@ -185,11 +171,6 @@ cj("input,#priceset select,#priceset").each(function () {
       }
       display( totalfee );
     });
-
-    cj('#additional_participants').change( function( ) {
-      display( totalfee );
-    });
-
     display( totalfee );
     break;
     }
@@ -219,20 +200,8 @@ function calculateText( object ) {
 
 //display calculated amount
 function display( totalfee ) {
-    num_participants = cj('#additional_participants').val()
-
-    if (!num_participants) {
-      num_participants = 0
-    }
-    // The value of this field is the number of *additional* participants
-    // What is displayed to the user is 1 + the value, because it is including
-    // the "yourself". Since we want to give a total, including "yourself" we have
-    // to add one to the value of #additional_participants.
-    num_participants++;
-
     // totalfee is monetary, round it to 2 decimal points so it can
     // go as a float - CRM-13491
-    totalfee = totalfee * num_participants;
     totalfee = Math.round(totalfee*100)/100;
     var totalEventFee  = formatMoney( totalfee, 2, seperator, thousandMarker);
     document.getElementById('pricevalue').innerHTML = "<b>"+symbol+"</b> "+totalEventFee;
index 7b022c53c4d3d74eaf633fcc6972ef0b05125fe2..713af03244363e0cf8e73fb6c3bce95f77b2e5e8 100644 (file)
     {if $action NEQ 2}&nbsp; &nbsp;{ts}CiviCRM ID{/ts}:&nbsp;{$contactId}{/if}
   </span>
   {if !empty($lastModified)}
-    {ts}Last Change by{/ts} <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$lastModified.id`"}">{$lastModified.name}</a> ({$lastModified.date|crmDate}) &nbsp;
+    {ts}Last Change by{/ts}: <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$lastModified.id`"}">{$lastModified.name}</a> ({$lastModified.date|crmDate}) &nbsp;
     {if !empty($changeLog)}
       <a href="{crmURL p='civicrm/contact/view' q="reset=1&action=browse&selectedChild=log&cid=`$contactId`"}" class="crm-log-view">&raquo; {ts}View Change Log{/ts}</a>
     {/if}
   {/if}
+       {if !empty($created_date)}<div class="contact-created-date">{ts}Created{/ts}: {$created_date|crmDate}</div>{/if}
 </div>
 {/strip}
index 07b6c53132b0fa8e11e2bc9ef0681d79492bf25e..535892841046aef0e08f4b481d96e95bb0c926fc 100644 (file)
@@ -797,11 +797,113 @@ WHERE c1.entity_table  = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.st
     $dao->fetch();
     $this->assertEquals('2', $dao->civicrm_contribution, 'civicrm_financial_trxn count does not match');
     $this->assertEquals('8', $dao->civicrm_financial_item, 'civicrm_financial_item count does not match');
-    $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft 
-INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id 
+    $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft
+INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id
 WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'";
     $dao = CRM_Core_DAO::executeQuery($query, $params);
     $dao->fetch();
     $this->assertEquals('2', $dao->civicrm_financial_trxn, 'civicrm_financial_trxn count does not match');
   }
+
+  function testEventApprovalRegistration() {
+    $this->webtestLogin();
+
+    //Participant Status
+    $this->openCiviPage("admin/participant_status", "reset=1&action=browse");
+    $this->_testEnableParticipantStatuses('Awaiting approval');
+    $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Awaiting approval')]/../td[9]/span/a[2][text()='Disable']");
+    $this->_testEnableParticipantStatuses('Pending from approval');
+    $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Pending from approval')]/../td[9]/span/a[2][text()='Disable']");
+    $this->_testEnableParticipantStatuses('Rejected');
+    $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Rejected')]/../td[9]/span/a[2][text()='Disable']");
+
+    //Create New Event
+
+    $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
+    $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
+    $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
+    $eventDescription = 'Here is a description for this conference.';
+    $this->select('event_type_id', 'value=1');
+
+    // Attendee role s/b selected now.
+    $this->select('default_role_id', 'value=1');
+    // Enter Event Title, Summary and Description
+    $this->type('title', $eventTitle);
+    $this->type('summary', 'This is a great conference. Sign up now!');
+
+    // Type description in ckEditor (fieldname, text to type, editor)
+    $this->fillRichTextField('description', $eventDescription );
+    $this->type('max_participants', '50');
+    $this->click('is_map');
+    $this->click('_qf_EventInfo_upload-bottom');
+
+    // Wait for Location tab form to load
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+
+    // Go to Fees tab
+    $this->click('link=Fees');
+    $id = $this->urlArg('id');
+    $this->waitForElementPresent('_qf_Fee_upload-bottom');
+    $this->click('CIVICRM_QFID_1_is_monetary');
+    $processorName = 'Test Processor';
+    $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
+    $this->select('financial_type_id','label=Event Fee');
+    $this->type("label[1]",'Junior Stars');
+    $this->type("value[1]",'500.00');
+    $this->type("label[2]",'Super Stars');
+    $this->type("value[2]",'1000.00');
+    $this->check('default');
+    $this->click('_qf_Fee_upload-bottom');
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+
+    // intro text for registration page
+    $registerIntro = 'Fill in all the fields below and click Continue.';
+
+   // Go to Online Registration tab
+   $this->click('link=Online Registration');
+   $this->waitForElementPresent('_qf_Registration_upload-bottom');
+   $this->check('is_online_registration');
+   $this->assertChecked('is_online_registration');
+
+   //Requires Approvel
+   $this->check('requires_approval');
+   $this->assertChecked('requires_approval');
+   $this->click('_qf_Registration_upload-bottom');
+   $this->waitForPageToLoad($this->getTimeoutMsec());
+   $this->waitForTextPresent("'Registration' information has been saved.");
+
+   // verify event input on info page
+   // start at Manage Events listing
+   $this->openCiviPage('event/manage', 'reset=1');
+   $this->click("link=$eventTitle");
+   $this->waitForPageToLoad($this->getTimeoutMsec());
+   $firstName = substr(sha1(rand()), 0, 7);
+   $this->webtestAddContact($firstName, 'Anderson', TRUE);
+   $contactName = "Anderson, $firstName";
+   $displayName = "$firstName Anderson";
+   $this->openCiviPage("event/register", "reset=1&id=$id", '_qf_Register_upload-bottom');
+   $this->type('first_name',$firstName);
+
+   //fill in last name
+   $lastName = 'Recuron'.substr(sha1(rand()), 0, 7);
+   $this->type('last_name', $contactName);
+   $email = $firstName . '@example.com';
+   $this->type('email-Primary', $email);
+   $this->click('_qf_Register_upload');
+   $this->waitForElementPresent("_qf_Confirm_next");
+   $this->click('_qf_Confirm_next');
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+   $this->waitForElementPresent("xpath=//div[@class='section']");
+   $this->assertTextPresent("Thank You for Registering");
+
+  }
+
+ function _testEnableParticipantStatuses($status) {
+   // enable participant status
+   if ($this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Enable']")){
+     $this->click("xpath=//td[@class='crm-particpant-label'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Enable']");
+     $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']");
+     $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]");
+   }
+ }
 }
index 31a923841defd2df5f2f054ac9fec6bcafaf391c..e37f607c1f5dbd22c11acaa8470fe5b09d090117 100644 (file)
@@ -84,14 +84,25 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     }
     $this->_domainID3 = $result['id'];
     $this->_currentDomain = CRM_Core_Config::domainID();
+    $this->hookClass = CRM_Utils_Hook::singleton();
   }
 
   function tearDown() {
+    CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
     $this->callAPISuccess('system','flush', array());
     $this->quickCleanup(array('civicrm_domain'));
   }
 
+  /**
+   * Set additional settings into metadata (implements hook)
+   * @param array $metaDataFolders
+   */
+  function setExtensionMetadata(&$metaDataFolders) {
+    global $civicrm_root;
+    $metaDataFolders[] = $civicrm_root . '/tests/phpunit/api/v3/settings';
+  }
+  /**
   /**
    * check getfields works
    */
@@ -125,6 +136,26 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $this->assertArrayHasKey('advanced_search_options',$result['values']);
   }
 
+  /**
+   * Test that getfields will filter on group
+   */
+  function testGetFieldsGroupFilters() {
+    $params = array('filters' => array('group' => 'multisite'));
+    $result = $this->callAPISuccess('setting', 'getfields', $params);
+    $this->assertArrayNotHasKey('customCSSURL', $result['values']);
+    $this->assertArrayHasKey('domain_group_id',$result['values']);
+  }
+
+  /**
+   * Test that getfields will filter on another field (prefetch)
+   */
+  function testGetFieldsPrefetchFilters() {
+    $params = array('filters' => array('prefetch' => 1));
+    $result = $this->callAPISuccess('setting', 'getfields', $params);
+    $this->assertArrayNotHasKey('disable_mandatory_tokens_check', $result['values']);
+    $this->assertArrayHasKey('monetaryDecimalPoint',$result['values']);
+  }
+
   /**
    * Ensure that on_change callbacks fire.
    *
@@ -341,6 +372,22 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $result =  $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSettingCurrentDomain');
     $this->assertArrayHasKey(CRM_Core_Config::domainID(), $result['values']);
   }
+
+  /**
+   * Check that setting defined in extension can be retrieved
+   */
+  function testGetExtensionSetting() {
+    $this->hookClass->setHook('civicrm_alterSettingsFolders', array($this, 'setExtensionMetadata'));
+    $data = NULL;
+    // the caching of data to all duplicates the caching of data to the empty string
+    CRM_Core_BAO_Cache::setItem($data, 'CiviCRM setting Spec', 'All');
+    CRM_Core_BAO_Cache::setItem($data, 'CiviCRM setting Specs', 'settingsMetadata__');
+    $fields = $this->callAPISuccess('setting', 'getfields', array('filters' => array('group_name' => 'Test Settings')));
+    $this->assertArrayHasKey('test_key', $fields['values']);
+    $this->callAPISuccess('setting', 'create', array('test_key' => 'keyset'));
+    $result = $this->callAPISuccess('setting', 'getvalue', array('name' => 'test_key', 'group' => 'Test Settings'));
+    $this->assertEquals('keyset', $result);
+  }
 /**
  * setting api should set & fetch settings stored in config as well as those in settings table
  */
diff --git a/tests/phpunit/api/v3/settings/test.setting.php b/tests/phpunit/api/v3/settings/test.setting.php
new file mode 100644 (file)
index 0000000..bb8d1d6
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+return array(
+  'test_key' => array(
+    'group_name' => 'Test Settings',
+    'group' => 'test',
+    'name' => 'test_key',
+    'type' => 'String',
+    'add' => '4.4',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => 'Test Key',
+    'title' =>  'Test Key',
+    'help_text' => '',
+    'html_type' => 'Text',
+    'quick_form_type' => 'Element',
+  ),
+  'test_secret' => array(
+    'group_name' => 'Test Settings',
+    'group' => 'test',
+    'name' => 'test_secret',
+    'type' => 'String',
+    'add' => '4.4',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => 'Test Secret',
+    'title' => 'Test Secret',
+    'help_text' => '',
+    'html_type' => 'Text',
+    'quick_form_type' => 'Element',
+  ),
+  'test_public_certificate' => array(
+    'group_name' => 'Test Settings',
+    'group' => 'test',
+    'name' => 'test_public_certificate',
+    'type' => 'Text',
+    'add' => '4.4',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'title' => 'Test Public Certificate Path',
+    'description' => 'Enter the full path to your public Certificate',
+    'help_text' => '',
+    'html_type' => 'Text',
+    'html_attributes' => array(
+      'size' => 50,
+    ),
+    'quick_form_type' => 'Element',
+  ),
+  'test_private_key' => array(
+    'group_name' => 'Test Settings',
+    'group' => 'test',
+    'name' => 'test_private_key',
+    'type' => 'String',
+    'add' => '4.4',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'title' => 'Test Private Key Path',
+    'description' => 'Enter the full path to your private Key',
+    'help_text' => '',
+    'html_type' => 'Text',
+    'quick_form_type' => 'Element',
+  ),
+ );
\ No newline at end of file