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


PHP CRM_Utils_Type::validate方法代码示例

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


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

示例1: 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;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:31,代码来源:OptionGroups.php

示例2: 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}"));
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:37,代码来源:Export.php

示例3: 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;
 }
开发者ID:torrance,项目名称:nz.co.fuzion.cmcic,代码行数:17,代码来源:CmcicIPN.php

示例4: retrieve

 /**
  * @param string $name
  * @param $type
  * @param bool $abort
  *
  * @return mixed
  */
 public function retrieve($name, $type, $abort = TRUE)
 {
     static $store = NULL;
     $value = CRM_Utils_Type::validate(CRM_Utils_Array::value($name, $this->_inputParameters), $type, FALSE);
     if ($abort && $value === NULL) {
         CRM_Core_Error::debug_log_message("Could not find an entry for {$name}");
         echo "Failure: Missing Parameter<p>" . CRM_Utils_Type::escape($name, 'String');
         exit;
     }
     return $value;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:18,代码来源:PayPalIPN.php

示例5: getCaseActivity

 public static function getCaseActivity()
 {
     // Should those params be passed through the validateParams method?
     $caseID = CRM_Utils_Type::validate($_GET['caseID'], 'Integer');
     $contactID = CRM_Utils_Type::validate($_GET['cid'], 'Integer');
     $userID = CRM_Utils_Type::validate($_GET['userID'], 'Integer');
     $context = CRM_Utils_Type::validate(CRM_Utils_Array::value('context', $_GET), 'String');
     $optionalParameters = array('source_contact_id' => 'Integer', 'status_id' => 'Integer', 'activity_deleted' => 'Boolean', 'activity_type_id' => 'Integer', 'activity_date_low' => 'Date', 'activity_date_high' => 'Date');
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
     $params += CRM_Core_Page_AJAX::validateParams(array(), $optionalParameters);
     // get the activities related to given case
     $activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
     CRM_Utils_JSON::output($activities);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:14,代码来源:AJAX.php

示例6: get

 /**
  * Retrieve a value from the bag.
  *
  * @param string $key
  * @param string|null $type
  * @param mixed $default
  * @return mixed
  * @throws API_Exception
  */
 public function get($key, $type = NULL, $default = NULL)
 {
     if (!array_key_exists($key, $this->data)) {
         return $default;
     }
     if (!$type) {
         return $this->data[$key];
     }
     $r = CRM_Utils_Type::validate($this->data[$key], $type);
     if ($r !== NULL) {
         return $r;
     } else {
         throw new \API_Exception(ts("Could not find valid value for %1 (%2)", array(1 => $key, 2 => $type)));
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:24,代码来源:OptionBag.php

示例7: retrieve

 static function retrieve($name, $type, $object, $abort = TRUE)
 {
     $value = CRM_Utils_Array::value($name, $object);
     if ($abort && $value === NULL) {
         CRM_Core_Error::debug_log_message("Could not find an entry for {$name}");
         echo "Failure: Missing Parameter<p>";
         exit;
     }
     if ($value) {
         if (!CRM_Utils_Type::validate($value, $type)) {
             CRM_Core_Error::debug_log_message("Could not find a valid entry for {$name}");
             echo "Failure: Invalid Parameter<p>";
             exit;
         }
     }
     return $value;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:17,代码来源:GoogleIPN.php

示例8: retrieve

 /**
  * Retrieve a value from the request (GET/POST/REQUEST)
  *
  * @param string $name
  *   Name of the variable to be retrieved.
  * @param string $type
  *   Type of the variable (see CRM_Utils_Type for details).
  * @param object $store
  *   Session scope where variable is stored.
  * @param bool $abort
  *   TRUE, if the variable is required.
  * @param mixed $default
  *   Default value of the variable if not present.
  * @param string $method
  *   Where to look for the variable - 'GET', 'POST' or 'REQUEST'.
  *
  * @return mixed
  *   The value of the variable
  */
 public static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST')
 {
     // hack to detect stuff not yet converted to new style
     if (!is_string($type)) {
         CRM_Core_Error::backtrace();
         CRM_Core_Error::fatal(ts("Please convert retrieve call to use new function signature"));
     }
     $value = NULL;
     switch ($method) {
         case 'GET':
             $value = CRM_Utils_Array::value($name, $_GET);
             break;
         case 'POST':
             $value = CRM_Utils_Array::value($name, $_POST);
             break;
         default:
             $value = CRM_Utils_Array::value($name, $_REQUEST);
             break;
     }
     if (isset($value) && CRM_Utils_Type::validate($value, $type, $abort, $name) === NULL) {
         $value = NULL;
     }
     if (!isset($value) && $store) {
         $value = $store->get($name);
     }
     if (!isset($value) && $abort) {
         CRM_Core_Error::fatal(ts("Could not find valid value for %1", array(1 => $name)));
     }
     if (!isset($value) && $default) {
         $value = $default;
     }
     // minor hack for action
     if ($name == 'action' && is_string($value)) {
         $value = CRM_Core_Action::resolve($value);
     }
     if (isset($value) && $store) {
         $store->set($name, $value);
     }
     return $value;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:59,代码来源:Request.php

示例9: accessCase

 /**
  * Verify user has permission to access a case.
  *
  * @param int $caseId
  * @param bool $denyClosed
  *   Set TRUE if one wants closed cases to be treated as inaccessible.
  *
  * @return bool
  */
 public static function accessCase($caseId, $denyClosed = TRUE)
 {
     if (!$caseId || !self::enabled()) {
         return FALSE;
     }
     // This permission always has access
     if (CRM_Core_Permission::check('access all cases and activities')) {
         return TRUE;
     }
     // This permission is required at minimum
     if (!CRM_Core_Permission::check('access my cases and activities')) {
         return FALSE;
     }
     $session = CRM_Core_Session::singleton();
     $userID = CRM_Utils_Type::validate($session->get('userID'), 'Positive');
     $caseId = CRM_Utils_Type::validate($caseId, 'Positive');
     $condition = " AND civicrm_case.is_deleted = 0 ";
     $condition .= " AND case_relationship.contact_id_b = {$userID} ";
     $condition .= " AND civicrm_case.id = {$caseId}";
     if ($denyClosed) {
         $closedId = CRM_Core_OptionGroup::getValue('case_status', 'Closed', 'name');
         $condition .= " AND civicrm_case.status_id != {$closedId}";
     }
     // We don't actually care about activities in the case, but the underlying
     // query is verbose, and this allows us to share the basic query with
     // getCases(). $type=='any' means that activities will be left-joined.
     $query = self::getCaseActivityQuery('any', $userID, $condition);
     $queryParams = array();
     $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
     return (bool) $dao->fetch();
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:40,代码来源:Case.php

示例10: __construct

 /**
  * The constructor takes an assoc array
  * key names of variable (which should be the same as the column name)
  * value: ascending or descending
  *
  * @param mixed $vars
  *   Assoc array as described above.
  * @param string $defaultSortOrder
  *   Order to sort.
  *
  * @return \CRM_Utils_Sort
  */
 public function __construct(&$vars, $defaultSortOrder = NULL)
 {
     $this->_vars = array();
     $this->_response = array();
     foreach ($vars as $weight => $value) {
         $this->_vars[$weight] = array('name' => CRM_Utils_Type::validate($value['sort'], 'MysqlColumnName'), 'direction' => CRM_Utils_Array::value('direction', $value), 'title' => $value['name']);
     }
     $this->_currentSortID = 1;
     if (isset($this->_vars[$this->_currentSortID])) {
         $this->_currentSortDirection = $this->_vars[$this->_currentSortID]['direction'];
     }
     $this->_urlVar = self::SORT_ID;
     $this->_link = CRM_Utils_System::makeURL($this->_urlVar, TRUE);
     $this->initialize($defaultSortOrder);
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:27,代码来源:Sort.php

示例11: formRule

 /**
  * Global form rule.
  *
  * @param array $fields
  *   The input form values.
  * @param array $files
  *   The uploaded files if any.
  * @param array $self
  *   Current form object.
  *
  * @return array
  *   array of errors / empty array.
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->_gName == 'case_status' && empty($fields['grouping'])) {
         $errors['grouping'] = ts('Status class is a required field');
     }
     if (in_array($self->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && empty($self->_defaultValues['is_reserved'])) {
         $label = $fields['label'];
         $condition = " AND v.label = '{$label}' ";
         $values = CRM_Core_OptionGroup::values($self->_gName, FALSE, FALSE, FALSE, $condition, 'filter');
         $checkContactOptions = TRUE;
         if ($self->_id && $self->_defaultValues['contactOptions'] == $fields['contactOptions']) {
             $checkContactOptions = FALSE;
         }
         if ($checkContactOptions && in_array($fields['contactOptions'], $values)) {
             $errors['label'] = ts('This Label already exists in the database for the selected contact type.');
         }
     }
     if ($self->_gName == 'from_email_address') {
         $formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
         if (!CRM_Utils_Rule::email($formEmail)) {
             $errors['label'] = ts('Please enter a valid email address.');
         }
         $formName = explode('"', $fields['label']);
         if (empty($formName[1]) || count($formName) != 3) {
             $errors['label'] = ts('Please follow the proper format for From Email Address');
         }
     }
     $dataType = self::getOptionGroupDataType($self->_gName);
     if ($dataType && $self->_gName !== 'activity_type') {
         $validate = CRM_Utils_Type::validate($fields['value'], $dataType, FALSE);
         if (!$validate) {
             CRM_Core_Session::setStatus(ts('Data Type of the value field for this option value does not match ' . $dataType), ts('Value field Data Type mismatch'));
         }
     }
     return $errors;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:50,代码来源:Options.php

示例12: del

 /**
  * Delete the tag.
  *
  * @param int $id
  *   Tag id.
  *
  * @return bool
  */
 public static function del($id)
 {
     // since this is a destructive operation, lets make sure
     // id is a positive number
     CRM_Utils_Type::validate($id, 'Positive');
     // delete all crm_entity_tag records with the selected tag id
     $entityTag = new CRM_Core_DAO_EntityTag();
     $entityTag->tag_id = $id;
     $entityTag->delete();
     // delete from tag table
     $tag = new CRM_Core_DAO_Tag();
     $tag->id = $id;
     CRM_Utils_Hook::pre('delete', 'Tag', $id, $tag);
     if ($tag->delete()) {
         CRM_Utils_Hook::post('delete', 'Tag', $id, $tag);
         return TRUE;
     }
     return FALSE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:Tag.php

示例13: preProcess

 /**
  * set variables up before form is built
  *
  * @access public
  */
 function preProcess()
 {
     // VOL-71: permissions check is moved from XML to preProcess function to support
     // permissions-challenged Joomla instances
     if (CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported() && !CRM_Volunteer_Permission::check('register to volunteer')) {
         CRM_Utils_System::permissionDenied();
     }
     $validNeedIds = array();
     $needs = CRM_Utils_Request::retrieve('needs', 'String', $this, TRUE);
     if (!is_array($needs)) {
         $needs = explode(',', $needs);
     }
     foreach ($needs as $need) {
         if (CRM_Utils_Type::validate($need, 'Positive', FALSE)) {
             $validNeedIds[] = $need;
         }
     }
     $api = civicrm_api3('VolunteerNeed', 'get', array('id' => array('IN' => $validNeedIds)));
     $this->_needs = $api['values'];
     foreach ($this->_needs as $need) {
         $this->_projects[$need['project_id']] = array();
     }
     $this->fetchProjectDetails();
     $this->setDestination();
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     // current mode
     $this->_mode = $this->_action == CRM_Core_Action::PREVIEW ? 'test' : 'live';
 }
开发者ID:JohnFF,项目名称:org.civicrm.volunteer,代码行数:33,代码来源:VolunteerSignUp.php

示例14: retrieve

 /**
  * @param string $name
  *   Parameter name.
  * @param string $type
  *   Parameter type.
  * @param bool $abort
  *   Abort if not present.
  * @param null $default
  *   Default value.
  *
  * @throws CRM_Core_Exception
  * @return mixed
  */
 public function retrieve($name, $type, $abort = TRUE, $default = NULL)
 {
     $value = CRM_Utils_Type::validate(empty($this->_inputParameters[$name]) ? $default : $this->_inputParameters[$name], $type, FALSE);
     if ($abort && $value === NULL) {
         throw new CRM_Core_Exception("Could not find an entry for {$name}");
     }
     return $value;
 }
开发者ID:indydas,项目名称:civi-demo,代码行数:21,代码来源:AuthorizeNetIPN.php

示例15: validateAll

 /**
  * Helper function to call validate on arrays
  *
  * @see validate
  */
 public static function validateAll($data, $type, $abort = TRUE)
 {
     foreach ($data as $key => $value) {
         $data[$key] = CRM_Utils_Type::validate($value, $type, $abort);
     }
     return $data;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:12,代码来源:Type.php


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