本文整理汇总了PHP中CRM_Core_Error类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Error类的具体用法?PHP CRM_Core_Error怎么用?PHP CRM_Core_Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Error类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isConditionValid
public function isConditionValid(CRM_Civirules_EventData_EventData $eventData)
{
$contactId = $eventData->getContactId();
$entityData = $eventData->getEntityData('ContributionSoft');
$contacts = array();
$query = $this->conditionParams['smart_group_query'];
if (!empty($query)) {
$subQueries = explode(';', $query);
// To run only first and select statement in query string
if (!empty($subQueries) && !preg_match('/^(insert|update|delete|create|drop|replace)/i', $subQueries[0])) {
CRM_Core_Error::debug_var('CiviRules::Custom Query Contact Condition Query', $subQueries[0]);
CRM_Core_Error::debug_var('CiviRules::Custom Query Contact Condition Param Contribution', $entityData['contribution_id']);
$dao = CRM_Core_DAO::executeQuery('SELECT ' . $subQueries[0], array(1 => array($entityData['contribution_id'], 'Int')));
while ($dao->fetch()) {
$contacts[] = $dao->contact_id;
}
}
}
CRM_Core_Error::debug_var('CiviRules::Custom Query Contact Condition Contacts', $contacts);
if (!empty($contacts)) {
$eventData->setConditionOutputData('ContributionSoft', $contacts);
return TRUE;
} else {
return FALSE;
}
}
示例2: preProcess
/**
* This function is called prior to building and submitting the form
*/
function preProcess()
{
// check contact_id
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if (empty($this->_contactId)) {
CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// check for permissions
$session = CRM_Core_Session::singleton();
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// get request
$this->_request = CRM_Utils_Request::retrieve('request', 'String', $this, FALSE, 'choose');
// get session
$session = CRM_Core_Session::singleton();
// get values
$this->_configRelationship = CRM_Lidmaatschapwijziging_ConfigRelationship::singleton($this->_contactId);
$this->_values = $this->_configRelationship->getContact();
// set contact id
$this->_values['contact_id'] = $this->_contactId;
// set display name
$this->_display_name = $this->_values['display_name'];
// set request
$this->_values['request'] = $this->_request;
// set title
CRM_Utils_System::setTitle('LidmaatschapWijziging - Relatie - ' . $this->_values['display_name']);
// request
if ('empty' == $this->_request) {
}
if ('choose' == $this->_request) {
// if there is no relatiosnhips then the options are empty, we
// show a message that there are no memebrships and a submit butten to
// go to the relationship, first we redirect them to request empty
$relationships = $this->_configRelationship->getRelationships();
if (empty($relationships)) {
// redirect user
$url = CRM_Utils_System::url('civicrm/lidmaatschapwijziging/relationship', 'reset=1&request=empty&cid=' . $this->_contactId);
CRM_Utils_System::redirect($url);
}
}
if ('update' == $this->_request) {
// get relationship id
$this->_relationshipId = CRM_Utils_Request::retrieve('relationship_id', 'Positive', $this);
$this->_values['relationship_id'] = $this->_relationshipId;
// get relationship
$this->_values = array_merge($this->_values, $this->_configRelationship->getRelationship($this->_relationshipId));
if (!empty($this->_values['contact_a']['display_name'])) {
$this->assign('sort_name_a', $this->_values['contact_a']['display_name']);
}
if (!empty($this->_values['contact_b']['display_name'])) {
$this->assign('sort_name_b', $this->_values['contact_b']['display_name']);
}
// note
$this->_values['note_id'] = $this->_values['notes']['id'];
$this->_values['note'] = $this->_values['notes']['note'];
}
}
示例3: smarty_function_crmAPI
/**
*/
function smarty_function_crmAPI($params, &$smarty)
{
if (!array_key_exists('action', $params)) {
$params['action'] = "get";
}
if (!array_key_exists('sequential', $params)) {
$params['sequential'] = 1;
}
if (!array_key_exists('entity', $params)) {
$smarty->trigger_error("assign: missing 'entity' parameter");
return "crmAPI: missing 'entity' parameter";
}
CRM_Core_Error::setCallback(array('CRM_Utils_REST', 'fatal'));
$action = $params['action'];
$entity = $params['entity'];
unset($params['entity']);
unset($params['method']);
unset($params['assign']);
$params['version'] = 3;
require_once 'api/api.php';
$result = civicrm_api($entity, $action, $params);
CRM_Core_Error::setCallback();
if ($result === FALSE) {
$smarty->trigger_error("Unkown error");
return;
}
if (!array_key_exists('var', $params)) {
return json_encode($result);
}
if (!empty($params['json'])) {
$smarty->assign($params["var"], json_encode($result));
} else {
$smarty->assign($params["var"], $result);
}
}
示例4: checkLogFileIsNotAccessible
/**
* Check if our logfile is directly accessible.
*
* Per CiviCRM default the logfile sits in a folder which is
* web-accessible, and is protected by a default .htaccess
* configuration. If server config causes the .htaccess not to
* function as intended, there may be information disclosure.
*
* The debug log may be jam-packed with sensitive data, we don't
* want that.
*
* Being able to be retrieved directly doesn't mean the logfile
* is browseable or visible to search engines; it means it can be
* requested directly.
*
* @return array
* Array of messages
* @see CRM-14091
*/
public function checkLogFileIsNotAccessible()
{
$messages = array();
$config = CRM_Core_Config::singleton();
$log = CRM_Core_Error::createDebugLogger();
$log_filename = str_replace('\\', '/', $log->_filename);
$filePathMarker = $this->getFilePathMarker();
// Hazard a guess at the URL of the logfile, based on common
// CiviCRM layouts.
if ($upload_url = explode($filePathMarker, $config->imageUploadURL)) {
$url[] = $upload_url[0];
if ($log_path = explode($filePathMarker, $log_filename)) {
// CRM-17149: check if debug log path includes $filePathMarker
if (count($log_path) > 1) {
$url[] = $log_path[1];
$log_url = implode($filePathMarker, $url);
$headers = @get_headers($log_url);
if (stripos($headers[0], '200')) {
$docs_url = $this->createDocUrl('checkLogFileIsNotAccessible');
$msg = 'The <a href="%1">CiviCRM debug log</a> should not be downloadable.' . '<br />' . '<a href="%2">Read more about this warning</a>';
$messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts($msg, array(1 => $log_url, 2 => $docs_url)), ts('Security Warning'), \Psr\Log\LogLevel::WARNING, 'fa-lock');
}
}
}
}
return $messages;
}
示例5: preProcess
/**
* For pre-processing
*
* @return void
*/
public function preProcess()
{
parent::preProcess();
$this->_key = CRM_Utils_Request::retrieve('key', 'String', $this, FALSE, 0);
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1&action=browse');
$session->pushUserContext($url);
$this->assign('id', $this->_id);
$this->assign('key', $this->_key);
switch ($this->_action) {
case CRM_Core_Action::ADD:
case CRM_Core_Action::DELETE:
case CRM_Core_Action::ENABLE:
case CRM_Core_Action::DISABLE:
$info = CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->_key);
$extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
$this->assign('extension', $extInfo);
break;
case CRM_Core_Action::UPDATE:
if (!CRM_Extension_System::singleton()->getBrowser()->isEnabled()) {
CRM_Core_Error::fatal(ts('The system administrator has disabled this feature.'));
}
$info = CRM_Extension_System::singleton()->getBrowser()->getExtension($this->_key);
$extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
$this->assign('extension', $extInfo);
break;
default:
CRM_Core_Error::fatal(ts('Unsupported action'));
}
}
示例6: __construct
function __construct()
{
$this->initialize();
CRM_Utils_System::authenticateScript(TRUE);
//log the execution of script
CRM_Core_Error::debug_log_message('CiviReportMail.php');
}
示例7: preProcess
public function preProcess()
{
$this->_type = 'unsubscribe';
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
if (!$job_id || !$queue_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing Parameters"));
}
// verify that the three numbers above match
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
CRM_Core_Error::fatal(ts("There was an error in your request"));
}
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
$this->assign('display_name', $displayName);
$emailMasked = CRM_Utils_String::maskEmail($email);
$this->assign('email_masked', $emailMasked);
$this->assign('email', $email);
$this->_email = $email;
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
$this->assign('groups', $groups);
$groupExist = NULL;
foreach ($groups as $key => $value) {
if ($value) {
$groupExist = TRUE;
}
}
if (!$groupExist) {
$statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', array(1 => $email));
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
}
$this->assign('groupExist', $groupExist);
}
示例8: preProcess
static function preProcess(&$form)
{
if (!$form->get('page_id')) {
CRM_Core_Error::fatal(ts("Can't determine pcp id."));
}
$form->assign('component_page_id', $form->get('component_page_id'));
}
示例9: run
/**
* Perform an upgrade without using the web-frontend
*
* @param bool $enablePrint
*
* @throws Exception
* @return array, with keys:
* - message: string, HTML-ish blob
*/
public function run($enablePrint = TRUE)
{
// lets get around the time limit issue if possible for upgrades
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
$upgrade = new CRM_Upgrade_Form();
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
throw new Exception($error);
}
// Disable our SQL triggers
CRM_Core_DAO::dropTriggers();
// CRM-11156
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
$postUpgradeMessageFile = CRM_Utils_File::tempnam('civicrm-post-upgrade');
$queueRunner = new CRM_Queue_Runner(array('title' => ts('CiviCRM Upgrade Tasks'), 'queue' => CRM_Upgrade_Form::buildQueue($currentVer, $latestVer, $postUpgradeMessageFile)));
$queueResult = $queueRunner->runAll();
if ($queueResult !== TRUE) {
$errorMessage = CRM_Core_Error::formatTextException($queueResult['exception']);
CRM_Core_Error::debug_log_message($errorMessage);
if ($enablePrint) {
print $errorMessage;
}
throw $queueResult['exception'];
// FIXME test
}
CRM_Upgrade_Form::doFinish();
$message = file_get_contents($postUpgradeMessageFile);
return array('latestVer' => $latestVer, 'message' => $message, 'text' => CRM_Utils_String::htmlToText($message));
}
示例10: __construct
/**
* @param $formValues
*
* @throws Exception
*/
public function __construct(&$formValues)
{
parent::__construct($formValues);
// unset search profile and other search params if set
unset($this->_formValues['uf_group_id']);
unset($this->_formValues['component_mode']);
unset($this->_formValues['operator']);
if (!empty($this->_formValues)) {
// add the country and state
if (!empty($this->_formValues['country_id'])) {
$this->_formValues['country'] = CRM_Core_PseudoConstant::country($this->_formValues['country_id']);
}
if (!empty($this->_formValues['state_province_id'])) {
$this->_formValues['state_province'] = CRM_Core_PseudoConstant::stateProvince($this->_formValues['state_province_id']);
}
// use the address to get the latitude and longitude
CRM_Utils_Geocode_Google::format($this->_formValues);
if (!is_numeric(CRM_Utils_Array::value('geo_code_1', $this->_formValues)) || !is_numeric(CRM_Utils_Array::value('geo_code_2', $this->_formValues)) || !isset($this->_formValues['distance'])) {
CRM_Core_Error::fatal(ts('Could not geocode input'));
}
$this->_latitude = $this->_formValues['geo_code_1'];
$this->_longitude = $this->_formValues['geo_code_2'];
if ($this->_formValues['prox_distance_unit'] == "miles") {
$conversionFactor = 1609.344;
} else {
$conversionFactor = 1000;
}
$this->_distance = $this->_formValues['distance'] * $conversionFactor;
}
$this->_group = CRM_Utils_Array::value('group', $this->_formValues);
$this->_tag = CRM_Utils_Array::value('tag', $this->_formValues);
$this->_columns = array(ts('Name') => 'sort_name', ts('Street Address') => 'street_address', ts('City') => 'city', ts('Postal Code') => 'postal_code', ts('State') => 'state_province', ts('Country') => 'country');
}
示例11: fetch
/**
* Download the remote zipfile.
*
* @param string $remoteFile URL of a .zip file
* @param string $localFile path at which to store the .zip file
* @return STATUS_OK|STATUS_WRITE_ERROR|STATUS_DL_ERROR
*/
public function fetch($remoteFile, $localFile)
{
// Download extension zip file ...
if (!function_exists('curl_init')) {
CRM_Core_Error::fatal('Cannot install this extension - curl is not installed!');
}
list($ch, $caConfig) = $this->createCurl($remoteFile);
if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
}
$fp = @fopen($localFile, "w");
if (!$fp) {
CRM_Core_Session::setStatus(ts('Unable to write to %1.<br />Is the location writable?', array(1 => $localFile)), ts('Write Error'), 'error');
return self::STATUS_WRITE_ERROR;
}
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
if (curl_errno($ch)) {
CRM_Core_Session::setStatus(ts('Unable to download extension from %1. Error Message: %2', array(1 => $remoteFile, 2 => curl_error($ch))), ts('Download Error'), 'error');
return self::STATUS_DL_ERROR;
} else {
curl_close($ch);
}
fclose($fp);
return self::STATUS_OK;
}
示例12: __construct
/**
* @param object $controller
* @param const|int $action
*/
public function __construct($controller, $action = CRM_Core_Action::NONE)
{
parent::__construct($controller, $action);
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$cart->load_associations();
if ($cart->is_empty()) {
CRM_Core_Error::statusBounce(ts("You don't have any events in you cart. Please add some events."), CRM_Utils_System::url('civicrm/event'));
}
$pages = array();
$is_monetary = FALSE;
$is_conference = FALSE;
foreach ($cart->events_in_carts as $event_in_cart) {
if ($event_in_cart->event->is_monetary) {
$is_monetary = TRUE;
}
}
$pages["CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices"] = NULL;
foreach ($cart->events_in_carts as $event_in_cart) {
if ($event_in_cart->is_parent_event()) {
foreach ($event_in_cart->participants as $participant) {
$pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = array('className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents', 'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}");
}
}
}
$pages["CRM_Event_Cart_Form_Checkout_Payment"] = NULL;
$pages["CRM_Event_Cart_Form_Checkout_ThankYou"] = NULL;
$this->addSequentialPages($pages, $action);
}
示例13: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
// reset action from the session
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
$rcid = $rcid ? "&id={$rcid}" : '';
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
if ($this->_contactId) {
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $this->_contactId;
if (!$contact->find(TRUE)) {
CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
}
$this->_contactType = $contact->contact_type;
// check for permissions
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
}
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
} else {
CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
}
}
示例14: preProcess
/**
* TODO: How many checks do we need to do? Should we check to make sure the
* activity is the right type? That the cid and aid are associated? Seems like
* if you are messing with URL params you are kind of asking for trouble...
*/
function preProcess()
{
$this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE);
$this->_cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
$this->_vid = CRM_Utils_Request::retrieve('vid', 'Positive', $this, FALSE);
if (!CRM_Volunteer_Permission::checkProjectPerms(CRM_Core_Action::UPDATE, $this->_vid)) {
CRM_Utils_System::permissionDenied();
}
if (!$this->_aid && !($this->_cid && $this->_vid)) {
CRM_Core_Error::fatal("Form expects an activity ID or both a contact and a volunteer project ID.");
}
$check = array('Activity' => $this->_aid, 'Contact' => $this->_cid, 'VolunteerProject' => $this->_vid);
$errors = array();
foreach ($check as $entityType => $entityID) {
if (!$this->entityExists($entityType, $entityID)) {
$errors[] = "No {$entityType} with ID {$entityID} exists.";
}
}
if (count($errors)) {
CRM_Core_Error::fatal("Invalid parameter(s) passed to commendation form: " . implode(' ', $errors));
}
$contact_display_name = civicrm_api3('Contact', 'getvalue', array('id' => $this->_cid, 'return' => 'display_name'));
CRM_Utils_System::setTitle(ts('Commend %1', array(1 => $contact_display_name, 'domain' => 'org.civicrm.volunteer')));
parent::preProcess();
}
示例15: __construct
function __construct(&$formValues)
{
parent::__construct($formValues);
$this->_earthFlattening = 1.0 / 298.257223563;
$this->_earthRadiusSemiMajor = 6378137.0;
$this->_earthRadiusSemiMinor = $this->_earthRadiusSemiMajor * (1.0 - $this->_earthFlattening);
$this->_earthEccentricitySQ = 2 * $this->_earthFlattening - pow($this->_earthFlattening, 2);
// unset search profile if set
unset($this->_formValues['uf_group_id']);
if (!empty($this->_formValues)) {
// add the country and state
if (CRM_Utils_Array::value('country_id', $this->_formValues)) {
$this->_formValues['country'] = CRM_Core_PseudoConstant::country($this->_formValues['country_id']);
}
if (CRM_Utils_Array::value('state_province_id', $this->_formValues)) {
$this->_formValues['state_province'] = CRM_Core_PseudoConstant::stateProvince($this->_formValues['state_province_id']);
}
// use the address to get the latitude and longitude
require_once 'CRM/Utils/Geocode/Google.php';
CRM_Utils_Geocode_Google::format($this->_formValues);
if (!isset($this->_formValues['geo_code_1']) || !isset($this->_formValues['geo_code_2']) || !isset($this->_formValues['distance'])) {
CRM_Core_Error::fatal(ts('Could not geocode input'));
}
$this->_latitude = $this->_formValues['geo_code_1'];
$this->_longitude = $this->_formValues['geo_code_2'];
$this->_distance = $this->_formValues['distance'] * 1000;
}
$this->_earthDistanceSQL = $this->earthDistanceSQL($this->_latitude, $this->_longitude);
$this->_tag = CRM_Utils_Array::value('tag', $this->_formValues);
$this->_columns = array(ts('Name') => 'sort_name', ts('Street Address') => 'street_address', ts('City') => 'city', ts('Postal Code') => 'postal_code', ts('State') => 'state_province', ts('Country') => 'country');
}