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