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


PHP CRM_Utils_System::authenticateKey方法代码示例

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


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

示例1: run

 function run()
 {
     if (CRM_Utils_System::authenticateKey()) {
         $request_type = CRM_Utils_Request::retrieve('type', 'String');
         $request_data = CRM_Utils_Request::retrieve('data', 'String');
         $config = CRM_Core_Config::singleton();
         if ($config->debug) {
             $request_data_log = print_r($request_data, TRUE);
             CRM_Core_Error::debug_log_message("Mailchimp Webhook Request [{$request_type}]: \n{$request_data_log}");
         }
         $function_name = 'self::mailchimpWebhook' . ucwords($request_type);
         if (is_callable($function_name)) {
             // Set a canary to prevent CiviMailchimp hooks from firing, which
             // would trigger updates back to Mailchimp, resulting in an endless
             // loop.
             civimailchimp_static('mailchimp_do_not_run_hooks', TRUE);
             try {
                 call_user_func($function_name, $request_data);
             } catch (Exception $e) {
                 $error = array('code' => get_class($e), 'message' => $e->getMessage(), 'exception' => $e);
                 $message = "Mailchimp Webhook Request [{$request_type}]: {$error['code']}: {$error['message']}";
                 CRM_CiviMailchimp_BAO_SyncLog::saveMessage('error', 'mailchimp_to_civicrm', $message, $request_data);
                 CRM_Core_Error::debug_var('Fatal Error Details', $error);
                 CRM_Core_Error::backtrace('backTrace', TRUE);
                 throw $e;
             }
         }
     }
     parent::run();
 }
开发者ID:kbrownell,项目名称:com.giantrabbit.civimailchimp,代码行数:30,代码来源:Webhook.php

