示例#1
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;
	}
	public function addAction()
	{
		$errorMsg = null;
		$messages = new Admin_Models_MessageMapper();
		$usergroups = new System_Models_UsergroupMapper();
		$addForm = new Admin_Form_MessageSave();
		$addForm->getElement('groupId')->addMultiOption('0','所有用户');
		$addForm->submit->setLabel("发送信息");
		$usergroups->populateDd($addForm);
		$addForm = $messages->formValidator($addForm);
		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($addForm->isValid($formData))
			{
				$array = $messages->dataValidator($formData);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$sendTime = date('Y-m-d,H:m');
					$groupId = $addForm->getValue('groupId');
					$message = new Admin_Models_Message();
					$message->setFromId($this->getUserId());
					$message->setTitle($addForm->getValue('title'));
					$message->setContent($addForm->getValue('content'));
					$message->setSendTime($sendTime);
					$message->setStatus(0);
					$messages->sendByGroup($groupId,$message);
					$this->_helper->flashMessenger->addMessage('信息: '.$message->getTitle().'发送成功。');
					$this->_redirect('/admin/message');
					}
					else
					{
						$addForm->populate($formData);
						}
				}
				else
				{
					$addForm->populate($formData);
					}
			}
		$this->view->controller = "add";
		$this->view->errorMsg = $errorMsg;
		$this->view->addForm = $addForm;
	}
示例#3
0
	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);
	}