<![CDATA[ how to set public read access for attachments - My Forums]]> https://forums.modx.com/thread/?thread=98881 <![CDATA[how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments?page=2#dis-post-534677 i'm new to modx.
I want to change the read permission of attachments --> public read access.
How is it possible to change the permission set of anonymous group?

]]>
[email protected] Nov 23, 2015, 04:51 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments?page=2#dis-post-534677
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments?page=2#dis-post-534889
Ah, those social buttons, hold on haha]]>
nuan88 Nov 27, 2015, 05:00 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments?page=2#dis-post-534889
<![CDATA[Re: how to set public read access for attachments (Best Answer)]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534888 thx again for your investigation.
I've solved my problem without code changes. smiley

I now know how to add a permission set to a user group.
That's the solution.

Access Control List ( you will find it down below your settings drop down)

  • User Groups
  • Roles
  • Access policies
  • Policy Templates
Access Policies -> define new policy based on the discuss member policy ( here you will find the attachment_read...)
named it Discuss Visitor policy, change back to groups -> update anonymous -> select context -> add new context (see attachement)
I did not know that it is possible to add the same context twice with different access rights.
ok once again, thx
Where have you posted the "social" stuff smiley ..]]>
[email protected] Nov 27, 2015, 04:46 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534888
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534887
core/components/discuss/hooks/post/getthread.php

From line 71:
/* setup basic settings/permissions */
$dateFormat = $modx->getOption('discuss.date_format',null,'%b %d, %Y, %H:%M %p');
$allowCustomTitles = $modx->getOption('discuss.allow_custom_titles',null,true);
$maxPostDepth = $modx->getOption('discuss.max_post_depth',null,3);

$canViewAttachments = $modx->hasPermission('discuss.view_attachments');
$canTrackIp = $discuss->user->isLoggedIn && $modx->hasPermission('discuss.track_ip');
$canViewEmails = $discuss->user->isLoggedIn && $modx->hasPermission('discuss.view_emails');
$canViewProfiles = $discuss->user->isLoggedIn && $modx->hasPermission('discuss.view_profiles');
$canReportPost = $discuss->user->isLoggedIn && $modx->hasPermission('discuss.thread_report');
$canMarkAsAnswer = $thread->get('class_key') == 'disThreadQuestion' && $thread->canMarkAsAnswer();


I notice it doesn't say logged in, as I thought, but rather only hasPermission...but I am not sure how to modify this...]]>
nuan88 Nov 27, 2015, 04:09 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534887
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534886
Here is the relevant part of the document, but I don't clearly see any check:
class DiscussAttachmentDownloadController extends DiscussController {
    public function getPageTitle() {

    }
    public function getSessionPlace() {
        return 'attachment/download:file='.$this->getProperty('file','');
    }

    public function process() {
        $file = $this->getProperty('file',false);
        /* get attachment */
]]>
nuan88 Nov 27, 2015, 03:54 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534886
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534885

We can solve this finally, with Modx there is always a way, and probably three haha

For social buttons, I will make a new post and put my code. Just to keep things organized.

For permissions and groups, this is not my area, you may finally need to make another post in the general part of this forum for a question about why you can't add a policy to the anonymous group. Perhaps we can explore this here for now and see if that's useful or not. I am not sure one way or another if it is a good way. Discuss it seems to me is going to ask the question, is the user logged in, rather than, what group the user is in...

I am not a developer, but love to dig into this stuff, could you tell me where I could see ACL->discuss->discuss.view_attachments? I am not sure where to look for it.

Also I have some suggestions for files to look at, will post them next.]]>
nuan88 Nov 27, 2015, 03:50 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534885
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534882 Is it possible to show me how you have done this?

thx]]>
[email protected] Nov 27, 2015, 02:40 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534882
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534881 thx a lot for your investigation.
yes i'm able to modify the files, i'm looking forward ..
i will checvk the this weekend.
By the way, is there are possibility to change the access role of the anonimous group?
I found the ACL->discuss->discuss.view_attachments
I was able to define a new policies, but i'm not able to add this policy to the anonimous group?
looking forward to your results, thx a lot again


]]>
[email protected] Nov 27, 2015, 02:34 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534881
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534880
When I drill down into the code I get to this part:

<div class="dis-content">
[[+content]]
[[+discuss.user.shouldMarkAnAnswer:eq=`1`:then=`
[[+idx:eq=`1`:then=`
<div class="dis-info"><p>[[%discuss.mark_answer_instructions]] <a id="Show-answer-link" href="#">[[%discuss.mark_answer_link]]</a></p></div>
`:else=``]]
`:else=``]]
[[+idx:eq=`1`:then=`
[[+answer_count:neq=`0`:then=`
<div class="dis-info"><p>[[+jump_to_first_answer.explanation]] [[+jump_to_first_answer.link]]</p></div>
`:else=``]]
`:else=``]]
[[+attachments:notempty=`<div class="dis-post-attachments"><ul class="dis-attachments">[[+attachments]]</ul></div>`]]
[[+editedby:is=`0`:then=``:else=`<span class="dis-post-editedon">[[%discuss.editedon_post? &on=`[[+editedon:ago]]` &user=`[[+editedby.username]]`]]</span>`]]
</div>

