Exemple #1
0
	/**
	 * Sets the data for this user. Used by update() and create().
	 * @param User $user The user object
	 */
	private function setUserData (User $user) {
		$user->setUsername($this->getParameter("username"));
		
		if ($this->hasParameter("password") && $this->getParameter("password") !== "") {
			$user->setHashedPassword($this->getParameter("password"));
		} else {
			$user->setHashedPassword("");
		}
	}
Exemple #2
0
@mkdir("../src/Proxies");
@mkdir("../data");
@mkdir("../data/images");
chmod("../data/images", 0777);
chmod("../data/files", 0777);

$tool = new \Doctrine\ORM\Tools\SchemaTool(PartKeepr::getEM());

$classes = PartKeepr::getClassMetaData();

$tool->dropDatabase($classes);
$tool->createSchema($classes);

/* Create initial test user */
$user = new User();
$user->setUsername("test");
$user->setPassword("test");
$user->setAdmin(true);
PartKeepr::getEM()->persist($user);

/* Create footprints */

$newFootprints = array();
$newCategories = array();

mysql_connect("localhost", "partdb", "partdb");
mysql_select_db("partdb");

$partUnit = new PartUnit();
$partUnit->setName(PartKeepr::i18n("Pieces"));
Exemple #3
0
	/**
	* Authenticates the given user. If successful, an instance
	* of the user is returned.
	*
	* @param User $user The user to authenticate
	* @throws InvalidLoginDataException Thrown if the user's credentials are not valid
	*/
	public function authenticate (User $user) {
		$result = 	PartKeepr::getEM()
			->getRepository("de\RaumZeitLabor\PartKeepr\User\User")
			->findOneBy(
				array(
					"username" => $user->getUsername(),
					"password" => $user->getHashedPassword()
				)
			);
	
		if ($result == null) {
			throw new InvalidLoginDataException();
		} else {
			return $result;
		}
	}