CVS edit link for AliraSirin

I'm willing to contribute a module named Junk which fully and correctly provides functionality of moving nodes to "Junk" before deleting permanently. It implemets following features:

- Ability to move to junk and restore from junk via "Move to junk" and "Restore" buttons on node edit page and in node local menu
- Automatic "garbage collector" which may delete nodes from junk permanently if they exceed their junk lifetime (i.e. automatically delete nodes for being in Junk for more then 5 days). Though there is an option to never delete junked nodes automatically.
- It uses CTools Page Manager (http://drupal.org/project/ctools) to limit access to the junked node and alter it's output. This way it doesn't ruin node output of latest Panels 3.0 module (which also uses CTools Page Manager) but integrates with it.
- Integration with Views 2 (http://drupal.org/project/views) providing own fields and filters
- Integration with Rules (http://drupal.org/project/rules) providing 2 events - one for moving node to junk and one for restoring
- Option to unpublish node after moving to junk automatically
- Option to filter out junked nodes in core node listings (and any other using db_rewrite_sql) and in any View

Here are the reasons why Junk module should be contributed to Drupal community while having some cross-functionality with following modules:
- Trash module (http://drupal.org/project/trash) doesn't work with contributed modules which implement altering node view callback (such as Panels 3) - Trash simply ruins other module's functionality and that is because of Trash architecture which is it's core feature. It also uses "-1" node.status which is something like hacking Drupal core. All this was the first reason why I decided to develop Junk (being active Panels user).
- Trasbin module (http://drupal.org/project/trashbin) - is a very simple and lightweight module which only provides 1 Rules event which you can use to mark node as "trashed" by another module. It doesn't store trashed nodes and doesn't have any mechanism of restoring or viewing trashed nodes to stay lightweight.
- Killfile module (http://drupal.org/project/killfile) doesn't have any clean way of viewing and restoring killfiled nodes (http://drupal.org/node/339437) and limits access to nodes via menu rather then give user options like altering output, unpublishing, using Rules.

Junk module all-in-one solution for indicated purpose and it doesn't hack core or ruin other modules while integrating with CTools, Views and Rules.

CommentFileSizeAuthor
#10 junk.zip15.24 KBAliraSirin
#8 junk.zip15.53 KBAliraSirin
#4 junk.zip15.46 KBAliraSirin
#1 junk.zip16.82 KBAliraSirin

Comments

AliraSirin’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new16.82 KB

The module is attached.

avpaderno’s picture

Issue tags: +Module review
avpaderno’s picture

Status: Needs review » Needs work
  1.      $schema['junk_node'] = array(
        'description' => t('Stores junked node states.'),
    

    Schema descriptions should not be passed to t() anymore. See system_schema() for an example of what done by Drupal core code.

  2.   variable_set('junk_hide_in_listings', 1);
      variable_set('junk_hide_in_views', 1);
      variable_set('junk_unpublish', 1);
      variable_set('junk_show_contents', 1);
    

    There is no need to set Drupal variables to the default value; the default value is returned from variable_get() when the Drupal variable has not been already set.

  3. function junk_menu()
    {
    	    
        $items['junk/clear'] = array(
        'title' => t('Clear junk confirm'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('junk_clear_junk_confirm'),
        'access arguments' => array('clear junk'),
        'type' => MENU_LOCAL_TASK,
        );
    

    Menu callback titles, and descriptions should not be passed to t() because that is already done by Drupal core code.

  4.    t(''),
    

    An empty string should not be passed to t(); you cannot translate an empty string, which is an emptry string independently from the language set.

  5.     if (variable_get('junk_unpublish',0))
        {
        	node_publish_action(&$node);
        	node_save($node);
        }
    

    See the Drupal coding standards to understand how a module code should be written. In particular, see the part about how to format the code.

  6.     drupal_set_message("Node restored from junk", 'status');
    

    The string is not translated.

  7. 	  '#options' => array(
    	    '0' => t('unlimited'), 
    	    '1' => t('1'), 
    	    '2' => t('2'),
    		'3' => t('3'),
    		'4' => t('4'),
    		'5' => t('5'),
    		'6' => t('6'),
    		'7' => t('7'),
    		'14' => t('14'),
    		'30' => t('30'),
    	  ),
    

    Is there a case where numbers need to be translated?

  8. function junk_admin_settings_submit($form, &$form_state)
    {
    	variable_set('junk_lifetime', $form_state['values']['junk_lifetime']);
    	variable_set('junk_hide_in_listings', $form_state['values']['junk_hide_in_listings']);
    	variable_set('junk_hide_in_views', $form_state['values']['junk_hide_in_views']);
    	variable_set('junk_unpublish', $form_state['values']['junk_unpublish']);
    	variable_set('junk_show_contents', $form_state['values']['junk_show_contents']);
    	drupal_set_message(t('Your changes have been saved.'));
    }
    

    If the module would call system_settings_form(), that code would not be necessary.

As there are already projects with the same purpose, the proposed module should first resolve the points I listed.

AliraSirin’s picture

Status: Needs work » Needs review
StatusFileSize
new15.46 KB

Thank you for the review! Here is the new version with fixed format and other points resolved.

avpaderno’s picture

Status: Needs review » Needs work
  1. The uninstallation function doesn't remove the Drupal variables used by the module.
  2. hook_enable() is settings two Drupal variables that the code doesn't use; if those variables are used from another module, then the code should first verify if that module is enabled.

  3. /*
     * Confirm deleteing junk form
     */
    function junk_clear_junk_confirm($form, &$form_state) {
      return confirm_form($form,
        t('Are you shure you want to empty junk?'),
    	'junk',
    	t('This action cannot be undone'),
    	t('Clear'),
    	t('Cancel')
      );
    }
    
AliraSirin’s picture

Thanks for the new review! Though I have some questions on the points:

1. About the variables in hook_enable() - this variables are used by CTools Page Manager module, Junk has a dependency on it defined in .info file. So it can't be enabled without Page Manager being enabled already. OG Panels module which uses CTools Page Manager same way doesn't check if it's enabled when setting variable on hook_enable(). So is it really necessary?

2. Could you please provide more detailes on this point?

avpaderno’s picture

If those variables are used from the module from which your module depends, then what I reported is not necessary. It's not clear if the names of the variables were not correct, so I pointed out that part of the code.
About the code reported in point #2, you wrote shure, when I guess you meant sure.

AliraSirin’s picture

Status: Needs work » Needs review
StatusFileSize
new15.53 KB

Ah, now I feel like an idiot with the second point :)

Here is an updated version with all points resolved.

avpaderno’s picture

Status: Needs review » Needs work

See comment #3, point #2.

AliraSirin’s picture

Status: Needs work » Needs review
StatusFileSize
new15.24 KB

I'm sorry. That's quite strange cause I remember fixing it.

avpaderno’s picture

Status: Needs review » Fixed

I apologize for the time it took me before to review the code.

AliraSirin’s picture

Thank you kiamlaluno and no need to apologize, I know you are quite busy here.

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.