本文整理汇总了PHP中CRM_Event_PseudoConstant::event方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_PseudoConstant::event方法的具体用法?PHP CRM_Event_PseudoConstant::event怎么用?PHP CRM_Event_PseudoConstant::event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Event_PseudoConstant::event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValueLabelMap
protected static function getValueLabelMap($name)
{
static $valueLabelMap = NULL;
if ($valueLabelMap === NULL) {
$valueLabelMap['activity_type'] = \CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
asort($valueLabelMap['activity_type']);
$valueLabelMap['activity_status'] = \CRM_Core_PseudoConstant::activityStatus();
$valueLabelMap['event_type'] = \CRM_Event_PseudoConstant::eventType();
$valueLabelMap['civicrm_event'] = \CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
$valueLabelMap['civicrm_participant_status_type'] = \CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$valueLabelMap['event_template'] = \CRM_Event_PseudoConstant::eventTemplates();
$valueLabelMap['auto_renew_options'] = \CRM_Core_OptionGroup::values('auto_renew_options');
$valueLabelMap['contact_date_reminder_options'] = \CRM_Core_OptionGroup::values('contact_date_reminder_options');
$valueLabelMap['civicrm_membership_type'] = \CRM_Member_PseudoConstant::membershipType();
$allCustomFields = \CRM_Core_BAO_CustomField::getFields('');
$dateFields = array('birth_date' => ts('Birth Date'), 'created_date' => ts('Created Date'), 'modified_date' => ts('Modified Date'));
foreach ($allCustomFields as $fieldID => $field) {
if ($field['data_type'] == 'Date') {
$dateFields["custom_{$fieldID}"] = $field['label'];
}
}
$valueLabelMap['civicrm_contact'] = $dateFields;
}
return $valueLabelMap[$name];
}
示例2: browse
/**
* Browse all custom data groups.
*
* @param string $action the action to be invoked
*
* @return void
* @access public
*/
function browse($action = NULL)
{
// get all custom groups sorted by weight
$customGroup = array();
$dao = new CRM_Core_DAO_CustomGroup();
$dao->orderBy('weight, title');
$dao->find();
while ($dao->fetch()) {
$customGroup[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $customGroup[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on custom_group properties.
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$customGroup[$dao->id]['order'] = $customGroup[$dao->id]['weight'];
$customGroup[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id));
}
$customGroupExtends = CRM_Core_SelectValues::customGroupExtends();
foreach ($customGroup as $key => $array) {
CRM_Core_DAO_CustomGroup::addDisplayEnums($customGroup[$key]);
$customGroup[$key]['extends_display'] = $customGroupExtends[$customGroup[$key]['extends']];
}
//fix for Displaying subTypes
$subTypes = array();
$subTypes['Activity'] = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
$subTypes['Contribution'] = CRM_Contribute_PseudoConstant::contributionType();
$subTypes['Membership'] = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
$subTypes['Event'] = CRM_Core_OptionGroup::values('event_type');
$subTypes['Grant'] = CRM_Core_OptionGroup::values('grant_type');
$subTypes['Campaign'] = CRM_Campaign_PseudoConstant::campaignType();
$subTypes['Participant'] = array();
$subTypes['ParticipantRole'] = CRM_Core_OptionGroup::values('participant_role');
$subTypes['ParticipantEventName'] = CRM_Event_PseudoConstant::event();
$subTypes['ParticipantEventType'] = CRM_Core_OptionGroup::values('event_type');
$subTypes['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL);
$subTypes['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL);
$subTypes['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL);
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual');
$relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization');
$relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household');
$allRelationshipType = array();
$allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
//adding subtype specific relationships CRM-5256
$relSubType = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($relSubType as $subType => $val) {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
$allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes);
}
$subTypes['Relationship'] = $allRelationshipType;
$cSubTypes = CRM_Core_Component::contactSubTypes();
$contactSubTypes = array();
foreach ($cSubTypes as $key => $value) {
$contactSubTypes[$key] = $key;
}
$subTypes['Contact'] = $contactSubTypes;
CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($subTypes);
foreach ($customGroup as $key => $values) {
$subValue = CRM_Utils_Array::value('extends_entity_column_value', $customGroup[$key]);
$subName = CRM_Utils_Array::value('extends_entity_column_id', $customGroup[$key]);
$type = CRM_Utils_Array::value('extends', $customGroup[$key]);
if ($subValue) {
$subValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subValue, 1, -1));
$colValue = NULL;
foreach ($subValue as $sub) {
if ($sub) {
if ($type == 'Participant') {
if ($subName == 1) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantRole'][$sub] : $subTypes['ParticipantRole'][$sub];
} elseif ($subName == 2) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventName'][$sub] : $subTypes['ParticipantEventName'][$sub];
} elseif ($subName == 3) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventType'][$sub] : $subTypes['ParticipantEventType'][$sub];
}
} elseif ($type == 'Relationship') {
$colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_a_b'] : $subTypes[$type][$sub . '_a_b'];
if (isset($subTypes[$type][$sub . '_b_a'])) {
$colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_b_a'] : $subTypes[$type][$sub . '_b_a'];
}
} else {
$colValue = $colValue ? $colValue . (isset($subTypes[$type][$sub]) ? ', ' . $subTypes[$type][$sub] : '') : (isset($subTypes[$type][$sub]) ? $subTypes[$type][$sub] : '');
}
}
}
$customGroup[$key]["extends_entity_column_value"] = $colValue;
} else {
if (is_array(CRM_Utils_Array::value($type, $subTypes))) {
$customGroup[$key]["extends_entity_column_value"] = ts("Any");
//.........这里部分代码省略.........
示例3: alterDisplay
/**
* Alter display of rows.
*
* Iterate through the rows retrieved via SQL and make changes for display purposes,
* such as rendering contacts as links.
*
* @param array $rows
* Rows generated by SQL, with an array for each row.
*/
public function alterDisplay(&$rows)
{
$entryFound = FALSE;
$eventType = CRM_Core_OptionGroup::values('event_type');
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
$eventId = $row['civicrm_participant_event_id'];
if ($eventId) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($eventId, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $eventId, $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = TRUE;
}
// handle event type id
$this->_initBasicRow($rows, $entryFound, $row, 'civicrm_event_event_type_id', $rowNum, $eventType);
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
$statusId = $row['civicrm_participant_status_id'];
if ($statusId) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($statusId, FALSE, 'label');
}
$entryFound = TRUE;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
$roleId = $row['civicrm_participant_role_id'];
if ($roleId) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $roleId);
$roleId = array();
foreach ($roles as $role) {
$roleId[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
$rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $roleId);
}
$entryFound = TRUE;
}
// Handel value seperator in Fee Level
if (array_key_exists('civicrm_participant_participant_fee_level', $row)) {
$feeLevel = $row['civicrm_participant_participant_fee_level'];
if ($feeLevel) {
CRM_Event_BAO_Participant::fixEventLevel($feeLevel);
$rows[$rowNum]['civicrm_participant_participant_fee_level'] = $feeLevel;
}
$entryFound = TRUE;
}
// Convert display name to link
$displayName = CRM_Utils_Array::value('civicrm_contact_sort_name_linked', $row);
$cid = CRM_Utils_Array::value('civicrm_contact_id', $row);
$id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row);
if ($displayName && $cid && $id) {
$url = CRM_Report_Utils_Report::getNextUrl('contact/detail', "reset=1&force=1&id_op=eq&id_value={$cid}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
$viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant", "reset=1&id={$id}&cid={$cid}&action=view&context=participant");
$contactTitle = ts('View Contact Details');
$participantTitle = ts('View Participant Record');
$rows[$rowNum]['civicrm_contact_sort_name_linked'] = "<a title='{$contactTitle}' href={$url}>{$displayName}</a>";
if ($this->_outputMode !== 'csv') {
$rows[$rowNum]['civicrm_contact_sort_name_linked'] .= "<span style='float: right;'><a title='{$participantTitle}' href={$viewUrl}>" . ts('View') . "</a></span>";
}
$entryFound = TRUE;
}
// Handle country id
if (array_key_exists('civicrm_address_country_id', $row)) {
$countryId = $row['civicrm_address_country_id'];
if ($countryId) {
$rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($countryId, TRUE);
}
$entryFound = TRUE;
}
// Handle state/province id
if (array_key_exists('civicrm_address_state_province_id', $row)) {
$provinceId = $row['civicrm_address_state_province_id'];
if ($provinceId) {
$rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($provinceId, TRUE);
}
$entryFound = TRUE;
}
// Handle employer id
if (array_key_exists('civicrm_contact_employer_id', $row)) {
$employerId = $row['civicrm_contact_employer_id'];
if ($employerId) {
$rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($employerId);
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $employerId, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_employer_id_link'] = $url;
$rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.');
//.........这里部分代码省略.........
示例4: customGroups
/**
* @param $xml
* @param $idMap
*/
public function customGroups(&$xml, &$idMap)
{
foreach ($xml->CustomGroups as $customGroupsXML) {
foreach ($customGroupsXML->CustomGroup as $customGroupXML) {
$customGroup = new CRM_Core_DAO_CustomGroup();
if (!$this->copyData($customGroup, $customGroupXML, TRUE, 'name')) {
$idMap['custom_group'][$customGroup->name] = $customGroup->id;
continue;
}
$saveAgain = FALSE;
if (!isset($customGroup->table_name) || empty($customGroup->table_name)) {
// fix table name
$customGroup->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($customGroup->title, '_', 32)) . "_{$customGroup->id}";
$saveAgain = TRUE;
}
// fix extends stuff if it exists
if (isset($customGroupXML->extends_entity_column_value_option_group) && isset($customGroupXML->extends_entity_column_value)) {
$valueIDs = array();
$optionValues = explode(",", $customGroupXML->extends_entity_column_value);
$optValues = implode("','", $optionValues);
if (trim($customGroup->extends) != 'Participant') {
if ($customGroup->extends == 'Relationship') {
foreach ($optionValues as $key => $value) {
$relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_RelationshipType', $value, 'id', 'name_a_b');
$valueIDs[] = $relTypeId;
}
} elseif (in_array($customGroup->extends, array('Individual', 'Organization', 'Household'))) {
$valueIDs = $optionValues;
} else {
$sql = "\nSELECT v.value\nFROM civicrm_option_value v\nINNER JOIN civicrm_option_group g ON g.id = v.option_group_id\nWHERE g.name = %1\nAND v.name IN ('{$optValues}')\n";
$params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'));
$dao =& CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) {
$valueIDs[] = $dao->value;
}
}
if (!empty($valueIDs)) {
$customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $valueIDs) . CRM_Core_DAO::VALUE_SEPARATOR;
unset($valueIDs);
// Note: No need to set extends_entity_column_id here.
$saveAgain = TRUE;
}
} else {
// when custom group extends 'Participant'
$sql = "\nSELECT v.value\nFROM civicrm_option_value v\nINNER JOIN civicrm_option_group g ON g.id = v.option_group_id\nWHERE g.name = 'custom_data_type'\nAND v.name = %1\n";
$params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'));
$valueID = (int) CRM_Core_DAO::singleValueQuery($sql, $params);
if ($valueID) {
$customGroup->extends_entity_column_id = $valueID;
}
$optionIDs = array();
switch ($valueID) {
case 1:
// ParticipantRole
$condition = "AND v.name IN ( '{$optValues}' )";
$optionIDs = CRM_Core_OptionGroup::values('participant_role', FALSE, FALSE, FALSE, $condition, 'name');
break;
case 2:
// ParticipantEventName
$condition = "( is_template IS NULL OR is_template != 1 ) AND title IN( '{$optValues}' )";
$optionIDs = CRM_Event_PseudoConstant::event(NULL, FALSE, $condition);
break;
case 3:
// ParticipantEventType
$condition = "AND v.name IN ( '{$optValues}' )";
$optionIDs = CRM_Core_OptionGroup::values('event_type', FALSE, FALSE, FALSE, $condition, 'name');
break;
}
if (is_array($optionIDs) && !empty($optionIDs)) {
$customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($optionIDs)) . CRM_Core_DAO::VALUE_SEPARATOR;
$saveAgain = TRUE;
}
}
}
if ($saveAgain) {
$customGroup->save();
}
CRM_Core_BAO_CustomGroup::createTable($customGroup);
$idMap['custom_group'][$customGroup->name] = $customGroup->id;
}
}
}
示例5: checkPermission
/**
* make sure that the user has permission to access this event
*
* @param int $id the id of the event
* @param int $name the name or title of the event
*
* @return string the permission that the user has (or null)
* @access public
* @static
*/
static function checkPermission($eventId = null, $type = CRM_Core_Permission::VIEW)
{
static $permissions = null;
if (empty($permissions)) {
require_once 'CRM/ACL/API.php';
require_once 'CRM/Event/PseudoConstant.php';
$allEvents = CRM_Event_PseudoConstant::event(null, true);
$createdEvents = array();
$session =& CRM_Core_Session::singleton();
if ($userID = $session->get('userID')) {
$createdEvents = array_keys(CRM_Event_PseudoConstant::event(null, true, "created_id={$userID}"));
}
// Note: for a multisite setup, a user with edit all events, can edit all events
// including those from other sites
if (CRM_Core_Permission::check('edit all events')) {
$permissions[CRM_Core_Permission::EDIT] = array_keys($allEvents);
} else {
$permissions[CRM_Core_Permission::EDIT] =& CRM_ACL_API::group(CRM_Core_Permission::EDIT, null, 'civicrm_event', $allEvents, $createdEvents);
}
if (CRM_Core_Permission::check('edit all events')) {
$permissions[CRM_Core_Permission::VIEW] = array_keys($allEvents);
} else {
if (CRM_Core_Permission::check('access CiviEvent') && CRM_Core_Permission::check('view event participants')) {
// use case: allow "view all events" but NOT "edit all events"
// so for a normal site allow users with these two permissions to view all events AND
// at the same time also allow any hook to override if needed.
$createdEvents = array_keys($allEvents);
}
$permissions[CRM_Core_Permission::VIEW] =& CRM_ACL_API::group(CRM_Core_Permission::VIEW, null, 'civicrm_event', $allEvents, $createdEvents);
}
$permissions[CRM_Core_Permission::DELETE] = array();
if (CRM_Core_Permission::check('delete in CiviEvent')) {
// Note: we want to restrict the scope of delete permission to
// events that are editable/viewable (usecase multisite).
// We can remove array_intersect once we have ACL support for delete functionality.
$permissions[CRM_Core_Permission::DELETE] = array_intersect($permissions[CRM_Core_Permission::EDIT], $permissions[CRM_Core_Permission::VIEW]);
}
}
if ($eventId) {
return in_array($eventId, $permissions[$type]) ? true : false;
}
return $permissions;
}
示例6: array
/**
* Retrieve list of Scheduled Reminders
*
* @param bool $namesOnly return simple list of names
*
* @param null $entityValue
* @param null $id
*
* @return array (reference) reminder list
* @static
* @access public
*/
static function &getList($namesOnly = FALSE, $entityValue = NULL, $id = NULL)
{
$activity_type = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
$activity_status = CRM_Core_PseudoConstant::activityStatus();
$event_type = CRM_Event_PseudoConstant::eventType();
$civicrm_event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
$civicrm_participant_status_type = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$event_template = CRM_Event_PseudoConstant::eventTemplates();
$civicrm_contact = self::getDateFields();
$auto_renew_options = CRM_Core_OptionGroup::values('auto_renew_options');
$contact_date_reminder_options = CRM_Core_OptionGroup::values('contact_date_reminder_options');
$civicrm_membership_type = CRM_Member_PseudoConstant::membershipType();
$entity = array('civicrm_activity' => 'Activity', 'civicrm_participant' => 'Event', 'civicrm_membership' => 'Member', 'civicrm_contact' => 'Contact');
$query = "\nSELECT\n title,\n cam.entity,\n cas.id as id,\n cam.entity_value as entityValue,\n cas.entity_value as entityValueIds,\n cam.entity_status as entityStatus,\n cas.entity_status as entityStatusIds,\n cas.start_action_date as entityDate,\n cas.start_action_offset,\n cas.start_action_unit,\n cas.start_action_condition,\n cas.absolute_date,\n is_repeat,\n is_active\n\nFROM civicrm_action_schedule cas\nLEFT JOIN civicrm_action_mapping cam ON (cam.id = cas.mapping_id)\n";
$params = CRM_Core_DAO::$_nullArray;
if ($entityValue and $id) {
$where = "\nWHERE cas.entity_value = {$id} AND\n cam.entity_value = '{$entityValue}'";
$query .= $where;
$params = array(1 => array($id, 'Integer'), 2 => array($entityValue, 'String'));
}
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$list[$dao->id]['id'] = $dao->id;
$list[$dao->id]['title'] = $dao->title;
$list[$dao->id]['start_action_offset'] = $dao->start_action_offset;
$list[$dao->id]['start_action_unit'] = $dao->start_action_unit;
$list[$dao->id]['start_action_condition'] = $dao->start_action_condition;
$list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate));
$list[$dao->id]['absolute_date'] = $dao->absolute_date;
$status = $dao->entityStatus;
$statusArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityStatusIds);
foreach ($statusArray as &$s) {
$s = CRM_Utils_Array::value($s, ${$status});
}
$statusIds = implode(', ', $statusArray);
$value = $dao->entityValue;
$valueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds);
foreach ($valueArray as &$v) {
$v = CRM_Utils_Array::value($v, ${$value});
}
$valueIds = implode(', ', $valueArray);
$list[$dao->id]['entity'] = $entity[$dao->entity];
$list[$dao->id]['value'] = $valueIds;
$list[$dao->id]['status'] = $statusIds;
$list[$dao->id]['is_repeat'] = $dao->is_repeat;
$list[$dao->id]['is_active'] = $dao->is_active;
}
return $list;
}
示例7: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = false;
$eventType = CRM_Core_OptionGroup::values('event_type');
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
if ($value = $row['civicrm_participant_event_id']) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, false);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $value, $this->_absoluteUrl, $this->_id);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = true;
}
// handle event type id
if (array_key_exists('civicrm_event_event_type_id', $row)) {
if ($value = $row['civicrm_event_event_type_id']) {
$rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value];
}
$entryFound = true;
}
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
if ($value = $row['civicrm_participant_status_id']) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, false);
}
$entryFound = true;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
if ($value = $row['civicrm_participant_role_id']) {
$rows[$rowNum]['civicrm_participant_role_id'] = CRM_Event_PseudoConstant::participantRole($value, false);
}
$entryFound = true;
}
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
break;
}
}
}
示例8: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$id = CRM_PCP_BAO_PCP::getSupporterProfileId($this->_pageId, $this->_component);
if (CRM_PCP_BAO_PCP::checkEmailProfile($id)) {
$this->assign('profileDisplay', TRUE);
}
$fields = NULL;
if ($this->_contactID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
}
$this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
} else {
CRM_Core_BAO_CMSUser::buildForm($this, $id, TRUE);
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
}
if ($fields) {
$this->assign('fields', $fields);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if (isset($field['data_type']) && $field['data_type'] == 'File') {
// ignore file upload fields
continue;
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
// CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
if ($field['add_captcha'] && !$this->_contactID) {
$addCaptcha = TRUE;
}
}
if ($addCaptcha) {
$captcha =& CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
}
if ($this->_component == 'contribute') {
$this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
} elseif ($this->_component == 'event') {
$this->assign('campaignName', CRM_Event_PseudoConstant::event($this->_pageId));
}
if ($this->_single) {
$button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
} else {
$button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE);
}
$this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
$this->addButtons($button);
}
示例9: fixFormValues
function fixFormValues()
{
// if this search has been forced
// then see if there are any get values, and if so over-ride the post values
// note that this means that GET over-rides POST :)
$event = CRM_Utils_Request::retrieve('event', 'Positive', CRM_Core_DAO::$_nullObject);
if ($event) {
require_once 'CRM/Event/PseudoConstant.php';
$this->_formValues['event_id'] = $event;
$this->_formValues['event_name'] = CRM_Event_PseudoConstant::event($event, true);
}
$status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
if (isset($status)) {
require_once 'CRM/Event/PseudoConstant.php';
if ($status === 'true') {
$statusTypes = CRM_Event_PseudoConstant::participantStatus(null, "is_counted = 1");
} elseif ($status === 'false') {
$statusTypes = CRM_Event_PseudoConstant::participantStatus(null, "is_counted = 0");
} elseif (is_numeric($status)) {
$status = (int) $status;
$statusTypes = array($status => CRM_Event_PseudoConstant::participantStatus($status));
}
$status = array();
foreach ($statusTypes as $key => $value) {
$status[$key] = 1;
}
$this->_formValues['participant_status_id'] = $status;
}
$role = CRM_Utils_Request::retrieve('role', 'String', CRM_Core_DAO::$_nullObject);
if (isset($role)) {
require_once 'CRM/Event/PseudoConstant.php';
if ($role === 'true') {
$roleTypes = CRM_Event_PseudoConstant::participantRole(null, "filter = 1");
} elseif ($role === 'false') {
$roleTypes = CRM_Event_PseudoConstant::participantRole(null, "filter = 0");
} elseif (is_numeric($role)) {
$role = (int) $role;
$roleTypes = array($role => CRM_Event_PseudoConstant::participantRole($role));
}
$role = array();
foreach ($roleTypes as $key => $value) {
$role[$key] = 1;
}
$this->_formValues['participant_role_id'] = $role;
}
$type = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject);
if ($type) {
$this->_formValues['event_type'] = $type;
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if ($cid) {
$cid = CRM_Utils_Type::escape($cid, 'Integer');
if ($cid > 0) {
$this->_formValues['contact_id'] = $cid;
// also assign individual mode to the template
$this->_single = true;
}
}
}
示例10: alterComponentDisplay
function alterComponentDisplay(&$componentRows)
{
// custom code to alter rows
require_once 'CRM/Core/PseudoConstant.php';
$activityTypes = CRM_Core_PseudoConstant::activityType(true, false);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$entryFound = false;
foreach ($componentRows as $contactID => $components) {
foreach ($components as $component => $rows) {
foreach ($rows as $rowNum => $row) {
// handle contribution
if ($component == 'contribution_civireport') {
require_once 'CRM/Contribute/PseudoConstant.php';
if ($val = CRM_Utils_Array::value('civicrm_contribution_contribution_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_type_id'] = CRM_Contribute_PseudoConstant::contributionType($val, false);
}
if ($val = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant::contributionStatus($val);
}
$entryFound = true;
}
if ($component == 'membership_civireport') {
require_once 'CRM/Member/PseudoConstant.php';
if ($val = CRM_Utils_Array::value('civicrm_membership_membership_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant::membershipType($val, false);
}
if ($val = CRM_Utils_Array::value('civicrm_membership_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val, false);
}
$entryFound = true;
}
if ($component == 'participant_civireport') {
require_once 'CRM/Event/PseudoConstant.php';
if ($val = CRM_Utils_Array::value('civicrm_participant_event_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($val, false);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $val, $this->_absoluteUrl, $this->_id);
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income details for this Event.");
$entryFound = true;
}
if ($val = CRM_Utils_Array::value('civicrm_participant_participant_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($val, false);
}
if ($val = CRM_Utils_Array::value('civicrm_participant_role_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = CRM_Event_PseudoConstant::participantRole($val, false);
}
$entryFound = true;
}
if ($component == 'activity_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_activity_activity_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
}
if ($val = CRM_Utils_Array::value('civicrm_activity_activity_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
}
$entryFound = true;
}
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
break;
}
}
}
}
}
示例11: alterDisplay
/**
* Alter row display.
*
* @param array $rows
*/
public function alterDisplay(&$rows) {
// custom code to alter rows
$entryFound = FALSE;
$eventType = CRM_Core_OptionGroup::values('event_type');
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
$honorTypes = CRM_Core_OptionGroup::values('honor_type', FALSE, FALSE, FALSE, NULL, 'label');
$genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id', array('localize' => TRUE));
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_participant_event_id', $row)) {
if ($value = $row['civicrm_participant_event_id']) {
$rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income',
'reset=1&force=1&id_op=in&id_value=' . $value,
$this->_absoluteUrl, $this->_id, $this->_drilldownReport
);
$rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
$rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
}
$entryFound = TRUE;
}
// handle event type id
if (array_key_exists('civicrm_event_event_type_id', $row)) {
if ($value = $row['civicrm_event_event_type_id']) {
$rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value];
}
$entryFound = TRUE;
}
// handle participant status id
if (array_key_exists('civicrm_participant_status_id', $row)) {
if ($value = $row['civicrm_participant_status_id']) {
$rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, FALSE, 'label');
}
$entryFound = TRUE;
}
// handle participant role id
if (array_key_exists('civicrm_participant_role_id', $row)) {
if ($value = $row['civicrm_participant_role_id']) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
$value = array();
foreach ($roles as $role) {
$value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
$rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
}
$entryFound = TRUE;
}
// Handle value separator in Fee Level
if (array_key_exists('civicrm_participant_participant_fee_level', $row)) {
if ($value = $row['civicrm_participant_participant_fee_level']) {
CRM_Event_BAO_Participant::fixEventLevel($value);
$rows[$rowNum]['civicrm_participant_participant_fee_level'] = $value;
}
$entryFound = TRUE;
}
// Convert display name to link
if (($displayName = CRM_Utils_Array::value('civicrm_contact_sort_name', $row)) &&
($cid = CRM_Utils_Array::value('civicrm_contact_id', $row)) &&
($id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row))
) {
$url = CRM_Report_Utils_Report::getNextUrl('contact/detail',
"reset=1&force=1&id_op=eq&id_value=$cid",
$this->_absoluteUrl, $this->_id, $this->_drilldownReport
);
$viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant",
"reset=1&id=$id&cid=$cid&action=view&context=participant"
);
$contactTitle = ts('View Contact Details');
$participantTitle = ts('View Participant Record');
$rows[$rowNum]['civicrm_contact_sort_name'] = "<a title='$contactTitle' href=$url>$displayName</a>";
if ($this->_outputMode !== 'csv' && $this->_outputMode !== 'pdf' && $this->_outputMode !== 'print') {
$rows[$rowNum]['civicrm_contact_sort_name'] .= "<span style='float: right;'>
<a title='$participantTitle' href=$viewUrl> " . ts('View') . "</a></span>";
}
$entryFound = TRUE;
}
// Handle country id
if (array_key_exists('civicrm_address_country_id', $row)) {
if ($value = $row['civicrm_address_country_id']) {
//.........这里部分代码省略.........
示例12: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
*/
public function run()
{
$session = CRM_Core_Session::singleton();
$config = CRM_Core_Config::singleton();
$permissionCheck = FALSE;
$statusMessage = '';
if ($config->userFramework != 'Joomla') {
$permissionCheck = CRM_Core_Permission::check('administer CiviCRM');
}
//get the pcp id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$prms = array('id' => $this->_id);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
$this->_component = $pcpInfo['page_type'];
if (empty($pcpInfo)) {
$statusMessage = ts('The personal campaign page you requested is currently unavailable.');
CRM_Core_Error::statusBounce($statusMessage, $config->userFrameworkBaseURL);
}
CRM_Utils_System::setTitle($pcpInfo['title']);
$this->assign('pcp', $pcpInfo);
$pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
// check if PCP is created by anonymous user
$anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this);
if ($anonymousPCP) {
$loginURL = $config->userSystem->getLoginURL();
$anonMessage = ts('Once you\'ve received your new account welcome email, you can <a href=%1>click here</a> to login and promote your campaign page.', array(1 => $loginURL));
CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success');
} else {
$statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.');
}
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($pcpInfo['page_type']);
$pcpBlock->entity_id = $pcpInfo['page_id'];
$pcpBlock->find(TRUE);
// Redirect back to source page in case of error.
if ($pcpInfo['page_type'] == 'contribute') {
$urlBase = 'civicrm/contribute/transact';
} elseif ($pcpInfo['page_type'] == 'event') {
$urlBase = 'civicrm/event/register';
}
if ($pcpInfo['status_id'] != $approvedId || !$pcpInfo['is_active']) {
if ($pcpInfo['contact_id'] != $session->get('userID') && !$permissionCheck) {
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, "reset=1&id=" . $pcpInfo['page_id'], FALSE, NULL, FALSE, TRUE));
}
} else {
$getStatus = CRM_PCP_BAO_PCP::getStatus($this->_id, $this->_component);
if (!$getStatus) {
// PCP not enabled for this contribution page. Forward everyone to source page
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, "reset=1&id=" . $pcpInfo['page_id'], FALSE, NULL, FALSE, TRUE));
}
}
$default = array();
if ($pcpBlock->target_entity_type == 'contribute') {
$urlBase = 'civicrm/contribute/transact';
} elseif ($pcpBlock->target_entity_type == 'event') {
$urlBase = 'civicrm/event/register';
}
if ($pcpBlock->entity_table == 'civicrm_event') {
$page_class = 'CRM_Event_DAO_Event';
$this->assign('pageName', CRM_Event_PseudoConstant::event($pcpInfo['page_id']));
CRM_Core_DAO::commonRetrieveAll($page_class, 'id', $pcpInfo['page_id'], $default, array('start_date', 'end_date', 'registration_start_date', 'registration_end_date'));
} elseif ($pcpBlock->entity_table == 'civicrm_contribution_page') {
$page_class = 'CRM_Contribute_DAO_ContributionPage';
$this->assign('pageName', CRM_Contribute_PseudoConstant::contributionPage($pcpInfo['page_id'], TRUE));
CRM_Core_DAO::commonRetrieveAll($page_class, 'id', $pcpInfo['page_id'], $default, array('start_date', 'end_date'));
}
$pageInfo = $default[$pcpInfo['page_id']];
if ($pcpInfo['contact_id'] == $session->get('userID')) {
$owner = $pageInfo;
$owner['status'] = CRM_Utils_Array::value($pcpInfo['status_id'], $pcpStatus);
$this->assign('owner', $owner);
$link = CRM_PCP_BAO_PCP::pcpLinks();
$hints = array(CRM_Core_Action::UPDATE => ts('Change the content and appearance of your page'), CRM_Core_Action::DETACH => ts('Send emails inviting your friends to support your campaign!'), CRM_Core_Action::VIEW => ts('Copy this link to share directly with your network!'), CRM_Core_Action::BROWSE => ts('Update your personal contact information'), CRM_Core_Action::DISABLE => ts('De-activate the page (you can re-activate it later)'), CRM_Core_Action::ENABLE => ts('Activate the page (you can de-activate it later)'), CRM_Core_Action::DELETE => ts('Remove the page (this cannot be undone!)'));
$replace = array('id' => $this->_id, 'block' => $pcpBlock->id, 'pageComponent' => $this->_component);
if (!$pcpBlock->is_tellfriend_enabled || CRM_Utils_Array::value('status_id', $pcpInfo) != $approvedId) {
unset($link['all'][CRM_Core_Action::DETACH]);
}
switch ($pcpInfo['is_active']) {
case 1:
unset($link['all'][CRM_Core_Action::ENABLE]);
break;
case 0:
unset($link['all'][CRM_Core_Action::DISABLE]);
break;
}
$this->assign('links', $link['all']);
$this->assign('hints', $hints);
$this->assign('replace', $replace);
}
//.........这里部分代码省略.........
示例13: alterComponentDisplay
/**
* @param $componentRows
*/
public function alterComponentDisplay(&$componentRows)
{
// custom code to alter rows
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$entryFound = FALSE;
foreach ($componentRows as $contactID => $components) {
foreach ($components as $component => $rows) {
foreach ($rows as $rowNum => $row) {
// handle contribution
if ($component == 'contribution_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] = CRM_Contribute_PseudoConstant::financialType($val, FALSE);
}
if ($val = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant::contributionStatus($val);
}
$entryFound = TRUE;
}
if ($component == 'membership_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_membership_membership_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant::membershipType($val, FALSE);
}
if ($val = CRM_Utils_Array::value('civicrm_membership_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val, FALSE);
}
$entryFound = TRUE;
}
if ($component == 'participant_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_participant_event_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($val, FALSE);
$url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $val, $this->_absoluteUrl, $this->_id);
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
$entryFound = TRUE;
}
if ($val = CRM_Utils_Array::value('civicrm_participant_participant_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($val, FALSE);
}
if ($val = CRM_Utils_Array::value('civicrm_participant_role_id', $row)) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val);
$value = array();
foreach ($roles as $role) {
$value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
$componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
}
$entryFound = TRUE;
}
if ($component == 'activity_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_activity_activity_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
}
if ($val = CRM_Utils_Array::value('civicrm_activity_activity_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
}
$entryFound = TRUE;
}
if ($component == 'membership_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_membership_membership_status_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val);
}
$entryFound = TRUE;
}
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
break;
}
}
}
}
}
示例14: browse
/**
* Browse all custom data groups.
*
*
* @return void
* @access public
* @static
*/
function browse($action = NULL)
{
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
if ($this->_sortByCharacter == 1 || !empty($_POST)) {
$this->_sortByCharacter = '';
}
$status = CRM_PCP_PseudoConstant::pcpstatus();
$cpages = CRM_Contribute_PseudoConstant::contributionPage();
$epages = CRM_Event_PseudoConstant::event();
$pcpSummary = $params = array();
$whereClause = NULL;
if (!empty($_POST) || !empty($_GET['page_type'])) {
if (CRM_Utils_Array::value('status_id', $_POST)) {
$whereClause = ' AND cp.status_id = %1';
$params['1'] = array($_POST['status_id'], 'Integer');
}
if (CRM_Utils_Array::value('page_type', $_POST)) {
$whereClause .= ' AND cp.page_type = %2';
$params['2'] = array($_POST['page_type'], 'String');
} elseif (CRM_Utils_Array::value('page_type', $_GET)) {
$whereClause .= ' AND cp.page_type = %2';
$params['2'] = array($_GET['page_type'], 'String');
}
if (CRM_Utils_Array::value('page_id', $_POST)) {
$whereClause .= ' AND cp.page_id = %4 AND cp.page_type = "contribute"';
$params['4'] = array($_POST['page_id'], 'Integer');
}
if (CRM_Utils_Array::value('event_id', $_POST)) {
$whereClause .= ' AND cp.page_id = %5 AND cp.page_type = "event"';
$params['5'] = array($_POST['event_id'], 'Integer');
}
if ($whereClause) {
$this->set('whereClause', $whereClause);
$this->set('params', $params);
} else {
$this->set('whereClause', NULL);
$this->set('params', NULL);
}
}
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
//check for delete CRM-4418
$allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
// get all contribution pages
$query = "SELECT id, title, start_date, end_date FROM civicrm_contribution_page WHERE (1)";
$cpages = CRM_Core_DAO::executeQuery($query);
while ($cpages->fetch()) {
$pages['contribute'][$cpages->id]['id'] = $cpages->id;
$pages['contribute'][$cpages->id]['title'] = $cpages->title;
$pages['contribute'][$cpages->id]['start_date'] = $cpages->start_date;
$pages['contribute'][$cpages->id]['end_date'] = $cpages->end_date;
}
// get all event pages. pcp campaign start and end dates for event related pcp's use the online registration start and end dates,
// altho if target is contribution page this might not be correct. fixme? dgg
$query = "SELECT id, title, start_date, end_date, registration_start_date, registration_end_date \n FROM civicrm_event \n WHERE is_template IS NULL OR is_template != 1";
$epages = CRM_Core_DAO::executeQuery($query);
while ($epages->fetch()) {
$pages['event'][$epages->id]['id'] = $epages->id;
$pages['event'][$epages->id]['title'] = $epages->title;
$pages['event'][$epages->id]['start_date'] = $epages->registration_start_date;
$pages['event'][$epages->id]['end_date'] = $epages->registration_end_date;
}
$params = $this->get('params') ? $this->get('params') : array();
$title = '1';
if ($this->_sortByCharacter !== NULL) {
$clauses[] = "cp.title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
}
$query = "\n SELECT cp.id, cp.contact_id , cp.status_id, cp.title, cp.is_active, cp.page_type, cp.page_id\n FROM civicrm_pcp cp\n WHERE {$title}" . $this->get('whereClause') . " ORDER BY cp.status_id";
$pcp = CRM_Core_DAO::executeQuery($query, $params);
while ($pcp->fetch()) {
$action = array_sum(array_keys($this->links()));
$contact = CRM_Contact_BAO_Contact::getDisplayAndImage($pcp->contact_id);
$class = '';
if ($pcp->status_id != $approvedId || $pcp->is_active != 1) {
$class = 'disabled';
}
switch ($pcp->status_id) {
case 2:
$action -= CRM_Core_Action::RENEW;
break;
case 3:
$action -= CRM_Core_Action::REVERT;
break;
}
switch ($pcp->is_active) {
case 1:
$action -= CRM_Core_Action::ENABLE;
break;
case 0:
$action -= CRM_Core_Action::DISABLE;
break;
}
if (!$allowToDelete) {
//.........这里部分代码省略.........
示例15: fixFormValues
public function fixFormValues()
{
// if this search has been forced
// then see if there are any get values, and if so over-ride the post values
// note that this means that GET over-rides POST :)
$event = CRM_Utils_Request::retrieve('event', 'Positive', CRM_Core_DAO::$_nullObject);
if ($event) {
$this->_formValues['event_id'] = $event;
$this->_formValues['event_name'] = CRM_Event_PseudoConstant::event($event, TRUE);
}
$status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
if (isset($status)) {
if ($status === 'true') {
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1");
} elseif ($status === 'false') {
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 0");
} elseif (is_numeric($status)) {
$statusTypes = (int) $status;
} elseif (is_array($status) && !array_key_exists('IN', $status)) {
$statusTypes = array_keys($status);
}
$this->_formValues['participant_status_id'] = is_array($statusTypes) ? array('IN' => array_keys($statusTypes)) : $statusTypes;
}
$role = CRM_Utils_Request::retrieve('role', 'String', CRM_Core_DAO::$_nullObject);
if (isset($role)) {
if ($role === 'true') {
$roleTypes = CRM_Event_PseudoConstant::participantRole(NULL, "filter = 1");
} elseif ($role === 'false') {
$roleTypes = CRM_Event_PseudoConstant::participantRole(NULL, "filter = 0");
} elseif (is_numeric($role)) {
$roleTypes = (int) $role;
}
$this->_formValues['participant_role_id'] = is_array($roleTypes) ? array_keys($roleTypes) : $roleTypes;
}
$type = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject);
if ($type) {
$this->_formValues['event_type'] = $type;
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if ($cid) {
$cid = CRM_Utils_Type::escape($cid, 'Integer');
if ($cid > 0) {
$this->_formValues['contact_id'] = $cid;
// also assign individual mode to the template
$this->_single = TRUE;
}
}
}