Ejemplo n.º 1
0
 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];
 }
Ejemplo n.º 2
0
 /**
  * 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");
             }
         }
     }
     $returnURL = CRM_Utils_System::url('civicrm/admin/custom/group', "reset=1&action=browse");
     CRM_Utils_Weight::addOrder($customGroup, 'CRM_Core_DAO_CustomGroup', 'id', $returnURL);
     $this->assign('rows', $customGroup);
 }
 /**
  * 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.');
             }
         }
         // Convert campaign_id to campaign title
         $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_participant_campaign_id', $rowNum, $this->activeCampaigns);
         // handle contribution status
         $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_contribution_status_id', $rowNum, $contributionStatus);
         // handle payment instrument
         $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_payment_instrument_id', $rowNum, $paymentInstruments);
         // handle financial type
         $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_financial_type_id', $rowNum, $financialTypes);
         $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'event/participantListing', 'View Event Income Details') ? TRUE : $entryFound;
         // display birthday in the configured custom format
         if (array_key_exists('civicrm_contact_birth_date', $row)) {
             $birthDate = $row['civicrm_contact_birth_date'];
             if ($birthDate) {
                 $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d');
             }
             $entryFound = TRUE;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @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;
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 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;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * 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' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
     } else {
         $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
     }
     $this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
     $this->addButtons($button);
 }
Ejemplo n.º 9
0
 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;
         }
     }
 }
Ejemplo n.º 10
0
 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;
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
  /**
   * 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']) {
          $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, TRUE);
        }
        $entryFound = TRUE;
      }

      // Handle state/province id
      if (array_key_exists('civicrm_address_state_province_id', $row)) {
        if ($value = $row['civicrm_address_state_province_id']) {
          $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, TRUE);
        }
        $entryFound = TRUE;
      }

      // Handle employer id
      if (array_key_exists('civicrm_contact_employer_id', $row)) {
        if ($value = $row['civicrm_contact_employer_id']) {
          $rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($value);
          $url = CRM_Utils_System::url('civicrm/contact/view',
            'reset=1&cid=' . $value, $this->_absoluteUrl
          );
          $rows[$rowNum]['civicrm_contact_employer_id_link'] = $url;
          $rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.');
        }
      }

      // Convert campaign_id to campaign title
      if (array_key_exists('civicrm_participant_campaign_id', $row)) {
        if ($value = $row['civicrm_participant_campaign_id']) {
          $rows[$rowNum]['civicrm_participant_campaign_id'] = $this->activeCampaigns[$value];
          $entryFound = TRUE;
        }
      }

      // handle contribution status
      if (array_key_exists('civicrm_contribution_contribution_status_id', $row)) {
        if ($value = $row['civicrm_contribution_contribution_status_id']) {
          $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
        }
        $entryFound = TRUE;
      }

      // handle payment instrument
      if (array_key_exists('civicrm_contribution_payment_instrument_id', $row)) {
        if ($value = $row['civicrm_contribution_payment_instrument_id']) {
          $rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
        }
        $entryFound = TRUE;
      }

      // handle financial type
      if (array_key_exists('civicrm_contribution_financial_type_id', $row)) {
        if ($value = $row['civicrm_contribution_financial_type_id']) {
          $rows[$rowNum]['civicrm_contribution_financial_type_id'] = $financialTypes[$value];
        }
        $entryFound = TRUE;
      }

      if (array_key_exists('civicrm_contribution_honor_type_id', $row)) {
        if ($value = $row['civicrm_contribution_honor_type_id']) {
          $rows[$rowNum]['civicrm_contribution_honor_type_id'] = $honorTypes[$value];
        }
        $entryFound = TRUE;
      }

      if (array_key_exists('civicrm_contact_gender_id', $row)) {
        if ($value = $row['civicrm_contact_gender_id']) {
          $rows[$rowNum]['civicrm_contact_gender_id'] = $genders[$value];
        }
        $entryFound = TRUE;
      }

      // display birthday in the configured custom format
      if (array_key_exists('civicrm_contact_birth_date', $row)) {
        if ($value = $row['civicrm_contact_birth_date']) {
          $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($row['civicrm_contact_birth_date'], '%Y%m%d');
        }
        $entryFound = TRUE;
      }

      if (array_key_exists('civicrm_phone_phone', $row)) {
        $rows[$rowNum]['civicrm_phone_phone'] = $this->alterPhoneGroup($row['civicrm_phone_phone']);
      }

      // skip looking further in rows, if first row itself doesn't
      // have the column we need
      if (!$entryFound) {
        break;
      }
    }
    parent::alterDisplay($rows);
  }
Ejemplo n.º 12
0
 /**
  * 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);
     }
     $honor = CRM_PCP_BAO_PCP::honorRoll($this->_id);
     $entityFile = CRM_Core_BAO_File::getEntityFile('civicrm_pcp', $this->_id);
     if (!empty($entityFile)) {
         $fileInfo = reset($entityFile);
         $fileId = $fileInfo['fileID'];
         $image = '<img src="' . CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$this->_id}") . '" />';
         $this->assign('image', $image);
     }
     $totalAmount = CRM_PCP_BAO_PCP::thermoMeter($this->_id);
     $achieved = round($totalAmount / $pcpInfo['goal_amount'] * 100, 2);
     if ($pcpBlock->is_active == 1) {
         $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$pcpInfo['page_id']}&component={$pcpInfo['page_type']}", TRUE, NULL, TRUE, TRUE);
         $this->assign('linkTextUrl', $linkTextUrl);
         $this->assign('linkText', $pcpBlock->link_text);
     }
     $this->assign('honor', $honor);
     $this->assign('total', $totalAmount ? $totalAmount : '0.0');
     $this->assign('achieved', $achieved <= 100 ? $achieved : 100);
     if ($achieved <= 100) {
         $this->assign('remaining', 100 - $achieved);
     }
     // make sure that we are between contribution page start and end dates OR registration start date and end dates if they are set
     if ($pcpBlock->entity_table == 'civicrm_event') {
         $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $pageInfo));
         $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $pageInfo));
     } else {
         $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('start_date', $pageInfo));
         $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $pageInfo));
     }
     $now = time();
     $validDate = TRUE;
     if ($startDate && $startDate >= $now) {
         $validDate = FALSE;
     }
     if ($endDate && $endDate < $now) {
         $validDate = FALSE;
     }
     $this->assign('validDate', $validDate);
     // form parent page url
     if ($action == CRM_Core_Action::PREVIEW) {
         $parentUrl = CRM_Utils_System::url($urlBase, "id={$pcpInfo['page_id']}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
     } else {
         $parentUrl = CRM_Utils_System::url($urlBase, "id={$pcpInfo['page_id']}&reset=1", TRUE, NULL, TRUE, TRUE);
     }
     $this->assign('parentURL', $parentUrl);
     if ($validDate) {
         $contributionText = ts('Contribute Now');
         if (!empty($pcpInfo['donate_link_text'])) {
             $contributionText = $pcpInfo['donate_link_text'];
         }
         $this->assign('contributionText', $contributionText);
         // we always generate urls for the front end in joomla
         if ($action == CRM_Core_Action::PREVIEW) {
             $url = CRM_Utils_System::url($urlBase, "id=" . $pcpBlock->target_entity_id . "&pcpId={$this->_id}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
         } else {
             $url = CRM_Utils_System::url($urlBase, "id=" . $pcpBlock->target_entity_id . "&pcpId={$this->_id}&reset=1", TRUE, NULL, TRUE, TRUE);
         }
         $this->assign('contributeURL', $url);
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', FALSE);
     $single = $permission = FALSE;
     switch ($action) {
         case CRM_Core_Action::BROWSE:
             $subForm = 'PCPAccount';
             $form = "CRM_PCP_Form_{$subForm}";
             $single = TRUE;
             break;
         case CRM_Core_Action::UPDATE:
             $subForm = 'Campaign';
             $form = "CRM_PCP_Form_{$subForm}";
             $single = TRUE;
             break;
     }
     $userID = $session->get('userID');
     //make sure the user has "administer CiviCRM" permission
     //OR has created the PCP
     if (CRM_Core_Permission::check('administer CiviCRM') || $userID && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'contact_id') == $userID) {
         $permission = TRUE;
     }
     if ($single && $permission) {
         $controller = new CRM_Core_Controller_Simple($form, $subForm, $action);
         $controller->set('id', $this->_id);
         $controller->set('single', TRUE);
         $controller->process();
         return $controller->run();
     }
     $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&id=' . $this->_id));
     parent::run();
 }
Ejemplo n.º 13
0
 /**
  * @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;
                 }
             }
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * 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) {
             $action -= CRM_Core_Action::DELETE;
         }
         $page_type = $pcp->page_type;
         $page_id = (int) $pcp->page_id;
         if ($pages[$page_type][$page_id]['title'] == '' || $pages[$page_type][$page_id]['title'] == NULL) {
             $title = '(no title found for ' . $page_type . ' id ' . $page_id . ')';
         } else {
             $title = $pages[$page_type][$page_id]['title'];
         }
         if ($pcp->page_type == 'contribute') {
             $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/transact', 'reset=1&id=' . $pcp->page_id);
         } else {
             $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/register', 'reset=1&id=' . $pcp->page_id);
         }
         $pcpSummary[$pcp->id] = array('id' => $pcp->id, 'start_date' => $pages[$page_type][$page_id]['start_date'], 'end_date' => $pages[$page_type][$page_id]['end_date'], 'supporter' => $contact['0'], 'supporter_id' => $pcp->contact_id, 'status_id' => $status[$pcp->status_id], 'page_id' => $page_id, 'page_title' => $title, 'page_url' => $pageUrl, 'page_type' => $page_type, 'action' => CRM_Core_Action::formLink(self::links(), $action, array('id' => $pcp->id)), 'title' => $pcp->title, 'class' => $class);
     }
     $this->search();
     $this->pagerAToZ($this->get('whereClause'), $params);
     $this->assign('rows', $pcpSummary);
     // Let template know if user has run a search or not
     if ($this->get('whereClause')) {
         $this->assign('isSearch', 1);
     } else {
         $this->assign('isSearch', 0);
     }
 }
Ejemplo n.º 15
0
 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;
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->applyFilter('__ALL__', 'trim');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_CustomGroup');
     //title
     $this->add('text', 'title', ts('Set Name'), $attributes['title'], TRUE);
     //Fix for code alignment, CRM-3058
     $contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
     $this->assign('contactTypes', json_encode($contactTypes));
     $sel1 = array("" => ts("- select -")) + CRM_Core_SelectValues::customGroupExtends();
     $sel2 = array();
     $activityType = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
     $eventType = CRM_Core_OptionGroup::values('event_type');
     $grantType = CRM_Core_OptionGroup::values('grant_type');
     $campaignTypes = CRM_Campaign_PseudoConstant::campaignType();
     $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
     $participantRole = CRM_Core_OptionGroup::values('participant_role');
     $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');
     ksort($sel1);
     asort($activityType);
     asort($eventType);
     asort($grantType);
     asort($membershipType);
     asort($participantRole);
     $allRelationshipType = array();
     $allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
     $allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
     //adding subtype specific relationships CRM-5256
     $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
     foreach ($subTypes as $subType => $val) {
         $subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
         $allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes);
     }
     $sel2['Event'] = $eventType;
     $sel2['Grant'] = $grantType;
     $sel2['Activity'] = $activityType;
     $sel2['Campaign'] = $campaignTypes;
     $sel2['Membership'] = $membershipType;
     $sel2['ParticipantRole'] = $participantRole;
     $sel2['ParticipantEventName'] = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
     $sel2['ParticipantEventType'] = $eventType;
     $sel2['Contribution'] = CRM_Contribute_PseudoConstant::financialType();
     $sel2['Relationship'] = $allRelationshipType;
     $sel2['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL);
     $sel2['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL);
     $sel2['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL);
     CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($sel2);
     foreach ($sel2 as $main => $sub) {
         if (!empty($sel2[$main])) {
             if ($main == 'Relationship') {
                 $relName = self::getFormattedList($sel2[$main]);
                 $sel2[$main] = array('' => ts("- Any -")) + $relName;
             } else {
                 $sel2[$main] = array('' => ts("- Any -")) + $sel2[$main];
             }
         }
     }
     $cSubTypes = CRM_Core_Component::contactSubTypes();
     if (!empty($cSubTypes)) {
         $contactSubTypes = array();
         foreach ($cSubTypes as $key => $value) {
             $contactSubTypes[$key] = $key;
         }
         $sel2['Contact'] = array("" => "- Any -") + $contactSubTypes;
     } else {
         if (!isset($this->_id)) {
             $formName = 'document.forms.' . $this->_name;
             $js = "<script type='text/javascript'>\n";
             $js .= "{$formName}['extends_1'].style.display = 'none';\n";
             $js .= "</script>";
             $this->assign('initHideBlocks', $js);
         }
     }
     $sel =& $this->add('hierselect', 'extends', ts('Used For'), array('name' => 'extends[0]', 'style' => 'vertical-align: top;'), TRUE);
     $sel->setOptions(array($sel1, $sel2));
     if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) {
         // make second selector a multi-select -
         $sel->_elements[1]->setMultiple(TRUE);
         $sel->_elements[1]->setSize(5);
     }
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $subName = CRM_Utils_Array::value('extends_entity_column_id', $this->_defaults);
         if ($this->_defaults['extends'] == 'Participant') {
             if ($subName == 1) {
                 $this->_defaults['extends'] = 'ParticipantRole';
             } elseif ($subName == 2) {
                 $this->_defaults['extends'] = 'ParticipantEventName';
             } elseif ($subName == 3) {
                 $this->_defaults['extends'] = 'ParticipantEventType';
             }
         }
         //allow to edit settings if custom set is empty CRM-5258
         $this->_isGroupEmpty = CRM_Core_BAO_CustomGroup::isGroupEmpty($this->_id);
         if (!$this->_isGroupEmpty) {
             if (!empty($this->_subtypes)) {
                 // we want to allow adding / updating subtypes for this case,
                 // and therefore freeze the first selector only.
                 $sel->_elements[0]->freeze();
             } else {
                 // freeze both the selectors
                 $sel->freeze();
             }
         }
         $this->assign('isCustomGroupEmpty', $this->_isGroupEmpty);
         $this->assign('gid', $this->_id);
     }
     $this->assign('defaultSubtypes', json_encode($this->_subtypes));
     // help text
     $this->add('wysiwyg', 'help_pre', ts('Pre-form Help'), $attributes['help_pre']);
     $this->add('wysiwyg', 'help_post', ts('Post-form Help'), $attributes['help_post']);
     // weight
     $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     // display style
     $this->add('select', 'style', ts('Display Style'), CRM_Core_SelectValues::customGroupStyle());
     // is this set collapsed or expanded ?
     $this->addElement('checkbox', 'collapse_display', ts('Collapse this set on initial display'));
     // is this set collapsed or expanded ? in advanced search
     $this->addElement('checkbox', 'collapse_adv_display', ts('Collapse this set in Advanced Search'));
     // is this set active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Custom Data Set active?'));
     // does this set have multiple record?
     $multiple = $this->addElement('checkbox', 'is_multiple', ts('Does this Custom Field Set allow multiple records?'), NULL);
     // $min_multiple = $this->add('text', 'min_multiple', ts('Minimum number of multiple records'), $attributes['min_multiple'] );
     // $this->addRule('min_multiple', ts('is a numeric field') , 'numeric');
     $max_multiple = $this->add('text', 'max_multiple', ts('Maximum number of multiple records'), $attributes['max_multiple']);
     $this->addRule('max_multiple', ts('is a numeric field'), 'numeric');
     //allow to edit settings if custom set is empty CRM-5258
     $this->assign('isGroupEmpty', $this->_isGroupEmpty);
     if (!$this->_isGroupEmpty) {
         $multiple->freeze();
         //$min_multiple->freeze();
         $max_multiple->freeze();
     }
     $this->assign('showStyle', FALSE);
     $this->assign('showMultiple', FALSE);
     $buttons = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
     if (!$this->_isGroupEmpty && !empty($this->_subtypes)) {
         $buttons[0]['class'] = 'crm-warnDataLoss';
     }
     $this->addButtons($buttons);
     // TODO: Is this condition ever true? Can this code be removed?
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"));
     }
 }
Ejemplo n.º 17
0
 function postProcess()
 {
     $this->beginPostProcess();
     $this->_setVariable = TRUE;
     if (empty($this->_params['id_value'][0])) {
         $this->_params['id_value'] = array();
         $this->_setVariable = FALSE;
         $events = CRM_Event_PseudoConstant::event(NULL, NULL, "is_template IS NULL OR is_template = 0");
         if (empty($events)) {
             return FALSE;
         }
         foreach ($events as $key => $dnt) {
             $this->_params['id_value'][] = $key;
         }
     }
     $this->_rowsFound = count($this->_params['id_value']);
     //set pager and limit if output mode is html
     if ($this->_outputMode == 'html') {
         $this->limit();
         $this->setPager();
         $showEvents = array();
         $count = 0;
         $numRows = $this->_limit;
         while ($count < self::ROW_COUNT_LIMIT) {
             if (!isset($this->_params['id_value'][$numRows])) {
                 break;
             }
             $showEvents[] = $this->_params['id_value'][$numRows];
             $count++;
             $numRows++;
         }
         $this->buildEventReport($showEvents);
     } else {
         $this->buildEventReport($this->_params['id_value']);
     }
     parent::endPostProcess();
 }
Ejemplo n.º 18
0
 /**
  * replace event id with name & link to drilldown report
  *
  * @param string $value
  * @param array $row
  * @param string $selectedfield
  * @param string $criteriaFieldName
  *
  * @return string
  */
 function alterEventID($value, &$row, $selectedfield, $criteriaFieldName) {
   if (isset($this->_drilldownReport)) {
     $criteriaString = $this->getCriteriaString();
     $url = CRM_Report_Utils_Report::getNextUrl(implode(',', array_keys($this->_drilldownReport)),
       $criteriaString . '&event_id_op=in&event_id_value=' . $value,
       $this->_absoluteUrl, $this->_id, $this->_drilldownReport
     );
     $row[$selectedfield . '_link'] = $url;
     $row[$selectedfield . '_hover'] = ts(implode(',', $this->_drilldownReport));
   }
   return is_string(CRM_Event_PseudoConstant::event($value, FALSE)) ? CRM_Event_PseudoConstant::event($value, FALSE) : '';
 }
