CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
break;
case 'activity_result':
- if(is_array($value)) {
+ if (is_array($value)) {
$safe = NULL;
- while(list(,$k) = each($value)) {
+ while (list(,$k) = each($value)) {
$safe[] = "'" . CRM_Utils_Type::escape($k, 'String') . "'";
}
$query->_where[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")";
$value = array();
$value = CRM_Core_OptionGroup::values($name);
if (!empty($value)) {
- while(list($k,$v) = each($value)) {
+ while (list($k,$v) = each($value)) {
$resultOptions[$v] = $v;
}
}
}
// If no survey result options have been created, don't build
// the field to avoid clutter.
- if(count($resultOptions) > 0) {
+ if (count($resultOptions) > 0) {
$buildSurveyResult = TRUE;
asort($resultOptions);
$form->add('select', 'activity_result', ts("Survey Result"),
$result = $query->searchQuery(0, 0, NULL);
while ($result->fetch()) {
- if(!empty($result->activity_id)) {
+ if (!empty($result->activity_id)) {
$ids[] = $result->activity_id;
}
}
'Activity', $returnProperties
);
$readOnlyFields['assignee_display_name'] = ts('Assigned to');
- if(!empty($contactDetails)) {
- foreach($contactDetails as $key => $value){
+ if (!empty($contactDetails)) {
+ foreach ($contactDetails as $key => $value){
$assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
- foreach($assignee as $keys => $values) {
+ foreach ($assignee as $keys => $values) {
$assigneeContact[] = CRM_Contact_BAO_Contact::displayname($values);
}
$contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL;
$clientRelationships = array_slice($allClientRelationships, $offset, $rowCount, TRUE);
// after sort we can update username fields to be a url
- foreach($clientRelationships as $key => $value) {
+ foreach ($clientRelationships as $key => $value) {
$clientRelationships[$key]['name'] = '<a href='.CRM_Utils_System::url('civicrm/contact/view',
'action=view&reset=1&cid='.$clientRelationships[$key]['cid']).'>'.$clientRelationships[$key]['name'].'</a>';
}
// move/transform caseRoles array data to caseRelationships
// for sorting and display
// CRM-14466 added cid to the non-client array to avoid php notice
- foreach($caseRoles as $id => $value) {
+ foreach ($caseRoles as $id => $value) {
if ($id != "client") {
$rel = array();
$rel['relation'] = $value;
$caseRelationships[] = $rel;
}
else {
- foreach($value as $clientRole) {
+ foreach ($value as $clientRole) {
$relClient = array();
$relClient['relation'] = 'Client';
$relClient['name'] = $clientRole['sort_name'];
if ($hasAccessToAllCases) {
$contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
$contactType = $contactType == 'Contact' ? '' : $contactType;
- switch($row['source']) {
+ switch ($row['source']) {
case 'caseRel':
$row['actions'] =
'<a href="#editCaseRoleDialog" title="'. ts('Reassign %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="'. $row['relation_type'] .'" data-rel_id="'. $row['rel_id'] .'"data-key="'. CRM_Core_Key::get('civicrm/ajax/relation') .'">'.
protected $_ppDAO;
public function preProcess() {
- if(!CRM_Core_Permission::check('administer payment processors')) {
+ if (!CRM_Core_Permission::check('administer payment processors')) {
CRM_Core_Error::statusBounce('The \'administer payment processors\' permission is required to add or edit a payment processor.');
}
parent::preProcess();
foreach ($this->_settings as $setting => $group){
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
$props = $settingMetaData['values'][$setting];
- if(isset($props['quick_form_type'])){
+ if (isset($props['quick_form_type'])){
$add = 'add' . $props['quick_form_type'];
- if($add == 'addElement'){
+ if ($add == 'addElement'){
$this->$add(
$props['html_type'],
$setting,
$this->$add($setting, ts($props['title']));
}
$this->assign("{$setting}_description", ts($props['description']));
- if($setting == 'max_attachments'){
+ if ($setting == 'max_attachments'){
//temp hack @todo fix to get from metadata
$this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
}
- if($setting == 'maxFileSize'){
+ if ($setting == 'maxFileSize'){
//temp hack
$this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
}
$tmpDir = trim($fields['newBaseDir']);
$errors = array();
- if (!is_writeable($tmpDir)) {
+ if (!is_writable($tmpDir)) {
$errors['newBaseDir'] = ts('%1 directory does not exist or cannot be written by webserver',
array(1 => $tmpDir)
);
case 'Joomla':
//condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value
- if( version_compare(JVERSION, '3.0', 'lt') ) {
+ if (version_compare(JVERSION, '3.0', 'lt') ) {
JHTML::_('behavior.modal');
$url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component';
$jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"';
$localExtensionRows = array(); // array($pseudo_id => extended_CRM_Extension_Info)
$keys = array_keys($manager->getStatuses());
sort($keys);
- foreach($keys as $key) {
+ foreach ($keys as $key) {
try {
$obj = $mapper->keyToInfo($key);
}
$printLabel->find();
$labels = array();
- while($printLabel->fetch()) {
+ while ($printLabel->fetch()) {
$labels[$printLabel->id] = $printLabel->title;
}
return $labels;
// CRM-14238 Only translate when we are in contact mode
// Other modes need the untranslated data for export and other functions
if (is_array($query->_select) && $query->_mode == CRM_Contact_BAO_Query::MODE_CONTACTS) {
- foreach($query->_select as $field => $queryString) {
+ foreach ($query->_select as $field => $queryString) {
if (substr($field, -11) == 'campaign_id') {
$query->_pseudoConstantsSelect[$field] = array(
'pseudoField' => 'campaign_id',
return NULL;
}
$reportId = CRM_Campaign_BAO_Survey::getReportID($id);
- if($reportId){
+ if ($reportId){
CRM_Report_BAO_ReportInstance::del($reportId);
}
$dao = new CRM_Campaign_DAO_Survey();
ON ( activityAssignment.activity_id = activity.id AND activityAssignment.record_type_id = $assigneeID )
WHERE activity.source_record_id = %1
AND ( activity.is_deleted IS NULL OR activity.is_deleted = 0 ) ";
- if(!empty($interviewerId)) {
+ if (!empty($interviewerId)) {
$query .= "AND activityAssignment.contact_id = %2 ";
$params[2] = array($interviewerId, 'Integer');
}
$upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
$recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
- foreach($upcoming as $key => $value) {
- if(strtotime($value['case_scheduled_activity_date']) < time()) {
+ foreach ($upcoming as $key => $value) {
+ if (strtotime($value['case_scheduled_activity_date']) < time()) {
$upcoming[$key]['activity_status'] = 'status-overdue';
}
}
// use metadata to translate the array to the appropriate DB type or altering the param in the api layer,
// or at least altering the param in same section as 'group_type' rather than repeating here. However, further down
// we need the $params one to be in it's original form & we are not sure what test coverage we have on that
- if(isset($group->parents) && is_array($group->parents)) {
+ if (isset($group->parents) && is_array($group->parents)) {
$group->parents = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
array_keys($group->parents)
) . CRM_Core_DAO::VALUE_SEPARATOR;
if (empty($params['parent_id']) && !empty($value['parents'])) {
$groupIds = explode(',', $value['parents']);
$title = array();
- foreach($groupIds as $gId) {
+ foreach ($groupIds as $gId) {
$title[] = $allGroups[$gId];
}
$groupList[$id]['group_name'] .= '<div class="crm-row-parent-name"><em>'.ts('Child of').'</em>: ' . implode(', ', $title) . '</div>';
$where .= " AND status = 'Added'";
}
$dao = CRM_Core_DAO::executeQuery("SELECT group_id, COUNT(id) as `count` FROM $table WHERE $where GROUP BY group_id");
- while($dao->fetch()) {
+ while ($dao->fetch()) {
$values[$dao->group_id]['count'] = $dao->count;
}
}
$relationshipId = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params));
//CRM-9015 - the hooks are called here & in add (since add doesn't call create)
// but in future should be tidied per ticket
- if(empty($relationshipId)){
+ if (empty($relationshipId)){
$hook = 'create';
$action = CRM_Core_Action::ADD;
}
CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params));
$hook = 'create';
- if($relationshipId) {
+ if ($relationshipId) {
$hook = 'edit';
}
//@todo hook are called from create and add - remove one
$dateFields = array('end_date', 'start_date');
foreach (self::getdefaults() as $defaultField => $defaultValue){
- if(isset($params[$defaultField])){
- if(in_array($defaultField, $dateFields)){
+ if (isset($params[$defaultField])){
+ if (in_array($defaultField, $dateFields)){
$relationship->$defaultField = CRM_Utils_Date::format(CRM_Utils_Array::value($defaultField, $params));
- if(!$relationship->$defaultField){
+ if (!$relationship->$defaultField){
$relationship->$defaultField = 'NULL';
}
}
$dateFields = array('end_date', 'start_date');
foreach ($dateFields as $dateField){
- if(array_key_exists($dateField, $params)) {
+ if (array_key_exists($dateField, $params)) {
if (empty($params[$dateField]) || $params[$dateField] == 'null'){
//this is most likely coming from an api call & probably loaded
// from the DB to deal with some of the
// CRM-6181
$where .= ' AND civicrm_contact.is_deleted = 0';
- if(!empty($params['membership_type_id']) && empty($params['relationship_type_id'])) {
+ if (!empty($params['membership_type_id']) && empty($params['relationship_type_id'])) {
$where .= self::membershipTypeToRelationshipTypes($params, $direction);
}
- if(!empty($params['relationship_type_id'])) {
- if(is_array($params['relationship_type_id'])) {
+ if (!empty($params['relationship_type_id'])) {
+ if (is_array($params['relationship_type_id'])) {
$where .= " AND " . CRM_Core_DAO::createSQLFilter('relationship_type_id', $params['relationship_type_id'], 'Integer');
}
else {
public static function membershipTypeToRelationshipTypes(&$params, $direction = NULL) {
$membershipType = civicrm_api3('membership_type', 'getsingle', array('id' => $params['membership_type_id'], 'return' => 'relationship_type_id, relationship_direction'));
$relationshipTypes = $membershipType['relationship_type_id'];
- if(empty($relationshipTypes)) {
+ if (empty($relationshipTypes)) {
return;
}
// if we don't have any contact data we can only filter on type
- if(empty($params['contact_id']) && empty($params['contact_id_a']) && empty($params['contact_id_a'])) {
+ if (empty($params['contact_id']) && empty($params['contact_id_a']) && empty($params['contact_id_a'])) {
$params['relationship_type_id'] = array('IN' => $relationshipTypes);
return;
}
// if we have contact_id_a OR contact_id_b we can make a call here
// if we have contact??
foreach ($relationshipDirections as $index => $mtdirection) {
- if(isset($params['contact_id_a']) && $mtdirection == 'a_b' || $direction == 'a_b') {
+ if (isset($params['contact_id_a']) && $mtdirection == 'a_b' || $direction == 'a_b') {
$types[] = $relationshipTypes[$index];
}
- if(isset($params['contact_id_b']) && $mtdirection == 'b_a' || $direction == 'b_a') {
+ if (isset($params['contact_id_b']) && $mtdirection == 'b_a' || $direction == 'b_a') {
$types[] = $relationshipTypes[$index];
}
}
- if(!empty($types)) {
+ if (!empty($types)) {
$params['relationship_type_id'] = array('IN' => $types);
}
elseif(!empty($clauses)) {
// this is due to some condition inside it which restricts it from saving in session
// so doing this for multi record edit action
$entityId = CRM_Utils_Request::retrieve('entityID', 'Positive', $this);
- if(!empty($entityId)) {
+ if (!empty($entityId)) {
$subType = CRM_Contact_BAO_Contact::getContactSubType($entityId, ',');
}
CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, NULL, NULL, $entityId);
// DETACH 'required' form rule error to
// custom data only if address data not exists upon submission
if (!empty($customDataRequiredFields)) {
- foreach($customDataRequiredFields as $customElementName) {
+ foreach ($customDataRequiredFields as $customElementName) {
$elementName = "address[$instance][$customElementName]";
if ($self->getElementError($elementName)) {
// set element error to none
// DETACH 'required' form rule error to
// custom data only if address data not exists upon submission
if (!empty($customDataRequiredFields) && !CRM_Core_BAO_Address::dataExists($addressValues)) {
- foreach($customDataRequiredFields as $customElementName) {
+ foreach ($customDataRequiredFields as $customElementName) {
$elementName = "address[$instance][$customElementName]";
if ($self->getElementError($elementName)) {
// set element error to none
* @static
*/
public static function buildQuickForm(&$form) {
- if(!empty($form->_submitValues)) {
+ if (!empty($form->_submitValues)) {
if ($customValueCount = CRM_Utils_Array::value('hidden_custom_group_count', $form->_submitValues)) {
if (is_array($customValueCount)) {
if (array_key_exists(0, $customValueCount)) {
$dedupeParams = CRM_Dedupe_Finder::formatParams($params['honor'], $profileContactType);
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType);
- if(count($ids)) {
+ if (count($ids)) {
$honorId = CRM_Utils_Array::value(0, $ids);
}
$jsData = array();
// Get just what we need to keep the dom small
$whatWeWant = array_flip(array('contact_type_a', 'contact_type_b', 'contact_sub_type_a', 'contact_sub_type_b'));
- foreach($this->_allRelationshipNames as $id => $vals) {
+ foreach ($this->_allRelationshipNames as $id => $vals) {
if ($vals['name_a_b'] === 'Employee of') {
$this->assign('employmentRelationship', $id);
}
$financialType = CRM_Utils_Array::value('financial_type_id', $this->_formValues);
if ($financialType && is_array($financialType)) {
unset($this->_formValues['financial_type_id']);
- foreach($financialType as $notImportant => $typeID) {
+ foreach ($financialType as $notImportant => $typeID) {
$this->_formValues['financial_type_id'][$typeID] = 1;
}
}
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
$financial_types = CRM_Contribute_PseudoConstant::financialType();
- foreach($financial_types as $financial_type_id => $financial_type) {
+ foreach ($financial_types as $financial_type_id => $financial_type) {
$form->addElement('checkbox', "financial_type_id[{$financial_type_id}]", 'Financial Type', $financial_type);
}
if (!empty($params['pref'])) {
$privacyValues = $params['pref'];
$count = 0;
- foreach($this->_contactIds as $contact_id) {
+ foreach ($this->_contactIds as $contact_id) {
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contact_id;
- foreach($privacyValues as $privacy_key => $privacy_value) {
+ foreach ($privacyValues as $privacy_key => $privacy_value) {
$contact->$privacy_key = $privacyValueNew;
}
$contact->save();
// Status message
$privacyOptions = CRM_Core_SelectValues::privacy();
$status = array();
- foreach($privacyValues as $privacy_key => $privacy_value) {
+ foreach ($privacyValues as $privacy_key => $privacy_value) {
$label = $privacyOptions[$privacy_key];
$status[] = $privacyValueNew ? ts("Added '%1'", array(1 => $label)) : ts("Removed '%1'", array(1 => $label));
}
if (isset($form->_caseId)) {
// if case-id is found in the url, create case activity record
$cases = explode(',', $form->_caseId);
- foreach($cases as $key => $val) {
+ foreach ($cases as $key => $val) {
if (is_numeric($val)) {
$caseParams = array(
'activity_id' => $activityId,
// retrieve and highlight required custom fields
$formattedFieldNames = $this->formatCustomFieldName($this->_mapperFields);
self::$customFields = CRM_Core_BAO_CustomField::getFields($this->_contactType);
- foreach(self::$customFields as $key => $attr) {
+ foreach (self::$customFields as $key => $attr) {
if (!empty($attr['is_required'])) {
$highlightedFields[] = "custom_$key";
}
$ret = array('is_error' => 0);
- foreach($clientList as $sourceContactID) {
+ foreach ($clientList as $sourceContactID) {
$relationParams = array(
'relationship_type_id' => $relType . '_a_b',
'contact_check' => array($relContactID => 1),
$caseRelationships->contact_id_a = $sourceContactID;
$caseRelationships->find();
- while($caseRelationships->fetch()) {
+ while ($caseRelationships->fetch()) {
$relationIds['relationship'] = $caseRelationships->id;
$relationIds['contactTarget'] = $relContactID;
}
// build insert query, note that currently we build cache for 500 contact records at a time, hence below approach
$insertValues = array();
- while($dao->fetch()) {
+ while ($dao->fetch()) {
$insertValues[] = "('civicrm_contact', {$dao->contact_id}, {$dao->contact_id}, '{$cacheKey}', '" . CRM_Core_DAO::escapeString($dao->sort_name) . "')";
}
* @return bool
*/
static protected function isPaymentTransaction($form) {
- if(!empty($form->_values['is_monetary']) && $form->_amount >= 0.0) {
+ if (!empty($form->_values['is_monetary']) && $form->_amount >= 0.0) {
return TRUE;
}
return FALSE;
*/
public static function getIsMembershipPayment($id) {
$membershipBlocks = civicrm_api3('membership_block', 'get', array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $id, 'sequential' => TRUE));
- if(!$membershipBlocks['count']) {
+ if (!$membershipBlocks['count']) {
return FALSE;
}
return $membershipBlocks['values'][0]['is_separate_payment'];
public static function del($params) {
//delete from contribution soft table
$contributionSoft = new CRM_Contribute_DAO_ContributionSoft();
- foreach($params as $column => $value) {
+ foreach ($params as $column => $value) {
$contributionSoft->$column = $value;
}
$contributionSoft->delete();
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
foreach (self::getRecurringFields() as $dateField => $dateFieldTitle) {
- if(self::buildDateWhere($values, $query, $name, $dateField, $dateFieldTitle)) {
+ if (self::buildDateWhere($values, $query, $name, $dateField, $dateFieldTitle)) {
return;
}
}
// Ensure we have a sensible string to display to the user.
$names = array();
if (isset($val) && is_array($val)) {
- foreach($val as $id) {
+ foreach ($val as $id) {
$names[] = CRM_Utils_Array::value($id, $types);
}
}
*/
public static function buildDateWhere(&$values, $query, $name, $field, $title) {
$fieldPart = strpos($name, $field);
- if($fieldPart === FALSE) {
+ if ($fieldPart === FALSE) {
return;
}
// we only have recurring dates using this ATM so lets' short cut to find the table name
$onlinePaymentProcessorEnabled = FALSE;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $name) {
- if($name['billing_mode'] == 1) {
+ if ($name['billing_mode'] == 1) {
$onlinePaymentProcessorEnabled = TRUE;
}
$pps[$key] = $name['name'];
}
$contactID = $this->getContactID();
- if($this->getContactID() === '0') {
+ if ($this->getContactID() === '0') {
$this->addCidZeroOptions($onlinePaymentProcessorEnabled);
}
//build pledge block.
$pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
// Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute');
- if(!empty($text)) {
+ if (!empty($text)) {
$pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
}
$this->assign('pcpSupporterText', $pcp_supporter_text);
$unitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $frUnits);
// CRM 10860, display text instead of a dropdown if there's only 1 frequency unit
- if(sizeof($unitVals) == 1) {
+ if (sizeof($unitVals) == 1) {
$form->assign('one_frequency_unit', TRUE);
$unit = $unitVals[0];
$form->add('hidden', 'frequency_unit', $unit);
$errors['_qf_default'] = ts('Select at least one option from Contribution(s).');
}
}
- if($otherAmount && !empty($check)) {
+ if ($otherAmount && !empty($check)) {
$errors["price_{$otherAmount}"] = ts('Amount is required field.');
}
'account_relationship = 7'
);
$productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
- foreach( $financialType as $key => $financialTypeName ){
- if(!in_array( $key, $productFinancialType)) {
+ foreach ($financialType as $key => $financialTypeName ){
+ if (!in_array( $key, $productFinancialType)) {
unset( $financialType[$key] );
}
}
- if( count( $financialType ) ){
+ if (count( $financialType ) ){
$this->assign( 'financialType', $financialType );
}
$this->add(
}
if (!empty($fields['is_recur_interval'])) {
- foreach(array_keys($fields['payment_processor']) as $paymentProcessorID) {
+ foreach (array_keys($fields['payment_processor']) as $paymentProcessorID) {
$paymentProcessorTypeId = CRM_Core_DAO::getFieldValue(
'CRM_Financial_DAO_PaymentProcessor',
$paymentProcessorID,
'account_relationship = 7'
);
$productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
- foreach( $financialType as $key => $financialTypeName ){
- if(!in_array( $key, $productFinancialType)) {
+ foreach ($financialType as $key => $financialTypeName ){
+ if (!in_array( $key, $productFinancialType)) {
unset( $financialType[$key] );
}
}
- if( count( $financialType ) ){
+ if (count( $financialType ) ){
$this->assign( 'financialType', $financialType );
}
$this->add(
// to check wether GD is installed or not
$gdSupport = CRM_Utils_System::getModuleSetting('gd', 'GD Support');
- if($gdSupport) {
- if($imageFile) {
+ if ($gdSupport) {
+ if ($imageFile) {
$error = FALSE;
$params['image'] = $this->_resizeImage($imageFile, "_full", 200, 200);
$params['thumbnail'] = $this->_resizeImage($imageFile, "_thumb", 50, 50);
$widthOrig = $imageInfo[0];
$heightOrig = $imageInfo[1];
$image = imagecreatetruecolor($width, $height);
- if($imageInfo['mime'] == 'image/gif') {
+ if ($imageInfo['mime'] == 'image/gif') {
$source = imagecreatefromgif($filename);
}
elseif($imageInfo['mime'] == 'image/png') {
$financialType = CRM_Utils_Array::value('financial_type_id', $this->_formValues);
if ($financialType && is_array($financialType)) {
unset($this->_formValues['financial_type_id']);
- foreach($financialType as $notImportant => $typeID) {
+ foreach ($financialType as $notImportant => $typeID) {
$this->_formValues['financial_type_id'][$typeID] = 1;
}
}
if ($tags && is_array($tags)) {
unset($this->_formValues['contact_tags']);
- foreach($tags as $notImportant => $tagID) {
+ foreach ($tags as $notImportant => $tagID) {
$this->_formValues['contact_tags'][$tagID] = 1;
}
}
if ($group && is_array($group)) {
unset($this->_formValues['group']);
- foreach($group as $notImportant => $groupID) {
+ foreach ($group as $notImportant => $groupID) {
$this->_formValues['group'][$groupID] = 1;
}
}
$this->add('text', 'title', ts('Find'), $attributes);
$financial_account = CRM_Contribute_PseudoConstant::financialType( );
- foreach($financial_account as $contributionId => $contributionName) {
+ foreach ($financial_account as $contributionId => $contributionName) {
$this->addElement('checkbox', "financial_type_id[$contributionId]", 'Financial Type', $contributionName);
}
'email' => ts('Send emails where possible. Generate printable PDFs for contacts who cannot receive email.'),
'both' => ts('Send emails where possible. Generate printable PDFs for all contacts.'),
);
- if(CRM_Core_Config::singleton()->doNotAttachPDFReceipt) {
+ if (CRM_Core_Config::singleton()->doNotAttachPDFReceipt) {
$emailOptions['pdfemail'] = ts('Send emails with an attached PDF where possible. Generate printable PDFs for contacts who cannot receive email.');
$emailOptions['pdfemail_both'] = ts('Send emails with an attached PDF where possible. Generate printable PDFs for all contacts.');
}
list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($form);
$isPDF = FALSE;
$emailParams = array();
- if(!empty($formValues['email_options'])) {
+ if (!empty($formValues['email_options'])) {
$returnProperties['email'] = $returnProperties['on_hold'] = $returnProperties['is_deceased'] = $returnProperties['do_not_email'] = 1;
$emailParams = array(
'subject' => $formValues['subject']
);
// We need display_name for emailLetter() so add to returnProperties here
$returnProperties['display_name'] = 1;
- if(stristr($formValues['email_options'], 'pdfemail')) {
+ if (stristr($formValues['email_options'], 'pdfemail')) {
$isPDF = TRUE;
}
}
$realSeparator = ', ';
//the original thinking was mutliple options - but we are going with only 2 (comma & td) for now in case
// there are security (& UI) issues we need to think through
- if(isset($formValues['group_by_separator'])) {
- if($formValues['group_by_separator'] == 'td') {
+ if (isset($formValues['group_by_separator'])) {
+ if ($formValues['group_by_separator'] == 'td') {
$realSeparator = "</td><td>";
}
}
foreach ($contributions as $contributionId => $contribution) {
$contact = &$contacts[$contribution['contact_id']];
$grouped = $groupByID = 0;
- if($groupBy) {
+ if ($groupBy) {
$groupByID = empty($contribution[$groupBy]) ? 0 : $contribution[$groupBy];
$contribution = $contact['combined'][$groupBy][$groupByID];
$grouped = TRUE;
self::assignCombinedContributionValues($contact, $contributions, $groupBy, $groupByID);
- if(empty($groupBy) || empty($contact['is_sent'][$groupBy][$groupByID])) {
- if(!$validated && $realSeparator == '</td><td>' && !self::isValidHTMLWithTableSeparator($messageToken, $html_message)) {
+ if (empty($groupBy) || empty($contact['is_sent'][$groupBy][$groupByID])) {
+ if (!$validated && $realSeparator == '</td><td>' && !self::isValidHTMLWithTableSeparator($messageToken, $html_message)) {
$realSeparator = ', ';
CRM_Core_Session::setStatus(ts('You have selected the table cell separator, but one or more token fields are not placed inside a table cell. This would result in invalid HTML, so comma separators have been used instead.'));
}
$validated = TRUE;
$html[$contributionId] = str_replace($separator, $realSeparator, self::resolveTokens($html_message, $contact, $contribution, $messageToken, $categories, $grouped, $separator));
$contact['is_sent'][$groupBy][$groupByID] = TRUE;
- if(!empty($formValues['email_options'])) {
- if(self::emailLetter($contact, $html[$contributionId], $isPDF, $formValues, $emailParams)) {
+ if (!empty($formValues['email_options'])) {
+ if (self::emailLetter($contact, $html[$contributionId], $isPDF, $formValues, $emailParams)) {
$emailed ++;
- if(!stristr($formValues['email_options'], 'both')) {
+ if (!stristr($formValues['email_options'], 'both')) {
unset($html[$contributionId]);
}
}
//@todo - figure out why
$form->_contactIds = array_keys($contacts);
self::createActivities($form, $html_message, $form->_contactIds);
- if(!empty($html)) {
+ if (!empty($html)) {
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
}
if ($updateStatus) {
CRM_Core_Session::setStatus($updateStatus);
}
- if(!empty($html)) {
+ if (!empty($html)) {
// ie. we have only sent emails - lets no show a white screen
CRM_Utils_System::civiExit(1);
}
foreach ($relevantEntities as $entity) {
if (isset($tokens[$entity]) && is_array($tokens[$entity])) {
foreach ($tokens[$entity] as $token) {
- if(!self::isHtmlTokenInTableCell($token, $entity, $html)) {;
+ if (!self::isHtmlTokenInTableCell($token, $entity, $html)) {;
return FALSE;
}
}
*/
private static function resolveTokens($html_message, $contact, $contribution, $messageToken, $categories, $grouped, $separator) {
$tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact, TRUE, $messageToken);
- if($grouped) {
+ if ($grouped) {
$tokenHtml = CRM_Utils_Token::replaceMultipleContributionTokens($separator, $tokenHtml, $contribution, TRUE, $messageToken);
}
else {
else {
$contactID = $contribution['contact_id'];
}
- if(!isset($contacts[$contactID])) {
+ if (!isset($contacts[$contactID])) {
list($contact) = CRM_Utils_Token::getTokenDetails(array('contact_id' => $contactID),
$returnProperties,
$skipOnHold,
$groupByID = empty($contribution[$groupBy]) ? 0 : $contribution[$groupBy];
$contacts[$contactID]['contribution_ids'][$groupBy][$groupByID][$contributionId] = TRUE;
- if(!isset($contacts[$contactID]['combined'][$groupBy]) || !isset($contacts[$contactID]['combined'][$groupBy][$groupByID])) {
+ if (!isset($contacts[$contactID]['combined'][$groupBy]) || !isset($contacts[$contactID]['combined'][$groupBy][$groupByID])) {
$contacts[$contactID]['combined'][$groupBy][$groupByID] = $contribution;
$contacts[$contactID]['aggregates'][$groupBy][$groupByID] = $contribution['total_amount'];
}
*/
public static function emailLetter($contact, $html, $is_pdf, $format = array(), $params = array()) {
try {
- if(empty($contact['email'])) {
+ if (empty($contact['email'])) {
return FALSE;
}
$mustBeEmpty = array('do_not_email', 'is_deceased', 'on_hold');
foreach ($mustBeEmpty as $emptyField) {
- if(!empty($contact[$emptyField])) {
+ if (!empty($contact[$emptyField])) {
return FALSE;
}
}
'text' => '',
'html' => $html,
);
- if(empty($params['from'])) {
+ if (empty($params['from'])) {
$emails = CRM_Core_BAO_Email::getFromEmail();
$emails = array_keys($emails);
$defaults['from'] = array_pop($emails);
}
- if($is_pdf) {
+ if ($is_pdf) {
$defaults['html'] = ts('Please see attached');
$defaults['attachments'] = array(CRM_Utils_Mail::appendPDF('ThankYou.pdf', $html, $format));
}
0,
);
}
- if(!empty($mapperKeysValues) && $mapperKeysValues[$i][0] == 'soft_credit') {
+ if (!empty($mapperKeysValues) && $mapperKeysValues[$i][0] == 'soft_credit') {
$js .= "cj('#mapper_".$i."_1').val($mapperKeysValues[$i][1]);\n";
$js .= "cj('#mapper_".$i."_2').val($mapperKeysValues[$i][2]);\n";
}
$params[$this->_activeFields[$i]->_name] = array();
}
$params[$this->_activeFields[$i]->_name][$i][$this->_activeFields[$i]->_softCreditField] = $this->_activeFields[$i]->_value;
- if(isset($this->_activeFields[$i]->_softCreditType)){
+ if (isset($this->_activeFields[$i]->_softCreditType)){
$params[$this->_activeFields[$i]->_name][$i]['soft_credit_type_id'] = $this->_activeFields[$i]->_softCreditType;
}
}
//Delete all existing soft Contribution from contribution_soft table for pcp_id is_null
$existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit['contribution_id']);
- if(isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])){
- foreach($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues){
+ if (isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])){
+ foreach ($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues){
if (!empty($existingSoftCreditValues['soft_credit_id'])) {
$deleteParams = array(
'id' => $existingSoftCreditValues['soft_credit_id'],
$dao->id
);
//Financial Type
- if( !empty( $dao->financial_type_id ) ){
+ if (!empty( $dao->financial_type_id ) ){
require_once 'CRM/Core/DAO.php';
$premiums[$dao->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name' );
}
unset(self::$_tasks[1]);
}
//CRM-12920 - check for edit permission
- if( !CRM_Core_Permission::check('edit contributions') ){
+ if (!CRM_Core_Permission::check('edit contributions') ){
unset(self::$_tasks[4], self::$_tasks[6]);
}
$actionSchedule = new CRM_Core_DAO_ActionSchedule();
$actionSchedule->mapping_id = $mappingID;
$actionSchedule->is_active = 1;
- if(!empty($params)) {
+ if (!empty($params)) {
_civicrm_api3_dao_set_filter($actionSchedule, $params, FALSE, 'ActionSchedule');
}
$actionSchedule->find();
// the DB to fatal
$fields = CRM_Core_BAO_Address::fields();
foreach ($fields as $fieldname => $field) {
- if(!empty($field['maxlength']) && strlen(CRM_Utils_Array::value($fieldname, $parseFields)) > $field['maxlength']) {
+ if (!empty($field['maxlength']) && strlen(CRM_Utils_Array::value($fieldname, $parseFields)) > $field['maxlength']) {
return $emptyParseFields;
}
}
if ($count > 2) {
break;
}
- if(count($first_names) == 1){
+ if (count($first_names) == 1){
$family = $first_names[current(array_keys($first_names))]['addressee_display'];
}
else {
$sql = "UPDATE $table SET is_primary = 0 WHERE contact_id = %1";
$sqlParams = array(1 => array($contactId, 'Integer'));
// we don't want to create unecessary entries in the log_ tables so exclude the one we are working on
- if(!empty($params['id'])){
+ if (!empty($params['id'])){
$sql .= " AND id <> %2";
$sqlParams[2] = array($params['id'], 'Integer');
}
$fieldName = "custom_{$fieldID}";
if ($isMultiple[$tableName]) {
if ($formatMultiRecordField) {
- if($file[$tableName][$fieldID] == 'File') {
- if($fileid = $dao->$fieldName) {
+ if ($file[$tableName][$fieldID] == 'File') {
+ if ($fileid = $dao->$fieldName) {
$fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName, $entityID);
$result["{$dao->id}"]["{$fieldID}"] = $fileurl[$dao->$fieldName];
}
}
}
else {
- if($file[$tableName][$fieldID] == 'File') {
- if($fileid = $dao->$fieldName) {
+ if ($file[$tableName][$fieldID] == 'File') {
+ if ($fileid = $dao->$fieldName) {
$fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName, $entityID);
$result[$fieldID] = $fileurl[$dao->$fieldName];
}
//Get the id of Logged in User
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
- if(!empty($contactID)) {
+ if (!empty($contactID)) {
$contactIDs[] = $session->get('userID');
}
}
SET is_bulkmail = 0
WHERE contact_id = {$params['contact_id']}
";
- if($hook == 'edit'){
+ if ($hook == 'edit'){
$sql .= " AND id <> {$params['id']}";
}
CRM_Core_DAO::executeQuery($sql);
$balanceAmtDAO = CRM_Core_DAO::executeQuery($q, $p);
$ret = array();
- while($balanceAmtDAO->fetch()) {
+ while ($balanceAmtDAO->fetch()) {
$ret['trxn_id'] = $balanceAmtDAO->id;
$ret['total_amount'] = $balanceAmtDAO->total_amount;
}
$sqlParams = array(1 => array($entity_id, 'Integer'), 2 => array($entity_table, 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
- while($dao->fetch()){
+ while ($dao->fetch()){
$result[$dao->financial_trxn_id][$dao->id] = $dao->amount;
}
if (!empty($result)) {
return $result;
}
- if(empty($params['id'])) {
+ if (empty($params['id'])) {
$params['is_ssl'] = CRM_Utils_Array::value('is_ssl', $params, FALSE);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
}
$js .= implode(', ', $elements);
$js .= "]";
$js .= "
- for(var i=0;i<nullArray.length;i++) {
+ for (var i=0;i<nullArray.length;i++) {
if ( {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'] ) {
{$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'].style.display = '';
}
$js .= implode(', ', $elements);
$js .= "]";
$js .= "
- for(var i=0;i<noneArray.length;i++) {
+ for (var i=0;i<noneArray.length;i++) {
if ( {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'] ) {
{$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'].style.display = 'none';
}
* @return object
*/
public static function add(&$params, $ids = array()) {
- if(empty($params['id'])){
+ if (empty($params['id'])){
$params['id'] = CRM_Utils_Array::value('optionGroup', $ids);
}
* @param array $params
*/
public static function setDefaults(&$params){
- if(CRM_Utils_Array::value('label', $params, NULL) === NULL){
+ if (CRM_Utils_Array::value('label', $params, NULL) === NULL){
$params['label'] = $params['name'];
}
- if(CRM_Utils_Array::value('name', $params, NULL) === NULL){
+ if (CRM_Utils_Array::value('name', $params, NULL) === NULL){
$params['name'] = $params['label'];
}
- if(CRM_Utils_Array::value('weight', $params, NULL) === NULL){
+ if (CRM_Utils_Array::value('weight', $params, NULL) === NULL){
$params['weight'] = self::getDefaultWeight($params);
}
if (CRM_Utils_Array::value('value', $params, NULL) === NULL){
public static function getDefaultValue($params){
$bao = new CRM_Core_BAO_OptionValue();
$bao->option_group_id = $params['option_group_id'];
- if(isset($params['domain_id'])){
+ if (isset($params['domain_id'])){
$bao->domain_id = $params['domain_id'];
}
$bao->selectAdd();
// to make sure we not copying to source itself\r
unset($repeatingEntities[$key]);\r
\r
- foreach($repeatingEntities as $key => $val) {\r
+ foreach ($repeatingEntities as $key => $val) {\r
$entityID = $val['id'];\r
$entityTable = $val['table'];\r
\r
// for each parent entity in the set, find out a similar linked entity,\r
// if doesn't exist create one, and also create entries in recurring_entity table\r
\r
- foreach($pRepeatingEntities as $key => $val) {\r
+ foreach ($pRepeatingEntities as $key => $val) {\r
if (array_key_exists($key, $processedEntities)) {\r
// this graph is already being processed\r
return NULL;\r
// start with first entry with just itself\r
CRM_Core_BAO_RecurringEntity::quickAdd($obj->id, $obj->id, $obj->__table);\r
\r
- foreach($pRepeatingEntities as $key => $val) {\r
+ foreach ($pRepeatingEntities as $key => $val) {\r
$rlinkedDAO = new self::$_tableDAOMapper[$obj->__table]();\r
$rlinkedDAO->$idCol = $val['id'];\r
$rlinkedDAO->$tableCol = $val['table'];\r
$startActionCondition = $scheduleReminderDetails['start_action_condition'];\r
$explodeStartActionCondition = explode(',', $startActionCondition);\r
$buildRuleArray = array();\r
- foreach($explodeStartActionCondition as $key => $val) {\r
+ foreach ($explodeStartActionCondition as $key => $val) {\r
$buildRuleArray[] = strtoupper(substr($val, 0, 2));\r
}\r
$r->wkst('MO')->byday($buildRuleArray);\r
}
}
- if($triggerRebuild) {
+ if ($triggerRebuild) {
CRM_Core_DAO::triggerRebuild($params['table_name']);
}
$fields = $result = array();
$fieldsToGet = self::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE);
foreach ($domains as $domainID) {
- if($domainID != CRM_Core_Config::domainID()){
+ if ($domainID != CRM_Core_Config::domainID()){
$reloadConfig = TRUE;
CRM_Core_BAO_Domain::setDomain($domainID);
}
$config = CRM_Core_Config::singleton($reloadConfig, $reloadConfig);
$result[$domainID] = array();
foreach ($fieldsToGet as $name => $value) {
- if(!empty($fields['values'][$name]['prefetch'])){
- if(isset($params['filters']) && isset($params['filters']['prefetch'])
+ if (!empty($fields['values'][$name]['prefetch'])){
+ if (isset($params['filters']) && isset($params['filters']['prefetch'])
&& $params['filters']['prefetch'] == 0){
// we are filtering out the prefetches from the return array
// so we will skip
continue;
}
$configKey = CRM_Utils_Array::value('config_key', $fields['values'][$name], $name);
- if(isset($config->$configKey)){
+ if (isset($config->$configKey)){
$setting = $config->$configKey;
}
}
}
foreach ($domains as $domainID) {
- if($domainID != CRM_Core_Config::domainID()){
+ if ($domainID != CRM_Core_Config::domainID()){
$reloadConfig = TRUE;
CRM_Core_BAO_Domain::setDomain($domainID);
}
$result[$domainID] = array();
foreach ($fieldsToSet as $name => $value) {
- if(empty($fields['values'][$name]['config_only'])){
+ if (empty($fields['values'][$name]['config_only'])){
CRM_Core_BAO_Setting::_setItem(
$fields['values'][$name],
$value,
$domainID
);
}
- if(!empty($fields['values'][$name]['prefetch'])){
- if(!empty($fields['values'][$name]['config_key'])){
+ if (!empty($fields['values'][$name]['prefetch'])){
+ if (!empty($fields['values'][$name]['config_key'])){
$name = $fields['values'][$name]['config_key'];
}
$config_keys[$name] = $value;
}
$result[$domainID][$name] = $value;
}
- if($reloadConfig){
+ if ($reloadConfig){
CRM_Core_Config::singleton($reloadConfig, $reloadConfig);
}
- if(!empty($config_keys)){
+ if (!empty($config_keys)){
CRM_Core_BAO_ConfigSetting::create($config_keys);
}
- if($reloadConfig){
+ if ($reloadConfig){
CRM_Core_BAO_Domain::resetDomain();
}
}
* @fieldSpec array Metadata for given field (drawn from the xml)
*/
public static function validateSetting(&$value, $fieldSpec) {
- if($fieldSpec['type'] == 'String' && is_array($value)){
+ if ($fieldSpec['type'] == 'String' && is_array($value)){
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,$value) . CRM_Core_DAO::VALUE_SEPARATOR;
}
if (empty($fieldSpec['validate_callback'])) {
$spec = self::getSettingSpecification(NULL, array('name' => $name), $domainID);
$configKey = CRM_Utils_Array::value('config_key', $spec[$name], CRM_Utils_Array::value('legacy_key', $spec[$name], $name));
//if the key is set to config_only we don't need to do anything
- if(empty($spec[$name]['config_only'])){
+ if (empty($spec[$name]['config_only'])){
if (!empty($values[$configKey])) {
civicrm_api('setting', 'create', array('version' => 3, $name => $values[$configKey], 'domain_id' => $domainID));
}
$requiredProfileFields = array();
foreach ($profileFields['values'] as $field) {
- if(in_array($field['field_name'], $validBillingFields)) {
+ if (in_array($field['field_name'], $validBillingFields)) {
$validProfileFields[] = $field['field_name'];
}
if ($field['is_required']) {
public static function create($params) {
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'UFMatch', CRM_Utils_Array::value('id', $params), $params);
- if(empty($params['domain_id'])) {
+ if (empty($params['domain_id'])) {
$params['domain_id'] = CRM_Core_Config::domainID();
}
$dao = new CRM_Core_DAO_UFMatch();
* @return WordReplacement array
*/
public static function create($params) {
- if(array_key_exists("domain_id", $params) === FALSE) {
+ if (array_key_exists("domain_id", $params) === FALSE) {
$params["domain_id"] = CRM_Core_Config::domainID();
}
$wordReplacement = new CRM_Core_DAO_WordReplacement();
);
$field['html'] = array();
foreach ($validOptions as $htmlOption) {
- if(!empty($fieldXML->html->$htmlOption)){
+ if (!empty($fieldXML->html->$htmlOption)){
$field['html'][$htmlOption] = $this->value($htmlOption, $fieldXML->html);
}
}
}
$field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
- if(!empty($field['pseudoconstant'])){
+ if (!empty($field['pseudoconstant'])){
//ok this is a bit long-winded but it gets there & is consistent with above approach
$field['pseudoconstant'] = array();
$validOptions = array(
'callback',
);
foreach ($validOptions as $pseudoOption) {
- if(!empty($fieldXML->pseudoconstant->$pseudoOption)){
+ if (!empty($fieldXML->pseudoconstant->$pseudoOption)){
$field['pseudoconstant'][$pseudoOption] = $this->value($pseudoOption, $fieldXML->pseudoconstant);
}
}
*/
public static function schemaRequiresRebuilding($tables = array("civicrm_contact")) {
$show = array();
- foreach($tables as $tableName){
+ foreach ($tables as $tableName){
if (!array_key_exists($tableName, $show)) {
$query = "SHOW CREATE TABLE $tableName";
$dao = CRM_Core_DAO::executeQuery($query);
// Core field
else {
$info = civicrm_api3($props['entity'], 'getfields');
- foreach($info['values'] as $uniqueName => $fieldSpec) {
+ foreach ($info['values'] as $uniqueName => $fieldSpec) {
if (
$uniqueName === $props['field'] ||
CRM_Utils_Array::value('name', $fieldSpec) === $props['field'] ||
*/
public function convertDateFieldsToMySQL(&$params){
foreach ($this->_dateFields as $fieldName => $specs){
- if(!empty($params[$fieldName])){
+ if (!empty($params[$fieldName])){
$params[$fieldName] = CRM_Utils_Date::isoToMysql(
CRM_Utils_Date::processDate(
$params[$fieldName],
);
}
else{
- if(isset($specs['default'])){
+ if (isset($specs['default'])){
$params[$fieldName] = date('YmdHis', strtotime($specs['default']));
}
}
*/
public function getContactID() {
$tempID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
- if(isset($this->_params) && isset($this->_params['select_contact_id'])) {
+ if (isset($this->_params) && isset($this->_params['select_contact_id'])) {
$tempID = $this->_params['select_contact_id'];
}
- if(isset($this->_params, $this->_params[0]) && !empty($this->_params[0]['select_contact_id'])) {
+ if (isset($this->_params, $this->_params[0]) && !empty($this->_params[0]['select_contact_id'])) {
// event form stores as an indexed array, contribution form not so much...
$tempID = $this->_params[0]['select_contact_id'];
}
'api' => array('params' => array('contact_type' => 'Individual'))
), $autoCompleteField);
- if($this->canUseAjaxContactLookups()) {
+ if ($this->canUseAjaxContactLookups()) {
$this->assign('selectable', $autoCompleteField['id_field']);
$this->addEntityRef($autoCompleteField['id_field'], NULL, array('placeholder' => $autoCompleteField['placeholder'], 'api' => $autoCompleteField['api']));
public function addCIDZeroOptions($onlinePaymentProcessorEnabled) {
$this->assign('nocid', TRUE);
$profiles = array();
- if($this->_values['custom_pre_id']) {
+ if ($this->_values['custom_pre_id']) {
$profiles[] = $this->_values['custom_pre_id'];
}
- if($this->_values['custom_post_id']) {
+ if ($this->_values['custom_post_id']) {
$profiles = array_merge($profiles, (array) $this->_values['custom_post_id']);
}
- if($onlinePaymentProcessorEnabled) {
+ if ($onlinePaymentProcessorEnabled) {
$profiles[] = 'billing';
}
- if(!empty($this->_values)) {
+ if (!empty($this->_values)) {
$this->addAutoSelector($profiles);
}
}
CRM_Core_OptionValue::getValues(array('name' => $entityTable.'_repeat_exclude_dates_'.self::$_parentEntityId), $optionValue);
$excludeOptionValues = array();
if (!empty($optionValue)) {
- foreach($optionValue as $key => $val) {
+ foreach ($optionValue as $key => $val) {
$excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value']));
}
self::$_excludeDateInfo = $excludeOptionValues;
$defaults['repetition_frequency_unit'] = self::$_scheduleReminderDetails->repetition_frequency_unit;
$defaults['repetition_frequency_interval'] = self::$_scheduleReminderDetails->repetition_frequency_interval;
$defaults['start_action_condition'] = array_flip(explode(",", self::$_scheduleReminderDetails->start_action_condition));
- foreach($defaults['start_action_condition'] as $key => $val) {
+ foreach ($defaults['start_action_condition'] as $key => $val) {
$val = 1;
$defaults['start_action_condition'][$key] = $val;
}
$numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
$form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;'));
$form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
- foreach($dayOfTheWeek as $key => $val) {
+ foreach ($dayOfTheWeek as $key => $val) {
$startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val." ", 0, 3));
}
$form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on'));
if ($opGroup->id) {
$oldWeight = 0;
$fieldValues = array('option_group_id' => $opGroup->id);
- foreach($excludeDates as $val) {
+ foreach ($excludeDates as $val) {
$optionGroupValue =
array(
'option_group_id' => $opGroup->id,
// find all entities from the recurring set. At this point we 'll get entities which were not deleted
// for e.g due to participants being present. We need to delete them from recurring tables anyway.
$pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);
- foreach($pRepeatingEntities as $val) {
+ foreach ($pRepeatingEntities as $val) {
CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);
}
}
* the date we entered to be respected
*/
$minDate = date_create('now', new DateTimeZone(self::TIMEZONE));
- if(strtotime($startDate->format('Y-m-d')) < strtotime($minDate->format('Y-m-d'))){
+ if (strtotime($startDate->format('Y-m-d')) < strtotime($minDate->format('Y-m-d'))){
$startDate->setTimezone(new DateTimeZone(self::TIMEZONE));
}
*/
public function _getAuthorizeNetFields() {
$amount = $this->_getParam('total_amount');//Total amount is from the form contribution field
- if(empty($amount)){//CRM-9894 would this ever be the case??
+ if (empty($amount)){//CRM-9894 would this ever be the case??
$amount = $this->_getParam('amount');
}
$fields = array();
$contRecur = CRM_Core_DAO::executeQuery($sql);
$contRecur->fetch();
$ids['contributionRecur'] = $contRecur->id;
- if($ids['contact'] != $contRecur->contact_id){
+ if ($ids['contact'] != $contRecur->contact_id){
CRM_Core_Error::debug_log_message("Recurring contribution appears to have been re-assigned from id {$ids['contact']} to {$contRecur->contact_id}
Continuing with {$contRecur->contact_id}
");
* @throws CRM_Core_Exception
*/
public function setInputParameters($parameters) {
- if(!is_array($parameters)) {
+ if (!is_array($parameters)) {
throw new CRM_Core_Exception('Invalid input parameters');
}
$this->_inputParameters = $parameters;
$values['receipt_from_name'] = $domainValues[0];
$values['receipt_from_email'] = $domainValues[1];
}
- if($recurContrib && $recurContrib->id){
+ if ($recurContrib && $recurContrib->id){
//CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
// we have a pledge now we need to get the oldest unpaid payment
$paymentDetails = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
- if(empty($paymentDetails['id'])){
+ if (empty($paymentDetails['id'])){
// we can assume this pledge is now completed
// return now so we don't create a core error & roll back
return;
* Set $this->_invoiceData from the input array
*/
public function setInvoiceData() {
- if(empty($this->_inputParameters['rp_invoice_id'])) {
+ if (empty($this->_inputParameters['rp_invoice_id'])) {
$this->_isPaymentExpress = TRUE;
return;
}
// p has been overloaded & could mean contribution page or participant id. Clearly we need an
// alphabet with more letters.
// the mode will always be resolved before the mystery p is reached
- if($rpValueArray[1] == 'contribute') {
+ if ($rpValueArray[1] == 'contribute') {
$mapping['p'] = 'contribution_page_id';
}
}
- if(empty($this->_inputParameters['component'])) {
+ if (empty($this->_inputParameters['component'])) {
$this->_isPaymentExpress = TRUE;
}
}
$contributionStatuses = $contributionStatuses['values'];
switch ($txnType) {
case 'recurring_payment_profile_created':
- if(in_array($recur->contribution_status_id, array(array_search('Pending', $contributionStatuses), array_search('In Progress', $contributionStatuses)))
+ if (in_array($recur->contribution_status_id, array(array_search('Pending', $contributionStatuses), array_search('In Progress', $contributionStatuses)))
&& !empty($recur->processor_id)) {
echo "already handled";
return;
//contribution installment is completed
if ($this->retrieve('profile_status', 'String') == 'Expired') {
- if(!empty($recur->end_date)) {
+ if (!empty($recur->end_date)) {
echo "already handled";
return;
}
public function main() {
CRM_Core_Error::debug_var('GET', $_GET, TRUE, TRUE);
CRM_Core_Error::debug_var('POST', $_POST, TRUE, TRUE);
- if($this->_isPaymentExpress) {
+ if ($this->_isPaymentExpress) {
$this->handlePaymentExpress();
return;
}
$objects = $ids = $input = array();
$isFirst = FALSE;
$input['txnType'] = $this->retrieve('txn_type', 'String');
- if($input['txnType'] != 'recurring_payment') {
+ if ($input['txnType'] != 'recurring_payment') {
throw new CRM_Core_Exception('Paypal IPNS not handled other than recurring_payments');
}
$input['invoice'] = self::getValue('i', FALSE);
$this->getInput($input, $ids);
- if($this-> transactionExists($input['trxn_id'])) {
+ if ($this-> transactionExists($input['trxn_id'])) {
throw new CRM_Core_Exception('This transaction has already been processed');
}
$ids['contribution'] = $result['id'];
//@todo hard - coding 'pending' for now
- if($result['contribution_status_id'] == 2) {
+ if ($result['contribution_status_id'] == 2) {
$isFirst = TRUE;
}
// arg api won't get this - fix it
* @param string $trxn_id
*/
public function transactionExists($trxn_id) {
- if(CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_contribution WHERE trxn_id = %1",
+ if (CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_contribution WHERE trxn_id = %1",
array(
1 => array($trxn_id, 'String')
))) {
$permissions = (array) $permissions;
foreach ($permissions as $permission) {
- if(is_array($permission)) {
+ if (is_array($permission)) {
foreach ($permission as $orPerm) {
- if(self::check($orPerm)) {
+ if (self::check($orPerm)) {
//one of our 'or' permissions has succeeded - stop checking this permission
return TRUE;;
}
return FALSE;
}
else {
- if(!CRM_Core_Config::singleton()->userPermissionClass->check($permission)) {
+ if (!CRM_Core_Config::singleton()->userPermissionClass->check($permission)) {
//one of our 'and' conditions has not been met
return FALSE;
}
* @return array|null
*/
public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL, $context = '') {
- if(!empty($context)) {
- if(CRM_Core_Permission::check($context)) {
+ if (!empty($context)) {
+ if (CRM_Core_Permission::check($context)) {
return TRUE;
}
}
}
list ($civiPrefix, $name) = CRM_Utils_String::parsePrefix(':', $perm, NULL);
- switch($civiPrefix) {
+ switch ($civiPrefix) {
case 'Joomla':
return explode(':', $name);
$pseudoconstant = $fieldSpec['pseudoconstant'];
// if callback is specified..
- if(!empty($pseudoconstant['callback'])) {
+ if (!empty($pseudoconstant['callback'])) {
list($className, $fnName) = explode('::', $pseudoconstant['callback']);
if (method_exists($className, $fnName)) {
return call_user_func(array($className, $fnName));
);
// Fetch option group from option_value table
- if(!empty($pseudoconstant['optionGroupName'])) {
+ if (!empty($pseudoconstant['optionGroupName'])) {
if ($context == 'validate') {
$params['labelColumn'] = 'name';
}
if ($snippet['disabled']) {
continue;
}
- switch($snippet['type']) {
+ switch ($snippet['type']) {
case 'markup':
$html .= $snippet['markup'];
break;
$setDateFields = array_intersect_key($this->_params, array_flip($this->_dateFields));
CRM_Contact_Import_Parser_Contact::formatCommonData($this->_params, $formatted, $formatted);
- foreach($formatted['custom'] as $key => $val) {
+ foreach ($formatted['custom'] as $key => $val) {
$this->_params['custom_'.$key] = $val[-1]['value'];
}
$this->_params['skipRecentView'] = TRUE;
public static function internalFilters($rg, $strID1 = 'contact1.id', $strID2 = 'contact2.id') {
// Add a contact id filter for dedupe by group requests and add logic
// to remove duplicate results with opposing orders, i.e. 1,2 and 2,1
- if( !empty($rg->contactIds) ) {
+ if (!empty($rg->contactIds) ) {
$cids = implode(',', $rg->contactIds);
return "($strID1 IN ($cids) AND ( $strID2 NOT IN ($cids) OR ($strID2 IN ($cids) AND $strID1 < $strID2) ))";
}
'extends' => array('IN' => array('Individual', 'Organization', 'Household', 'Contact')),
'return' => array('id', 'title', 'table_name', 'style'),
));
- foreach($result['values'] as $custom) {
+ foreach ($result['values'] as $custom) {
$data['cidRefs'][$custom['table_name']] = array('entity_id');
$urlSuffix = $custom['style'] == 'Tab' ? '&selectedChild=custom_' . $custom['id'] : '';
$data['relTables']['rel_table_custom_' . $custom['id']] = array(
//generally if people are creating participant_payments via the api they won't be setting the line item correctly - we can't help them if they are doing complex transactions
// but if they have a single line item for the contribution we can assume it should refer to the participant line
$lineItemCount = CRM_Core_DAO::singleValueQuery("select count(*) FROM civicrm_line_item WHERE contribution_id = %1", array(1 => array($participantPayment->contribution_id, 'Integer')));
- if($lineItemCount == 1) {
+ if ($lineItemCount == 1) {
$sql = "UPDATE civicrm_line_item li
SET entity_table = 'civicrm_participant', entity_id = %1
WHERE contribution_id = %2 AND entity_table = 'civicrm_contribution'";
//Get parent of this event
$exEventId = '';
if ($query->_where[$grouping]) {
- foreach($query->_where[$grouping] as $key => $val) {
+ foreach ($query->_where[$grouping] as $key => $val) {
if (strstr($val, 'civicrm_event.id =')) {
$exEventId = $val;
$extractEventId = explode(" ", $val);
if ($thisEventHasParent) {
$getAllConnections = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($thisEventHasParent, 'civicrm_event');
$allEventIds = array();
- foreach($getAllConnections as $key => $val) {
+ foreach ($getAllConnections as $key => $val) {
$allEventIds[] = $val['id'];
}
if (!empty($allEventIds)) {
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->id = $contriId;
$contribution->find( TRUE );
- foreach( array('financial_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', 'total_amount' ) as $f ) {
+ foreach (array('financial_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', 'total_amount' ) as $f ) {
if ($f == 'receive_date') {
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults($contribution->$f);
}
//create discount priceset
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
if (!empty($discountFieldIDs[$j])) {
- foreach($discountFieldIDs[$j] as $fID){
+ foreach ($discountFieldIDs[$j] as $fID){
CRM_Price_BAO_PriceFieldValue::setIsActive($fID, '0');
}
}
// check each of the fields in the index against the profile field
foreach ($index as $ifield => $icombos) {
- if(strpos($field['name'], $ifield) !== FALSE) {
+ if (strpos($field['name'], $ifield) !== FALSE) {
// we found the field in the profile, now record it in the index
foreach ($icombos as $icombo => $dontcare) {
$cantDedupe = ts("The selected profiles can collect enough information to match registrations with existing contacts, but not all of the relevant fields are required. Anonymous registrations may result in duplicate contacts.");
}
if (!empty($params['is_multiple_registrations'])) {
- switch(self::canProfilesDedupe($additionalProfileIds, $rgId)) {
+ switch (self::canProfilesDedupe($additionalProfileIds, $rgId)) {
case 0:
$dedupeTitle = 'Duplicate Matching Impossible';
if ($cantDedupe) {
$allEventIdsArray = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($checkParentExistsForThisId, 'civicrm_event');
$allEventIds = array();
if (!empty($allEventIdsArray)) {
- foreach($allEventIdsArray as $key => $val) {
+ foreach ($allEventIdsArray as $key => $val) {
$allEventIds[] = $val['id'];
}
if (!empty($allEventIds)) {
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
$permissions = CRM_Event_BAO_Event::checkPermission();
- while($dao->fetch()) {
+ while ($dao->fetch()) {
if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
$manageEvent[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
GROUP BY p.event_id";
$dao = CRM_Core_DAO::executeQuery($query);
$participantDetails = array();
- while($dao->fetch()) {
+ while ($dao->fetch()) {
$participantDetails['countByID'][$dao->event_id] = $dao->participant_count;
$participantDetails['countByName'][$dao->event_id][$dao->event_data] = $dao->participant_count;
}
$eventID = $_POST['event_id'];
}
- if($this->_eID) {
+ if ($this->_eID) {
$eventID = $this->_eID;
//@todo - rationalise the $this->_eID with $POST['event_id'], $this->_eid is set when eid=x is in the url
$roleID = CRM_Core_DAO::getFieldValue(
$this->_eID,
'default_role_id'
);
- if(empty($roleIDs)) {
+ if (empty($roleIDs)) {
$roleIDs = (array) $defaults[$this->_id]['participant_role_id'] = $roleID;
}
$defaults[$this->_id]['event_id'] = $eventID;
}
//these should take precedence so we state them last
$urlRoleIDS = CRM_Utils_Request::retrieve('roles', 'String');
- if($urlRoleIDS) {
+ if ($urlRoleIDS) {
$roleIDs = explode(',', $urlRoleIDS);
}
if (isset($roleIDs)) {
}
// For single additions - show validation error if the contact has already been registered
// for this event with the same role.
- if($self->_single && ($self->_action & CRM_Core_Action::ADD)) {
+ if ($self->_single && ($self->_action & CRM_Core_Action::ADD)) {
$contactId = $self->_contactId;
$eventId = CRM_Utils_Array::value('event_id', $values);
- if(!empty($contactId) && !empty($eventId)) {
+ if (!empty($contactId) && !empty($eventId)) {
$dupeCheck = new CRM_Event_BAO_Participant;
$dupeCheck->contact_id = $contactId;
$dupeCheck->event_id = $eventId;
$dupeCheck->find(TRUE);
- if(!empty($dupeCheck->id)) {
+ if (!empty($dupeCheck->id)) {
$errorMsg['event_id'] = ts("This contact has already been assigned to this event.");
}
}
// removed automatically and the user receives one notification.
if ($this->_action & CRM_Core_Action::ADD) {
$event_id = $this->_eventId;
- if(empty($event_id) && !empty($params['event_id'])) {
+ if (empty($event_id) && !empty($params['event_id'])) {
$event_id = $params['event_id'];
}
- if(!$this->_single && !empty($event_id)) {
+ if (!$this->_single && !empty($event_id)) {
$duplicateContacts = 0;
- while(list($k, $dupeCheckContactId) = each($this->_contactIds)) {
+ while (list($k, $dupeCheckContactId) = each($this->_contactIds)) {
// Eliminate contacts that have already been assigned to this event.
$dupeCheck = new CRM_Event_BAO_Participant;
$dupeCheck->contact_id = $dupeCheckContactId;
$dupeCheck->event_id = $event_id;
$dupeCheck->find(TRUE);
- if(!empty($dupeCheck->id)) {
+ if (!empty($dupeCheck->id)) {
$duplicateContacts++;
unset($this->_contactIds[$k]);
}
}
- if($duplicateContacts > 0) {
+ if ($duplicateContacts > 0) {
$msg = ts(
"%1 contacts have already been assigned to this event. They were not added a second time.",
array(1 => $duplicateContacts)
);
CRM_Core_Session::setStatus($msg);
}
- if(count($this->_contactIds) == 0) {
+ if (count($this->_contactIds) == 0) {
CRM_Core_Session::setStatus(ts("No participants were added."));
return;
}
$defaults[$this->_participantId] = array_merge($defaults[$this->_participantId], $priceSetValues);
}
else {
- foreach($priceFieldId as $key => $value) {
+ foreach ($priceFieldId as $key => $value) {
if (!empty($value) && ($this->_values['fee'][$value]['html_type'] == 'Radio' || $this->_values['fee'][$value]['html_type'] == 'Select') && !$this->_values['fee'][$value]['is_required']) {
$defaults[$this->_participantId]['price_'.array_keys($this->_values['fee'])[$key]] = 0;
}
// update participant
CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'status_id', $params['status_id']);
- if(!empty($params['note'])) {
+ if (!empty($params['note'])) {
$noteParams = array(
'entity_table' => 'civicrm_participant',
'note' => $params['note'],
'contact_type'
);
- if(array_key_exists('contact_id', $params) && empty($params['contact_id'])) {
+ if (array_key_exists('contact_id', $params) && empty($params['contact_id'])) {
// we unset this here because the downstream function ignores the contactID we give it
// if it is set & it is difficult to understand the implications of 'fixing' this downstream
// but if we are passing a contact id into this function it's reasonable to assume we don't
$onlinePaymentProcessorEnabled = FALSE;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $name) {
- if($name['billing_mode'] == 1) {
+ if ($name['billing_mode'] == 1) {
$onlinePaymentProcessorEnabled = TRUE;
}
$pps[$key] = $name['name'];
}
}
- if($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) {
+ if ($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) {
//@todo we are blocking for multiple registrations because we haven't tested
$this->addCidZeroOptions($onlinePaymentProcessorEnabled);
}
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
- if($key == 'participant_register_date') {
+ if ($key == 'participant_register_date') {
CRM_Utils_Date::convertToDefaultDate($params, $dateType, 'participant_register_date');
$formatted['participant_register_date'] = CRM_Utils_Date::processDate($params['participant_register_date']);
}
unset(self::$_tasks[1]);
}
//CRM-12920 - check for edit permission
- if( !CRM_Core_Permission::check('edit event participants') ){
+ if (!CRM_Core_Permission::check('edit event participants') ){
unset(self::$_tasks[4], self::$_tasks[5], self::$_tasks[15]);
}
}
public function checkRequirements() {
$errors = array();
- if (!$this->containerDir || !is_dir($this->containerDir) || !is_writeable($this->containerDir)) {
+ if (!$this->containerDir || !is_dir($this->containerDir) || !is_writable($this->containerDir)) {
$civicrmDestination = urlencode(CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'));
$url = CRM_Utils_System::url('civicrm/admin/setting/path', "reset=1&civicrmDestination=${civicrmDestination}");
$errors[] = array(
// boolean false means don't try to check extensions
// http://issues.civicrm.org/jira/browse/CRM-10575
- if($url === FALSE) {
+ if ($url === FALSE) {
$this->_repoUrl = FALSE;
}
else {
public function export($exportParams) {
parent::export( $exportParams );
- foreach( self::$complementaryTables as $rct ) {
+ foreach (self::$complementaryTables as $rct ) {
$func = "export{$rct}";
$this->$func();
}
// In all cases need to do something with tabs in the input.
$s1 = str_replace( self::$SEPARATOR, '\t', $s );
- switch( $type ) {
+ switch ($type ) {
case 'date':
$sout = date( 'Y/m/d', strtotime( $s1 ) );
break;
* @return object
*/
public static function add(&$params, &$ids = array()) {
- if(empty($params['id'])) {
+ if (empty($params['id'])) {
$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);
* @return object
*/
public static function add(&$params, &$ids = array()) {
- if(empty($params['id'])) {
+ if (empty($params['id'])) {
$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 (!empty($_GET['batch_id'])) {
//validate batch ids
$batchIds = explode(',', $_GET['batch_id']);
- foreach($batchIds as $batchId) {
+ foreach ($batchIds as $batchId) {
CRM_Utils_Type::validate($batchId, 'Positive');
}
//check if batch status is valid, do not allow exported batches to export again
$batchStatus = CRM_Batch_BAO_Batch::getBatchStatuses($this->_batchIds);
- foreach( $batchStatus as $batchStatusId ) {
+ foreach ($batchStatus as $batchStatusId ) {
if ($batchStatusId == $this->_exportStatusId) {
CRM_Core_Error::fatal(ts('You cannot exported the batches which were exported earlier.'));
}
$batchParams['status_id'] = $this->_exportStatusId;
$ids = array();
- foreach($batchIds as $batchId) {
+ foreach ($batchIds as $batchId) {
$batchParams['id'] = $ids['batchID'] = $batchId;
// Update totals
$batchParams = array_merge($batchParams, $totals[$batchId]);
$params['entity_table'] = 'civicrm_financial_type';
CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
- foreach( $financialAccountIds as $key => $values){
+ foreach ($financialAccountIds as $key => $values){
if (!empty($financialAccounts[$values['financial_account_id']])) {
$financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value(
$values['financial_account_id'], $financialAccounts );
$grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
if (empty($params['skipRecentView'])) {
- if(!isset($grant->contact_id) || !isset($grant->grant_type_id)){
+ if (!isset($grant->contact_id) || !isset($grant->grant_type_id)){
$grant->find(TRUE);
}
$title = CRM_Contact_BAO_Contact::displayName($grant->contact_id) . ' - ' . ts('Grant') . ': ' . $grantTypes[$grant->grant_type_id];
}
}
if (!empty($val)) {
- foreach($val as $id) {
+ foreach ($val as $id) {
$names[] = CRM_Utils_Array::value($id, $grantTypes);
}
}
}
}
if (!empty($val)) {
- foreach($val as $id) {
+ foreach ($val as $id) {
$names[] = CRM_Utils_Array::value($id, $grantStatus);
}
}
//add setting so this can be tested by unit test
//@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate
// from the one which deals with web inputs & outputs so we have a properly testable & re-usable function
- if(!empty($params['is_unit_test'])) {
+ if (!empty($params['is_unit_test'])) {
return array($groups, $iFilteredTotal);
}
echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
// the record that comes last that counts. That's because we are
// INSERT'ing INTO a table with a primary id so that last record
// over writes any previous record.
- switch($email_selection_method) {
+ switch ($email_selection_method) {
case 'location-exclude':
$location_filter = "($email.location_type_id != $location_type_id)";
// If there is more than one email that doesn't match the location,
$tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens);
}
- if(method_exists($form, 'listTokens')) {
+ if (method_exists($form, 'listTokens')) {
$tokens = array_merge($form->listTokens(), $tokens);
}
$tracker->url = $url;
$tracker->mailing_id = $mailing_id;
- if(strlen($tracker->url) > 254) {
+ if (strlen($tracker->url) > 254) {
return $url;
}
if (!$tracker->find(TRUE)) {
$this->assign('groupCount', count($groups));
$this->assign('mailingCount', count($mailings));
- if(count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) {
+ if (count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) {
CRM_Core_Error::statusBounce("To send a mailing, you must have a valid group of recipients - either at least one group that's a Mailing List or at least one previous mailing or start from a search");
}
}
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if(CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if(CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if(CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if(CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
*/
public static function create($params){
$ids = array();
- if(!empty($params['id'])){
+ if (!empty($params['id'])){
$ids['membershipStatus'] = $params['id'];
}
else{
$names = array();
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
foreach ($value as $id => $dontCare) {
- if(!empty($membershipTypes[$id])) {
+ if (!empty($membershipTypes[$id])) {
$names[] = $membershipTypes[$id];
}
}
));
$tmp_statuses = $result['values'];
$status_ids = array();
- foreach($tmp_statuses as $cur_stat) {
+ foreach ($tmp_statuses as $cur_stat) {
$status_ids[] = $cur_stat['id'];
}
if (empty($params['status_id']) || in_array( $params['status_id'], $status_ids) == FALSE) {
$autoRenewOptions = array(ts('Not offered'), ts('Give option'), ts('Required'));
$this->addElement('select', "auto_renew_$k", ts('Auto-renew'), $autoRenewOptions);
//CRM-15573
- if($autoRenew == 2) {
+ if ($autoRenew == 2) {
$this->freeze("auto_renew_$k");
$params['id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipBlock', $this->_id, 'id', 'entity_id');
}
if (!empty($paymentProcessorId)) {
$paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, NULL, 'name');
- foreach($paymentProcessorId as $pid) {
+ foreach ($paymentProcessorId as $pid) {
if ($pid) {
$paymentProcessorTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor',
$pid, 'payment_processor_type_id'
// auto renew options if enabled for the membership
$options = CRM_Core_SelectValues::memberAutoRenew();
- foreach( $allMemberships as $key => $values ) {
+ foreach ($allMemberships as $key => $values ) {
if (!empty($values['is_active'])) {
$membershipType[$key] = CRM_Utils_Array::value('name', $values);
if ($this->_mode && empty($values['minimum_fee'])) {
}
//assign contribution contact id to the field expected by recordMembershipContribution
- if($this->_contributorContactID != $this->_contactID){
+ if ($this->_contributorContactID != $this->_contactID){
$formValues['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])){
$formValues['soft_credit'] = array(
$mergeSameAddress = CRM_Utils_Array::value('merge_same_address', $formValues);
$mergeSameHousehold = CRM_Utils_Array::value('merge_same_household', $formValues);
$isPerMembership = CRM_Utils_Array::value('per_membership', $formValues);
- if($isPerMembership && ($mergeSameAddress || $mergeSameHousehold)) {
+ if ($isPerMembership && ($mergeSameAddress || $mergeSameHousehold)) {
// this shouldn't happen - perhaps is could if JS is disabled
CRM_Core_Session::setStatus(ts('As you are printing one label per membership your merge settings are being ignored'));
$mergeSameAddress = $mergeSameHousehold = FALSE;
$rows[$id] = array($formatted);
}
- if($isPerMembership) {
+ if ($isPerMembership) {
$labelRows = array();
$memberships = civicrm_api3('membership', 'get', array('id' => array('IN' => $this->_memberIds), 'return' => 'contact_id'));
foreach ($memberships['values'] as $id => $membership) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$values[$key] = $value;
$type = $customFields[$customFieldID]['html_type'];
- if( $type == 'CheckBox' || $type == 'Multi-Select' || $type == 'AdvMulti-Select') {
+ if ($type == 'CheckBox' || $type == 'Multi-Select' || $type == 'AdvMulti-Select') {
$mulValues = explode( ',', $value );
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
$values[$key] = array();
- foreach( $mulValues as $v1 ) {
- foreach($customOption as $customValueID => $customLabel) {
+ foreach ($mulValues as $v1 ) {
+ foreach ($customOption as $customValueID => $customLabel) {
$customValue = $customLabel['value'];
if (( strtolower($customLabel['label']) == strtolower(trim($v1)) ) ||
( strtolower($customValue) == strtolower(trim($v1)) )) {
//CRM-13901 don't show dashboard to contacts with limited view writes & it does not relect
//what they have access to
//@todo implement acls on dashboard querys (preferably via api to enhance that at the same time)
- if(!CRM_Core_Permission::check(array('view all contacts', 'edit all contacts'))) {
+ if (!CRM_Core_Permission::check(array('view all contacts', 'edit all contacts'))) {
$this->showMembershipSummary = FALSE;
$this->assign('membershipSummary', FALSE);
return;
unset(self::$_tasks[1]);
}
//CRM-12920 - check for edit permission
- if( !CRM_Core_Permission::check('edit memberships') ){
+ if (!CRM_Core_Permission::check('edit memberships') ){
unset(self::$_tasks[5]);
}
}
if ($pcpInfo['page_type'] == 'event') {
$pcp_supporter_text = ts('This event registration is being made thanks to effort of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event');
- if(!empty($text)) {
+ if (!empty($text)) {
$pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!";
}
}
else {
$pcp_supporter_text = ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute');
- if(!empty($text)) {
+ if (!empty($text)) {
$pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!";
}
}
if (empty($line['entity_id'])) {
$line['entity_id'] = $entityId;
}
- if(!empty($line['membership_type_id'])) {
+ if (!empty($line['membership_type_id'])) {
$line['entity_table'] = 'civicrm_membership';
}
if (!empty($contributionDetails->id)) {
* @static
*/
public static function create(&$params) {
- if(empty($params['id']) && empty($params['name'])) {
+ if (empty($params['id']) && empty($params['name'])) {
$params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
}
$transaction = new CRM_Core_Transaction();
$extra = array();
if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) {
- foreach($fieldOptions as &$fieldOption) {
+ foreach ($fieldOptions as &$fieldOption) {
if ($fieldOption['name'] == 'other_amount') {
$fieldOption['label'] = $fieldOption['label'] . ' ' . $currencySymbol;
}
if (!is_array($params) || empty($params)) {
return;
}
- if(!$id && empty($params['name'])) {
+ if (!$id && empty($params['name'])) {
$params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
}
* @static
*/
public static function create(&$params) {
- if(empty($params['id']) && empty($params['name'])) {
+ if (empty($params['id']) && empty($params['name'])) {
$params['name'] = CRM_Utils_String::munge($params['title'], '_', 242);
}
if (!empty($params['extends']) && is_array($params['extends'])) {
* @return int
*/
public static function getOnlyPriceFieldID(array $priceSet) {
- if(count($priceSet['fields']) > 1) {
+ if (count($priceSet['fields']) > 1) {
throw new CRM_Core_Exception(ts('expected only one price field to be in priceset but multiple are present'));
}
return (int) implode('_', array_keys($priceSet['fields']));
*/
public static function getOnlyPriceFieldValueID(array $priceSet) {
$priceFieldID = self::getOnlyPriceFieldID($priceSet);
- if(count($priceSet['fields'][$priceFieldID]['options']) > 1) {
+ if (count($priceSet['fields'][$priceFieldID]['options']) > 1) {
throw new CRM_Core_Exception(ts('expected only one price field to be in priceset but multiple are present'));
}
return (int) implode('_', array_keys($priceSet['fields'][$priceFieldID]['options']));
* Name of entity - e.g event.
*/
public static function setPriceSets(&$params, $entity, $entityName) {
- if(empty($params['price_set_id']) || !is_array($params['price_set_id'])) {
+ if (empty($params['price_set_id']) || !is_array($params['price_set_id'])) {
return;
}
// CRM-14069 note that we may as well start by assuming more than one.
$pse->entity_table = 'civicrm_' . $entityName;
$pse->entity_id = $entity->id;
while ($pse->fetch()) {
- if(!in_array($pse->price_set_id, $params['price_set_id'])) {
+ if (!in_array($pse->price_set_id, $params['price_set_id'])) {
// note an even more aggressive form of this deletion currently happens in event form
// past price sets discounts are made inaccessible by this as the discount_id is set to NULL
// on the participant record
$priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id);
if ($priceSetId) {
$isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
- if($isQuickConfig) {
+ if ($isQuickConfig) {
$copyPriceSet = &CRM_Price_BAO_PriceSet::copy($priceSetId);
CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id);
}
// installments * intervals using the mysql date_add function, along
// with the interval unit (e.g. DATE_ADD(start_date, INTERVAL 12 * 1 MONTH)
$date_suffixes = array('relative', 'from', 'to');
- while(list(, $suffix) = each($date_suffixes)) {
+ while (list(, $suffix) = each($date_suffixes)) {
// Check to see if the user wants to search by calculated date.
- if(!empty($this->_params['calculated_end_date_' . $suffix])) {
+ if (!empty($this->_params['calculated_end_date_' . $suffix])) {
// The calculated date field is in use - spring into action
// Gather values
$relative = CRM_Utils_Array::value("calculated_end_date_relative", $this->_params);
WHERE report_id = %1";
$params = array(1 => array($reportUrl, 'String'));
$result = CRM_Core_DAO::executeQuery($sql, $params);
- while( $result->fetch()) {
+ while ($result->fetch()) {
$instanceDetails[$reportUrl][$result->id] = $result->title . " (ID: {$result->id})";
}
}
CRM_Core_Error::fatal(ts('Permission Denied'));
}
$content = json_decode($_REQUEST['ufData'], TRUE);
- foreach(array('ufGroup', 'ufFieldCollection') as $key) {
+ foreach (array('ufGroup', 'ufFieldCollection') as $key) {
if (!is_array($content[$key])) {
CRM_Core_Error::fatal("Missing JSON parameter, $key");
}
//CRM-11636
//here we do the financial type check and migration
$isDefaultsModified = self::_checkAndMigrateDefaultFinancialTypes();
- if($isDefaultsModified) {
+ if ($isDefaultsModified) {
$postUpgradeMessage .= '<br />' . ts('Please review all price set financial type assignments.');
}
list($context, $orgName) = self::createDomainContacts();
WHERE name IN ('Donation', 'Event Fee', 'Member Dues');
";
$daoFinancialIds = CRM_Core_DAO::executeQuery($sqlFinancialIds);
- while($daoFinancialIds->fetch()) {
+ while ($daoFinancialIds->fetch()) {
$financialIds[$daoFinancialIds->name] = $daoFinancialIds->id;
}
$sqlPriceSetUpdate = "
LEFT JOIN civicrm_email ce ON ce.id = clb.email_id ;
' ;
$dao = CRM_Core_DAO::executeQuery($query);
- while($dao->fetch()) {
+ while ($dao->fetch()) {
$query = "
SELECT cc.id FROM civicrm_contact cc
LEFT JOIN civicrm_email ce ON ce.contact_id = cc.id
";
$params = array(1 => array($dbUf['database'], 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE);
- foreach($tables as $columnName => $value){
+ foreach ($tables as $columnName => $value){
if ($value['tableName'] == 'civicrm_membership_type' || $value['tableName'] == 'civicrm_contribution_recur') {
$foreignKeyExists = CRM_Core_DAO::checkConstraintExists($value['tableName'], $value['fkey']);
$fKey = $value['fkey'];
'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
'civicrm_group' => 'FK_civicrm_group_saved_search_id',
);
- foreach($tables as $tableName => $fKey){
+ foreach ($tables as $tableName => $fKey){
$foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
if ($foreignKeyExists){
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
// If one of the options was specified, then try to match records.
// Matching logic differs for 'create' and 'replace' actions.
if ($keys !== NULL) {
- switch($apiRequest['action']) {
+ switch ($apiRequest['action']) {
case 'create':
if (empty($apiRequest['params']['id'])) {
$apiRequest['params'] = $this->match($apiRequest['entity'], $apiRequest['params'], $keys, $isMandatory);
));
// attempt to match each replacement item
- foreach($apiRequest['params']['values'] as $offset => $createParams) {
+ foreach ($apiRequest['params']['values'] as $offset => $createParams) {
$createParams = array_merge($baseParams, $createParams);
$createParams = $this->match($apiRequest['entity'], $createParams, $keys, $isMandatory);
$apiRequest['params']['values'][$offset] = $createParams;
foreach (func_get_args() as $n => $key) {
// Skip argument 0 ($items) by testing $n for truth.
if ($n && is_array($key)) {
- foreach($key as $k) {
+ foreach ($key as $k) {
unset($items[$k]);
}
}
$quarter = ceil($now['mon'] / 3);
$quarter = $quarter - $difference;
//CRM-14550 QA Fix
- if($quarter > 4) {
+ if ($quarter > 4) {
$now['year'] = $now['year'] + 1;
$quarter = 1;
}
continue;
}
- if($name == 'phone_ext'){
+ if ($name == 'phone_ext'){
$block = 'Phone';
}
);
// contact_type has a limited number of valid values
- if(empty($params['contact_type'])) {
+ if (empty($params['contact_type'])) {
return civicrm_api3_create_error("No Contact Type");
}
$fields = CRM_Utils_Array::value($params['contact_type'], $required);
if (array_key_exists('json', $requestParams) && $requestParams['json'][0] == "{") {
$params = json_decode($requestParams['json'], TRUE);
- if($params === NULL) {
+ if ($params === NULL) {
CRM_Utils_JSON::output(array('is_error' => 1, 'error_message', 'Unable to decode supplied JSON.'));
}
}
$tpl = 'CRM/'.$entity.'/Page/Inline/'.$tplfile.'.tpl';
$smarty = CRM_Core_Smarty::singleton( );
CRM_Utils_System::setTitle( "$entity::$tplfile inline $tpl" );
- if( !$smarty->template_exists($tpl) ){
+ if (!$smarty->template_exists($tpl) ){
header("Status: 404 Not Found");
die ("Can't find the requested template file templates/$tpl");
}
*/
public function setMySQLTimeZone(){
$timeZoneOffset = $this->getTimeZoneOffset();
- if($timeZoneOffset){
+ if ($timeZoneOffset){
$sql = "SET time_zone = '$timeZoneOffset'";
CRM_Core_DAO::executequery($sql);
}
* @return int $ufid - user ID of UF System
*/
public function getBestUFID($user = NULL) {
- if($user) {
+ if ($user) {
return $this->getUserIDFromUserObject($user);
}
return $this->getLoggedInUfID();
* @return string $uniqueIdentifier - unique identifier from the UF System
*/
public function getBestUFUniqueIdentifier($user = NULL) {
- if($user) {
+ if ($user) {
return $this->getUniqueIdentifierFromUserObject($user);
}
return $this->getLoggedInUniqueIdentifier();
$form_state['input']['pass'] = array('pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']);
}
- if(!empty($params['notify'])){
+ if (!empty($params['notify'])){
$form_state['input']['notify'] = $params['notify'];
}
);
}
if (strtolower($dbEmail) == strtolower($email)) {
- if(empty($email)) {
+ if (empty($email)) {
$errors[$emailName] = ts('You cannot create an email account for a contact with no email',
array(1 => $email)
);
public function appendCoreDirectoryToResourceBase($url) {
global $civicrm_root;
$lastDirectory = basename($civicrm_root);
- if($lastDirectory != 'civicrm') {
+ if ($lastDirectory != 'civicrm') {
return $url .= $lastDirectory . '/';
}
return $url;
define('JVERSION', $jversion->getShortVersion());
}
- if( version_compare(JVERSION, '3.0', 'lt') ) {
+ if (version_compare(JVERSION, '3.0', 'lt') ) {
require $joomlaBase . '/libraries/joomla/environment/uri.php';
require $joomlaBase . '/libraries/joomla/application/component/helper.php';
}
$ufName = CRM_Utils_Type::escape($ufName, 'String');
$values = array('ID' => $ufID, 'user_email' => $ufName);
- if( $ufID ) {
+ if ($ufID ) {
wp_update_user( $values );
}
}
* @return null
*/
public function log($level, $message, array $context = array()) {
- if(!isset($context['hostname'])) {
+ if (!isset($context['hostname'])) {
$context['hostname'] = CRM_Utils_System::ipAddress();
}
$rec = new CRM_Core_DAO_SystemLog();
$greetingTokens = $remainingTokens['contact'];
reset($greetingTokens);
$greetingsReturnProperties = array();
- while(list($key) = each($greetingTokens)) {
+ while (list($key) = each($greetingTokens)) {
$props = array_flip(CRM_Utils_Array::value($key, $greetingTokens));
$props = array_fill_keys(array_keys($props), 1);
$greetingsReturnProperties = $greetingsReturnProperties + $props;
* @return \Ambigous|mixed|string|\unknown
*/
public static function replaceMultipleContributionTokens($separator, $str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) {
- if(empty($knownTokens['contribution'])) {
+ if (empty($knownTokens['contribution'])) {
return $str;
}
- if(in_array('receive_date', $knownTokens['contribution'])) {
+ if (in_array('receive_date', $knownTokens['contribution'])) {
$formattedDates = array();
$dates = explode($separator, $contribution['receive_date']);
foreach ($dates as $date) {
function civicrm_api3($entity, $action, $params = array()) {
$params['version'] = 3;
$result = civicrm_api($entity, $action, $params);
- if(is_array($result) && !empty($result['is_error'])){
+ if (is_array($result) && !empty($result['is_error'])){
throw new CiviCRM_API3_Exception($result['error_message'], CRM_Utils_Array::value('error_code', $result, 'undefined'), $result);
}
return $result;
}
$getFieldsParams = array('action' => $apiRequest['action']);
$entity = $apiRequest['entity'];
- if($entity == 'profile' && array_key_exists('profile_id', $apiRequest['params'])) {
+ if ($entity == 'profile' && array_key_exists('profile_id', $apiRequest['params'])) {
$getFieldsParams['profile_id'] = $apiRequest['params']['profile_id'];
}
$fields = civicrm_api3($entity, 'getfields', $getFieldsParams);
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
}
$options = _civicrm_api3_get_options_from_params($params, FALSE, 'activity', 'get');
- if($options['is_count']) {
+ if ($options['is_count']) {
return civicrm_api3_create_success($activities, $params, 'activity', 'get');
}
}
else{
$values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
- if(!empty($values)){
+ if (!empty($values)){
return civicrm_api3_create_success($values, $params, 'constant');
}
}
}
// phone_numeric should be phone
$searchField = str_replace('_numeric', '', $field_name);
- if(!in_array($searchField, $list)) {
+ if (!in_array($searchField, $list)) {
$list[] = $searchField;
}
}
}
// phone_numeric should be phone
$searchField = str_replace('_numeric', '', $field_name);
- if(!in_array($searchField, $list)) {
+ if (!in_array($searchField, $list)) {
$list[] = $searchField;
}
$request['description_field'] = $list;
}
}
$address = array();
- foreach($addressFields as $item) {
+ foreach ($addressFields as $item) {
if (!empty($row[$item])) {
$address[] = $row[$item];
}
*/
function _civicrm_api3_contribution_create_legacy_support_45(&$params){
//legacy soft credit handling - recommended approach is chaining
- if(!empty($params['soft_credit_to'])){
+ if (!empty($params['soft_credit_to'])){
$params['soft_credit'][] = array(
'contact_id' => $params['soft_credit_to'],
'amount' => $params['total_amount'],
'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type")
);
}
- if(!empty($params['honor_contact_id'])){
+ if (!empty($params['honor_contact_id'])){
$params['soft_credit'][] = array(
'contact_id' => $params['honor_contact_id'],
'amount' => $params['total_amount'],
$contribution_details = $query->store($dao);
$softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE);
$contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution);
- if(isset($contribution[$dao->contribution_id]['financial_type_id'])){
+ if (isset($contribution[$dao->contribution_id]['financial_type_id'])){
$contribution[$dao->contribution_id]['financial_type_id'] = $contribution[$dao->contribution_id]['financial_type_id'];
}
// format soft credit for backward compatibility
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['id'];
$contribution->find(TRUE);
- if(!$contribution->id == $params['id']){
+ if (!$contribution->id == $params['id']){
throw new API_Exception('A valid contribution ID is required', 'invalid_data');
}
try {
- if(!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)){
+ if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)){
throw new API_Exception('failed to load related objects');
}
elseif ($contribution->contribution_status_id == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
$input['is_test'] = $contribution->is_test;
$input['trxn_id'] = !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id;
$input['amount'] = $contribution->total_amount;
- if(isset($params['is_email_receipt'])){
+ if (isset($params['is_email_receipt'])){
$input['is_email_receipt'] = $params['is_email_receipt'];
}
// @todo required for base ipn but problematic as api layer handles this
$domains = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'domain');
foreach ($domains as $domain) {
- if(!empty($domain['contact_id'])){
+ if (!empty($domain['contact_id'])){
$values = array();
$locparams = array(
'contact_id' => $domain['contact_id']
*/
function civicrm_api3_entity_tag_get($params) {
- if(empty($params['entity_id'])) {
+ if (empty($params['entity_id'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
else{
* across schema changes.
*/
function _civicrm_api3_event_create_legacy_support_42(&$params){
- if(!empty($params['payment_processor_id'])){
+ if (!empty($params['payment_processor_id'])){
$params['payment_processor'] = CRM_Core_DAO::VALUE_SEPARATOR . $params['payment_processor_id'] . CRM_Core_DAO::VALUE_SEPARATOR;
}
}
}
_civicrm_api3_event_get_legacy_support_42($event, $eventDAO->id);
_civicrm_api3_custom_data_get($event[$eventDAO->id], 'Event', $eventDAO->id, NULL, $eventDAO->event_type_id);
- if(!empty($options['return'])) {
+ if (!empty($options['return'])) {
$event[$eventDAO->id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventDAO->id);
}
}
* across schema changes.
*/
function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id){
- if(!empty($event[$event_id]['payment_processor'])){
+ if (!empty($event[$event_id]['payment_processor'])){
$processors = explode(CRM_Core_DAO::VALUE_SEPARATOR, $event[$event_id]['payment_processor']);
- if(count($processors) == 3 ){
+ if (count($processors) == 3 ){
$event[$event_id]['payment_processor_id'] = $processors[1];
}
}
$results = array();
// we will also clear pseudoconstants here - should potentially be moved to relevant BAO classes
CRM_Core_PseudoConstant::flush();
- if(!empty($apiRequest['params']['fieldname'])){
+ if (!empty($apiRequest['params']['fieldname'])){
CRM_Utils_PseudoConstant::flushConstant($apiRequest['params']['fieldname']);
}
- if(!empty($apiRequest['params']['option_group_id'])){
+ if (!empty($apiRequest['params']['option_group_id'])){
$optionGroupName = civicrm_api('option_group', 'getvalue', array('version' => 3, 'id' => $apiRequest['params']['option_group_id'], 'return' => 'name') );
- if(is_string($optionGroupName)){
+ if (is_string($optionGroupName)){
CRM_Utils_PseudoConstant::flushConstant(_civicrm_api_get_camel_name($optionGroupName));
}
}
$metadata = _civicrm_api_get_fields($apiRequest['entity'], $unique, $apiRequest['params']);
if (empty($metadata['id'])){
// if id is not set we will set it eg. 'id' from 'case_id', case_id will be an alias
- if(!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) {
+ if (!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) {
$metadata['id'] = $metadata[$lcase_entity . '_id'];
unset($metadata[$lcase_entity . '_id']);
$metadata['id']['api.aliases'] = array($lcase_entity . '_id');
function civicrm_api3_generic_getcount($apiRequest) {
$apiRequest['params']['options']['is_count'] = TRUE;
$result = civicrm_api($apiRequest['entity'], 'get', $apiRequest['params']);
- if(is_numeric (CRM_Utils_Array::value('values', $result))) {
+ if (is_numeric (CRM_Utils_Array::value('values', $result))) {
return (int) $result['values'];
}
- if(!isset($result['count'])) {
+ if (!isset($result['count'])) {
throw new API_Exception(ts('Unexpected result from getcount') . print_r($result, TRUE));
}
return $result['count'];
// @fixme
// tests show that contribution works better with create
// this is horrible but to make it work we'll just handle it separately
- if(strtolower($apiRequest['entity']) == 'contribution'){
+ if (strtolower($apiRequest['entity']) == 'contribution'){
return civicrm_api($apiRequest['entity'], 'create', $apiRequest['params']);
}
$seek = array($key_id => $apiRequest['params'][$key_id], 'version' => $apiRequest['version']);
*/
function civicrm_api3_group_get($params) {
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'group', 'get');
- if(empty($options['return']) || !in_array('member_count', $options['return'])) {
+ if (empty($options['return']) || !in_array('member_count', $options['return'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group');
}
* @throws Exception
*/
function _civicrm_api3_mailing_contact_getresults($params, $count){
- if(empty($params['type'])){
+ if (empty($params['type'])){
//ie. because the api is an anomoly & passing in id is not valid
throw new Exception('This api call does not accept api as a parameter');
}
$membershipValues = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Membership');
$return = $options['return'];
- if(empty($membershipValues) ||
+ if (empty($membershipValues) ||
(!empty($return)
&& !array_key_exists('related_contact_id', $return)
&& !array_key_exists('relationship_name', $return)
throw new API_Exception('membershipParams do not contain membership_id');
}
- if(empty($membershipParams['id'])) {
+ if (empty($membershipParams['id'])) {
//for consistency lets make sure id is set as this will get passed to hooks downstream
$membershipParams['id'] = $membershipID;
}
function civicrm_api3_option_value_delete($params) {
// we will get the option group id before deleting so we can flush pseudoconstants
$optionGroupID = civicrm_api('option_value', 'getvalue', array('version' => 3, 'id' => $params['id'], 'return' => 'option_group_id'));
- if(CRM_Core_BAO_OptionValue::del((int) $params['id'])){
+ if (CRM_Core_BAO_OptionValue::del((int) $params['id'])){
civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $optionGroupID));
return civicrm_api3_create_success();
}
$participantBAO = CRM_Event_BAO_Participant::create($params);
- if(empty($params['price_set_id']) && empty($params['id']) && !empty($params['fee_level'])){
+ if (empty($params['price_set_id']) && empty($params['id']) && !empty($params['fee_level'])){
_civicrm_api3_participant_createlineitem($params, $participantBAO);
}
_civicrm_api3_object_to_array($participantBAO, $participant[$participantBAO->id]);
$priceFieldValueDetails = CRM_Utils_Array::explodePadded(
$params["fee_level"]);
- foreach($priceFieldValueDetails as $detail) {
+ foreach ($priceFieldValueDetails as $detail) {
if (preg_match('/- ([0-9]+)$/', $detail, $matches)) {
// it is possible that a price field value is payd for multiple times.
// (FIXME: if the price field value ends in minus followed by whitespace
}
$dao = CRM_Pledge_BAO_PledgePayment::add($paymentParams);
- if(empty($dao->pledge_id)){
+ if (empty($dao->pledge_id)){
$dao->find(TRUE);
}
_civicrm_api3_object_to_array($dao, $result[$dao->id]);
*/
function civicrm_api3_price_field_value_create($params) {
$ids = array();
- if(!empty($params['id'])){
+ if (!empty($params['id'])){
$ids['id'] = $params['id'];
}
function civicrm_api3_price_set_get($params) {
// hack to make getcount work. - not sure the best approach here
// as creating an alternate getcount function also feels a bit hacky
- if(isset($params['options']) && isset($params['options']['is_count'])) {
+ if (isset($params['options']) && isset($params['options']['is_count'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
$result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
*/
function civicrm_api3_profile_get($params) {
$nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE;
- if(!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', array('contact_id' => $params['contact_id'], 'check_permissions' => 1))) {
+ if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', array('contact_id' => $params['contact_id'], 'check_permissions' => 1))) {
throw new API_Exception('permission denied');
}
$profiles = (array) $params['profile_id'];
$values[$profileID] = _civicrm_api3_profile_getbillingpseudoprofile($params);
continue;
}
- if(!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_active')) {
+ if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_active')) {
throw new API_Exception('Invalid value for profile_id : ' . $profileID);
}
$values[$profileID] = array_fill_keys(array_keys($profileFields), '');
}
}
- if($nonStandardLegacyBehaviour) {
+ if ($nonStandardLegacyBehaviour) {
$result = civicrm_api3_create_success();
$result['values'] = $values[$profileID];
return $result;
$locationEntities = array('email', 'address', 'phone', 'website', 'im');
$entity = strtolower(CRM_Utils_Array::value('entity', $field));
- if($entity && !in_array($entity, array_merge($contactEntities, $locationEntities))) {
+ if ($entity && !in_array($entity, array_merge($contactEntities, $locationEntities))) {
$contactParams['api.' . $entity . '.create'][$fieldName] = $value;
//@todo we are not currently declaring this option
- if(isset($params['batch_id']) && strtolower($entity) == 'contribution') {
+ if (isset($params['batch_id']) && strtolower($entity) == 'contribution') {
$contactParams['api.' . $entity . '.create']['batch_id'] = $params['batch_id'];
}
- if(isset($params[$entity . '_id'])) {
+ if (isset($params[$entity . '_id'])) {
//todo possibly declare $entity_id in getfields ?
$contactParams['api.' . $entity . '.create']['id'] = $params[$entity . '_id'];
}
$contactParams[_civicrm_api3_profile_translate_fieldnames_for_bao($fieldName)] = $value;
}
}
- if(isset($contactParams['api.contribution.create']) && isset($contactParams['api.membership.create'])) {
+ if (isset($contactParams['api.contribution.create']) && isset($contactParams['api.membership.create'])) {
$contactParams['api.membership_payment.create'] = array(
'contribution_id' => '$value.api.contribution.create.id',
'membership_id' => '$value.api.membership.create.id'
);
}
- if(isset($contactParams['api.contribution.create']) && isset($contactParams['api.participant.create'])) {
+ if (isset($contactParams['api.contribution.create']) && isset($contactParams['api.participant.create'])) {
$contactParams['api.participant_payment.create'] = array(
'contribution_id' => '$value.api.contribution.create.id',
'participant_id' => '$value.api.participant.create.id'
* @param array $apirequest
*/
function _civicrm_api3_profile_submit_spec(&$params, $apirequest) {
- if(isset($apirequest['params']['profile_id'])) {
+ if (isset($apirequest['params']['profile_id'])) {
// we will return what is required for this profile
// note the problem with simply over-riding getfields & then calling generic if needbe is we don't have the
// api request array to pass to it.
$locations = civicrm_api3('address', 'getoptions', array('field' => 'location_type_id'));
$locationTypeID = array_search('Billing', $locations['values']);
- if(empty($params['contact_id'])) {
+ if (empty($params['contact_id'])) {
$config = CRM_Core_Config::singleton();
$blanks = array(
'billing_first_name' => '',
'billing_last_name' => $result['last_name'],
);
- if(!empty($result['api.address.get.1']['count'])) {
+ if (!empty($result['api.address.get.1']['count'])) {
foreach ($addressFields as $fieldname) {
$values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.1']['values'][0][$fieldname]) ? $result['api.address.get.1']['values'][0][$fieldname] : '';
}
}
}
- if(!empty($result['api.email.get.1']['count'])) {
+ if (!empty($result['api.email.get.1']['count'])) {
$values['billing-email'. '-' . $locationTypeID] = $result['api.email.get.1']['values'][0]['email'];
}
elseif(!empty($result['api.email.get.2']['count'])) {
function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour = 1, $is_flush) {
static $profileFields = array();
- if($is_flush) {
+ if ($is_flush) {
$profileFields = array();
- if(empty($profileID)) {
+ if (empty($profileID)) {
return;
}
}
- if(isset($profileFields[$profileID])) {
+ if (isset($profileFields[$profileID])) {
return $profileFields[$profileID];
}
$fields = civicrm_api3('uf_field', 'get', array('uf_group_id' => $profileID));
$entities = array();
foreach ($fields['values'] as $field) {
- if(!$field['is_active']) {
+ if (!$field['is_active']) {
continue;
}
list($entity, $fieldName) = _civicrm_api3_map_profile_fields_to_entity($field);
$aliasArray = array();
- if(strtolower($fieldName) != $fieldName) {
+ if (strtolower($fieldName) != $fieldName) {
$aliasArray['api.aliases'] = array($fieldName);
$fieldName = strtolower($fieldName);
}
), $aliasArray);
$ufFieldTaleFieldName = $field['field_name'];
- if(isset($entity[$ufFieldTaleFieldName]['name'])) {
+ if (isset($entity[$ufFieldTaleFieldName]['name'])) {
// in the case where we are dealing with an alias we map back to a name
// this will be tested by 'membership_type_id' field
$ufFieldTaleFieldName = $entity[$ufFieldTaleFieldName]['name'];
'soft_credit_type' => 'soft_credit_type_id',
);
- if(array_key_exists($ufFieldTaleFieldName, $hardCodedEntityFields)) {
+ if (array_key_exists($ufFieldTaleFieldName, $hardCodedEntityFields)) {
$ufFieldTaleFieldName = $hardCodedEntityFields[$ufFieldTaleFieldName];
}
$entityGetFieldsResult = _civicrm_api3_profile_appendaliases($result['values'], $entity);
foreach ($entityFields as $entityfield => $realName) {
$fieldName = strtolower($entityfield);
- if(!strstr($fieldName, '-')) {
- if(strtolower($realName) != $fieldName) {
+ if (!strstr($fieldName, '-')) {
+ if (strtolower($realName) != $fieldName) {
// we want to keep the '-' pattern for locations but otherwise
// we are going to make the api-standard field the main / preferred name but support the db name
// in future naming the fields in the DB to reflect the way the rest of the api / BAO / metadata works would
// reduce code
$fieldName = strtolower($realName);
}
- if(isset($entityGetFieldsResult[$realName]['uniqueName'])) {
+ if (isset($entityGetFieldsResult[$realName]['uniqueName'])) {
// we won't alias the field name on here are we are using uniqueNames for the possibility of needing to differentiate
// which entity 'status_id' belongs to
$fieldName = $entityGetFieldsResult[$realName]['uniqueName'];
}
else{
- if(isset($entityGetFieldsResult[$realName]['name'])) {
+ if (isset($entityGetFieldsResult[$realName]['name'])) {
// this will sort out membership_type_id vs membership_type
$fieldName = $entityGetFieldsResult[$realName]['name'];
}
}
}
$profileFields[$profileID][$fieldName] = array_merge($entityGetFieldsResult[$realName], $profileFields[$profileID][$entityfield]);
- if(!isset($profileFields[$profileID][$fieldName]['api.aliases'])) {
+ if (!isset($profileFields[$profileID][$fieldName]['api.aliases'])) {
$profileFields[$profileID][$fieldName]['api.aliases'] = array();
}
- if($optionsBehaviour && !empty($entityGetFieldsResult[$realName]['pseudoconstant'])) {
- if($optionsBehaviour > 1 || !in_array($realName, array('state_province_id', 'county_id', 'country_id'))) {
+ if ($optionsBehaviour && !empty($entityGetFieldsResult[$realName]['pseudoconstant'])) {
+ if ($optionsBehaviour > 1 || !in_array($realName, array('state_province_id', 'county_id', 'country_id'))) {
$options = civicrm_api3($entity, 'getoptions', array('field' => $realName));
$profileFields[$profileID][$fieldName]['options'] = $options['values'];
}
}
- if($entityfield != $fieldName) {
- if(isset($profileFields[$profileID][$entityfield])) {
+ if ($entityfield != $fieldName) {
+ if (isset($profileFields[$profileID][$entityfield])) {
unset($profileFields[$profileID][$entityfield]);
}
- if(!in_array($entityfield, $profileFields[$profileID][$fieldName]['api.aliases'])) {
+ if (!in_array($entityfield, $profileFields[$profileID][$fieldName]['api.aliases'])) {
// we will make the mixed case version (e.g. of 'Primary') an alias
$profileFields[$profileID][$fieldName]['api.aliases'][] = $entityfield;
}
}
/**
* putting this on hold -this would cause the api to set the default - but could have unexpected behaviour
- if(isset($result['values'][$realName]['default_value'])) {
+ if (isset($result['values'][$realName]['default_value'])) {
//this would be the case for a custom field with a configured default
$profileFields[$profileID][$entityfield]['api.default'] = $result['values'][$realName]['default_value'];
}
function _civicrm_api3_map_profile_fields_to_entity(&$field) {
$entity = $field['field_type'];
$contactTypes = civicrm_api3('contact', 'getoptions', array('field' => 'contact_type'));
- if(in_array($entity, $contactTypes['values'])) {
+ if (in_array($entity, $contactTypes['values'])) {
$entity = 'contact';
}
$entity = _civicrm_api_get_entity_name_from_camel($entity);
$locationFields = array('email' => 'email');
$fieldName = $field['field_name'];
- if(!empty($field['location_type_id'])) {
- if($fieldName == 'email') {
+ if (!empty($field['location_type_id'])) {
+ if ($fieldName == 'email') {
$entity = 'email';
}
else{
$fieldName .= '-Primary';
$entity = 'email';
}
- if(!empty($field['phone_type_id'])) {
+ if (!empty($field['phone_type_id'])) {
$fieldName .= '-' . $field['location_type_id'];
$entity = 'phone';
}
'group' => 'group_contact',
'tag' => 'entity_tag',
);
- if(array_key_exists($fieldName, $hardCodedEntityMappings)) {
+ if (array_key_exists($fieldName, $hardCodedEntityMappings)) {
$entity = $hardCodedEntityMappings[$fieldName];
}
return array($entity, $fieldName);
* @throws CiviCRM_API3_Exception
*/
function _civicrm_api3_profile_getProfileID($profileID) {
- if(!empty($profileID) && strtolower($profileID) != 'billing' && !is_numeric($profileID)) {
+ if (!empty($profileID) && strtolower($profileID) != 'billing' && !is_numeric($profileID)) {
$profileID = civicrm_api3('uf_group', 'getvalue', array('return' => 'id', 'name' => $profileID));
}
return $profileID;
*/
function _civicrm_api3_profile_appendaliases($values, $entity) {
foreach ($values as $field => $spec) {
- if(!empty($spec['api.aliases'])) {
+ if (!empty($spec['api.aliases'])) {
foreach ($spec['api.aliases'] as $alias) {
$values[$alias] = $spec;
}
}
- if(!empty($spec['uniqueName'])) {
+ if (!empty($spec['uniqueName'])) {
$values[$spec['uniqueName']] = $spec;
}
}
//special case on membership & contribution - can't see how to handle in a generic way
- if(in_array($entity, array('membership', 'contribution'))) {
+ if (in_array($entity, array('membership', 'contribution'))) {
$values['send_receipt'] = array('title' => 'Send Receipt', 'type' => (int) 16);
}
return $values;
$options = _civicrm_api3_get_options_from_params($params);
if (empty($params['contact_id'])) {
- if(!empty($params['membership_type_id']) && empty($params['relationship_type_id'])) {
+ if (!empty($params['membership_type_id']) && empty($params['relationship_type_id'])) {
CRM_Contact_BAO_Relationship::membershipTypeToRelationshipTypes($params);
}
$relationships = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Relationship');
);
}
//perhaps we should add a 'getcount' but at this stage lets just handle getcount output
- if($options['is_count']) {
+ if ($options['is_count']) {
return array('count' => $relationships);
}
foreach ($relationships as $relationshipId => $values) {
* @throws CiviCRM_API3_Exception
*/
function _civicrm_api3_report_template_getrows($params) {
- if(empty($params['report_id'])) {
+ if (empty($params['report_id'])) {
$params['report_id'] = civicrm_api3('report_instance', 'getvalue', array('id' => $params['instance_id'], 'return' => 'report_id'));
}
);
$reportInstance = new $class();
- if(!empty($params['instance_id'])) {
+ if (!empty($params['instance_id'])) {
$reportInstance->setID($params['instance_id']);
}
$reportInstance->setParams($params);
$rows = $metadata = $requiredMetadata = array();
$reportInstance->buildRows($sql, $rows);
$requiredMetadata = array();
- if(isset($params['options']) && !empty($params['options']['metadata'])) {
+ if (isset($params['options']) && !empty($params['options']['metadata'])) {
$requiredMetadata = $params['options']['metadata'];
- if(in_array('title', $requiredMetadata)) {
+ if (in_array('title', $requiredMetadata)) {
$metadata['metadata']['title'] = $reportInstance->getTitle();
}
- if(in_array('labels', $requiredMetadata)) {
+ if (in_array('labels', $requiredMetadata)) {
foreach ($reportInstance->_columnHeaders as $key => $header) {
//would be better just to expect reports to provide titles but reports are not consistent so we anticipate empty
//NB I think these are already translated
*/
function civicrm_api3_setting_getfields($params) {
- if(!empty($params['action']) && strtolower($params['action']) == 'getvalue'){
+ if (!empty($params['action']) && strtolower($params['action']) == 'getvalue'){
$result = array(
'name' => array(
'title' => 'name of setting field',
);
return civicrm_api3_create_success($result, $params, 'setting', 'getfields');
}
- if(!empty($params['name'])){
+ if (!empty($params['name'])){
//am of two minds about special handling for 'name' as opposed to other filters - but is does make most common
//usage really easy
$params['filters']['name'] = $params['name'];
$defaults[$domainID] = array();
$noDefaults = array();
foreach ($settings['values'] as $setting => $spec){
- if(array_key_exists('default', $spec) && !is_null($spec['default'])){
+ if (array_key_exists('default', $spec) && !is_null($spec['default'])){
$defaults[$domainID][$setting] = $spec['default'];
}
else{
$noDefaults[$setting] = 1;
}
}
- if(!empty($params['debug'])){
+ if (!empty($params['debug'])){
// we are only tracking 'noDefaults' to help us check the xml
print_r($noDefaults);
}
$result = array();
foreach ($domains as $domainID){
$valuesToRevert = array_intersect_key($defaults['values'][$domainID], $fields);
- if(!empty($valuesToRevert)){
+ if (!empty($valuesToRevert)){
$valuesToRevert['version'] = $params['version'];
$valuesToRevert['domain_id'] = $domainID;
// note that I haven't looked at how the result would appear with multiple domains in play
);
$existing = civicrm_api3('setting', 'get', $apiArray);
$valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]);
- if(!empty($valuesToFill)){
+ if (!empty($valuesToFill)){
$result = array_merge($result, civicrm_api('setting', 'create', $valuesToFill + $apiArray));
}
}
*/
function civicrm_api3_setting_getvalue($params) {
$config = CRM_Core_Config::singleton();
- if(isset($config->$params['name'])){
+ if (isset($config->$params['name'])){
return $config->$params['name'];
}
return CRM_Core_BAO_Setting::getItem(
* we did talk about id being a pseudonym for domain_id in this api so applying it here
*/
function _civicrm_api3_setting_getDomainArray(&$params){
- if(empty($params['domain_id']) && isset($params['id'])){
+ if (empty($params['domain_id']) && isset($params['id'])){
$params['domain_id'] = $params['id'];
}
- if($params['domain_id'] == 'current_domain'){
+ if ($params['domain_id'] == 'current_domain'){
$params['domain_id'] = CRM_Core_Config::domainID();
}
- if($params['domain_id'] == 'all'){
+ if ($params['domain_id'] == 'all'){
$domainAPIResult = civicrm_api('domain', 'get', array('version' => 3, 'return' => 'id'));
if (isset($domainAPIResult['values'])) {
$params['domain_id'] = array_keys($domainAPIResult['values']);
throw new Exception('All domains not retrieved - problem with Domain Get api call ' . $domainAPIResult['error_message']);
}
}
- if(is_array($params['domain_id'])){
+ if (is_array($params['domain_id'])){
$domains = $params['domain_id'];
}
else{
$log = new CRM_Utils_SystemLogger();
// this part means fields with separate db storage are accepted as params which kind of seems more intuitive to me
// because I felt like not doing this required a bunch of explanation in the spec function - but perhaps other won't see it as helpful?
- if(!isset($params['context'])) {
+ if (!isset($params['context'])) {
$params['context'] = array();
}
$specialFields = array('contact_id', 'hostname');
- foreach($specialFields as $specialField) {
- if(isset($params[$specialField]) && !isset($params['context'])) {
+ foreach ($specialFields as $specialField) {
+ if (isset($params[$specialField]) && !isset($params['context'])) {
$params['context'][$specialField] = $params[$specialField];
}
}
$data['error_message'] = $msg;
// we will show sql to privileged user only (not sure of a specific
// security hole here but seems sensible - perhaps should apply to the trace as well?)
- if(isset($data['sql']) && CRM_Core_Permission::check('Administer CiviCRM')) {
+ if (isset($data['sql']) && CRM_Core_Permission::check('Administer CiviCRM')) {
$data['debug_information'] = $data['sql']; // Isn't this redundant?
}
else {
if (empty($item['id']) && !empty($item[$entity . "_id"])) {
$values[$key]['id'] = $item[$entity . "_id"];
}
- if(!empty($item['financial_type_id'])){
+ if (!empty($item['financial_type_id'])){
//4.3 legacy handling
$values[$key]['contribution_type_id'] = $item['financial_type_id'];
}
- if(!empty($item['next_sched_contribution_date'])){
+ if (!empty($item['next_sched_contribution_date'])){
// 4.4 legacy handling
$values[$key]['next_sched_contribution'] = $item['next_sched_contribution_date'];
}
else {
$result['values'] = $values;
}
- if(!empty($params['options']['metadata'])) {
+ if (!empty($params['options']['metadata'])) {
// we've made metadata an array but only supporting 'fields' atm
- if(in_array('fields', (array) $params['options']['metadata']) && $action !== 'getfields') {
+ if (in_array('fields', (array) $params['options']['metadata']) && $action !== 'getfields') {
$fields = civicrm_api3($entity, 'getfields', array('action' => substr($action, 0, 3) == 'get' ? 'get' : 'create'));
$result['metadata']['fields'] = $fields['values'];
}
}
// Really weird apis can declare their own DAO name. Not sure if this is a good idea...
- if(file_exists("api/v3/$name.php")) {
+ if (file_exists("api/v3/$name.php")) {
include_once "api/v3/$name.php";
}
_civicrm_api3_separate_values($value);
}
elseif (is_string($value)) {
- if($key == 'case_type_id'){// this is to honor the way case API was originally written
+ if ($key == 'case_type_id'){// this is to honor the way case API was originally written
$value = trim(str_replace($sp, ',', $value), ',');
}
elseif (strpos($value, $sp) !== FALSE) {
CRM_Utils_Array::value('return', $options, array()),
CRM_Utils_Array::value('return', $additional_options, array())
);
- if(empty($returnProperties)){
+ if (empty($returnProperties)){
$returnProperties = NULL;
}
- if(!empty($params['check_permissions'])){
+ if (!empty($params['check_permissions'])){
// we will filter query object against getfields
$fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'get'));
// we need to add this in as earlier in this function 'id' was unset in favour of $entity_id
$fields['values'][$entity . '_id'] = array();
$varsToFilter = array('returnProperties', 'inputParams');
foreach ($varsToFilter as $varToFilter){
- if(!is_array($$varToFilter)){
+ if (!is_array($$varToFilter)){
continue;
}
//I was going to throw an exception rather than silently filter out - but
$limit = CRM_Utils_Array::value('limit', $options, NULL);
$smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
- if($getCount){
+ if ($getCount){
$limit = NULL;
$returnProperties = NULL;
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
foreach ($newParams as &$newParam) {
- if($newParam[1] == '=' && is_array($newParam[2])) {
+ if ($newParam[1] == '=' && is_array($newParam[2])) {
// we may be looking at an attempt to use the 'IN' style syntax
// @todo at time of writing only 'IN' & 'NOT IN' are supported for the array style syntax
$sqlFilter = CRM_Core_DAO::createSqlFilter($newParam[0], $params[$newParam[0]], 'String', NULL, TRUE);
- if($sqlFilter) {
+ if ($sqlFilter) {
$newParam[1] = key($newParam[2]);
$newParam[2] = $sqlFilter;
}
if (!empty($sort)) {
$sql .= " ORDER BY $sort ";
}
- if(!empty($rowCount)) {
+ if (!empty($rowCount)) {
$sql .= " LIMIT $offset, $rowCount ";
}
$dao = CRM_Core_DAO::executeQuery($sql);
//get the actual fieldname from db
$fieldName = $allfields[$field]['name'];
$where = CRM_Core_DAO::createSqlFilter($fieldName, $params[$field], 'String');
- if(!empty($where)) {
+ if (!empty($where)) {
$dao->whereAdd($where);
}
}
$fieldName = substr($filterField, 0, -4);
$dao->whereAdd("($fieldName >= $filterValue )");
}
- if($filterField == 'is_current' && $filterValue == 1){
+ if ($filterField == 'is_current' && $filterValue == 1){
$todayStart = date('Ymd000000', strtotime('now'));
$todayEnd = date('Ymd235959', strtotime('now'));
$dao->whereAdd("(start_date <= '$todayStart' OR start_date IS NULL) AND (end_date >= '$todayEnd' OR end_date IS NULL)");
- if(property_exists($dao, 'is_active')){
+ if (property_exists($dao, 'is_active')){
$dao->whereAdd('is_active = 1');
}
}
function _civicrm_api3_apply_options_to_dao(&$params, &$dao, $entity) {
$options = _civicrm_api3_get_options_from_params($params, FALSE, $entity);
- if(!$options['is_count']) {
- if(!empty($options['limit'])) {
+ if (!$options['is_count']) {
+ if (!empty($options['limit'])) {
$dao->limit((int) $options['offset'], (int) $options['limit']);
}
if (!empty($options['sort'])) {
*/
function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "", $autoFind = TRUE) {
$result = array();
- if(isset($params['options']) && !empty($params['options']['is_count'])) {
+ if (isset($params['options']) && !empty($params['options']['is_count'])) {
return $dao->count();
}
if (empty($dao)) {
return array();
}
- if(isset($dao->count)) {
+ if (isset($dao->count)) {
return $dao->count;
}
}
$result[$dao->id] = $tmp;
- if(_civicrm_api3_custom_fields_are_required($entity, $params)) {
+ if (_civicrm_api3_custom_fields_are_required($entity, $params)) {
_civicrm_api3_custom_data_get($result[$dao->id], $entity, $dao->id);
}
}
$options = _civicrm_api3_get_options_from_params($params);
//we check for possibility of 'custom' => 1 as well as specific custom fields
$returnString = implode('', $options['return']) . implode('', array_keys($options['return']));
- if(stristr($returnString, 'custom')) {
+ if (stristr($returnString, 'custom')) {
return TRUE;
}
}
$values['custom'] = array();
$checkCheckBoxField = FALSE;
$entity = $extends;
- if(in_array($extends, array('Household', 'Individual', 'Organization'))) {
+ if (in_array($extends, array('Household', 'Individual', 'Organization'))) {
$entity = 'Contact';
}
$fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create'));
- if(!$fields['is_error']) {
+ if (!$fields['is_error']) {
// not sure if fields could be error - maybe change to using civicrm_api3 wrapper later - this is conservative
$fields = $fields['values'];
$checkCheckBoxField = TRUE;
$nonGenericEntities = array('Contact', 'Individual', 'Household', 'Organization');
$customFieldEntities = array_diff_key(CRM_Core_BAO_CustomQuery::$extendsMap, array_fill_keys($nonGenericEntities, 1));
- if(!array_key_exists($entity, $customFieldEntities)) {
+ if (!array_key_exists($entity, $customFieldEntities)) {
return;
}
$values = array();
}
// Check our field length
- if(is_string($params[$fieldName]) && !empty($fieldInfo['maxlength']) && strlen($params[$fieldName]) > $fieldInfo['maxlength']
+ if (is_string($params[$fieldName]) && !empty($fieldInfo['maxlength']) && strlen($params[$fieldName]) > $fieldInfo['maxlength']
){
throw new API_Exception( $params[$fieldName] . " is " . strlen($params[$fieldName]) . " characters - longer than $fieldName length" . $fieldInfo['maxlength'] . ' characters',
2100, array('field' => $fieldName, "max_length" => $fieldInfo['maxlength'])
function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity) {
// If fieldname exists in params
$value = CRM_Utils_Array::value($fieldName, $params, '');
- if(!is_array($value)){
+ if (!is_array($value)){
$value = (string) $value;
}
else{
function _civicrm_api3_api_match_pseudoconstant(&$params, $entity, $fieldName, $fieldInfo) {
$options = CRM_Utils_Array::value('options', $fieldInfo);
if (!$options) {
- if(strtolower($entity) == 'profile' && !empty($fieldInfo['entity'])) {
+ if (strtolower($entity) == 'profile' && !empty($fieldInfo['entity'])) {
// we need to get the options from the entity the field relates to
$entity = $fieldInfo['entity'];
}
$this->_joblog = TRUE;
}
else {
- while(list($short, $long) = each($this->_additional_arguments)) {
+ while (list($short, $long) = each($this->_additional_arguments)) {
if ($arg == '-' . $short || $arg == '--' . $long) {
$property = '_' . $long;
$this->$property = $value;
}
if (!empty($this->_user)) {
- if(!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) {
+ if (!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) {
$this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user)));
return FALSE;
}
$result = civicrm_api($this->_entity, 'Get', $this->_params);
$first = TRUE;
foreach ($result['values'] as $row) {
- if($first) {
+ if ($first) {
$columns = array_keys($row);
fputcsv($out, $columns, $this->separator, '"');
$first = FALSE;
}
//handle values returned as arrays (i.e. custom fields that allow multiple selections) by inserting a control character
foreach ($row as &$field) {
- if(is_array($field)) {
+ if (is_array($field)) {
//convert to string
$field = implode($field, CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR;
}
$this->header = $header;
while (($data = fgetcsv($handle, 0, $this->separator)) !== FALSE) {
// skip blank lines
- if(count($data) == 1 && is_null($data[0])) { continue;
+ if (count($data) == 1 && is_null($data[0])) { continue;
}
$this->row++;
$params = $this->convertLine($data);
$filename = $this->getBaseDir() . $filename;
}
- if (!is_writeable($filename)) {
+ if (!is_writable($filename)) {
$name = NULL;
if (function_exists('posix_getpwuid')) {
$user = posix_getpwuid(posix_geteuid());
$this->assertEquals(date('Y-m-d', strtotime('now')), $result['values'][3]['join_date']);
$result = $this->callAPISuccess('contribution', 'get', array('return' => 'total_amount'));
$this->assertEquals(3, $result['count']);
- foreach($result['values'] as $contribution) {
+ foreach ($result['values'] as $contribution) {
$this-> assertEquals($this->callAPISuccess('line_item', 'getvalue', array(
'contribution_id' => $contribution['id'],
'return' => 'line_total',
$this->assertTrue($form->testProcessContribution($params));
$result = $this->callAPISuccess('contribution', 'get', array('return' => 'total_amount'));
$this->assertEquals(2, $result['count']);
- foreach($result['values'] as $contribution) {
+ foreach ($result['values'] as $contribution) {
$this-> assertEquals($this->callAPISuccess('line_item', 'getvalue', array(
'contribution_id' => $contribution['id'],
'return' => 'line_total',
$this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_event'], 'Check if the number of events created are right');
$actualDates = array();
- foreach($generatedEntities['civicrm_event'] as $key => $val) {
+ foreach ($generatedEntities['civicrm_event'] as $key => $val) {
$this->assertDBNotNull('CRM_Event_DAO_Event', $val, 'id', 'id', 'Check if repeating events were created.');
$startDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'start_date', 'id')));
$endDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'end_date', 'id')));
$resultDates = array_diff($actualDates, $expectedDates);
$this->assertEquals(0, count($resultDates), "Check if all the value in expected array matches actual array");
- foreach($generatedEntities['civicrm_tell_friend'] as $key => $val) {
+ foreach ($generatedEntities['civicrm_tell_friend'] as $key => $val) {
$this->assertDBNotNull('CRM_Friend_DAO_Friend', $val, 'id', 'id', 'Check if friends were created in loop');
$this->assertDBCompareValue('CRM_Friend_DAO_Friend', $val, 'entity_id', 'id', $generatedEntities['civicrm_event'][$key], 'Check DB if correct FK was maintained with event for Friend');
}
$groups[] = $dao->id;
}
- if(!empty($allGroups)) {
+ if (!empty($allGroups)) {
//all groups is empty if we really mean all groups but if a filter like 'is_disabled' is already applied
// it is populated, ajax calls from Manage Groups will leave empty but calls from New Mailing pass in a filtered list
$currentGroups = array_intersect($groups, array_flip($allGroups));
$backtrace = debug_backtrace();
$dir_name = dirname( __FILE__ );
$cwd_len = strlen( $dir_name ) + 1;
- foreach( $backtrace as $frame ){
+ foreach ($backtrace as $frame ){
echo " ";
if ( array_key_exists( 'class', $frame ) ) {
echo " class {$frame['class']}";
private function inlineEdit($block, $params, $valid = 're_open') {
$this->openInlineForm($block);
foreach ($params as $item => $val) {
- switch(gettype($val)) {
+ switch (gettype($val)) {
case 'boolean':
$this->click($item);
break;
if ($validate && $valid !== 'no_open') {
$this->openInlineForm($block);
foreach ($params as $item => $val) {
- switch(gettype($val)) {
+ switch (gettype($val)) {
case 'string':
if ($val && substr($val, 0, 5) == 'date:') {
$val = date('m/d/Y', strtotime(trim(substr($val, 5))));
}
// Verify there was a form error
else {
- switch($valid) {
+ switch ($valid) {
case 'errorJs':
$this->waitForElementPresent('css=label.error');
break;
3 => "{$firstName3}.{$lastName3}@example.com"
);
- foreach($contactEmails as $key => $value) {
+ foreach ($contactEmails as $key => $value) {
$this->click('sort_name_navigation');
$this->type('css=input#sort_name_navigation', $value);
$this->typeKeys('css=input#sort_name_navigation', $value);
$isDefault = FALSE;
//Add new organisation
- if($orgName) {
+ if ($orgName) {
$this->webtestAddOrganization($orgName);
}
$this->_testAddFinancialAccount($financialAccountTitle,
$isDefault = FALSE;
//Add new organisation
- if($orgName) {
+ if ($orgName) {
$this->webtestAddOrganization($orgName);
}
//verifying the registered participants
$status = "Registered (test)";
- foreach($contacts as $contact) {
+ foreach ($contacts as $contact) {
$this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$contact['sort_name']}']/../../td[9]", preg_quote($status));
$this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$contact['sort_name']}']/../../td[4]/a", preg_quote($eventName));
}
$isDefault = FALSE;
//Add new organisation
- if($orgName) {
+ if ($orgName) {
$this->webtestAddOrganization($orgName);
}
$isDefault
);
- if($orgNameEdit) {
+ if ($orgNameEdit) {
$orgName = $orgNameEdit;
}
$this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
$this->click("css=ul.ui-autocomplete li");
$this->waitForPageToLoad($this->getTimeoutMsec());
- foreach($customDataParams['customFields'] as $key => $value){
+ foreach ($customDataParams['customFields'] as $key => $value){
$this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-summary-row']/div[@class='crm-label'][contains(text(), '$key')]"));
$this->assertElementContainsText('address-block-1', "$value");
}
'state' => 'State',
'country' => 'Country',
);
- foreach( $customDataParams['headers'] as $key => $value){
+ foreach ($customDataParams['headers'] as $key => $value){
$headers[$key] = $value;
}
$summaryInfoLinks = array('Intended Recipients', 'Successful Deliveries', 'Tracked Opens', 'Click-throughs', 'Forwards', 'Replies', 'Bounces', 'Unsubscribe Requests', 'Opt-out Requests');
//check for report and adv search links
- foreach($summaryInfoLinks as $value) {
+ foreach ($summaryInfoLinks as $value) {
$this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[1][text()='Report']"), "Report link missing for {$value}");
$this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[2][text()='Advanced Search']"), "Advance Search link missing for {$value}");
}
* @param $mailingReportUrl
*/
public function criteriaCheck($criteriaCheck, $mailingReportUrl) {
- foreach($criteriaCheck as $key => $infoFilter) {
- foreach($infoFilter as $entity => $dataToCheck) {
+ foreach ($criteriaCheck as $key => $infoFilter) {
+ foreach ($infoFilter as $entity => $dataToCheck) {
$this->open($mailingReportUrl);
if ($entity == "report") {
$this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[1][text()='Report']");
* @param $entity
*/
public function _verifyCriteria($summaryInfo, $dataToCheck, $entity) {
- foreach($dataToCheck as $key => $value) {
+ foreach ($dataToCheck as $key => $value) {
if ($entity == 'report') {
if ($key == 'report_name') {
$this->assertElementContainsText('page-title', "{$value}");
),
);
$i = 2;
- foreach($options as $index => $values){
+ foreach ($options as $index => $values){
$this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
// Because it tends to cause problems, all uses of sleep() must be justified in comments
// Sleep should never be used for wait for anything to load from the server
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input", $values['membership_num_terms']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input", $values['label']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input", $values['amount']);
- if($i > 3){
+ if ($i > 3){
$this->click('link=another choice');
}
$i++;
);
$i = 2;
- foreach($options as $index => $values){
+ foreach ($options as $index => $values){
$this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
$this->waitForElementPresent("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input");
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input", $values['membership_num_terms']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input", $values['label']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input", $values['amount']);
- if($i > 3){
+ if ($i > 3){
$this->click('link=another choice');
}
$i++;
* @param bool $renew
*/
public function _testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, $term, $renew = FALSE){
- if($renew){
+ if ($renew){
$this->openCiviPage('member/search', 'reset=1', 'member_end_date_high');
$this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
$this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
'6' => 'Completed',
);
- foreach($expected as $key => $value) {
+ foreach ($expected as $key => $value) {
$this->verifyText("xpath=//div[@class='crm-accordion-wrapper']//table/tbody//tr/td[$key]", $value);
}
$this->click('_qf_Field_next');
$this->waitForPageToLoad($this->getTimeoutMsec());
- if($gid) {
+ if ($gid) {
$this->openCiviPage('admin/setting/localization', 'reset=1', '_qf_Localization_next-bottom');
$country = array(1001 => 'Afghanistan', 1013 => 'Australia', 1039 => 'Canada', 1101 => 'India');
$enabledCountries = $this->getSelectOptions("countryLimit-t");
$enabledStates = $this->getSelectOptions("provinceLimit-t");
$newCountry = array();
- foreach($country as $countryID => $countryName) {
- if(!in_array($countryName, $enabledCountries)) {
+ foreach ($country as $countryID => $countryName) {
+ if (!in_array($countryName, $enabledCountries)) {
$newCountry[$countryID] = $countryName;
$this->addSelection("countryLimit-f", "label=$countryName");
$this->click("xpath=//select[@id='countryLimit-f']/option[@value='$countryID']");
$this->click("xpath=//tr[@class='crm-localization-form-block-countryLimit']/td[2]/table//tbody/tr/td[2]/input[@name='add']");
}
- if(!in_array($countryName, $enabledStates)) {
+ if (!in_array($countryName, $enabledStates)) {
$this->addSelection("provinceLimit-f", "label=$countryName");
$this->click("//option[@value='$countryID']");
$this->click("xpath=//tr[@class='crm-localization-form-block-provinceLimit']/td[2]/table//tbody/tr/td[2]/input[@name='add']");
$enabledCountries = $this->getSelectOptions("countryLimit-t");
$enabledStates = $this->getSelectOptions("provinceLimit-t");
$removed = FALSE;
- foreach($newCountry as $countryID => $countryName) {
+ foreach ($newCountry as $countryID => $countryName) {
$this->addSelection("countryLimit-t", "label=$countryName");
$this->click("xpath=//select[@id='countryLimit-t']/option[@value='$countryID']");
$this->click("xpath=//tr[@class='crm-localization-form-block-countryLimit']/td[2]/table//tbody/tr/td[2]/input[@name='remove']");
$apiStdFunctions = $this->getAllAPIStdFunctions();
$this->assertGreaterThan(1, count($apiStdFunctions),"something has gone wrong getting the std functions in line " . __LINE__);
$params = 'string';
- foreach($apiStdFunctions as $key => $function){
+ foreach ($apiStdFunctions as $key => $function){
if ( in_array( $function, $this->_skipFunctionList ) ) {
continue;
}
*/
public function testCreateGetEventLegacyContributionTypeID() {
$contributionTypeArray = array('contribution_type_id' => 3);
- if(isset($this->_params[0]['financial_type_id'])){
+ if (isset($this->_params[0]['financial_type_id'])){
//in case someone edits $this->_params & invalidates this test :-)
unset($this->_params[0]['financial_type_id']);
}
* @param int $groupID
*/
public function createContactsInGroup($count, $groupID) {
- for($i = 1; $i <= $count; $i++ ) {
+ for ($i = 1; $i <= $count; $i++ ) {
$contactID = $this->individualCreate(array('first_name' => $count, 'email' => 'mail' . $i . '@nul.com'));
$this->callAPISuccess('group_contact', 'create', array('contact_id' => $contactID, 'group_id' => $groupID, 'status' => 'Added'));
}
*/
public function getRecipients($start, $count) {
$recipients = array();
- for($i = $start; $i < ($start + $count); $i++ ) {
+ for ($i = $start; $i < ($start + $count); $i++ ) {
$recipients[][0] = 'mail' . $i . '@nul.com';
}
return $recipients;
public function testMembershipGetFieldsOrder() {
$result = $this->callAPISuccess('profile', 'getfields', array('action' => 'submit', 'profile_id' => 'membership_batch_entry'));
$weight = 1;
- foreach($result['values'] as $fieldName => $field) {
- if($fieldName == 'profile_id') {
+ foreach ($result['values'] as $fieldName => $field) {
+ if ($fieldName == 'profile_id') {
continue;
}
$this->assertEquals($field['weight'], $weight);
* @dataProvider getReportTemplates
*/
public function testReportTemplateGetRowsAllReports($reportID) {
- if(stristr($reportID, 'has existing issues')) {
+ if (stristr($reportID, 'has existing issues')) {
$this->markTestIncomplete($reportID);
}
$result = $this->callAPISuccess('report_template', 'getrows', array(
* @dataProvider getReportTemplates
*/
public function testReportTemplateGetStatisticsAllReports($reportID) {
- if(stristr($reportID, 'has existing issues')) {
+ if (stristr($reportID, 'has existing issues')) {
$this->markTestIncomplete($reportID);
}
- if(in_array($reportID, array('contribute/softcredit', 'contribute/bookkeeping'))) {
+ if (in_array($reportID, array('contribute/softcredit', 'contribute/bookkeeping'))) {
$this->markTestIncomplete($reportID . " has non enotices when calling statistics fn");
}
$description = "Get Statistics from a report (note there isn't much data to get in the test DB :-(";
$reports = civicrm_api3('report_template', 'get', array('return' => 'value', 'options' => array('limit' => 500)));
foreach ($reports['values'] as $report) {
- if(empty($reportsToSkip[$report['value']])) {
+ if (empty($reportsToSkip[$report['value']])) {
$reportTemplates[] = array($report['value']);
}
else {
$invalidEntities = array('Individual', 'Organization', 'Household');
$entitiesToFix = array('Case', 'Relationship');
foreach ($entities as $entityName => $entity ) {
- if(!in_array($entityName, $invalidEntities)
+ if (!in_array($entityName, $invalidEntities)
&& !in_array($entityName, $entitiesToFix)) {
- if(!empty(self::$componentMap[$entityName]) && empty($enabledComponents[self::$componentMap[$entityName]])) {
+ if (!empty(self::$componentMap[$entityName]) && empty($enabledComponents[self::$componentMap[$entityName]])) {
CRM_Core_BAO_ConfigSetting::enableComponent(self::$componentMap[$entityName]);
}
$customDataEntities[] = array($entityName);
),
),
);
- if(empty($knownFailures[$entity]) || empty($knownFailures[$entity][$key])){
+ if (empty($knownFailures[$entity]) || empty($knownFailures[$entity][$key])){
return array();
}
return $knownFailures[$entity][$key];
$this->checkLimitAgainstExpected($entityName, $case[0], $case[1], $case[2]);
//non preferred / legacy syntax
- if(isset($case[0]['options']['limit'])) {
+ if (isset($case[0]['options']['limit'])) {
$this->checkLimitAgainstExpected($entityName, array('rowCount' => $case[0]['options']['limit']), $case[1], $case[2]);
$this->checkLimitAgainstExpected($entityName, array('option_limit' => $case[0]['options']['limit']), $case[1], $case[2]);
$this->checkLimitAgainstExpected($entityName, array('option.limit' => $case[0]['options']['limit']), $case[1], $case[2]);
*/
public function checkLimitAgainstExpected($entityName, $params, $limit, $message) {
$result = $this->callAPISuccess($entityName, 'get', $params);
- if($limit == 30) {
+ if ($limit == 30) {
$this->assertGreaterThanOrEqual($limit, $result['count'], $message);
$this->assertGreaterThanOrEqual($limit, $result['count'], $message);
}
$this->assertNotEmpty($baoString, $entityName);
$this->assertNotEmpty($entityName, $entityName);
$fieldsGet = $fields = $this->callAPISuccess($entityName, 'getfields', array('action' => 'get'));
- if($entityName != 'Pledge'){
+ if ($entityName != 'Pledge'){
$fields = $this->callAPISuccess($entityName, 'getfields', array('action' => 'create'));
}
$fields = $fields['values'];
$entity[$fieldName] = 2;
}
elseif (!empty($specs['FKClassName'])) {
- if($specs['FKClassName'] == $baoString){
+ if ($specs['FKClassName'] == $baoString){
$entity[$fieldName] = (string) $entity2['id'];
}
else{
$options = $this->callAPISuccess($entityName, 'getoptions', array('context' => 'create', 'field' => $field));
if (empty($options['values'])) {
//eg. pdf_format id doesn't ship with any
- if(isset($specs['pseudoconstant']['optionGroupName'])) {
+ if (isset($specs['pseudoconstant']['optionGroupName'])) {
$optionGroupID = $this->callAPISuccess('option_group', 'getvalue', array('name' => 'pdf_format', 'return' => 'id'));
$optionValue = $this->callAPISuccess('option_value', 'create', array('option_group_id' => $optionGroupID, 'label' => 'new option value'));
$options['values'][] = $optionValue['id'];
'id' => $entity['id'],
$field => isset($entity[$field]) ? $entity[$field] : NULL,
);
- if(isset($updateParams['financial_type_id']) && in_array($entityName, array('Grant'))) {
+ if (isset($updateParams['financial_type_id']) && in_array($entityName, array('Grant'))) {
//api has special handling on these 2 fields for backward compatibility reasons
$entity['contribution_type_id'] = $updateParams['financial_type_id'];
}
$entity = array_merge($entity, $resetFKTo);
$updateParams = array_merge($updateParams, $resetFKTo);
$this->callAPISuccess($entityName, 'create', $updateParams);
- if(isset($updateParams['financial_type_id']) && in_array($entityName, array('Grant'))) {
+ if (isset($updateParams['financial_type_id']) && in_array($entityName, array('Grant'))) {
//api has special handling on these 2 fields for backward compatibility reasons
$entity['contribution_type_id'] = $updateParams['financial_type_id'];
}
}
$baos = array();
$i = 0;
- while($i < $count) {
+ while ($i < $count) {
// create entities
$baoObj = CRM_Core_DAO::createTestObject($baoString, array('currency' => 'USD'));
$this->assertTrue(is_integer($baoObj->id), 'check first id');