3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class is a wrapper that moves some boilerplate code out of the Form class and helps remove some ambiguity with name and label.
21 class CRM_Activity_BAO_ActivityType
{
24 * key/value pair for this activity type
27 * machineName The internal name for lookups - matches up to option_value 'name' column in the database
28 * displayLabel The label used for display/output - matches up to option_value 'label' column in the database
29 * id The value used to initialize this object - matches up to the option_value 'value' column in the database
31 protected $_activityType = [
32 'machineName' => NULL,
33 'displayLabel' => NULL,
40 * @param $activity_type_id int This matches up to the option_value 'value' column in the database.
42 public function __construct($activity_type_id) {
43 $this->setActivityType($activity_type_id);
47 * Get the key/value pair representing this activity type.
50 * @see $this->_activityType
52 public function getActivityType() {
53 return $this->_activityType
;
57 * Look up the key/value pair representing this activity type from the id.
58 * Generally called from constructor.
60 * @param $activity_type_id int This matches up to the option_value 'value' column in the database.
62 public function setActivityType($activity_type_id) {
63 if ($activity_type_id && is_numeric($activity_type_id)) {
66 * These are pulled from CRM_Activity_Form_Activity.
67 * To avoid unexpectedly changing things like introducing hidden
68 * business logic or changing permission checks I've kept it using
69 * the same function call. It may or may not be desired to have
70 * that but this at least doesn't introduce anything that wasn't
73 $machineNames = CRM_Core_OptionGroup
::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $activity_type_id, 'name');
74 $displayLabels = CRM_Core_OptionGroup
::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $activity_type_id, 'label');
76 $this->_activityType
= [
77 'machineName' => CRM_Utils_Array
::value($activity_type_id, $machineNames),
78 'displayLabel' => CRM_Utils_Array
::value($activity_type_id, $displayLabels),
79 'id' => $activity_type_id,