Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

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

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

Take 1: Editing Permissions for specific page - based on Member Groups


Reply

14 Posts   12171 Views

Avatar
elijahlofgren

8 August 2007 at 6:40am Google Summer of Code Hacker, 222 Posts

> 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>)


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

I have put trying out your code and trying to help you more on my [url=http://www.rememberthemilk.com/home/elijahlofgren/1612288/]SilverStripe To Do list[/url] and I will try to help you more today if I finish working on this bug today: [url=http://open.silverstripe.com/ticket/1370] Ticket #1370: Behaviour is not applied with ajax in IE[/url]

Hope this helps,

Elijah Lofgren

Avatar
Hani

8 August 2007 at 3:39pm (Last edited: 8 August 2007 3:41pm), 12 Posts

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.

Avatar
Markus

9 August 2007 at 2:24am (Last edited: 9 August 2007 2:26am), Google Summer of Code Hacker, 152 Posts

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 ([url=http://www.silverstripe.com/google-summer-of-code-forum/flat/3679?showPost=3679]post in the GSoC forum[/url]).

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)

Avatar
elijahlofgren

9 August 2007 at 11:07am Google Summer of Code Hacker, 222 Posts

> 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. ;)

Avatar
Tim

9 August 2007 at 3:34pm (Last edited: 9 August 2007 3:43pm), Core Development Team, 201 Posts

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.

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

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.

Avatar
Markus

10 August 2007 at 3:30am Google Summer of Code Hacker, 152 Posts

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