4 * Copyright © 2014 Free Software Foundation, Inc.
6 * This file is a part of FSF Member Dashboard.
8 * FSF Member Dashboard is free software; you can copy, modify, and
9 * distribute it under the terms of the GNU Affero General Public
10 * License Version 3, 19 November 2007 and the CiviCRM Licensing
13 * FSF Member Dashboard is distributed in the hope that it will be
14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Affero General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FSF Member Dashboard. If not, see
20 * <http://www.gnu.org/licenses/>.
23 require_once 'CRM/Core/Page.php';
25 class CRM_Memberdashboard_Page_Communications
extends CRM_Core_Page
{
26 function contactId() {
27 return CRM_Core_Session
::singleton()->get('userID');
30 function loadContact() {
31 return civicrm_api3('contact', 'getsingle', array(
32 'id' => $this->contactId()
37 return $_SERVER['REQUEST_METHOD'] == 'POST';
40 function postProcess($params) {
41 // Update member's preferred mail format (plain text, HTML)
42 $key = 'preferred_mail_format';
43 $value = $params[$key];
45 civicrm_api3('contact', 'create', array(
46 'id' => $this->contactId(),
52 // Handle POST requests to update email preferences.
54 $this->postProcess($_POST);
57 $helper = new CRM_Memberdashboard_Page_ComponentHelper(array('CiviEvent'));
59 $this->assign('dashboardElements', $helper->buildDashboardElements());
61 $gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
64 $this->assign('contact', $this->loadContact());
65 $this->assign('mailFormats', array('Both', 'HTML', 'Text'));
67 CRM_Utils_System
::setTitle('Communications');