当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Error::singleton方法代码示例

本文整理汇总了PHP中CRM_Core_Error::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Error::singleton方法的具体用法?PHP CRM_Core_Error::singleton怎么用?PHP CRM_Core_Error::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Error的用法示例。


在下文中一共展示了CRM_Core_Error::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 function add(&$params, &$ids)
 {
     require_once 'CRM/Utils/Hook.php';
     $duplicates = array();
     if (CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicates)) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_CORE_ERROR_DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching contribution(s): {$d}");
         return $error;
     }
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $ids['contribution'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', null, $params);
     }
     $contribution =& new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->domain_id = CRM_Utils_Array::value('domain', $ids, CRM_Core_Config::domainID());
     $contribution->id = CRM_Utils_Array::value('contribution', $ids);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         require_once 'CRM/Core/Config.php';
         $config =& CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     $result = $contribution->save();
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:47,代码来源:Contribution.php

示例2: add

 /**
  * Takes an associative array and creates a contribution object.
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return CRM_Contribute_BAO_Contribution
  * @todo move hook calls / extended logic to create - requires changing calls to call create not add
  */
 public static function add(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'ContributionRecur', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'ContributionRecur', NULL, $params);
     }
     // make sure we're not creating a new recurring contribution with the same transaction ID
     // or invoice ID as an existing recurring contribution
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates)) {
         $error = CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching recurring contribution(s): {$d}");
         return $error;
     }
     $recurring = new CRM_Contribute_BAO_ContributionRecur();
     $recurring->copyValues($params);
     $recurring->id = CRM_Utils_Array::value('id', $params);
     // set currency for CRM-1496
     if (empty($params['id']) && !isset($recurring->currency)) {
         $config = CRM_Core_Config::singleton();
         $recurring->currency = $config->defaultCurrency;
     }
     $result = $recurring->save();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'ContributionRecur', $recurring->id, $recurring);
     } else {
         CRM_Utils_Hook::post('create', 'ContributionRecur', $recurring->id, $recurring);
     }
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution_recur', $recurring->id);
     }
     return $result;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:48,代码来源:ContributionRecur.php

示例3: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 static function add(&$params, &$ids)
 {
     if (empty($params)) {
         return;
     }
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates, CRM_Utils_Array::value('contribution', $ids))) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}");
         return $error;
     }
     // first clean up all the money fields
     $moneyFields = array('total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount');
     //if priceset is used, no need to cleanup money
     if (CRM_UTils_Array::value('skipCleanMoney', $params)) {
         unset($moneyFields[0]);
     }
     foreach ($moneyFields as $field) {
         if (isset($params[$field])) {
             $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
         }
     }
     if (CRM_Utils_Array::value('payment_instrument_id', $params)) {
         require_once 'CRM/Contribute/PseudoConstant.php';
         $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
         if ($params['payment_instrument_id'] != array_search('Check', $paymentInstruments)) {
             $params['check_number'] = 'null';
         }
     }
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $ids['contribution'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', null, $params);
     }
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->id = CRM_Utils_Array::value('contribution', $ids);
     // also add financial_trxn details as part of fix for CRM-4724
     $contribution->trxn_result_code = CRM_Utils_Array::value('trxn_result_code', $params);
     $contribution->payment_processor = CRM_Utils_Array::value('payment_processor', $params);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         require_once 'CRM/Core/Config.php';
         $config = CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     $result = $contribution->save();
     // reset the group contact cache for this group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:73,代码来源:Contribution.php

示例4:

 function &error($errorCode = null, $errorMessage = null)
 {
     $e =& CRM_Core_Error::singleton();
     if ($errorCode) {
         $e->push($errorCode, 0, null, $errorMessage);
     } else {
         $e->push(9001, 0, null, 'Unknown System Error.');
     }
     return $e;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:10,代码来源:Dummy.php

示例5: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 static function add(&$params, &$ids)
 {
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates)) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching contribution(s): {$d}");
         return $error;
     }
     $recurring =& new CRM_Contribute_BAO_ContributionRecur();
     $recurring->copyValues($params);
     $recurring->id = CRM_Utils_Array::value('contribution', $ids);
     return $recurring->save();
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:28,代码来源:ContributionRecur.php

