Projet

Général

Profil

Révision a1051c43

Ajouté par Assos Assos il y a plus de 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform/webform.module
3988 3988
 * Check if current user has a draft of this webform, and return the sid.
3989 3989
 */
3990 3990
function _webform_fetch_draft_sid($nid, $uid) {
3991
  $q = db_select('webform_submissions')
3992
    ->fields('webform_submissions', array('sid'))
3993
    ->condition('nid', $nid)
3994
    ->condition('uid', $uid)
3995
    ->condition('is_draft', 1)
3996
    ->orderBy('submitted', 'DESC');
3997

  
3991 3998
  // Detect whether a webform draft is being edited. If so, that is the one that
3992 3999
  // should be returned.
3993
  if (isset($_POST['form_id']) && stripos($_POST['form_id'], 'webform_client_form_') === 0 &&
3994
      !empty($_POST['details']['sid']) && empty($_POST['details']['finished'])) {
3995
    // A draft is already being edited.
3996
    $sid = $_POST['details']['sid'];
4000
  $is_webform = isset($_POST['form_id']) && stripos($_POST['form_id'], 'webform_client_form_') === 0;
4001
  $sid_provided = !empty($_POST['details']['sid']) && is_string($_POST['details']['sid']);
4002
  $not_finished = empty($_POST['details']['finished']);
4003
  if ($is_webform && $sid_provided && $not_finished) {
4004
    // Validate that the sid from $_POST belongs to the current user.
4005
    $q->condition('sid', $_POST['details']['sid']);
4006
    $existing_sid = TRUE;
3997 4007
  }
3998
  else {
3999
    $sid = db_select('webform_submissions')
4000
      ->fields('webform_submissions', array('sid'))
4001
      ->condition('nid', $nid)
4002
      ->condition('uid', $uid)
4003
      ->condition('is_draft', 1)
4004
      ->orderBy('submitted', 'DESC')
4005
      ->execute()
4006
      ->fetchField();
4007 4008

  
4008
    if ($sid) {
4009
      $context = array(
4010
        'nid' => $nid,
4011
        'uid' => $uid,
4012
      );
4013
      drupal_alter('webform_draft', $sid, $context);
4014
    }
4009
  // Retrieve exisiting draft sid.
4010
  $sid = $q
4011
    ->execute()
4012
    ->fetchField();
4013

  
4014
  // Allow modules to alter the initial choice of sid when there might be more
4015
  // than one.
4016
  if ($sid && empty($existing_sid)) {
4017
    $context = array(
4018
      'nid' => $nid,
4019
      'uid' => $uid,
4020
    );
4021
    drupal_alter('webform_draft', $sid, $context);
4015 4022
  }
4016 4023
  return $sid;
4017 4024
}

Formats disponibles : Unified diff