Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Take 1: Editing Permissions for specific page - based on Member Groups

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 12147 Views
  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Re: Take 1: Editing Permissions for specific page - based on Member Groups Link to this post

    > I'm stuck.
    > I am able to successfully insert data into the Authors_By_Group table in the DB - but what seems to be happening is that the whole CMS system is reloaded every time I press the "Add Group" button. I would simply like the new group assignment to be written to the DB and stay on the same page and tab. (I have yet to write the code to display the current groups assigned to the page.) I am fairly certain it isn't running the javascript I have created - using the javascript written for the "save" function.
    > Is there an easier way to do this? Am I on the right track? Thanks in advance.

    Hi Hani,

    To prevent who page reloads, you need to do Javascript AJAX requests, for example I wrote this function in the gsoc branch:

    // Called when checkbox on Bounced tab of Mailing List is clicked
    Behaviour.register( {
       '#BouncedListTable tr td.markingcheckbox input': {
          onchange : function(e) {
             new Ajax.Request(
                'admin/newsletter/memberblacklisttoggle/' + this.value,
                {
                   method: 'post',
                   postBody: 'forceajax=1',
                   onComplete: function(response){
                      Ajax.Evaluator(response);
                   }.bind(this),
                   onFailure: ajaxErrorHandler
                }
             );
          }
       }
    });

    One thing I would do is try putting stuff like:

    alert('yes, this js code was called');
    // or if you have the Firebug extension for Mozilla Firefox
    console.log('yes, this code ran');


    to see if your Javascript code is running.

    However, you may want to use Debug.log('test'); instead of console.log, because of this (I have not tried it yet though):

    Please use the Debug-class rather than console.log for outputting debug-information
    Debug.show(<anyobject>)
    Debug.log(<anyobject>)


    http://doc.silverstripe.com/doku.php?id=javascript#debugging_javascript_in_silverstripe

    I have put trying out your code and trying to help you more on my SilverStripe To Do list and I will try to help you more today if I finish working on this bug today: Ticket #1370: Behaviour is not applied with ajax in IE

    Hope this helps,

    Elijah Lofgren

  • Hani
    Avatar
    12 Posts

    Re: Take 1: Editing Permissions for specific page - based on Member Groups Link to this post

    Hi Elijah,

    That helped TREMENDOUSLY. Thank you! I am slowly (but surely) starting to better understand the architecture of SilverStripe.

    I feel inclined to post the next question in a new topic, but I guess since it is a part of this task, I might as well ask it here.

    I tracked the "whole page refresh problem" to the way I was submitting the data. I was using a submit button to trigger an ajax response. However, since the submit button I wanted to trigger the action is located in the EditForm form, it was triggering that action first.

    I used an onchange event (on a drop down menu) to trigger the ajax response instead of the submit button - and it works. I suppose I could now use a graphical button instead of a submit button and it would work. However, is there an easy way to change the following code so that instead of calling the default action of the form, it calls an ajax response?

    [code php]
    $fields->addFieldToTab('Root.Authors', new FormAction( "addAuthorByGroup", "Add Group" ));

    If seeing more of my code will help you understand what I have, let me know.

  • Markus
    Avatar
    Google Summer of Code Hacker
    152 Posts

    Re: Take 1: Editing Permissions for specific page - based on Member Groups Link to this post

    Hi Hani,

    sorry that I didn't reply to your post. I was in vacation and I missed your post when I came back, sorry!

    In the next days I'll concentrate on page security and implement also inheritance (post in the GSoC forum).

    After that, the current access tab (not public available yet) which looks as follows:

    will look more or less like this little mockup:

    Has someone a better idea how to label the two list boxes ("Available groups", "Selected groups")?

    If you want, you can send me your code (markus at silverstripe dotcom)

  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Re: Take 1: Editing Permissions for specific page - based on Member Groups Link to this post

    > I used an onchange event (on a drop down menu) to trigger the ajax response instead of the submit button - and it works. I suppose I could now use a graphical button instead of a submit button and it would work. However, is there an easy way to change the following code so that instead of calling the default action of the form, it calls an ajax response?

    I'm not sure... Anyone else have any ideas?

    > If you want, you can send me your code (markus at silverstripe dotcom)

    It looks like Markus is handling this (he's a great bug fixer!), so I'll take this off my To Do list and move on to other stuff. ;)

  • Tim
    Avatar
    Core Development Team
    201 Posts

    Re: Take 1: Editing Permissions for specific page - based on Member Groups Link to this post

    Hi Markus,

    We've been debating this interface internally for a while, and one our clients have just dictated the interface we use for security. We need to use the matrix style interface, similar to what was discussed here.

    http://www.silverstripe.com/google-summer-of-code-forum/flat/2613

    The basic context of this is, one of the systems we've developed has had a full audit from a "big 5" consultancy company, and one short comings identified was the security area not being clear enough, and in their view the matrix is by far the best way to go.

    There is now a lot of urgency to fast track this at our end - Hayden is going to be working on this all next week with the view of having it completed at the next week, it's likely there is a lot of code you guys can share here.

  • Markus
    Avatar
    Google Summer of Code Hacker
    152 Posts

    Re: Take 1: Editing Permissions for specific page - based on Member Groups Link to this post

    OK, so I'll chat with Hayden and see what he has already done. Thanks for the advice Tim!

    12147 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.