本文整理汇总了PHP中CRM_Core_SelectValues::groupContactStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_SelectValues::groupContactStatus方法的具体用法?PHP CRM_Core_SelectValues::groupContactStatus怎么用?PHP CRM_Core_SelectValues::groupContactStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_SelectValues
的用法示例。
在下文中一共展示了CRM_Core_SelectValues::groupContactStatus方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null)
{
$config =& CRM_Core_Config::singleton();
if (($output == CRM_CORE_SELECTOR_CONTROLLER_EXPORT || $output == CRM_CORE_SELECTOR_CONTROLLER_SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIds = true;
} else {
$includeContactIds = false;
}
// note the formvalues were given by CRM_Contact_Form_Search to us
// and contain the search criteria (parameters)
// note that the default action is basic
$result = $this->_query->searchQuery($offset, $rowCount, $sort, false, $includeContactIds);
// process the result of the query
$rows = array();
$mask = CRM_Core_Action::mask(CRM_Core_Permission::getPermission());
$mapMask = $mask & 4095;
// mask value to hide map link if there are not lat/long
$gc = CRM_Core_SelectValues::groupContactStatus();
/* Dirty session hack to get at the context */
$session =& CRM_Core_Session::singleton();
$context = $session->get('context', 'CRM_Contact_Controller_Search');
// CRM_Core_Error::debug( 'p', self::$_properties );
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach ($GLOBALS['_CRM_CONTACT_SELECTOR']['_properties'] as $property) {
if ($property == 'status') {
continue;
}
$row[$property] = $result->{$property};
}
if (!empty($result->postal_code_suffix)) {
$row['postal_code'] .= "-" . $result->postal_code_suffix;
}
if ($output != CRM_CORE_SELECTOR_CONTROLLER_EXPORT || $context == 'smog') {
if (empty($result->status)) {
$row['status'] = ts('Smart');
} else {
$row['status'] = $gc[$result->status];
}
}
if ($output != CRM_CORE_SELECTOR_CONTROLLER_EXPORT && $output != CRM_CORE_SELECTOR_CONTROLLER_SCREEN) {
$row['checkbox'] = CRM_CORE_FORM_CB_PREFIX . $result->contact_id;
if (is_numeric(CRM_Utils_Array::value('geo_code_1', $row))) {
$row['action'] = CRM_Core_Action::formLink(CRM_Contact_Selector::links(), $mask, array('id' => $result->contact_id));
} else {
$row['action'] = CRM_Core_Action::formLink(CRM_Contact_Selector::links(), $mapMask, array('id' => $result->contact_id));
}
$contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
switch ($result->contact_type) {
case 'Individual':
$contact_type .= 'ind.gif" alt="' . ts('Individual') . '" />';
break;
case 'Household':
$contact_type .= 'house.png" alt="' . ts('Household') . '" height="16" width="16" />';
break;
case 'Organization':
$contact_type .= 'org.gif" alt="' . ts('Organization') . '" height="16" width="18" />';
break;
}
$row['contact_type'] = $contact_type;
}
$rows[] = $row;
}
return $rows;
}
示例2: buildQuickForm
/**
* Build the common elements between the search/advanced form.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
$permission = CRM_Core_Permission::getPermission();
// some tasks.. what do we want to do with the selected contacts ?
$tasks = array();
if ($this->_componentMode == 1 || $this->_componentMode == 7) {
$tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
} else {
$className = $this->_modeValue['taskClassName'];
$tasks += $className::permissionedTaskTitles($permission, FALSE);
}
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
$tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
}
$search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
$savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
$this->assign_by_ref('savedSearch', $savedSearchValues);
$this->assign('ssID', $this->_ssID);
}
if ($this->_context === 'smog') {
// CRM-11788, we might want to do this for all of search where force=1
$formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
$getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
$postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
$url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
CRM_Utils_System::redirect($url);
}
$permissionForGroup = FALSE;
if (!empty($this->_groupID)) {
// check if user has permission to edit members of this group
$permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID);
if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
$permissionForGroup = TRUE;
}
// check if _groupID exists, it might not if
// we are displaying a hidden group
if (!isset($this->_group[$this->_groupID])) {
$this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title');
}
// set the group title
$groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
$this->assign_by_ref('group', $groupValues);
// also set ssID if this is a saved search
$ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
$this->assign('ssID', $ssID);
//get the saved search mapping id
if ($ssID) {
$this->_ssID = $ssID;
$ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
$this->assign('ssMappingID', $ssMappingId);
}
// Set dynamic page title for 'Show Members of Group'
CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
}
$group_contact_status = array();
foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
if (!empty($k)) {
$group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
}
}
$this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
$this->assign('permissionedForGroup', $permissionForGroup);
}
// add the go button for the action form, note it is of type 'next' rather than of type 'submit'
if ($this->_context === 'amtg') {
// check if _groupID exists, it might not if
// we are displaying a hidden group
if (!isset($this->_group[$this->_amtgID])) {
$this->assign('permissionedForGroup', FALSE);
$this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
}
// Set dynamic page title for 'Add Members Group'
CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
// also set the group title and freeze the action task with Add Members to Group
$groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
$this->assign_by_ref('group', $groupValues);
$this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('class' => 'crm-form-submit'));
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
$selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
$allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
$this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
$this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
}
$selectedContactIds = array();
$qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
// We use ajax to handle selections only if the search results component_mode is set to "contacts"
if ($qfKeyParam && ($this->get('component_mode') <= 1 || $this->get('component_mode') == 7)) {
$this->addClass('crm-ajax-selection-form');
$qfKeyParam = "civicrm search {$qfKeyParam}";
$selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
$selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
}
$this->assign_by_ref('selectedContactIds', $selectedContactIds);
//.........这里部分代码省略.........
示例3: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$config = CRM_Core_Config::singleton();
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIds = TRUE;
} else {
$includeContactIds = FALSE;
}
// note the formvalues were given by CRM_Contact_Form_Search to us
// and contain the search criteria (parameters)
// note that the default action is basic
if ($rowCount) {
$cacheKey = $this->buildPrevNextCache($sort);
$result = $this->_query->getCachedContacts($cacheKey, $offset, $rowCount, $includeContactIds);
} else {
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
}
// process the result of the query
$rows = array();
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// mask value to hide map link if there are not lat/long
$mapMask = $mask & 4095;
if ($this->_searchContext == 'smog') {
$gc = CRM_Core_SelectValues::groupContactStatus();
}
if ($this->_ufGroupID) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$names = array();
static $skipFields = array('group', 'tag');
foreach ($this->_fields as $key => $field) {
if (!empty($field['in_selector']) && !in_array($key, $skipFields)) {
if (strpos($key, '-') !== FALSE) {
list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $key, 3);
if ($id == 'Primary') {
$locationTypeName = 1;
} else {
$locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
if (!$locationTypeName) {
continue;
}
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array('phone', 'im', 'email'))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = $field['name'];
}
}
}
$names[] = "status";
} elseif (!empty($this->_returnProperties)) {
$names = self::makeProperties($this->_returnProperties);
} else {
$names = self::$_properties;
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$links = self::links($this->_context, $this->_contextMenu, $this->_key);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
$pseudoconstants = array();
// for CRM-3157 purposes
if (in_array('world_region', $names)) {
$pseudoconstants['world_region'] = array('dbName' => 'world_region_id', 'values' => CRM_Core_PseudoConstant::worldRegion());
}
$seenIDs = array();
while ($result->fetch()) {
$row = array();
$this->_query->convertToPseudoNames($result);
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} elseif ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
$key = $property;
$paramsNew = array($key => $result->{$property});
//.........这里部分代码省略.........
示例4: buildQuickForm
/**
* Build the common elements between the search/advanced form
*
* @access public
* @return void
*/
function buildQuickForm()
{
$permission = CRM_Core_Permission::getPermission();
// some tasks.. what do we want to do with the selected contacts ?
$tasks = array('' => ts('- more actions -')) + CRM_Contact_Task::permissionedTaskTitles($permission);
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
$tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
}
$savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
$this->assign_by_ref('savedSearch', $savedSearchValues);
$this->assign('ssID', $this->_ssID);
}
if ($this->_context === 'smog') {
// need to figure out how to freeze a bunch of checkboxes, hack for now
if ($this->_action != CRM_Core_Action::ADVANCED) {
//Fix ME
//$this->_groupElement->freeze( );
}
// also set the group title
$groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
$this->assign_by_ref('group', $groupValues);
// also set ssID if this is a saved search
$ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
$this->assign('ssID', $ssID);
//get the saved search mapping id
if ($ssID) {
$ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
}
if (isset($ssMappingId)) {
$this->assign('ssMappingID', $ssMappingId);
}
$group_contact_status = array();
foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
if (!empty($k)) {
$group_contact_status[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
}
}
$this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
/*
* commented out to fix CRM-4268
*
* $this->addGroupRule( 'group_contact_status',
* ts( 'Please select at least Group Status value.' ), 'required', null, 1 );
*/
// Set dynamic page title for 'Show Members of Group'
CRM_Utils_System::setTitle(ts('Group Members: %1', array(1 => $this->_group[$this->_groupID])));
// check if user has permission to edit members of this group
require_once 'CRM/Contact/BAO/Group.php';
$permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID, $this->_group[$this->_groupID]);
if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
$this->assign('permissionedForGroup', true);
} else {
$this->assign('permissionedForGroup', false);
}
}
/*
* add the go button for the action form, note it is of type 'next' rather than of type 'submit'
*
*/
if ($this->_context === 'amtg') {
// Set dynamic page title for 'Add Members Group'
CRM_Utils_System::setTitle(ts('Add Members: %1', array(1 => $this->_group[$this->_amtgID])));
// also set the group title and freeze the action task with Add Members to Group
$groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
$this->assign_by_ref('group', $groupValues);
$this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
} else {
$this->add('select', 'task', ts('Actions:') . ' ', $tasks);
$this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
}
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', null, '', 'ts_sel', array('checked' => 'checked', 'onclick' => 'toggleTaskAction( true );'));
$this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );"));
/*
* add form checkboxes for each row. This is needed out here to conform to QF protocol
* of all elements being declared in builQuickForm
*/
$rows = $this->get('rows');
if (is_array($rows)) {
$this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
foreach ($rows as $row) {
$this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
}
}
// add buttons
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
$this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'id' => 'Print', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
$this->setDefaultAction('refresh');
}
示例5: buildQuickForm
/**
* Build the common elements between the search/advanced form
*
* @access public
*
* @return void
*/
function buildQuickForm()
{
$permission = CRM_Core_Permission::getPermission();
// some tasks.. what do we want to do with the selected contacts ?
$tasks = array('' => ts('- actions -'));
if ($this->_componentMode == 1 || $this->_componentMode == 7) {
$tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
} else {
require_once str_replace('_', DIRECTORY_SEPARATOR, $this->_modeValue['taskClassName']) . '.php';
eval('$tasks += ' . $this->_modeValue['taskClassName'] . '::permissionedTaskTitles( $permission );');
}
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
$tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
}
$search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
$savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
$this->assign_by_ref('savedSearch', $savedSearchValues);
$this->assign('ssID', $this->_ssID);
}
if ($this->_context === 'smog') {
if (!empty($this->_groupID)) {
// set the group title
$groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
$this->assign_by_ref('group', $groupValues);
// also set ssID if this is a saved search
$ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
$this->assign('ssID', $ssID);
//get the saved search mapping id
if ($ssID) {
$this->_ssID = $ssID;
$ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
$this->assign('ssMappingID', $ssMappingId);
}
}
$group_contact_status = array();
foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
if (!empty($k)) {
$group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
}
}
$this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
$this->assign('permissionedForGroup', FALSE);
if (!empty($this->_groupID)) {
// Set dynamic page title for 'Show Members of Group'
CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
// check if user has permission to edit members of this group
$permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID, $this->_group[$this->_groupID]);
if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
$this->assign('permissionedForGroup', TRUE);
}
}
}
// add the go button for the action form, note it is of type 'next' rather than of type 'submit'
if ($this->_context === 'amtg') {
// Set dynamic page title for 'Add Members Group'
CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
// also set the group title and freeze the action task with Add Members to Group
$groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
$this->assign_by_ref('group', $groupValues);
$this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
} else {
$this->add('select', 'task', ts('Actions:') . ' ', $tasks);
$this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, " . (int) empty($this->_customSearchClass) . ");"));
}
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked', 'onclick' => 'toggleTaskAction( true );'));
$this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
if ($qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues)) {
$qfKeyParam = "civicrm search {$qfKeyParam}";
$selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
$selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
}
$this->assign_by_ref('selectedContactIds', $selectedContactIds);
$allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );toggleContactSelection( 'resetSel', '{$qfKeyParam}', 'reset' );"));
$this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
/*
* add form checkboxes for each row. This is needed out here to conform to QF protocol
* of all elements being declared in builQuickForm
*/
$rows = $this->get('rows');
if (is_array($rows)) {
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true ); toggleCheckboxVals('mark_x_',this);return toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );"));
$unselectedContactIds = array();
foreach ($rows as $row) {
$this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');"));
if (!in_array($row['contact_id'], $selectedContactIds)) {
$unselectedContactIds[] = $row['contact_id'];
}
}
$this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
}
//.........这里部分代码省略.........
示例6: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null)
{
$config =& CRM_Core_Config::singleton();
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIds = true;
} else {
$includeContactIds = false;
}
// note the formvalues were given by CRM_Contact_Form_Search to us
// and contain the search criteria (parameters)
// note that the default action is basic
$result = $this->_query->searchQuery($offset, $rowCount, $sort, false, $includeContactIds);
// process the result of the query
$rows = array();
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$mapMask = $mask & 4095;
// mask value to hide map link if there are not lat/long
$gc = CRM_Core_SelectValues::groupContactStatus();
if ($this->_ufGroupID) {
require_once 'CRM/Core/PseudoConstant.php';
$locationTypes = CRM_Core_PseudoConstant::locationType();
$names = array();
static $skipFields = array('group', 'tag');
foreach ($this->_fields as $key => $field) {
if (CRM_Utils_Array::value('in_selector', $field) && !in_array($key, $skipFields)) {
if (strpos($key, '-') !== false) {
list($fieldName, $id, $type) = explode('-', $key);
if ($id == 'Primary') {
$locationTypeName = 1;
} else {
$locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
if (!$locationTypeName) {
continue;
}
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array('phone', 'im', 'email'))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = $field['name'];
}
}
}
$names[] = "status";
} else {
if (!empty($this->_returnProperties)) {
$names =& self::makeProperties($this->_returnProperties);
} else {
$names = self::$_properties;
}
}
//hack for student data (checkboxs)
$multipleSelectFields = array('preferred_communication_method' => 1);
if (CRM_Core_Permission::access('Quest')) {
require_once 'CRM/Quest/BAO/Student.php';
$multipleSelectFields = CRM_Quest_BAO_Student::$multipleSelectFields;
}
$searchType = null;
if ($this->_action == CRM_Core_Action::BASIC) {
$searchType = 'basic';
} elseif ($this->_action == CRM_Core_Action::ADVANCED) {
$searchType = 'advance';
}
require_once 'CRM/Core/OptionGroup.php';
$links =& self::links($searchType, $this->_contextMenu);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} else {
if ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
//.........这里部分代码省略.........
示例7: buildQuickForm
/**
* Build the common elements between the search/advanced form
*
* @access public
*
* @return void
*/
function buildQuickForm()
{
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
$permission = CRM_Core_Permission::getPermission();
// some tasks.. what do we want to do with the selected contacts ?
$tasks = array('' => ts('- actions -'));
if ($this->_componentMode == 1 || $this->_componentMode == 7) {
$tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
} else {
$className = $this->_modeValue['taskClassName'];
$tasks += $className::permissionedTaskTitles($permission, false);
}
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
$tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
}
$search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
$savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
$this->assign_by_ref('savedSearch', $savedSearchValues);
$this->assign('ssID', $this->_ssID);
}
if ($this->_context === 'smog') {
// CRM-11788, we might want to do this for all of search where force=1
$formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
$getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
$postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
$url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
CRM_Utils_System::redirect($url);
}
if (!empty($this->_groupID)) {
$permissionForGroup = FALSE;
// check if user has permission to edit members of this group
$permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID);
if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
$permissionForGroup = TRUE;
}
// check if _groupID exists, it might not if
// we are displaying a hidden group
if (!isset($this->_group[$this->_groupID])) {
$permissionForGroup = FALSE;
$this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title');
}
$this->assign('permissionedForGroup', $permissionForGroup);
// set the group title
$groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
$this->assign_by_ref('group', $groupValues);
// also set ssID if this is a saved search
$ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
$this->assign('ssID', $ssID);
//get the saved search mapping id
if ($ssID) {
$this->_ssID = $ssID;
$ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
$this->assign('ssMappingID', $ssMappingId);
}
// Set dynamic page title for 'Show Members of Group'
CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
}
$group_contact_status = array();
foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
if (!empty($k)) {
$group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
}
}
$this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
$this->assign('permissionedForGroup', FALSE);
}
// add the go button for the action form, note it is of type 'next' rather than of type 'submit'
if ($this->_context === 'amtg') {
// check if _groupID exists, it might not if
// we are displaying a hidden group
if (!isset($this->_group[$this->_amtgID])) {
$this->assign('permissionedForGroup', FALSE);
$this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
}
// Set dynamic page title for 'Add Members Group'
CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
// also set the group title and freeze the action task with Add Members to Group
$groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
$this->assign_by_ref('group', $groupValues);
$this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
} else {
$this->add('select', 'task', ts('Actions:') . ' ', $tasks);
$this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, 1);"));
}
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked', 'onclick' => 'toggleTaskAction( true );'));
$this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
if ($qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues)) {
$qfKeyParam = "civicrm search {$qfKeyParam}";
$selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
//.........这里部分代码省略.........
示例8: where
/**
* Construct a SQL WHERE clause
*
* @return string, sql fragment with conditional expressions
*/
function where($includeContactIDs = FALSE)
{
$params = array();
$aWhereClause = array();
$count = 1;
#group
$atemp = array();
$aSelectedGroups = CRM_Utils_Array::value('group_contact', $this->_formValues);
if (!empty($aSelectedGroups)) {
foreach ($aSelectedGroups as $groupIds) {
$params[$count] = array($groupIds, 'Integer');
$aGroupname = "cgroup.id = %{$count}";
$atemp[] = $aGroupname;
$count++;
}
}
if (!empty($atemp)) {
$aWhereClause[] = implode(" OR ", $atemp);
}
#Group end
#status
/*$oGroupContact = new CRM_Contact_DAO_GroupContact;
$aGroupFields = $oGroupContact->fields();
$aStatus = explode(', ', $aGroupFields['status']['enumValues']);*/
$aStatus = CRM_Core_SelectValues::groupContactStatus();
$temp = array();
foreach ($aStatus as $status) {
$aSelectedStatus = CRM_Utils_Array::value($status, $this->_formValues);
if (!empty($aSelectedStatus)) {
$params[$count] = array($status, 'String');
$selectedStatus = " group_contact.status = %{$count} ";
$temp[] = $selectedStatus;
$count++;
}
}
if (!empty($temp)) {
$aWhereClause[] = implode(" OR ", $temp);
}
#Status end
#date range
$fromDate = $this->_formValues['start_date'] ? date('Ymd', strtotime($this->_formValues['start_date'])) : NULL;
$toDate = $this->_formValues['end_date'] ? date('Ymd', strtotime($this->_formValues['end_date'])) : NULL;
if (!empty($fromDate)) {
$aWhereClause[] = "history.date >= {$fromDate}";
}
if (!empty($toDate)) {
$aWhereClause[] = "history.date <= {$toDate}";
}
#end date range
$sWhere = '( 1 )';
if (!empty($aWhereClause)) {
$sWhere = implode(' AND ', $aWhereClause);
}
return $this->whereClause($sWhere, $params);
}