Author |
Message |
spyrule
Worker


Joined: Jun 06, 2006
Posts: 105
|
Posted:
Fri Aug 24, 2007 11:44 am |
|
Hello,
I am just getting into writing a few modules for the most recent version of raven nuke.
I am wondering a few things...
1) Is a module ALWAYS connected to the same Db as the website? meaning to I have to call to it in any special way to "connect" to the database?
2) If I want to pass form data back to a the modules single index.php file,
and I want to pass a set variable back along with the data (I want to be able to set : HasRun = 0; on initial, then HasRun=1; on first form result, and then HasRun = 2; on final second form result, and once that is done, reset HasRun =0; so that it starts over. How do I pass the incremental value of this variable back to the module itself, preferably using a method that is hidden from the user (not in the URL) ?
3) How do I double check module permissions access for more then one group (ex. Major Accounts Managers, Managers, Administrator groups) ?
Thank you in advance, this site kicks A and so does raven.
also any other "look out for's" when coding modules with forms, is apreciated.
Spyrule |
|
|
|
 |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Fri Aug 24, 2007 11:59 am |
|
1) There is a global object called $db that modules can use to access the site database.
2) An input type="hidden" variable in a POST form would keep it out of the URL
3) I've never used the Group feature. Sorry.
Google for the PHP-Nuke How-To. It has a tutorial on module building. Good luck! |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
spyrule

|
Posted:
Fri Aug 24, 2007 12:20 pm |
|
Thanks,
I read the how-to, but to be honest, it is lacking quite a bit in the sense of the total scope of things that can/should can't/shouldn't be done inside modules (especially when it comes to security). |
|
|
|
 |
Gremmie

|
Posted:
Fri Aug 24, 2007 1:00 pm |
|
All the usual PHP application security do's and don'ts still apply to Nuke modules. |
|
|
|
 |
fkelly
Former Moderator in Good Standing

Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY
|
Posted:
Fri Aug 24, 2007 8:41 pm |
|
Gremmie pretty much nailed the database access. Unless you have very unusual requirements and coding skills you'd be better off just accessing the single database that's defined in your config.php file.
RE. the forms data. If you want something that's as persistent as what you imply you might be better off developing a table and storing the data there. You might have to include the username or some other "persistent" indicator in there but otherwise I don't know how you can achieve what you are hinting at. Session variables are another option I suppose.
I believe you can limit module access to a single group. But you have to realize that nsngroups was not really developed for this purpose and I don't see any way you can assign multiple groups. You could create a super group that contains all the individual members of the several groups you want to access the module but there is currently no way to have groups within a group. Furthermore group permissions have no relevance to Nuke administrative permissions .. i.e. those contained in /modules/modulex/admin. These can only be granted by using the edit admins function that only GOD has access to and then only on an admin by admin basis. This is a major p.i.t.a. with Nuke but that's the way it is.
And finally, yeah the HOWTO is a great resource but at the same time severely lacking. That's what you get for free. |
|
|
|
 |
spyrule

|
Posted:
Sat Aug 25, 2007 7:29 am |
|
thanks fkelly,
yeah, I'm only trying to access the $db that is with nuke. I've added some tables to it, but mainly the reason for the question, is because I'm reading a standard php/mysql book, and it want to create the connection each time. Which I was pretty sure, was not needed with this cms. So that part I have now figured out, as for passing blind data back to the same form, actually it works quite well with hidden post data. So I have the entire dataflow tree inside one single index.php module file.
Quite nice actually, now I'm just having to get my darn mysql to stop giving me errors (my weekend test server is running php5/mysql 5, but my work active server is running php5-cgi/mysql 4).
So some code seems to barf errors (specifically mysqli commands). Which also doesn't help that the book I'm reading is for mysql5/php5 as well so ALL the commands are mysqli.
but if you want to see what I have done so far, check :
http://www.ravenphpscripts.com/postt14058.html
Thanks guys,
Spyrule |
|
|
|
 |
fkelly

|
Posted:
Sat Aug 25, 2007 9:05 am |
|
To work well inside Nuke you really need to use the mysql.php file that's inside the /db directory. There are plenty of examples throughout Nuke. There are some other threads mentioning mysqli and it looks very promising to me but for right now you need to make your code work with the "standard" database objects in mysql.php. I've posted elsewhere a hack you can do to mysql.php to capture errors to a log file. Standard Nuke and even RN doesn't do very well at showing database errors or helping you diagnose the problems. |
|
|
|
 |
|