vendor/pimcore/pimcore/models/Asset/Listing.php line 37

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Model\Asset;
  15. use Pimcore\Model;
  16. use Pimcore\Model\Paginator\PaginateListingInterface;
  17. /**
  18.  * @method Model\Asset[] load()
  19.  * @method Model\Asset|false current()
  20.  * @method int getTotalCount()
  21.  * @method int getCount()
  22.  * @method int[] loadIdList()
  23.  * @method \Pimcore\Model\Asset\Listing\Dao getDao()
  24.  * @method onCreateQueryBuilder(?callable $callback)
  25.  */
  26. class Listing extends Model\Listing\AbstractListing implements PaginateListingInterface
  27. {
  28.     /**
  29.      * @return Model\Asset[]
  30.      */
  31.     public function getAssets()
  32.     {
  33.         return $this->getData();
  34.     }
  35.     /**
  36.      * @param Model\Asset[] $assets
  37.      *
  38.      * @return $this
  39.      */
  40.     public function setAssets($assets)
  41.     {
  42.         return $this->setData($assets);
  43.     }
  44.     /**
  45.      *
  46.      * Methods for AdapterInterface
  47.      */
  48.     /**
  49.      * @return int
  50.      */
  51.     #[\ReturnTypeWillChange]
  52.     public function count()// : int
  53.     {
  54.         return $this->getTotalCount();
  55.     }
  56.     /**
  57.      * @param int $offset
  58.      * @param int $itemCountPerPage
  59.      *
  60.      * @return Model\Asset[]
  61.      */
  62.     public function getItems($offset$itemCountPerPage)
  63.     {
  64.         $this->setOffset($offset);
  65.         $this->setLimit($itemCountPerPage);
  66.         return $this->load();
  67.     }
  68.     /**
  69.      * @internal
  70.      *
  71.      * @param Model\User $user
  72.      * @param Model\Asset $asset
  73.      *
  74.      * @return $this
  75.      */
  76.     public function filterAccessibleByUser(Model\User $userModel\Asset $asset)
  77.     {
  78.         if (!$user->isAdmin()) {
  79.             $userIds $user->getRoles();
  80.             $currentUserId $user->getId();
  81.             $userIds[] = $currentUserId;
  82.             $inheritedPermission $asset->getDao()->isInheritingPermission('list'$userIds);
  83.             $anyAllowedRowOrChildren 'EXISTS(SELECT list FROM users_workspaces_asset uwa WHERE userId IN (' implode(','$userIds) . ') AND list=1 AND LOCATE(CONCAT(path,filename),cpath)=1 AND
  84.             NOT EXISTS(SELECT list FROM users_workspaces_asset WHERE userId =' $currentUserId '  AND list=0 AND cpath = uwa.cpath))';
  85.             $isDisallowedCurrentRow 'EXISTS(SELECT list FROM users_workspaces_asset WHERE userId IN (' implode(','$userIds) . ')  AND cid = id AND list=0)';
  86.             $condition 'IF(' $anyAllowedRowOrChildren ',1,IF(' $inheritedPermission ', ' $isDisallowedCurrentRow ' = 0, 0)) = 1';
  87.             $this->addConditionParam($condition);
  88.         }
  89.         return $this;
  90.     }
  91. }