示例6: add

 /**
  * Takes an associative array and creates a contribution object.
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  *
  * @return CRM_Contribute_BAO_Contribution|void
  */
 public static function add(&$params, $ids = array())
 {
     if (empty($params)) {
         return NULL;
     }
     //per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
     $contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates, $contributionID)) {
         $error = CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}");
         return $error;
     }
     // first clean up all the money fields
     $moneyFields = array('total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount');
     //if priceset is used, no need to cleanup money
     if (!empty($params['skipCleanMoney'])) {
         unset($moneyFields[0]);
     }
     foreach ($moneyFields as $field) {
         if (isset($params[$field])) {
             $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
         }
     }
     //set defaults in create mode
     if (!$contributionID) {
         CRM_Core_DAO::setCreateDefaults($params, self::getDefaults());
     }
     self::calculateMissingAmountParams($params, $contributionID);
     if (!empty($params['payment_instrument_id'])) {
         $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
         if ($params['payment_instrument_id'] != array_search('Check', $paymentInstruments)) {
             $params['check_number'] = 'null';
         }
     }
     $setPrevContribution = TRUE;
     // CRM-13964 partial payment
     if (!empty($params['partial_payment_total']) && !empty($params['partial_amount_pay'])) {
         $partialAmtTotal = $params['partial_payment_total'];
         $partialAmtPay = $params['partial_amount_pay'];
         $params['total_amount'] = $partialAmtTotal;
         if ($partialAmtPay < $partialAmtTotal) {
             $params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Partially paid', 'name');
             $params['is_pay_later'] = 0;
             $setPrevContribution = FALSE;
         }
     }
     if ($contributionID) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', NULL, $params);
     }
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->id = $contributionID;
     if (empty($contribution->id)) {
         // (only) on 'create', make sure that a valid currency is set (CRM-16845)
         if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
             $config = CRM_Core_Config::singleton();
             $contribution->currency = $config->defaultCurrency;
         }
     }
     if ($contributionID && $setPrevContribution) {
         $params['prevContribution'] = self::getValues(array('id' => $contributionID), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
     }
     $result = $contribution->save();
     // Add financial_trxn details as part of fix for CRM-4724
     $contribution->trxn_result_code = CRM_Utils_Array::value('trxn_result_code', $params);
     $contribution->payment_processor = CRM_Utils_Array::value('payment_processor', $params);
     //add Account details
     $params['contribution'] = $contribution;
     self::recordFinancialAccounts($params);
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
     if ($contributionID) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:96,代码来源:Contribution.php

示例7: createError

 /**
  * @param $message
  * @param int $code
  * @param string $level
  * @param array $params
  *
  * @return object
  */
 public static function createError($message, $code = 8000, $level = 'Fatal', $params = NULL)
 {
     $error = CRM_Core_Error::singleton();
     $error->push($code, $level, array($params), $message);
     return $error;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:14,代码来源:Error.php

示例8: postProcessOld


//.........这里部分代码省略.........
                 if (isset($mapper[$key][1])) {
                     $header[] = $locationTypes[$mapper[$key][1]];
                 }
                 if (isset($mapper[$key][2])) {
                     $header[] = $phoneTypes[$mapper[$key][2]];
                 }
             }
         }
         $mapperFields[] = implode(' - ', $header);
     }
     $tableName = $this->get('importTableName');
     //print "Running parser on table: $tableName<br/>";
     $parser->run($tableName, $mapperFields, CRM_Import_Parser::MODE_IMPORT, $this->get('contactType'), $this->get('primaryKeyName'), $this->get('statusFieldName'), $onDuplicate, $this->get('statusID'), $this->get('totalRowCount'), $doGeocodeAddress, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->get('contactSubType'), $this->get('dedupe'));
     // add the new contacts to selected groups
     $contactIds =& $parser->getImportedContacts();
     // add the new related contacts to selected groups
     $relatedContactIds =& $parser->getRelatedImportedContacts();
     $this->set('relatedCount', count($relatedContactIds));
     $newGroupId = NULL;
     //changed below if-statement "if ($newGroup) {" to "if ($newGroupName) {"
     if ($newGroupName) {
         /* Create a new group */
         $gParams = array('name' => $newGroupName, 'title' => $newGroupName, 'description' => $newGroupDesc, 'is_active' => TRUE);
         $group = CRM_Contact_BAO_Group::create($gParams);
         $groups[] = $newGroupId = $group->id;
     }
     if (is_array($groups)) {
         $groupAdditions = array();
         foreach ($groups as $groupId) {
             $addCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
             if (!empty($relatedContactIds)) {
                 $addRelCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($relatedContactIds, $groupId);
             }
             $totalCount = $addCount[1] + $addRelCount[1];
             if ($groupId == $newGroupId) {
                 $name = $newGroupName;
                 $new = TRUE;
             } else {
                 $name = $allGroups[$groupId];
                 $new = FALSE;
             }
             $groupAdditions[] = array('url' => CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $groupId), 'name' => $name, 'added' => $totalCount, 'notAdded' => $addCount[2] + $addRelCount[2], 'new' => $new);
         }
         $this->set('groupAdditions', $groupAdditions);
     }
     $newTagId = NULL;
     if ($newTagName) {
         /* Create a new Tag */
         $tagParams = array('name' => $newTagName, 'title' => $newTagName, 'description' => $newTagDesc, 'is_active' => TRUE);
         $id = array();
         $addedTag = CRM_Core_BAO_Tag::add($tagParams, $id);
         $tag[$addedTag->id] = 1;
     }
     //add Tag to Import
     if (is_array($tag)) {
         $tagAdditions = array();
         foreach ($tag as $tagId => $val) {
             $addTagCount = CRM_Core_BAO_EntityTag::addContactsToTag($contactIds, $tagId);
             if (!empty($relatedContactIds)) {
                 $addRelTagCount = CRM_Core_BAO_EntityTag::addContactsToTag($relatedContactIds, $tagId);
             }
             $totalTagCount = $addTagCount[1] + $addRelTagCount[1];
             if ($tagId == $addedTag->id) {
                 $tagName = $newTagName;
                 $new = TRUE;
             } else {
                 $tagName = $allTags[$tagId];
                 $new = FALSE;
             }
             $tagAdditions[] = array('url' => CRM_Utils_System::url('civicrm/contact/search', 'reset=1&force=1&context=smog&id=' . $tagId), 'name' => $tagName, 'added' => $totalTagCount, 'notAdded' => $addTagCount[2] + $addRelTagCount[2], 'new' => $new);
         }
         $this->set('tagAdditions', $tagAdditions);
     }
     // add all the necessary variables to the form
     $parser->set($this, CRM_Import_Parser::MODE_IMPORT);
     // check if there is any error occured
     $errorStack = CRM_Core_Error::singleton();
     $errors = $errorStack->getErrors();
     $errorMessage = array();
     if (is_array($errors)) {
         foreach ($errors as $key => $value) {
             $errorMessage[] = $value['message'];
         }
         // there is no fileName since this is a sql import
         // so fudge it
         $config = CRM_Core_Config::singleton();
         $errorFile = $config->uploadDir . "sqlImport.error.log";
         if ($fd = fopen($errorFile, 'w')) {
             fwrite($fd, implode('\\n', $errorMessage));
         }
         fclose($fd);
         $this->set('errorFile', $errorFile);
         $urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contact_Import_Parser';
         $this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlparams));
         $urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contact_Import_Parser';
         $this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
         $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contact_Import_Parser';
         $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Preview.php

