• Main Page
  • Modules
  • Classes
  • Files
  • File List

controllers/grid/settings/user/form/UserEmailForm.inc.php

00001 <?php
00002 
00015 import('lib.pkp.classes.form.Form');
00016 
00017 class UserEmailForm extends Form {
00018 
00019    /* @var the user id of user to send email to */
00020    var $userId;
00021 
00025    function UserEmailForm($userId) {
00026       parent::Form('controllers/grid/settings/user/form/userEmailForm.tpl');
00027 
00028       $this->userId = (int) $userId;
00029 
00030       $this->addCheck(new FormValidator($this, 'subject', 'required', 'email.subjectRequired'));
00031       $this->addCheck(new FormValidator($this, 'message', 'required', 'email.bodyRequired'));
00032       $this->addCheck(new FormValidatorPost($this));
00033    }
00034 
00038    function initData($args, &$request) {
00039       $fromUser =& $request->getUser();
00040       $fromSignature = "\n\n\n" . $fromUser->getLocalizedSignature();
00041 
00042       $this->_data = array(
00043          'message' => $fromSignature
00044       );
00045    }
00046 
00051    function readInputData() {
00052       $this->readUserVars(
00053          array(
00054             'subject',
00055             'message'
00056          )
00057       );
00058 
00059    }
00060 
00064    function display($args, &$request) {
00065       $userDao =& DAORegistry::getDAO('UserDAO');
00066       $user =& $userDao->getById($this->userId);
00067 
00068       $templateMgr =& TemplateManager::getManager();
00069       $templateMgr->assign('userId', $this->userId);
00070       $templateMgr->assign('userFullName', $user->getFullName());
00071       $templateMgr->assign('userEmail', $user->getEmail());
00072 
00073       return $this->fetch($request);
00074    }
00075 
00081    function execute($args, &$request) {
00082       $userDao =& DAORegistry::getDAO('UserDAO');
00083       $toUser =& $userDao->getById($this->userId);
00084       $fromUser =& $request->getUser();
00085 
00086       import('lib.pkp.classes.mail.Mail');
00087       $email = new Mail();
00088 
00089       $email->addRecipient($toUser->getEmail(), $toUser->getFullName());
00090       $email->setFrom($fromUser->getEmail(), $fromUser->getFullName());
00091       $email->setSubject($this->getData('subject'));
00092       $email->setBody($this->getData('message'));
00093       $email->send();
00094    }
00095 }
00096 
00097 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1