Pimcore\Model\Object\AbstractObject\Dao::isAllowed PHP Метод

isAllowed() публичный Метод

public isAllowed ( $type, $user )
    public function isAllowed($type, $user)
    {
        $parentIds = $this->collectParentIds();
        $userIds = $user->getRoles();
        $userIds[] = $user->getId();
        try {
            $permissionsParent = $this->db->fetchOne("SELECT `" . $type . "` FROM users_workspaces_object WHERE cid IN (" . implode(",", $parentIds) . ") AND userId IN (" . implode(",", $userIds) . ") ORDER BY LENGTH(cpath) DESC, ABS(userId-" . $user->getId() . ") ASC LIMIT 1");
            if ($permissionsParent) {
                return true;
            }
            // exception for list permission
            if (empty($permissionsParent) && $type == "list") {
                // check for childs with permissions
                $path = $this->model->getRealFullPath() . "/";
                if ($this->model->getId() == 1) {
                    $path = "/";
                }
                $permissionsChilds = $this->db->fetchOne("SELECT list FROM users_workspaces_object WHERE cpath LIKE ? AND userId IN (" . implode(",", $userIds) . ") AND list = 1 LIMIT 1", $path . "%");
                if ($permissionsChilds) {
                    return true;
                }
            }
        } catch (\Exception $e) {
            Logger::warn("Unable to get permission " . $type . " for object " . $this->model->getId());
        }
        return false;
    }