本文整理汇总了PHP中CRM_Utils_Type类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Type类的具体用法?PHP CRM_Utils_Type怎么用?PHP CRM_Utils_Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
CRM_Utils_System::setTitle(ts('Dropdown Options'));
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
$this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
$this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), TRUE);
$element = $this->add('checkbox', 'is_active', ts('Enabled?'));
if ($this->_action & CRM_Core_Action::UPDATE) {
if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
static $caseCount = NULL;
if (!isset($caseCount)) {
$caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
}
if ($caseCount > 0) {
$element->freeze();
}
}
if (!empty($this->_values['is_reserved'])) {
$this->freeze(array('name', 'is_active'));
}
}
$this->assign('id', $this->_id);
}
示例5: 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();
}
示例6: 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();
}
示例7: checkOptionGroupValues
/**
* @return array
*/
public function checkOptionGroupValues()
{
$messages = array();
$problemValues = array();
$optionGroups = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'data_type' => array('IS NOT NULL' => 1), 'options' => array('limit' => 0)));
if ($optionGroups['count'] > 0) {
foreach ($optionGroups['values'] as $optionGroup) {
$values = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroup['id']);
if (count($values) > 0) {
foreach ($values as $value) {
$validate = CRM_Utils_Type::validate($value['value'], $optionGroup['data_type'], FALSE);
if (!$validate) {
$problemValues[] = array('group_name' => $optionGroup['title'], 'value_name' => $value['label']);
}
}
}
}
}
if (!empty($problemValues)) {
$strings = '';
foreach ($problemValues as $problemValue) {
$strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', array(1 => $problemValue['group_name'], 2 => $problemValue['value_name']));
}
$messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p>
<p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') . $strings . ts('</tbody></table></p>'), ts('Option Values with problematic Values'), \Psr\Log\LogLevel::NOTICE, 'fa-server');
}
return $messages;
}
示例8: 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;
}
示例9: 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);
}
示例10: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
// this mean it's a batch action
if (!$this->_id) {
if (!empty($_GET['batch_id'])) {
// validate batch ids
$batchIds = explode(',', $_GET['batch_id']);
foreach ($batchIds as $batchId) {
CRM_Utils_Type::validate($batchId, 'Positive');
}
$this->_batchIds = $_GET['batch_id'];
$this->set('batchIds', $this->_batchIds);
} else {
$this->_batchIds = $this->get('batchIds');
}
if (!empty($_GET['export_format']) && in_array($_GET['export_format'], array('IIF', 'CSV'))) {
$this->_exportFormat = $_GET['export_format'];
}
} else {
$this->_batchIds = $this->_id;
}
$allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
$this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus);
// check if batch status is valid, do not allow exported batches to export again
$batchStatus = CRM_Batch_BAO_Batch::getBatchStatuses($this->_batchIds);
foreach ($batchStatus as $batchStatusId) {
if ($batchStatusId == $this->_exportStatusId) {
CRM_Core_Error::fatal(ts('You cannot exported the batches which were exported earlier.'));
}
}
$session = CRM_Core_Session::singleton();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/financialbatches', "reset=1&batchStatus={$this->_exportStatusId}"));
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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);
}
示例15: retrieve
/**
* @param string $name of variable to return
* @param string $type data type
* - String
* - Integer
* @param string $location - deprecated
* @param boolean $abort abort if empty
* @return Ambigous <mixed, NULL, value, unknown, array, number>
*/
function retrieve($name, $type, $abort = TRUE)
{
$value = CRM_Utils_Type::validate(CRM_Utils_Array::value($name, $this->_inputParameters), $type, FALSE);
if ($abort && $value === NULL) {
throw new CRM_Core_Exception("Could not find an entry for {$name}");
}
return $value;
}