CRM-14043 - cid=0 contribution form giving contribution to logged in use...
//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;
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':
$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) {
// 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) {
$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,
* 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
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
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()) {
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
$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
//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);
}
}
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)
+++ /dev/null
-<?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();
- }
-}
-
+++ /dev/null
-<?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();
- }
-}
-
}
}
- $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']);
}
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) {
$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;
* @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
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.');
}
$controller->set('cid', $this->_contactId);
$controller->set('crid', $this->_crid);
$controller->set('context', 'contribution');
+ $controller->set('limit', 50);
$controller->process();
$controller->run();
$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);
$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');
$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);
}
}
}
$params['file'] = $smarty->_tpl_vars['tplFile'];
}
elseif (empty($params['file'])) {
- return $help;
+ return NULL;
}
$params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
$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
$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(),
$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 ";
}
$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);
$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)
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
//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);
!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');
}
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,
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));
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;
}
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];
}
}
}
}
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);
";
CRM_Core_DAO::executeQuery($query);
+ return TRUE;
}
/**
$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();
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/
$expectedResult = array(
'is_error' => 0,
'version' => 3,
- 'count' => 81,
+ 'count' => 82,
'values' => array(
'address_standardization_provider' => array(
'group_name' => 'Address Preferences',
'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',
'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',
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of 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}
</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"}">» {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"}">» {ts}View all contributions from this contact{/ts}... </a></td>
</tr>
{/if}
{/if}
*}
<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>
}
display( totalfee );
});
- cj('#additional_participants').change( function( ) {
- display( totalfee );
- });
-
display( totalfee );
break;
display( totalfee );
});
-
- cj('#additional_participants').change( function( ) {
- display( totalfee );
- });
-
display( totalfee );
break;
cj(this).bind( 'keyup', function() { calculateText( this );
}).bind( 'blur' , function() { calculateText( this );
});
-
- cj('#additional_participants').change( function( ) {
- display( totalfee );
- });
-
display( totalfee );
break;
}
display( totalfee );
});
-
- cj('#additional_participants').change( function( ) {
- display( totalfee );
- });
-
display( totalfee );
break;
}
//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;
{if $action NEQ 2} {ts}CiviCRM ID{/ts}: {$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})
+ {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})
{if !empty($changeLog)}
<a href="{crmURL p='civicrm/contact/view' q="reset=1&action=browse&selectedChild=log&cid=`$contactId`"}" class="crm-log-view">» {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}
$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]");
+ }
+ }
}
}
$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
*/
$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.
*
$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
*/
--- /dev/null
+<?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