Attached are two patches that creates a new column in the /admin/block section called "hidden".
Each block can be set to be hidden from anonymous users so that only logged in users can view
the block. I use this feature extensively on several Business related websites, where I don't want
backend blocks (eg the "Navigation" block) to be visible to the general public. This helps to create
a much more smooth/slick Business related website, utilizing the Drupal as a backend CMS
platform for managing the content. This coupled with changes to the Themes to strip attributions
and other related useless "community" oriented information creates a very trimmed down
business specific capability to Drupal.

I suspect there are other uses/reasons for this code. I know that blocks can utilize the "custom"
feature to allow users to select whether or not to show blocks, but that method doesn't allow
control over anonymous users viewing of blocks. Some other examples might be displaying of
certain blocks to users after they have logged in (rich content for "paying" or "contributing" users;
eg "benefits").

Changes/notes:
+ Added new "hidden" column
+ Code changes to the modules/block.module file to enable the column
+ databases/database.mysql changed to add the new column on new installs
+ databases/database.pgsql changed to add thenew column on new installs
+ databases/updates.inc new function update_110() added to modify existing database instances
+ patch based against Drupal 4.5.0 release code
+ patches created with "diff -unR -F^f" format
+ apply from the base drupal install directory with "patch -p 0 < block.module.patch"
and "patch -p 0 < block-database.patch"
+ I verified patches update the associated files correctly, and subsequently that the feature works

v/r

Shane

CommentFileSizeAuthor
block_0.patch9.52 KBshane
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

matt westgate’s picture

This looks like a good start, but why not let site admins choose which roles can view blocks rather than just a toggle for anonymous users?

You might also want to take a look at Drumm's current work on the block interface.

drumm’s picture

Changing block visibility by role as mathias requested is the next step for the issue he cited. I'll get a chance to update that when I am on my way to http://drupal.org/node/11593.

This should wait until #11875 is commited so it can take advantage of the cleaner UI which takes things out of the overloaded table instead of adding them.

tostinni’s picture

Hi, Thanks for your work, I have to thanks cvs community which look very active and enthousiast about making such patch.
I'm sorry not to have (yet) the skills to help, but I would have a little question :
Is the fact that you will publish custom blocks (and hide then regarding of the role) will also prohibit users to view content including in this block or should I also protect content using node_perm_byrole ?

tostinni’s picture

feature #11875 have been commited.
Hope you can offer a patch for allow user byrole to see the block ;)
Thanks again

drumm’s picture

drumm’s picture

Oops, this is really superceded by http://drupal.org/node/12988.