From 73f5f860b4def9258525b3f08e569a32fc0a4cd4 Mon Sep 17 00:00:00 2001
From: David Thompson
Date: Tue, 4 Nov 2014 12:53:05 -0500
Subject: [PATCH] benefits: Display email aliases in a table.
* CRM/Memberdashboard/Page/Benefits.php (CRM_Memberdashboard_Page_Benefits)
[loadEmailAliases]: New method.
[padEmailAliases]: New method.
* memberdashboard.php (MEMBERDASHBOARD_MAX_EMAIL_ALIASES): New constant.
* templates/CRM/Memberdashboard/Page/Benefits.tpl: Render email aliases.
---
CRM/Memberdashboard/Page/Benefits.php | 35 +++++++++++++++++++
memberdashboard.php | 1 +
.../CRM/Memberdashboard/Page/Benefits.tpl | 23 ++++++++++--
3 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/CRM/Memberdashboard/Page/Benefits.php b/CRM/Memberdashboard/Page/Benefits.php
index 034ec9a..286ecd6 100644
--- a/CRM/Memberdashboard/Page/Benefits.php
+++ b/CRM/Memberdashboard/Page/Benefits.php
@@ -3,14 +3,49 @@
require_once 'CRM/Memberdashboard/Page.php';
class CRM_Memberdashboard_Page_Benefits extends CRM_Memberdashboard_Page {
+ function loadEmailAliases() {
+ $dao = CRM_Core_DAO::executeQuery(
+ 'SELECT * FROM member_email_alias WHERE contact_id=%1',
+ array( 1 => array($this->contact['id'], 'Integer') )
+ );
+ $rows = array();
+
+ while($dao->fetch()) {
+ $rows[] = array(
+ 'id' => $dao->id,
+ 'contact_id' => $dao->contact_id,
+ 'localpart' => $dao->localpart,
+ 'forward' => $dao->forward
+ );
+ }
+
+ $dao->free();
+
+ return $rows;
+ }
+
+ function padEmailAliases($emailAliases) {
+ $nil = array(
+ 'id' => NULL,
+ 'contact_id' => NULL,
+ 'localpart' => '',
+ 'forward' => '',
+ );
+
+ return array_pad($emailAliases, MEMBERDASHBOARD_MAX_EMAIL_ALIASES, $nil);
+ }
+
function run() {
// FIXME: Assumes CiviCRM is running on Drupal.
// Ugly global variable for the current Drupal user.
global $user;
+ $emailAliases = $this->padEmailAliases($this->loadEmailAliases());
+
CRM_Utils_System::setTitle(ts('Benefits'));
$this->assign('user', $user);
+ $this->assign('emailAliases', $emailAliases);
parent::run();
}
diff --git a/memberdashboard.php b/memberdashboard.php
index da96b3c..f06aabc 100644
--- a/memberdashboard.php
+++ b/memberdashboard.php
@@ -3,6 +3,7 @@
require_once 'memberdashboard.civix.php';
define('MEMBERDASHBOARD_SETTINGS_GROUP', 'Member Dashboard Preferences');
+define('MEMBERDASHBOARD_MAX_EMAIL_ALIASES', 5);
/**
* Implementation of hook_civicrm_config
diff --git a/templates/CRM/Memberdashboard/Page/Benefits.tpl b/templates/CRM/Memberdashboard/Page/Benefits.tpl
index 1d09a1f..e40c777 100644
--- a/templates/CRM/Memberdashboard/Page/Benefits.tpl
+++ b/templates/CRM/Memberdashboard/Page/Benefits.tpl
@@ -63,9 +63,26 @@
take effect.
-
- mail forwarding form goes here
-
+
--
2.25.1