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


PHP CRM_Core_Page_AJAX::checkAuthz方法代码示例

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


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

示例1: testCheckAuthz

 public function testCheckAuthz()
 {
     $cases = array();
     $cases[] = array('method', 'CRM_Foo', FALSE, 'method');
     $cases[] = array('method', 'CRM_Foo_Page_AJAX_Bar', FALSE, 'method');
     $cases[] = array('method', 'CRM_Contact_Page_AJAX', TRUE, 'getAddressDisplay');
     $cases[] = array('method', 'CRM_Foo_Page_AJAX', FALSE, 'method(');
     $cases[] = array('method', 'CRM_Foo_Page_AJAX', FALSE, 'method()');
     $cases[] = array('method', 'othermethod;CRM_Foo_Page_AJAX', FALSE, 'method');
     $cases[] = array('method', 'CRM_Foo_Page_AJAX;othermethod', FALSE, 'method');
     $cases[] = array('method', 'CRM_Foo_Page_Inline_Bar', FALSE, '');
     $cases[] = array('method', 'CRM_Foo_Page_Inline_Bar', FALSE, 'method');
     $cases[] = array('method', 'CRM_Foo->method', FALSE);
     $cases[] = array('page', 'CRM_Foo', FALSE);
     $cases[] = array('page', 'CRM_Foo_Bar', FALSE);
     $cases[] = array('page', 'CRM_Foo_Page', FALSE);
     $cases[] = array('page', 'CRM_Foo_Page_Bar', FALSE);
     $cases[] = array('page', 'CRM_Foo_Page_Inline', FALSE);
     $cases[] = array('page', 'CRM_Contact_Page_Inline_CommunicationPreferences', TRUE);
     $cases[] = array('page', 'CRM_Foo_Page_Inline_Bar_Bang', FALSE);
     $cases[] = array('page', 'othermethod;CRM_Foo_Page_Inline_Bar', FALSE);
     $cases[] = array('page', 'CRM_Foo_Page_Inline_Bar;othermethod', FALSE);
     $cases[] = array('page', 'CRM_Foo_Form', FALSE);
     $cases[] = array('page', 'CRM_Foo_Form_Bar', FALSE);
     $cases[] = array('page', 'CRM_Foo_Form_Inline', FALSE);
     $cases[] = array('page', 'CRM_Contact_Form_Inline_Email', TRUE);
     $cases[] = array('page', 'CRM_Foo_Form_Inline_Bar_Bang', FALSE);
     $cases[] = array('page', 'othermethod;CRM_Foo_Form_Inline_Bar', FALSE);
     $cases[] = array('page', 'CRM_Foo_Form_Inline_Bar;othermethod', FALSE);
     // aliases for 'page'
     $cases[] = array('class', 'CRM_Foo_Bar', FALSE);
     $cases[] = array('class', 'CRM_Contact_Page_Inline_Phone', TRUE);
     $cases[] = array('', 'CRM_Foo_Bar', FALSE);
     $cases[] = array('', 'CRM_Contact_Page_Inline_Demographics', TRUE);
     // invalid type
     $cases[] = array('invalidtype', 'CRM_Foo_Page_Inline_Bar', FALSE);
     $cases[] = array('invalidtype', 'CRM_Foo_Page_AJAX::method', FALSE);
     foreach ($cases as $case) {
         list($type, $className, $expectedResult) = $case;
         $methodName = CRM_Utils_Array::value(3, $case);
         $actualResult = CRM_Core_Page_AJAX::checkAuthz($type, $className, $methodName);
         if ($methodName) {
             $this->assertEquals($expectedResult, $actualResult, sprintf('Check type=[%s] value=[%s] method=[%s]', $type, $className, $methodName));
         } else {
             $this->assertEquals($expectedResult, $actualResult, sprintf('Check type=[%s] value=[%s]', $type, $className));
         }
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:48,代码来源:AJAXTest.php

示例2: process

 /**
  * @param $args
  * @param array $params
  *
  * @return array|int
  */
 public static function process(&$args, $params)
 {
     $params['check_permissions'] = TRUE;
     $fnName = $apiFile = NULL;
     // clean up all function / class names. they should be alphanumeric and _ only
     for ($i = 1; $i <= 3; $i++) {
         if (!empty($args[$i])) {
             $args[$i] = CRM_Utils_String::munge($args[$i]);
         }
     }
     // incase of ajax functions className is passed in url
     if (isset($params['className'])) {
         $params['className'] = CRM_Utils_String::munge($params['className']);
         // functions that are defined only in AJAX.php can be called via
         // rest interface
         if (!CRM_Core_Page_AJAX::checkAuthz('method', $params['className'], $params['fnName'])) {
             return self::error('Unknown function invocation.');
         }
         return call_user_func(array($params['className'], $params['fnName']), $params);
     }
     if (!array_key_exists('version', $params)) {
         $params['version'] = 3;
     }
     if ($params['version'] == 2) {
         $result['is_error'] = 1;
         $result['error_message'] = "FATAL: API v2 not accessible from ajax/REST";
         $result['deprecated'] = "Please upgrade to API v3";
         return $result;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'GET' && strtolower(substr($args[2], 0, 3)) != 'get' && strtolower($args[2] != 'check')) {
         // get only valid for non destructive methods
         require_once 'api/v3/utils.php';
         return civicrm_api3_create_error("SECURITY: All requests that modify the database must be http POST, not GET.", array('IP' => $_SERVER['REMOTE_ADDR'], 'level' => 'security', 'referer' => $_SERVER['HTTP_REFERER'], 'reason' => 'Destructive HTTP GET'));
     }
     // trap all fatal errors
     $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal'));
     $result = civicrm_api($args[1], $args[2], $params);
     unset($errorScope);
     if ($result === FALSE) {
         return self::error('Unknown error.');
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:49,代码来源:REST.php


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