What's new
Xen Factory

Register today to become a member! Once signed in, you'll be able to start purchasing our products, ask questions, request support and suggest new ideas!

  • We are aware that a no permission error was shown when you tried to purchase in the last 2 days, this is now fixed.

Bug Cannot Reproduce No permission error on my forum after upgrade

trakiss

New Member
Hi,

After an upgrade on the latest versions of Xenforo (2.1.2 to 2.1.3) + Ressource Manager (2.1.2 to 2.1.3) + RM Marketplace (4.2.1) + [XFA] Core (1.6.0), we have a "No permission for download" message when trying to download a ressource.

After a check of every permissions, we didn't found anything to fix this. Users seem to have the correct permissions ... Same problem with administrator (they have all permissions to yes)
I see in your announcement you just have the same problem on this forum.

So .. how fix this ? :)

Cordially
 

trakiss

New Member
After more investigation, the problem is with the "Download without buying".

If this permission is set to FALSE, users can't download (even on free ressources).
This behavior is really strange, it's "normal" ? :/
 

trakiss

New Member
I think the problem is in method canDownload() on ResourceItem entity.

I have added a check in the method:

Code:
        if (!$this->isForSaleInMarketplace()) {
            return true;
        }

Full method:

Code:
    public function canDownload(&$error = null)
    {
        $visitor = \XF::visitor();

        $canDownload = parent::canDownload($error);

        /* Default rights not met */
        if (!$canDownload)
        {
            return false;
        }

        if (!$this->isForSaleInMarketplace()) {
            return true;
        }

        /* If user is author or user can download without buying download is authorized */
        if ($this->Category->canDownloadWithoutBuying($error)
            || ($visitor->user_id && $this->user_id == $visitor->user_id))
        {
            return true;
        }

        /* Check if valid license */
        if ($this->xfa_rmmp_type == 'digital' && !$this->DigitalProduct->hasValidLicense())
        {
            return false;
        }

        return true;
    }

EDIT:
Same problem on ResourceVersion entity. Same fix :

Code:
public function canDownload(&$error = null)
    {
        $resource = $this->Resource;

        if (!$resource)
        {
            return false;
        }

        /* If resource owner, download allowed */
        if ($resource->user_id == \XF::visitor()->user_id)
        {
            return true;
        }

        if (!$resource->isForSaleInMarketplace()) {
            return true;
        }

        /* If resource is digital, check dedicated rights */
        if ($resource->xfa_rmmp_type == 'digital')
        {
            if (isset($GLOBALS['xfa_rmmp_dl_authorized']) && $GLOBALS['xfa_rmmp_dl_authorized'])
            {
                return true;
            }

            return false;
        }

        return parent::canDownload($error);
    }

@MtoR what did you think about this fix ?
 
Last edited:

Clement

Freaky Coder
Staff member
Not sure to get the initial issue.

It's users without permission to download that try to download free resources ?
 
Top