3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class generates form components
20 * for previewing Civicrm Profile Group
22 class CRM_UF_Form_Inline_Preview
extends CRM_UF_Form_AbstractPreview
{
25 * Pre processing work done here.
27 * gets session variables for group or field id
29 public function preProcess() {
30 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
31 // CRM_Core_Controller validates qfKey for POST requests, but not necessarily
32 // for GET requests. Allowing GET would therefore be CSRF vulnerability.
33 CRM_Core_Error
::fatal(ts('Preview only supports HTTP POST'));
35 // Inline forms don't get menu-level permission checks
39 'manage event profiles',
42 if (!CRM_Core_Permission
::check($checkPermission)) {
43 CRM_Core_Error
::statusBounce(ts('Permission Denied'));
45 $content = json_decode($_REQUEST['ufData'], TRUE);
46 foreach (['ufGroup', 'ufFieldCollection'] as $key) {
47 if (!is_array($content[$key])) {
48 CRM_Core_Error
::fatal("Missing JSON parameter, $key");
51 //echo '<pre>'.htmlentities(var_export($content, TRUE)) .'</pre>';
52 //CRM_Utils_System::civiExit();
53 $fields = CRM_Core_BAO_UFGroup
::formatUFFields($content['ufGroup'], $content['ufFieldCollection']);
54 //$fields = CRM_Core_BAO_UFGroup::getFields(1);
55 $this->setProfile($fields);
56 //echo '<pre>'.htmlentities(var_export($fields, TRUE)) .'</pre>';CRM_Utils_System::civiExit();