]> BookStack Code Mirror - bookstack/blob - app/Services/PermissionService.php
#47 - Fixes the issues with the test case.
[bookstack] / app / Services / PermissionService.php
1 <?php namespace BookStack\Services;
2
3 use BookStack\Book;
4 use BookStack\Chapter;
5 use BookStack\Entity;
6 use BookStack\EntityPermission;
7 use BookStack\JointPermission;
8 use BookStack\Ownable;
9 use BookStack\Page;
10 use BookStack\Role;
11 use BookStack\User;
12 use Illuminate\Database\Connection;
13 use Illuminate\Database\Eloquent\Builder;
14 use Illuminate\Database\Query\Builder as QueryBuilder;
15 use Illuminate\Support\Collection;
16
17 class PermissionService
18 {
19
20     protected $currentAction;
21     protected $isAdminUser;
22     protected $userRoles = false;
23     protected $currentUserModel = false;
24
25     public $book;
26     public $chapter;
27     public $page;
28
29     protected $db;
30
31     protected $jointPermission;
32     protected $role;
33     protected $entityPermission;
34
35     protected $entityCache;
36
37     /**
38      * PermissionService constructor.
39      * @param JointPermission $jointPermission
40      * @param EntityPermission $entityPermission
41      * @param Connection $db
42      * @param Book $book
43      * @param Chapter $chapter
44      * @param Page $page
45      * @param Role $role
46      */
47     public function __construct(JointPermission $jointPermission, EntityPermission $entityPermission, Connection $db, Book $book, Chapter $chapter, Page $page, Role $role)
48     {
49         $this->db = $db;
50         $this->jointPermission = $jointPermission;
51         $this->entityPermission = $entityPermission;
52         $this->role = $role;
53         $this->book = $book;
54         $this->chapter = $chapter;
55         $this->page = $page;
56         // TODO - Update so admin still goes through filters
57     }
58
59     /**
60      * Set the database connection
61      * @param Connection $connection
62      */
63     public function setConnection(Connection $connection)
64     {
65         $this->db = $connection;
66     }
67
68     /**
69      * Prepare the local entity cache and ensure it's empty
70      */
71     protected function readyEntityCache()
72     {
73         $this->entityCache = [
74             'books' => collect(),
75             'chapters' => collect()
76         ];
77     }
78
79     /**
80      * Get a book via ID, Checks local cache
81      * @param $bookId
82      * @return Book
83      */
84     protected function getBook($bookId)
85     {
86         if (isset($this->entityCache['books']) && $this->entityCache['books']->has($bookId)) {
87             return $this->entityCache['books']->get($bookId);
88         }
89
90         $book = $this->book->find($bookId);
91         if ($book === null) $book = false;
92         if (isset($this->entityCache['books'])) {
93             $this->entityCache['books']->put($bookId, $book);
94         }
95
96         return $book;
97     }
98
99     /**
100      * Get a chapter via ID, Checks local cache
101      * @param $chapterId
102      * @return Book
103      */
104     protected function getChapter($chapterId)
105     {
106         if (isset($this->entityCache['chapters']) && $this->entityCache['chapters']->has($chapterId)) {
107             return $this->entityCache['chapters']->get($chapterId);
108         }
109
110         $chapter = $this->chapter->find($chapterId);
111         if ($chapter === null) $chapter = false;
112         if (isset($this->entityCache['chapters'])) {
113             $this->entityCache['chapters']->put($chapterId, $chapter);
114         }
115
116         return $chapter;
117     }
118
119     /**
120      * Get the roles for the current user;
121      * @return array|bool
122      */
123     protected function getRoles()
124     {
125         if ($this->userRoles !== false) return $this->userRoles;
126
127         $roles = [];
128
129         if (auth()->guest()) {
130             $roles[] = $this->role->getSystemRole('public')->id;
131             return $roles;
132         }
133
134
135         foreach ($this->currentUser()->roles as $role) {
136             $roles[] = $role->id;
137         }
138         return $roles;
139     }
140
141     /**
142      * Re-generate all entity permission from scratch.
143      */
144     public function buildJointPermissions()
145     {
146         $this->jointPermission->truncate();
147         $this->readyEntityCache();
148
149         // Get all roles (Should be the most limited dimension)
150         $roles = $this->role->with('permissions')->get()->all();
151
152         // Chunk through all books
153         $this->bookFetchQuery()->chunk(5, function ($books) use ($roles) {
154             $this->buildJointPermissionsForBooks($books, $roles);
155         });
156     }
157
158     /**
159      * Get a query for fetching a book with it's children.
160      * @return QueryBuilder
161      */
162     protected function bookFetchQuery()
163     {
164         return $this->book->newQuery()->select(['id', 'restricted', 'created_by'])->with(['chapters' => function($query) {
165             $query->select(['id', 'restricted', 'created_by', 'book_id']);
166         }, 'pages'  => function($query) {
167             $query->select(['id', 'restricted', 'created_by', 'book_id', 'chapter_id']);
168         }]);
169     }
170
171     /**
172      * Build joint permissions for an array of books
173      * @param Collection $books
174      * @param array $roles
175      * @param bool $deleteOld
176      */
177     protected function buildJointPermissionsForBooks($books, $roles, $deleteOld = false) {
178         $entities = clone $books;
179
180         /** @var Book $book */
181         foreach ($books->all() as $book) {
182             foreach ($book->getRelation('chapters') as $chapter) {
183                 $entities->push($chapter);
184             }
185             foreach ($book->getRelation('pages') as $page) {
186                 $entities->push($page);
187             }
188         }
189
190         if ($deleteOld) $this->deleteManyJointPermissionsForEntities($entities->all());
191         $this->createManyJointPermissions($entities, $roles);
192     }
193
194     /**
195      * Rebuild the entity jointPermissions for a particular entity.
196      * @param Entity $entity
197      */
198     public function buildJointPermissionsForEntity(Entity $entity)
199     {
200         $entities = [$entity];
201         if ($entity->isA('book')) {
202             $books = $this->bookFetchQuery()->where('id', '=', $entity->id)->get();
203             $this->buildJointPermissionsForBooks($books, $this->role->newQuery()->get(), true);
204             return;
205         }
206
207         $entities[] = $entity->book;
208         if ($entity->isA('page') && $entity->chapter_id) $entities[] = $entity->chapter;
209         if ($entity->isA('chapter')) {
210             foreach ($entity->pages as $page) {
211                 $entities[] = $page;
212             }
213         }
214         $this->deleteManyJointPermissionsForEntities($entities);
215         $this->buildJointPermissionsForEntities(collect($entities));
216     }
217
218     /**
219      * Rebuild the entity jointPermissions for a collection of entities.
220      * @param Collection $entities
221      */
222     public function buildJointPermissionsForEntities(Collection $entities)
223     {
224         $roles = $this->role->newQuery()->get();
225         $this->deleteManyJointPermissionsForEntities($entities->all());
226         $this->createManyJointPermissions($entities, $roles);
227     }
228
229     /**
230      * Build the entity jointPermissions for a particular role.
231      * @param Role $role
232      */
233     public function buildJointPermissionForRole(Role $role)
234     {
235         $roles = [$role];
236         $this->deleteManyJointPermissionsForRoles($roles);
237
238         // Chunk through all books
239         $this->bookFetchQuery()->chunk(5, function ($books) use ($roles) {
240             $this->buildJointPermissionsForBooks($books, $roles);
241         });
242     }
243
244     /**
245      * Delete the entity jointPermissions attached to a particular role.
246      * @param Role $role
247      */
248     public function deleteJointPermissionsForRole(Role $role)
249     {
250         $this->deleteManyJointPermissionsForRoles([$role]);
251     }
252
253     /**
254      * Delete all of the entity jointPermissions for a list of entities.
255      * @param Role[] $roles
256      */
257     protected function deleteManyJointPermissionsForRoles($roles)
258     {
259         $roleIds = array_map(function($role) {
260             return $role->id;
261         }, $roles);
262         $this->jointPermission->newQuery()->whereIn('id', $roleIds)->delete();
263     }
264
265     /**
266      * Delete the entity jointPermissions for a particular entity.
267      * @param Entity $entity
268      */
269     public function deleteJointPermissionsForEntity(Entity $entity)
270     {
271         $this->deleteManyJointPermissionsForEntities([$entity]);
272     }
273
274     /**
275      * Delete all of the entity jointPermissions for a list of entities.
276      * @param Entity[] $entities
277      */
278     protected function deleteManyJointPermissionsForEntities($entities)
279     {
280         if (count($entities) === 0) return;
281
282         $this->db->transaction(function() use ($entities) {
283
284             foreach (array_chunk($entities, 1000) as $entityChunk) {
285                 $query = $this->db->table('joint_permissions');
286                 foreach ($entityChunk as $entity) {
287                     $query->orWhere(function(QueryBuilder $query) use ($entity) {
288                         $query->where('entity_id', '=', $entity->id)
289                             ->where('entity_type', '=', $entity->getMorphClass());
290                     });
291                 }
292                 $query->delete();
293             }
294
295         });
296     }
297
298     /**
299      * Create & Save entity jointPermissions for many entities and jointPermissions.
300      * @param Collection $entities
301      * @param array $roles
302      */
303     protected function createManyJointPermissions($entities, $roles)
304     {
305         $this->readyEntityCache();
306         $jointPermissions = [];
307
308         // Fetch Entity Permissions and create a mapping of entity restricted statuses
309         $entityRestrictedMap = [];
310         $permissionFetch = $this->entityPermission->newQuery();
311         foreach ($entities as $entity) {
312             $entityRestrictedMap[$entity->getMorphClass() . ':' . $entity->id] = boolval($entity->getRawAttribute('restricted'));
313             $permissionFetch->orWhere(function($query) use ($entity) {
314                 $query->where('restrictable_id', '=', $entity->id)->where('restrictable_type', '=', $entity->getMorphClass());
315             });
316         }
317         $permissions = $permissionFetch->get();
318
319         // Create a mapping of explicit entity permissions
320         $permissionMap = [];
321         foreach ($permissions as $permission) {
322             $key = $permission->restrictable_type . ':' . $permission->restrictable_id . ':' . $permission->role_id . ':' . $permission->action;
323             $isRestricted = $entityRestrictedMap[$permission->restrictable_type . ':' . $permission->restrictable_id];
324             $permissionMap[$key] = $isRestricted;
325         }
326
327         // Create a mapping of role permissions
328         $rolePermissionMap = [];
329         foreach ($roles as $role) {
330             foreach ($role->getRelationValue('permissions') as $permission) {
331                 $rolePermissionMap[$role->getRawAttribute('id') . ':' . $permission->getRawAttribute('name')] = true;
332             }
333         }
334
335         // Create Joint Permission Data
336         foreach ($entities as $entity) {
337             foreach ($roles as $role) {
338                 foreach ($this->getActions($entity) as $action) {
339                     $jointPermissions[] = $this->createJointPermissionData($entity, $role, $action, $permissionMap, $rolePermissionMap);
340                 }
341             }
342         }
343
344         $this->db->transaction(function() use ($jointPermissions) {
345             foreach (array_chunk($jointPermissions, 1000) as $jointPermissionChunk) {
346                 $this->db->table('joint_permissions')->insert($jointPermissionChunk);
347             }
348         });
349     }
350
351
352     /**
353      * Get the actions related to an entity.
354      * @param Entity $entity
355      * @return array
356      */
357     protected function getActions(Entity $entity)
358     {
359         $baseActions = ['view', 'update', 'delete'];
360         if ($entity->isA('chapter') || $entity->isA('book')) $baseActions[] = 'page-create';
361         if ($entity->isA('book')) $baseActions[] = 'chapter-create';
362         return $baseActions;
363     }
364
365     /**
366      * Create entity permission data for an entity and role
367      * for a particular action.
368      * @param Entity $entity
369      * @param Role $role
370      * @param string $action
371      * @param array $permissionMap
372      * @param array $rolePermissionMap
373      * @return array
374      */
375     protected function createJointPermissionData(Entity $entity, Role $role, $action, $permissionMap, $rolePermissionMap)
376     {
377         $permissionPrefix = (strpos($action, '-') === false ? ($entity->getType() . '-') : '') . $action;
378         $roleHasPermission = isset($rolePermissionMap[$role->getRawAttribute('id') . ':' . $permissionPrefix . '-all']);
379         $roleHasPermissionOwn = isset($rolePermissionMap[$role->getRawAttribute('id') . ':' . $permissionPrefix . '-own']);
380         $explodedAction = explode('-', $action);
381         $restrictionAction = end($explodedAction);
382
383         if ($role->system_name === 'admin') {
384             return $this->createJointPermissionDataArray($entity, $role, $action, true, true);
385         }
386
387         if ($entity->restricted) {
388             $hasAccess = $this->mapHasActiveRestriction($permissionMap, $entity, $role, $restrictionAction);
389             return $this->createJointPermissionDataArray($entity, $role, $action, $hasAccess, $hasAccess);
390         }
391
392         if ($entity->isA('book')) {
393             return $this->createJointPermissionDataArray($entity, $role, $action, $roleHasPermission, $roleHasPermissionOwn);
394         }
395
396         // For chapters and pages, Check if explicit permissions are set on the Book.
397         $book = $this->getBook($entity->book_id);
398         $hasExplicitAccessToParents = $this->mapHasActiveRestriction($permissionMap, $book, $role, $restrictionAction);
399         $hasPermissiveAccessToParents = !$book->restricted;
400
401         // For pages with a chapter, Check if explicit permissions are set on the Chapter
402         if ($entity->isA('page') && $entity->chapter_id !== 0 && $entity->chapter_id !== '0') {
403             $chapter = $this->getChapter($entity->chapter_id);
404             $hasPermissiveAccessToParents = $hasPermissiveAccessToParents && !$chapter->restricted;
405             if ($chapter->restricted) {
406                 $hasExplicitAccessToParents = $this->mapHasActiveRestriction($permissionMap, $chapter, $role, $restrictionAction);
407             }
408         }
409
410         return $this->createJointPermissionDataArray($entity, $role, $action,
411             ($hasExplicitAccessToParents || ($roleHasPermission && $hasPermissiveAccessToParents)),
412             ($hasExplicitAccessToParents || ($roleHasPermissionOwn && $hasPermissiveAccessToParents))
413         );
414     }
415
416     /**
417      * Check for an active restriction in an entity map.
418      * @param $entityMap
419      * @param Entity $entity
420      * @param Role $role
421      * @param $action
422      * @return bool
423      */
424     protected function mapHasActiveRestriction($entityMap, Entity $entity, Role $role, $action) {
425         $key = $entity->getMorphClass() . ':' . $entity->getRawAttribute('id') . ':' . $role->getRawAttribute('id') . ':' . $action;
426         return isset($entityMap[$key]) ? $entityMap[$key] : false;
427     }
428
429     /**
430      * Create an array of data with the information of an entity jointPermissions.
431      * Used to build data for bulk insertion.
432      * @param Entity $entity
433      * @param Role $role
434      * @param $action
435      * @param $permissionAll
436      * @param $permissionOwn
437      * @return array
438      */
439     protected function createJointPermissionDataArray(Entity $entity, Role $role, $action, $permissionAll, $permissionOwn)
440     {
441         return [
442             'role_id'            => $role->getRawAttribute('id'),
443             'entity_id'          => $entity->getRawAttribute('id'),
444             'entity_type'        => $entity->getMorphClass(),
445             'action'             => $action,
446             'has_permission'     => $permissionAll,
447             'has_permission_own' => $permissionOwn,
448             'created_by'         => $entity->getRawAttribute('created_by')
449         ];
450     }
451
452     /**
453      * Checks if an entity has a restriction set upon it.
454      * @param Ownable $ownable
455      * @param $permission
456      * @return bool
457      */
458     public function checkOwnableUserAccess(Ownable $ownable, $permission)
459     {
460         if ($this->isAdmin()) {
461             $this->clean();
462             return true;
463         }
464
465         $explodedPermission = explode('-', $permission);
466
467         $baseQuery = $ownable->where('id', '=', $ownable->id);
468         $action = end($explodedPermission);
469         $this->currentAction = $action;
470
471         $nonJointPermissions = ['restrictions', 'image', 'attachment', 'comment'];
472
473         // Handle non entity specific jointPermissions
474         if (in_array($explodedPermission[0], $nonJointPermissions)) {
475             $allPermission = $this->currentUser() && $this->currentUser()->can($permission . '-all');
476             $ownPermission = $this->currentUser() && $this->currentUser()->can($permission . '-own');
477             $this->currentAction = 'view';
478             $isOwner = $this->currentUser() && $this->currentUser()->id === $ownable->created_by;
479             return ($allPermission || ($isOwner && $ownPermission));
480         }
481
482         // Handle abnormal create jointPermissions
483         if ($action === 'create') {
484             $this->currentAction = $permission;
485         }
486
487         $q = $this->entityRestrictionQuery($baseQuery)->count() > 0;
488         $this->clean();
489         return $q;
490     }
491
492     /**
493      * Check if an entity has restrictions set on itself or its
494      * parent tree.
495      * @param Entity $entity
496      * @param $action
497      * @return bool|mixed
498      */
499     public function checkIfRestrictionsSet(Entity $entity, $action)
500     {
501         $this->currentAction = $action;
502         if ($entity->isA('page')) {
503             return $entity->restricted || ($entity->chapter && $entity->chapter->restricted) || $entity->book->restricted;
504         } elseif ($entity->isA('chapter')) {
505             return $entity->restricted || $entity->book->restricted;
506         } elseif ($entity->isA('book')) {
507             return $entity->restricted;
508         }
509     }
510
511     /**
512      * The general query filter to remove all entities
513      * that the current user does not have access to.
514      * @param $query
515      * @return mixed
516      */
517     protected function entityRestrictionQuery($query)
518     {
519         $q = $query->where(function ($parentQuery) {
520             $parentQuery->whereHas('jointPermissions', function ($permissionQuery) {
521                 $permissionQuery->whereIn('role_id', $this->getRoles())
522                     ->where('action', '=', $this->currentAction)
523                     ->where(function ($query) {
524                         $query->where('has_permission', '=', true)
525                             ->orWhere(function ($query) {
526                                 $query->where('has_permission_own', '=', true)
527                                     ->where('created_by', '=', $this->currentUser()->id);
528                             });
529                     });
530             });
531         });
532         $this->clean();
533         return $q;
534     }
535
536     /**
537      * Get the children of a book in an efficient single query, Filtered by the permission system.
538      * @param integer $book_id
539      * @param bool $filterDrafts
540      * @param bool $fetchPageContent
541      * @return QueryBuilder
542      */
543     public function bookChildrenQuery($book_id, $filterDrafts = false, $fetchPageContent = false) {
544         $pageSelect = $this->db->table('pages')->selectRaw($this->page->entityRawQuery($fetchPageContent))->where('book_id', '=', $book_id)->where(function($query) use ($filterDrafts) {
545             $query->where('draft', '=', 0);
546             if (!$filterDrafts) {
547                 $query->orWhere(function($query) {
548                     $query->where('draft', '=', 1)->where('created_by', '=', $this->currentUser()->id);
549                 });
550             }
551         });
552         $chapterSelect = $this->db->table('chapters')->selectRaw($this->chapter->entityRawQuery())->where('book_id', '=', $book_id);
553         $query = $this->db->query()->select('*')->from($this->db->raw("({$pageSelect->toSql()} UNION {$chapterSelect->toSql()}) AS U"))
554             ->mergeBindings($pageSelect)->mergeBindings($chapterSelect);
555
556         if (!$this->isAdmin()) {
557             $whereQuery = $this->db->table('joint_permissions as jp')->selectRaw('COUNT(*)')
558                 ->whereRaw('jp.entity_id=U.id')->whereRaw('jp.entity_type=U.entity_type')
559                 ->where('jp.action', '=', 'view')->whereIn('jp.role_id', $this->getRoles())
560                 ->where(function($query) {
561                     $query->where('jp.has_permission', '=', 1)->orWhere(function($query) {
562                         $query->where('jp.has_permission_own', '=', 1)->where('jp.created_by', '=', $this->currentUser()->id);
563                     });
564                 });
565             $query->whereRaw("({$whereQuery->toSql()}) > 0")->mergeBindings($whereQuery);
566         }
567
568         $query->orderBy('draft', 'desc')->orderBy('priority', 'asc');
569         $this->clean();
570         return  $query;
571     }
572
573     /**
574      * Add restrictions for a generic entity
575      * @param string $entityType
576      * @param Builder|Entity $query
577      * @param string $action
578      * @return Builder
579      */
580     public function enforceEntityRestrictions($entityType, $query, $action = 'view')
581     {
582         if (strtolower($entityType) === 'page') {
583             // Prevent drafts being visible to others.
584             $query = $query->where(function ($query) {
585                 $query->where('draft', '=', false);
586                 if ($this->currentUser()) {
587                     $query->orWhere(function ($query) {
588                         $query->where('draft', '=', true)->where('created_by', '=', $this->currentUser()->id);
589                     });
590                 }
591             });
592         }
593
594         if ($this->isAdmin()) {
595             $this->clean();
596             return $query;
597         }
598
599         $this->currentAction = $action;
600         return $this->entityRestrictionQuery($query);
601     }
602
603     /**
604      * Filter items that have entities set as a polymorphic relation.
605      * @param $query
606      * @param string $tableName
607      * @param string $entityIdColumn
608      * @param string $entityTypeColumn
609      * @return mixed
610      */
611     public function filterRestrictedEntityRelations($query, $tableName, $entityIdColumn, $entityTypeColumn)
612     {
613         if ($this->isAdmin()) {
614             $this->clean();
615             return $query;
616         }
617
618         $this->currentAction = 'view';
619         $tableDetails = ['tableName' => $tableName, 'entityIdColumn' => $entityIdColumn, 'entityTypeColumn' => $entityTypeColumn];
620
621         $q = $query->where(function ($query) use ($tableDetails) {
622             $query->whereExists(function ($permissionQuery) use (&$tableDetails) {
623                 $permissionQuery->select('id')->from('joint_permissions')
624                     ->whereRaw('joint_permissions.entity_id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
625                     ->whereRaw('joint_permissions.entity_type=' . $tableDetails['tableName'] . '.' . $tableDetails['entityTypeColumn'])
626                     ->where('action', '=', $this->currentAction)
627                     ->whereIn('role_id', $this->getRoles())
628                     ->where(function ($query) {
629                         $query->where('has_permission', '=', true)->orWhere(function ($query) {
630                             $query->where('has_permission_own', '=', true)
631                                 ->where('created_by', '=', $this->currentUser()->id);
632                         });
633                     });
634             });
635         });
636         $this->clean();
637         return $q;
638     }
639
640     /**
641      * Filters pages that are a direct relation to another item.
642      * @param $query
643      * @param $tableName
644      * @param $entityIdColumn
645      * @return mixed
646      */
647     public function filterRelatedPages($query, $tableName, $entityIdColumn)
648     {
649         if ($this->isAdmin()) {
650             $this->clean();
651             return $query;
652         }
653
654         $this->currentAction = 'view';
655         $tableDetails = ['tableName' => $tableName, 'entityIdColumn' => $entityIdColumn];
656
657         $q = $query->where(function ($query) use ($tableDetails) {
658             $query->where(function ($query) use (&$tableDetails) {
659                 $query->whereExists(function ($permissionQuery) use (&$tableDetails) {
660                     $permissionQuery->select('id')->from('joint_permissions')
661                         ->whereRaw('joint_permissions.entity_id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
662                         ->where('entity_type', '=', 'Bookstack\\Page')
663                         ->where('action', '=', $this->currentAction)
664                         ->whereIn('role_id', $this->getRoles())
665                         ->where(function ($query) {
666                             $query->where('has_permission', '=', true)->orWhere(function ($query) {
667                                 $query->where('has_permission_own', '=', true)
668                                     ->where('created_by', '=', $this->currentUser()->id);
669                             });
670                         });
671                 });
672             })->orWhere($tableDetails['entityIdColumn'], '=', 0);
673         });
674         $this->clean();
675         return $q;
676     }
677
678     /**
679      * Check if the current user is an admin.
680      * @return bool
681      */
682     private function isAdmin()
683     {
684         if ($this->isAdminUser === null) {
685             $this->isAdminUser = ($this->currentUser()->id !== null) ? $this->currentUser()->hasSystemRole('admin') : false;
686         }
687
688         return $this->isAdminUser;
689     }
690
691     /**
692      * Get the current user
693      * @return User
694      */
695     private function currentUser()
696     {
697         if ($this->currentUserModel === false) {
698             $this->currentUserModel = user();
699         }
700
701         return $this->currentUserModel;
702     }
703
704     /**
705      * Clean the cached user elements.
706      */
707     private function clean()
708     {
709         $this->currentUserModel = false;
710         $this->userRoles = false;
711         $this->isAdminUser = null;
712     }
713
714 }