// contacts or not
// CRM-11971
$trashParamExists = FALSE;
- $paramByGroup = array();
- foreach ( $this->_params as $k => $param ) {
- if (!empty($param[0]) && $param[0] == 'contact_is_deleted' ) {
+ $paramByGroup = array();
+ foreach ($this->_params as $k => $param) {
+ if (!empty($param[0]) && $param[0] == 'contact_is_deleted') {
$trashParamExists = TRUE;
}
if (!empty($param[3])) {
}
}
- if ( $trashParamExists ) {
+ if ($trashParamExists) {
$this->_skipDeleteClause = TRUE;
//cycle through group sets and explicitly add trash param if not set
- foreach ( $paramByGroup as $setID => $set ) {
+ foreach ($paramByGroup as $setID => $set) {
if (
!in_array(array('contact_is_deleted', '=', '1', $setID, '0'), $this->_params) &&
- !in_array(array('contact_is_deleted', '=', '0', $setID, '0'), $this->_params) ) {
+ !in_array(array('contact_is_deleted', '=', '0', $setID, '0'), $this->_params)
+ ) {
$this->_params[] = array(
'contact_is_deleted',
'=',
}
if (in_array($tableName,
- array('email_greeting', 'postal_greeting', 'addressee'))) {
+ array('email_greeting', 'postal_greeting', 'addressee'))) {
$this->_element["{$name}_id"] = 1;
$this->_select["{$name}_id"] = "contact_a.{$name}_id as {$name}_id";
$this->_pseudoConstantsSelect[$name] = array('pseudoField' => $tableName, 'idCol' => "{$name}_id");
if (in_array($tName, array('country', 'state_province', 'county'))) {
if ($tName == 'state_province') {
$this->_pseudoConstantsSelect['state_province_name'] =
- array('pseudoField' => "{$tName}", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address',
- 'table' => "civicrm_{$tName}", 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id ");
+ array(
+ 'pseudoField' => "{$tName}",
+ 'idCol' => "{$tName}_id",
+ 'bao' => 'CRM_Core_BAO_Address',
+ 'table' => "civicrm_{$tName}",
+ 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id "
+ );
$this->_pseudoConstantsSelect[$tName] =
- array('pseudoField' => 'state_province_abbreviation', 'idCol' => "{$tName}_id",
- 'table' => "civicrm_{$tName}", 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id ");
+ array(
+ 'pseudoField' => 'state_province_abbreviation',
+ 'idCol' => "{$tName}_id",
+ 'table' => "civicrm_{$tName}",
+ 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id "
+ );
}
else {
$this->_pseudoConstantsSelect[$name] =
- array('pseudoField' => "{$tName}_id", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address',
- 'table' => "civicrm_{$tName}", 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id ");
+ array(
+ 'pseudoField' => "{$tName}_id",
+ 'idCol' => "{$tName}_id",
+ 'bao' => 'CRM_Core_BAO_Address',
+ 'table' => "civicrm_{$tName}",
+ 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id "
+ );
}
$this->_select["{$tName}_id"] = "civicrm_address.{$tName}_id as {$tName}_id";
}
elseif ($fieldName != 'id') {
if ($fieldName == 'prefix_id') {
- $this->_pseudoConstantsSelect['individual_prefix'] = array('pseudoField' => 'prefix_id', 'idCol' => "prefix_id", 'bao' => 'CRM_Contact_BAO_Contact');
+ $this->_pseudoConstantsSelect['individual_prefix'] = array(
+ 'pseudoField' => 'prefix_id',
+ 'idCol' => "prefix_id",
+ 'bao' => 'CRM_Contact_BAO_Contact'
+ );
}
if ($fieldName == 'suffix_id') {
- $this->_pseudoConstantsSelect['individual_suffix'] = array('pseudoField' => 'suffix_id', 'idCol' => "suffix_id", 'bao' => 'CRM_Contact_BAO_Contact');
+ $this->_pseudoConstantsSelect['individual_suffix'] = array(
+ 'pseudoField' => 'suffix_id',
+ 'idCol' => "suffix_id",
+ 'bao' => 'CRM_Contact_BAO_Contact'
+ );
}
if ($fieldName == 'gender_id') {
- $this->_pseudoConstantsSelect['gender'] = array('pseudoField' => 'gender_id', 'idCol' => "gender_id", 'bao' => 'CRM_Contact_BAO_Contact');
+ $this->_pseudoConstantsSelect['gender'] = array(
+ 'pseudoField' => 'gender_id',
+ 'idCol' => "gender_id",
+ 'bao' => 'CRM_Contact_BAO_Contact'
+ );
}
if ($name == 'communication_style_id') {
- $this->_pseudoConstantsSelect['communication_style'] = array('pseudoField' => 'communication_style_id', 'idCol' => "communication_style_id", 'bao' => 'CRM_Contact_BAO_Contact');
+ $this->_pseudoConstantsSelect['communication_style'] = array(
+ 'pseudoField' => 'communication_style_id',
+ 'idCol' => "communication_style_id",
+ 'bao' => 'CRM_Contact_BAO_Contact'
+ );
}
$this->_select[$name] = "contact_a.{$fieldName} as `$name`";
}
$this->_element[$provider] = 1;
}
if ($pf == 'country' || $pf == 'county') {
- $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = array('pseudoField' => "{$pf}_id", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address');
+ $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = array(
+ 'pseudoField' => "{$pf}_id",
+ 'idCol' => "{$tName}_id",
+ 'bao' => 'CRM_Core_BAO_Address'
+ );
$this->_pseudoConstantsSelect["{$name}-{$elementFullName}"]['select'] = "`$tName`.$fieldName as `{$name}-{$elementFullName}`";
}
else {
if ($count) {
if (isset($this->_rowCountClause)) {
$select = "SELECT {$this->_rowCountClause}";
- } else if (isset($this->_distinctComponentClause)) {
+ }
+ else if (isset($this->_distinctComponentClause)) {
// we add distinct to get the right count for components
// for the more complex result set, we use GROUP BY the same id
// CRM-9630
}
}
elseif (preg_match('/_date_relative$/', $id) ||
- $id == 'event_relative' ||
- $id == 'case_from_relative' ||
- $id == 'case_to_relative'
- ) {
+ $id == 'event_relative' ||
+ $id == 'case_from_relative' ||
+ $id == 'case_to_relative'
+ ) {
if ($id == 'event_relative') {
$fromRange = 'event_start_date_low';
$toRange = 'event_end_date_high';
if (!$skipWhere) {
$skipWhere = array(
- 'task', 'radio_ts', 'uf_group_id',
- 'component_mode', 'qfKey', 'operator',
+ 'task',
+ 'radio_ts',
+ 'uf_group_id',
+ 'component_mode',
+ 'qfKey',
+ 'operator',
'display_relationship_type',
);
}
$wildcard = 1;
}
- if (!$useEquals && in_array($id, $likeNames)) {
+ if (!$useEquals && in_array($id, $likeNames)) {
$result = array($id, 'LIKE', $values, 0, 1);
}
elseif (is_string($values) && strpos($values, '%') !== FALSE) {
list($name, $op, $value, $grouping, $wildcard) = $values;
$values[0] = 'group';
$values[1] = 'IN';
- $this->_paramLookup['group'][0][0] ='group';
+ $this->_paramLookup['group'][0][0] = 'group';
$this->_paramLookup['group'][0][1] = 'IN';
$this->_paramLookup['group'][0][2] = $values[2] = $this->getGroupsFromTypeCriteria($value);
$this->group($values);
}
}
elseif (in_array($locType[0],
- array(
- 'address_name', 'street_address', 'supplemental_address_1', 'supplemental_address_2',
- 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2',
- )
- )) {
+ array(
+ 'address_name',
+ 'street_address',
+ 'supplemental_address_1',
+ 'supplemental_address_2',
+ 'city',
+ 'postal_code',
+ 'postal_code_suffix',
+ 'geo_code_1',
+ 'geo_code_2',
+ )
+ )) {
//fix for search by profile with address fields.
$tName = "{$locationType[$locType[1]]}-address";
}
if ((!empty($tables['civicrm_state_province']) || !empty($tables['civicrm_country']) ||
CRM_Utils_Array::value('civicrm_county', $tables)
- ) && empty($tables['civicrm_address'])) {
+ ) && empty($tables['civicrm_address'])
+ ) {
$tables = array_merge(array('civicrm_address' => 1),
$tables
);
// add group_contact and group table is subscription history is present
if (!empty($tables['civicrm_subscription_history']) && empty($tables['civicrm_group'])) {
$tables = array_merge(array(
- 'civicrm_group' => 1,
+ 'civicrm_group' => 1,
'civicrm_group_contact' => 1,
),
$tables
*
* @return array
*/
- public function getGroupsFromTypeCriteria($value){
+ public function getGroupsFromTypeCriteria($value) {
$groupIds = array();
foreach ($value as $groupTypeValue) {
$groupList = CRM_Core_PseudoConstant::group($groupTypeValue);
OR children IS NOT NULL )
";
- $group = CRM_Core_DAO::executeQuery($sql);
+ $group = CRM_Core_DAO::executeQuery($sql);
$groupsFiltered = array();
while ($group->fetch()) {
if ($useAllTagTypes[2]) {
$this->_tables[$etTable] =
- $this->_whereTables[$etTable] =
+ $this->_whereTables[$etTable] =
" LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id)
LEFT JOIN civicrm_tag {$tTable} ON ( {$etTable}.tag_id = {$tTable}.id )";
$etCaseTable = "`civicrm_entity_case_tag-" . $value . "`";
$tCaseTable = "`civicrm_case_tag-" . $value . "`";
$this->_tables[$etCaseTable] =
- $this->_whereTables[$etCaseTable] =
+ $this->_whereTables[$etCaseTable] =
" LEFT JOIN civicrm_case_contact ON civicrm_case_contact.contact_id = contact_a.id
LEFT JOIN civicrm_case
ON (civicrm_case_contact.case_id = civicrm_case.id
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$this->_tables[$etActTable] =
- $this->_whereTables[$etActTable] =
+ $this->_whereTables[$etActTable] =
" LEFT JOIN civicrm_activity_contact
ON ( civicrm_activity_contact.contact_id = contact_a.id AND civicrm_activity_contact.record_type_id = {$targetID} )
LEFT JOIN civicrm_activity
LEFT JOIN civicrm_entity_tag as {$etActTable} ON ( {$etActTable}.entity_table = 'civicrm_activity' AND {$etActTable}.entity_id = civicrm_activity.id )
LEFT JOIN civicrm_tag {$tActTable} ON ( {$etActTable}.tag_id = {$tActTable}.id )";
- $this->_where[$grouping][] = "({$tTable}.name $op '". $value . "' OR {$tCaseTable}.name $op '". $value . "' OR {$tActTable}.name $op '". $value . "')";
+ $this->_where[$grouping][] = "({$tTable}.name $op '" . $value . "' OR {$tCaseTable}.name $op '" . $value . "' OR {$tActTable}.name $op '" . $value . "')";
$this->_qill[$grouping][] = ts('Tag %1 %2', array(1 => $tagTypesText[2], 2 => $op)) . ' ' . $value;
- } else {
+ }
+ else {
$etTable = "`civicrm_entity_tag-" . $value . "`";
$tTable = "`civicrm_tag-" . $value . "`";
$this->_tables[$etTable] = $this->_whereTables[$etTable] = " LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND
if ($useAllTagTypes[2]) {
$this->_tables[$etTable] =
- $this->_whereTables[$etTable] =
+ $this->_whereTables[$etTable] =
" LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND {$etTable}.entity_table = 'civicrm_contact') ";
// search tag in cases
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$this->_tables[$etCaseTable] =
- $this->_whereTables[$etCaseTable] =
+ $this->_whereTables[$etCaseTable] =
" LEFT JOIN civicrm_case_contact ON civicrm_case_contact.contact_id = contact_a.id
LEFT JOIN civicrm_case
ON (civicrm_case_contact.case_id = civicrm_case.id
// search tag in activities
$etActTable = "`civicrm_entity_act_tag-" . $value . "`";
$this->_tables[$etActTable] =
- $this->_whereTables[$etActTable] =
+ $this->_whereTables[$etActTable] =
" LEFT JOIN civicrm_activity_contact
ON ( civicrm_activity_contact.contact_id = contact_a.id AND civicrm_activity_contact.record_type_id = {$targetID} )
LEFT JOIN civicrm_activity
LEFT JOIN civicrm_entity_tag as {$etActTable} ON ( {$etActTable}.entity_table = 'civicrm_activity' AND {$etActTable}.entity_id = civicrm_activity.id ) ";
// CRM-10338
- if ( in_array( $op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY' ) ) ) {
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
$this->_where[$grouping][] = "({$etTable}.tag_id $op OR {$etCaseTable}.tag_id $op OR {$etActTable}.tag_id $op)";
}
else {
- $this->_where[$grouping][] = "({$etTable}.tag_id $op (". $value . ") OR {$etCaseTable}.tag_id $op (". $value . ") OR {$etActTable}.tag_id $op (". $value . "))";
+ $this->_where[$grouping][] = "({$etTable}.tag_id $op (" . $value . ") OR {$etCaseTable}.tag_id $op (" . $value . ") OR {$etActTable}.tag_id $op (" . $value . "))";
}
$this->_qill[$grouping][] = ts('Tag %1 %2', array(1 => $op, 2 => $tagTypesText[2])) . ' ' . $names;
- } else {
+ }
+ else {
$this->_tables[$etTable] =
- $this->_whereTables[$etTable] =
+ $this->_whereTables[$etTable] =
" LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND {$etTable}.entity_table = 'civicrm_contact') ";
// CRM-10338
- if ( in_array( $op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY' ) ) ) {
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
// this converts IS (NOT)? EMPTY to IS (NOT)? NULL
$op = str_replace('EMPTY', 'NULL', $op);
$this->_where[$grouping][] = "{$etTable}.tag_id $op";
else {
$this->_where[$grouping][] = "{$etTable}.tag_id $op (" . $value . ')';
}
- $this->_qill[$grouping][] = ts('Tagged %1', array( 1 => $op)) . ' ' . $names;
+ $this->_qill[$grouping][] = ts('Tagged %1', array(1 => $op)) . ' ' . $names;
}
}
$this->_useDistinct = TRUE;
$this->_tables['civicrm_note'] =
- $this->_whereTables['civicrm_note'] =
+ $this->_whereTables['civicrm_note'] =
" LEFT JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_contact' AND contact_a.id = civicrm_note.entity_id ) ";
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$label = NULL;
$clauses = array();
- if ( $noteOption % 2 == 0 ) {
+ if ($noteOption % 2 == 0) {
$clauses[] = self::buildClause('civicrm_note.note', $op, $value, 'String');
$label = ts('Note: Body Only');
}
- if ( $noteOption % 3 == 0 ) {
+ if ($noteOption % 3 == 0) {
$clauses[] = self::buildClause('civicrm_note.subject', $op, $value, 'String');
$label = $label ? ts('Note: Body and Subject') : ts('Note: Subject Only');
}
* @return bool
*/
public function nameNullOrEmptyOp($name, $op, $grouping) {
- switch ( $op ) {
+ switch ($op) {
case 'IS NULL':
case 'IS NOT NULL':
$this->_where[$grouping][] = "contact_a.$name $op";
$this->_qill[$grouping][] = ts('Name') . ' ' . $op;
- return true;
+ return TRUE;
case 'IS EMPTY':
$this->_where[$grouping][] = "(contact_a.$name IS NULL OR contact_a.$name = '')";
$this->_qill[$grouping][] = ts('Name') . ' ' . $op;
- return true;
+ return TRUE;
case 'IS NOT EMPTY':
$this->_where[$grouping][] = "(contact_a.$name IS NOT NULL AND contact_a.$name <> '')";
$this->_qill[$grouping][] = ts('Name') . ' ' . $op;
- return true;
+ return TRUE;
default:
- return false;
+ return FALSE;
}
}
// Strip non-numeric characters; allow wildcards
$number = preg_replace('/[^\d%]/', '', $value);
if ($number) {
- if ( strpos($number, '%') === FALSE ) {
+ if (strpos($number, '%') === FALSE) {
$number = "%$number%";
}
*
* @return void
*/
- public function county(&$values, $status = null) {
+ public function county(&$values, $status = NULL) {
list($name, $op, $value, $grouping, $wildcard) = $values;
- if (! is_array($value)) {
+ if (!is_array($value)) {
// force the county to be an array
$value = array($value);
}
$op = str_replace('EMPTY', 'NULL', $op);
}
- if (in_array( $op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
$clause = "civicrm_address.county_id $op";
}
elseif ($inputFormat == 'id') {
$this->_where[$grouping][] = $clause;
if (!$status) {
$this->_qill[$grouping][] = ts('County') . ' - ' . implode(' ' . ts('or') . ' ', $names);
- } else {
+ }
+ else {
return implode(' ' . ts('or') . ' ', $names);
}
}
list($name, $op, $value, $grouping, $wildcard) = $values;
// quick escape for IS NULL
- if ( in_array( $op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY' ) ) ) {
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
$value = NULL;
}
else if (!is_array($value)) {
// this converts IS (NOT)? EMPTY to IS (NOT)? NULL
$op = str_replace('EMPTY', 'NULL', $op);
}
- if ( in_array( $op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY' ) ) ) {
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
$stateClause = "civicrm_address.state_province_id $op";
}
else if ($inputFormat == 'id') {
list($name, $op, $value, $grouping, $wildcard) = $values;
$pref = array();
- if (in_array($op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
$value = NULL;
}
elseif (!is_array($value)) {
*/
public function relationship(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
- if ($this->_relationshipValuesAdded){
- return;
+ if ($this->_relationshipValuesAdded) {
+ return;
}
// also get values array for relation_target_name
// for relationship search we always do wildcard
}
$rTypeValues = array();
- if (!empty($relationType) ) {
+ if (!empty($relationType)) {
$rel = explode('_', $relationType[2]);
self::$_relType = $rel[1];
$params = array('id' => $rel[0]);
if (self::$_relType == 'reciprocal' && empty($targetGroup)) {
$where = array();
self::$_relationshipTempTable =
- $relationshipTempTable =
- CRM_Core_DAO::createTempTableName( 'civicrm_rel');
+ $relationshipTempTable =
+ CRM_Core_DAO::createTempTableName('civicrm_rel');
if ($nameClause) {
$where[$grouping][] = " sort_name $nameClause ";
}
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
if ($nameClause || !$targetGroup) {
- if (!empty($relationType) ) {
- $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] ." $name";
- } else {
+ if (!empty($relationType)) {
+ $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] . " $name";
+ }
+ else {
$this->_qill[$grouping][] = $name;
}
}
if ($targetGroup) {
//add contacts from static groups
$this->_tables['civicrm_relationship_group_contact'] =
- $this->_whereTables['civicrm_relationship_group_contact'] =
+ $this->_whereTables['civicrm_relationship_group_contact'] =
" LEFT JOIN civicrm_group_contact civicrm_relationship_group_contact ON civicrm_relationship_group_contact.contact_id = contact_b.id AND civicrm_relationship_group_contact.status = 'Added'";
$groupWhere[] =
"( civicrm_relationship_group_contact.group_id IN (" .
- implode(",", $targetGroup[2]) . ") ) ";
+ implode(",", $targetGroup[2]) . ") ) ";
//add contacts from saved searches
$ssWhere = $this->addGroupContactCache($targetGroup[2], "civicrm_relationship_group_contact_cache", "contact_b");
$qillNames[] = $groupNames[$groupId];
}
}
- if ( !empty($relationType) ) {
- $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] ." ( " . implode(", ", $qillNames) . " )";
- } else {
+ if (!empty($relationType)) {
+ $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] . " ( " . implode(", ", $qillNames) . " )";
+ }
+ else {
$this->_qill[$grouping][] = implode(", ", $qillNames);
}
}
civicrm_relationship.is_permission_a_b = 1
)";
$this->_qill[$grouping][] = ts('Relationship - Permissioned');
- } elseif ($relPermission[2] == 2) {
+ }
+ elseif ($relPermission[2] == 2) {
//non-allowed permission relationship.
$where[$grouping][] = "(
civicrm_relationship.is_permission_a_b = 0
}
$this->addRelationshipDateClauses($grouping, $where);
- if (!empty($relationType) && !empty($rType) && isset($rType->id)){
+ if (!empty($relationType) && !empty($rType) && isset($rType->id)) {
$where[$grouping][] = 'civicrm_relationship.relationship_type_id = ' . $rType->id;
}
$this->_tables['civicrm_relationship'] = $this->_whereTables['civicrm_relationship'] = 1;
// an OR in the join
if ($relationshipTempTable) {
$whereClause = '';
- if ( ! empty( $where[$grouping] ) ) {
+ if (!empty($where[$grouping])) {
$whereClause = ' WHERE ' . implode(' AND ', $where[$grouping]);
}
$sql = "
}
}
-/**
- * Add start & end date criteria in
- * @param string $grouping
- * @param array $where
- * = array to add where clauses to, in case you are generating a temp table.
- * not the main query.
- */
- public function addRelationshipDateClauses($grouping, &$where){
+
+ /**
+ * Add start & end date criteria in
+ * @param string $grouping
+ * @param array $where
+ * = array to add where clauses to, in case you are generating a temp table.
+ * not the main query.
+ */
+ public function addRelationshipDateClauses($grouping, &$where) {
$dateValues = array();
$dateTypes = array(
- 'start_date',
- 'end_date',
+ 'start_date',
+ 'end_date',
);
- foreach ($dateTypes as $dateField){
- $dateValueLow = $this->getWhereValues('relation_'. $dateField .'_low', $grouping);
- $dateValueHigh= $this->getWhereValues('relation_'. $dateField .'_high', $grouping);
- if (!empty($dateValueLow)){
+ foreach ($dateTypes as $dateField) {
+ $dateValueLow = $this->getWhereValues('relation_' . $dateField . '_low', $grouping);
+ $dateValueHigh = $this->getWhereValues('relation_' . $dateField . '_high', $grouping);
+ if (!empty($dateValueLow)) {
$date = date('Ymd', strtotime($dateValueLow[2]));
$where[$grouping][] = "civicrm_relationship.$dateField >= $date";
$this->_qill[$grouping][] = ($dateField == 'end_date' ? ts('Relationship Ended on or After') : ts('Relationship Recorded Start Date On or Before')) . " " . CRM_Utils_Date::customFormat($date);
}
- if (!empty($dateValueHigh)){
+ if (!empty($dateValueHigh)) {
$date = date('Ymd', strtotime($dateValueHigh[2]));
$where[$grouping][] = "civicrm_relationship.$dateField <= $date";
- $this->_qill[$grouping][] = ( $dateField == 'end_date' ? ts('Relationship Ended on or Before') : ts('Relationship Recorded Start Date On or After')) . " " . CRM_Utils_Date::customFormat($date);
+ $this->_qill[$grouping][] = ($dateField == 'end_date' ? ts('Relationship Ended on or Before') : ts('Relationship Recorded Start Date On or After')) . " " . CRM_Utils_Date::customFormat($date);
}
}
}
TRUE, $smartGroupCache
);
- //this should add a check for view deleted if permissions are enabled
- if ($skipPermissions){
- $query->_skipDeleteClause = TRUE;
- }
+ //this should add a check for view deleted if permissions are enabled
+ if ($skipPermissions) {
+ $query->_skipDeleteClause = TRUE;
+ }
$query->generatePermissionClause(FALSE, $count);
// note : this modifies _fromClause and _simpleFromClause
list($select, $from, $where, $having) = $query->query($count);
$options = $query->_options;
- if (!empty($query->_permissionWhereClause)){
+ if (!empty($query->_permissionWhereClause)) {
if (empty($where)) {
$where = "WHERE $query->_permissionWhereClause";
}
if ($count) {
$noRows = $dao->rowCount;
$dao->free();
- return array($noRows,NULL);
+ return array($noRows, NULL);
}
$val = $query->store($dao);
$convertedVals = $query->convertToPseudoNames($dao, TRUE);
$where = $where . ' AND ' . $additionalWhereClause;
}
- //additional from clause should be w/ proper joins.
+ //additional from clause should be w/ proper joins.
if ($additionalFromClause) {
$from .= "\n" . $additionalFromClause;
}
}
// make sure contribution is completed - CRM-4989
- $completedWhere = $where . " AND civicrm_contribution.contribution_status_id = 1 ";
+ $completedWhere = $where . " AND civicrm_contribution.contribution_status_id = 1 ";
$summary = array();
'do_not_sms' => 1,
'do_not_trade' => 1,
'location' =>
- array(
- '1' => array('location_type' => 1,
- 'street_address' => 1,
- 'city' => 1,
- 'state_province' => 1,
- 'postal_code' => 1,
- 'postal_code_suffix' => 1,
- 'country' => 1,
- 'phone-Phone' => 1,
- 'phone-Mobile' => 1,
- 'phone-Fax' => 1,
- 'phone-1' => 1,
- 'phone-2' => 1,
- 'phone-3' => 1,
- 'im-1' => 1,
- 'im-2' => 1,
- 'im-3' => 1,
- 'email-1' => 1,
- 'email-2' => 1,
- 'email-3' => 1,
- ),
- '2' => array(
- 'location_type' => 1,
- 'street_address' => 1,
- 'city' => 1,
- 'state_province' => 1,
- 'postal_code' => 1,
- 'postal_code_suffix' => 1,
- 'country' => 1,
- 'phone-Phone' => 1,
- 'phone-Mobile' => 1,
- 'phone-1' => 1,
- 'phone-2' => 1,
- 'phone-3' => 1,
- 'im-1' => 1,
- 'im-2' => 1,
- 'im-3' => 1,
- 'email-1' => 1,
- 'email-2' => 1,
- 'email-3' => 1,
+ array(
+ '1' => array(
+ 'location_type' => 1,
+ 'street_address' => 1,
+ 'city' => 1,
+ 'state_province' => 1,
+ 'postal_code' => 1,
+ 'postal_code_suffix' => 1,
+ 'country' => 1,
+ 'phone-Phone' => 1,
+ 'phone-Mobile' => 1,
+ 'phone-Fax' => 1,
+ 'phone-1' => 1,
+ 'phone-2' => 1,
+ 'phone-3' => 1,
+ 'im-1' => 1,
+ 'im-2' => 1,
+ 'im-3' => 1,
+ 'email-1' => 1,
+ 'email-2' => 1,
+ 'email-3' => 1,
+ ),
+ '2' => array(
+ 'location_type' => 1,
+ 'street_address' => 1,
+ 'city' => 1,
+ 'state_province' => 1,
+ 'postal_code' => 1,
+ 'postal_code_suffix' => 1,
+ 'country' => 1,
+ 'phone-Phone' => 1,
+ 'phone-Mobile' => 1,
+ 'phone-1' => 1,
+ 'phone-2' => 1,
+ 'phone-3' => 1,
+ 'im-1' => 1,
+ 'im-2' => 1,
+ 'im-3' => 1,
+ 'email-1' => 1,
+ 'email-2' => 1,
+ 'email-3' => 1,
+ ),
),
- ),
);
}
return self::$_defaultHierReturnProperties;
* @param null $options
*/
function numberRangeBuilder(&$values,
- $tableName, $fieldName,
- $dbFieldName, $fieldTitle,
- $options = NULL
+ $tableName, $fieldName,
+ $dbFieldName, $fieldTitle,
+ $options = NULL
) {
list($name, $op, $value, $grouping, $wildcard) = $values;
*
* @return bool
*/
- public static function caseImportant( $op ) {
+ public static function caseImportant($op) {
return
in_array($op, array('LIKE', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY')) ? FALSE : TRUE;
}
*
* @return bool
*/
- public static function componentPresent( &$returnProperties, $prefix ) {
- foreach ($returnProperties as $name => $dontCare ) {
+ public static function componentPresent(&$returnProperties, $prefix) {
+ foreach ($returnProperties as $name => $dontCare) {
if (substr($name, 0, strlen($prefix)) == $prefix) {
return TRUE;
}
$useIDsOnly = FALSE
) {
- if (!empty($selectValues) && !is_array($value) && !empty($selectValues[$value])) {
+ if (!empty($selectValues) && !is_array($value) && !empty($selectValues[$value])) {
$qill = $selectValues[$value];
}
else {
$qill = $value;
}
- $pseudoFields = array('email_greeting', 'postal_greeting', 'addressee', 'gender_id', 'prefix_id', 'suffix_id', 'communication_style_id');
+ $pseudoFields = array(
+ 'email_greeting',
+ 'postal_greeting',
+ 'addressee',
+ 'gender_id',
+ 'prefix_id',
+ 'suffix_id',
+ 'communication_style_id'
+ );
if (is_numeric($value)) {
$qill = $selectValues[(int ) $value];
$returnValues = array();
foreach ($values as $v) {
- if ($dataType == 'Integer' && ! is_numeric($v)) {
+ if ($dataType == 'Integer' && !is_numeric($v)) {
return FALSE;
}
- else if ($dataType == 'String' && ! is_string($v)) {
+ else if ($dataType == 'String' && !is_string($v)) {
return FALSE;
}
$returnValues[] = trim($v);
$presentSimpleFrom = $present;
if (array_key_exists('civicrm_worldregion', $this->_whereTables) &&
- array_key_exists('civicrm_country', $presentSimpleFrom)) {
+ array_key_exists('civicrm_country', $presentSimpleFrom)
+ ) {
unset($presentSimpleFrom['civicrm_country']);
}
if (array_key_exists('civicrm_worldregion', $this->_tables) &&
- array_key_exists('civicrm_country', $present)) {
+ array_key_exists('civicrm_country', $present)
+ ) {
unset($present['civicrm_country']);
}