本文整理汇总了PHP中CRM_Utils_System::loadBootStrap方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::loadBootStrap方法的具体用法?PHP CRM_Utils_System::loadBootStrap怎么用?PHP CRM_Utils_System::loadBootStrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::loadBootStrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
CRM_Core_Config::singleton(1, 1);
CRM_Utils_System::loadBootStrap(array('name' => $GLOBALS['_CV']['ADMIN_USER'], 'pass' => $GLOBALS['_CV']['ADMIN_PASS']));
CRM_Utils_System::synchronizeUsers();
parent::setUpBeforeClass();
}
示例2: run
function run()
{
session_start();
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config =& CRM_Core_Config::singleton();
// this does not return on failure
CRM_Utils_System::authenticateScript(true);
//log the execution of script
CRM_Core_Error::debug_log_message('civimail.cronjob.php');
// load bootstrap to call hooks
require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap();
// we now use DB locks on a per job basis
processQueue($config->mailerJobSize);
}
示例3: check
/**
* Given a permission string, check for access requirements
*
* @param string $str
* The permission to check.
*
* @return bool
* true if yes, else false
*/
public function check($str)
{
// Generic cms 'administer users' role tranlates to 'administrator' WordPress role
$str = $this->translatePermission($str, 'WordPress', array('administer users' => 'edit_users'));
if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
return FALSE;
}
if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
return TRUE;
}
// CRM-15629
// During some extern/* calls we don't bootstrap CMS hence
// below constants are not set. In such cases, we don't need to
// check permission, hence directly return TRUE
if (!defined('ABSPATH') || !defined('WPINC')) {
require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap();
}
require_once ABSPATH . WPINC . '/pluggable.php';
// for administrators give them all permissions
if (!function_exists('current_user_can')) {
return TRUE;
}
if (current_user_can('super admin') || current_user_can('administrator')) {
return TRUE;
}
// Make string lowercase and convert spaces into underscore
$str = CRM_Utils_String::munge(strtolower($str));
if (is_user_logged_in()) {
// Check whether the logged in user has the capabilitity
if (current_user_can($str)) {
return TRUE;
}
} else {
//check the capabilities of Anonymous user)
$roleObj = new WP_Roles();
if ($roleObj->get_role('anonymous_user') != NULL && array_key_exists($str, $roleObj->get_role('anonymous_user')->capabilities)) {
return TRUE;
}
}
return FALSE;
}
示例4: boot
protected function boot(InputInterface $input, OutputInterface $output)
{
if ($input->hasOption('test') && $input->getOption('test')) {
putenv('CIVICRM_UF=UnitTests');
$_ENV['CIVICRM_UF'] = 'UnitTests';
}
if ($input->hasOption('level') && $input->getOption('level') !== 'full') {
\Civi\Cv\Bootstrap::singleton()->boot(array('prefetch' => FALSE));
} else {
\Civi\Cv\Bootstrap::singleton()->boot();
\CRM_Core_Config::singleton();
\CRM_Utils_System::loadBootStrap(array(), FALSE);
if ($input->getOption('user')) {
if (is_callable(array(\CRM_Core_Config::singleton()->userSystem, 'loadUser'))) {
\CRM_Utils_System::loadUser($input->getOption('user'));
} else {
$output->writeln("<error>Failed to set user. Feature not supported by UF (" . CIVICRM_UF . ")</error>");
}
}
}
}
示例5: run
function run($argc, $argv)
{
global $debug;
session_start();
require_once '../civicrm.config.php';
require_once 'api/v2/Domain.php';
require_once 'api/v2/Group.php';
require_once 'api/v2/GroupNesting.php';
require_once 'api/v2/GroupOrganization.php';
require_once 'api/v2/Contact.php';
if ($argc < 3 || $argc > 4) {
#var_dump($argv);
print_usage($argv[0]);
exit(-1);
}
$org_name = $argv[1];
$org_desc = $argv[2];
$config = CRM_Core_Config::singleton();
//load bootstrap to call hooks
require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap();
# create the domain
$existing_domain = civicrm_domain_get();
$domain_params = array('name' => $org_name, 'description' => $org_desc, 'version' => $existing_domain['version']);
$domain = civicrm_domain_create($domain_params);
if ($debug) {
print "Create domain result: " . var_export($domain) . "\n";
}
$domain_id = $domain['id'];
# find the parent group, if necessary
if (!is_null($argv[3])) {
$parent_group_name = $argv[3];
$parent_group_params = array('title' => $parent_group_name);
$parent_groups = civicrm_group_get($parent_group_params);
if ($debug) {
print "Find parent group result: " . var_export($parent_groups) . "\n";
}
$parent_group_keys = array_keys($parent_groups);
$parent_group_id = $parent_group_keys[0];
}
# create the group
$group_params = array('title' => $org_name, 'description' => $org_desc, 'is_active' => 1);
$group = civicrm_group_add($group_params);
if ($debug) {
print "Create group result: " . var_export($group) . "\n";
}
$group_id = $group['result'];
# create the org nesting if necessary
if (!is_null($parent_group_id)) {
$group_nesting_params = array('parent_group_id' => $parent_group_id, 'child_group_id' => $group_id);
$group_nesting = civicrm_group_nesting_create($group_nesting_params);
if ($debug) {
print "Create group nesting result: " . var_export($group_nesting) . "\n";
}
}
# create the org contact
$org_params = array('organization_name' => $org_name, 'contact_type' => 'Organization');
$org = civicrm_contact_create($org_params);
if ($debug) {
print "Create org contact result: " . var_export($org) . "\n";
}
$org_id = $org['contact_id'];
# associate the two
$group_org_params = array('group_id' => $group_id, 'organization_id' => $org_id);
$group_org_id = civicrm_group_organization_create($group_org_params);
if ($debug) {
print "Create group-org association result: " . var_export($group_org_id) . "\n";
}
print "\n";
print "Add or modify the following lines in the appropriate ";
print "civicrm.settings.php file for {$org_name}:\n";
print "\tdefine( 'CIVICRM_DOMAIN_ID', {$domain_id} );\n";
print "\tdefine( 'CIVICRM_DOMAIN_GROUP_ID', {$group_id} );\n";
print "\tdefine( 'CIVICRM_DOMAIN_ORG_ID', {$org_id} );\n";
print "\n";
}
示例6: authenticate
/**
* @inheritDoc
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL)
{
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
$user = NULL;
if ($loadCMSBootstrap) {
$bootStrapParams = array();
if ($name && $password) {
$bootStrapParams = array('name' => $name, 'pass' => $password);
}
CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, FALSE);
}
jimport('joomla.application.component.helper');
jimport('joomla.database.table');
jimport('joomla.user.helper');
$JUserTable = JTable::getInstance('User', 'JTable');
$db = $JUserTable->getDbo();
$query = $db->getQuery(TRUE);
$query->select('id, name, username, email, password');
$query->from($JUserTable->getTableName());
$query->where('(LOWER(username) = LOWER(\'' . $name . '\')) AND (block = 0)');
$db->setQuery($query, 0, 0);
$users = $db->loadObjectList();
$row = array();
if (count($users)) {
$row = $users[0];
}
$joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));
if (!defined('JVERSION')) {
require $joomlaBase . '/libraries/cms/version/version.php';
$jversion = new JVersion();
define('JVERSION', $jversion->getShortVersion());
}
if (!empty($row)) {
$dbPassword = $row->password;
$dbId = $row->id;
$dbEmail = $row->email;
if (version_compare(JVERSION, '2.5.18', 'lt') || version_compare(JVERSION, '3.0', 'ge') && version_compare(JVERSION, '3.2.1', 'lt')) {
// now check password
list($hash, $salt) = explode(':', $dbPassword);
$cryptpass = md5($password . $salt);
if ($hash != $cryptpass) {
return FALSE;
}
} else {
if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) {
return FALSE;
}
//include additional files required by Joomla 3.2.1+
if (version_compare(JVERSION, '3.2.1', 'ge')) {
require_once $joomlaBase . '/libraries/cms/application/helper.php';
require_once $joomlaBase . '/libraries/cms/application/cms.php';
require_once $joomlaBase . '/libraries/cms/application/administrator.php';
}
}
CRM_Core_BAO_UFMatch::synchronizeUFMatch($row, $dbId, $dbEmail, 'Joomla');
$contactID = CRM_Core_BAO_UFMatch::getContactId($dbId);
if (!$contactID) {
return FALSE;
}
return array($contactID, $dbId, mt_rand());
}
return FALSE;
}
示例7: authenticate
function authenticate($user, $pass)
{
session_start();
require_once 'CRM/Core/Config.php';
$config =& CRM_Core_Config::singleton();
// this does not return on failure
// require_once 'CRM/Utils/System.php';
CRM_Utils_System::authenticateScript(true, $user, $pass);
// bootstrap CMS environment
global $civicrm_root;
$_SERVER['SCRIPT_FILENAME'] = "{$civicrm_root}/bin/cli.php";
require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap($user, $pass);
}
示例8: CRM_ProcessAuthorizeReport
function CRM_ProcessAuthorizeReport()
{
_civicrm_initialize();
$config = CRM_Core_Config::singleton();
//load bootstrap to call hooks
require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap();
$config->userFramework = 'Soap';
$config->userFrameworkClass = 'CRM_Utils_System_Soap';
$config->userHookClass = 'CRM_Utils_Hook_Soap';
if (!function_exists('imap_headers')) {
die('PHP IMAP extension required to use this script');
}
if (defined('_CRM_PROCESS_AUTHORIZE_REPORT_DEBUG')) {
$this->_debug = _CRM_PROCESS_AUTHORIZE_REPORT_DEBUG;
error_reporting(E_ALL);
ini_set('display_errors', true);
} else {
$this->_debug = false;
ini_set('display_errors', false);
}
}
示例9: authenticate
/**
* Authenticate the user against the drupal db
*
* @param string $name the user name
* @param string $password the password for the above user name
* @param boolean $loadCMSBootstrap load cms bootstrap?
* @param NULL|string $realPath filename of script
*
* @return mixed false if no auth
* array(
* contactID, ufID, unique string ) if success
* @access public
*/
static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL)
{
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
$dbDrupal = DB::connect($config->userFrameworkDSN);
if (DB::isError($dbDrupal)) {
CRM_Core_Error::fatal("Cannot connect to drupal db via {$config->userFrameworkDSN}, " . $dbDrupal->getMessage());
}
$account = $userUid = $userMail = NULL;
if ($loadCMSBootstrap) {
$bootStrapParams = array();
if ($name && $password) {
$bootStrapParams = array('name' => $name, 'pass' => $password);
}
CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
global $user;
if ($user) {
$userUid = $user->uid;
$userMail = $user->mail;
}
} else {
// CRM-8638
// SOAP cannot load drupal bootstrap and hence we do it the old way
// Contact CiviSMTP folks if we run into issues with this :)
$cmsPath = $config->userSystem->cmsRootPath($realPath);
require_once "{$cmsPath}/includes/bootstrap.inc";
require_once "{$cmsPath}/includes/password.inc";
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$name = $dbDrupal->escapeSimple($strtolower($name));
$sql = "\nSELECT u.*\nFROM {$config->userFrameworkUsersTableName} u\nWHERE LOWER(u.name) = '{$name}'\nAND u.status = 1\n";
$query = $dbDrupal->query($sql);
$row = $query->fetchRow(DB_FETCHMODE_ASSOC);
if ($row) {
$fakeDrupalAccount = drupal_anonymous_user();
$fakeDrupalAccount->name = $name;
$fakeDrupalAccount->pass = $row['pass'];
$passwordCheck = user_check_password($password, $fakeDrupalAccount);
if ($passwordCheck) {
$userUid = $row['uid'];
$userMail = $row['mail'];
}
}
}
if ($userUid && $userMail) {
CRM_Core_BAO_UFMatch::synchronizeUFMatch($account, $userUid, $userMail, 'Drupal');
$contactID = CRM_Core_BAO_UFMatch::getContactId($userUid);
if (!$contactID) {
return FALSE;
}
return array($contactID, $userUid, mt_rand());
}
return FALSE;
}
示例10: LLC
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
require_once '../civicrm.config.php';
$config = CRM_Core_Config::singleton();
CRM_Utils_System::loadBootStrap(array(), FALSE);
CRM_Cxn_BAO_Cxn::createApiServer()->handle(file_get_contents('php://input'))->send();
示例11: run
function run($supportedArgs, $context)
{
session_start();
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
// this does not return on failure
CRM_Utils_System::authenticateScript(true);
//log the execution of script
CRM_Core_Error::debug_log_message('Email2Activity.php');
// load bootstrap to call hooks
require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap();
$mailDir = MAIL_DIR_DEFAULT;
if (isset($_GET['mailDir'])) {
$mailDir = $_GET['mailDir'];
}
if ($mailDir == 'PUT YOUR MAIL DIR HERE') {
require_once 'CRM/Core/Error.php';
CRM_Core_Error::fatal();
}
if (array_key_exists('context', $_GET) && isset($supportedArgs[strtolower($_GET['context'])])) {
$context = $supportedArgs[strtolower($_GET['context'])];
}
$email = new bin_Email2Activity($mailDir, $context);
$email->run();
}
示例12: authenticate_wordpress
function authenticate_wordpress($config)
{
// make sure user has access to civicrm
CRM_Utils_System::loadBootStrap();
require_once "CRM/Core/Permission.php";
if (CRM_Core_Permission::check('access CiviCRM')) {
return true;
}
return false;
}
示例13: authenticate
/**
* Authenticate the user against the joomla db
*
* @param string $name the user name
* @param string $password the password for the above user name
* @param $loadCMSBootstrap boolean load cms bootstrap?
*
* @return mixed false if no auth
* array(
contactID, ufID, unique string ) if success
* @access public
*/
function authenticate($name, $password, $loadCMSBootstrap = FALSE)
{
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
if ($loadCMSBootstrap) {
$bootStrapParams = array();
if ($name && $password) {
$bootStrapParams = array('name' => $name, 'pass' => $password);
}
CRM_Utils_System::loadBootStrap($bootStrapParams);
}
jimport('joomla.application.component.helper');
jimport('joomla.database.table');
$JUserTable =& JTable::getInstance('User', 'JTable');
$db = $JUserTable->getDbo();
$query = $db->getQuery(TRUE);
$query->select('id, username, email, password');
$query->from($JUserTable->getTableName());
$query->where('(LOWER(username) = LOWER(\'' . $name . '\')) AND (block = 0)');
$db->setQuery($query, 0, 0);
$users = $db->loadAssocList();
$row = array();
if (count($users)) {
$row = $users[0];
}
$user = NULL;
if (!empty($row)) {
$dbPassword = CRM_Utils_Array::value('password', $row);
$dbId = CRM_Utils_Array::value('id', $row);
$dbEmail = CRM_Utils_Array::value('email', $row);
// now check password
if (strpos($dbPassword, ':') === FALSE) {
if ($dbPassword != md5($password)) {
return FALSE;
}
} else {
list($hash, $salt) = explode(':', $dbPassword);
$cryptpass = md5($password . $salt);
if ($hash != $cryptpass) {
return FALSE;
}
}
CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $dbId, $dbEmail, 'Joomla');
$contactID = CRM_Core_BAO_UFMatch::getContactId($dbId);
if (!$contactID) {
return FALSE;
}
return array($contactID, $dbId, mt_rand());
}
return FALSE;
}
示例14: authenticate
/**
* Authenticate the user against the drupal db
*
* @param string $name the user name
* @param string $password the password for the above user name
*
* @return mixed false if no auth
* array(
contactID, ufID, unique string ) if success
* @access public
*/
function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL)
{
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
$dbDrupal = DB::connect($config->userFrameworkDSN);
if (DB::isError($dbDrupal)) {
CRM_Core_Error::fatal("Cannot connect to drupal db via {$config->userFrameworkDSN}, " . $dbDrupal->getMessage());
}
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$dbpassword = md5($password);
$name = $dbDrupal->escapeSimple($strtolower($name));
$sql = 'SELECT u.* FROM ' . $config->userFrameworkUsersTableName . " u WHERE LOWER(u.name) = '{$name}' AND u.pass = '{$dbpassword}' AND u.status = 1";
$query = $dbDrupal->query($sql);
$user = NULL;
// need to change this to make sure we matched only one row
while ($row = $query->fetchRow(DB_FETCHMODE_ASSOC)) {
CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $row['uid'], $row['mail'], 'Drupal');
$contactID = CRM_Core_BAO_UFMatch::getContactId($row['uid']);
if (!$contactID) {
return FALSE;
} else {
//success
if ($loadCMSBootstrap) {
$bootStrapParams = array();
if ($name && $password) {
$bootStrapParams = array('name' => $name, 'pass' => $password);
}
CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
}
return array($contactID, $row['uid'], mt_rand());
}
}
return FALSE;
}
示例15: authenticate
/**
* @inheritDoc
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL)
{
//@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare
// if ever now.
// probably if bootstrap is loaded this call
// CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); would be
// sufficient to do what this fn does. It does exist as opposed to return which might need some hanky-panky to make
// safe in the unknown situation where authenticate might be called & it is important that
// false is returned
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
$dbDrupal = DB::connect($config->userFrameworkDSN);
if (DB::isError($dbDrupal)) {
CRM_Core_Error::fatal("Cannot connect to drupal db via {$config->userFrameworkDSN}, " . $dbDrupal->getMessage());
}
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$dbpassword = md5($password);
$name = $dbDrupal->escapeSimple($strtolower($name));
$userFrameworkUsersTableName = $this->getUsersTableName();
$sql = 'SELECT u.* FROM ' . $userFrameworkUsersTableName . " u WHERE LOWER(u.name) = '{$name}' AND u.pass = '{$dbpassword}' AND u.status = 1";
$query = $dbDrupal->query($sql);
$user = NULL;
// need to change this to make sure we matched only one row
while ($row = $query->fetchRow(DB_FETCHMODE_ASSOC)) {
CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $row['uid'], $row['mail'], 'Drupal');
$contactID = CRM_Core_BAO_UFMatch::getContactId($row['uid']);
if (!$contactID) {
return FALSE;
} else {
//success
if ($loadCMSBootstrap) {
$bootStrapParams = array();
if ($name && $password) {
$bootStrapParams = array('name' => $name, 'pass' => $password);
}
CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
}
return array($contactID, $row['uid'], mt_rand());
}
}
return FALSE;
}