Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
spyrule
Worker
Worker


Joined: Jun 06, 2006
Posts: 105

PostPosted: Fri Aug 24, 2007 11:44 am Reply with quote

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 Akaching! and so does raven.

also any other "look out for's" when coding modules with forms, is apreciated.

Spyrule
 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing


Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Fri Aug 24, 2007 11:59 am Reply with quote

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 
View user's profile Send private message
spyrule
PostPosted: Fri Aug 24, 2007 12:20 pm Reply with quote

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
PostPosted: Fri Aug 24, 2007 1:00 pm Reply with quote

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

PostPosted: Fri Aug 24, 2007 8:41 pm Reply with quote

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.
 
View user's profile Send private message Visit poster's website
spyrule
PostPosted: Sat Aug 25, 2007 7:29 am Reply with quote

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 :
Only registered users can see links on this board! Get registered or login!

Thanks guys,

Spyrule
 
fkelly
PostPosted: Sat Aug 25, 2007 9:05 am Reply with quote

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.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©