Made to Order Software Corporation Logo

MO Auto Add Terms: mo_autoaddterms.module File Reference

Module functions of the auto-add-terms module. More...

Enumerations

enum  MO_AUTOADDTERMS_VERSION
 

Define the version of the MO Auto-Add Terms module.

More...

Functions

 mo_autoaddterms_perm ()
 Check for the list of permissions used in this module.
 mo_autoaddterms_help ($section)
 Display different help messages.
 mo_autoaddterms_form_alter (&$form, $form_state, $form_id)
 Grab all the node forms and alter them.
 mo_autoaddterms_form_node_type_form_alter (&$form, $form_state)
 Add a few fields in the Node Type.
 mo_autoaddterms_form_taxonomy_form_vocabulary_alter (&$form, $form_state)
 Add entries in the taxonomy vocabulary.
 mo_autoaddterms_form_taxonomy_form_term_alter (&$form, $form_state)
 Add entries in the taxonomy term.
 _mo_autoaddterms_validate ($form, &$form_state)
 Validation of the vocabulary form.
 _mo_autoaddterms_form_vocabulary_submit ($form, &$form_state)
 Handle saving the data submited by the vocabulary form.
 _mo_autoaddterms_terms_form_submit ($form, &$form_state)
 Save the submitted data when saving a term.
 mo_autoaddterms_form_settings_submit ($form, &$form_state)
 The submit function for the global settings.
 mo_autoaddterms_nodeapi (&$node, $op)
 Intercept the message to know each time a node is modified.
 mo_autoaddterms_comment ($comment, $op)
 Reset cache of node if a comment is updated/inserted.
 mo_autoaddterms_taxonomy ($op, $hook, $form_value)
 Detect when a taxonomy is being modified.
 mo_autoaddterms_menu ()
 Menu to edit the MO Auto add terms settings.
 mo_autoaddterms_hook_info ()
 Implementation of hook_hook_info().
 mo_autoaddterms_action_info_alter (&$actions)
 Alter the list of actions by adding us to different entries.
 mo_autoaddterms_cron ()
 Check a few nodes every now and then.

Detailed Description

The mo_autoaddterms module was created to let user(s) add terms to a taxonomy and automatically add all the terms that already exists to each node that include that word.

So for instance, if you create a node with the term "yellow" and later write a post with the word "yellow" in the post but "forget" to add it as a term, this module automatically adds it for you.

Plus, the module can be setup to automatically process existing nodes. So if you added a new term (i.e. yellow) to a new post, and have older nodes that included the same term, with time, these older nodes will also be assigned that new term.

For those who do not want to allow their users to enter words in their site index, this module will also includes the feature of hiding the taxonomy field in the Node add & edit windows. Since this feature has no special bearing on the fact that the category is an auto add term category, the hiding works for any taxonomy. It is also possible to designate a role with permission to edit that taxonomy. In other words, one role can be given permission to add new terms without having to edit the taxonomy, unhide, add terms, then re-hide.

By default, the system will add terms found in your node title and body. You can also search the comments and all of those are selectable or not depending on your needs (i.e. you may want to only scan titles).

Copyright (c) 2008-2011 Made to Order Software Corp.

http://www.m2osw.com/mo_glossary contact@m2osw.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Enumeration Type Documentation

This variable defines the version of the MO Auto-Add Terms module. This will always be the same as the version defined in Drupal (throught the .info file.)


Function Documentation

_mo_autoaddterms_form_vocabulary_submit ( form,
&$  form_state 
)

Implementation of the submit function for the hook_form_alter()

This function has the side effect of resetting the cache for the corresponding vocabulary.

Parameters:
[in] $form The form being submitted
[in,out] $form_state The current state of the form

References _mo_autoaddterms_autocheck(), _mo_autoaddterms_body(), _mo_autoaddterms_check_composed_terms(), _mo_autoaddterms_comments(), _mo_autoaddterms_hide(), _mo_autoaddterms_ifexist(), _mo_autoaddterms_only_parents(), _mo_autoaddterms_parents(), _mo_autoaddterms_render(), _mo_autoaddterms_reset_cache(), _mo_autoaddterms_selected(), _mo_autoaddterms_synonyms(), and _mo_autoaddterms_title().

_mo_autoaddterms_terms_form_submit ( form,
&$  form_state 
)

This function is the submit callback of the hook_form_alter() used when creating or editing a terms.

Parameters:
[in] $form The form being submitted
[in,out] $form_state The current state of the form
_mo_autoaddterms_validate ( form,
&$  form_state 
)

