Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
e7112fa7 | 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Page for displaying list of Gender | |
38 | */ | |
39 | class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { | |
40 | ||
96f50de2 CW |
41 | public $useLivePageJS = TRUE; |
42 | ||
6a488035 | 43 | /** |
fe482240 | 44 | * The action links that we need to display for the browse screen. |
6a488035 TO |
45 | * |
46 | * @var array | |
6a488035 TO |
47 | */ |
48 | static $_links = NULL; | |
49 | ||
50 | /** | |
fe482240 | 51 | * The option group name. |
6a488035 TO |
52 | * |
53 | * @var array | |
6a488035 TO |
54 | */ |
55 | protected $_gName; | |
56 | ||
57 | /** | |
58 | * The option group name in display format (capitalized, without underscores...etc) | |
59 | * | |
60 | * @var array | |
6a488035 TO |
61 | */ |
62 | protected $_GName; | |
63 | ||
64 | /** | |
fe482240 | 65 | * The option group id. |
6a488035 TO |
66 | * |
67 | * @var array | |
6a488035 TO |
68 | */ |
69 | protected $_gid = NULL; | |
70 | ||
71 | /** | |
72 | * Obtains the group name from url and sets the title. | |
73 | * | |
74 | * @return void | |
6a488035 | 75 | */ |
00be9182 | 76 | public function preProcess() { |
6a488035 TO |
77 | $this->_gName = 'activity_type'; |
78 | ||
79 | $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gName, 'id', 'name'); | |
80 | ||
81 | $this->_GName = 'Survey Type'; | |
82 | ||
83 | $this->assign('gName', $this->_gName); | |
84 | $this->assign('GName', $this->_GName); | |
85 | ||
86 | CRM_Utils_System::setTitle(ts('%1 Options', array(1 => $this->_GName))); | |
87 | ||
88 | $this->assign('addSurveyType', CRM_Utils_System::url("civicrm/admin/campaign/surveyType", 'reset=1&action=add')); | |
89 | } | |
90 | ||
91 | /** | |
fe482240 | 92 | * Get BAO Name. |
6a488035 | 93 | * |
a6c01b45 CW |
94 | * @return string |
95 | * Classname of BAO. | |
6a488035 | 96 | */ |
00be9182 | 97 | public function getBAOName() { |
6a488035 TO |
98 | return 'CRM_Core_BAO_OptionValue'; |
99 | } | |
100 | ||
101 | /** | |
fe482240 | 102 | * Get action Links. |
6a488035 | 103 | * |
a6c01b45 CW |
104 | * @return array |
105 | * (reference) of action links | |
6a488035 | 106 | */ |
00be9182 | 107 | public function &links() { |
6a488035 TO |
108 | if (!(self::$_links)) { |
109 | self::$_links = array( | |
110 | CRM_Core_Action::UPDATE => array( | |
111 | 'name' => ts('Edit'), | |
112 | 'url' => 'civicrm/admin/campaign/surveyType', | |
113 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
114 | 'title' => ts('Edit %1', array(1 => $this->_gName)), | |
115 | ), | |
116 | CRM_Core_Action::DISABLE => array( | |
117 | 'name' => ts('Disable'), | |
4d17a233 | 118 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
119 | 'title' => ts('Disable %1', array(1 => $this->_gName)), |
120 | ), | |
121 | CRM_Core_Action::ENABLE => array( | |
122 | 'name' => ts('Enable'), | |
4d17a233 | 123 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
124 | 'title' => ts('Enable %1', array(1 => $this->_gName)), |
125 | ), | |
126 | CRM_Core_Action::DELETE => array( | |
127 | 'name' => ts('Delete'), | |
128 | 'url' => 'civicrm/admin/campaign/surveyType', | |
129 | 'qs' => 'action=delete&id=%%id%%', | |
130 | 'title' => ts('Delete %1 Type', array(1 => $this->_gName)), | |
131 | ), | |
132 | ); | |
133 | } | |
134 | return self::$_links; | |
135 | } | |
136 | ||
137 | /** | |
138 | * Run the basic page (run essentially starts execution for that page). | |
139 | * | |
140 | * @return void | |
141 | */ | |
00be9182 | 142 | public function run() { |
6a488035 TO |
143 | $this->preProcess(); |
144 | return parent::run(); | |
145 | } | |
146 | ||
147 | /** | |
fe482240 | 148 | * Browse all options. |
6a488035 TO |
149 | * |
150 | * | |
151 | * @return void | |
6a488035 | 152 | */ |
00be9182 | 153 | public function browse() { |
6a488035 | 154 | $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign'); |
353ffa53 TO |
155 | $groupParams = array('name' => $this->_gName); |
156 | $optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight'); | |
6a488035 TO |
157 | |
158 | foreach ($optionValues as $key => $optionValue) { | |
159 | if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) { | |
160 | unset($optionValues[$key]); | |
161 | } | |
162 | } | |
163 | ||
164 | $returnURL = CRM_Utils_System::url("civicrm/admin/campaign/surveyType", | |
165 | "reset=1" | |
166 | ); | |
167 | $filter = "option_group_id = " . $this->_gid; | |
168 | CRM_Utils_Weight::addOrder($optionValues, 'CRM_Core_DAO_OptionValue', | |
169 | 'id', $returnURL, $filter | |
170 | ); | |
171 | $this->assign('rows', $optionValues); | |
172 | } | |
173 | ||
174 | /** | |
fe482240 | 175 | * Get name of edit form. |
6a488035 | 176 | * |
a6c01b45 CW |
177 | * @return string |
178 | * Classname of edit form. | |
6a488035 | 179 | */ |
00be9182 | 180 | public function editForm() { |
6a488035 TO |
181 | return 'CRM_Campaign_Form_SurveyType'; |
182 | } | |
183 | ||
184 | /** | |
fe482240 | 185 | * Get edit form name. |
6a488035 | 186 | * |
a6c01b45 CW |
187 | * @return string |
188 | * name of this page. | |
6a488035 | 189 | */ |
00be9182 | 190 | public function editName() { |
6a488035 TO |
191 | return $this->_GName; |
192 | } | |
193 | ||
194 | /** | |
195 | * Get user context. | |
196 | * | |
da6b46f4 EM |
197 | * @param null $mode |
198 | * | |
a6c01b45 CW |
199 | * @return string |
200 | * user context. | |
6a488035 | 201 | */ |
00be9182 | 202 | public function userContext($mode = NULL) { |
6a488035 TO |
203 | return 'civicrm/admin/campaign/surveyType'; |
204 | } | |
205 | ||
206 | /** | |
fe482240 | 207 | * Get userContext params. |
6a488035 | 208 | * |
7aaf6db0 TO |
209 | * @param int $mode |
210 | * Mode that we are in. | |
6a488035 TO |
211 | * |
212 | * @return string | |
6a488035 | 213 | */ |
00be9182 | 214 | public function userContextParams($mode = NULL) { |
6a488035 TO |
215 | return 'reset=1'; |
216 | } | |
96025800 | 217 | |
6a488035 | 218 | } |