Commit | Line | Data |
---|---|---|
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 | /** | |
3819f101 | 19 | * Page for displaying list of Gender. |
6a488035 TO |
20 | */ |
21 | class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { | |
22 | ||
96f50de2 CW |
23 | public $useLivePageJS = TRUE; |
24 | ||
6a488035 | 25 | /** |
fe482240 | 26 | * The action links that we need to display for the browse screen. |
6a488035 TO |
27 | * |
28 | * @var array | |
6a488035 | 29 | */ |
f157740d | 30 | public static $_links = NULL; |
6a488035 TO |
31 | |
32 | /** | |
fe482240 | 33 | * The option group name. |
6a488035 TO |
34 | * |
35 | * @var array | |
6a488035 TO |
36 | */ |
37 | protected $_gName; | |
38 | ||
39 | /** | |
40 | * The option group name in display format (capitalized, without underscores...etc) | |
41 | * | |
42 | * @var array | |
6a488035 TO |
43 | */ |
44 | protected $_GName; | |
45 | ||
46 | /** | |
fe482240 | 47 | * The option group id. |
6a488035 TO |
48 | * |
49 | * @var array | |
6a488035 TO |
50 | */ |
51 | protected $_gid = NULL; | |
52 | ||
53 | /** | |
54 | * Obtains the group name from url and sets the title. | |
6a488035 | 55 | */ |
00be9182 | 56 | public function preProcess() { |
6a488035 TO |
57 | $this->_gName = 'activity_type'; |
58 | ||
59 | $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gName, 'id', 'name'); | |
60 | ||
61 | $this->_GName = 'Survey Type'; | |
62 | ||
63 | $this->assign('gName', $this->_gName); | |
64 | $this->assign('GName', $this->_GName); | |
65 | ||
be2fb01f | 66 | CRM_Utils_System::setTitle(ts('%1 Options', [1 => $this->_GName])); |
6a488035 | 67 | |
be2fb01f | 68 | $this->assign('addSurveyType', ["civicrm/admin/campaign/surveyType", "reset=1&action=add"]); |
6a488035 TO |
69 | } |
70 | ||
71 | /** | |
fe482240 | 72 | * Get BAO Name. |
6a488035 | 73 | * |
a6c01b45 CW |
74 | * @return string |
75 | * Classname of BAO. | |
6a488035 | 76 | */ |
00be9182 | 77 | public function getBAOName() { |
6a488035 TO |
78 | return 'CRM_Core_BAO_OptionValue'; |
79 | } | |
80 | ||
81 | /** | |
fe482240 | 82 | * Get action Links. |
6a488035 | 83 | * |
a6c01b45 CW |
84 | * @return array |
85 | * (reference) of action links | |
6a488035 | 86 | */ |
00be9182 | 87 | public function &links() { |
6a488035 | 88 | if (!(self::$_links)) { |
be2fb01f CW |
89 | self::$_links = [ |
90 | CRM_Core_Action::UPDATE => [ | |
6a488035 TO |
91 | 'name' => ts('Edit'), |
92 | 'url' => 'civicrm/admin/campaign/surveyType', | |
93 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
be2fb01f CW |
94 | 'title' => ts('Edit %1', [1 => $this->_gName]), |
95 | ], | |
96 | CRM_Core_Action::DISABLE => [ | |
6a488035 | 97 | 'name' => ts('Disable'), |
4d17a233 | 98 | 'ref' => 'crm-enable-disable', |
be2fb01f CW |
99 | 'title' => ts('Disable %1', [1 => $this->_gName]), |
100 | ], | |
101 | CRM_Core_Action::ENABLE => [ | |
6a488035 | 102 | 'name' => ts('Enable'), |
4d17a233 | 103 | 'ref' => 'crm-enable-disable', |
be2fb01f CW |
104 | 'title' => ts('Enable %1', [1 => $this->_gName]), |
105 | ], | |
106 | CRM_Core_Action::DELETE => [ | |
6a488035 TO |
107 | 'name' => ts('Delete'), |
108 | 'url' => 'civicrm/admin/campaign/surveyType', | |
109 | 'qs' => 'action=delete&id=%%id%%', | |
be2fb01f CW |
110 | 'title' => ts('Delete %1 Type', [1 => $this->_gName]), |
111 | ], | |
112 | ]; | |
6a488035 TO |
113 | } |
114 | return self::$_links; | |
115 | } | |
116 | ||
117 | /** | |
118 | * Run the basic page (run essentially starts execution for that page). | |
6a488035 | 119 | */ |
00be9182 | 120 | public function run() { |
6a488035 TO |
121 | $this->preProcess(); |
122 | return parent::run(); | |
123 | } | |
124 | ||
125 | /** | |
fe482240 | 126 | * Browse all options. |
6a488035 | 127 | */ |
00be9182 | 128 | public function browse() { |
6a488035 | 129 | $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign'); |
be2fb01f | 130 | $groupParams = ['name' => $this->_gName]; |
353ffa53 | 131 | $optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight'); |
6a488035 TO |
132 | |
133 | foreach ($optionValues as $key => $optionValue) { | |
134 | if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) { | |
135 | unset($optionValues[$key]); | |
136 | } | |
137 | } | |
138 | ||
139 | $returnURL = CRM_Utils_System::url("civicrm/admin/campaign/surveyType", | |
140 | "reset=1" | |
141 | ); | |
142 | $filter = "option_group_id = " . $this->_gid; | |
143 | CRM_Utils_Weight::addOrder($optionValues, 'CRM_Core_DAO_OptionValue', | |
144 | 'id', $returnURL, $filter | |
145 | ); | |
146 | $this->assign('rows', $optionValues); | |
147 | } | |
148 | ||
149 | /** | |
fe482240 | 150 | * Get name of edit form. |
6a488035 | 151 | * |
a6c01b45 CW |
152 | * @return string |
153 | * Classname of edit form. | |
6a488035 | 154 | */ |
00be9182 | 155 | public function editForm() { |
6a488035 TO |
156 | return 'CRM_Campaign_Form_SurveyType'; |
157 | } | |
158 | ||
159 | /** | |
fe482240 | 160 | * Get edit form name. |
6a488035 | 161 | * |
a6c01b45 CW |
162 | * @return string |
163 | * name of this page. | |
6a488035 | 164 | */ |
00be9182 | 165 | public function editName() { |
6a488035 TO |
166 | return $this->_GName; |
167 | } | |
168 | ||
169 | /** | |
170 | * Get user context. | |
171 | * | |
da6b46f4 EM |
172 | * @param null $mode |
173 | * | |
a6c01b45 CW |
174 | * @return string |
175 | * user context. | |
6a488035 | 176 | */ |
00be9182 | 177 | public function userContext($mode = NULL) { |
6a488035 TO |
178 | return 'civicrm/admin/campaign/surveyType'; |
179 | } | |
180 | ||
181 | /** | |
fe482240 | 182 | * Get userContext params. |
6a488035 | 183 | * |
7aaf6db0 TO |
184 | * @param int $mode |
185 | * Mode that we are in. | |
6a488035 TO |
186 | * |
187 | * @return string | |
6a488035 | 188 | */ |
00be9182 | 189 | public function userContextParams($mode = NULL) { |
6a488035 TO |
190 | return 'reset=1'; |
191 | } | |
96025800 | 192 | |
6a488035 | 193 | } |