benefits: Display member button.
authorDavid Thompson <davet@gnu.org>
Mon, 17 Nov 2014 21:12:55 +0000 (16:12 -0500)
committerDavid Thompson <davet@gnu.org>
Mon, 17 Nov 2014 21:12:55 +0000 (16:12 -0500)
* CRM/Admin/Form/Setting/MemberDashboard.php
  (CRM_Admin_Form_Setting_MemberDashboard) [buildQuickForm]: Add input
  for static button URL.
  [postProcess]: Save static button URL.
* CRM/Memberdashboard/Page/Benefits.php
  (CRM_Memberdashboard_Page_Benefits) [run]: Add 'contact' and
  'buttonUrl' smarty variables.
* settings/MemberDashboard.setting.php
  (memberdashboard_button_static_url): New setting.
* templates/CRM/Admin/Form/Setting/MemberDashboard.tpl: Render static
  button URL form field.
* templates/CRM/Memberdashboard/Page/Benefits.tpl: Render member button.

CRM/Admin/Form/Setting/MemberDashboard.php
CRM/Memberdashboard/Page/Benefits.php
settings/MemberDashboard.setting.php
templates/CRM/Admin/Form/Setting/MemberDashboard.tpl
templates/CRM/Memberdashboard/Page/Benefits.tpl

index a2b32f3de8037a2db27df074076f57574aff9aaa..e065f8f18be24a71056c51293a1e401aed064141 100644 (file)
@@ -45,6 +45,8 @@ class CRM_Admin_Form_Setting_MemberDashboard extends CRM_Admin_Form_Setting {
   public function buildQuickForm() {
     $this->add('select', 'memberdashboard_info_profile_id',
                'Member Info Profile', $this->fetchProfiles());
+    $this->add('text', 'memberdashboard_button_static_url',
+               'Member Button Static Image URL');
     $this->add('text', 'memberdashboard_button_api_url',
                'Member Button API URL');
     $this->add('text', 'memberdashboard_button_api_user',
@@ -64,13 +66,15 @@ class CRM_Admin_Form_Setting_MemberDashboard extends CRM_Admin_Form_Setting {
   public function postProcess() {
     $params = $this->exportValues();
     $profileKey = 'memberdashboard_info_profile_id';
-    $urlKey = 'memberdashboard_button_api_url';
+    $staticUrlKey = 'memberdashboard_button_static_url';
+    $apiUrlKey = 'memberdashboard_button_api_url';
     $userKey = 'memberdashboard_button_api_user';
     $passwordKey = 'memberdashboard_button_api_password';
 
     civicrm_api3('setting', 'create', array(
       $profileKey => $params[$profileKey],
-      $urlKey => $params[$urlKey],
+      $staticUrlKey => $params[$staticUrlKey],
+      $apiUrlKey => $params[$apiUrlKey],
       $userKey => $params[$userKey],
       $passwordKey => $params[$passwordKey]
     ));
index 41a7da1e8aa4485771009c084ef7f328b71d10a1..ac6bfdb5d58503b49240937556a9f16ea8ac1465 100644 (file)
@@ -161,12 +161,18 @@ class CRM_Memberdashboard_Page_Benefits extends CRM_Memberdashboard_Page {
     }
 
     $emailAliases = $this->loadEmailAliases();
+    $buttonUrl = civicrm_api3('setting', 'getvalue', array(
+      'name' => 'memberdashboard_button_static_url',
+      'group' => MEMBERDASHBOARD_SETTINGS_GROUP
+    ));
 
     CRM_Utils_System::setTitle(ts('Benefits'));
 
+    $this->assign('contact', $this->contact);
     $this->assign('user', $user);
     $this->assign('emailAliases', $emailAliases);
     $this->assign('hasValidMembership', $this->hasValidMembership());
+    $this->assign('buttonUrl', $buttonUrl);
 
     parent::run();
   }
index 445656688ba4baa4e6fc0e74059057c768457452..79ca7b50f442a9930b3420689763ceec1c5eba6c 100644 (file)
@@ -32,6 +32,17 @@ return array(
     'description' => 'Info Profile ID',
     'help_text' => 'Profile ID for member-editable contact information'
   ),
+  'memberdashboard_button_static_url' => array(
+    'group_name' => 'Member Dashboard Preferences',
+    'group' => 'memberdashboard',
+    'name' => 'memberdashboard_button_static_url',
+    'type' => 'String',
+    'default' => '',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => 'Member button static image directory URL',
+    'help_text' => 'The location of the member button static image files'
+  ),
   'memberdashboard_button_api_url' => array(
     'group_name' => 'Member Dashboard Preferences',
     'group' => 'memberdashboard',
index 3484fec9b66581cd929935cb126154a9e5d435a4..bf21d8109919cb84bc2c3b271a38f4a2c9b11f61 100644 (file)
           {$form.memberdashboard_info_profile_id.html}
         </td>
       </tr>
+      <tr>
+        <td class="label">
+          {$form.memberdashboard_button_static_url.label}
+        </td>
+        <td>
+          {$form.memberdashboard_button_static_url.html}
+        </td>
+      </tr>
       <tr>
         <td class="label">
           {$form.memberdashboard_button_api_url.label}
index 158f87688d1de3b80680eef6e79ea103badf0776..213cbca4b587131cd0ec575d6987213e2875b0b5 100644 (file)
     <input class="crm-form-submit default" type="submit" value="Add" />
   </form>
 
+  {if !empty($buttonUrl) }
+    <div class="header-dark">Member button</div>
+
+    <p>
+      Display this member button proudly on your website to show how
+      long you have been an FSF member!
+    </p>
+
+    <div width="1000px">
+      <div style="margin: 0 auto;">
+      <img style="width:182px" src="{$buttonUrl}{$contact.id}.png" />
+      </div>
+    </div>
+  {/if}
+
   <div class="header-dark">Member Forums</div>
 
   <p>