* CRM/Memberdashboard/Page.php: New file.
* CRM/Memberdashboard/Page/Communications.php
(CRM_Memberdashboard_Page_Communications): Inherit from base page.
[contactId, loadContact, isPOST]: Remove methods.
[run]: Use pre-loaded contact object.
* CRM/Memberdashboard/Page/MemberDashboard.php
(CRM_Memberdashboard_Page_MemberDashboard): Inherit from base page.
[$contact]: Remove variable.
[__construct, loadContact]: Remove methods.
--- /dev/null
+<?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/>.
+ */
+
+require_once 'CRM/Core/Page.php';
+
+class CRM_Memberdashboard_Page extends CRM_Core_Page {
+ public $contact = NULL;
+
+ function __construct() {
+ parent::__construct();
+
+ $this->contact = $this->loadContact();
+ }
+
+ function contactId() {
+ return CRM_Core_Session::singleton()->get('userID');
+ }
+
+ /**
+ * Return a contact object for the current user.
+ *
+ * @return CRM_Contact
+ */
+ function loadContact() {
+ return civicrm_api3('contact', 'getsingle', array(
+ 'id' => $this->contactId()
+ ));
+ }
+
+ function isPOST() {
+ return $_SERVER['REQUEST_METHOD'] == 'POST';
+ }
+}
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';
- }
-
+class CRM_Memberdashboard_Page_Communications extends CRM_Memberdashboard_Page {
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(),
+ 'id' => $this->contact['id'],
$key => $value
));
}
$gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
$gContact->browse();
- $this->assign('contact', $this->loadContact());
+ $this->assign('contact', $this->contact);
$this->assign('mailFormats', array('Both', 'HTML', 'Text'));
CRM_Utils_System::setTitle('Communications');
require_once 'CRM/Core/Page.php';
-class CRM_Memberdashboard_Page_MemberDashboard extends CRM_Core_Page {
- public $contact = NULL;
-
- function __construct() {
- parent::__construct();
-
- $this->contact = $this->loadContact();
- }
-
- /**
- * Return a contact object for the current user.
- *
- * @return CRM_Contact
- */
- function loadContact() {
- return civicrm_api3('contact', 'getsingle', array(
- 'id' => CRM_Core_Session::singleton()->get('userID')
- ));
- }
-
+class CRM_Memberdashboard_Page_MemberDashboard extends CRM_Memberdashboard_Page {
/**
* Return the personalized title for the page.
*