示例9: elseif

 function &error($error = null)
 {
     $e =& CRM_Core_Error::singleton();
     if (is_object($error)) {
         $e->push($error->getResponseCode(), 0, null, $error->getMessage());
     } elseif (is_string($error)) {
         $e->push(9002, 0, null, $error);
     } else {
         $e->push(9001, 0, null, "Unknown System Error.");
     }
     return $e;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:12,代码来源:Moneris.php

示例10: postProcess

 /**
  * Process the mapped fields and map it into the uploaded file
  * preview the file and extract some summary statistics
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $fileName = $this->controller->exportValue('UploadFile', 'uploadFile');
     $skipColumnHeader = $this->controller->exportValue('UploadFile', 'skipColumnHeader');
     $invalidRowCount = $this->get('invalidRowCount');
     $conflictRowCount = $this->get('conflictRowCount');
     $onDuplicate = $this->get('onDuplicate');
     $config =& CRM_Core_Config::singleton();
     $seperator = $config->fieldSeparator;
     $mapper = $this->controller->exportValue('MapField', 'mapper');
     $mapperKeys = array();
     $mapperLocType = array();
     $mapperPhoneType = array();
     foreach ($mapper as $key => $value) {
         $mapperKeys[$key] = $mapper[$key][0];
         if (is_numeric($mapper[$key][1])) {
             $mapperLocType[$key] = $mapper[$key][1];
         } else {
             $mapperLocType[$key] = null;
         }
         if (!is_numeric($mapper[$key][2])) {
             $mapperPhoneType[$key] = $mapper[$key][2];
         } else {
             $mapperPhoneType[$key] = null;
         }
     }
     $parser =& new CRM_Activity_Import_Parser_Activity($mapperKeys, $mapperLocType, $mapperPhoneType);
     $mapFields = $this->get('fields');
     foreach ($mapper as $key => $value) {
         $header = array();
         if (isset($mapFields[$mapper[$key][0]])) {
             $header[] = $mapFields[$mapper[$key][0]];
         }
         $mapperFields[] = implode(' - ', $header);
     }
     $parser->run($fileName, $seperator, $mapperFields, $skipColumnHeader, CRM_Activity_Import_Parser::MODE_IMPORT, $onDuplicate);
     // add all the necessary variables to the form
     $parser->set($this, CRM_Activity_Import_Parser::MODE_IMPORT);
     // check if there is any error occured
     $errorStack =& CRM_Core_Error::singleton();
     $errors = $errorStack->getErrors();
     $errorMessage = array();
     if (is_array($errors)) {
         foreach ($errors as $key => $value) {
             $errorMessage[] = $value['message'];
         }
         $errorFile = $fileName['name'] . '.error.log';
         if ($fd = fopen($errorFile, 'w')) {
             fwrite($fd, implode('\\n', $errorMessage));
         }
         fclose($fd);
         $this->set('errorFile', $errorFile);
         $this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=1&realm=activity'));
         $this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=2&realm=activity'));
         $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=4&realm=activity'));
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:64,代码来源:Preview.php

示例11: invokeAPI

 /**
  * Hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
  */
 public function invokeAPI($args, $url = NULL)
 {
     if ($url === NULL) {
         if (empty($this->_paymentProcessor['url_api'])) {
             CRM_Core_Error::fatal(ts('Please set the API URL. Please refer to the documentation for more details'));
         }
         $url = $this->_paymentProcessor['url_api'] . 'nvp';
     }
     if (!function_exists('curl_init')) {
         CRM_Core_Error::fatal("curl functions NOT available.");
     }
     //setting the curl parameters.
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_VERBOSE, 1);
     //turning off the server and peer verification(TrustManager Concept).
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'));
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL') ? 2 : 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     $p = array();
     foreach ($args as $n => $v) {
         $p[] = "{$n}=" . urlencode($v);
     }
     //NVPRequest for submitting to server
     $nvpreq = implode('&', $p);
     //setting the nvpreq as POST FIELD to curl
     curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
     //getting response from server
     $response = curl_exec($ch);
     //converting NVPResponse to an Associative Array
     $result = self::deformat($response);
     if (curl_errno($ch)) {
         $e = CRM_Core_Error::singleton();
         $e->push(curl_errno($ch), 0, NULL, curl_error($ch));
         return $e;
     } else {
         curl_close($ch);
     }
     if (strtolower($result['ack']) != 'success' && strtolower($result['ack']) != 'successwithwarning') {
         $e = CRM_Core_Error::singleton();
         $e->push($result['l_errorcode0'], 0, NULL, "{$result['l_shortmessage0']} {$result['l_longmessage0']}");
         return $e;
     }
     return $result;
 }
