This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Entities/User.php
T
Taras Machyshyn 417576fd5e change instance
2013-11-01 13:49:54 +02:00

85 lines
1.4 KiB
PHP
Executable File

<?php
namespace Espo\Entities;
use Doctrine\Common\Collections\ArrayCollection,
\Espo\Core as Core;
/**
* @Entity @Table(name="users")
*/
class User extends Core\Base
{
/**
* @var string
*/
protected $id;
/**
* @var string
*/
protected $username;
protected $password;
protected $isAdmin;
public function __construct()
{
//$this->reportedBugs = new ArrayCollection();
//$this->assignedBugs = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getUsername()
{
return $this->username;
}
public function getIsAdmin()
{
return $this->isAdmin;
}
public function setName($name)
{
$this->name = $name;
}
/**
* Check user's credentials (NEED TO REWRITE)
*/
public function login($username, $password)
{
$dbUsername= 'admin';
$dbPassword= '1';
if ($username==$dbUsername && $password==$dbPassword) {
return true;
}
return false;
}
//NEED TO REWRITE
public function isAdmin($username='')
{
if (empty($username)) {
$username= $this->getUsername();
}
if ( !isset($this->id) || empty($this->id) ) {
global $base;
return $base->em->getRepository('\Espo\Entities\User')->findOneBy(array('username' => $username))->getIsAdmin(); //$this->getEntityManager()
}
if ($this->getUsername() == $username) {
return $this->getIsAdmin();
}
return false;
}
}