Projet

Général

Profil

Révision 6331c987

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/i18n/i18n_sync/i18n_sync.module
80 80
  }
81 81
}
82 82

  
83
/**
84
 * Implements hook_form_FORM_ID_alter().
85
 */
86
function i18n_sync_form_node_delete_confirm_alter(&$form, &$form_state) {
87
  // Intercept form submission so we can handle uploads, replace callback
88
  $form['#submit'] = array_merge(array('i18n_sync_node_delete_submit'), $form['#submit']);
89
}
90

  
91

  
92

  
93 83
/**
94 84
 * Implements hook_form_FORM_ID_alter().
95 85
 */
......
145 135
  }
146 136
}
147 137

  
148
/**
149
 * Submit callback for
150
 * - node delete confirm
151
 * - node multiple delete confirm
152
 */
153
function i18n_sync_node_delete_submit($form, $form_state) {
154
  if ($form_state['values']['confirm']) {
155
    if (!empty($form_state['values']['nid'])) {
156
      // Single node
157
      i18n_sync_node_delete_prepare($form_state['values']['nid']);
158
    }
159
    elseif (!empty($form_state['values']['nodes'])) {
160
      // Multiple nodes
161
      foreach ($form_state['values']['nodes'] as $nid => $value) {
162
        i18n_sync_node_delete_prepare($nid);
163
      }
164
    }
165
  }
166
  // Then it will go through normal form submission
167
}
168

  
169
/**
170
 * Prepare node for deletion, work out synchronization issues
171
 */
172
function i18n_sync_node_delete_prepare($nid) {
173
  $node = node_load($nid);
174
  // Delete file associations when files are shared with existing translations
175
  // so they are not removed by upload module
176
  if (!empty($node->tnid) && module_exists('upload')) {
177
    $result = db_query('SELECT u.* FROM {upload} u WHERE u.nid = %d AND u.fid IN (SELECT t.fid FROM {upload} t WHERE t.fid = u.fid AND t.nid <> u.nid)', $nid);
178
    while ($up = db_fetch_object($result)) {
179
      db_query("DELETE FROM {upload} WHERE fid = %d AND vid = %d", $up->fid, $up->vid);
180
    }
181
  }
182
}
183

  
184 138
/**
185 139
 * Check whether this node is to be synced
186 140
 */

Formats disponibles : Unified diff