Add member info profile setting.
authorDavid Thompson <davet@gnu.org>
Mon, 20 Oct 2014 16:03:57 +0000 (12:03 -0400)
committerDavid Thompson <davet@gnu.org>
Mon, 20 Oct 2014 16:06:28 +0000 (12:06 -0400)
* settings/MemberDashboard.setting.php: New file.
* CRM/Memberdashboard/Page/Info.php (CRM_Memberdashboard_Page_Info.run):
  Fetch member info profile and pass it to the client.
* assets/js/member-info.js: Load the configured profile instead of a
  hardcoded one.
* README.org (Configuration): New section.

CRM/Memberdashboard/Page/Info.php
README.md
assets/js/member-info.js
settings/MemberDashboard.setting.php [new file with mode: 0644]

index 6727e75154a7820b2bc97ad3cbda6987042985b5..9d62abd2151f27772bc95e4de5396edc6dfb2cca 100644 (file)
@@ -25,10 +25,18 @@ require_once 'CRM/Core/Page.php';
 class CRM_Memberdashboard_Page_Info extends CRM_Core_Page {
   function run() {
     CRM_Utils_System::setTitle('My Info');
-    CRM_Core_Resources::singleton()->addScriptFile('org.fsf.memberdashboard',
-                                                   'assets/js/underscore.js');
-    CRM_Core_Resources::singleton()->addScriptFile('org.fsf.memberdashboard',
-                                                   'assets/js/member-info.js');
+
+    $profile_id = civicrm_api3('setting', 'getvalue', array(
+      'name' => 'memberdashboard_info_profile_id',
+      'group' => 'Member Dashboard Preferences'
+    ));
+
+    $resources = CRM_Core_Resources::singleton();
+    $resources->addScriptFile('org.fsf.memberdashboard',
+                              'assets/js/underscore.js');
+    $resources->addScriptFile('org.fsf.memberdashboard',
+                              'assets/js/member-info.js');
+    $resources->addScript("var memberDashboard = { profileId: $profile_id };");
 
     parent::run();
   }
index d22a350f942c6138d38249081ce970b4e34ab6e5..19ecb76cbc2b8b6bd7427cc54ea1a4ae8eb62708 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,6 +4,16 @@ FSF Member Dashboard for CiviCRM
 This CiviCRM extension provides a custom user interface for FSF
 associate members to manage their account information.
 
+Configuration
+-------------
+
+### Set the member settings profile
+
+```
+drush civicrm-api setting.create memberdashboard_info_profile_id=<profile-id>
+```
+
+
 Copyright
 ---------
 
index 7e5d6540d6f9dee179a6502efac1b0a9ce636533..e6e8b05b93df68231e68c9398328aff88da9f4ba 100644 (file)
@@ -52,6 +52,6 @@
   }
 
   $(document).ready(function() {
-    loadProfile(1, renderProfile);
+    loadProfile(memberDashboard.profile_id, renderProfile);
   });
 })(jQuery);
diff --git a/settings/MemberDashboard.setting.php b/settings/MemberDashboard.setting.php
new file mode 100644 (file)
index 0000000..0af6b22
--- /dev/null
@@ -0,0 +1,35 @@
+<?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/>.
+ */
+
+return array(
+  'memberdashboard_info_profile_id' => array(
+    'group_name' => 'Member Dashboard Preferences',
+    'group' => 'memberdashboard',
+    'name' => 'memberdashboard_info_profile_id',
+    'type' => 'Integer',
+    'default' => 1,
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => 'Info Profile ID',
+    'help_text' => 'Profile ID for member-editable contact information'
+  )
+);
\ No newline at end of file