Jump to content
pwFoo

Custom permissions page-delete-own and page-edit-own

Recommended Posts

Hi,

I try to add page-edit-own and page-delete-own permissions, but it's strange...

If a add the custom permissions it looks like both are children of page-edit respectively page-delete. I played with added / revoked permissions, but I can't get it work, that a user of a role just can delete own content.
First the user can't delete any content and now the user can delete own and foreign pages 🤪

Is there a tutorial to learn more about the PW permissions?
Or do I have to rename the permissions to page-own-edit and page-own-delete to be independent from page-edit and page-delete?

Share this post


Link to post
Share on other sites

Thanks! Tested the permissions, but have a problem with permissions or understanding how it works.
"page-create" is activated for "basic-page". Don't know if needed... just activated to test...

My role has the following permissions set.

image.thumb.png.1ae081b9e48745edccbd57d9b81293bd.png

 

Tried to add a page to home ("/") with template ""basic-page".

Do some permission check before...

Page owner: test
Current user: test
Current user roles: guest, writer
Current user permissions: page-view, page-edit  // --> missing allowed permissions "page-edit-created, page-edit-trash-created"
Addable (parent): 0         // --> 1 (allowed to add child to "/")
Addable (child to page): 0  // --> OK, add to parent should work, not add children to that page
Editable: 1                 // --> OK, but by page-edit or as should page-edit-created???
Trashable: 0                // --> 1 (allowed by page-edit-trash-created)
Deleteable: 0               // --> OK, just allowed to trash the page...

User test has role "writer" (screenshot with permissions), is page owner(!). Added expected values to the permission check output above.

Checked by addable(), editable(), trashable() and deleteable() methods.

Share this post


Link to post
Share on other sites

Hi @gmclelland,

strange... Image isn't broken here, but I changed the post a short time later because I fixed it... The changes are gone, just the "solved" tag is there.

Problem was that the page was moved to trash and so parent wasn't home ("/") anymore. So different permissions and trashable == false was "fine". I moved the page back and all looks good.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By pwFoo
      I tried to add a new page with $pages->add() with a custom method inside of a module. It looks like the method is called each page load (as should) and also if the backend page tree is loaded / refreshed (bug??)?
      public function create($template, $parent, Array $data = array(), $name = false) { $name = wire('sanitizer')->pageName($name ? $name : $data['title']); $obj = wire('pages')->add($template, $parent, $name, $data); return $obj; } called inside of home page ("/"):
      $api->create('basic-page', '/', array('title' => 'ApiCreatedTest1')); Works fine. Load it twice (create duplicate page) results in an error.
       
      But without "/" requested the page gets created if I view the backend?!
      Checked it by delete the page, check the page tree again and it looks fine. But if I reload the backend page the page appears again. So backend page tree load executes the home page ("/") and create the page?
      Is it a bug or I'm missing anything...?
    • By cehlo
      Hello everyone,
      I am starting to creating some hooks, but I am little bit new to this part of Processwire so please help 🙂. 
      My problem: 
      I have multiple fields in one template - Page Reference - I activated autocomplete and also possibility of creating new pages from the fields. 
      Is it possible to add additional values to newly created page via Page Reference field? 
      For example: I know that the name of Page reference field is called for example car - I am searching with autocomplete for example for Mercedez, it is not created, so I know that newly created page via this field will have value in category field - cars,...
      I think I should addHookbefore to InputfieldPage::processInputAddPages, am I on the right track? Any assumptions? 
      Thanks for help.
       
    • By EyeDentify
      Hello Gentlemen and Ladies.

      I have not posted for a while but now i need your help figuring out some things.
      The Documentation has come a long way and i love it.
      Though on the page:
      https://processwire.com/api/ref/pageimages/

      I am trying to figure out if when i want to add an image to an existing image field with multiple images alldready in it and using the method $page->images->add()
      <?PHP /* get the images object array for the Page */ $myPageImg = $page->images; /* define the image to add */ $newImg = 'http://www.somesite.com/image.jpg'; /* Thanks Autofahrn, forgot about the output formating */ $page->of(false); /* create a new Pageimage object with the given URL and add to the Pageimages array */ $myPageImg->add($newImg); /* save the page */ $page->save(); ?> I am pretty sure i missed a few steps in the code above?
      Is that string suppose to be an URL like "http://www.somesite.com/image.jpg" and the method will automaticly download the image and create an Pageimage Object and add it to Pageimages array or does it have to exist on the host first and i supply a file path to that image?

      I guess im confused about that, hope you guys could clarify that for me.

      And if it needs to be allready downloaded to my host before adding the image, what would be the best API methods for that task?
      Just point me in the right direction and i will figure it out.
      Sorry for the bad explaination but i could not figure out a better way of asking.

      Thanks in advance.
      /EyeDentify
    • By angelo, italy
      Hi guys,
      I've always used WP but I want to swtich to PW. I'm not sure ....
      I'd like to know if it's possible to create a website for an online photo contest.
      The participants of the competition could create their own account, in which they upload their photos. The photos uploaded remain visible only to themselves and the judges.
      From their account they can make the "entrance fee" payment.
      The judges of the competition can create their own account... entering they see the photos of the participants and vote photos
      At the main page I imagine the title of the competition, a button to read the regulation, and a button to register.
      The website should be in Italian and English.
      Thank you!!
       
       
    • By Jest
      Hi all,
      the site is in non-English language and uses some modules which needs to be translated. Since the content is not multilingual I've installed only the LanguageSupport. I added another language, but can't translate any string since the Admin > Setup > Languages > [en/xx] > Find Files to Translate always returns an error "Object of class DirectoryIterator could not be converted to boolean" and a standard "The process returned no content." text.
      I've checked the /site/assets/files/[lang id] folder permissions, even chmoded folder and its contents to 777, to no avail. If I manually create the json translation file and then upload it via the admin everything works as expected (I can see the file in the 'Site/Core Translation files' list, I can edit it, and the translation shows up).
      Can somebody point me in the right direction? Am I missing something?
      The PW version is 3.0.123. I've setup a few PW multilingual sites with ease, that's why this issue confuses me even more.
      Thanks,
      Jan
×
×
  • Create New...