Skip to content

Commit

Permalink
Merging.
Browse files Browse the repository at this point in the history
  • Loading branch information
coldrunKacper committed Jul 3, 2016
2 parents 7236e62 + 441e77e commit 72a2950
Show file tree
Hide file tree
Showing 9 changed files with 16,700 additions and 25 deletions.
35 changes: 34 additions & 1 deletion CRM/Activityreport/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,37 @@ protected static function formatValue($key, $value, $level = 0) {
if (!empty(self::$fields[$key]['optionValues'])) {
return self::$fields[$key]['optionValues'][$value];
}
return strip_tags($value);
return strip_tags(self::customizeValue($key, $value));
}

/**
* Additional function for customizing Activity value by its key
* (if it's needed). For example: we want to return Campaign's title
* instead of ID.
*
* @param string $key
* @param string $value
* @return string
*/
protected static function customizeValue($key, $value) {
$result = $value;
switch ($key) {
case 'campaign_id':
if (!empty($value)) {
$campaign = civicrm_api3('Campaign', 'getsingle', array(
'sequential' => 1,
'return' => "title",
'id' => $value,
));
if ($campaign['is_error']) {
$result = '';
} else {
$result = $campaign['title'];
}
}
break;
}
return $result;
}

protected static function getEmptyRow() {
Expand Down Expand Up @@ -207,6 +237,9 @@ protected static function getActivityFields() {
if (!empty($fields['activity_type_id'])) {
$fields['activity_type_id']['title'] = t('Activity Type');
}
if (!empty($fields['activity_date_time'])) {
$fields['activity_date_time']['title'] = t('Activity Date Time');
}
$keys = CRM_Activity_DAO_Activity::fieldKeys();
$result = array();

Expand Down
82 changes: 82 additions & 0 deletions CRM/Activityreport/Upgrader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

/**
* Collection of upgrade steps.
*/
class CRM_Activityreport_Upgrader extends CRM_Activityreport_Upgrader_Base {

/**
* Installation logic.
*
* @return boolean
*/
public function install() {
$this->upgrade_0001();

return TRUE;
}

/**
* Uninstallation logic.
*
* @return boolean
*/
public function uninstall()
{
CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_navigation` WHERE name = 'activityreport'");
CRM_Core_BAO_Navigation::resetNavigation();

return TRUE;
}

/**
* Install Activity Report link under Reports menu.
*
* @return boolean
*/
public function upgrade_0001() {
CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_navigation` WHERE name = 'activityreport' and parent_id IS NULL");
$reportsNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name');
$navigation = new CRM_Core_DAO_Navigation();
$params = array (
'domain_id' => CRM_Core_Config::domainID(),
'label' => ts('Activity Report'),
'name' => 'activityreport',
'url' => 'civicrm/activity-report',
'parent_id' => $reportsNavId,
'weight' => 0,
'permission' => 'access CiviCRM pivot table reports',
'separator' => 1,
'is_active' => 1
);
$navigation->copyValues($params);
$navigation->save();
CRM_Core_BAO_Navigation::resetNavigation();

return TRUE;
}

/**
* Logic which is executing when enabling extension.
*
* @return boolean
*/
public function onEnable() {
CRM_Core_DAO::executeQuery("UPDATE civicrm_navigation SET is_active = 1 WHERE name = 'activityreport'");
CRM_Core_BAO_Navigation::resetNavigation();

return TRUE;
}

/**
* Logic which is executing when disabling extension.
*
* @return boolean
*/
public function onDisable() {
CRM_Core_DAO::executeQuery("UPDATE civicrm_navigation SET is_active = 0 WHERE name = 'activityreport'");
CRM_Core_BAO_Navigation::resetNavigation();

return TRUE;
}
}
Loading

0 comments on commit 72a2950

Please sign in to comment.