Skip to content
Snippets Groups Projects
Commit ce4fd42f authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-10-02-11-18-44

Conflicts:
	sql/civicrm_generated.mysql
	templates/CRM/Contact/Form/Search/AdvancedCriteria.tpl
	xml/version.xml
parents 698973c3 69244ea1
No related branches found
No related tags found
No related merge requests found
......@@ -112,7 +112,7 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
else {
CRM_Utils_Hook::post('create', 'Event', $event->id, $event);
}
if ($financialTypeId && CRM_Utils_Array::value('financial_type_id', $params)
if ($financialTypeId && CRM_Utils_Array::value('financial_type_id', $params)
&& $financialTypeId != $params['financial_type_id']) {
CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_event', $params['financial_type_id']);
}
......@@ -683,16 +683,28 @@ WHERE civicrm_address.geo_code_1 IS NOT NULL
/**
* function to get the complete information for one or more events
*
* @param date $start get events with start date >= this date
* @param integer $type get events on the a specific event type (by event_type_id)
* @param integer $eventId return a single event - by event id
* @param date $end also get events with end date >= this date
* @param date $start get events with start date >= this date
* @param integer $type get events on the a specific event type (by event_type_id)
* @param integer $eventId return a single event - by event id
* @param date $end also get events with end date >= this date
* @param boolean $onlyPublic include public events only, default TRUE
*
* @return array $all array of all the events that are searched
* @static
* @access public
*/
static function &getCompleteInfo($start = NULL, $type = NULL, $eventId = NULL, $end = NULL) {
static function &getCompleteInfo(
$start = NULL,
$type = NULL,
$eventId = NULL,
$end = NULL,
$onlyPublic = TRUE
) {
$publicCondition = NULL;
if ($onlyPublic) {
$publicCondition = " AND civicrm_event.is_public = 1";
}
$dateCondition = '';
// if start and end date are NOT passed, return all events with start_date OR end_date >= today CRM-5133
if ($start) {
......@@ -707,7 +719,8 @@ WHERE civicrm_address.geo_code_1 IS NOT NULL
$dateCondition .= " AND ( civicrm_event.end_date <= '{$endDate}' ) ";
}
// CRM-9421 and CRM-8620 Default mode for ical/rss feeds. No start or end filter passed. Need to exclude old events with only start date
// CRM-9421 and CRM-8620 Default mode for ical/rss feeds. No start or end filter passed.
// Need to exclude old events with only start date
// and not exclude events in progress (start <= today and end >= today). DGG
if (empty($start) && empty($end)) {
// get events with end date >= today, not sure of this logic
......@@ -762,8 +775,8 @@ LEFT JOIN civicrm_option_value ON (
civicrm_event.event_type_id = civicrm_option_value.value AND
civicrm_option_value.option_group_id = %1 )
WHERE civicrm_event.is_active = 1
AND civicrm_event.is_public = 1
AND (is_template = 0 OR is_template IS NULL)
{$publicCondition}
{$dateCondition}";
if (isset($typeCondition)) {
......
......@@ -1122,6 +1122,7 @@ AND cli.entity_table = 'civicrm_contribution' AND cli.id IN (" . implode(',', $v
* @return bool TRUE for success
*/
function task_4_3_x_checkConstraints(CRM_Queue_TaskContext $ctx) {
CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_financial_account` CHANGE `contact_id` `contact_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL');
$config = CRM_Core_Config::singleton();
$dbname = DB::parseDSN($config->dsn);
$constraintArray = array(
......
{* file to handle db changes in 4.3.7 during upgrade *}
......@@ -34,6 +34,7 @@
*/
require_once 'HTML/QuickForm/Rule/Email.php';
class CRM_Utils_Rule {
static function title($str, $maxLength = 127) {
......@@ -272,17 +273,26 @@ class CRM_Utils_Rule {
return TRUE;
}
if (($value < 0)) {
// CRM-13460
// ensure number passed is always a string numeral
if (!is_numeric($value)) {
return FALSE;
}
// note that is_int matches only integer type
// and not strings which are only integers
// hence we do this here
if (preg_match('/^\d+$/', $value)) {
return TRUE;
}
if ($value < 0) {
$negValue = -1 * $value;
if (is_int($negValue)) {
return TRUE;
}
}
if (is_numeric($value) && preg_match('/^\d+$/', $value)) {
return TRUE;
}
return FALSE;
}
......@@ -291,7 +301,13 @@ class CRM_Utils_Rule {
return ($value < 0) ? FALSE : TRUE;
}
if (is_numeric($value) && preg_match('/^\d+$/', $value)) {
// CRM-13460
// ensure number passed is always a string numeral
if (!is_numeric($value)) {
return FALSE;
}
if (preg_match('/^\d+$/', $value)) {
return TRUE;
}
......@@ -299,6 +315,11 @@ class CRM_Utils_Rule {
}
static function numeric($value) {
// lets use a php gatekeeper to ensure this is numeric
if (!is_numeric($value)) {
return FALSE;
}
return preg_match('/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/', $value) ? TRUE : FALSE;
}
......
<?php
require_once 'CiviTest/CiviUnitTestCase.php';
class CRM_Utils_RuleTest extends CiviUnitTestCase {
function get_info() {
return array(
'name' => 'Rule Test',
'description' => 'Test the validation rules',
'group' => 'CiviCRM BAO Tests',
);
}
function setUp() {
parent::setUp();
}
/**
* @dataProvider integerDataProvider
*/
function testInteger($inputData, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Utils_Rule::integer($inputData));
}
function integerDataProvider() {
return array(
array(10, true),
array('145E+3', false),
array('10', true),
array(-10, true),
array('-10', true),
array('-10foo', false),
);
}
/**
* @dataProvider positiveDataProvider
*/
function testPositive($inputData, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Utils_Rule::positiveInteger($inputData));
}
function positiveDataProvider() {
return array(
array(10, true),
array('145.0E+3', false),
array('10', true),
array(-10, false),
array('-10', false),
array('-10foo', false),
);
}
/**
* @dataProvider numericDataProvider
*/
function testNumeric($inputData, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Utils_Rule::numeric($inputData));
}
function numericDataProvider() {
return array(
array(10, true),
array('145.0E+3', false),
array('10', true),
array(-10, true),
array('-10', true),
array('-10foo', false),
);
}
}
<?php
require_once 'CiviTest/CiviUnitTestCase.php';
class CRM_Utils_TypeTest extends CiviUnitTestCase {
function get_info() {
return array(
'name' => 'Type Test',
'description' => 'Test the validate function',
'group' => 'CiviCRM BAO Tests',
);
}
function setUp() {
parent::setUp();
}
/**
* @dataProvider validateDataProvider
*/
function testValidate($inputData, $inputType, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Utils_Type::validate($inputData, $inputType, FALSE));
}
function validateDataProvider() {
return array(
array(10, 'Int', 10),
array('145E+3', 'Int', NULL),
array('10', 'Integer', 10),
array(-10, 'Int', -10),
array('-10', 'Integer', -10),
array('-10foo', 'Int', NULL),
array(10, 'Positive', 10),
array('145.0E+3', 'Positive', NULL),
array('10', 'Positive', 10),
array(-10, 'Positive', NULL),
array('-10', 'Positive', NULL),
array('-10foo', 'Positive', NULL),
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment