本文整理汇总了PHP中CRM_Core_BAO_RecurringEntity::getPositionAndCount方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_RecurringEntity::getPositionAndCount方法的具体用法?PHP CRM_Core_BAO_RecurringEntity::getPositionAndCount怎么用?PHP CRM_Core_BAO_RecurringEntity::getPositionAndCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_RecurringEntity
的用法示例。
在下文中一共展示了CRM_Core_BAO_RecurringEntity::getPositionAndCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $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 string $output
* What should the result set include (web/email/csv).
*
* @return array
* rows in the given offset and rowCount
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_activityClause);
$rows = array();
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = CRM_Core_Permission::check('access CiviMail');
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//get all activity types
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
while ($result->fetch()) {
$row = array();
// ignore rows where we dont have an activity id
if (empty($result->activity_id)) {
continue;
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
$contactId = CRM_Utils_Array::value('contact_id', $row);
if (!$contactId) {
$contactId = CRM_Utils_Array::value('source_contact_id', $row);
}
$row['target_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $targetID);
$row['assignee_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $assigneeID);
list($row['source_contact_name'], $row['source_contact_id']) = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $sourceID, TRUE);
$row['source_contact_name'] = implode(',', array_values($row['source_contact_name']));
$row['source_contact_id'] = implode(',', $row['source_contact_id']);
if ($this->_context == 'search') {
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->activity_id;
}
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$accessMailingReport = FALSE;
$activityTypeId = $row['activity_type_id'];
if ($row['activity_is_test']) {
$row['activity_type'] = $row['activity_type'] . " (test)";
}
$bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes);
$row['mailingId'] = '';
if ($accessCiviMail && ($mailingIDs === TRUE || in_array($result->source_record_id, $mailingIDs)) && $bulkActivityTypeID == $activityTypeId) {
$row['mailingId'] = CRM_Utils_System::url('civicrm/mailing/report', "mid={$result->source_record_id}&reset=1&cid={$contactId}&context=activitySelector");
$row['recipients'] = ts('(recipients)');
$row['target_contact_name'] = '';
$row['assignee_contact_name'] = '';
$accessMailingReport = TRUE;
}
$activityActions = new CRM_Activity_Selector_Activity($result->contact_id, NULL);
$actionLinks = $activityActions->actionLinks($activityTypeId, CRM_Utils_Array::value('source_record_id', $row), $accessMailingReport, CRM_Utils_Array::value('activity_id', $row), $this->_key, $this->_compContext);
$row['action'] = CRM_Core_Action::formLink($actionLinks, NULL, array('id' => $result->activity_id, 'cid' => $contactId, 'cxt' => $this->_context), ts('more'), FALSE, 'activity.selector.row', 'Activity', $result->activity_id);
//carry campaign to selector.
$row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->activity_campaign_id;
if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) {
$row['activity_engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
//Check if recurring activity
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity');
$row['repeat'] = '';
if ($repeat) {
$row['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
$rows[] = $row;
}
return $rows;
}
示例2: getContactActivitySelector
//.........这里部分代码省略.........
$params['caseId'] = NULL;
$context = CRM_Utils_Array::value('context', $params);
// Get contact activities.
$activities = CRM_Activity_BAO_Activity::getActivities($params);
// Add total.
$params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
// Format params and add links.
$contactActivities = array();
if (!empty($activities)) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
// Check logged in user for permission.
$page = new CRM_Core_Page();
CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
$permissions = array($page->_permission);
if (CRM_Core_Permission::check('delete activities')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
foreach ($activities as $activityId => $values) {
$activity = array();
$activity['DT_RowId'] = $activityId;
// Add class to this row if overdue.
$activity['DT_RowClass'] = 'crm-entity';
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values)) && CRM_Utils_Array::value('status_id', $values) == 1) {
$activity['DT_RowClass'] .= ' status-overdue';
} else {
$activity['DT_RowClass'] .= ' status-ontime';
}
$activity['DT_RowAttr'] = array();
$activity['DT_RowAttr']['data-entity'] = 'activity';
$activity['DT_RowAttr']['data-id'] = $activityId;
$activity['activity_type'] = $values['activity_type'];
$activity['subject'] = $values['subject'];
$activity['source_contact_name'] = '';
if ($params['contact_id'] == $values['source_contact_id']) {
$activity['source_contact_name'] = $values['source_contact_name'];
} elseif ($values['source_contact_id']) {
$activity['source_contact_name'] = CRM_Utils_System::href($values['source_contact_name'], 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}");
} else {
$activity['source_contact_name'] = '<em>n/a</em>';
}
$activity['target_contact_name'] = '';
if (isset($values['mailingId']) && !empty($values['mailingId'])) {
$activity['target_contact'] = CRM_Utils_System::href($values['recipients'], 'civicrm/mailing/report/event', "mid={$values['source_record_id']}&reset=1&event=queue&cid={$params['contact_id']}&context=activitySelector");
} elseif (!empty($values['recipients'])) {
$activity['target_contact_name'] = $values['recipients'];
} elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
$activity['target_contact_name'] = '';
foreach ($values['target_contact_name'] as $tcID => $tcName) {
$activity['target_contact_name'] .= CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
}
if ($extraCount = $values['target_contact_counter'] - 1) {
$activity['target_contact_name'] .= ";<br />" . "(" . ts('%1 more', array(1 => $extraCount)) . ")";
}
} elseif (!$values['target_contact_name']) {
$activity['target_contact_name'] = '<em>n/a</em>';
}
$activity['assignee_contact_name'] = '';
if (empty($values['assignee_contact_name'])) {
$activity['assignee_contact_name'] = '<em>n/a</em>';
} elseif (!empty($values['assignee_contact_name'])) {
$count = 0;
$activity['assignee_contact_name'] = '';
foreach ($values['assignee_contact_name'] as $acID => $acName) {
if ($acID && $count < 5) {
$activity['assignee_contact_name'] .= CRM_Utils_System::href($acName, 'civicrm/contact/view', "reset=1&cid={$acID}");
$count++;
if ($count) {
$activity['assignee_contact_name'] .= "; ";
}
if ($count == 4) {
$activity['assignee_contact_name'] .= "(" . ts('more') . ")";
break;
}
}
}
}
$activity['activity_date_time'] = CRM_Utils_Date::customFormat($values['activity_date_time']);
$activity['status_id'] = $activityStatus[$values['status_id']];
// build links
$activity['links'] = '';
$accessMailingReport = FALSE;
if (!empty($values['mailingId'])) {
$accessMailingReport = TRUE;
}
$actionLinks = CRM_Activity_Selector_Activity::actionLinks(CRM_Utils_Array::value('activity_type_id', $values), CRM_Utils_Array::value('source_record_id', $values), $accessMailingReport, CRM_Utils_Array::value('activity_id', $values));
$actionMask = array_sum(array_keys($actionLinks)) & $mask;
$activity['links'] = CRM_Core_Action::formLink($actionLinks, $actionMask, array('id' => $values['activity_id'], 'cid' => $params['contact_id'], 'cxt' => $context, 'caseid' => CRM_Utils_Array::value('case_id', $values)), ts('more'), FALSE, 'activity.tab.row', 'Activity', $values['activity_id']);
if ($values['is_recurring_activity']) {
$activity['is_recurring_activity'] = CRM_Core_BAO_RecurringEntity::getPositionAndCount($values['activity_id'], 'civicrm_activity');
}
array_push($contactActivities, $activity);
}
}
$activitiesDT = array();
$activitiesDT['data'] = $contactActivities;
$activitiesDT['recordsTotal'] = $params['total'];
$activitiesDT['recordsFiltered'] = $params['total'];
return $activitiesDT;
}
示例3: _civicrm_api3_activity_getlist_output
/**
* Get output for activity list.
*
* @see _civicrm_api3_generic_getlist_output
*
* @param array $result
* @param array $request
*
* @return array
*/
function _civicrm_api3_activity_getlist_output($result, $request)
{
$output = array();
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
$data = array('id' => $row[$request['id_field']], 'label' => $row[$request['label_field']] ? $row[$request['label_field']] : ts('(no subject)'), 'description' => array(CRM_Core_Pseudoconstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $row['activity_type_id'])));
if (!empty($row['activity_date_time'])) {
$data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['activity_date_time']);
}
if (!empty($row['source_contact_id'])) {
$data['description'][] = ts('By %1', array(1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['source_contact_id'], 'display_name')));
}
// Add repeating info
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_activity');
$data['extra']['is_recur'] = FALSE;
if ($repeat) {
$data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
$data['extra']['is_recur'] = TRUE;
}
$output[] = $data;
}
}
return $output;
}
示例4: browse
/**
* Browse all events.
*
* @return void
*/
public function browse()
{
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
$createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) {
$this->_sortByCharacter = '';
$this->set('sortByCharacter', '');
}
$this->_force = $this->_searchResult = NULL;
$this->search();
$params = array();
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this);
$whereClause = $this->whereClause($params, FALSE, $this->_force);
$this->pagerAToZ($whereClause, $params);
$params = array();
$whereClause = $this->whereClause($params, TRUE, $this->_force);
// because is_template != 1 would be to simple
$whereClause .= ' AND (is_template = 0 OR is_template IS NULL)';
$this->pager($whereClause, $params);
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
// get all custom groups sorted by weight
$manageEvent = array();
$query = "\n SELECT *\n FROM civicrm_event\n WHERE {$whereClause}\nORDER BY start_date desc\n LIMIT {$offset}, {$rowCount}";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
$permissions = CRM_Event_BAO_Event::checkPermission();
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
// get the list of active event pcps
$eventPCPS = array();
$pcpDao = new CRM_PCP_DAO_PCPBlock();
$pcpDao->entity_table = 'civicrm_event';
$pcpDao->find();
while ($pcpDao->fetch()) {
$eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id;
}
// check if we're in shopping cart mode for events
$enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
$this->assign('eventCartEnabled', $enableCart);
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
$eventType = CRM_Core_OptionGroup::values('event_type');
while ($dao->fetch()) {
if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
$manageEvent[$dao->id] = array();
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event');
$manageEvent[$dao->id]['repeat'] = '';
if ($repeat) {
$manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) {
$action -= CRM_Core_Action::DELETE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) {
$action -= CRM_Core_Action::UPDATE;
}
$manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), TRUE, 'event.manage.list', 'Event', $dao->id);
$params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1);
$defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params);
if (isset($defaults['location']['address'][1]['city'])) {
$manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city'];
}
if (isset($defaults['location']['address'][1]['state_province_id'])) {
$manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']);
}
//show campaigns on selector.
$manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
$manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId());
$manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS);
$manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType);
$manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id');
// allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled
CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id));
}
}
$manageEvent['tab'] = self::tabs($enableCart);
$this->assign('rows', $manageEvent);
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0');
$findParticipants['statusCounted'] = implode(', ', array_values($statusTypes));
$findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending));
$this->assign('findParticipants', $findParticipants);
}
示例5: _civicrm_api3_event_getlist_output
/**
* Get event list output.
*
* @see _civicrm_api3_generic_getlist_output
*
* @param array $result
* @param array $request
*
* @return array
*/
function _civicrm_api3_event_getlist_output($result, $request)
{
$output = array();
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
$data = array('id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => array(CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id'])));
if (!empty($row['start_date'])) {
$data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']);
}
if (!empty($row['summary'])) {
$data['description'][] = $row['summary'];
}
// Add repeating info
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_event');
$data['extra']['is_recur'] = FALSE;
if ($repeat) {
$data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
$data['extra']['is_recur'] = TRUE;
}
$output[] = $data;
}
}
return $output;
}