Ejemplo n.º 19
0
 static function extractGroupTypes($groupType)
 {
     $returnGroupTypes = array();
     if (!$groupType) {
         return $returnGroupTypes;
     }
     $groupTypeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $groupType);
     foreach (explode(',', $groupTypeParts[0]) as $type) {
         $returnGroupTypes[$type] = $type;
     }
     if (CRM_Utils_Array::value(1, $groupTypeParts)) {
         foreach (explode(',', $groupTypeParts[1]) as $typeValue) {
             $groupTypeValues = $valueLabels = array();
             $valueParts = explode(':', $typeValue);
             $typeName = NULL;
             switch ($valueParts[0]) {
                 case 'ContributionType':
                     $typeName = 'Contribution';
                     $valueLabels = CRM_Contribute_PseudoConstant::financialType();
                     break;
                 case 'ParticipantRole':
                     $typeName = 'Participant';
                     $valueLabels = CRM_Event_PseudoConstant::participantRole();
                     break;
                 case 'ParticipantEventName':
                     $typeName = 'Participant';
                     $valueLabels = CRM_Event_PseudoConstant::event();
                     break;
                 case 'ParticipantEventType':
                     $typeName = 'Participant';
                     $valueLabels = CRM_Event_PseudoConstant::eventType();
                     break;
                 case 'MembershipType':
                     $typeName = 'Membership';
                     $valueLabels = CRM_Member_PseudoConstant::membershipType();
                     break;
                 case 'ActivityType':
                     $typeName = 'Activity';
                     $valueLabels = CRM_Core_PseudoConstant::ActivityType(TRUE, TRUE, FALSE, 'label', TRUE);
                     break;
             }
             foreach ($valueParts as $val) {
                 if (CRM_Utils_Rule::integer($val)) {
                     $groupTypeValues[$val] = CRM_Utils_Array::value($val, $valueLabels);
                 }
             }
             if (!is_array($returnGroupTypes[$typeName])) {
                 $returnGroupTypes[$typeName] = array();
             }
             $returnGroupTypes[$typeName][$valueParts[0]] = $groupTypeValues;
         }
     }
     return $returnGroupTypes;
 }
