00001 <?php
00002
00015 import('lib.pkp.classes.form.Form');
00016
00017 class UserDisableForm extends Form {
00018
00019
00020 var $_userId;
00021
00022
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 ?>