Limit access of custom content type?

kreynen - January 2, 2007 - 21:24

I'm in the process of wrapping a large database application in Drupal. I don't want to rebuild the whole thing with custom content types or CCK because of the number of primary/secondary key relations in the database, but I do want to limit the users who can add content using Drupal's permissions. I've created a custom content type called "Custom Forms" and copied the PHP and HTML for the form into a node of that type.

http://www.sidewalktheory.com/newspapers/suggest_an_edit/?ID=2

In Administer > User management > Access Control, I can modify a role's ability to create and edit "Custom Form" content, but the settings for accessing the content seems to be universally controlled by "access content". When submitted, this form calls an action file that modifies a database outside of Drupal. If this were a fully Drupal application, I could limit a user's access by changing the Edit permissions for that content type. I want users to see a "you must register or login" message if they aren't logged in. I've hacked user lookups based on the cookie/session data in 4.7, but I'm hoping there is a way to do this within the framework of 5.

Any advice for limiting a roles ability to even view a specific page or content type in Drupal 5?

Added hack

kreynen - January 2, 2007 - 23:58

I needed to move on so I've hacked this again by looking up the SessionID from the cookie...

$SessionID = $_COOKIE["PHPSESSID"];

then doing a quick query of the Session table to get the user's ID.

SELECT * FROM Sessions WHERE sid = '$SessionID'

If the user ID == 0, I direct them to log in or register.

Please let me know if there is a better way to do this.

Seems like this problem is

vacilando - April 29, 2008 - 22:14

Seems like this problem is answered by this the Content Access module: http://drupal.org/project/content_access

 
 

Drupal is a registered trademark of Dries Buytaert.