The content is visible to the public, so the check for logged in users must happen later. Then we have code related to checking one post as the answer to a question thread, an important feature of discuss (which I don't use, though).

The user.shouldMarkAnAnswer stuff seems to be whether the thread author has chosen an answer, but it seems to close. And I don't quite understand +idx:eq='1', is it a check of logged in user? There are two levels to this as well. Or more...

But, it seems to me that all that stuff ends, and we get +attachments:notempty, with no check. Damn. Maybe I am wrong, if not, then its into the deeper files to find div class and ul class "dis-post-attachment", I guess.

Ok, I looked into stuff and just confused myself more, I am taking a break. I was going to write more but right now I have no clue. This isn't that hard, I am sure, but right now I am bolloxed...


]]>
nuan88 Nov 27, 2015, 02:08 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534880
<![CDATA[Re: how to set public read access for attachments]]> https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534875
This file in my install is full of stuff, so I will grab what I assume is the default file from the original package. Our job is to find where the check is on whether the user is logged in or not, to be honest I am having a bit of trouble to find it quickly:

<li class="[[+class]] group-fix" id="dis-post-[[+id]]" data-author="[[+author.username:htmlent]]" data-date="[[+createdon_raw]]" data-message="[[+content_raw]]">
    [[+answer:neq=``:then=`
    <div class="dis-post-answer-marker">
        [[+answer_count:gt=`1`:then=`
            <nav>
            [[+answer_prev.link]]
            [[+answer_next.link]]
            </nav>
        `:else=``]]

        [[+url_mark_as_answer:eq=``:then=`
            <span title="[[%discuss.answer]]">[[%discuss.answer]]</span>
        `:else=`
        <a href="[[+url_mark_as_answer]]">
            <span title="[[%discuss.unflag_answer]]">[[%discuss.unflag_answer]]</span>
        </a>
        `]]
    </div>
    `:else=`
        <div class="dis-post-answer-marker dis-post-notanswer">
            [[+url_mark_as_answer:eq=``:then=``:else=`
            <div class="dis-post-answer-marker dis-post-notanswer">
                <p>[[%discuss.flag_answer]]</p>
                <a href="[[+url_mark_as_answer]]">
                    <span>[[%discuss.flag_answer]]</span>
                </a>
            </div>
            `]]
        </div>
    `]]
    <!-- mark answer-->
    <div class="dis-post-left">
        <ul>
            <li class="dis-usr-icon">
                <a href="[[DiscussUrlMaker? &action=`user` ¶ms=`{"type":"username", "user":"[[+author.username]]"}`]]" class="auth-avatar" title="[[%discuss.view_author_profile]]">
                    [[+author.avatar]]
                    [[+author.title:notempty=`<span class="dis-usr-title">[[+author.title]]</span>`]]
                </a>
            </li>
            <li class="dis-usr-post-count">[[+author.posts]] [[%discuss.posts]]</li>
            <a href="[[DiscussUrlMaker? &action=`messages/new` ¶ms=`{"user":"[[+author.username]]"}`]]" class="dis-pm-btn">Send PM</a>
        </ul>
    </div>
    <div class="dis-post-right">
        <div class="title">
            <strong>[[+author.username_link]]</strong> <a class="normal-type" href="[[+url]]" title="[[%discuss.post_link]]">Reply #[[+idx]], <span title="[[+createdon]]">[[+createdon:ago]]</span></a>
            [[+action_modify:notempty=`<ul class="dis-content-actions">[[+action_modify]][[+action_remove]][[+action_spam]]</ul>`]]
        </div>
        <div class="dis-content">
            [[+content]]
            [[+discuss.user.shouldMarkAnAnswer:eq=`1`:then=`
                [[+idx:eq=`1`:then=`
                    <div class="dis-info"><p>[[%discuss.mark_answer_instructions]] <a id="Show-answer-link" href="#">[[%discuss.mark_answer_link]]</a></p></div>
                `:else=``]]
            `:else=``]]
            [[+idx:eq=`1`:then=`
                [[+answer_count:neq=`0`:then=`
                    <div class="dis-info"><p>[[+jump_to_first_answer.explanation]] [[+jump_to_first_answer.link]]</p></div>
                `:else=``]]
            `:else=``]]
            [[+attachments:notempty=`<div class="dis-post-attachments"><ul class="dis-attachments">[[+attachments]]</ul></div>`]]
            [[+editedby:is=`0`:then=``:else=`<span class="dis-post-editedon">[[%discuss.editedon_post? &on=`[[+editedon:ago]]` &user=`[[+editedby.username]]`]]</span>`]]
        </div>
        <ul class="dis-action-btn">[[+report_link]][[+action_reply]]</ul>
    </div>
    [[+author.signature:notempty=`<div class="dis-signature">[[+author.signature]]</div>`]]
</li>
]]>
nuan88 Nov 27, 2015, 12:41 AM https://forums.modx.com/thread/98881/how-to-set-public-read-access-for-attachments#dis-post-534875