$className))); } $fnName = NULL; if (isset($_REQUEST['fn_name'])) { $fnName = CRM_Utils_Type::escape($_REQUEST['fn_name'], 'String'); } if (!self::checkAuthz($type, $className, $fnName)) { CRM_Utils_System::civiExit(); } switch ($type) { case 'method': call_user_func(array($className, $fnName)); break; case 'page': case 'class': case '': // FIXME: This is done to maintain current wire protocol, but it might be // simpler to just require different 'types' for pages and forms if (preg_match('/^CRM_[a-zA-Z0-9]+_Page_Inline_/', $className)) { $page = new $className; $page->run(); } else { $wrapper = new CRM_Utils_Wrapper(); $wrapper->run($className); } break; default: CRM_Core_Error::debug_log_message('Unsupported inline request type: ' . var_export($type, TRUE)); } CRM_Utils_System::civiExit(); } /** * function to change is_quick_config priceSet to complex * * @static * @access public */ static function setIsQuickConfig() { $id = $context = NULL; if (CRM_Utils_Array::value('id', $_REQUEST)) { $id = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer'); } if (CRM_Utils_Array::value('context', $_REQUEST)) { $context = CRM_Utils_Type::escape($_REQUEST['context'], 'String'); } // return false if $id is null and // $context is not civicrm_event or civicrm_contribution_page if (!$id || !in_array($context, array('civicrm_event', 'civicrm_contribution_page'))) { return false; } $priceSetId = CRM_Price_BAO_PriceSet::getFor($context, $id, NULL); if ($priceSetId) { $result = CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetId, 0); if ($context == 'civicrm_event') { $sql = "UPDATE civicrm_price_set cps INNER JOIN civicrm_discount cd ON cd.price_set_id = cps.id SET cps.is_quick_config = 0 WHERE cd.entity_id = (%1) AND cd.entity_table = 'civicrm_event' "; $params = array(1 => array($id, 'Integer')); CRM_Core_DAO::executeQuery($sql, $params); CRM_Core_BAO_Discount::del($id, $context); } } if (!$result) { $priceSetId = null; } echo json_encode($priceSetId); CRM_Utils_System::civiExit(); } /** * Determine whether the request is for a valid class/method name. * * @param string $type 'method'|'class'|'' * @param string $className 'Class_Name' * @param string $fnName method name */ static function checkAuthz($type, $className, $fnName = null) { switch ($type) { case 'method': if (!preg_match('/^CRM_[a-zA-Z0-9]+_Page_AJAX$/', $className)) { return FALSE; } if (!preg_match('/^[a-zA-Z0-9]+$/', $fnName)) { return FALSE; } // ensure that function exists return method_exists($className, $fnName); case 'page': case 'class': case '': if (!preg_match('/^CRM_[a-zA-Z0-9]+_(Page|Form)_Inline_[a-zA-Z0-9]+$/', $className)) { return FALSE; } return class_exists($className); default: return FALSE; } } }