|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
ÁTICA - Aplicación web para la gestión documental de centros educativos |
|
4
|
|
|
|
|
5
|
|
|
Copyright (C) 2015-2017: Luis Ramón López López |
|
6
|
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU Affero General Public License as published by |
|
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU Affero General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
along with this program. If not, see [http://www.gnu.org/licenses/]. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppBundle\Repository\Documentation; |
|
22
|
|
|
|
|
23
|
|
|
use AppBundle\Entity\Documentation\FolderPermission; |
|
24
|
|
|
use AppBundle\Entity\Organization; |
|
25
|
|
|
use AppBundle\Entity\User; |
|
26
|
|
|
|
|
27
|
|
|
class FolderRepository extends \Gedmo\Tree\Entity\Repository\NestedTreeRepository |
|
28
|
|
|
{ |
|
29
|
|
|
public function getAccessDeniedFoldersForUserAndOrganizationArray(User $user, Organization $organization) |
|
30
|
|
|
{ |
|
31
|
|
|
$userProfiles = $this->getEntityManager()->getRepository('AppBundle:Element') |
|
32
|
|
|
->findAllProfilesByUserAndOrganization($user, $organization); |
|
33
|
|
|
|
|
34
|
|
|
$restrictedFolders = $this->getEntityManager()->createQuery(' |
|
35
|
|
|
SELECT f FROM AppBundle:Documentation\Folder f WHERE f NOT IN ( |
|
36
|
|
|
SELECT f2 FROM AppBundle:Documentation\Folder f2 JOIN AppBundle:Documentation\FolderPermission fp WITH fp.folder = f2 WHERE fp.permission = :permission AND fp.element IN (:elements) |
|
37
|
|
|
) AND f IN ( |
|
38
|
|
|
SELECT DISTINCT f3 FROM AppBundle:Documentation\Folder f3 JOIN AppBundle:Documentation\FolderPermission fp2 WITH fp2.folder = f3 WHERE fp2.permission = :permission |
|
39
|
|
|
) AND f.organization = :organization |
|
40
|
|
|
') |
|
41
|
|
|
->setParameter('permission', FolderPermission::PERMISSION_VISIBLE) |
|
42
|
|
|
->setParameter('elements', $userProfiles) |
|
43
|
|
|
->setParameter('organization', $organization) |
|
44
|
|
|
->getResult(); |
|
45
|
|
|
|
|
46
|
|
|
return $restrictedFolders; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|