Jump to content
blad

If user has permission to see the edit tabs...

Recommended Posts

Hi! I´m trying to edit the ProcessPageEdit for hide the tabs "Childrens, Setup, Delete, View" if user dont have X permission. My client doesn´t need these tabs. 

post-2447-0-51562100-1408295418_thumb.pn

Any ideas?. 

Share this post


Link to post
Share on other sites

The module: 

<?php

class AdminHelperHooks extends WireData implements Module {

public static function getModuleInfo() {
        return array(
            'title' => 'HideTabs ProccesPageEdit',
            'summary' => 'Hide the tabs Childrens, Configuration, Delete, View', 
            'version' => 1,
            'singular' => true,
            'autoload' => true
            );
    }

    public function init(){
        $this->addHookAfter("ProcessPageEdit::buildForm", $this, "buildFormHook");    
    }

    public function buildFormHook(HookEvent $event){
     
        if(wire("user")->hasRole("superuser")) return;
        
            $form = $event->return;

            $fieldset = $form->find("id=ProcessPageEditSettings")->first();
            $form->remove($fieldset);
            
            $fieldset = $form->find("id=ProcessPageEditDelete")->first();
            $form->remove($fieldset);
            
            $fieldset = $form->find("id=ProcessPageEditChildren")->first();
            $form->remove($fieldset); 

            $fieldset = $form->find("id=ProcessPageEditView")->first();
            $form->remove($fieldset);

    } 
}

Based on https://processwire.com/talk/topic/4680-block-access-to-settings-delete-and-view-tabs-for-page/ by Soma

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      If your module has a lot of config fields you might want to divide them into groups inside a tabbed interface. Here is a demonstration module showing how this can be done.
      https://github.com/Toutouwai/ModuleConfigTabs

      Thanks to @kixe for providing my starting point in this forum topic.
    • By jonatan
      "Permission “page-sort” for template “ ... ” not allowed (requires “page-edit” permission)"

      – This lovely error message is thrown at me, if, as implied by it, I try to add (to my "editor" role) the permission "page-sort" for a specific template, without the permission "page-edit" enabled for the same template.
      Seems like it's been mentioned a few times before but never properly answered, by e.g. @Robin S ... :  
      "Allow the granting of page-sort permission independent of page-edit": https://github.com/processwire/processwire-requests/issues/29
       
       
       


      Why do I wanna do this?:

      I have a page tree structure  🌳  as so:

      ________________________

      Category [C1]
      – Page a [C1_p] – Page b [C1_p] Different category [C2]
      – Page c [C2_p] – Page d [C2_p] ________________________

      The page "Category" has the page-template "C1",
      the pages "Page a" and "Page b" both have the page-template "C1_p".
      The page "Different category" has the page-template "C2"
      the pages "Page c" and "Page d" both have the page-template "C2_p".
       
      The two pages called "Category" and "Different category" do not have any content, they only serve as containers for pages belonging to that category.
       
      I want my "editor" role not to be able to do anything at all with these pages "Category" and "Different category"; i.e. I do not want my editor to be able to edit, move, unpublish, hide, lock, delete (or do anything else to) these category pages. 
      – So, I want my "editor" role to have the "page-edit" permission for pages with the templates "C1_p" and "C2_p", but not for the pages with the category templates "C1" and "C2",
      Also, I want my "editor" role to be able to move the pages with the templates "C1_p" and "C2_p" within their parent-pages. 


      Problem:

      But if I just simply add the "page-edit" and the "page-move" permissions for the "C1_p" and "C2_p" templates, then, using the "editor" role, I am not able to move these "C1_p" (and "C2_p") -template-based pages. I can actually click "MOVE" next to them and then move them, but... then I will be met by the error message "You do not have permission to sort pages using this parent - /Category/".  
      – So, I try to add the "page-sort" (description: "permission to sort child pages") permission to the "C1" and "C2" templates... but then trying to do so I am met by the initially mentioned error message   ! Permission “page-sort” for template “C1” not allowed (requires “page-edit” permission)  . 
      And, as mentioned, I do not want my editor role users to be able to edit these category ("C1" and "C2") pages...
      – what to do about this? 😅 
       
      All the best,
      Jonatan 
    • By louisstephens
      So I ran into a very strange issue today. I have a template with a pagetable and I went to add an item to it, when I went to select an image (for an image field) the page instantly threw up an error
      "ProcessPageSearchLive: No search specified"
      The page's content also switched to the image attached. This all worked perfectly last week (local mamp box). Has anyone experienced this before, and how did you solve it?
       

    • By Pip
      Hi everyone, 
      Is there a way for us to replicate the "http://mydomain.com/processwire/page/edit/?id=xxx" and change the template to match my site template? 
      I'm terribly happy with the admin / backend page edit. It covers literaly everything I want to empower my non super admin user in updating pages such as validation, repeater management, file upload. 
      I wish not to allow the users to see the backend for both security and aesthetic reasons. 
      Thanks and hope to hear from you soon. 
       
    • By AndZyk
      Hello,
      I have a user role employee with the permission page-edit-created. This user role has access to add new pages to the template posts with the template post.
      The template posts should have children with the template post. The template post should have the parent with the template posts. Now every time I try to add a new page with the template post, an exception throws:
      You don't have access to the template required to add pages here
      Is this a bug in this permission or have I not configured the permissions correct?
      Is there a hook to allow to add pages to the template posts for the role employee?
      I would appreciate some help. 😀
      Regards, Andreas
×
×
  • Create New...