enable encounter name with quotes (#1715)
[openemr.git] / repositories / UserRepository.php
blobc069d40e9eb4721b532df020e2b736ef76bb822d
1 <?php
2 /**
3 * User repository.
5 * Copyright (C) 2017 Matthew Vita <matthewvita48@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Matthew Vita <matthewvita48@gmail.com>
20 * @author Victor Kofia <victor.kofia@gmail.com>
21 * @link http://www.open-emr.org
24 namespace OpenEMR\Repositories;
26 use Doctrine\ORM\EntityRepository;
27 use Doctrine\Common\Collections\Criteria;
29 class UserRepository extends EntityRepository
31 /**
32 * Finds the user associated with the local session id.
34 * @return user.
36 public function getCurrentlyLoggedInUser()
38 $results = $this->_em->getRepository($this->_entityName)->findOneBy(array("username" => $_SESSION["authUser"]));
39 return $results;
42 /**
43 * Finds the user associated with the specified id
45 * @return user.
47 public function getUser($userId)
49 $results = $this->_em->getRepository($this->_entityName)->findOneBy(array("id" => $userId));
50 return $results;
53 /**
54 * Returns all active users
56 * @return users
58 public function getActiveUsers()
60 $criteria = Criteria::create();
61 $criteria->where(Criteria::expr()->neq("username", ""));
62 $criteria->andWhere(Criteria::expr()->eq("active", 1));
63 $criteria->orderBy(array("lname" => "ASC", "fname" => "ASC", "mname" => "ASC"));
64 $results = $this->_em->getRepository($this->_entityName)->matching($criteria);
65 return $results;