[Xen-Soluce] Display Visitor Attachments

[Xen-Soluce] Display Visitor Attachments 2.1.0 Fix 2

No permission to download
Hi Cruel,

@CRUEL-MODZ :
I think I was not enough clear, sorry for that.
I do not use an addon article.

I am just talking about the Article forum type which is now native in Xenforo 2.2 :

If not enough clear I can PM you and explain in french... as I am french and you too 😂.
Please tell me and I will send you a link in order to help you to understand my issue.

Bonne journée
David
Hello,

Ah, okay sorry !
I'll watch this then lol

Regards, CRUEL-MODZ
 
@XenSoluce The solution seems simple - I commented out line 32: \XF::dump('dd');

PHP:
<?php
/*************************************************************************
 * Display Visitor Attachments - Xen-Soluce (c) 2019-2020
 * All Rights Reserved.
 * Created by SyTy and CRUEL-MODZ
 *************************************************************************
 * This file is subject to the terms and conditions defined in the Licence
 * Agreement available at https://xen-soluce.com/help/license-agreement/.
 *************************************************************************/

namespace XenSoluce\DisplayVisitorAttachments\XF\Attachment;

use XF\Entity\Attachment;
use XF\Mvc\Entity\Entity;

/**
 * Class Post
 * @package XenSoluce\DisplayVisitorAttachments\XF\Attachment
 */
class Post extends XFCP_Post
{
    /**
     * @param Attachment $attachment
     * @param Entity $container
     * @param null $error
     * @return bool
     */
    public function canView(Attachment $attachment, Entity $container, &$error = null)
    {
        $visitor = \XF::visitor();
        $options = \XF::options();
    /*    \XF::dump('dd'); */
        if($options->xs_dva_enable_thread['Enable'] && $Extension = $options->xs_dva_enable_thread['Extension'])
        {
            /** @var \XF\Entity\Post $container */
            if (!$container->canView())
            {
                return false;
            }
            if(!$visitor->user_id)
            {
                $extensions = preg_split('/\s+/', trim($Extension), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($extensions as $extension)
                {
                    if($extension == $attachment->getExtension())
                    {
                        return true;
                    }
                }

            }
            return parent::canView($attachment, $container, $error);
        }
        else
        {
            return parent::canView($attachment, $container, $error);
        }
    }
}
 
I use this because in an article node, the covers will only show in original quality, if attachments are allowed for guests. It seems that otherwise the thumbnail is used for the cover.

Sadly, the addon causes an issue with embedded mp3s (regular core option) - the posts with mp3s in them can't be edited, and there appear "dump-artefacts" above the breadcrumb. See here: https://xenforo.com/community/threads/sf-dump-artefacts-when-mp3s-embedded-in-forum-posts.207510/
@XenSoluce The solution seems simple - I commented out line 32: \XF::dump('dd');

PHP:
<?php
/*************************************************************************
 * Display Visitor Attachments - Xen-Soluce (c) 2019-2020
 * All Rights Reserved.
 * Created by SyTy and CRUEL-MODZ
 *************************************************************************
 * This file is subject to the terms and conditions defined in the Licence
 * Agreement available at https://xen-soluce.com/help/license-agreement/.
 *************************************************************************/

namespace XenSoluce\DisplayVisitorAttachments\XF\Attachment;

use XF\Entity\Attachment;
use XF\Mvc\Entity\Entity;

/**
 * Class Post
 * @package XenSoluce\DisplayVisitorAttachments\XF\Attachment
 */
class Post extends XFCP_Post
{
    /**
     * @param Attachment $attachment
     * @param Entity $container
     * @param null $error
     * @return bool
     */
    public function canView(Attachment $attachment, Entity $container, &$error = null)
    {
        $visitor = \XF::visitor();
        $options = \XF::options();
    /*    \XF::dump('dd'); */
        if($options->xs_dva_enable_thread['Enable'] && $Extension = $options->xs_dva_enable_thread['Extension'])
        {
            /** @var \XF\Entity\Post $container */
            if (!$container->canView())
            {
                return false;
            }
            if(!$visitor->user_id)
            {
                $extensions = preg_split('/\s+/', trim($Extension), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($extensions as $extension)
                {
                    if($extension == $attachment->getExtension())
                    {
                        return true;
                    }
                }

            }
            return parent::canView($attachment, $container, $error);
        }
        else
        {
            return parent::canView($attachment, $container, $error);
        }
    }
}
Hello, tagging @CRUEL-MODZ !
 
@XenSoluce The solution seems simple - I commented out line 32: \XF::dump('dd');

PHP:
<?php
/*************************************************************************
 * Display Visitor Attachments - Xen-Soluce (c) 2019-2020
 * All Rights Reserved.
 * Created by SyTy and CRUEL-MODZ
 *************************************************************************
 * This file is subject to the terms and conditions defined in the Licence
 * Agreement available at https://xen-soluce.com/help/license-agreement/.
 *************************************************************************/

namespace XenSoluce\DisplayVisitorAttachments\XF\Attachment;

use XF\Entity\Attachment;
use XF\Mvc\Entity\Entity;

/**
 * Class Post
 * @package XenSoluce\DisplayVisitorAttachments\XF\Attachment
 */
class Post extends XFCP_Post
{
    /**
     * @param Attachment $attachment
     * @param Entity $container
     * @param null $error
     * @return bool
     */
    public function canView(Attachment $attachment, Entity $container, &$error = null)
    {
        $visitor = \XF::visitor();
        $options = \XF::options();
    /*    \XF::dump('dd'); */
        if($options->xs_dva_enable_thread['Enable'] && $Extension = $options->xs_dva_enable_thread['Extension'])
        {
            /** @var \XF\Entity\Post $container */
            if (!$container->canView())
            {
                return false;
            }
            if(!$visitor->user_id)
            {
                $extensions = preg_split('/\s+/', trim($Extension), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($extensions as $extension)
                {
                    if($extension == $attachment->getExtension())
                    {
                        return true;
                    }
                }

            }
            return parent::canView($attachment, $container, $error);
        }
        else
        {
            return parent::canView($attachment, $container, $error);
        }
    }
}
Hey, sorry for the delay ! Fixed if you want 👍

Regards, SyTry
 
Top Bottom