/[drupal]/contributions/modules/hierarchical_select/modules/hs_subscriptions_taxonomy.module
ViewVC logotype

Diff of /contributions/modules/hierarchical_select/modules/hs_subscriptions_taxonomy.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4, Wed Sep 17 21:36:54 2008 UTC revision 1.5, Mon Dec 1 02:21:17 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: hs_subscriptions_taxonomy.module,v 1.3 2008/07/16 21:12:23 wimleers Exp $  // $Id: hs_subscriptions_taxonomy.module,v 1.4 2008/09/17 21:36:54 wimleers Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 34  function hs_subscriptions_taxonomy_form_ Line 34  function hs_subscriptions_taxonomy_form_
34    
35          // 1) Extract the tids of the selected terms.          // 1) Extract the tids of the selected terms.
36          // 2) Make the checkboxes value form elements, to keep the form          // 2) Make the checkboxes value form elements, to keep the form
37          // structure (and the $form_values structure) the same as the original.          // structure (and the $form_state['values'] structure) the same as the original.
38          $selected_tids = array();          $selected_tids = array();
39          foreach ($form[$name]['checkboxes'] as $tid => $element) {          foreach ($form[$name]['checkboxes'] as $tid => $element) {
40            // Selected?            // Selected?
# Line 91  function hs_subscriptions_taxonomy_form_ Line 91  function hs_subscriptions_taxonomy_form_
91  /**  /**
92   * Validate callback; per-user taxonomy subscriptions form.   * Validate callback; per-user taxonomy subscriptions form.
93   */   */
94  function hs_subscriptions_taxonomy_validate($form_id, $form_values, $form) {  function hs_subscriptions_taxonomy_validate($form_id, $form_state['values'], $form) {
95    if ($form_id == 'subscriptions_taxonomy_taxa_form') {    if ($form_id == 'subscriptions_taxonomy_taxa_form') {
96      foreach ($form_values as $vid => $element) {      foreach ($form_state['values'] as $vid => $element) {
97        if (is_numeric($vid)) {        if (is_numeric($vid)) {
98    
99          // Collect the tids of the selected terms.          // Collect the tids of the selected terms.
100          $selected_tids = array();          $selected_tids = array();
101          foreach ($form_values[$vid]['select'] as $tid) {          foreach ($form_state['values'][$vid]['select'] as $tid) {
102            $selected_tids[] = $tid;            $selected_tids[] = $tid;
103          }          }
104    
# Line 106  function hs_subscriptions_taxonomy_valid Line 106  function hs_subscriptions_taxonomy_valid
106          // - When it's in the set of selected tids, then set it to 1.          // - When it's in the set of selected tids, then set it to 1.
107          // - When it's *not* in the set of selected tids, and its current value          // - When it's *not* in the set of selected tids, and its current value
108          //   is 1, then set it to 0.          //   is 1, then set it to 0.
109          foreach ($form_values[$vid]['checkboxes'] as $tid => $array) {          foreach ($form_state['values'][$vid]['checkboxes'] as $tid => $array) {
110            if (!in_array($tid, $selected_tids) && $form_values[$vid]['checkboxes'][$tid][-1] == 1) {            if (!in_array($tid, $selected_tids) && $form_state['values'][$vid]['checkboxes'][$tid][-1] == 1) {
111              form_set_value($form[$vid]['checkboxes'][$tid][-1], 0);              form_set_value($form[$vid]['checkboxes'][$tid][-1], 0);
112            }            }
113            else if (in_array($tid, $selected_tids)) {            else if (in_array($tid, $selected_tids)) {

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.2