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

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

00001 <?php
00002 
00015 import('lib.pkp.classes.form.Form');
00016 
00017 class UserDisableForm extends Form {
00018 
00019    /* @var the user id of user to enable/disable */
00020    var $_userId;
00021 
00022    /* @var whether to enable or disable the user */
00023    var $_enable;
00024 
00028    function UserDisableForm($userId, $enable = false) {
00029       parent::Form('controllers/grid/settings/user/form/userDisableForm.tpl');
00030 
00031       $this->_userId = (int) $userId;
00032       $this->_enable = (bool) $enable;
00033 
00034       $this->addCheck(new FormValidatorPost($this));
00035    }
00036 
00040    function initData($args, &$request) {
00041       if ($this->_userId) {
00042          $userDao =& DAORegistry::getDAO('UserDAO');
00043          $user =& $userDao->getById($this->_userId);
00044 
00045          if ($user) {
00046             $this->_data = array(
00047                'disableReason' => $user->getDisabledReason()
00048             );
00049          }
00050       }
00051    }
00052 
00057    function readInputData() {
00058       $this->readUserVars(
00059          array(
00060             'disableReason',
00061          )
00062       );
00063 
00064    }
00065 
00069    function display($args, &$request) {
00070       $templateMgr =& TemplateManager::getManager();
00071       $templateMgr->assign('userId', $this->_userId);
00072       $templateMgr->assign('enable', $this->_enable);
00073 
00074       return $this->fetch($request);
00075    }
00076 
00082    function &execute($args, &$request) {
00083       $userDao =& DAORegistry::getDAO('UserDAO');
00084       $user =& $userDao->getById($this->_userId);
00085 
00086       if ($user) {
00087          $user->setDisabled($this->_enable ? false : true);
00088          $user->setDisabledReason($this->getData('disableReason'));
00089          $userDao->updateObject($user);
00090       }
00091 
00092       return $user;
00093    }
00094 }
00095 
00096 ?>

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