Merge pull request #22825 from MegaphoneJon/membership-41
[civicrm-core.git] / CRM / Admin / Page / LocationType.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Page for displaying list of location types.
20 */
21 class CRM_Admin_Page_LocationType extends CRM_Core_Page_Basic {
22
23 public $useLivePageJS = TRUE;
24
25 /**
26 * The action links that we need to display for the browse screen.
27 *
28 * @var array
29 */
30 public static $_links = NULL;
31
32 /**
33 * Get BAO Name.
34 *
35 * @return string
36 * Classname of BAO.
37 */
38 public function getBAOName() {
39 return 'CRM_Core_BAO_LocationType';
40 }
41
42 /**
43 * Get action Links.
44 *
45 * @return array
46 * (reference) of action links
47 */
48 public function &links() {
49 if (!(self::$_links)) {
50 self::$_links = [
51 CRM_Core_Action::UPDATE => [
52 'name' => ts('Edit'),
53 'url' => 'civicrm/admin/locationType',
54 'qs' => 'action=update&id=%%id%%&reset=1',
55 'title' => ts('Edit Location Type'),
56 ],
57 CRM_Core_Action::DISABLE => [
58 'name' => ts('Disable'),
59 'ref' => 'crm-enable-disable',
60 'title' => ts('Disable Location Type'),
61 ],
62 CRM_Core_Action::ENABLE => [
63 'name' => ts('Enable'),
64 'ref' => 'crm-enable-disable',
65 'title' => ts('Enable Location Type'),
66 ],
67 CRM_Core_Action::DELETE => [
68 'name' => ts('Delete'),
69 'url' => 'civicrm/admin/locationType',
70 'qs' => 'action=delete&id=%%id%%',
71 'title' => ts('Delete Location Type'),
72 ],
73 ];
74 }
75 return self::$_links;
76 }
77
78 /**
79 * Get name of edit form.
80 *
81 * @return string
82 * Classname of edit form.
83 */
84 public function editForm() {
85 return 'CRM_Admin_Form_LocationType';
86 }
87
88 /**
89 * Get edit form name.
90 *
91 * @return string
92 * name of this page.
93 */
94 public function editName() {
95 return 'Location Types';
96 }
97
98 /**
99 * Get user context.
100 *
101 * @param null $mode
102 *
103 * @return string
104 * user context.
105 */
106 public function userContext($mode = NULL) {
107 return 'civicrm/admin/locationType';
108 }
109
110 /**
111 * @param $sort
112 * @param $action
113 * @param array $links
114 *
115 * @return array
116 */
117 protected function getRows($sort, $action, array $links): array {
118 $rows = parent::getRows($sort, $action, $links);
119 foreach ($rows as &$row) {
120 // prevent smarty notices.
121 foreach (['is_default', 'class', 'vcard_name'] as $expectedField) {
122 if (!isset($row['is_default'])) {
123 $row[$expectedField] = NULL;
124 }
125 }
126 }
127 return $rows;
128 }
129
130 }