示例2: execute

 public function execute($auth = TRUE)
 {
     $this->logEntry('Starting scheduled jobs execution');
     if ($auth && !CRM_Utils_System::authenticateKey(TRUE)) {
         $this->logEntry('Could not authenticate the site key.');
     }
     require_once 'api/api.php';
     // it's not asynchronous at this stage
     foreach ($this->jobs as $job) {
         if ($job->is_active) {
             if ($job->needsRunning()) {
                 $this->executeJob($job);
             }
         }
     }
     $this->logEntry('Finishing scheduled jobs execution.');
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:17,代码来源:JobManager.php

示例3: execute

 /**
  * @param bool $auth
  */
 public function execute($auth = TRUE)
 {
     $this->logEntry('Starting scheduled jobs execution');
     if ($auth && !CRM_Utils_System::authenticateKey(TRUE)) {
         $this->logEntry('Could not authenticate the site key.');
     }
     require_once 'api/api.php';
     // it's not asynchronous at this stage
     CRM_Utils_Hook::cron($this);
     foreach ($this->jobs as $job) {
         if ($job->is_active) {
             if ($job->needsRunning()) {
                 $this->executeJob($job);
             }
         }
     }
     $this->logEntry('Finishing scheduled jobs execution.');
     // Set last cron date for the status check
     $statusPref = array('name' => 'checkLastCron', 'check_info' => gmdate('U'));
     CRM_Core_BAO_StatusPreference::create($statusPref);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:24,代码来源:JobManager.php

示例4: loadCMSBootstrap

 /**
  * @return array|NULL
  *   NULL if execution should proceed; array if the response is already known
  */
 public function loadCMSBootstrap()
 {
     $requestParams = CRM_Utils_Request::exportValues();
     $q = CRM_Utils_array::value('q', $requestParams);
     $args = explode('/', $q);
     // Proceed with bootstrap for "?entity=X&action=Y"
     // Proceed with bootstrap for "?q=civicrm/X/Y" but not "?q=civicrm/ping"
     if (!empty($q)) {
         if (count($args) == 2 && $args[1] == 'ping') {
             return NULL;
             // this is pretty wonky but maybe there's some reason I can't see
         }
         if (count($args) != 3) {
             return self::error('ERROR: Malformed REST path');
         }
         if ($args[0] != 'civicrm') {
             return self::error('ERROR: Malformed REST path');
         }
         // Therefore we have reasonably well-formed "?q=civicrm/X/Y"
     }
     if (!CRM_Utils_System::authenticateKey(FALSE)) {
         // FIXME: At time of writing, this doesn't actually do anything because
         // authenticateKey abends, but that's a bad behavior which sends a
         // malformed response.
         return self::error('Failed to authenticate key');
     }
     $uid = NULL;
     if (!$uid) {
         $store = NULL;
         $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
         if (empty($api_key)) {
             return self::error("FATAL: mandatory param 'api_key' (user key) missing");
         }
         $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
         if ($contact_id) {
             $uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
         }
     }
     if ($uid) {
         CRM_Utils_System::loadBootStrap(array('uid' => $uid), TRUE, FALSE);
         return NULL;
     } else {
         return self::error('ERROR: No CMS user associated with given api-key');
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:49,代码来源:REST.php

示例5: handle

    function handle( $config ) {
        
        // Get the function name being called from the q parameter in the query string
        $q = CRM_Utils_array::value( 'q', $_REQUEST );
        $args = explode( '/', $q );
        // If the function isn't in the civicrm namespace, reject the request.
        if ( $args[0] != 'civicrm' ) {
            return self::error( 'Unknown function invocation.' );
        }

        // If the query string is malformed, reject the request.
        if ( ( count( $args ) != 3 ) && ( $args[1] != 'login' ) && ( $args[1] != 'ping') ) {
            return self::error( 'Unknown function invocation.' );
        }

        // Everyone should be required to provide the server key, so the whole 
        //  interface can be disabled in more change to the configuration file.
        //  This used to be done in the authenticate function, but that was bad...trust me
        // first check for civicrm site key
        if ( ! CRM_Utils_System::authenticateKey( false ) ) {
            $docLink = CRM_Utils_System::docURL2( "Command-line Script Configuration", true );
            return self::error( 'Could not authenticate user, invalid site key. More info at: ' . $docLink );
        }
	
        require_once 'CRM/Utils/Request.php';

        $store = null;
        if ( $args[1] == 'login' ) {
            $name = CRM_Utils_Request::retrieve( 'name', 'String', $store, false, null, 'REQUEST' );
            $pass = CRM_Utils_Request::retrieve( 'pass', 'String', $store, false, null, 'REQUEST' );
            if ( empty( $name ) ||
                 empty( $pass ) ) {
                return self::error( 'Invalid name / password.' );
            }
            return self::authenticate( $name, $pass );
        } else if ($args[1] == 'ping' ) {
            return self::ping();
        }
	
        // At this point we know we are not calling either login or ping (neither of which 
        //  require authentication prior to being called.  Therefore, at this point we need
        //  to make sure we're working with a trusted user.
	
        // There are two ways to check for a trusted user:
        //  First: they can be someone that has a valid session currently
        //  Second: they can be someone that has provided an API_Key
	
        $valid_user = false;

        // Check for valid session.  Session ID's only appear here if you have
        // run the rest_api login function.  That might be a problem for the 
        // AJAX methods.  
        $session = CRM_Core_Session::singleton();
        if ($session->get('PHPSESSID') ) {
            $valid_user = true;
        }
	
        // If the user does not have a valid session (most likely to be used by people using
        // an ajax interface), we need to check to see if they are carring a valid user's 
        // secret key.
        if ( !$valid_user ) {
            require_once 'CRM/Core/DAO.php';
            $api_key = CRM_Utils_Request::retrieve( 'api_key', 'String', $store, false, null, 'REQUEST' );
            $valid_user = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
        }
	
        // If we didn't find a valid user either way, then die.
        if ( empty($valid_user) ) {
            return self::error("Valid session, or user api_key required");
        }

        return self::process( $args );
    }
开发者ID:ryanrd,项目名称:DW-Campaigns,代码行数:73,代码来源:REST.php

示例6: loadCMSBootstrap

 function loadCMSBootstrap()
 {
     $q = CRM_Utils_array::value('q', $_REQUEST);
     $args = explode('/', $q);
     // If the function isn't in the civicrm namespace or request
     // is for login or ping
     if (empty($args) || $args[0] != 'civicrm' || count($args) != 3 && $args[1] != 'login' && $args[1] != 'ping' || $args[1] == 'login' || $args[1] == 'ping') {
         return;
     }
     $uid = null;
     $session = CRM_Core_Session::singleton();
     if (!CRM_Utils_System::authenticateKey(false)) {
         return;
     }
     if ($session->get('PHPSESSID') && $session->get('cms_user_id')) {
         $uid = $session->get('cms_user_id');
     }
     if (!$uid) {
         require_once 'CRM/Core/DAO.php';
         require_once 'CRM/Utils/Request.php';
         $store = null;
         $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, false, null, 'REQUEST');
         $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
         if ($contact_id) {
             require_once 'CRM/Core/BAO/UFMatch.php';
             $uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
         }
     }
     if ($uid) {
         CRM_Utils_System::loadBootStrap(null, null, $uid);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:REST.php


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