本文整理汇总了PHP中CRM_Contact_BAO_Group::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Group::retrieve方法的具体用法?PHP CRM_Contact_BAO_Group::retrieve怎么用?PHP CRM_Contact_BAO_Group::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Group
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Group::retrieve方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object - it consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
*
*
* @return void
*/
public function buildQuickForm()
{
CRM_Utils_System::setTitle(ts('Smart Group'));
// get the qill
$query = new CRM_Event_BAO_Query($this->get('formValues'));
$qill = $query->qill();
// Values from the search form
$formValues = $this->controller->exportValues();
// need to save qill for the smarty template
$this->assign('qill', $qill);
// the name and description are actually stored with the group and not the saved search
$this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE);
$this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
// get the group id for the saved search
$groupId = NULL;
if (isset($this->_id)) {
$params = array('saved_search_id' => $this->_id);
CRM_Contact_BAO_Group::retrieve($params, $values);
$groupId = $values['id'];
$this->addDefaultButtons(ts('Update Smart Group'));
} else {
$this->addDefaultButtons(ts('Save Smart Group'));
$this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all');
}
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title'));
}
示例2: buildQuickForm
/**
* Build the form - it consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
*
* @access public
* @return void
*/
function buildQuickForm()
{
CRM_Utils_System::setTitle(ts('Smart Group'));
require_once "CRM/Event/BAO/Query.php";
// get the qill
$query =& new CRM_Event_BAO_Query($this->get('formValues'));
$qill = $query->qill();
// need to save qill for the smarty template
$this->assign('qill', $qill);
// the name and description are actually stored with the group and not the saved search
$this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), true);
$this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
// get the group id for the saved search
$groupId = null;
if (isset($this->_id)) {
$params = array('saved_search_id' => $this->_id);
require_once "CRM/Contact/BAO/Group.php";
CRM_Contact_BAO_Group::retrieve($params, $values);
$groupId = $values['id'];
$this->addDefaultButtons(ts('Update Smart Group'));
} else {
$this->addDefaultButtons(ts('Save Smart Group'));
}
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title'));
}
示例3: preProcess
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess()
{
// initialize the task and row fields
parent::preProcess();
$session = CRM_Core_Session::singleton();
// Step 1: if we can't get team ID, there's no point continuing.
$this->_id = $this->get('amtgID');
if (!isset($this->_id)) {
$this->_id = CRM_Utils_Request::retrieve('amtgID', 'Positive');
}
if (!isset($this->_id)) {
$this->_id = $session->get('amtgID');
}
$session->set('amtgID', $this->_id);
//@todo Exit more gracefully if id still isn't set
if (!isset($this->_id)) {
return;
}
$this->_teamValues = array();
$params = array('id' => $this->_id);
$this->_team = CRM_Contact_BAO_Group::retrieve($params, $this->_teamValues);
$this->_context = $this->get('context');
$this->findTeamPlayers();
$this->findEligiblePlayers();
$session = CRM_Core_Session::singleton();
//$urlParams = 'reset=1&force=1';
$session->replaceUserContext(CRM_Utils_System::url('civicrm/tournament/team'));
//search', $urlParams));
}
示例4: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
$defaults = array();
$params = array();
$params = array('saved_search_id' => $this->_id);
CRM_Contact_BAO_Group::retrieve($params, $defaults);
return $defaults;
}
示例5: preProcess
/**
* Set up variables to build the form.
*
* @return void
* @acess protected
*/
public function preProcess()
{
// TODO: quit if user can't access any registration groups (remove from nav menu?)
// CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to change settings for this reserved group."));
$this->_id = $this->get('id');
if ($this->_id) {
$breadCrumb = array(array('title' => ts('Manage Teams'), 'url' => CRM_Utils_System::url('civicrm/tournament/team', 'reset=1')));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
$this->_groupValues = array();
$params = array('id' => $this->_id);
$this->_group = CRM_Contact_BAO_Group::retrieve($params, $this->_groupValues);
$this->_title = $this->_groupValues['title'];
}
$this->assign('action', $this->_action);
$this->assign('showBlockJS', TRUE);
if ($this->_action == CRM_Core_Action::DELETE) {
if (isset($this->_id)) {
$this->assign('title', $this->_title);
$this->assign('count', CRM_Contact_BAO_Group::memberCount($this->_id));
CRM_Utils_System::setTitle(ts('Confirm Group Delete'));
}
if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) {
CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved group."));
}
} else {
if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) {
CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to change settings for this reserved group."));
}
if (isset($this->_id)) {
$groupValues = array('id' => $this->_id, 'title' => $this->_title, 'saved_search_id' => isset($this->_groupValues['saved_search_id']) ? $this->_groupValues['saved_search_id'] : '');
if (isset($this->_groupValues['saved_search_id'])) {
$groupValues['mapping_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'mapping_id');
$groupValues['search_custom_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'search_custom_id');
}
if (!empty($this->_groupValues['created_id'])) {
$groupValues['created_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['created_id'], 'sort_name', 'id');
}
if (!empty($this->_groupValues['modified_id'])) {
$groupValues['modified_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['modified_id'], 'sort_name', 'id');
}
$this->assign_by_ref('group', $groupValues);
CRM_Utils_System::setTitle(ts('Team Settings: %1', array(1 => $this->_title)));
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/tournament/team', 'reset=1'));
}
//build custom data
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Group', $this->_id);
}
示例6: getGlobalContacts
/**
* @param $groupInfo
* @param null $sort
* @param null $showLinks
* @param bool $returnOnlyCount
* @param int $offset
* @param int $rowCount
*
* @return array
*/
static function getGlobalContacts(&$groupInfo, $sort = NULL, $showLinks = NULL, $returnOnlyCount = FALSE, $offset = 0, $rowCount = 25)
{
$globalContacts = array();
$settingsProcessor = new CRM_Case_XMLProcessor_Settings();
$settings = $settingsProcessor->run();
if (!empty($settings)) {
$groupInfo['name'] = $settings['groupname'];
if ($groupInfo['name']) {
$searchParams = array('name' => $groupInfo['name']);
$results = array();
CRM_Contact_BAO_Group::retrieve($searchParams, $results);
if ($results) {
$groupInfo['id'] = $results['id'];
$groupInfo['title'] = $results['title'];
$params = array(array('group', 'IN', array($groupInfo['id'] => 1), 0, 0));
$return = array('contact_id' => 1, 'sort_name' => 1, 'display_name' => 1, 'email' => 1, 'phone' => 1);
list($globalContacts) = CRM_Contact_BAO_Query::apiQuery($params, $return, NULL, $sort, $offset, $rowCount, TRUE, $returnOnlyCount);
if ($returnOnlyCount) {
return $globalContacts;
}
if ($showLinks) {
foreach ($globalContacts as $idx => $contact) {
$globalContacts[$idx]['sort_name'] = '<a href="' . CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contact['contact_id']}") . '">' . $contact['sort_name'] . '</a>';
}
}
}
}
}
return $globalContacts;
}
示例7: array
/**
* Register a subscription event. Create a new contact if one does not
* already exist.
*
* @param int $group_id
* The group id to subscribe to.
* @param string $email
* The email address of the (new) contact.
* @param int $contactId
* Currently used during event registration/contribution.
* Specifically to avoid linking group to wrong duplicate contact
* during event registration.
* @param string $context
*
* @return int|null
* $se_id The id of the subscription event, null on failure
*/
public static function &subscribe($group_id, $email, $contactId = NULL, $context = NULL)
{
// CRM-1797 - allow subscription only to public groups
$params = array('id' => (int) $group_id);
$defaults = array();
$contact_id = NULL;
$success = NULL;
$bao = CRM_Contact_BAO_Group::retrieve($params, $defaults);
if ($bao && substr($bao->visibility, 0, 6) != 'Public' && $context != 'profile') {
return $success;
}
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$email = $strtolower($email);
// process the query only if no contactId
if ($contactId) {
$contact_id = $contactId;
} else {
/* First, find out if the contact already exists */
$query = "\n SELECT DISTINCT contact_a.id as contact_id\n FROM civicrm_contact contact_a\nLEFT JOIN civicrm_email ON contact_a.id = civicrm_email.contact_id\n WHERE civicrm_email.email = %1 AND contact_a.is_deleted = 0";
$params = array(1 => array($email, 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$id = array();
// lets just use the first contact id we got
if ($dao->fetch()) {
$contact_id = $dao->contact_id;
}
$dao->free();
}
$transaction = new CRM_Core_Transaction();
if (!$contact_id) {
require_once 'CRM/Utils/DeprecatedUtils.php';
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual', 'version' => 3);
$locationType = CRM_Core_BAO_LocationType::getDefault();
$value = array('email' => $email, 'location_type_id' => $locationType->id);
_civicrm_api3_deprecated_add_formatted_param($value, $formatted);
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
$formatted['fixAddress'] = TRUE;
require_once 'api/api.php';
$contact = civicrm_api('contact', 'create', $formatted);
if (civicrm_error($contact)) {
return $success;
}
$contact_id = $contact['id'];
} elseif (!is_numeric($contact_id) && (int) $contact_id > 0) {
// make sure contact_id is numeric
return $success;
}
/* Get the primary email id from the contact to use as a hash input */
$dao = new CRM_Core_DAO();
$query = "\nSELECT civicrm_email.id as email_id\n FROM civicrm_email\n WHERE civicrm_email.email = %1\n AND civicrm_email.contact_id = %2";
$params = array(1 => array($email, 'String'), 2 => array($contact_id, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
CRM_Core_Error::fatal('Please file an issue with the backtrace');
return $success;
}
$se = new CRM_Mailing_Event_BAO_Subscribe();
$se->group_id = $group_id;
$se->contact_id = $contact_id;
$se->time_stamp = date('YmdHis');
$se->hash = substr(sha1("{$group_id}:{$contact_id}:{$dao->email_id}:" . time()), 0, 16);
$se->save();
$contacts = array($contact_id);
CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id);
$transaction->commit();
return $se;
}
示例8: getGlobalContacts
static function getGlobalContacts(&$groupInfo)
{
$globalContacts = array();
require_once 'CRM/Case/XMLProcessor/Settings.php';
require_once 'CRM/Contact/BAO/Group.php';
require_once 'api/v2/Contact.php';
$settingsProcessor = new CRM_Case_XMLProcessor_Settings();
$settings = $settingsProcessor->run();
if (!empty($settings)) {
$groupInfo['name'] = $settings['groupname'];
if ($groupInfo['name']) {
$searchParams = array('name' => $groupInfo['name']);
$results = array();
CRM_Contact_BAO_Group::retrieve($searchParams, $results);
if ($results) {
$groupInfo['id'] = $results['id'];
$groupInfo['title'] = $results['title'];
$searchParams = array('group' => array($groupInfo['id'] => 1), 'return.sort_name' => 1, 'return.display_name' => 1, 'return.email' => 1, 'return.phone' => 1);
$globalContacts = civicrm_contact_search($searchParams);
}
}
}
return $globalContacts;
}
示例9: preProcess
/**
* set up variables to build the form
*
* @return void
* @acess protected
*/
function preProcess()
{
$this->_id = $this->get('id');
if ($this->_id) {
$breadCrumb = array(array('title' => ts('Manage Groups'), 'url' => CRM_Utils_System::url('civicrm/group', 'reset=1')));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
$this->_groupValues = array();
$params = array('id' => $this->_id);
$this->_group =& CRM_Contact_BAO_Group::retrieve($params, $this->_groupValues);
$this->_title = $this->_groupValues['title'];
}
$this->assign('action', $this->_action);
$this->assign('showBlockJS', TRUE);
if ($this->_action == CRM_Core_Action::DELETE) {
if (isset($this->_id)) {
$this->assign('title', $this->_title);
$this->assign('count', CRM_Contact_BAO_Group::memberCount($this->_id));
CRM_Utils_System::setTitle(ts('Confirm Group Delete'));
}
} else {
if (isset($this->_id)) {
$groupValues = array('id' => $this->_id, 'title' => $this->_title, 'saved_search_id' => isset($this->_groupValues['saved_search_id']) ? $this->_groupValues['saved_search_id'] : '');
if (isset($this->_groupValues['saved_search_id'])) {
$groupValues['mapping_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'mapping_id');
$groupValues['search_custom_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'search_custom_id');
}
$this->assign_by_ref('group', $groupValues);
CRM_Utils_System::setTitle(ts('Group Settings: %1', array(1 => $this->_title)));
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/group', 'reset=1'));
}
//build custom data
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Group', $this->_id);
}
示例10: getGlobalContacts
static function getGlobalContacts(&$groupInfo)
{
$globalContacts = array();
$settingsProcessor = new CRM_Case_XMLProcessor_Settings();
$settings = $settingsProcessor->run();
if (!empty($settings)) {
$groupInfo['name'] = $settings['groupname'];
if ($groupInfo['name']) {
$searchParams = array('name' => $groupInfo['name']);
$results = array();
CRM_Contact_BAO_Group::retrieve($searchParams, $results);
if ($results) {
$groupInfo['id'] = $results['id'];
$groupInfo['title'] = $results['title'];
$params = array(array('group', 'IN', array($groupInfo['id'] => 1), 0, 0));
$return = array('sort_name' => 1, 'display_name' => 1, 'email' => 1, 'phone' => 1);
list($globalContacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, $return);
}
}
}
return $globalContacts;
}
示例11: array
/**
* Register a subscription event. Create a new contact if one does not
* already exist.
*
* @param int $group_id The group id to subscribe to
* @param string $email The email address of the (new) contact
* @return int|null $se_id The id of the subscription event, null on failure
* @access public
* @static
*/
public static function &subscribe($group_id, $email)
{
// CRM-1797 - allow subscription only to public groups
$params = array('id' => (int) $group_id);
$defaults = array();
require_once 'CRM/Contact/BAO/Group.php';
$bao = CRM_Contact_BAO_Group::retrieve($params, $defaults);
if (substr($bao->visibility, 0, 6) != 'Public') {
return null;
}
$email = strtolower($email);
/* First, find out if the contact already exists */
$query = "\n SELECT DISTINCT contact_a.id as contact_id \n FROM civicrm_contact contact_a \nLEFT JOIN civicrm_email ON contact_a.id = civicrm_email.contact_id\n WHERE civicrm_email.email = %1";
$params = array(1 => array($email, 'String'));
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$id = array();
// lets just use the first contact id we got
if ($dao->fetch()) {
$contact_id = $dao->contact_id;
}
$dao->free();
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
if (!$contact_id) {
require_once 'api/v2/Contact.php';
require_once 'CRM/Core/BAO/LocationType.php';
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual');
$locationType = CRM_Core_BAO_LocationType::getDefault();
$value = array('email' => $email, 'location_type_id' => $locationType->id);
_civicrm_add_formatted_param($value, $formatted);
require_once 'CRM/Import/Parser.php';
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
$formatted['fixAddress'] = true;
$contact =& civicrm_contact_format_create($formatted);
if (civicrm_error($contact, CRM_Core_Error)) {
return null;
}
$contact_id = $contact['id'];
} else {
if (!is_numeric($contact_id) && (int) $contact_id > 0) {
// make sure contact_id is numeric
return null;
}
}
require_once 'CRM/Core/BAO/Email.php';
require_once 'CRM/Core/BAO/Location.php';
require_once 'CRM/Contact/BAO/Contact.php';
/* Get the primary email id from the contact to use as a hash input */
$dao =& new CRM_Core_DAO();
$query = "\nSELECT civicrm_email.id as email_id\n FROM civicrm_email\n WHERE civicrm_email.email = %1\n AND civicrm_email.contact_id = %2";
$params = array(1 => array($email, 'String'), 2 => array($contact_id, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
CRM_Core_Error::fatal('Please file an issue with the backtrace');
return null;
}
$se =& new CRM_Mailing_Event_BAO_Subscribe();
$se->group_id = $group_id;
$se->contact_id = $contact_id;
$se->time_stamp = date('YmdHis');
$se->hash = substr(sha1("{$group_id}:{$contact_id}:{$dao->email_id}:" . time()), 0, 16);
$se->save();
$contacts = array($contact_id);
require_once 'CRM/Contact/BAO/GroupContact.php';
CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id);
$transaction->commit();
return $se;
}
示例12: setDefaultValues
function setDefaultValues()
{
$defaults = array();
$params = array();
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Contact_BAO_Group::retrieve($params, $defaults);
}
if (isset($this->_groupTree)) {
CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, $viewMode, $inactiveNeeded);
}
return $defaults;
}