Ejemplo n.º 20
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL');
     $this->add('text', 'name', ts('Description'), CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL', 'name'), TRUE);
     $operations = array('' => ts('- select -')) + CRM_ACL_BAO_ACL::operation();
     $this->add('select', 'operation', ts('Operation'), $operations, TRUE);
     $objTypes = array('1' => ts('A group of contacts'), '2' => ts('A profile'), '3' => ts('A set of custom data fields'));
     if (CRM_Core_Permission::access('CiviEvent')) {
         $objTypes['4'] = ts('Events');
     }
     $extra = array('onclick' => "showObjectSelect();");
     $this->addRadio('object_type', ts('Type of Data'), $objTypes, $extra, '&nbsp;', TRUE);
     $label = ts('Role');
     $role = array('-1' => ts('- select role -'), '0' => ts('Everyone')) + CRM_Core_OptionGroup::values('acl_role');
     $this->add('select', 'entity_id', $label, $role, TRUE);
     $group = array('-1' => ts('- select -'), '0' => ts('All Groups')) + CRM_Core_PseudoConstant::group();
     $customGroup = array('-1' => ts('- select -'), '0' => ts('All Custom Groups')) + CRM_Core_PseudoConstant::customGroup();
     $ufGroup = array('-1' => ts('- select -'), '0' => ts('All Profiles')) + CRM_Core_PseudoConstant::ufGroup();
     $event = array('-1' => ts('- select -'), '0' => ts('All Events')) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
     $this->add('select', 'group_id', ts('Group'), $group);
     $this->add('select', 'custom_group_id', ts('Custom Data'), $customGroup);
     $this->add('select', 'uf_group_id', ts('Profile'), $ufGroup);
     $this->add('select', 'event_id', ts('Event'), $event);
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->addFormRule(array('CRM_ACL_Form_ACL', 'formRule'));
 }
