本文整理汇总了PHP中CRM_Utils_Type::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Type::escape方法的具体用法?PHP CRM_Utils_Type::escape怎么用?PHP CRM_Utils_Type::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Type
的用法示例。
在下文中一共展示了CRM_Utils_Type::escape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: caseSubject
/**
* Function for Case Subject combo box
*/
function caseSubject(&$config)
{
require_once 'CRM/Utils/Type.php';
$whereclause = $caseIdClause = null;
if (isset($_GET['name'])) {
$name = CRM_Utils_Type::escape($_GET['name'], 'String');
$name = str_replace('*', '%', $name);
$whereclause = "civicrm_case.subject LIKE '%{$name}'";
}
if (isset($_GET['id'])) {
$caseId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
$caseIdClause = " AND civicrm_case.id = {$caseId}";
}
$elements = array();
if ($name || $caseIdClause) {
if (is_numeric($_GET['c'])) {
$contactID = CRM_Utils_Type::escape($_GET['c'], 'Integer');
if ($contactID) {
$clause = "civicrm_case_contact.contact_id = {$contactID}";
$whereclause = $whereclause ? $whereclause . " AND " . $clause : $clause;
}
}
$query = "\nSELECT distinct(civicrm_case.subject) as subject, civicrm_case.id as id\nFROM civicrm_case\nLEFT JOIN civicrm_case_contact ON civicrm_case_contact.case_id = civicrm_case.id\nWHERE {$whereclause} {$caseIdClause}\nORDER BY subject";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$elements[] = array('name' => $dao->subject, 'id' => $dao->id);
}
}
if (empty($elements)) {
$name = str_replace('%', '', $name);
$elements[] = array('name' => $name, 'id' => $name);
}
require_once "CRM/Utils/JSON.php";
echo CRM_Utils_JSON::encode($elements);
}
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!$this->_id && $this->_action & CRM_Core_Action::UPDATE) {
$this->_id = CRM_Utils_Type::escape($this->_id, 'Positive');
}
$url = CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$this->_aid}");
$this->_BAOName = 'CRM_Financial_BAO_FinancialTypeAccount';
if ($this->_aid && $this->_action & CRM_Core_Action::ADD) {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name');
CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Financial Accounts'));
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
// CRM-12492
if (!($this->_action & CRM_Core_Action::ADD)) {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$accountRelationship = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $this->_id, 'account_relationship');
if ($accountRelationship == $relationTypeId) {
$this->_isARFlag = TRUE;
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_Session::setStatus(ts("Selected financial type account with 'Accounts Receivable Account is' account relationship cannot be deleted."), '', 'error');
CRM_Utils_System::redirect($url);
}
}
}
if ($this->_id) {
$financialAccount = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $this->_id, 'financial_account_id');
$fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccount, 'name');
CRM_Utils_System::setTitle($fieldTitle . ' - ' . ts('Financial Type Accounts'));
}
$breadCrumb = array(array('title' => ts('Financial Type Accounts'), 'url' => $url));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
示例3: updateMode
public static function updateMode()
{
$finalResult = array();
if (CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)) {
$mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer');
$entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer');
$entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String');
if (!empty($_REQUEST['linkedEntityTable'])) {
$result = CRM_Core_BAO_RecurringEntity::updateModeLinkedEntity($entityId, $_REQUEST['linkedEntityTable'], $entityTable);
}
$dao = new CRM_Core_DAO_RecurringEntity();
if (!empty($result)) {
$dao->entity_id = $result['entityId'];
$dao->entity_table = $result['entityTable'];
} else {
$dao->entity_id = $entityId;
$dao->entity_table = $entityTable;
}
if ($dao->find(TRUE)) {
$dao->mode = $mode;
$dao->save();
$finalResult['status'] = 'Done';
} else {
$finalResult['status'] = 'Error';
}
}
CRM_Utils_JSON::output($finalResult);
}
示例4: getBatchList
/**
* Retrieve records.
*/
public static function getBatchList()
{
$sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => '');
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
$sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL;
$params = $_REQUEST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
if ($context != 'financialBatch') {
// data entry status batches
$params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
}
$params['context'] = $context;
// get batch list
$batches = CRM_Batch_BAO_Batch::getBatchListSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
if ($context == 'financialBatch') {
$selectorElements = array('check', 'batch_name', 'payment_instrument', 'item_count', 'total', 'status', 'created_by', 'links');
} else {
$selectorElements = array('batch_name', 'type', 'item_count', 'total', 'status', 'created_by', 'links');
}
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例5: getMemberTypeDefaults
/**
* Function to setDefaults according to membership type
*/
function getMemberTypeDefaults($config)
{
if (!$_POST['mtype']) {
$details['name'] = '';
$details['auto_renew'] = '';
$details['total_amount'] = '';
echo json_encode($details);
CRM_Utils_System::civiExit();
}
$memType = CRM_Utils_Type::escape($_POST['mtype'], 'Integer');
$query = "SELECT name, minimum_fee AS total_amount, financial_type_id, auto_renew\nFROM civicrm_membership_type\nWHERE id = %1";
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($memType, 'Positive')));
$properties = array('financial_type_id', 'total_amount', 'name', 'auto_renew');
while ($dao->fetch()) {
foreach ($properties as $property) {
$details[$property] = $dao->{$property};
}
}
$details['total_amount_numeric'] = $details['total_amount'];
// fix the display of the monetary value, CRM-4038
$details['total_amount'] = CRM_Utils_Money::format($details['total_amount'], NULL, '%a');
$options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
$details['auto_renew'] = CRM_Utils_Array::value('auto_renew', $options[$details]);
echo json_encode($details);
CRM_Utils_System::civiExit();
}
示例6: getPermissionedLocation
/**
* FIXME: we should make this method like getLocBlock() OR use the same method and
* remove this one.
*
* Function to obtain the location of given contact-id.
* This method is used by on-behalf-of form to dynamically generate poulate the
* location field values for selected permissioned contact.
*/
function getPermissionedLocation()
{
$cid = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
require_once 'CRM/Core/BAO/Location.php';
$entityBlock = array('contact_id' => $cid);
$location =& CRM_Core_BAO_Location::getValues($entityBlock);
$config =& CRM_Core_Config::singleton();
$addressSequence = array_flip($config->addressSequence());
$elements = array("phone_1_phone" => $location['phone'][1]['phone'], "email_1_email" => $location['email'][1]['email']);
if (array_key_exists('street_address', $addressSequence)) {
$elements["address_1_street_address"] = $location['address'][1]['street_address'];
}
if (array_key_exists('supplemental_address_1', $addressSequence)) {
$elements['address_1_supplemental_address_1'] = $location['address'][1]['supplemental_address_1'];
}
if (array_key_exists('supplemental_address_2', $addressSequence)) {
$elements['address_1_supplemental_address_2'] = $location['address'][1]['supplemental_address_2'];
}
if (array_key_exists('city', $addressSequence)) {
$elements['address_1_city'] = $location['address'][1]['city'];
}
if (array_key_exists('postal_code', $addressSequence)) {
$elements['address_1_postal_code'] = $location['address'][1]['postal_code'];
$elements['address_1_postal_code_suffix'] = $location['address'][1]['postal_code_suffix'];
}
if (array_key_exists('country', $addressSequence)) {
$elements['address_1_country_id'] = $location['address'][1]['country_id'];
}
if (array_key_exists('state_province', $addressSequence)) {
$elements['address_1_state_province_id'] = $location['address'][1]['state_province_id'];
}
echo json_encode($elements);
exit;
}
示例7: getCaseActivity
static function getCaseActivity()
{
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$userID = CRM_Utils_Type::escape($_GET['userID'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
$sortMapper = array(0 => 'display_date', 1 => 'ca.subject', 2 => 'ca.activity_type_id', 3 => 'acc.sort_name', 4 => 'cc.sort_name', 5 => 'ca.status_id');
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
$sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : null;
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortname'] = $sort;
$params['sortorder'] = $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
// get the activities related to given case
require_once "CRM/Case/BAO/Case.php";
$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
require_once "CRM/Utils/JSON.php";
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('display_date', 'subject', 'type', 'with_contacts', 'reporter', 'status', 'links', 'class');
echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例8: getContactMailings
/**
* Function to retrieve contact mailings
*/
public static function getContactMailings()
{
$contactID = CRM_Utils_Type::escape($_GET['contact_id'], 'Integer');
$sortMapper = array(0 => 'subject', 1 => 'creator_name', 2 => '', 3 => 'start_date', 4 => '', 5 => 'links');
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
$sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact mailings
$mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('subject', 'mailing_creator', 'recipients', 'start_date', 'openstats', 'links');
header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($mailings, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例9: pledgeName
/**
* Function for building Pledge Name combo box
*/
function pledgeName(&$config)
{
$getRecords = FALSE;
if (isset($_GET['name']) && $_GET['name']) {
$name = CRM_Utils_Type::escape($_GET['name'], 'String');
$name = str_replace('*', '%', $name);
$whereClause = "p.creator_pledge_desc LIKE '%{$name}%' ";
$getRecords = TRUE;
}
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
$whereClause = "p.id = {$pledgeId} ";
$getRecords = TRUE;
}
if ($getRecords) {
$query = "\nSELECT p.creator_pledge_desc, p.id\nFROM civicrm_pb_pledge p\nWHERE {$whereClause}\n";
$dao = CRM_Core_DAO::executeQuery($query);
$elements = array();
while ($dao->fetch()) {
$elements[] = array('name' => $dao->creator_pledge_desc, 'value' => $dao->id);
}
}
if (empty($elements)) {
$name = $_GET['name'];
if (!$name && isset($_GET['id'])) {
$name = $_GET['id'];
}
$elements[] = array('name' => trim($name, '*'), 'value' => trim($name, '*'));
}
echo CRM_Utils_JSON::encode($elements, 'value');
CRM_Utils_System::civiExit();
}
示例10: getTypedValue
/**
* @param string $name
* @param $type
*
* @return mixed|null
*/
public static function getTypedValue($name, $type)
{
$value = CRM_Utils_Array::value($name, $_GET);
if ($value === NULL) {
return NULL;
}
return CRM_Utils_Type::escape($value, CRM_Utils_Type::typeToString($type), FALSE);
}
示例11: getTypedValue
static function getTypedValue($name, $type)
{
$value = CRM_Utils_Array::value($name, $_GET);
if ($value === null) {
return null;
}
return CRM_Utils_Type::escape($value, CRM_Utils_Type::typeToString($type), false);
}
示例12: getPledgeDefaults
/**
* Function to setDefaults according to Pledge Id
* for batch entry pledges
*/
public function getPledgeDefaults()
{
$details = array();
if (!empty($_POST['pid'])) {
$pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer');
$details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID);
}
CRM_Utils_JSON::output($details);
}
示例13: getRequestExtAndSuite
/**
* Extrac the extension and suite from the request path
*
* @return array
*/
function getRequestExtAndSuite()
{
$config = CRM_Core_Config::singleton();
$arg = explode('/', $_GET[$config->userFrameworkURLVar]);
if ($arg[1] == 'dev' && CRM_Utils_Array::value(2, $arg) == 'qunit' && isset($arg[3]) && isset($arg[4])) {
return array(trim(CRM_Utils_Type::escape($arg[3], 'String'), '/'), trim(CRM_Utils_Type::escape($arg[4], 'String'), '/'));
} else {
return array(NULL, NULL);
}
}
示例14: getPledgeDefaults
/**
* Function to setDefaults according to Pledge Id
* for batch entry pledges
*/
public function getPledgeDefaults()
{
$details = array();
if (!empty($_POST['pid'])) {
$pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer');
$details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID);
}
echo json_encode($details);
CRM_Utils_System::civiExit();
}
示例15: run
/**
* This is some kind of special-purpose router/front-controller for the various profile URLs.
*
* @param $args array this array contains the arguments of the url
*
* @return string|void
* @static
* @access public
*/
function run($args = NULL)
{
if ($args[1] !== 'profile') {
return;
}
$secondArg = CRM_Utils_Array::value(2, $args, '');
if ($secondArg == 'map') {
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Task_Map', ts('Map Contact'), NULL, FALSE, FALSE, TRUE);
$gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
if (count($gids) > 1) {
foreach ($gids as $pfId) {
$profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
}
$controller->set('gid', $profileIds[0]);
$profileGID = $profileIds[0];
} else {
$profileGID = CRM_Utils_Request::retrieve('gid', 'Integer', $controller, TRUE);
}
// make sure that this profile enables mapping
// CRM-8609
$isMap = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map');
if (!$isMap) {
CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.'));
}
$profileView = CRM_Utils_Request::retrieve('pv', 'Integer', $controller, FALSE);
// set the userContext stack
$session = CRM_Core_Session::singleton();
if ($profileView) {
$session->pushUserContext(CRM_Utils_System::url('civicrm/profile/view'));
} else {
$session->pushUserContext(CRM_Utils_System::url('civicrm/profile', 'force=1'));
}
$controller->set('profileGID', $profileGID);
$controller->process();
return $controller->run();
}
if ($secondArg == 'edit' || $secondArg == 'create') {
if ($secondArg == 'edit') {
$controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit', ts('Create Profile'), CRM_Core_Action::UPDATE, FALSE, FALSE, TRUE);
$controller->set('edit', 1);
$controller->process();
return $controller->run();
} else {
$wrapper = new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Profile_Form_Edit', ts('Create Profile'), array('mode' => CRM_Core_Action::ADD, 'ignoreKey' => TRUE));
}
}
if ($secondArg == 'view' || empty($secondArg)) {
$page = new CRM_Profile_Page_Listings();
return $page->run();
}
CRM_Utils_System::permissionDenied();
return;
}