コード例 #1
0
ファイル: UserMapper.php プロジェクト: robliuning/Luckyrabbit
	public function find($userId,System_Models_User $user)
	{
		$resultSet = $this->getDbTable()->find($userId);

		if (0 == count($resultSet)) {

			return;
		}

		$row = $resultSet->current();

		$user->setId($row->id)
				->setUserName($row->username)
				->setGroupId($row->groupId)
				->setPassword($row->password)
				->setSalt($row->salt)
				->setContactId($row->contactId)
				->setCreatorId($row->creatorId);
		$creatorCid = $this->getContactId($user->getCreatorId());
		$contacts = new Employee_Models_ContactMapper();
		$contactName = $contacts->findContactName($user->getContactId());
		$creatorCname = $contacts->findContactName($creatorCid);
		$user->setContactName($contactName);
		$user->setCreatorCid($creatorCid);
		$user->setCreatorCname($creatorCname);
		$ugs = new System_Models_UsergroupMapper();
		$groupName = $ugs->getGroupName($user->getGroupId());
		$user->setGroupName($groupName);
	}
コード例 #2
0
	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;
	}