Add a settings page.
authorDavid Thompson <davet@gnu.org>
Tue, 21 Oct 2014 14:04:05 +0000 (10:04 -0400)
committerDavid Thompson <davet@gnu.org>
Tue, 21 Oct 2014 14:04:05 +0000 (10:04 -0400)
* CRM/Admin/Form/Setting/MemberDashboard.php: New file.
* templates/CRM/Admin/Form/Setting/MemberDashboard.tpl: New file.
* xml/Menu/memberdashboard.xml: Add menu entry.

CRM/Admin/Form/Setting/MemberDashboard.php [new file with mode: 0644]
templates/CRM/Admin/Form/Setting/MemberDashboard.tpl [new file with mode: 0644]
xml/Menu/memberdashboard.xml

diff --git a/CRM/Admin/Form/Setting/MemberDashboard.php b/CRM/Admin/Form/Setting/MemberDashboard.php
new file mode 100644 (file)
index 0000000..b9c4ca6
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * FSF Member Dashboard
+ * Copyright © 2014 Free Software Foundation, Inc.
+ *
+ * This file is a part of FSF Member Dashboard.
+ *
+ * FSF Member Dashboard is free software; you can copy, modify, and
+ * distribute it under the terms of the GNU Affero General Public
+ * License Version 3, 19 November 2007 and the CiviCRM Licensing
+ * Exception.
+ *
+ * FSF Member Dashboard is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FSF Member Dashboard.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+class CRM_Admin_Form_Setting_MemberDashboard extends CRM_Admin_Form_Setting {
+  protected $_values;
+
+  function setDefaultValues() {
+    return CRM_Core_BAO_Setting::getItem(MEMBERDASHBOARD_SETTINGS_GROUP);
+  }
+
+  public function buildQuickForm() {
+    // Fetch the names and ids of all unreserved profiles.
+    $sql = 'SELECT id, title FROM civicrm_uf_group WHERE is_reserved=0';
+    $dao = CRM_Core_DAO::executeQuery($sql);
+    $profiles = array();
+
+    while($dao->fetch()) {
+      $profiles[$dao->id] = $dao->title;
+    }
+
+    $this->add('select', 'memberdashboard_info_profile_id',
+               'Member Info Profile', $profiles);
+    $this->applyFilter('__ALL__', 'trim');
+    $this->addButtons(array(
+      array(
+        'type' => 'submit',
+        'name' => ts('Save'),
+        'isDefault' => TRUE,
+      ),
+    ));
+  }
+
+  public function postProcess() {
+    $params = $this->exportValues();
+    $key = 'memberdashboard_info_profile_id';
+    $value = $params[$key];
+
+    civicrm_api3('setting', 'create', array(
+      $key => $value
+    ));
+
+    CRM_Core_Session::setStatus(ts('Settings saved.'), '', 'success');
+  }
+}
diff --git a/templates/CRM/Admin/Form/Setting/MemberDashboard.tpl b/templates/CRM/Admin/Form/Setting/MemberDashboard.tpl
new file mode 100644 (file)
index 0000000..245e05f
--- /dev/null
@@ -0,0 +1,46 @@
+{*
+  FSF Member Dashboard
+  Copyright © 2014 Free Software Foundation, Inc.
+
+  This file is a part of FSF Member Dashboard.
+
+  FSF Member Dashboard is free software: you can redistribute it
+  and/or modify it under the terms of the GNU Affero General Public
+  License as published by the Free Software Foundation, either version
+  3 of the License, or (at your option) any later version.
+
+  FSF Member Dashboard is distributed in the hope that it will be
+  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with FSF Member Dashboard.  If not, see
+  <http://www.gnu.org/licenses/>.
+*}
+
+<div class="crm-block crm-form-block crm-regionlookup-form-block">
+  <fieldset>
+    <legend>{ts}Info Profile{/ts}</legend>
+
+    <div class="help">
+      {ts}The profile that members should see when editing their
+      contact information.{/ts}
+    </div>
+
+    <table class="form-layout-compressed">
+      <tr>
+        <td class="label">
+          {$form.memberdashboard_info_profile_id.label}
+        </td>
+        <td>
+          {$form.memberdashboard_info_profile_id.html}
+        </td>
+      </tr>
+    </table>
+  </fieldset>
+
+  <div class="crm-submit-buttons">
+    {include file="CRM/common/formButtons.tpl" location="bottom"}
+  </div>
+</div>
index 8792b7c342c16e60296a0ab893aa26f917758422..c9e97493c84885ab29c9fffc4bdb01d89224e199 100644 (file)
@@ -1,5 +1,12 @@
 <?xml version="1.0"?>
 <menu>
+  <item>
+    <path>civicrm/admin/setting/memberdashboard</path>
+    <title>FSF Member Dashboard Settings</title>
+    <page_callback>CRM_Admin_Form_Setting_MemberDashboard</page_callback>
+    <adminGroup>System Settings</adminGroup>
+    <access_arguments>administer CiviCRM</access_arguments>
+  </item>
   <item>
     <path>civicrm/member-dashboard</path>
     <page_callback>CRM_Memberdashboard_Page_MemberDashboard</page_callback>