本文整理汇总了PHP中CRM_Utils_Rule::objectExists方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Rule::objectExists方法的具体用法?PHP CRM_Utils_Rule::objectExists怎么用?PHP CRM_Utils_Rule::objectExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Rule
的用法示例。
在下文中一共展示了CRM_Utils_Rule::objectExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newGroupRule
/**
* function for validation
*
* @param array $params (reference) an assoc array of name/value pairs
*
* @return mixed true or array of errors
* @access public
* @static
*/
function newGroupRule(&$params)
{
if (CRM_Utils_Array::value('_qf_Import_refresh', $_POST)) {
return true;
}
/* If we're not creating a new group, accept */
if (!$params['newGroupName']) {
return true;
}
$errors = array();
// if ($params['newGroupName'] === '') {
// $errors['newGroupName'] = ts( 'Please enter a name for the new group.');
// } else {
if ($params['newGroupName']) {
if (!CRM_Utils_Rule::objectExists(trim($params['newGroupName']), array('CRM_Contact_DAO_Group'))) {
$errors['newGroupName'] = ts('Group "%1" already exists.', array(1 => $params['newGroupName']));
}
// }
}
return empty($errors) ? true : $errors;
}
示例2: formRule
/**
* global validation rules for the form
*
* @param array $fields posted values of the form
*
* @param $files
* @param $self
*
* @return array list of errors to be posted back to the form
* @static
* @access public
*/
static function formRule($fields, $files, $self)
{
$errors = array();
$invalidTagName = $invalidGroupName = FALSE;
if (!empty($fields['newTagName'])) {
if (!CRM_Utils_Rule::objectExists(trim($fields['newTagName']), array('CRM_Core_DAO_Tag'))) {
$errors['newTagName'] = ts('Tag \'%1\' already exists.', array(1 => $fields['newTagName']));
$invalidTagName = TRUE;
}
}
if (!empty($fields['newGroupName'])) {
$title = trim($fields['newGroupName']);
$name = CRM_Utils_String::titleToVar($title);
$query = 'select count(*) from civicrm_group where name like %1 OR title like %2';
$grpCnt = CRM_Core_DAO::singleValueQuery($query, array(1 => array($name, 'String'), 2 => array($title, 'String')));
if ($grpCnt) {
$invalidGroupName = TRUE;
$errors['newGroupName'] = ts('Group \'%1\' already exists.', array(1 => $fields['newGroupName']));
}
}
$self->assign('invalidTagName', $invalidTagName);
$self->assign('invalidGroupName', $invalidGroupName);
return empty($errors) ? TRUE : $errors;
}
示例3: newTagRule
/**
* function for validation
*
* @param array $params (reference) an assoc array of name/value pairs
*
* @return mixed true or array of errors
* @access public
* @static
*/
static function newTagRule(&$params)
{
if (CRM_Utils_Array::value('_qf_Import_refresh', $_POST)) {
return true;
}
/* If we're not creating a new Tag, accept */
if (!$params['newTagName']) {
return true;
}
$errors = array();
if ($params['newTagName']) {
if (!CRM_Utils_Rule::objectExists(trim($params['newTagName']), array('CRM_Core_DAO_Tag'))) {
$errors['newTagName'] = ts('Tag \'%1\' already exists.', array(1 => $params['newTagName']));
}
}
return empty($errors) ? true : $errors;
}