Ejemplo n.º 21
0
 function customGroups(&$xml, &$idMap)
 {
     require_once 'CRM/Core/BAO/CustomGroup.php';
     require_once 'CRM/Utils/String.php';
     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_option_value)) {
                 $optValues = explode(",", $customGroupXML->extends_entity_column_value_option_value);
                 $optValues = implode("','", $optValues);
                 if (trim($customGroup->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 = %1\nAND        v.name IN (%2)\n";
                     $params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'), 2 => array((string) $optValues, 'String'));
                     $dao =& CRM_Core_DAO::executeQuery($sql, $params);
                     $valueIDs = array();
                     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;
                         // 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
                             require_once 'CRM/Core/OptionGroup.php';
                             $condition = "AND v.name IN ( '{$optValues}' )";
                             $optionIDs = CRM_Core_OptionGroup::values('participant_role', false, false, false, $condition, 'name');
                             break;
                         case 2:
                             // ParticipantEventName
                             require_once 'CRM/Event/PseudoConstant.php';
                             $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
                             require_once 'CRM/Core/OptionGroup.php';
                             $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;
         }
     }
 }
 /**
  * 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');
     foreach ($rows as $rowNum => $row) {
         // convert sort name to links
         if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row)) {
             if ($value = $row['civicrm_contact_sort_name']) {
                 $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $row['civicrm_contact_id'], $this->_absoluteUrl);
                 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
                 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
             }
             $entryFound = TRUE;
         }
         // convert participant ID to links
         if (array_key_exists('civicrm_participant_participant_id', $row) && array_key_exists('civicrm_contact_id', $row)) {
             if ($value = $row['civicrm_participant_participant_id']) {
                 $url = CRM_Utils_System::url("civicrm/contact/view/participant", 'reset=1&id=' . $row['civicrm_participant_participant_id'] . '&cid=' . $row['civicrm_contact_id'] . '&action=view&context=participant', $this->_absoluteUrl);
                 $rows[$rowNum]['civicrm_participant_participant_id_link'] = $url;
                 $rows[$rowNum]['civicrm_participant_participant_id_hover'] = ts("View Participant Record for this Contact.");
             }
             $entryFound = TRUE;
         }
         // convert event 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&event_id_op=eq&event_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);
             }
             $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 gender
         if (array_key_exists('civicrm_contact_gender_id', $row)) {
             if ($value = $row['civicrm_contact_gender_id']) {
                 $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
                 $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value];
             }
             $entryFound = TRUE;
         }
         // display birthday in the configured custom format
         if (array_key_exists('civicrm_contact_birth_date', $row)) {
             $birthDate = $row['civicrm_contact_birth_date'];
             if ($birthDate) {
                 $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d');
             }
             $entryFound = TRUE;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
Ejemplo n.º 23
0
 function alterEventID($value, &$row)
 {
     return is_string(CRM_Event_PseudoConstant::event($value, FALSE)) ? CRM_Event_PseudoConstant::event($value, FALSE) : '';
 }
Ejemplo n.º 24
0
 /**
  * Get the values for pseudoconstants for name->value and reverse.
  *
  * @param array   $defaults (reference) the default values, some of which need to be resolved.
  * @param boolean $reverse  true if we want to resolve the values in the reverse direction (value -> name)
  *
  * @return void
  * @access public
  * @static
  */
 static function resolveDefaults(&$defaults, $reverse = false)
 {
     require_once 'CRM/Event/PseudoConstant.php';
     self::lookupValue($defaults, 'event', CRM_Event_PseudoConstant::event(), $reverse);
     self::lookupValue($defaults, 'status', CRM_Event_PseudoConstant::participantStatus(null, null, 'label'), $reverse);
     self::lookupValue($defaults, 'role', CRM_Event_PseudoConstant::participantRole(), $reverse);
 }
 function alterDisplay(&$rows)
 {
     if (is_array($rows)) {
         $eventType = CRM_Core_OptionGroup::values('event_type');
         foreach ($rows as $rowNum => $row) {
             if (array_key_exists('civicrm_event_title', $row)) {
                 if ($value = $row['civicrm_event_id']) {
                     CRM_Event_PseudoConstant::event($value, FALSE);
                     $url = CRM_Report_Utils_Report::getNextUrl('event/participantlist', 'reset=1&force=1&event_id_op=eq&event_id_value=' . $value, $this->_absoluteUrl, $this->_id);
                     $rows[$rowNum]['civicrm_event_title_link'] = $url;
                     $rows[$rowNum]['civicrm_event_title_hover'] = ts("View Event Participants For this Event");
                 }
             }
             //handle event type
             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];
                 }
             }
         }
     }
 }
 public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL)
 {
     $events = CRM_Event_PseudoConstant::event(NULL, TRUE);
     $includeEvents = array();
     // check if user has all powerful permission
     if (self::check('register for events')) {
         $includeEvents = array_keys($events);
     }
     if ($type == CRM_Core_Permission::VIEW && self::check('view event info')) {
         $includeEvents = array_keys($events);
     }
     $permissionedEvents = CRM_ACL_API::group($type, NULL, 'civicrm_event', $events, $includeEvents);
     if (!$eventID) {
         return $permissionedEvents;
     }
     return array_search($eventID, $permissionedEvents) === FALSE ? NULL : $eventID;
 }
Ejemplo n.º 27
0
 /**
  * Get the values for pseudoconstants for name->value and reverse.
  *
  * @param array $defaults
  *   (reference) the default values, some of which need to be resolved.
  * @param bool $reverse
  *   True if we want to resolve the values in the reverse direction (value -> name).
  */
 public static function resolveDefaults(&$defaults, $reverse = FALSE)
 {
     self::lookupValue($defaults, 'event', CRM_Event_PseudoConstant::event(), $reverse);
     self::lookupValue($defaults, 'status', CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), $reverse);
     self::lookupValue($defaults, 'role', CRM_Event_PseudoConstant::participantRole(), $reverse);
 }
Ejemplo n.º 28
0
 /**
  * Browse all acls
  *
  * @return void
  * @access public
  * @static
  */
 function browse()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     // get all acl's sorted by weight
     $acl = array();
     $query = "\n  SELECT *\n    FROM civicrm_acl\n   WHERE ( object_table IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group', 'civicrm_event' ) )\nORDER BY entity_id\n";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     $roles = CRM_Core_OptionGroup::values('acl_role');
     $group = array('-1' => ts('- select -'), '0' => ts('All Groups')) + CRM_Core_PseudoConstant::group();
     $customGroup = array('-1' => ts('- select -'), '0' => ts('All Custom Groups')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
     $ufGroup = array('-1' => ts('- select -'), '0' => ts('All Profiles')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
     $event = array('-1' => ts('- select -'), '0' => ts('All Events')) + CRM_Event_PseudoConstant::event();
     while ($dao->fetch()) {
         $acl[$dao->id] = array();
         $acl[$dao->id]['name'] = $dao->name;
         $acl[$dao->id]['operation'] = $dao->operation;
         $acl[$dao->id]['entity_id'] = $dao->entity_id;
         $acl[$dao->id]['entity_table'] = $dao->entity_table;
         $acl[$dao->id]['object_table'] = $dao->object_table;
         $acl[$dao->id]['object_id'] = $dao->object_id;
         $acl[$dao->id]['is_active'] = $dao->is_active;
         if ($acl[$dao->id]['entity_id']) {
             $acl[$dao->id]['entity'] = $roles[$acl[$dao->id]['entity_id']];
         } else {
             $acl[$dao->id]['entity'] = ts('Everyone');
         }
         switch ($acl[$dao->id]['object_table']) {
             case 'civicrm_saved_search':
                 $acl[$dao->id]['object'] = $group[$acl[$dao->id]['object_id']];
                 $acl[$dao->id]['object_name'] = ts('Group');
                 break;
             case 'civicrm_uf_group':
                 $acl[$dao->id]['object'] = $ufGroup[$acl[$dao->id]['object_id']];
                 $acl[$dao->id]['object_name'] = ts('Profile');
                 break;
             case 'civicrm_custom_group':
                 $acl[$dao->id]['object'] = $customGroup[$acl[$dao->id]['object_id']];
                 $acl[$dao->id]['object_name'] = ts('Custom Group');
                 break;
             case 'civicrm_event':
                 $acl[$dao->id]['object'] = $event[$acl[$dao->id]['object_id']];
                 $acl[$dao->id]['object_name'] = ts('Event');
                 break;
         }
         // 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;
         }
         $acl[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'ACL.manage.action', 'ACL', $dao->id);
     }
     $this->assign('rows', $acl);
 }
