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


PHP CRM_Core_Page_AJAX类代码示例

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


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

示例1: getGroupList

 /**
  * Get list of groups.
  */
 public static function getGroupList()
 {
     $params = $_GET;
     if (isset($params['parent_id'])) {
         // requesting child groups for a given parent
         $params['page'] = 1;
         $params['rp'] = 0;
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         CRM_Utils_JSON::output($groups);
     } else {
         $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
         $optionalParameters = array('parentsOnly' => 'Integer', 'showOrgInfo' => 'Boolean');
         $params += CRM_Core_Page_AJAX::validateParams(array(), $optionalParameters);
         // get group list
         $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
         // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
         // go ahead with flat hierarchy, CRM-12225
         if (empty($groups)) {
             $groupsAccessible = CRM_Core_PseudoConstant::group();
             $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
             if (!empty($groupsAccessible) && $parentsOnly) {
                 // recompute group list with flat hierarchy
                 $params['parentsOnly'] = 0;
                 $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
             }
         }
         CRM_Utils_JSON::output($groups);
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:32,代码来源:AJAX.php

示例2: getContactList

 /**
  * @deprecated
  */
 static function getContactList()
 {
     // if context is 'customfield'
     if (CRM_Utils_Array::value('context', $_GET) == 'customfield') {
         return self::contactReference();
     }
     $params = array('version' => 3, 'check_permissions' => TRUE);
     // String params
     // FIXME: param keys don't match input keys, using this array to translate
     $whitelist = array('s' => 'name', 'fieldName' => 'field_name', 'tableName' => 'table_name', 'context' => 'context', 'rel' => 'rel', 'contact_sub_type' => 'contact_sub_type', 'contact_type' => 'contact_type');
     foreach ($whitelist as $key => $param) {
         if (!empty($_GET[$key])) {
             $params[$param] = $_GET[$key];
         }
     }
     //CRM-10687: Allow quicksearch by multiple fields
     if (!empty($params['field_name'])) {
         if ($params['field_name'] == 'phone_numeric') {
             $params['name'] = preg_replace('/[^\\d]/', '', $params['name']);
         }
         if (!$params['name']) {
             CRM_Utils_System::civiExit();
         }
     }
     // Numeric params
     $whitelist = array('limit', 'org', 'employee_id', 'cid', 'id', 'cmsuser');
     foreach ($whitelist as $key) {
         if (!empty($_GET[$key]) && is_numeric($_GET[$key])) {
             $params[$key] = $_GET[$key];
         }
     }
     $result = civicrm_api('Contact', 'getquick', $params);
     CRM_Core_Page_AJAX::autocompleteResults(CRM_Utils_Array::value('values', $result), 'data');
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:37,代码来源:AJAX.php

示例3: getContactMailings

 /**
  * Retrieve contact mailings.
  */
 public static function getContactMailings()
 {
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
     $params += CRM_Core_Page_AJAX::validateParams(array('contact_id' => 'Integer'));
     // get the contact mailings
     $mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params);
     CRM_Utils_JSON::output($mailings);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:11,代码来源:AJAX.php

示例4: getNavigationMenu

 public static function getNavigationMenu()
 {
     $contactID = CRM_Core_Session::singleton()->get('userID');
     if ($contactID) {
         CRM_Core_Page_AJAX::setJsHeaders();
         print CRM_Core_Smarty::singleton()->fetchWith('CRM/Menufontawesome/Page/navigation.js.tpl', array('navigation' => CRM_Menufontawesome_BAO_Navigation::createNavigation($contactID)));
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:omarabuhussein,项目名称:com.opetmar.menufontawesome,代码行数:9,代码来源:AJAX.php

示例5: getSoftContributionRows

 /**
  * Get Soft credit to list in DT
  */
 public static function getSoftContributionRows()
 {
     $requiredParameters = array('cid' => 'Integer', 'context' => 'String');
     $optionalParameters = array('entityID' => 'Integer', 'isTest' => 'Integer');
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
     $params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters);
     $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionSelector($params);
     if (!empty($_GET['is_unit_test'])) {
         return $softCreditList;
     }
     CRM_Utils_JSON::output($softCreditList);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:15,代码来源:AJAX.php

示例6: 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

示例7: preProcess

 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     if ($this->_id) {
         $params = array('id' => $this->_id);
         $financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, CRM_Core_DAO::$_nullArray);
         $financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
         if ($financialAccount->financial_account_type_id == array_search('Asset', $financialAccountType) && strtolower($financialAccount->account_type_code) == 'ar' && !CRM_Financial_BAO_FinancialAccount::getARAccounts($this->_id, array_search('Asset', $financialAccountType))) {
             $this->_isARFlag = TRUE;
             if ($this->_action & CRM_Core_Action::DELETE) {
                 $msg = ts("The selected financial account cannot be deleted because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance).");
                 if (CRM_Utils_Array::value('snippet', $_REQUEST) == 'json') {
                     CRM_Core_Page_AJAX::returnJsonResponse($msg);
                 }
                 CRM_Core_Session::setStatus($msg, '', 'error');
                 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse"));
             }
         }
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:26,代码来源:FinancialAccount.php

示例8: redirect

 /**
  * Redirect to another URL.
  *
  * @param string $url
  *   The URL to provide to the browser via the Location header.
  */
 public static function redirect($url = NULL)
 {
     if (!$url) {
         $url = self::url('civicrm/dashboard', 'reset=1');
     }
     // replace the & characters with &
     // this is kinda hackish but not sure how to do it right
     $url = str_replace('&', '&', $url);
     // If we are in a json context, respond appropriately
     if (CRM_Utils_Array::value('snippet', $_GET) === 'json') {
         CRM_Core_Page_AJAX::returnJsonResponse(array('status' => 'redirect', 'userContext' => $url));
     }
     self::setHttpHeader('Location', $url);
     self::civiExit();
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:21,代码来源:System.php

示例9: renderForm

 /**
  * Render the page using a custom templating system.
  *
  * @param CRM_Core_Form $page
  *   The CRM_Core_Form page.
  */
 public function renderForm(&$page)
 {
     $this->_setRenderTemplates($page);
     $template = CRM_Core_Smarty::singleton();
     $form = $page->toSmarty();
     // Deprecated - use snippet=6 instead of json=1
     $json = CRM_Utils_Request::retrieve('json', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($json) {
         CRM_Utils_JSON::output($form);
     }
     $template->assign('form', $form);
     $template->assign('isForm', 1);
     $controller =& $page->controller;
     // Stop here if we are in embedded mode. Exception: displaying form errors via ajax
     if ($controller->getEmbedded() && !(!empty($form['errors']) && $controller->_QFResponseType == 'json')) {
         return;
     }
     $template->assign('action', $page->getAction());
     $pageTemplateFile = $page->getHookedTemplateFileName();
     $template->assign('tplFile', $pageTemplateFile);
     $content = $template->fetch($controller->getTemplateFile());
     if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
         CRM_Utils_System::addHTMLHead($region->render(''));
     }
     CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $page->overrideExtraTemplateFileName());
     //its time to call the hook.
     CRM_Utils_Hook::alterContent($content, 'form', $pageTemplateFile, $page);
     $print = $controller->getPrint();
     if ($print) {
         $html =& $content;
     } else {
         $html = CRM_Utils_System::theme($content, $print);
     }
     if ($controller->_QFResponseType == 'json') {
         $response = array('content' => $html);
         if (!empty($page->ajaxResponse)) {
             $response += $page->ajaxResponse;
         }
         if (!empty($form['errors'])) {
             $response['status'] = 'form_error';
             $response['errors'] = $form['errors'];
         }
         CRM_Core_Page_AJAX::returnJsonResponse($response);
     }
     if ($print) {
         if ($print == CRM_Core_Smarty::PRINT_PDF) {
             CRM_Utils_PDF_Utils::html2pdf($content, "{$page->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape'));
         } else {
             echo $html;
         }
         CRM_Utils_System::civiExit();
     }
     print $html;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:60,代码来源:Display.php

示例10: caseDetails

 /**
  * @throws \CiviCRM_API3_Exception
  */
 public function caseDetails()
 {
     $caseId = CRM_Utils_Type::escape($_GET['caseId'], 'Positive');
     $case = civicrm_api3('Case', 'getsingle', array('id' => $caseId, 'check_permissions' => TRUE, 'return' => array('subject', 'case_type_id', 'status_id', 'start_date', 'end_date')));
     $caseStatuses = CRM_Case_PseudoConstant::caseStatus();
     $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
     $caseDetails = "<table><tr><td>" . ts('Case Subject') . "</td><td>{$case['subject']}</td></tr>\n                                  <tr><td>" . ts('Case Type') . "</td><td>{$caseTypes[$case['case_type_id']]}</td></tr>\n                                  <tr><td>" . ts('Case Status') . "</td><td>{$caseStatuses[$case['status_id']]}</td></tr>\n                                  <tr><td>" . ts('Case Start Date') . "</td><td>" . CRM_Utils_Date::customFormat($case['start_date']) . "</td></tr>\n                                  <tr><td>" . ts('Case End Date') . "</td><td></td></tr>" . CRM_Utils_Date::customFormat($case['end_date']) . "</table>";
     if (CRM_Utils_Array::value('snippet', $_GET) == 'json') {
         CRM_Core_Page_AJAX::returnJsonResponse($caseDetails);
     }
     echo $caseDetails;
     CRM_Utils_System::civiExit();
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:16,代码来源:AJAX.php

示例11: statusBounce

 /**
  * Set a status message in the session, then bounce back to the referrer.
  *
  * @param string $status
  *   The status message to set.
  *
  * @param null $redirect
  * @param string $title
  * @return void
  */
 public static function statusBounce($status, $redirect = NULL, $title = NULL)
 {
     $session = CRM_Core_Session::singleton();
     if (!$redirect) {
         $redirect = $session->readUserContext();
     }
     if ($title === NULL) {
         $title = ts('Error');
     }
     $session->setStatus($status, $title, 'alert', array('expires' => 0));
     if (CRM_Utils_Array::value('snippet', $_REQUEST) === CRM_Core_Smarty::PRINT_JSON) {
         CRM_Core_Page_AJAX::returnJsonResponse(array('status' => 'error'));
     }
     CRM_Utils_System::redirect($redirect);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:25,代码来源:Error.php

示例12: outputLocalizationJS

 /**
  * Create dynamic script for localizing js widgets.
  */
 public static function outputLocalizationJS()
 {
     CRM_Core_Page_AJAX::setJsHeaders();
     $config = CRM_Core_Config::singleton();
     $vars = array('moneyFormat' => json_encode(CRM_Utils_Money::format(1234.56)), 'contactSearch' => json_encode($config->includeEmailInName ? ts('Start typing a name or email...') : ts('Start typing a name...')), 'otherSearch' => json_encode(ts('Enter search term...')), 'entityRef' => array('contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks(), 'filters' => self::getEntityRefFilters()), 'ajaxPopupsEnabled' => self::singleton()->ajaxPopupsEnabled);
     print CRM_Core_Smarty::singleton()->fetchWith('CRM/common/l10n.js.tpl', $vars);
     CRM_Utils_System::civiExit();
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:11,代码来源:Resources.php

示例13: getPermissionedEmployer

 /**
  * Function to obtain list of permissioned employer for the given contact-id.
  */
 static function getPermissionedEmployer()
 {
     $cid = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
     $name = str_replace('*', '%', $name);
     $elements = CRM_Contact_BAO_Relationship::getPermissionedEmployer($cid, $name);
     $results = array();
     if (!empty($elements)) {
         foreach ($elements as $cid => $name) {
             $results[$cid] = $name['name'];
         }
     }
     CRM_Core_Page_AJAX::autocompleteResults($results);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:17,代码来源:AJAX.php

示例14: mainProcess

 /**
  * just a wrapper, so that we can call all the hook functions
  * @param bool $allowAjax
  *   FIXME: This feels kind of hackish, ideally we would take the json-related code from this function.
  *                          and bury it deeper down in the controller
  */
 public function mainProcess($allowAjax = TRUE)
 {
     $this->postProcess();
     $this->postProcessHook();
     // Respond with JSON if in AJAX context (also support legacy value '6')
     if ($allowAjax && !empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], array(CRM_Core_Smarty::PRINT_JSON, 6))) {
         $this->ajaxResponse['buttonName'] = str_replace('_qf_' . $this->getAttribute('id') . '_', '', $this->controller->getButtonName());
         $this->ajaxResponse['action'] = $this->_action;
         if (isset($this->_id) || isset($this->id)) {
             $this->ajaxResponse['id'] = isset($this->id) ? $this->id : $this->_id;
         }
         CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse);
     }
 }
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:20,代码来源:Form.php

示例15: json_encode

| GNU Affero General Public License or the licensing of CiviCRM,     |
| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+--------------------------------------------------------------------+
*/
/**
 *
 * @package CRM
 * @copyright CiviCRM LLC (c) 2004-2015
 * $Id$
 */
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
$template = CRM_Core_Smarty::singleton();
require_once 'CRM/Utils/Request.php';
$cpageId = CRM_Utils_Request::retrieve('cpageId', 'Positive', CRM_Core_DAO::$_nullObject);
$widgetId = CRM_Utils_Request::retrieve('widgetId', 'Positive', CRM_Core_DAO::$_nullObject);
$format = CRM_Utils_Request::retrieve('format', 'Positive', CRM_Core_DAO::$_nullObject);
$includePending = CRM_Utils_Request::retrieve('includePending', 'Boolean', CRM_Core_DAO::$_nullObject);
require_once 'CRM/Contribute/BAO/Widget.php';
$jsonvar = 'jsondata';
if (isset($format)) {
    $jsonvar .= $cpageId;
}
$data = CRM_Contribute_BAO_Widget::getContributionPageData($cpageId, $widgetId, $includePending);
$output = '
    var ' . $jsonvar . ' = ' . json_encode($data) . ';
';
CRM_Core_Page_AJAX::setJsHeaders(60);
echo $output;
CRM_Utils_System::civiExit();
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:31,代码来源:widget.php


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