Exemplo n.º 1
0
 /**
  * Do AlterDisplay processing on Address Fields.
  *
  * @param array $row
  * @param array $rows
  * @param int $rowNum
  * @param string $baseUrl
  * @param string $linkText
  *
  * @return bool
  */
 public function alterDisplayContactFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText)
 {
     $entryFound = FALSE;
     // There is no reason not to add links for all fields but it seems a bit odd to be able to click on
     // 'Mrs'. Also, we don't have metadata about the title. So, add selectively to addLinks.
     $addLinks = array('gender_id' => 'Gender');
     foreach (array('prefix_id', 'suffix_id', 'gender_id') as $fieldName) {
         if (array_key_exists('civicrm_contact_' . $fieldName, $row)) {
             if (($value = $row['civicrm_contact_' . $fieldName]) != FALSE) {
                 $rows[$rowNum]['civicrm_contact_' . $fieldName] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', $fieldName, $value);
                 if ($baseUrl && ($title = CRM_Utils_Array::value($fieldName, $addLinks)) != FALSE) {
                     $this->addLinkToRow($rows[$rowNum], $baseUrl, $linkText, $value, $fieldName, 'civicrm_contact', $title);
                 }
             }
             $entryFound = TRUE;
         }
     }
     $yesNoFields = array('do_not_email', 'is_deceased', 'do_not_phone', 'do_not_sms', 'do_not_mail', 'is_opt_out');
     foreach ($yesNoFields as $fieldName) {
         if (array_key_exists('civicrm_contact_' . $fieldName, $row)) {
             // Since these are essentially 'negative fields' it feels like it
             // makes sense to only highlight the exceptions hence no 'No'.
             $rows[$rowNum]['civicrm_contact_' . $fieldName] = !empty($rows[$rowNum]['civicrm_contact_' . $fieldName]) ? ts('Yes') : '';
             $entryFound = TRUE;
         }
     }
     return $entryFound;
 }
Exemplo n.º 2
0
 /**
  * Do AlterDisplay processing on Address Fields.
  *
  * @param array $row
  * @param array $rows
  * @param int $rowNum
  * @param string $baseUrl
  * @param string $linkText
  *
  * @return bool
  */
 public function alterDisplayContactFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText)
 {
     $entryFound = FALSE;
     // There is no reason not to add links for all fields but it seems a bit odd to be able to click on
     // 'Mrs'. Also, we don't have metadata about the title. So, add selectively to addLinks.
     $addLinks = array('gender_id' => 'Gender');
     foreach (array('prefix_id', 'suffix_id', 'gender_id') as $fieldName) {
         if (array_key_exists('civicrm_contact_' . $fieldName, $row)) {
             if (($value = $row['civicrm_contact_' . $fieldName]) != FALSE) {
                 $rows[$rowNum]['civicrm_contact_' . $fieldName] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', $fieldName, $value);
                 if (($title = CRM_Utils_Array::value($fieldName, $addLinks)) != FALSE) {
                     $this->addLinkToRow($rows[$rowNum], $baseUrl, $linkText, $value, $fieldName, 'civicrm_contact', $title);
                 }
             }
             $entryFound = TRUE;
         }
     }
     return $entryFound;
 }
Exemplo n.º 3
0
/**
 * Get output for activity list.
 *
 * @see _civicrm_api3_generic_getlist_output
 *
 * @param array $result
 * @param array $request
 *
 * @return array
 */
function _civicrm_api3_activity_getlist_output($result, $request)
{
    $output = array();
    if (!empty($result['values'])) {
        foreach ($result['values'] as $row) {
            $data = array('id' => $row[$request['id_field']], 'label' => $row[$request['label_field']] ? $row[$request['label_field']] : ts('(no subject)'), 'description' => array(CRM_Core_Pseudoconstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $row['activity_type_id'])));
            if (!empty($row['activity_date_time'])) {
                $data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['activity_date_time']);
            }
            if (!empty($row['source_contact_id'])) {
                $data['description'][] = ts('By %1', array(1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['source_contact_id'], 'display_name')));
            }
            // Add repeating info
            $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_activity');
            $data['extra']['is_recur'] = FALSE;
            if ($repeat) {
                $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
                $data['extra']['is_recur'] = TRUE;
            }
            $output[] = $data;
        }
    }
    return $output;
}
Exemplo n.º 4
0
/**
 * Get event list output.
 *
 * @see _civicrm_api3_generic_getlist_output
 *
 * @param array $result
 * @param array $request
 *
 * @return array
 */