Ejemplo n.º 29
0
Archivo: PCP.php Proyecto: kidaa30/yes
 /**
  * Return PCP  Block info for dashboard.
  *
  * @param int $contactId
  *
  * @return array
  *   array of Pcp if found
  */
 public static function getPcpDashboardInfo($contactId)
 {
     $links = self::pcpLinks();
     $query = "\nSELECT * FROM civicrm_pcp pcp\nWHERE pcp.is_active = 1\n  AND pcp.contact_id = %1\nORDER BY page_type, page_id";
     $params = array(1 => array($contactId, 'Integer'));
     $pcpInfoDao = CRM_Core_DAO::executeQuery($query, $params);
     $pcpInfo = array();
     $hide = $mask = array_sum(array_keys($links['all']));
     $contactPCPPages = array();
     $event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
     $contribute = CRM_Contribute_PseudoConstant::contributionPage();
     $pcpStatus = CRM_Contribute_PseudoConstant::pcpStatus();
     $approved = CRM_Utils_Array::key('Approved', $pcpStatus);
     while ($pcpInfoDao->fetch()) {
         $mask = $hide;
         if ($links) {
             $replace = array('pcpId' => $pcpInfoDao->id, 'pcpBlock' => $pcpInfoDao->pcp_block_id, 'pageComponent' => $pcpInfoDao->page_type);
         }
         $pcpLink = $links['all'];
         $class = '';
         if ($pcpInfoDao->status_id != $approved || $pcpInfoDao->is_active != 1) {
             $class = 'disabled';
             if (!$pcpInfoDao->tellfriend) {
                 $mask -= CRM_Core_Action::DETACH;
             }
         }
         if ($pcpInfoDao->is_active == 1) {
             $mask -= CRM_Core_Action::ENABLE;
         } else {
             $mask -= CRM_Core_Action::DISABLE;
         }
         $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace, ts('more'), FALSE, 'pcp.dashboard.active', 'PCP', $pcpInfoDao->id);
         $component = $pcpInfoDao->page_type;
         $pageTitle = CRM_Utils_Array::value($pcpInfoDao->page_id, ${$component});
         $pcpInfo[] = array('pageTitle' => $pageTitle, 'pcpId' => $pcpInfoDao->id, 'pcpTitle' => $pcpInfoDao->title, 'pcpStatus' => $pcpStatus[$pcpInfoDao->status_id], 'action' => $action, 'class' => $class);
         $contactPCPPages[$pcpInfoDao->page_type][] = $pcpInfoDao->page_id;
     }
     $excludePageClause = $clause = NULL;
     if (!empty($contactPCPPages)) {
         foreach ($contactPCPPages as $component => $entityIds) {
             $excludePageClause[] = "\n( target_entity_type = '{$component}'\nAND target_entity_id NOT IN ( " . implode(',', $entityIds) . ") )";
         }
         $clause = ' AND ' . implode(' OR ', $excludePageClause);
     }
     $query = "\nSELECT *\nFROM civicrm_pcp_block block\nLEFT JOIN civicrm_pcp pcp ON pcp.pcp_block_id = block.id\nWHERE block.is_active = 1\n{$clause}\nGROUP BY block.id\nORDER BY target_entity_type, target_entity_id\n";
     $pcpBlockDao = CRM_Core_DAO::executeQuery($query);
     $pcpBlock = array();
     $mask = 0;
     while ($pcpBlockDao->fetch()) {
         if ($links) {
             $replace = array('pageId' => $pcpBlockDao->target_entity_id, 'pageComponent' => $pcpBlockDao->target_entity_type);
         }
         $pcpLink = $links['add'];
         $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace, ts('more'), FALSE, 'pcp.dashboard.other', "{$pcpBlockDao->target_entity_type}_PCP", $pcpBlockDao->target_entity_id);
         $component = $pcpBlockDao->target_entity_type;
         if ($pageTitle = CRM_Utils_Array::value($pcpBlockDao->target_entity_id, ${$component})) {
             $pcpBlock[] = array('pageId' => $pcpBlockDao->target_entity_id, 'pageTitle' => $pageTitle, 'action' => $action);
         }
     }
     return array($pcpBlock, $pcpInfo);
 }
Ejemplo n.º 30
0
 /**
  * Function to actually build the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Campaign'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         $status = array('' => ts('- select -')) + CRM_Core_OptionGroup::values("pcp_status");
         $types = array('' => ts('- select -'), 'contribute' => ts('Contribution'), 'event' => ts('Event'));
         $contribPages = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage();
         $eventPages = array('' => ts('- select -')) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
         $this->addElement('select', 'status_id', ts('Status'), $status);
         $this->addElement('select', 'page_type', ts('Source Type'), $types);
         $this->addElement('select', 'page_id', ts('Contribution Page'), $contribPages);
         $this->addElement('select', 'event_id', ts('Event Page'), $eventPages);
         $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
         parent::buildQuickForm();
     }
 }