Commit | Line | Data |
---|---|---|
6b4f39a8 DT |
1 | <?php |
2 | /** | |
3 | * FSF Member Dashboard | |
4 | * Copyright © 2014 Free Software Foundation, Inc. | |
5 | * | |
6 | * This file is a part of FSF Member Dashboard. | |
7 | * | |
8 | * FSF Member Dashboard is free software; you can copy, modify, and | |
9 | * distribute it under the terms of the GNU Affero General Public | |
10 | * License Version 3, 19 November 2007 and the CiviCRM Licensing | |
11 | * Exception. | |
12 | * | |
13 | * FSF Member Dashboard is distributed in the hope that it will be | |
14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty | |
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * Affero General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with FSF Member Dashboard. If not, see | |
20 | * <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | class CRM_Admin_Form_Setting_MemberDashboard extends CRM_Admin_Form_Setting { | |
24 | protected $_values; | |
25 | ||
26 | function setDefaultValues() { | |
27 | return CRM_Core_BAO_Setting::getItem(MEMBERDASHBOARD_SETTINGS_GROUP); | |
28 | } | |
29 | ||
9ecf8031 DT |
30 | /** |
31 | * Fetch the names and ids of all unreserved profiles. | |
32 | */ | |
33 | function fetchProfiles() { | |
ba667639 | 34 | $sql = 'SELECT id, title FROM civicrm_uf_group'; |
6b4f39a8 DT |
35 | $dao = CRM_Core_DAO::executeQuery($sql); |
36 | $profiles = array(); | |
37 | ||
38 | while($dao->fetch()) { | |
39 | $profiles[$dao->id] = $dao->title; | |
40 | } | |
41 | ||
9ecf8031 DT |
42 | return $profiles; |
43 | } | |
44 | ||
45 | public function buildQuickForm() { | |
6b4f39a8 | 46 | $this->add('select', 'memberdashboard_info_profile_id', |
9ecf8031 | 47 | 'Member Info Profile', $this->fetchProfiles()); |
f5310d9e DT |
48 | $this->add('text', 'memberdashboard_button_static_url', |
49 | 'Member Button Static Image URL'); | |
fdb5b92e DT |
50 | $this->add('text', 'memberdashboard_button_api_url', |
51 | 'Member Button API URL'); | |
52 | $this->add('text', 'memberdashboard_button_api_user', | |
53 | 'Member Button API User'); | |
54 | $this->add('text', 'memberdashboard_button_api_password', | |
55 | 'Member Button API Password'); | |
6b4f39a8 DT |
56 | $this->applyFilter('__ALL__', 'trim'); |
57 | $this->addButtons(array( | |
58 | array( | |
59 | 'type' => 'submit', | |
60 | 'name' => ts('Save'), | |
61 | 'isDefault' => TRUE, | |
62 | ), | |
63 | )); | |
64 | } | |
65 | ||
66 | public function postProcess() { | |
67 | $params = $this->exportValues(); | |
fdb5b92e | 68 | $profileKey = 'memberdashboard_info_profile_id'; |
f5310d9e DT |
69 | $staticUrlKey = 'memberdashboard_button_static_url'; |
70 | $apiUrlKey = 'memberdashboard_button_api_url'; | |
fdb5b92e DT |
71 | $userKey = 'memberdashboard_button_api_user'; |
72 | $passwordKey = 'memberdashboard_button_api_password'; | |
6b4f39a8 DT |
73 | |
74 | civicrm_api3('setting', 'create', array( | |
fdb5b92e | 75 | $profileKey => $params[$profileKey], |
f5310d9e DT |
76 | $staticUrlKey => $params[$staticUrlKey], |
77 | $apiUrlKey => $params[$apiUrlKey], | |
fdb5b92e DT |
78 | $userKey => $params[$userKey], |
79 | $passwordKey => $params[$passwordKey] | |
6b4f39a8 DT |
80 | )); |
81 | ||
82 | CRM_Core_Session::setStatus(ts('Settings saved.'), '', 'success'); | |
83 | } | |
84 | } |