/[drupal]/contributions/modules/fivestar/fivestar.install
ViewVC logotype

Diff of /contributions/modules/fivestar/fivestar.install

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

revision 1.1.2.6, Mon Jun 30 03:40:18 2008 UTC revision 1.1.2.7, Tue Jul 1 04:42:08 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: fivestar.install,v 1.1.2.5 2008/03/12 06:57:24 quicksketch Exp $  // $Id: fivestar.install,v 1.1.2.6 2008/06/30 03:40:18 quicksketch Exp $
3    
4  // Get the current schema so that updates that have already run for 5 don't get  // Get the current schema so that updates that have already run for 5 don't get
5  // run a second time when upgrading to 6.  // run a second time when upgrading to 6.
# Line 85  function fivestar_update_5702() { Line 85  function fivestar_update_5702() {
85      }      }
86    }    }
87    return array();    return array();
88    }
89    
90    
91    /**
92     * Update CCK target logic to rename "target" to "php_target".
93     */
94    function fivestar_update_5703() {
95      $result = db_query("SELECT field_name, global_settings FROM {node_field} WHERE type = 'fivestar'");
96      while ($field = db_fetch_object($result)) {
97        $settings = unserialize($field->global_settings);
98        if (!empty($settings['target'])) {
99          if (is_numeric($settings['target'])) {
100            // If previously a straight-integer, just add a "return" to the number.
101            $settings['php_target'] = 'return '. $settings['target'] .';';
102          }
103          else {
104            // If already PHP code, remove the PHP brackets.
105            $php = trim($settings['target']);
106            $php = preg_replace('/^<\?(php)?/', '', $php);
107            $php = preg_replace('/\?>$/', '', $php);
108            $settings['php_target'] = $php;
109          }
110        }
111        unset($settings['target']);
112        unset($settings['php']);
113        db_query("UPDATE {node_field} SET global_settings = '%s' WHERE field_name = '%s'", serialize($settings), $field->field_name);
114      }
115      return array();
116  }  }

Legend:
Removed from v.1.1.2.6  
changed lines
  Added in v.1.1.2.7

  ViewVC Help
Powered by ViewVC 1.1.2