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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

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


Go to End


14 Posts   13660 Views

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

8 August 2007 at 6:40am

> 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

Avatar
Hani

12 Posts

8 August 2007 at 3:39pm

Edited: 08/08/2007 3:41pm

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

Google Summer of Code Hacker, 152 Posts

9 August 2007 at 2:24am

Edited: 09/08/2007 2:26am

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)

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

9 August 2007 at 11:07am

> 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

Community Member, 201 Posts

9 August 2007 at 3:34pm

Edited: 09/08/2007 3:43pm

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.

Avatar
Markus

Google Summer of Code Hacker, 152 Posts

10 August 2007 at 3:30am

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

Go to Top