Jump to content

couldEdit() and moderator permissions


Recommended Posts

I don't understand what couldEdit() is even used for. In the normal edit methods in ip.suite it already checks canEdit(), anyway, and couldEdit() is checked within canEdit(), but then when the form is submitted, it specifically checks couldEdit() again, even though it would be checking it within canEdit() later in the method, anyway. And, also, the same moderator permission check is done in both couldEdit() and canEdit().

What confuses me the most is I did not even set up anything to do with moderator permissions or set an author field for my content item, but for some reason I pass the couldEdit() check and someone else in the acp does NOT pass it!

Is moderator permissions automatically used even if I do nothing to enable it? And it's having me pass the couldEdit() check just by me being in the admin group somehow? I don't want to use moderator permissions, btw, I am doing this editing in the acp only. Do I need to undo anything to keep ip.suite from "automatically" allowing moderator permissions for my app somewhere without me setting it up?

Link to comment
Share on other sites

Yes, generic moderator permissions such as "can edit content" are checked automatically.

You really don't need to worry about the specific differences between canEdit() and couldEdit(). Just check canEdit(). couldEdit() has to do with time cutoffs (e.g. so someone doesn't load an edit form, make changes, then get an error on submit) - it's not something you need to worry about though.

Link to comment
Share on other sites

More to the point, the reason I even posted this is because I am worried various functionality will automatically be allowed without me intending it to be and documentation doesn't make that clear.

For instance, 1. I don't know why I automatically passed the couldEdit() check when I didn't set up anything to do with moderator permissions for the app and 2. had I not happened to look through files, i wouldn't have realized that extending Content\Controller means a function edit() is automatically there, so without me intending to even allow editing on the front end, it would have allowed it, had I not noticed, and would be calling my add form methods.

Also, one last thing on couldEdit() is that I see it's checked when a form is submitted and it says it's to prevent losing data, so that is why I am confused is I don't see how that relates to losing form data and I don't know if I need a similar form submitted check.

Link to comment
Share on other sites

On ‎5‎/‎22‎/‎2018 at 11:03 AM, bfarber said:

Yes, generic moderator permissions such as "can edit content" are checked automatically.

You really don't need to worry about the specific differences between canEdit() and couldEdit(). Just check canEdit(). couldEdit() has to do with time cutoffs (e.g. so someone doesn't load an edit form, make changes, then get an error on submit) - it's not something you need to worry about though.

I re-read your post and realize I somehow originally missed where you explained that "form submitted" check. I see now... I don't think I'd need that form submitted check, then, because in my situation any time there is a deadline, even if they started beforehand, it 100% needs to not allow it, ie it needs to be actually submitted in time, so i guess I can leave the form submitted check out.

When the doc mentioned that it was to prevent losing content, I totally misread what that meant. ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...