Active
Project:
Private nodes
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Sep 2007 at 18:52 UTC
Updated:
3 Oct 2007 at 22:34 UTC
Hi,
Maybe this would be a nice addition for the module: A 4th option to show the node to 'authenticated users' (or members :-p ) only?
I have tried to do it myself (by forking the private_node module) and it is not that hard at all (thanks to very nicely written code):
define('PRIVATE_NODES_USERS', 3);
function private_nodes_check_access($uid, $nid) {
...
elseif ($level == PRIVATE_NODES_USERS && $user->uid > 0)
{
return true;
}
function private_nodes_form_alter($form_id, & $form) {
...
$options = array (
PRIVATE_NODES_PUBLIC => t('Anyone'),
PRIVATE_NODES_PRIVATE => t('Only myself'),
PRIVATE_NODES_USERS => t('Only members')
);
...
function private_nodes_edit_form_validation($form_id, $form_values, $extra_info) {
...
$privacy_levels = array(t('Public'),t('Buddies only'),t('Members only'),t('Private'));
...
function private_nodes_db_rewrite_sql($query, $primary_table, $primary_field, $args){
...
$return['where'] = "(pn.nid is null OR pn.level=".PRIVATE_NODES_USERS." OR (pn.level=".PRIVATE_NODES_BUDDIES." AND {$primary_table}.uid IN (".$buddies.")) OR {$primary_table}.uid=".$user->uid.")";
}else{ //user doesn't have any buddies
$return['where'] = "(pn.nid is null OR pn.level=".PRIVATE_NODES_USERS." OR {$primary_table}.uid=".$user->uid.")";
...
function private_nodes_edit_form_submit($form_id, $form_values, $extra_info) {
...
case PRIVATE_NODES_USERS:
$message=t("Your {$extra_info['name']} is now viewable to members only");
break;
...
That should do it; I hope I didn't forget anything.
So, what do you think?
Comments
Comment #1
finex commentedThis is similar to my issue here http://drupal.org/node/166422.
I've added a policy, but I've some problems on the private_nodes_db_rewrite_sql().