/** * @param array $cxn * @param string $entity * @param string $action * @param array $params * @return mixed */ public static function route($cxn, $entity, $action, $params) { $SUPER_PERM = array('administer CiviCRM'); require_once 'api/v3/utils.php'; // FIXME: Shouldn't the X-Forwarded-Proto check be part of CRM_Utils_System::isSSL()? if (Civi::settings()->get('enableSSL') && !CRM_Utils_System::isSSL() && strtolower(CRM_Utils_Array::value('X_FORWARDED_PROTO', CRM_Utils_System::getRequestHeaders())) != 'https') { return civicrm_api3_create_error('System policy requires HTTPS.'); } // Note: $cxn and cxnId are authenticated before router is called. $dao = new CRM_Cxn_DAO_Cxn(); $dao->cxn_id = $cxn['cxnId']; if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) { return civicrm_api3_create_error('Failed to lookup connection authorizations.'); } if (!$dao->is_active) { return civicrm_api3_create_error('Connection is inactive.'); } if (!is_string($entity) || !is_string($action) || !is_array($params)) { return civicrm_api3_create_error('API parameters are malformed.'); } if (empty($cxn['perm']['api']) || !is_array($cxn['perm']['api']) || empty($cxn['perm']['grant']) || !(is_array($cxn['perm']['grant']) || is_string($cxn['perm']['grant']))) { return civicrm_api3_create_error('Connection has no permissions.'); } $whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']); \Civi::service('dispatcher')->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist)); CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp(); if ($cxn['perm']['grant'] === '*') { CRM_Core_Config::singleton()->userPermissionTemp->grant($SUPER_PERM); } else { CRM_Core_Config::singleton()->userPermissionTemp->grant($cxn['perm']['grant']); } $params['check_permissions'] = 'whitelist'; return civicrm_api($entity, $action, $params); }
/** * Compute any messages which should be displayed before upgrade. * * @param string $preUpgradeMessage * alterable. * @param $currentVer * @param $latestVer */ public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) { if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) { $preUpgradeMessage .= '<p>' . ts('This webserver is running an outdated version of PHP (%1). It is strongly recommended to upgrade to PHP %2 or later, as older versions can present a security risk.', array(1 => phpversion(), 2 => self::MIN_RECOMMENDED_PHP_VER)) . '</p>'; } // http://issues.civicrm.org/jira/browse/CRM-13572 // Depending on how the code was upgraded, some sites may still have copies of old // source files left behind. This is often a forgivable offense, but it's quite // dangerous for CIVI-SA-2013-001. global $civicrm_root; $ofcFile = "{$civicrm_root}/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php"; if (file_exists($ofcFile)) { if (@unlink($ofcFile)) { $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', array(1 => $ofcFile)); } else { $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', array(1 => $ofcFile)); } } if (Civi::settings()->get('enable_innodb_fts')) { // The FTS indexing feature dynamically manipulates the schema which could // cause conflicts with other layers that manipulate the schema. The // simplest thing is to turn it off and back on. // It may not always be necessary to do this -- but I doubt we're going to test // systematically in future releases. When it is necessary, one could probably // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences // after the upgrade. But that's speculative. For now, we'll leave this // advanced feature in the hands of the sysadmin. $preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => System Settings => Miscellaneous".'); } }
public function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, FALSE, TRUE); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update'); if (isset($action)) { $this->assign('action', $action); } $session = CRM_Core_Session::singleton(); $this->_config = new CRM_Core_DAO(); if ($this->_system) { if (CRM_Core_Permission::check('administer CiviCRM')) { $this->_contactID = NULL; } else { CRM_Utils_System::fatal('You do not have permission to edit preferences'); } $this->_config->contact_id = NULL; } else { if (!$this->_contactID) { $this->_contactID = $session->get('userID'); if (!$this->_contactID) { CRM_Utils_System::fatal('Could not retrieve contact id'); } $this->set('cid', $this->_contactID); } $this->_config->contact_id = $this->_contactID; } $settings = Civi::settings(); foreach ($this->_varNames as $groupName => $settingNames) { foreach ($settingNames as $settingName => $options) { $this->_config->{$settingName} = $settings->get($settingName); } } $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); }
/** * Add an ics attachment to the input array. * * @param array $attachments * Reference to array in same format returned from CRM_Core_BAO_File::getEntityFile(). * @param array $contacts * Array of contacts (attendees). * * @return string|null * Array index of the added attachment in the $attachments array, else NULL. */ public function addAttachment(&$attachments, $contacts) { // Check preferences setting if (Civi::settings()->get('activity_assignee_notification_ics')) { $config =& CRM_Core_Config::singleton(); $this->icsfile = tempnam($config->customFileUploadDir, 'ics'); if ($this->icsfile !== FALSE) { rename($this->icsfile, $this->icsfile . '.ics'); $this->icsfile .= '.ics'; $icsFileName = basename($this->icsfile); // get logged in user's primary email // TODO: Is there a better way to do this? $organizer = $this->getPrimaryEmail(); $template = CRM_Core_Smarty::singleton(); $template->assign('activity', $this->activity); $template->assign('organizer', $organizer); $template->assign('contacts', $contacts); $template->assign('timezone', date_default_timezone_get()); $calendar = $template->fetch('CRM/Activity/Calendar/ICal.tpl'); if (file_put_contents($this->icsfile, $calendar) !== FALSE) { if (empty($attachments)) { $attachments = array(); } $attachments['activity_ics'] = array('mime_type' => 'text/calendar', 'fileName' => $icsFileName, 'cleanName' => $icsFileName, 'fullPath' => $this->icsfile); return 'activity_ics'; } } } return NULL; }
/** * @param bool $fresh * @return CRM_Cxn_CiviCxnHttp */ public static function singleton($fresh = FALSE) { if (self::$singleton === NULL || $fresh) { $cache = CRM_Utils_Cache::create(array('name' => 'CiviCxnHttp', 'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : array('SqlGroup', 'ArrayCache'), 'prefetch' => FALSE)); self::$singleton = new CRM_Cxn_CiviCxnHttp($cache); } return self::$singleton; }
/** * @param bool $fresh * @return CRM_Utils_QueryFormatter */ public static function singleton($fresh = FALSE) { if ($fresh || self::$singleton === NULL) { $mode = Civi::settings()->get('fts_query_mode'); self::$singleton = new CRM_Utils_QueryFormatter($mode); } return self::$singleton; }
/** * Build all the data structures needed to build the form. */ public function preProcess() { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $this->_searchKey = CRM_Utils_Request::retrieve('key', 'String', $this); // sort out whether it’s a delete-to-trash, delete-into-oblivion or restore (and let the template know) $values = $this->controller->exportValues(); $this->_skipUndelete = (CRM_Core_Permission::check('access deleted contacts') and (CRM_Utils_Request::retrieve('skip_undelete', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::DELETE_PERMANENTLY)); $this->_restore = (CRM_Utils_Request::retrieve('restore', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::RESTORE); if ($this->_restore && !CRM_Core_Permission::check('access deleted contacts')) { CRM_Core_Error::fatal(ts('You do not have permission to access this contact.')); } elseif (!CRM_Core_Permission::check('delete contacts')) { CRM_Core_Error::fatal(ts('You do not have permission to delete this contact.')); } $this->assign('trash', Civi::settings()->get('contact_undelete') and !$this->_skipUndelete); $this->assign('restore', $this->_restore); if ($this->_restore) { CRM_Utils_System::setTitle(ts('Restore Contact')); } if ($cid) { if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) { CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.')); } elseif (CRM_Contact_BAO_Contact::checkDomainContact($cid)) { CRM_Core_Error::fatal(ts('This contact is a special one for the contact information associated with the CiviCRM installation for this domain. No one is allowed to delete it because the information is used for special system purposes.')); } $this->_contactIds = array($cid); $this->_single = TRUE; $this->assign('totalSelectedContacts', 1); } else { parent::preProcess(); } $this->_sharedAddressMessage = $this->get('sharedAddressMessage'); if (!$this->_restore && !$this->_sharedAddressMessage) { // we check for each contact for shared contact address $sharedContactList = array(); $sharedAddressCount = 0; foreach ($this->_contactIds as $contactId) { // check if a contact that is being deleted has any shared addresses $sharedAddressMessage = CRM_Core_BAO_Address::setSharedAddressDeleteStatus(NULL, $contactId, TRUE); if ($sharedAddressMessage['count'] > 0) { $sharedAddressCount += $sharedAddressMessage['count']; $sharedContactList = array_merge($sharedContactList, $sharedAddressMessage['contactList']); } } $this->_sharedAddressMessage = array('count' => $sharedAddressCount, 'contactList' => $sharedContactList); if ($sharedAddressCount > 0) { if (count($this->_contactIds) > 1) { // more than one contact deleted $message = ts('One of the selected contacts has an address record that is shared with 1 other contact.', array('plural' => 'One or more selected contacts have address records which are shared with %count other contacts.', 'count' => $sharedAddressCount)); } else { // only one contact deleted $message = ts('This contact has an address record which is shared with 1 other contact.', array('plural' => 'This contact has an address record which is shared with %count other contacts.', 'count' => $sharedAddressCount)); } CRM_Core_Session::setStatus($message . ' ' . ts('Shared addresses will not be removed or altered but will no longer be shared.'), ts('Shared Addesses Owner')); } // set in form controller so that queries are not fired again $this->set('sharedAddressMessage', $this->_sharedAddressMessage); } }
/** * @return array */ public function checkOutboundMail() { $messages = array(); $mailingInfo = Civi::settings()->get('mailing_backend'); if ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB || defined('CIVICRM_MAIL_LOG') && CIVICRM_MAIL_LOG || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MOCK) { $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))), ts('Outbound Email Disabled'), \Psr\Log\LogLevel::WARNING, 'fa-envelope'); } return $messages; }
/** * @param bool $fresh * @return CRM_Core_InnoDBIndexer */ public static function singleton($fresh = FALSE) { if ($fresh || self::$singleton === NULL) { $indices = array('civicrm_address' => array(array('street_address', 'city', 'postal_code')), 'civicrm_activity' => array(array('subject', 'details')), 'civicrm_contact' => array(array('sort_name', 'nick_name', 'display_name')), 'civicrm_contribution' => array(array('source', 'amount_level', 'trxn_Id', 'invoice_id')), 'civicrm_email' => array(array('email')), 'civicrm_membership' => array(array('source')), 'civicrm_note' => array(array('subject', 'note')), 'civicrm_participant' => array(array('source', 'fee_level')), 'civicrm_phone' => array(array('phone')), 'civicrm_tag' => array(array('name'))); $active = Civi::settings()->get('enable_innodb_fts'); self::$singleton = new self($active, $indices); } return self::$singleton; }
/** * Set default values for the form. * * default values are retrieved from the database */ public function setDefaultValues() { $defaults = Civi::settings()->get('contribution_invoice_settings'); //CRM-16691: Changes made related to settings of 'CVV'. foreach ($this->_settings as $setting => $group) { $settingMetaData = civicrm_api3('setting', 'getfields', array('name' => $setting)); $defaults[$setting] = civicrm_api3('setting', 'getvalue', array('name' => $setting, 'group' => $group, 'default_value' => CRM_Utils_Array::value('default', $settingMetaData['values'][$setting]))); } return $defaults; }
/** * Get the final, usable URL string (after interpolating any variables) * * @return FALSE|string */ public function gettingStartedUrl() { // Note: We use "*default*" as the default (rather than self::GETTING_STARTED_URL) so that future // developers can change GETTING_STARTED_URL without needing to update {civicrm_setting}. $url = Civi::settings()->get('gettingStartedUrl'); if ($url === '*default*') { $url = self::GETTING_STARTED_URL; } return CRM_Utils_System::evalUrl($url); }
/** * This is some kind of special-purpose router/front-controller for the various profile URLs. * * @param array $args * this array contains the arguments of the url. * * @return string|void */ public function run($args = NULL) { if ($args[1] !== 'profile') { return NULL; } $secondArg = CRM_Utils_Array::value(2, $args, ''); if ($secondArg == 'map') { $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Task_Map', ts('Map Contact'), NULL, FALSE, FALSE, TRUE); $gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')); if (count($gids) > 1) { foreach ($gids as $pfId) { $profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive'); } $controller->set('gid', $profileIds[0]); $profileGID = $profileIds[0]; } else { $profileGID = CRM_Utils_Request::retrieve('gid', 'Integer', $controller, TRUE); } // make sure that this profile enables mapping // CRM-8609 $isMap = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map'); if (!$isMap) { CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.')); } $profileView = CRM_Utils_Request::retrieve('pv', 'Integer', $controller, FALSE); // set the userContext stack $session = CRM_Core_Session::singleton(); if ($profileView) { $session->pushUserContext(CRM_Utils_System::url('civicrm/profile/view')); } else { $session->pushUserContext(CRM_Utils_System::url('civicrm/profile', 'force=1')); } $controller->set('profileGID', $profileGID); $controller->process(); return $controller->run(); } if ($secondArg == 'edit' || $secondArg == 'create') { $allowRemoteSubmit = Civi::settings()->get('remote_profile_submissions'); if ($secondArg == 'edit') { $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit', ts('Create Profile'), CRM_Core_Action::UPDATE, FALSE, FALSE, $allowRemoteSubmit); $controller->set('edit', 1); $controller->process(); return $controller->run(); } else { $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run('CRM_Profile_Form_Edit', ts('Create Profile'), array('mode' => CRM_Core_Action::ADD, 'ignoreKey' => $allowRemoteSubmit)); } } if ($secondArg == 'view' || empty($secondArg)) { $page = new CRM_Profile_Page_Listings(); return $page->run(); } CRM_Utils_System::permissionDenied(); }
/** * @return string|'' * Class name, or empty. */ public static function getProviderClass() { $settings = Civi::settings(); if ($settings->get('geoProvider')) { return 'CRM_Utils_Geocode_' . $settings->get('geoProvider'); } elseif ($settings->get('mapProvider')) { return 'CRM_Utils_Geocode_' . $settings->get('mapProvider'); } else { return ''; } }
protected function createStreamOpts($verb, $url, $blob, $headers) { $result = parent::createStreamOpts($verb, $url, $blob, $headers); $caConfig = CA_Config_Stream::probe(array('verify_peer' => (bool) Civi::settings()->get('verifySSL'))); if ($caConfig->isEnableSSL()) { $result['ssl'] = $caConfig->toStreamOptions(); } if (!$caConfig->isEnableSSL() && preg_match('/^https:/', $url)) { CRM_Core_Error::fatal('Cannot fetch document - system does not support SSL'); } return $result; }
/** * @param CRM_Utils_Cache_Interface $cache * @param CRM_Utils_HttpClient $client * @param null $messagesUrl */ public function __construct($cache, $client, $messagesUrl = NULL) { $this->cache = $cache; $this->client = $client; if ($messagesUrl === NULL) { $this->messagesUrl = Civi::settings()->get('communityMessagesUrl'); } else { $this->messagesUrl = $messagesUrl; } if ($this->messagesUrl === '*default*') { $this->messagesUrl = self::DEFAULT_MESSAGES_URL; } }
/** * @param $values * * @return bool */ public static function checkAddress(&$values) { if (self::$_disabled) { return FALSE; } if (!isset($values['street_address']) || !isset($values['city']) && !isset($values['state_province']) && !isset($values['postal_code'])) { return FALSE; } $userID = Civi::settings()->get('address_standardization_userid'); $url = Civi::settings()->get('address_standardization_url'); if (empty($userID) || empty($url)) { return FALSE; } $address2 = str_replace(',', '', $values['street_address']); $XMLQuery = '<AddressValidateRequest USERID="' . $userID . '"><Address ID="0"><Address1>' . CRM_Utils_Array::value('supplemental_address_1', $values, '') . '</Address1><Address2>' . $address2 . '</Address2><City>' . $values['city'] . '</City><State>' . $values['state_province'] . '</State><Zip5>' . $values['postal_code'] . '</Zip5><Zip4>' . CRM_Utils_Array::value('postal_code_suffix', $values, '') . '</Zip4></Address></AddressValidateRequest>'; require_once 'HTTP/Request.php'; $request = new HTTP_Request(); $request->setURL($url); $request->addQueryString('API', 'Verify'); $request->addQueryString('XML', $XMLQuery); $response = $request->sendRequest(); $session = CRM_Core_Session::singleton(); $code = $request->getResponseCode(); if ($code != 200) { $session->setStatus(ts('USPS Address Lookup Failed with HTTP status code: %1', array(1 => $code))); return FALSE; } $responseBody = $request->getResponseBody(); $xml = simplexml_load_string($responseBody); if (is_null($xml) || is_null($xml->Address)) { $session->setStatus(ts('Your USPS API Lookup has Failed.')); return FALSE; } if ($xml->Number == '80040b1a') { $session->setStatus(ts('Your USPS API Authorization has Failed.')); return FALSE; } if (array_key_exists('Error', $xml->Address)) { $session->setStatus(ts('Address not found in USPS database.')); return FALSE; } $values['street_address'] = (string) $xml->Address->Address2; $values['city'] = (string) $xml->Address->City; $values['state_province'] = (string) $xml->Address->State; $values['postal_code'] = (string) $xml->Address->Zip5; $values['postal_code_suffix'] = (string) $xml->Address->Zip4; if (array_key_exists('Address1', $xml->Address)) { $values['supplemental_address_1'] = (string) $xml->Address->Address1; } return TRUE; }
/** * Retrieve unclosed cases. */ public static function unclosedCases() { $params = array('limit' => Civi::settings()->get('search_autocomplete_count'), 'sort_name' => CRM_Utils_Type::escape(CRM_Utils_Array::value('term', $_GET, ''), 'String')); $excludeCaseIds = array(); if (!empty($_GET['excludeCaseIds'])) { $excludeCaseIds = explode(',', CRM_Utils_Type::escape($_GET['excludeCaseIds'], 'String')); } $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds, TRUE, TRUE); $results = array(); foreach ($unclosedCases as $caseId => $details) { $results[] = array('id' => $caseId, 'label' => $details['sort_name'] . ' - ' . $details['case_type'] . ($details['end_date'] ? ' (' . ts('closed') . ')' : ''), 'label_class' => $details['end_date'] ? 'strikethrough' : '', 'description' => array("#{$caseId}: " . $details['case_subject'] . ' (' . $details['case_status'] . ')'), 'extra' => $details); } CRM_Utils_JSON::output($results); }
/** * Get the action links for this page. * * @param * * @return array */ public static function &actionLinks() { // check if variable _actionsLinks is populated if (!self::$_actionLinks) { // helper variable for nicer formatting $copyExtra = ts('Are you sure you want to make a copy of this Profile?'); self::$_actionLinks = array(CRM_Core_Action::BROWSE => array('name' => ts('Fields'), 'url' => 'civicrm/admin/uf/group/field', 'qs' => 'reset=1&action=browse&gid=%%id%%', 'title' => ts('View and Edit Fields')), CRM_Core_Action::UPDATE => array('name' => ts('Settings'), 'url' => 'civicrm/admin/uf/group/update', 'qs' => 'action=update&id=%%id%%&context=group', 'title' => ts('Edit CiviCRM Profile Group')), CRM_Core_Action::PREVIEW => array('name' => ts('Preview'), 'url' => 'civicrm/admin/uf/group', 'qs' => 'action=preview&id=%%id%%&field=0&context=group', 'title' => ts('Edit CiviCRM Profile Group')), CRM_Core_Action::ADD => array('name' => ts('Use - Create Mode'), 'url' => 'civicrm/profile/create', 'qs' => 'gid=%%id%%&reset=1', 'title' => ts('Use - Create Mode'), 'fe' => TRUE), CRM_Core_Action::ADVANCED => array('name' => ts('Use - Edit Mode'), 'url' => 'civicrm/profile/edit', 'qs' => 'gid=%%id%%&reset=1', 'title' => ts('Use - Edit Mode'), 'fe' => TRUE), CRM_Core_Action::BASIC => array('name' => ts('Use - Listings Mode'), 'url' => 'civicrm/profile', 'qs' => 'gid=%%id%%&reset=1', 'title' => ts('Use - Listings Mode'), 'fe' => TRUE), CRM_Core_Action::DISABLE => array('name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable CiviCRM Profile Group')), CRM_Core_Action::ENABLE => array('name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable CiviCRM Profile Group')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => 'civicrm/admin/uf/group', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete CiviCRM Profile Group')), CRM_Core_Action::COPY => array('name' => ts('Copy'), 'url' => 'civicrm/admin/uf/group', 'qs' => 'action=copy&gid=%%id%%', 'title' => ts('Make a Copy of CiviCRM Profile Group'), 'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"')); $allowRemoteSubmit = Civi::settings()->get('remote_profile_submissions'); if ($allowRemoteSubmit) { self::$_actionLinks[CRM_Core_Action::PROFILE] = array('name' => ts('HTML Form Snippet'), 'url' => 'civicrm/admin/uf/group', 'qs' => 'action=profile&gid=%%id%%', 'title' => ts('HTML Form Snippet for this Profile')); } } return self::$_actionLinks; }
/** * Determine the current site's callback URL. * * @return string */ public static function getSiteCallbackUrl() { $config = CRM_Core_Config::singleton(); if (preg_match('/^(http|https):/', $config->resourceBase)) { $civiUrl = $config->resourceBase; } else { $civiUrl = rtrim(CRM_Utils_System::baseURL(), '/') . '/' . ltrim($config->resourceBase, '/'); } // In practice, this may not be necessary, but we want to prevent // edge-cases that downgrade security-level below system policy. if (Civi::settings()->get('enableSSL')) { $civiUrl = preg_replace('/^http:/', 'https:', $civiUrl); } return rtrim($civiUrl, '/') . '/extern/cxn.php'; }
/** * This function provides the HTML form elements that are specific to the Individual Contact Type. * * @param CRM_Core_Form $form * Form object. * @param int $inlineEditMode * ( 1 for contact summary. * top bar form and 2 for display name edit ) */ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { $form->applyFilter('__ALL__', 'trim'); if (!$inlineEditMode || $inlineEditMode == 1) { $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2'); // Use names instead of labels to build form. $nameFields = array_keys($nameFields); // Fixme: dear god why? these come out in a format that is NOT the name of the fields. foreach ($nameFields as &$fix) { $fix = str_replace(' ', '_', strtolower($fix)); if ($fix == 'prefix' || $fix == 'suffix') { // God, why god? $fix .= '_id'; } } foreach ($nameFields as $name) { $props = array(); if ($name == 'prefix_id' || $name == 'suffix_id') { //override prefix/suffix label name as Prefix/Suffix respectively and adjust select size $props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix')); } $form->addField($name, $props); } } if (!$inlineEditMode || $inlineEditMode == 2) { // nick_name $form->addField('nick_name'); // job title // override the size for UI to look better $form->addField('job_title', array('size' => '30')); //Current Employer Element $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE); $form->addField('employer_id', $props); $form->addField('contact_source', array('class' => 'big')); } if (!$inlineEditMode) { $checkSimilar = Civi::settings()->get('contact_ajax_check_similar'); if ($checkSimilar == NULL) { $checkSimilar = 0; } $form->assign('checkSimilar', $checkSimilar); //External Identifier Element $form->addField('external_identifier', array('label' => 'External ID')); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier')); CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); } }
public function postProcess() { // check if mailing tab is enabled, if not prompt user to enable the tab if "write_activity_record" is disabled $params = $this->controller->exportValues($this->_name); if (empty($params['write_activity_record'])) { $existingViewOptions = Civi::settings()->get('contact_view_options'); $displayValue = CRM_Core_OptionGroup::getValue('contact_view_options', 'CiviMail', 'name'); $viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions); if (!in_array($displayValue, $viewOptions)) { $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR; Civi::settings()->set('contact_view_options', $existingViewOptions); CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens so that you can view mailings sent to each contact.'), ts('Saved'), 'success'); } } parent::postProcess(); }
/** * Heart of the iCalendar data assignment process. The runner gets all the meta * data for the event and calls the method to output the iCalendar * to the user. If gData param is passed on the URL, outputs gData XML format. * Else outputs iCalendar format per IETF RFC2445. Page param true means send * to browser as inline content. Else, we send .ics file as attachment. * * @return void */ public function run() { $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET'); $type = CRM_Utils_Request::retrieve('type', 'Positive', $this, FALSE, 0); $start = CRM_Utils_Request::retrieve('start', 'Positive', $this, FALSE, 0); $end = CRM_Utils_Request::retrieve('end', 'Positive', $this, FALSE, 0); $iCalPage = CRM_Utils_Request::retrieve('list', 'Positive', $this, FALSE, 0); $gData = CRM_Utils_Request::retrieve('gData', 'Positive', $this, FALSE, 0); $html = CRM_Utils_Request::retrieve('html', 'Positive', $this, FALSE, 0); $rss = CRM_Utils_Request::retrieve('rss', 'Positive', $this, FALSE, 0); $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end); $this->assign('events', $info); $this->assign('timezone', @date_default_timezone_get()); // Send data to the correct template for formatting (iCal vs. gData) $template = CRM_Core_Smarty::singleton(); $config = CRM_Core_Config::singleton(); if ($rss) { // rss 2.0 requires lower case dash delimited locale $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages))); $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl'); } elseif ($gData) { $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl'); } elseif ($html) { // check if we're in shopping cart mode for events $enable_cart = Civi::settings()->get('enable_cart'); if ($enable_cart) { $this->assign('registration_links', TRUE); } return parent::run(); } else { $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl'); $calendar = preg_replace('/(?<!\\r)\\n/', "\r\n", $calendar); } // Push output for feed or download if ($iCalPage == 1) { if ($gData || $rss) { CRM_Utils_ICalendar::send($calendar, 'text/xml', 'utf-8'); } else { CRM_Utils_ICalendar::send($calendar, 'text/plain', 'utf-8'); } } else { CRM_Utils_ICalendar::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment'); } CRM_Utils_System::civiExit(); }
/** * Heart of the viewing process. The runner gets all the meta data for * the contact and calls the appropriate type of page to view. * * @return void */ public function preProcess() { CRM_Utils_System::setTitle(ts('CiviEvent')); $eventSummary = CRM_Event_BAO_Event::getEventSummary(); $enableCart = Civi::settings()->get('enable_cart'); $eventSummary['tab'] = CRM_Event_Page_ManageEvent::tabs($enableCart); $actionColumn = FALSE; if (!empty($eventSummary) && isset($eventSummary['events']) && is_array($eventSummary['events'])) { foreach ($eventSummary['events'] as $e) { if (isset($e['isMap']) || isset($e['configure'])) { $actionColumn = TRUE; break; } } } $this->assign('actionColumn', $actionColumn); $this->assign('eventSummary', $eventSummary); }
/** * Heart of the viewing process. * * The runner gets all the meta data for the contact and calls the appropriate type of page to view. */ public function preProcess() { CRM_Utils_System::setTitle(ts('CiviPledge')); $startToDate = array(); $yearToDate = array(); $monthToDate = array(); $previousToDate = array(); $prefixes = array('start', 'month', 'year', 'previous'); $status = array('Completed', 'Cancelled', 'Pending', 'In Progress', 'Overdue'); // cumulative (since inception) - prefix = 'start' $startDate = NULL; $startDateEnd = NULL; // current year - prefix = 'year' $yearDate = \Civi::settings()->get('fiscalYearStart'); $year = array('Y' => date('Y')); $this->assign('curYear', $year['Y']); $yearDate = array_merge($year, $yearDate); $yearDate = CRM_Utils_Date::format($yearDate); $yearDate = $yearDate . '000000'; $yearDateEnd = $year['Y'] . '1231235959'; // current month - prefix = 'month' $currentMonth = date("F Y", mktime(0, 0, 0, date("m"), 01, date("Y"))); $this->assign('currentMonthYear', $currentMonth); $monthDate = date('Ym') . '01000000'; $monthDateEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m"), 01, date("Y"))), '%Y%m%d') . '235959'; // previous month - prefix = 'previous' $previousDate = CRM_Utils_Date::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '000000'; $previousDateEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '235959'; $previousMonth = date("F Y", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))); $this->assign('previousMonthYear', $previousMonth); foreach ($prefixes as $prefix) { $aName = $prefix . 'ToDate'; $startName = $prefix . 'Date'; $endName = $prefix . 'DateEnd'; foreach ($status as $s) { ${$aName}[str_replace(" ", "", $s)] = CRM_Pledge_BAO_Pledge::getTotalAmountAndCount($s, ${$startName}, ${$endName}); } $this->assign($aName, ${$aName}); } }
/** * Build the form object. */ public function buildQuickForm() { $wysiwyg_options = CRM_Core_OptionGroup::values('wysiwyg_editor', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name'); //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $this->assign('invoicing', $invoicing); $extra = array(); $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra); $this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor')); $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0'); $this->assign('editOptions', $editOptions); $contactBlocks = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1'); $this->assign('contactBlocks', $contactBlocks); $nameFields = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2'); $this->assign('nameFields', $nameFields); $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences')); $optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name'); $invoicesKey = array_search('Invoices / Credit Notes', $optionValues); $this->assign('invoicesKey', $invoicesKey); parent::buildQuickForm(); }
/** * List memberships for the UF user. * */ public function listMemberships() { $membership = array(); $dao = new CRM_Member_DAO_Membership(); $dao->contact_id = $this->_contactId; $dao->is_test = 0; $dao->find(); while ($dao->fetch()) { $membership[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $membership[$dao->id]); //get the membership status and type values. $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id); foreach (array('status', 'membership_type') as $fld) { $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]); } if (!empty($statusANDType[$dao->id]['is_current_member'])) { $membership[$dao->id]['active'] = TRUE; } $membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id); if (!$membership[$dao->id]['renewPageId']) { // Membership payment was not done via online contribution page or free membership. Check for default membership renewal page from CiviMember Settings $defaultRenewPageId = Civi::settings()->get('default_renewal_contribution_page'); if ($defaultRenewPageId) { //CRM-14831 - check if membership type is present in contrib page $memBlock = CRM_Member_BAO_Membership::getMembershipBlock($defaultRenewPageId); if (!empty($memBlock['membership_types'])) { $memTypes = explode(',', $memBlock['membership_types']); if (in_array($dao->membership_type_id, $memTypes)) { $membership[$dao->id]['renewPageId'] = $defaultRenewPageId; } } } } } $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership); $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive'); $this->assign('activeMembers', $activeMembers); $this->assign('inActiveMembers', $inActiveMembers); }
/** * These tasks are the core set of tasks that the user can perform * on a contact / group of contacts * * @return array * the set of tasks for a group of contacts */ public static function tasks() { if (!self::$_tasks) { self::$_tasks = array(1 => array('title' => ts('Delete contributions'), 'class' => 'CRM_Contribute_Form_Task_Delete', 'result' => FALSE), 2 => array('title' => ts('Print selected rows'), 'class' => 'CRM_Contribute_Form_Task_Print', 'result' => FALSE), 3 => array('title' => ts('Export contributions'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 4 => array('title' => ts('Update multiple contributions'), 'class' => array('CRM_Contribute_Form_Task_PickProfile', 'CRM_Contribute_Form_Task_Batch'), 'result' => TRUE), 5 => array('title' => ts('Email - send now'), 'class' => 'CRM_Contribute_Form_Task_Email', 'result' => TRUE), 6 => array('title' => ts('Update pending contribution status'), 'class' => 'CRM_Contribute_Form_Task_Status', 'result' => TRUE), 7 => array('title' => ts('Receipts - print or email'), 'class' => 'CRM_Contribute_Form_Task_PDF', 'result' => FALSE), 8 => array('title' => ts('Thank-you letters - print or email'), 'class' => 'CRM_Contribute_Form_Task_PDFLetter', 'result' => FALSE), 9 => array('title' => ts('Invoices - print or email'), 'class' => 'CRM_Contribute_Form_Task_Invoice', 'result' => FALSE)); //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviContribute')) { unset(self::$_tasks[1]); } //CRM-12920 - check for edit permission if (!CRM_Core_Permission::check('edit contributions')) { unset(self::$_tasks[4], self::$_tasks[6]); } // remove action "Invoices - print or email" $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); if (!$invoicing) { unset(self::$_tasks[9]); } CRM_Utils_Hook::searchTasks('contribution', self::$_tasks); asort(self::$_tasks); } return self::$_tasks; }
public function setUp() { parent::setUp(); $this->_individualId = $this->individualCreate(); $this->_orgId = $this->organizationCreate(NULL); $this->params = array('title' => "Test Contribution Page" . substr(sha1(rand()), 0, 7), 'financial_type_id' => 1, 'payment_processor' => 1, 'currency' => 'NZD', 'goal_amount' => 350, 'is_pay_later' => 1, 'pay_later_text' => 'I will pay later', 'pay_later_receipt' => "I will pay later", 'is_monetary' => TRUE, 'is_billing_required' => TRUE); $this->_priceSetParams = array('name' => 'tax_contribution' . substr(sha1(rand()), 0, 7), 'title' => 'contributiontax' . substr(sha1(rand()), 0, 7), 'is_active' => 1, 'help_pre' => "Where does your goat sleep", 'help_post' => "thank you for your time", 'extends' => 2, 'financial_type_id' => 3, 'is_quick_config' => 0, 'is_reserved' => 0); // Financial Account with 20% tax rate $financialAccountSetparams = array('name' => 'vat full taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 20.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0); $financialAccount = $this->callAPISuccess('financial_account', 'create', $financialAccountSetparams); $this->financialAccountId = $financialAccount['id']; // Financial type having 'Sales Tax Account is' with liability financail account $financialType = array('name' => 'grassvariety1' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1); $priceField = $this->callAPISuccess('financial_type', 'create', $financialType); $this->financialtypeID = $priceField['id']; $financialRelationParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->financialtypeID, 'account_relationship' => 10, 'financial_account_id' => $this->financialAccountId); $financialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationParams); // Financial type with 5% tax rate $financialAccHalftax = array('name' => 'vat half taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 5.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0); $halfFinancialAccount = CRM_Financial_BAO_FinancialAccount::add($financialAccHalftax); $this->halfFinancialAccId = $halfFinancialAccount->id; $halfFinancialtypeHalftax = array('name' => 'grassvariety2' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1); $halfFinancialType = CRM_Financial_BAO_FinancialType::add($halfFinancialtypeHalftax); $this->halfFinancialTypeId = $halfFinancialType->id; $financialRelationHalftax = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->halfFinancialTypeId, 'account_relationship' => 10, 'financial_account_id' => $this->halfFinancialAccId); $halfFinancialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationHalftax); // Enable component contribute setting $contributeSetting = array('invoicing' => 1, 'invoice_prefix' => 'INV_', 'credit_notes_prefix' => 'CN_', 'due_date' => 10, 'due_date_period' => 'days', 'notes' => '', 'is_email_pdf' => 1, 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive'); $setInvoiceSettings = Civi::settings()->set('contribution_invoice_settings', $contributeSetting); // Payment Processor $paymentProceParams = array('domain_id' => 1, 'name' => 'dummy' . substr(sha1(rand()), 0, 7), 'payment_processor_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_PaymentProcessor', 'payment_processor_type_id', 'Dummy'), 'financial_account_id' => 12, 'is_active' => 1, 'is_default' => 1, 'user_name' => 'dummy', 'url_site' => 'http://dummy.com', 'url_recur' => 'http://dummyrecur.com', 'class_name' => 'Payment_Dummy', 'billing_mode' => 1, 'is_recur' => 1, 'payment_type' => 1); $result = $this->callAPISuccess('payment_processor', 'create', $paymentProceParams); $this->_ids['paymentProcessID'] = $result['id']; require_once 'api/v3/examples/PaymentProcessor/Create.php'; $this->assertAPISuccess($result); }
/** * This function sends request and receives response from * the processor * * @param array $params * * @return array|object * @throws \Exception */ public function doDirectPayment(&$params) { if ($params['is_recur'] == TRUE) { CRM_Core_Error::fatal(ts('First Data - recurring payments not implemented')); } if (!defined('CURLOPT_SSLCERT')) { CRM_Core_Error::fatal(ts('%1 - Gateway requires curl with SSL support', array(1 => $paymentProcessor))); } /********************************************************** * Create the array of variables to be sent to the processor from the $params array * passed into this function **********************************************************/ $requestFields = self::mapProcessorFieldstoParams($params); /********************************************************** * create FirstData request object **********************************************************/ require_once 'FirstData/lphp.php'; // $mylphp=new lphp; /********************************************************** * define variables for connecting with the gateway **********************************************************/ # Name and location of certificate file $key = $this->_paymentProcessor['password']; # Your store number $requestFields["configfile"] = $this->_paymentProcessor['user_name']; $port = "1129"; $host = $this->_paymentProcessor['url_site'] . ":" . $port . "/LSGSXML"; //---------------------------------------------------------------------------------------------------- // Check to see if we have a duplicate before we send //---------------------------------------------------------------------------------------------------- if ($this->checkDupe($params['invoiceID'], CRM_Utils_Array::value('contributionID', $params))) { return self::errorExit(9003, 'It appears that this transaction is a duplicate. Have you already submitted the form once? If so there may have been a connection problem. Check your email for a receipt from eWAY. If you do not receive a receipt within 2 hours you can try your transaction again. If you continue to have problems please contact the site administrator.'); } //---------------------------------------------------------------------------------------------------- // Convert to XML using function provided by payment processor //---------------------------------------------------------------------------------------------------- $requestxml = lphp::buildXML($requestFields); /*---------------------------------------------------------------------------------------------------- // Send to the payment information using cURL /---------------------------------------------------------------------------------------------------- */ $ch = curl_init($host); if (!$ch) { return self::errorExit(9004, 'Could not initiate connection to payment gateway'); } curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestxml); curl_setopt($ch, CURLOPT_SSLCERT, $key); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, Civi::settings()->get('verifySSL') ? 2 : 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, Civi::settings()->get('verifySSL')); // return the result on success, FALSE on failure curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 36000); // ensures any Location headers are followed if (ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off') { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); } // Send the data out over the wire //-------------------------------- $responseData = curl_exec($ch); //---------------------------------------------------------------------------------------------------- // See if we had a curl error - if so tell 'em and bail out // // NOTE: curl_error does not return a logical value (see its documentation), but // a string, which is empty when there was no error. //---------------------------------------------------------------------------------------------------- if (curl_errno($ch) > 0 || strlen(curl_error($ch)) > 0) { $errorNum = curl_errno($ch); $errorDesc = curl_error($ch); // Paranoia - in the unlikley event that 'curl' errno fails if ($errorNum == 0) { $errorNum = 9005; } // Paranoia - in the unlikley event that 'curl' error fails if (strlen($errorDesc) == 0) { $errorDesc = "Connection to payment gateway failed"; } if ($errorNum == 60) { return self::errorExit($errorNum, "Curl error - " . $errorDesc . " Try this link for more information http://curl.haxx.se/docs/sslcerts.html"); } return self::errorExit($errorNum, "Curl error - " . $errorDesc . " your key is located at " . $key . " the url is " . $host . " xml is " . $requestxml . " processor response = " . $processorResponse); } //---------------------------------------------------------------------------------------------------- // If null data returned - tell 'em and bail out // // NOTE: You will not necessarily get a string back, if the request failed for // any reason, the return value will be the boolean false. //---------------------------------------------------------------------------------------------------- if ($responseData === FALSE || strlen($responseData) == 0) { return self::errorExit(9006, "Error: Connection to payment gateway failed - no data returned."); } //---------------------------------------------------------------------------------------------------- // If gateway returned no data - tell 'em and bail out //---------------------------------------------------------------------------------------------------- if (empty($responseData)) { return self::errorExit(9007, "Error: No data returned from payment gateway."); } //---------------------------------------------------------------------------------------------------- // Success so far - close the curl and check the data //---------------------------------------------------------------------------------------------------- curl_close($ch); //---------------------------------------------------------------------------------------------------- // Payment successfully sent to gateway - process the response now //---------------------------------------------------------------------------------------------------- // $processorResponse = lphp::decodeXML($responseData); // transaction failed, print the reason if ($processorResponse["r_approved"] != "APPROVED") { return self::errorExit(9009, "Error: [" . $processorResponse['r_error'] . "] - from payment processor"); } else { //----------------------------------------------------------------------------------------------------- // Cross-Check - the unique 'TrxnReference' we sent out should match the just received 'TrxnReference' // // this section not used as the processor doesn't appear to pass back our invoice no. Code in eWay model if // used later //----------------------------------------------------------------------------------------------------- //============= // Success ! //============= $params['trxn_result_code'] = $processorResponse['r_message']; $params['trxn_id'] = $processorResponse['r_ref']; CRM_Core_Error::debug_log_message("r_authresponse " . $processorResponse['r_authresponse']); CRM_Core_Error::debug_log_message("r_code " . $processorResponse['r_code']); CRM_Core_Error::debug_log_message("r_tdate " . $processorResponse['r_tdate']); CRM_Core_Error::debug_log_message("r_avs " . $processorResponse['r_avs']); CRM_Core_Error::debug_log_message("r_ordernum " . $processorResponse['r_ordernum']); CRM_Core_Error::debug_log_message("r_error " . $processorResponse['r_error']); CRM_Core_Error::debug_log_message("csp " . $processorResponse['r_csp']); CRM_Core_Error::debug_log_message("r_message " . $processorResponse['r_message']); CRM_Core_Error::debug_log_message("r_ref " . $processorResponse['r_ref']); CRM_Core_Error::debug_log_message("r_time " . $processorResponse['r_time']); return $params; } }
/** * Set defaults for api.getlist. * * @param string $entity * @param array $request * @param array $apiDefaults * @param array $fields */ function _civicrm_api3_generic_getList_defaults($entity, &$request, $apiDefaults, $fields) { $config = CRM_Core_Config::singleton(); $defaults = array('page_num' => 1, 'input' => '', 'image_field' => NULL, 'id_field' => $entity == 'option_value' ? 'value' : 'id', 'description_field' => array(), 'params' => array(), 'extra' => array()); // Find main field from meta foreach (array('sort_name', 'title', 'label', 'name', 'subject') as $field) { if (isset($fields[$field])) { $defaults['label_field'] = $defaults['search_field'] = $field; break; } } // Find fields to be used for the description foreach (array('description') as $field) { if (isset($fields[$field])) { $defaults['description_field'][] = $field; } } $resultsPerPage = Civi::settings()->get('search_autocomplete_count'); if (isset($request['params']) && isset($apiDefaults['params'])) { $request['params'] += $apiDefaults['params']; } $request += $apiDefaults + $defaults; // Default api params $params = array('options' => array('limit' => $resultsPerPage + 1, 'offset' => ($request['page_num'] - 1) * $resultsPerPage, 'sort' => $request['label_field']), 'sequential' => 1); // When searching e.g. autocomplete if ($request['input']) { $params[$request['search_field']] = array('LIKE' => ($config->includeWildCardInName ? '%' : '') . $request['input'] . '%'); } // When looking up a field e.g. displaying existing record if (!empty($request['id'])) { if (is_string($request['id']) && strpos($request['id'], ',')) { $request['id'] = explode(',', trim($request['id'], ', ')); } // Don't run into search limits when prefilling selection $params['options']['limit'] = NULL; unset($params['options']['offset'], $request['params']['options']['limit'], $request['params']['options']['offset']); $params[$request['id_field']] = is_array($request['id']) ? array('IN' => $request['id']) : $request['id']; } $request['params'] += $params; }