开发者ID:sugan2111,项目名称:Drupal_code,代码行数:52,代码来源:PayPalImpl.php

示例12: invokeAPI

 /**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @paymentProcessor is the array of payment processor settings value.
  * @searchParamsnvpStr is the array of search params.
  * returns an associtive array containing the response from the server.
  * @param $paymentProcessor
  * @param $searchParams
  * @return array|object
  * @throws \Exception
  */
 function invokeAPI($paymentProcessor, $searchParams)
 {
     $merchantID = $paymentProcessor['user_name'];
     $merchantKey = $paymentProcessor['password'];
     $siteURL = rtrim(str_replace('https://', '', $paymentProcessor['url_site']), '/');
     $url = "https://{$merchantID}:{$merchantKey}@{$siteURL}/api/checkout/v2/reports/Merchant/{$merchantID}";
     $xml = self::buildXMLQuery($searchParams);
     if (!function_exists('curl_init')) {
         CRM_Core_Error::fatal("curl functions NOT available.");
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_VERBOSE, 1);
     //turning off the server and peer verification(TrustManager Concept).
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     //setting the nvpreq as POST FIELD to curl
     curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
     //getting response from server
     $xmlResponse = curl_exec($ch);
     // strip slashes if needed
     if (get_magic_quotes_gpc()) {
         $xmlResponse = stripslashes($xmlResponse);
     }
     if (curl_errno($ch)) {
         $e =& CRM_Core_Error::singleton();
         $e->push(curl_errno($ch), 0, NULL, curl_error($ch));
         return $e;
     } else {
         curl_close($ch);
     }
     return self::getArrayFromXML($xmlResponse);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:45,代码来源:GoogleCheckout.php

示例13: postProcess

 /**
  * Process the mapped fields and map it into the uploaded file
  * preview the file and extract some summary statistics
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $fileName = $this->controller->exportValue('DataSource', 'uploadFile');
     $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
     $invalidRowCount = $this->get('invalidRowCount');
     $conflictRowCount = $this->get('conflictRowCount');
     $onDuplicate = $this->get('onDuplicate');
     $config = CRM_Core_Config::singleton();
     $seperator = $config->fieldSeparator;
     $mapper = $this->controller->exportValue('MapField', 'mapper');
     $mapperKeys = array();
     foreach ($mapper as $key => $value) {
         $mapperKeys[$key] = $mapper[$key][0];
     }
     $parser = new CRM_Event_Import_Parser_Participant($mapperKeys);
     $mapFields = $this->get('fields');
     foreach ($mapper as $key => $value) {
         $header = array();
         if (isset($mapFields[$mapper[$key][0]])) {
             $header[] = $mapFields[$mapper[$key][0]];
         }
         $mapperFields[] = implode(' - ', $header);
     }
     $parser->run($fileName, $seperator, $mapperFields, $skipColumnHeader, CRM_Import_Parser::MODE_IMPORT, $this->get('contactType'), $onDuplicate);
     // add all the necessary variables to the form
     $parser->set($this, CRM_Import_Parser::MODE_IMPORT);
     // check if there is any error occured
     $errorStack = CRM_Core_Error::singleton();
     $errors = $errorStack->getErrors();
     $errorMessage = array();
     if (is_array($errors)) {
         foreach ($errors as $key => $value) {
             $errorMessage[] = $value['message'];
         }
         $errorFile = $fileName['name'] . '.error.log';
         if ($fd = fopen($errorFile, 'w')) {
             fwrite($fd, implode('\\n', $errorMessage));
         }
         fclose($fd);
         $this->set('errorFile', $errorFile);
         $urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Event_Import_Parser';
         $this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
         $urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Event_Import_Parser';
         $this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
         $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Event_Import_Parser';
         $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:55,代码来源:Preview.php

示例14: error

 /**
  * Error reporting mechanism
  *
  * @param string  $message Error Message
  * @param int     $code    Error Code
  * @param CRM_Core_DAO $dao     A data access object on which we perform a rollback if non - empty
  * @return void
  * @access public
  */
 function error($message, $code = null, $dao = null)
 {
     if ($dao) {
         $dao->query('ROLLBACK');
     }
     $error =& CRM_Core_Error::singleton();
     $error->push($code, $message);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:17,代码来源:Form.php

示例15: add

 /**
  * Takes an associative array and creates a contribution object.
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  *
  * @return CRM_Contribute_BAO_Contribution|void
  */
 public static function add(&$params, $ids = array())
 {
     if (empty($params)) {
         return NULL;
     }
     //per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
     $contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates, $contributionID)) {
         $error = CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}");
         return $error;
     }
     // first clean up all the money fields
     $moneyFields = array('total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount');
     //if priceset is used, no need to cleanup money
     if (!empty($params['skipCleanMoney'])) {
         unset($moneyFields[0]);
     }
     foreach ($moneyFields as $field) {
         if (isset($params[$field])) {
             $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
         }
     }
     //set defaults in create mode
     if (!$contributionID) {
         CRM_Core_DAO::setCreateDefaults($params, self::getDefaults());
     }
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     //if contribution is created with cancelled or refunded status, add credit note id
     if (!empty($params['contribution_status_id'])) {
         // @todo - should we include Chargeback? If so use self::isContributionStatusNegative($params['contribution_status_id'])
         if ($params['contribution_status_id'] == array_search('Refunded', $contributionStatus) || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus)) {
             if (empty($params['creditnote_id']) || $params['creditnote_id'] == "null") {
                 $params['creditnote_id'] = self::createCreditNoteId();
             }
         }
     } else {
         // Since the fee amount is expecting this (later on) ensure it is always set.
         // It would only not be set for an update where it is unchanged.
         $params['contribution_status_id'] = civicrm_api3('Contribution', 'getvalue', array('id' => $contributionID, 'return' => 'contribution_status_id'));
     }
     if (!$contributionID && CRM_Utils_Array::value('membership_id', $params) && self::checkContributeSettings('deferred_revenue_enabled')) {
         $memberStartDate = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $params['membership_id'], 'start_date');
         if ($memberStartDate) {
             $params['revenue_recognition_date'] = date('Ymd', strtotime($memberStartDate));
         }
     }
     self::calculateMissingAmountParams($params, $contributionID);
     if (!empty($params['payment_instrument_id'])) {
         $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
         if ($params['payment_instrument_id'] != array_search('Check', $paymentInstruments)) {
             $params['check_number'] = 'null';
         }
     }
     $setPrevContribution = TRUE;
     // CRM-13964 partial payment
     if (!empty($params['partial_payment_total']) && !empty($params['partial_amount_pay'])) {
         $partialAmtTotal = $params['partial_payment_total'];
         $partialAmtPay = $params['partial_amount_pay'];
         $params['total_amount'] = $partialAmtTotal;
         if ($partialAmtPay < $partialAmtTotal) {
             $params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Partially paid', 'name');
             $params['is_pay_later'] = 0;
             $setPrevContribution = FALSE;
         }
     }
     if ($contributionID && $setPrevContribution) {
         $params['prevContribution'] = self::getOriginalContribution($contributionID);
     }
     // CRM-16189
     CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($params, $contributionID);
     if ($contributionID && !empty($params['revenue_recognition_date']) && !empty($params['prevContribution']) && !($contributionStatus[$params['prevContribution']->contribution_status_id] == 'Pending') && !self::allowUpdateRevenueRecognitionDate($contributionID)) {
         unset($params['revenue_recognition_date']);
     }
     if (!isset($params['tax_amount']) && $setPrevContribution && (isset($params['total_amount']) || isset($params['financial_type_id']))) {
         $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
     }
     if ($contributionID) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', NULL, $params);
     }
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php


注:本文中的CRM_Core_Error::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。