本文整理汇总了PHP中Civi::settings方法的典型用法代码示例。如果您正苦于以下问题:PHP Civi::settings方法的具体用法?PHP Civi::settings怎么用?PHP Civi::settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Civi
的用法示例。
在下文中一共展示了Civi::settings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* @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);
}
示例2: setPreUpgradeMessage
/**
* 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".');
}
}
示例3: preProcess
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'));
}
示例4: addAttachment
/**
* 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;
}
示例5: singleton
/**
* @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;
}
示例6: 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;
}
示例7: preProcess
/**
* 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);
}
}
示例8: checkOutboundMail
/**
* @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;
}
示例9: singleton
/**
* @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;
}
示例10: setDefaultValues
/**
* 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;
}
示例11: gettingStartedUrl
/**
* 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);
}
示例12: run
/**
* 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();
}
示例13: getProviderClass
/**
* @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 '';
}
}
示例14: createStreamOpts
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;
}
示例15: __construct
/**
* @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;
}
}