hidden module

Events happening in the community are now at Drupal community events on www.drupal.org.
shensche's picture

kia ora koutou...

i created a module called hidden to have something in between the Drupal states of published and unpublished.
each article (node) or comment has a link 'hide'/'unhide' if the user has the permission to 'mark as hidden'. after having supplied a reason, the obscured items are available unter /hidden.

current caveats:
- comments for hidden items are disabled
- in admin/content/node, the hidden articles appear only as unpublished

dunno how to use the module infrastructure (without patching core modules) to get that straight.

have a go and give me feedback, please.
NOTE: the file is not an OpenOffice document. please rename it to hidden.tar.gz! the server restricts uploads of files to certain file extensions.

AttachmentSize
hidden-0.3.tar_.gz_.odp10.47 KB
hidden-0.4.tar_.gz_.odp10.9 KB
hidden-0.5.tar_.gz_.odp11.27 KB

Comments

Seems like it would be worth

mfb's picture

Seems like it would be worth contributing as a project on drupal.org.
The main thing I notice is that, you create and drop the table each time the module is enabled and disabled. This could cause unexpected data loss since most modules preserve the data when disabled. You should create the table in the .install file, and only drop it via uninstall.

.install file

shensche's picture

tena koe...

i had it in an install file first and due to my not understanding of how to install the database migration part of a module, i put it into enable and disable. but today i believe learned you have to use update.php if you have a module with an .install file to make the changes in the database. please correct me if i am wrong.
version 0.5 will improve that.

cheers,

The install hook is executed

mfb's picture

The install hook is executed when you first install and enable a module. At this time, the corresponding row in the system table is updated to reflect the current update level (the highest-numbered update function in the .install file), but no update hooks are executed.

Later, if a new version of the install file includes higher-numbered update functions, these will be executed when update.php is run.

yes, i did not know about

shensche's picture

yes, i did not know about the entry in the system table until yesterday. previously i wondered why my _install was not run and put the un-/install stuff into the en-/disable functions.
version 0.5 contains a .install file. please remove the current entry for hidden from the database:

delete from system where name = 'hidden';
drop table 'hidden';

and then upload the new version, go to the admin/build/modules and enable the module. mind that previously hidden items are now only unpublished and might have 'HIDDEN: ' prepended to the title/subject.
i reckon that future database upgrades will make use of the update_N functions, until version 1.0.

ka kite,

Version two

ekes's picture

I've had a run at rewriting this... loads of new features :-) If anyone wants to help test it notes and download are on wiki here:

https://en.wiki.aktivix.org/IMC-Drupal/Development/Hiddens

Indymedia

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: