ausmedia Posted February 19, 2007 Share Posted February 19, 2007 Hi guys, I am currently working on a project using php & mysql, however i have some problems which i cannot solve by myself (not smart enough), so i would like to ask for your expertise regarding this problem. Problem: -------------------------------- Don't know how to add/remove modules into admin system. I want to be able to add/remove modules into the systems (record it into the database), then assign access permission to certain user groups. -------------------------------- Am not sure where to start and what are the steps, could someone please give me some guidelines, resources or websites where i can do some further research? If possible some codes to start off would be greatly. Thank you Link to comment https://forums.phpfreaks.com/topic/39146-addremove-modules-from-admin-system/ Share on other sites More sharing options...
Psycho Posted February 19, 2007 Share Posted February 19, 2007 Fairly straitforward, but you need to be sure to fully plan out your access model (the specifics of how the groups can access the modules). If not, you run the risk of programming yourself into a corner where there is a hole in the logic. Anyway. you will need at least four tables: users, groups, modules, and moduleAccess. The tables will contain a lot of other data, but here is the data I would include specifically to address your issue: Each table will have a unique ID field: userID, groupID, etc. The users table will include a column for the group ID. The groupAccess table will have columns for groupID and moduleID. You could then pull what modules a user has access to with the following query SELECT * FROM modules LEFT JOIN moduleAccess ON modules.moduleID = moduleAccess.moduleID LEFT JOIN users ON moduleAccess.groupID = users.groupID WHERE user.userID = $userID Link to comment https://forums.phpfreaks.com/topic/39146-addremove-modules-from-admin-system/#findComment-188615 Share on other sites More sharing options...
ausmedia Posted February 20, 2007 Author Share Posted February 20, 2007 hi mjdamato thank you for your reply, I have done that already, although what am really confuse about is: how do write a script that will automatically detect a new module when i place it into the folder call "modules" after that how will i link that module to the table "modules" so then from there i can control the access permission of that module. cheers Link to comment https://forums.phpfreaks.com/topic/39146-addremove-modules-from-admin-system/#findComment-189210 Share on other sites More sharing options...
Psycho Posted February 20, 2007 Share Posted February 20, 2007 OK, the picture is becoming clearer now. You want to add a file/folder to a "modules" folder and have your system automatically pick it up. Well, on a "manage modules" page you could have the page do the following steps when you first access the page: 1) Iterrogate the "modules" folder and create an array of all the module names. 2) Query the "modules" table for all the modules. 3) Step through each module in the query restults. If the module does not exist in the array list then that would indicate that the module which was previously in the database has been moved/deleted. So, if it does not exist in the array delete the module from the database and all dependencies (i.e. moduleAccess table). If the module does exist in the array, then remove that item from the array. When this process is done your database will have purged any modules that have been removed and your array will contain the names of the new modules. 4) Iterate through the remaining items in the array and add those modules to the module table. One all that is done your module manager page would do a final query of the modules and their dependencies and display a UI accordingly. Link to comment https://forums.phpfreaks.com/topic/39146-addremove-modules-from-admin-system/#findComment-189506 Share on other sites More sharing options...
ausmedia Posted February 21, 2007 Author Share Posted February 21, 2007 hi mjdamato i will definitely give it a go, will try my best to put it together then post the result here. thank you very much Link to comment https://forums.phpfreaks.com/topic/39146-addremove-modules-from-admin-system/#findComment-190263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.