Merge pull request #23509 from eileenmcnaughton/import_except
[civicrm-core.git] / CRM / Admin / Page / ContactType.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
ce064e4f 19 * Page for displaying list of contact Subtypes.
6a488035
TO
20 */
21class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic {
22
96f50de2
CW
23 public $useLivePageJS = TRUE;
24
6a488035 25 /**
eceb18cc 26 * The action links that we need to display for the browse screen.
6a488035
TO
27 *
28 * @var array
6a488035 29 */
62d3ee27 30 public static $_links = NULL;
6a488035
TO
31
32 /**
eceb18cc 33 * Get BAO Name.
6a488035 34 *
a6c01b45
CW
35 * @return string
36 * Classname of BAO.
6a488035 37 */
00be9182 38 public function getBAOName() {
6a488035
TO
39 return 'CRM_Contact_BAO_ContactType';
40 }
41
42 /**
eceb18cc 43 * Get action Links.
6a488035 44 *
a6c01b45
CW
45 * @return array
46 * (reference) of action links
6a488035 47 */
00be9182 48 public function &links() {
6a488035 49 if (!(self::$_links)) {
be2fb01f
CW
50 self::$_links = [
51 CRM_Core_Action::UPDATE => [
6a488035
TO
52 'name' => ts('Edit'),
53 'url' => 'civicrm/admin/options/subtype',
54 'qs' => 'action=update&id=%%id%%&reset=1',
55 'title' => ts('Edit Contact Type'),
be2fb01f
CW
56 ],
57 CRM_Core_Action::DISABLE => [
6a488035 58 'name' => ts('Disable'),
4d17a233 59 'ref' => 'crm-enable-disable',
6a488035 60 'title' => ts('Disable Contact Type'),
be2fb01f
CW
61 ],
62 CRM_Core_Action::ENABLE => [
6a488035 63 'name' => ts('Enable'),
4d17a233 64 'ref' => 'crm-enable-disable',
6a488035 65 'title' => ts('Enable Contact Type'),
be2fb01f
CW
66 ],
67 CRM_Core_Action::DELETE => [
6a488035
TO
68 'name' => ts('Delete'),
69 'url' => 'civicrm/admin/options/subtype',
70 'qs' => 'action=delete&id=%%id%%',
71 'title' => ts('Delete Contact Type'),
be2fb01f
CW
72 ],
73 ];
6a488035
TO
74 }
75 return self::$_links;
76 }
77
ce064e4f 78 /**
79 * Run page.
80 */
00be9182 81 public function run() {
6a488035
TO
82 $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
83 $this->assign('action', $action);
84 $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
85 if (!$action) {
86 $this->browse();
87 }
88 return parent::run();
89 }
90
ce064e4f 91 /**
92 * Browse contact types.
93 */
00be9182 94 public function browse() {
6a488035
TO
95 $rows = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE);
96 foreach ($rows as $key => $value) {
97 $mask = NULL;
a7488080 98 if (!empty($value['is_reserved'])) {
6a488035
TO
99 $mask = CRM_Core_Action::UPDATE;
100 }
101 else {
102 $mask -= CRM_Core_Action::DELETE - 2;
a7488080 103 if (!empty($value['is_active'])) {
6a488035
TO
104 $mask -= CRM_Core_Action::ENABLE;
105 }
106 else {
107 $mask -= CRM_Core_Action::DISABLE;
108 }
109 }
110 $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask,
be2fb01f 111 ['id' => $value['id']],
87dab4a4
AH
112 ts('more'),
113 FALSE,
114 'contactType.manage.action',
115 'ContactType',
116 $value['id']
6a488035
TO
117 );
118 }
119 $this->assign('rows', $rows);
120 }
121
122 /**
eceb18cc 123 * Get name of edit form.
6a488035 124 *
a6c01b45
CW
125 * @return string
126 * Classname of edit form.
6a488035 127 */
00be9182 128 public function editForm() {
6a488035
TO
129 return 'CRM_Admin_Form_ContactType';
130 }
131
132 /**
eceb18cc 133 * Get edit form name.
6a488035 134 *
a6c01b45
CW
135 * @return string
136 * name of this page.
6a488035 137 */
00be9182 138 public function editName() {
6a488035
TO
139 return 'Contact Types';
140 }
141
142 /**
143 * Get user context.
144 *
da6b46f4
EM
145 * @param null $mode
146 *
a6c01b45
CW
147 * @return string
148 * user context.
6a488035 149 */
00be9182 150 public function userContext($mode = NULL) {
6a488035
TO
151 return 'civicrm/admin/options/subtype';
152 }
96025800 153
6a488035 154}