require_once 'CRM/Core/Page.php';
class CRM_Memberdashboard_Page_Communications extends CRM_Core_Page {
+ function contactId() {
+ return CRM_Core_Session::singleton()->get('userID');
+ }
+
+ function loadContact() {
+ return civicrm_api3('contact', 'getsingle', array(
+ 'id' => $this->contactId()
+ ));
+ }
+
+ function isPOST() {
+ return $_SERVER['REQUEST_METHOD'] == 'POST';
+ }
+
+ function postProcess($params) {
+ // Update member's preferred mail format (plain text, HTML)
+ $key = 'preferred_mail_format';
+ $value = $params[$key];
+
+ civicrm_api3('contact', 'create', array(
+ 'id' => $this->contactId(),
+ $key => $value
+ ));
+ }
+
function run() {
+ // Handle POST requests to update email preferences.
+ if($this->isPOST()) {
+ $this->postProcess($_POST);
+ }
+
$helper = new CRM_Memberdashboard_Page_ComponentHelper(array('CiviEvent'));
$helper->run();
$this->assign('dashboardElements', $helper->buildDashboardElements());
+
$gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
- $gContact->run();
+ $gContact->browse();
+
+ $this->assign('contact', $this->loadContact());
+ $this->assign('mailFormats', array('Both', 'HTML', 'Text'));
CRM_Utils_System::setTitle('Communications');