本文整理汇总了PHP中CRM_Contact_BAO_Group::groupTypeCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Group::groupTypeCondition方法的具体用法?PHP CRM_Contact_BAO_Group::groupTypeCondition怎么用?PHP CRM_Contact_BAO_Group::groupTypeCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Group
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Group::groupTypeCondition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
// add the email address
$this->add('text', 'email', ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'), TRUE);
$this->addRule('email', ts("Please enter a valid email address."), 'email');
if (!$this->_groupID) {
// create a selector box of all public groups
$groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
$query = "\nSELECT id, title, description\n FROM civicrm_group\n WHERE ( saved_search_id = 0\n OR saved_search_id IS NULL )\n AND visibility != 'User and User Admin Only'\n AND {$groupTypeCondition}\nORDER BY title";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
$rows = array();
while ($dao->fetch()) {
$row = array();
$row['id'] = $dao->id;
$row['title'] = $dao->title;
$row['description'] = $dao->description;
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $row['id'];
$this->addElement('checkbox', $row['checkbox'], NULL, NULL);
$rows[] = $row;
}
if (empty($rows)) {
CRM_Core_Error::fatal(ts('There are no public mailing list groups to display.'));
}
$this->assign('rows', $rows);
$this->addFormRule(array('CRM_Mailing_Form_Subscribe', 'formRule'));
}
$addCaptcha = TRUE;
// if recaptcha is not configured, then dont add it
// CRM-11316 Only enable ReCAPTCHA for anonymous visitors
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if (empty($config->recaptchaPublicKey) || empty($config->recaptchaPrivateKey) || $contactID) {
$addCaptcha = FALSE;
} else {
// if this is POST request and came from a block,
// lets add recaptcha only if already present
// gross hack for now
if (!empty($_POST) && !array_key_exists('recaptcha_challenge_field', $_POST)) {
$addCaptcha = FALSE;
}
}
if ($addCaptcha) {
// add captcha
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Subscribe'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例2:
/**
* Get all permissioned groups from database
*
* The static array group is returned, and if it's
* called the first time, the <b>Group DAO</b> is used
* to get all the groups.
*
* Note: any database errors will be trapped by the DAO.
*
* @access public
* @static
*
* @return array - array reference of all groups.
*
*/
public static function &staticGroup($onlyPublic = FALSE, $groupType = NULL, $excludeHidden = TRUE)
{
if (!self::$staticGroup) {
$condition = 'saved_search_id = 0 OR saved_search_id IS NULL';
if ($onlyPublic) {
$condition .= " AND visibility != 'User and User Admin Only'";
}
if ($groupType) {
$condition .= ' AND ' . CRM_Contact_BAO_Group::groupTypeCondition($groupType);
}
if ($excludeHidden) {
$condition .= ' AND is_hidden != 1 ';
}
self::populate(self::$staticGroup, 'CRM_Contact_DAO_Group', FALSE, 'title', 'is_active', $condition, 'title');
}
return self::$staticGroup;
}
示例3:
/**
* Get all permissioned groups from database
*
* The static array group is returned, and if it's
* called the first time, the <b>Group DAO</b> is used
* to get all the groups.
*
* Note: any database errors will be trapped by the DAO.
*
* @access public
* @static
*
* @return array - array reference of all groups.
*
*/
public static function &staticGroup($onlyPublic = false, $groupType = null)
{
if (!self::$staticGroup) {
$condition = 'saved_search_id = 0 OR saved_search_id IS NULL';
if ($onlyPublic) {
$condition .= " AND visibility != 'User and User Admin Only'";
}
if ($groupType) {
require_once 'CRM/Contact/BAO/Group.php';
$condition .= ' AND ' . CRM_Contact_BAO_Group::groupTypeCondition($groupType);
}
self::populate(self::$staticGroup, 'CRM_Contact_DAO_Group', false, 'title', 'is_active', $condition, 'title');
}
return self::$staticGroup;
}