4 * Copyright © 2014 Free Software Foundation, Inc.
6 * This file is a part of FSF Member Dashboard.
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
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.
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/>.
23 class CRM_Admin_Form_Setting_MemberDashboard
extends CRM_Admin_Form_Setting
{
26 function setDefaultValues() {
27 return CRM_Core_BAO_Setting
::getItem(MEMBERDASHBOARD_SETTINGS_GROUP
);
31 * Fetch the names and ids of all unreserved profiles.
33 function fetchProfiles() {
34 $sql = 'SELECT id, title FROM civicrm_uf_group';
35 $dao = CRM_Core_DAO
::executeQuery($sql);
38 while($dao->fetch()) {
39 $profiles[$dao->id
] = $dao->title
;
45 public function buildQuickForm() {
46 $this->add('select', 'memberdashboard_info_profile_id',
47 'Member Info Profile', $this->fetchProfiles());
48 $this->add('text', 'memberdashboard_button_static_url',
49 'Member Button Static Image URL');
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');
56 $this->applyFilter('__ALL__', 'trim');
57 $this->addButtons(array(
66 public function postProcess() {
67 $params = $this->exportValues();
68 $profileKey = 'memberdashboard_info_profile_id';
69 $staticUrlKey = 'memberdashboard_button_static_url';
70 $apiUrlKey = 'memberdashboard_button_api_url';
71 $userKey = 'memberdashboard_button_api_user';
72 $passwordKey = 'memberdashboard_button_api_password';
74 civicrm_api3('setting', 'create', array(
75 $profileKey => $params[$profileKey],
76 $staticUrlKey => $params[$staticUrlKey],
77 $apiUrlKey => $params[$apiUrlKey],
78 $userKey => $params[$userKey],
79 $passwordKey => $params[$passwordKey]
82 CRM_Core_Session
::setStatus(ts('Settings saved.'), '', 'success');