public function addAction() { $addForm = new System_Forms_UserSave(); $users = new System_Models_UserMapper(); $addForm->submit->setLabel('创建建用户'); $errorMsg = null; $ugs = new System_Models_UsergroupMapper(); $ugs->populateDd($addForm); $addForm = $users->formValidator($addForm,0); if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($addForm->isValid($formData)) { $array = $users->dataValidator($formData,0); $trigger = $array['trigger']; $errorMsg = $array['errorMsg']; if($trigger == 0) { $cTime = date("Y-m-d,H:m"); $creatorId = $this->getUserId(); $creatorCid = $users->getContactId($creatorId); $user = new System_Models_User(); $salt = md5(General_Models_GenRandomString::genRandomString(8)); $password = sha1($formData['password'].$salt); $user->setUserName($addForm->getValue('username')); $user->setPassword($password); $user->setSalt($salt); $user->setGroupId($addForm->getValue('groupId')); $user->setContactId($addForm->getValue('contactId')); $user->setCreatorId($creatorCid); $user->setCTime($cTime); $users->save($user); $this->_helper->flashMessenger->addMessage('添加用户成功。'); $this->_redirect('/system/user'); } else { $addForm->populate($formData); } } else { $addForm->populate($formData); } } $this->view->errorMsg = $errorMsg; $this->view->addForm = $addForm; }