/[drupal]/contributions/modules/flag/includes/flag.export.inc
ViewVC logotype

Diff of /contributions/modules/flag/includes/flag.export.inc

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

revision 1.1.2.1, Wed Oct 28 00:31:47 2009 UTC revision 1.1.2.2, Tue Nov 3 02:10:45 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: flag.export.inc,v 1.1.2.1 2009/10/28 00:31:47 quicksketch Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 136  function flag_import_form_submit($form, Line 136  function flag_import_form_submit($form,
136  /**  /**
137   * Export a flag and display it in a form.   * Export a flag and display it in a form.
138   */   */
139  function flag_export_form(&$form_state, $flag_name = NULL) {  function flag_export_form(&$form_state, $flag = NULL) {
140    $form = array();    $form = array();
141    
142    // Convert a flag name (if any) to the list of export flags.    // Convert a flag name (if any) to the list of export flags.
143    if ($flag = flag_get_flag($flag_name)) {    if (is_object($flag) || ($flag = flag_get_flag($flag))) {
144      $flags = array($flag);      $flags = array($flag);
145    }    }
146    
# Line 193  function flag_export_form(&$form_state, Line 193  function flag_export_form(&$form_state,
193  function flag_export_form_submit($form, &$form_state) {  function flag_export_form_submit($form, &$form_state) {
194    $form_state['rebuild'] = TRUE;    $form_state['rebuild'] = TRUE;
195  }  }
196    
197    /**
198     * Page for displaying an upgrade message and export form for Flag 1.x flags.
199     */
200    function flag_update_page($flag_name) {
201      $flags = flag_get_default_flags(TRUE);
202      if (!isset($flags[$flag_name])) {
203        drupal_not_found();
204        return;
205      }
206    
207      if ($flags[$flag_name]->api_version == FLAG_API_VERSION) {
208        drupal_set_message(t('The flag %name is already up-to-date with the latest Flag API and does not need upgrading.'));
209        drupal_goto('admin/build/flags');
210      }
211    
212      $flag = $flags[$flag_name];
213      drupal_set_message(t('The flag %name is currently using the Flag API version @version, which is not compatible with the current version of Flag. You can upgrade this flag by pasting the below code into <em>@module_flag_default_flags()</em> function in the @module.module file.', array('%name' => $flag->name, '@version' => $flag->api_version, '@module' => $flag->module)), 'warning');
214    
215      flag_update_export($flag);
216    
217      return drupal_get_form('flag_export_form', $flag);
218    }
219    
220    /**
221     * Update a flag before export.
222     *
223     * @param $flag
224     *   The flag object passed by reference.
225     */
226    function flag_update_export(&$flag) {
227      // Update differences.
228      if (empty($flag->api_version) || $flag->api_version == 1) {
229        if (isset($flag->roles) && !isset($flag->roles['flag'])) {
230          $flag->roles = array(
231            'flag' => $flag->roles,
232            'unflag' => $flag->roles,
233          );
234        }
235        $flag->api_version = FLAG_API_VERSION;
236      }
237    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2