This patch adds an optional mode to add a checkbox widget to node and comment forms. It is modeled after the Flag form widget.

It also adds some extra settings to select which content types the widget will appear on, and whether the confirmation message should be displayed on form submit as a user notification.

Lastly, a bunch of refactoring so it would work someone gracefully and with minimal code reuse.

This is all powered from hooks and functions that could be called from any module.

Add Support for Other Mark Types

  1. Call mark_add_mark_form() in mark_form_alter() to add the Mark widget to the new form type.
  2. Call mark_apply_form_changes() from some hook that is fired on update/insert *and* has an object id. hook_nodeapi() and hook_comment() did it for me.
  3. Implement hook_mark_type_allowed_settings() for 'form_widget' or modify Mark's own implementation in mark.admin.inc.

Comments

Grayside’s picture

StatusFileSize
new10.89 KB

Forgot some debug code. Changed mark_load to return array() to avoid some warnings.

Grayside’s picture

StatusFileSize
new12.46 KB

Rerolled with helper function: mark_remove_mark_from_form(&$form, $name, $type = 'node', $object = NULL). Efficiently removes a mark from a form, and checks to see if the fieldset as a whole should be removed.

I'm not sure whether this should be here, but since it's general logic and will save other developers time working through how to do it effectively, I went for it. The patch is otherwise identical to #1.

Grayside’s picture

StatusFileSize
new12.38 KB

So of course I had a bug.

Grayside’s picture

StatusFileSize
new12.4 KB

Avoid foreach warning for nodes without a mark widget.

DjebbZ’s picture

Tested this patch in OpenAtrium 8 with the module OG Privacy and the feature inside the module which needs this precise patch. It produces this warning : Warning: Call-time pass-by-reference has been deprecated in /var/www/oa8/sites/all/modules/mark/mark.module on line 386
This line is the following : drupal_alter('mark_load', &$marks['names']);
When I change it to drupal_alter('mark_load', $marks['names']); (removed the '&' before $marks[...]) the warning vanishes, but I don't know if it will have side effects. What do you think ?

Grayside’s picture

That should be fine.

According to #920388: Patch to mark.module for feature og_privacy_atrium non applicable., the patch needs a reroll for the updates to Mark since it was originally created.

DjebbZ’s picture

StatusFileSize
new8.85 KB

I rerolled the patch against the last stable version of mark, included the rejects, and also the minor change in #5.

discipolo’s picture

according to http://drupal.org/node/966436#comment-3770870 the reroll doesnt work (initial tests on my side indicate the same) will try to get it to work and get another patch working.

discipolo’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0-beta4
StatusFileSize
new11.45 KB

i rerolled the patch against the current git version. hope it works