function _civicrm_api3_event_getlist_output($result, $request)
{
    $output = array();
    if (!empty($result['values'])) {
        foreach ($result['values'] as $row) {
            $data = array('id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => array(CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id'])));
            if (!empty($row['start_date'])) {
                $data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']);
            }
            if (!empty($row['summary'])) {
                $data['description'][] = $row['summary'];
            }
            // Add repeating info
            $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_event');
            $data['extra']['is_recur'] = FALSE;
            if ($repeat) {
                $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
                $data['extra']['is_recur'] = TRUE;
            }
            $output[] = $data;
        }
    }
    return $output;
}
Exemplo n.º 5
0
/**
 * @see _civicrm_api3_generic_getlist_output
 *
 * @param $result array
 * @param $request array
 *
 * @return array
 */
function _civicrm_api3_event_getlist_output($result, $request)
{
    $output = array();
    if (!empty($result['values'])) {
        foreach ($result['values'] as $row) {
            $data = array('id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => array(CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id'])));
            if (!empty($row['start_date'])) {
                $data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']);
            }
            if (!empty($row['summary'])) {
                $data['description'][] = $row['summary'];
            }
            foreach ($request['extra'] as $field) {
                $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
            }
            $output[] = $data;
        }
    }
    return $output;
}
Exemplo n.º 6
0
 /**
  * @param $rows
  */
 public function alterDisplay(&$rows)
 {
     // Custom code to alter rows.
     $entryFound = FALSE;
     foreach ($rows as $rowNum => $row) {
         // Handle ID to label conversion for contact fields
         $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contact/relationship', 'View Relationships') ? TRUE : $entryFound;
         // Handle contact subtype A
         // @todo refactor into separate function
         if (array_key_exists('civicrm_contact_contact_sub_type_a', $row)) {
             if ($value = $row['civicrm_contact_contact_sub_type_a']) {
                 $rowValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                 $rowLabels = array();
                 foreach ($rowValues as $rowValue) {
                     if ($rowValue) {
                         $rowLabels[] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue);
                     }
                 }
                 $rows[$rowNum]['civicrm_contact_contact_sub_type_a'] = implode(', ', $rowLabels);
             }
             $entryFound = TRUE;
         }
         // Handle contact subtype B
         // @todo refactor into separate function
         if (array_key_exists('civicrm_contact_b_contact_sub_type_b', $row)) {
             if ($value = $row['civicrm_contact_b_contact_sub_type_b']) {
                 $rowValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                 $rowLabels = array();
                 foreach ($rowValues as $rowValue) {
                     if ($rowValue) {
                         $rowLabels[] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue);
                     }
                 }
                 $rows[$rowNum]['civicrm_contact_b_contact_sub_type_b'] = implode(', ', $rowLabels);
             }
             $entryFound = TRUE;
         }
         // Handle country
         // @todo use alterDisplayAddressFields function
         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, FALSE);
             }
             $entryFound = TRUE;
         }
         // Handle state/province
         // @todo use alterDisplayAddressFields function
         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, FALSE);
             }
             $entryFound = TRUE;
         }
         // Handle contact name A
         // @todo refactor into separate function
         if (array_key_exists('civicrm_contact_sort_name_a', $row) && array_key_exists('civicrm_contact_id', $row)) {
             $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
             $rows[$rowNum]['civicrm_contact_sort_name_a'] = $rows[$rowNum]['civicrm_contact_sort_name_a'] . ' (' . $rows[$rowNum]['civicrm_contact_id'] . ')';
             $rows[$rowNum]['civicrm_contact_sort_name_a_link'] = $url;
             $rows[$rowNum]['civicrm_contact_sort_name_a_hover'] = ts('View Contact Detail Report for this contact');
             $entryFound = TRUE;
         }
         // Handle contact name B
         // @todo refactor into separate function
         if (array_key_exists('civicrm_contact_b_sort_name_b', $row) && array_key_exists('civicrm_contact_b_id', $row)) {
             $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_b_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
             $rows[$rowNum]['civicrm_contact_b_sort_name_b'] = $rows[$rowNum]['civicrm_contact_b_sort_name_b'] . ' (' . $rows[$rowNum]['civicrm_contact_b_id'] . ')';
             $rows[$rowNum]['civicrm_contact_b_sort_name_b_link'] = $url;
             $rows[$rowNum]['civicrm_contact_b_sort_name_b_hover'] = ts('View Contact Detail Report for this contact');
             $entryFound = TRUE;
         }
         // Handle relationship
         if (array_key_exists('civicrm_relationship_relationship_id', $row) && array_key_exists('civicrm_contact_id', $row)) {
             $url = "/civicrm/contact/view/rel?reset=1&action=update&rtype=a_b&cid=" . $row['civicrm_contact_id'] . "&id=" . $row['civicrm_relationship_relationship_id'];
             $rows[$rowNum]['civicrm_relationship_relationship_id_link'] = $url;
             $rows[$rowNum]['civicrm_relationship_relationship_id_hover'] = ts("Edit this relationship.");
             $entryFound = TRUE;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }