Passing values from a function call

Discuss about Group-Office development here

Moderator: Developers

ZedBel
Posts: 8
Joined: Tue Aug 27, 2013 11:53 am

Passing values from a function call

Postby ZedBel » Wed Jan 15, 2014 1:12 pm

Hello everyone!

I have managed to get the username and password using the event handling, however i want to pass them to MainPanal.js inorder to append them to a url which is fetched from the DB and have a direct login to the called url. for instance the event is written in BookmarksModule.php and i want to call and get a return from the function written in this .php file to MainPanal.js. I tried with the ff but it doesnt work:

Code: Select all

var dat = GO.url('bookmarks/BookmarksModule/beforeLogin');
In which the beforeLogin is a function written inside BookmarksModele in BookmarksModule.php

Thanks Happy coding :D
mschering
Site Admin
Site Admin
Posts: 8332
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Passing values from a function call

Postby mschering » Wed Jan 15, 2014 4:14 pm

You can only call controller functions. With GO.url('module/controller/action');

https://www.group-office.com/wiki/Controllers
Best regards,

Merijn Schering
Intermesh
ZedBel
Posts: 8
Joined: Tue Aug 27, 2013 11:53 am

Re: Passing values from a function call

Postby ZedBel » Thu Jan 16, 2014 12:31 pm

Thanks! Any idea to achive this?
jamesarthur
Posts: 55
Joined: Fri Nov 08, 2013 9:15 am

Re: Passing values from a function call

Postby jamesarthur » Mon Feb 10, 2014 1:46 pm

Hi

I'm not sure I fully understand your question, so please excuse me if I don't answer it exactly.

Any php script must start with a controller function as the entry point. These functions all begin their name with `action`, and take 1 argument `$params` which contains all the parameters submitted either on the cmd line (`?x=y&z=foo`) or submitted as the body of a POST request.
(NB the post request must be in x-www-form-urlencoded but groupoffice javascript will do that for you).

Once in this function you can do any standard php things, like `include` something into the file and use it in the function, or use any of the autoloaded models/controllers.

At the end you return some array, which will be JSON encoded and sent as the response to the user.

If you want to allow users who are not logged in to access a function, you have to put the function name as a string into the return value of allowGuests, e.g. in your controller:

Code: Select all

protected function allowGuests() {
    return array('beforeLogin', 'anotherMethod');
}
then any functions called actionBeforeLogin and actionAnotherMethod will be available even if the user has not logged in.

Also see 'ignoreAcl' (I think that's the right name, but you might need to look in the docs to make sure)

Who is online

Users browsing this forum: No registered users and 2 guests

cron