Implementation of the validation function to make sure that the user selects Multiple with this module (it won't be too useful otherwise!)

This way, we avoid issues of people telling us that it doesn't work for them!

When an error occurs, the form_set_error() function is called.

Parameters:
[in] $form The form being validated
[in,out] $form_state The status of the work
mo_autoaddterms_action_info_alter ( &$  actions  ) 

This function ensures that we can apply the minimum & maximum triggers to nodes and system actions.

Parameters:
[in,out] $actions Set of actions we want to tweak to suppor MO Auto add terms.
mo_autoaddterms_comment ( comment,
op 
)

This function resets the MO Auto add terms for the node that was just created or modified.

Bug:
This could be optimized to not reset the node terms in case the comment is not currently published. On the other hand, the update could mean a comment going from published to unpublished and the administrator selected "remove terms that are not defined in the node."
Parameters:
[in] $comment The comment that was just modified (an array)
[in] $op The operation on the comment

References _mo_autoaddterms_process_node().

mo_autoaddterms_cron (  ) 

This function runs whenever CRON wakes up. It uses the the mo_autoaddterm cache table to know which nodes to work on next.

Because we do not want to take too much time while processing nodes, we only process a very few at a time. By default we process AUTOADDTERMS_NODE_COUNT nodes.

References _mo_autoaddterms_auto_process_nodes().

mo_autoaddterms_form_alter ( &$  form,
form_state,
form_id 
)

Implementation of hook_form_alter().

This function adds a few entries to the node forms. The module is capable of hidding the taxonomy from the node form which is what this function is doing.

Parameters:
[in,out] $form The form to alter
[in] $form_state what state the form is in (i.e. submitted?)
[in] $form_id The identifier of this form

References _mo_autoaddterms_fix_node_form().

mo_autoaddterms_form_node_type_form_alter ( &$  form,
form_state 
)

MO Auto-add terms let you enter a minimum and maximum size for your titles on a per node type. This may just generates an error and prevent you from saving your node.

Parameters:
[in,out] $form The form to tweak.
[in] $form_state The current state of the form.

References mo_autoaddterms_node_type_form().

mo_autoaddterms_form_settings_submit ( form,
&$  form_state 
)

This function saves the mo_autoaddterms_node_count value in the database.

Parameters:
[in] $form The form being submitted
[in,out] $form_state The current state of the form
mo_autoaddterms_form_taxonomy_form_term_alter ( &$  form,
form_state 
)

This function intercepts the term form and adds a few widgets to handle the MO Auto add terms functionality.

Parameters:
[in,out] $form The form to alter
[in] $form_state what state the form is in (i.e. submitted?)

References mo_autoaddterms_terms_form().

mo_autoaddterms_form_taxonomy_form_vocabulary_alter ( &$  form,
form_state 
)

This function intercepts the vocabulary form and adds a few widgets to handle the MO Auto add terms functionality.

Parameters:
[in,out] $form The form to alter
[in] $form_state what state the form is in (i.e. submitted?)

References _mo_autoaddterms_edit_taxonomy_form_vocabulary().

mo_autoaddterms_help ( section  ) 

Implementation of hook_help().

Parameters:
[in] $section The section that requests a help message.
Returns:
A string with the help.
mo_autoaddterms_hook_info (  ) 

This function defines the list triggers that this module will generate. These triggers can be linked to an action by the user.

Returns:
An array of triggers.
mo_autoaddterms_menu (  ) 

This function returns an array of menu items.

Returns:
An array with all the MO Auto add terms menu items.
mo_autoaddterms_nodeapi ( &$  node,
op 
)

Implementation of hook_nodeapi().

We implement this one so nodes get processed "instantaneously". However, since users may add new terms all the time, old nodes also need to be processed. Those are worked on in the CRON process.

We intercept the 'insert' (creating a new node) and the 'update' (editing an existing node) operations for the purpose of automatic terms.

We intercept the 'validate' (before anything gets saved) to validate different parameters that are not otherwise offered by the system. (i.e. title length, content keywords, etc.)

Parameters:
[in,out] $node The node that has changed, new term list is returned
[in] $op The operation that was performed on the node

References _mo_autoaddterms_process_node(), and _mo_autoaddterms_validate_node().

mo_autoaddterms_perm (  ) 

Only the administrator has access these global settings by default. You need to edit the permissions to authorize other users to connect.

Returns:
An array of permissions.
mo_autoaddterms_taxonomy ( op,
hook,
form_value 
)

Whenever a taxonomy or one of its terms is being modified we want to clear the corresponding cache in the MO Auto-add terms.

Note:
We do reset the cache when a term was updated in case the term got new synonyms. This can be important.
Parameters:
[in] $op The operation being applied
[in] $hook Either 'vocabulary' or 'term'
[in] $form_value The data in the form

References _mo_autoaddterms_reset_cache().

Documentation generated by Doxygen on Sat Mar 12 16:05:17 2011