Browse Source

updated view_send, vews_php, nodeformcols, email_registratio

Bachir Soussi Chiadmi 7 years ago
parent
commit
3b6c7b914d
20 changed files with 318 additions and 130 deletions
  1. 3 3
      sites/all/modules/contrib/admin/nodeformcols/nfcbiblio.info
  2. 3 3
      sites/all/modules/contrib/admin/nodeformcols/nfcbiblio.module
  3. 3 3
      sites/all/modules/contrib/admin/nodeformcols/nfccaptcha.info
  4. 18 2
      sites/all/modules/contrib/admin/nodeformcols/nodeformcols.admin.inc
  5. 3 3
      sites/all/modules/contrib/admin/nodeformcols/nodeformcols.info
  6. 3 3
      sites/all/modules/contrib/admin/nodeformcols/nodeformcols.module
  7. 6 0
      sites/all/modules/contrib/mail/views_send/CHANGELOG.txt
  8. 9 0
      sites/all/modules/contrib/mail/views_send/views_send.admin.inc
  9. 3 3
      sites/all/modules/contrib/mail/views_send/views_send.info
  10. 5 5
      sites/all/modules/contrib/mail/views_send/views_send.js
  11. 118 50
      sites/all/modules/contrib/mail/views_send/views_send.module
  12. 3 3
      sites/all/modules/contrib/users/email_registration/email_registration.info
  13. 7 0
      sites/all/modules/contrib/users/email_registration/email_registration.install
  14. 70 12
      sites/all/modules/contrib/users/email_registration/email_registration.module
  15. 33 12
      sites/all/modules/contrib/users/email_registration/email_registration.test
  16. 7 2
      sites/all/modules/contrib/views/views_php/plugins/views/views_php_handler_field.inc
  17. 12 0
      sites/all/modules/contrib/views/views_php/plugins/views/views_php_plugin_pager.inc
  18. 0 24
      sites/all/modules/contrib/views/views_php/views_php-2484407-10.patch
  19. 2 2
      sites/all/modules/contrib/views/views_php/views_php.info
  20. 10 0
      sites/all/modules/contrib/views/views_php/views_php.module

+ 3 - 3
sites/all/modules/contrib/admin/nodeformcols/nfcbiblio.info

@@ -5,9 +5,9 @@ dependencies[] = biblio
 core = 7.x
 package = Node form columns
 
-; Information added by Drupal.org packaging script on 2014-01-15
-version = "7.x-1.0"
+; Information added by Drupal.org packaging script on 2016-09-16
+version = "7.x-1.1"
 core = "7.x"
 project = "nodeformcols"
-datestamp = "1389798806"
+datestamp = "1474036440"
 

+ 3 - 3
sites/all/modules/contrib/admin/nodeformcols/nfcbiblio.module

@@ -19,7 +19,7 @@ function nfcbiblio_nodeformcols_variants_alter(&$variants, $type) {
       WHERE tid >= :tid
         AND visible = :visible
       ORDER BY weight ASC', array(':tid' => 0, ':visible' => 1));
-    while ($option = db_fetch_object($res)) {
+    while ($option = $res->fetchObject()) {
       $variants[$option->tid] = $option->name;
     }
   }
@@ -35,8 +35,8 @@ function _nfcbiblio_top_visible_type() {
   return db_query_range("SELECT tid
     FROM {biblio_types}
     WHERE visible = :visible
-      AND tid> = :tid>
-    ORDER BY weight ASC", array(':visible' => 1, ':tid>' => 0))->fetchField();
+    AND tid >= :tid
+    ORDER BY weight ASC", 0, 1, array(':visible' => 1, ':tid' => 0))->fetchField();
 }
 
 /**

+ 3 - 3
sites/all/modules/contrib/admin/nodeformcols/nfccaptcha.info

@@ -5,9 +5,9 @@ dependencies[] = captcha
 core = 7.x
 package = Node form columns
 
-; Information added by Drupal.org packaging script on 2014-01-15
-version = "7.x-1.0"
+; Information added by Drupal.org packaging script on 2016-09-16
+version = "7.x-1.1"
 core = "7.x"
 project = "nodeformcols"
-datestamp = "1389798806"
+datestamp = "1474036440"
 

+ 18 - 2
sites/all/modules/contrib/admin/nodeformcols/nodeformcols.admin.inc

@@ -21,6 +21,20 @@ function _nodeformcols_get_node_type_form($type) {
   );
   $fs += form_state_defaults();
   $nf = drupal_retrieve_form($nfid, $fs);
+  // Add in field_groups if they exist.
+  if (module_exists('field_group') && !empty($nf['#groups'])) {
+    foreach ($nf['#groups'] as $group) {
+      $group_title = $group->label . ' (' . t('Field group') . ')';
+      $nf[$group->group_name] = array(
+        '#group'  =>  $group,
+        '#weight' =>  $group->weight,
+        '#title'  =>  $group_title,
+      );
+      foreach ($nf['#groups'][$group->group_name]->children as $group_field) {
+        unset($nf[$group_field]);
+      }
+    }
+  }
   drupal_prepare_form($nfid, $nf, $fs);
   drupal_process_form($nfid, $nf, $fs);
   return $nf;
@@ -35,8 +49,10 @@ function nodeformcols_update_placements($type, $variant, &$placements) {
     $field = $form[$key];
     if (
       substr($key, 0, 8) == 'section_' ||
+      // Exclude hidden fields.
       (isset($field['#type']) && in_array($field['#type'], array('value', 'hidden', 'token'))) ||
-      (isset($field['#type'], $field['#group']) && $field['#type'] === 'fieldset')
+      // Exclude the vertical tabs.
+      (isset($field['#group']) && $field['#group'] == 'additional_settings')
     ) {
       // Remove placements that meet exclusion rules.
       if (isset($placements[$key])) {
@@ -128,7 +144,7 @@ function nodeformcols_configuration_form($form, $form_state, $node_type, $varian
     $form['variant'] = array(
       '#type' => 'item',
       '#title' => t('Select a form variant'),
-      '#value' => theme('links', array('links' => $variant_links)),
+      '#markup' => theme('links', array('links' => $variant_links)),
     );
   }
 

+ 3 - 3
sites/all/modules/contrib/admin/nodeformcols/nodeformcols.info

@@ -3,9 +3,9 @@ description = Separates the node forms into two columns and a footer.
 core = 7.x
 package = Node form columns
 
-; Information added by Drupal.org packaging script on 2014-01-15
-version = "7.x-1.0"
+; Information added by Drupal.org packaging script on 2016-09-16
+version = "7.x-1.1"
 core = "7.x"
 project = "nodeformcols"
-datestamp = "1389798806"
+datestamp = "1474036440"
 

+ 3 - 3
sites/all/modules/contrib/admin/nodeformcols/nodeformcols.module

@@ -160,8 +160,8 @@ function template_preprocess_node_form(&$aVars) {
     }
   }
 
-  foreach ($has_elements as $name => $has) {
-    if ($has) {
+  foreach ($regions as $name => $data) {
+    if (!empty($has_elements[$name])) {
       $class[] = 'node-form-has-region-' . $name;
       $form['nodeformcols_region_' . $name] = $regions[$name];
     }
@@ -191,8 +191,8 @@ function nodeformcols_node_type_update($info) {
     $base = 'nodeformscols_field_placements_' . $info->old_type;
     $new_base = 'nodeformscols_field_placements_' . $info->type;
     $result = db_select('variable')
-      ->condition('name', $base . '%', 'LIKE')
       ->fields('variable', array('name'))
+      ->condition('name', $base . '%', 'LIKE')
       ->execute();
     foreach ($result as $row) {
       $value = variable_get($row->name, NULL);

+ 6 - 0
sites/all/modules/contrib/mail/views_send/CHANGELOG.txt

@@ -1,3 +1,9 @@
+Views Send 7.x-1.2, 2016-03-29
+------------------------------
+#2237585 by hansfn: Make allowed file extensions for attachments configurable
+#2368533 by hansfn: Bypassing views render layer breaks all sort of things (Also fixes #1833608 Views field rewriting)
+#2693393 by hansfn: Mailsystem 3.x-dev requires "key" and "module" keys in the mail message
+
 Views Send 7.x-1.1, 2014-06-21
 ------------------------------
 #2225631 by hansfn: Using filter_fallback_format() instead of hard-coded value for message text format.

+ 9 - 0
sites/all/modules/contrib/mail/views_send/views_send.admin.inc

@@ -13,6 +13,15 @@
 function views_send_settings() {
   $form = array();
 
+  if (VIEWS_SEND_MIMEMAIL) {
+    $form['views_send_attachment_valid_extensions'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Valid file extensions for attachments'),
+      '#default_value' => variable_get('views_send_attachment_valid_extensions', ''),
+      '#description' => t('A space separated list of allowed file extensions for attachments. Leave the list empty if you want to use the default list from file_save_upload().'),
+    );
+  }
+
   $throttle = drupal_map_assoc(array(1, 10, 20, 30, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000));
   $throttle[0] = t('Unlimited');
 

+ 3 - 3
sites/all/modules/contrib/mail/views_send/views_send.info

@@ -8,9 +8,9 @@ core = 7.x
 files[] = views_send.rules.inc
 files[] = views/views_send_handler_field_selector.inc
 
-; Information added by Drupal.org packaging script on 2014-06-21
-version = "7.x-1.1"
+; Information added by Drupal.org packaging script on 2016-03-29
+version = "7.x-1.2"
 core = "7.x"
 project = "views_send"
-datestamp = "1403371134"
+datestamp = "1459239847"
 

+ 5 - 5
sites/all/modules/contrib/mail/views_send/views_send.js

@@ -14,7 +14,7 @@
     // This is the "select all" checkbox in (each) table header.
     $('.views-send-table-select-all', form).click(function() {
       var table = $(this).closest('table')[0];
-      $('input[id^="edit-views-send"]:not(:disabled)', table).attr('checked', this.checked);
+      $('input[id^="edit-views-send"]:not(:disabled)', table).attr('checked', this.checked).change();
     });
   }
 
@@ -23,21 +23,21 @@
     $('.views-send-select-all-markup', form).show();
 
     $('.views-send-select-this-page', form).click(function() {
-      $('input[id^="edit-views-send"]', form).attr('checked', this.checked);
+      $('input[id^="edit-views-send"]', form).attr('checked', this.checked).change();
 
       // Toggle the "select all" checkbox in grouped tables (if any).
-      $('.views-send-table-select-all', form).attr('checked', this.checked);
+      $('.views-send-table-select-all', form).attr('checked', this.checked).change();
     });
 
     $('.views-send-select', form).click(function() {
       // If a checkbox was deselected, uncheck any "select all" checkboxes.
       if (!this.checked) {
-        $('.views-send-select-this-page', form).attr('checked', false);
+        $('.views-send-select-this-page', form).attr('checked', false).change();
 
         var table = $(this).closest('table')[0];
         if (table) {
           // Uncheck the "select all" checkbox in the table header.
-          $('.views-send-table-select-all', table).attr('checked', false);
+          $('.views-send-table-select-all', table).attr('checked', false).change();
         }
       }
     });

+ 118 - 50
sites/all/modules/contrib/mail/views_send/views_send.module

@@ -56,7 +56,7 @@ function _views_send_mailsystem_set($key) {
  * @return
  *  The field object if found. Otherwise, FALSE.
  */
-function _views_send_get_field($view) {
+function _views_send_get_field_selector($view) {
   foreach ($view->field as $field_name => $field) {
     if ($field instanceof views_send_handler_field_selector) {
       // Add in the view object for convenience.
@@ -68,26 +68,30 @@ function _views_send_get_field($view) {
 }
 
 /**
- * Gets the raw field value from a result row in a view.
+ * Gets the field value from a result row in a view - rendered value (default),
+ * plain text or array with mail addresses.
  * 
  * @return
- *  An array with raw values from the field.
+ *  See description.
  */
-function _views_send_get_raw_field_from_views_row($view, $row_id, $field_id) {
-  $result = array();
-  $raw_value = $view->style_plugin->get_field_value($row_id, $field_id);
-  if (!is_array($raw_value)) {
-      $result[] = trim($raw_value);
-  } 
-  else { 
-    foreach ($raw_value as $arr) {
-      if (isset($arr['value'])) {
-        $value = $arr['value'];
-      } else {
-        list($value) = array_values($arr);
-      }
-      $result[] = trim($value);
-    }
+function _views_send_get_field_value_from_views_row($view, $row_id, $field_id, $type='') {
+  if (strpos($field_id, 'custom_text') === 0) {
+    // Handle the special case for custom text fields.
+    $field_id = str_replace('custom_text', 'nothing', $field_id);
+  }
+  $rendered_field = $view->style_plugin->get_field($row_id, $field_id);
+
+  if ($type == 'plain_text') {
+    // Removing HTML tags. Used for names in headers, not body.
+    $result = strip_tags($rendered_field);
+  }
+  elseif ($type == 'mail') {
+    // Removing HTML tags and entities. Used for e-mail addresses in headers, not body.
+    $result = explode(',', decode_entities(strip_tags($rendered_field)));
+    $result = array_map('trim', $result);
+  }
+  else {
+    $result = $rendered_field;
   }
   return $result;
 }
@@ -142,7 +146,7 @@ function theme_views_send_select_all($variables) {
  */
 function views_send_form_alter(&$form, &$form_state, $form_id) {
   if (strpos($form_id, 'views_form_') === 0) {
-    $field = _views_send_get_field($form_state['build_info']['args'][0]);
+    $field = _views_send_get_field_selector($form_state['build_info']['args'][0]);
   }
   // This form isn't used by Views Send.
   if (empty($field)) {
@@ -198,6 +202,10 @@ function views_send_form_alter(&$form, &$form_state, $form_id) {
  @TODO: Hide "Sender" (from) if Mandrill is used.
  */
 function views_send_config_form($form, &$form_state, $view, $output) {
+  if (!empty($form_state['configuration'])) {
+    // Values entered in the "config" step.
+    $config = $form_state['configuration'];
+  }
   $display = $view->name . ':' . $view->current_display;
   $form['display'] = array(
     '#type' => 'value',
@@ -213,7 +221,7 @@ function views_send_config_form($form, &$form_state, $view, $output) {
     '#type' => 'textfield',
     '#title' => t('Sender\'s name'),
     '#description' => t("Enter the sender's human readable name."),
-    '#default_value' => variable_get('views_send_from_name_' . $display, variable_get('site_name', '')),
+    '#default_value' => isset($config['views_send_from_name']) ? $config['views_send_from_name'] : variable_get('views_send_from_name_' . $display, variable_get('site_name', '')),
     '#maxlen' => 255,
   );
   $form['from']['views_send_from_mail'] = array(
@@ -221,7 +229,7 @@ function views_send_config_form($form, &$form_state, $view, $output) {
     '#title' => t('Sender\'s e-mail'),
     '#description' => t("Enter the sender's e-mail address."),
     '#required' => TRUE,
-    '#default_value' => variable_get('views_send_from_mail_' . $display, variable_get('site_mail', ini_get('sendmail_from'))),
+    '#default_value' => isset($config['views_send_from_mail']) ? $config['views_send_from_mail'] : variable_get('views_send_from_mail_' . $display, variable_get('site_mail', ini_get('sendmail_from'))),
     '#maxlen' => 255,
   );
 
@@ -246,14 +254,14 @@ function views_send_config_form($form, &$form_state, $view, $output) {
     '#title' => t('Field used for recipient\'s name'),
     '#description' => t('Select which field from the current view will be used as recipient\'s name.'),
     '#options' => $fields_options,
-    '#default_value' => variable_get('views_send_to_name_' . $display, ''),
+    '#default_value' => isset($config['views_send_to_name']) ? $config['views_send_to_name'] : variable_get('views_send_to_name_' . $display, ''),
   );
   $form['to']['views_send_to_mail'] = array(
     '#type' => 'select',
     '#title' => t('Field used for recipient\'s e-mail'),
     '#description' => t('Select which field from the current view will be used as recipient\'s e-mail.'),
     '#options' => $fields_options,
-    '#default_value' => variable_get('views_send_to_mail_' . $display, ''),
+    '#default_value' => isset($config['views_send_to_mail']) ? $config['views_send_to_mail'] : variable_get('views_send_to_mail_' . $display, ''),
     '#required' => TRUE,
   );
   $form['mail'] = array(
@@ -268,18 +276,28 @@ function views_send_config_form($form, &$form_state, $view, $output) {
     '#description' => t('Enter the e-mail\'s subject. You can use tokens in the subject.'),
     '#maxlen' => 255,
     '#required' => TRUE,
-    '#default_value' => variable_get('views_send_subject_' . $display, ''),
+    '#default_value' => isset($config['views_send_subject']) ? $config['views_send_subject'] : variable_get('views_send_subject_' . $display, ''),
   );
-  $saved_message = variable_get('views_send_message_' . $display);
   $form['mail']['views_send_message'] = array(
     '#type' => 'text_format',
-    '#format' => isset($saved_message['format']) ? $saved_message['format'] : filter_fallback_format(),
     '#title' => t('Message'),
     '#description' => t('Enter the body of the message. You can use tokens in the message.'),
     '#required' => TRUE,
     '#rows' => 10,
-    '#default_value' => isset($saved_message['value']) ? $saved_message['value'] : '',
   );
+  if (isset($config['views_send_message']['value'])) {
+    $form['mail']['views_send_message'] += array(
+      '#format' => $config['views_send_message']['format'],
+      '#default_value' => $config['views_send_message']['value'],
+    );
+  }
+  else {
+    $saved_message = variable_get('views_send_message_' . $display);
+    $form['mail']['views_send_message'] += array(
+      '#format' => isset($saved_message['format']) ? $saved_message['format'] : filter_fallback_format(),
+      '#default_value' => isset($saved_message['value']) ? $saved_message['value'] : '',
+    );
+  }
   $form['mail']['token'] = array(
     '#type' => 'fieldset',
     '#title' => t('Tokens'),
@@ -343,12 +361,12 @@ function views_send_config_form($form, &$form_state, $view, $output) {
       VIEWS_SEND_PRIORITY_LOWEST => t('lowest')
     ),
     '#description' => t('Note that e-mail priority is ignored by a lot of e-mail programs.'),
-    '#default_value' => variable_get('views_send_priority_' . $display, 0),
+    '#default_value' => isset($config['views_send_priority']) ? $config['views_send_priority'] : variable_get('views_send_priority_' . $display, 0),
   );
   $form['additional']['views_send_receipt'] = array(
     '#type' => 'checkbox',
     '#title' => t('Request receipt'),
-    '#default_value' => variable_get('views_send_receipt_' . $display, 0),
+    '#default_value' => isset($config['views_send_receipt']) ? $config['views_send_receipt'] : variable_get('views_send_receipt_' . $display, 0),
     '#description' => t('Request a Read Receipt from your e-mails. A lot of e-mail programs ignore these so it is not a definitive indication of how many people have read your message.'),
   );
   $form['additional']['views_send_headers'] = array(
@@ -356,18 +374,18 @@ function views_send_config_form($form, &$form_state, $view, $output) {
     '#title' => t('Additional headers'),
     '#description' => t("Additional headers to be send with the message. You'll have to enter one per line. Example:<pre>Reply-To: noreply@example.com\nX-MyCustomHeader: Whatever</pre>"),
     '#rows' => 4,
-    '#default_value' => variable_get('views_send_headers_' . $display, ''),
+    '#default_value' => isset($config['views_send_headers']) ? $config['views_send_headers'] : variable_get('views_send_headers_' . $display, ''),
   );
 
   $form['views_send_direct'] = array(
     '#type' => 'checkbox',
     '#title' => t('Send the message directly using the Batch API.'),
-    '#default_value' => variable_get('views_send_direct_'. $display, TRUE),
+    '#default_value' => isset($config['views_send_direct']) ? $config['views_send_direct'] : variable_get('views_send_direct_'. $display, TRUE),
   );
   $form['views_send_carbon_copy'] = array(
     '#type' => 'checkbox',
     '#title' => t('Send a copy of the message to the sender.'),
-    '#default_value' => variable_get('views_send_carbon_copy_' . $display, TRUE),
+    '#default_value' => isset($config['views_send_carbon_copy']) ? $config['views_send_carbon_copy'] : variable_get('views_send_carbon_copy_' . $display, TRUE),
   );
 
   $form['views_send_remember'] = array(
@@ -419,7 +437,7 @@ function views_send_config_form_validate($form, &$form_state) {
 
     $to_mail_field = $values['views_send_tokens'][$values['views_send_to_mail']];
     foreach ($form_state['selection'] as $row_id) {
-      $mail_addresses = _views_send_get_raw_field_from_views_row($view, $row_id, $to_mail_field);
+      $mail_addresses = _views_send_get_field_value_from_views_row($view, $row_id, $to_mail_field, 'mail');
       foreach ($mail_addresses as $mail_address) {
         if (!valid_email_address($mail_address)) {
           $wrong_addresses[$row_id] = $mail_address;
@@ -495,9 +513,9 @@ function views_send_confirm_form($form, &$form_state, $view, $output) {
   $to_mail_field = $configuration['views_send_tokens'][$configuration['views_send_to_mail']];
   foreach ($form_state['selection'] as $row_id) {
     if ($to_name_field) {
-      list($to_name) = _views_send_get_raw_field_from_views_row($view, $row_id, $to_name_field);
+      $to_name = _views_send_get_field_value_from_views_row($view, $row_id, $to_name_field, 'plain_text');
     }
-    $mail_addresses = _views_send_get_raw_field_from_views_row($view, $row_id, $to_mail_field);
+    $mail_addresses = _views_send_get_field_value_from_views_row($view, $row_id, $to_mail_field, 'mail');
     foreach ($mail_addresses as $mail_address) {
       $recipients[] = check_plain(empty($to_name) ? $mail_address : trim($to_name) . ' <' .  $mail_address . '>');
     }
@@ -546,6 +564,11 @@ function views_send_confirm_form($form, &$form_state, $view, $output) {
     '#attributes' => array('class' => array('form-actions')),
     '#weight' => 999,
   );
+  $form['actions']['back'] = array(
+    '#type' => 'submit',
+    '#value' => t('Go back'),
+    '#submit' => array('views_send_form_back_submit'),
+  );
   $form['actions']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Send'),
@@ -560,7 +583,7 @@ function views_send_confirm_form($form, &$form_state, $view, $output) {
  * Submit handler for all steps of the Views Send multistep form.
  */
 function views_send_form_submit($form, &$form_state) {
-  $field = _views_send_get_field($form_state['build_info']['args'][0]);
+  $field = _views_send_get_field_selector($form_state['build_info']['args'][0]);
 
   switch ($form_state['step']) {
     case 'views_form_views_form':
@@ -592,7 +615,15 @@ function views_send_form_submit($form, &$form_state) {
         // attempt to save the uploaded file
         $dir = file_default_scheme() . '://views_send_attachments';
         file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
-        $file = file_save_upload('views_send_attachments', array(), $dir);
+        $file_extensions = variable_get('views_send_attachment_valid_extensions', FALSE);
+        if ($file_extensions) {
+          $file_validators['file_validate_extensions'] = array();
+          $file_validators['file_validate_extensions'][0] = $file_extensions;
+        }
+        else {
+          $file_validators = array();
+        }
+        $file = file_save_upload('views_send_attachments', $file_validators, $dir);
         // set error if file was not uploaded
         if (!$file) {
           //form_set_error('views_send_attachment', 'Error uploading file.');
@@ -619,6 +650,18 @@ function views_send_form_submit($form, &$form_state) {
   }
 }
 
+/**
+ * Submit handler that handles back buttons.
+ */
+function views_send_form_back_submit($form, &$form_state) {
+  switch ($form_state['step']) {
+    case 'views_send_confirm_form':
+      $form_state['step'] = 'views_send_config_form';
+      $form_state['rebuild'] = TRUE;
+      break;
+  }
+}
+
 /**
  * Assembles the email and queues it for sending.
  *
@@ -656,11 +699,11 @@ function views_send_queue_mail($params, $selected_rows, $view) {
     $to_name_key = false;
     $to_name = '';
   }
-  foreach ($selected_rows as $row_id) {
+  foreach ($selected_rows as $selected_rows_key => $row_id) {
     // To: parts.
-    $to_mail = implode(',', _views_send_get_raw_field_from_views_row($view, $row_id, $to_mail_key));
+    $to_mail = implode(',', _views_send_get_field_value_from_views_row($view, $row_id, $to_mail_key, 'mail'));
     if ($to_name_key) {
-      list($to_name) = _views_send_get_raw_field_from_views_row($view, $row_id, $to_name_key);
+      $to_name = _views_send_get_field_value_from_views_row($view, $row_id, $to_name_key, 'plain_text');
     }
 
     $subject = $params['views_send_subject'];
@@ -679,7 +722,7 @@ function views_send_queue_mail($params, $selected_rows, $view) {
     $token_keys = $token_values = array();
     foreach ($params['views_send_tokens'] as $field_key => $field_name) {
       $token_keys[] = VIEWS_SEND_TOKEN_PREFIX .  sprintf(VIEWS_SEND_TOKEN_PATTERN, $field_name) . VIEWS_SEND_TOKEN_POSTFIX;
-      $token_values[] = $view->style_plugin->get_field($row_id, $field_name);
+      $token_values[] = _views_send_get_field_value_from_views_row($view, $row_id, $field_name);
     }
 
     // Views Send specific token replacements
@@ -736,16 +779,23 @@ function views_send_queue_mail($params, $selected_rows, $view) {
     }
     else {
       _views_send_prepare_mail($message, $plain_format, $attachments);
-      // Queue the message to the spool table.
-      db_insert('views_send_spool')->fields($message)->execute();
-      if (module_exists('rules')) {
-        rules_invoke_event('views_send_email_added_to_spool', $message);
+      // Only queue the message if it hasn't been cancelled by another module.
+      if ($message['send']) {
+        unset($message['send']);
+
+        db_insert('views_send_spool')->fields($message)->execute();
+        if (module_exists('rules')) {
+          rules_invoke_event('views_send_email_added_to_spool', $message);
+        }
+
+        // Enabled other modules to act just after a message is queued
+        // by providing the hook 'views_send_mail_queued'.
+        module_invoke_all('views_send_mail_queued', $message, $view, $row_id);
+      }
+      else {
+        unset($selected_rows[$selected_rows_key]);
       }
     }
-
-    // Enabled other modules to act just after a message is queued
-    // by providing the hook 'views_send_mail_queued'.
-    module_invoke_all('views_send_mail_queued', $message, $view, $row_id);
   }
 
   if ($params['views_send_direct']) {
@@ -1057,6 +1107,7 @@ function _views_send_prepare_mail(&$message, $plain_format=TRUE, $attachments=ar
   $message['from_mail'] = $mail['from'];
   $message['subject'] = $mail['subject'];
   $message['body'] = $mail['body'];
+  $message['send'] = $mail['send'];
   $message['headers'] = serialize($mail['headers']);
 }
 
@@ -1075,6 +1126,9 @@ function views_send_deliver($message) {
   $headers = unserialize($message->headers);
 
   $mail = array(
+    'id' => 'views_send_' . $key,
+    'module' => 'views_send',
+    'key' => $key,
     'to' => $message->to_mail,
     'from' => $message->from_mail,
     'subject' => $message->subject,
@@ -1099,6 +1153,15 @@ function views_send_deliver($message) {
  */
 function views_send_batch_deliver($message, $plain_format, $attachments, &$context) {
   _views_send_prepare_mail($message, $plain_format, $attachments);
+  if (!$message['send']) {
+    $context['results'][] = t('Skipping sending message to %mail.',
+      array('%mail' => $message['to_mail']));
+    return;
+  }
+  else {
+    unset($message['send']);
+  }
+  
   $status = views_send_deliver($message);
 
   if ($status) {
@@ -1214,7 +1277,12 @@ function _views_send_get_fields_and_tokens($view, $type) {
     if (property_exists($field, 'views_form_callback') || method_exists($field, 'views_form')) {
       continue;
     }
-    if (!empty($field->field_info)) {
+    if ($field instanceof views_handler_field_custom) {
+      $field_key = $field_name;
+      // Using a nice field name (for tokens) for custom text fields.
+      $field_name = str_replace('nothing', 'custom_text', $field_name);;
+    } 
+    elseif (!empty($field->field_info)) {
       $field_key = $field->field_info['field_name'];
     }
     elseif (property_exists($field, 'field_alias')) {

+ 3 - 3
sites/all/modules/contrib/users/email_registration/email_registration.info

@@ -3,9 +3,9 @@ description = Allows users to register with an e-mail address as their username.
 files[] = email_registration.test
 core = 7.x
 
-; Information added by Drupal.org packaging script on 2014-04-23
-version = "7.x-1.2"
+; Information added by Drupal.org packaging script on 2015-10-05
+version = "7.x-1.3"
 core = "7.x"
 project = "email_registration"
-datestamp = "1398265775"
+datestamp = "1444050240"
 

+ 7 - 0
sites/all/modules/contrib/users/email_registration/email_registration.install

@@ -23,3 +23,10 @@ function email_registration_requirements() {
 
   return $requirements;
 }
+
+/**
+ * Implements hook_uninstall().
+ */
+function email_registration_uninstall() {
+  variable_del('email_registration_login_with_username');
+}

+ 70 - 12
sites/all/modules/contrib/users/email_registration/email_registration.module

@@ -53,7 +53,9 @@ function email_registration_user_insert(&$edit, &$account, $category = NULL) {
  * /admin/people/create forms which have already called user_validate_name,
  * valid_email_address or a similar function. If your custom code is creating
  * users, you should ensure that the email/name is already validated using
- * something like that.
+ * something like that. Alternatively you can prepend the account user name
+ * to contain 'email_registration_' to allow for the email registration hooks
+ * to generate a unique username based on mail.
  *
  * @param string $name
  *   A name from which to base the final user name.  May contain illegal
@@ -67,12 +69,18 @@ function email_registration_user_insert(&$edit, &$account, $category = NULL) {
  *
  * @see user_validate_name()
  */
-function email_registration_unique_username($name, $uid) {
+function email_registration_unique_username($name, $uid = NULL) {
   // Iterate until we find a unique name.
   $i = 0;
   do {
     $new_name = empty($i) ? $name : $name . '_' . $i;
-    $found = db_query_range("SELECT uid from {users} WHERE uid <> :uid AND name = :name", 0, 1, array(':uid' => $uid, ':name' => $new_name))->fetchAssoc();
+    if ($uid) {
+      $found = db_query_range("SELECT uid from {users} WHERE uid <> :uid AND name = :name", 0, 1, array(':uid' => $uid, ':name' => $new_name))->fetchAssoc();
+    }
+    else {
+      $found = db_query_range("SELECT uid from {users} WHERE name = :name", 0, 1, array(':name' => $new_name))->fetchAssoc();
+    }
+
     $i++;
   } while (!empty($found));
 
@@ -100,7 +108,7 @@ function email_registration_cleanup_username($name, $uid = NULL) {
   $name = trim($name);
 
   // Convert any other series of spaces to a single underscore.
-  $name = preg_replace('/  +/', '_', $name);
+  $name = preg_replace('/\s+/', '_', $name);
 
   // If there's nothing left use a default.
   $name = ('' === $name) ? t('user') : $name;
@@ -135,8 +143,12 @@ function email_registration_form_user_pass_alter(&$form, &$form_state) {
  * Implements hook_form_FORM_ID_alter().
  */
 function email_registration_form_user_login_alter(&$form, &$form_state) {
-  $form['name']['#title'] = t('E-mail');
-  $form['name']['#description'] = t('Enter your e-mail address.');
+  $form['name']['#title'] = variable_get('email_registration_login_with_username', TRUE)
+    ? t('E-mail or username')
+    : t('E-mail');
+  $form['name']['#description'] = variable_get('email_registration_login_with_username', TRUE)
+      ? t('Enter your e-mail address or username.')
+      : t('Enter your e-mail address.');
   $form['name']['#element_validate'][] = 'email_registration_user_login_validate';
   $form['pass']['#description'] = t('Enter the password that accompanies your e-mail.');
 }
@@ -145,22 +157,68 @@ function email_registration_form_user_login_alter(&$form, &$form_state) {
  * Implements hook_form_FORM_ID_alter().
  */
 function email_registration_form_user_login_block_alter(&$form, &$form_state) {
-  $form['name']['#title'] = t('E-mail');
+  $form['name']['#title'] = variable_get('email_registration_login_with_username', TRUE)
+    ? t('E-mail or username')
+    : t('E-mail');
   $form['name']['#element_validate'][] = 'email_registration_user_login_validate';
 }
 
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function email_registration_form_user_admin_settings_alter(&$form, &$form_state) {
+  $form['registration_cancellation']['email_registration_login_with_username'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow users login with e-mail or username.'),
+    '#description' => t('Allow users to login with their username in addition to their e-mail.'),
+    '#default_value' => variable_get('email_registration_login_with_username', TRUE),
+    );
+  $form['#submit'][] = 'email_registration_form_user_admin_settings_submit';
+}
+
+/**
+ * Submit function for user_admin_settings to save our variable.
+ *
+ * @see email_registration_form_user_admin_settings_alter().
+ */
+function email_registration_form_user_admin_settings_submit($form, &$form_state) {
+  variable_set('email_registration_login_with_username', $form_state['values']['email_registration_login_with_username']);
+}
+
+
 /**
  * Form element validation handler for the user login form.
  *
  * Allows users to authenticate by email, which is our preferred method.
  */
 function email_registration_user_login_validate($form, &$form_state) {
-  if (isset($form_state['values']['name'])) {
-    // Keep the email value in form state for further validation.
+  $name = NULL;
+  if (isset($form_state['values']['name']) && valid_email_address($form_state['values']['name'])) {
+    // Try to load the username matching the email, if any exists.
+    $name = db_select('users')
+    ->fields('users', array('name'))
+    ->condition('mail', db_like($form_state['values']['name']), 'LIKE')
+    ->execute()
+    ->fetchField();
+  }
+  // If the value is set, and a valid email, and a match was found, use it.
+  if (!empty($name)) {
+    // Keep the email value in form state for further use/validation.
     $form_state['values']['email'] = $form_state['values']['name'];
-    if ($name = db_query('SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:name)', array(':name' => $form_state['values']['name']))->fetchField()) {
-      $form_state['values']['name'] = $name;
-    }
+
+    // If the name matches an e-mail, assume that it's the desired name and
+    // set the username in the form values.
+    $form_state['values']['name'] = $name;
+  }
+  elseif (!variable_get('email_registration_login_with_username', TRUE)) {
+    // If no username was found for the e-mail, and registration with username
+    // is not allowed, unset the name from the form. This prevents
+    // user_login_authenticate_validate() from trying to load a user from the
+    // value as a username, which in turn causes user_login_final_validate()
+    // to set a form error telling the user that no account has been found.
+    // We have to set this to NULL rather than FALSE, because
+    // user_login_name_validate() uses isset() rather than empty().
+    $form_state['values']['name'] = NULL;
   }
 }
 

+ 33 - 12
sites/all/modules/contrib/users/email_registration/email_registration.test

@@ -6,23 +6,26 @@
  */
 
 class EmailRegistrationTestCase extends DrupalWebTestCase {
+
   /**
-   * Implementation of getInfo().
+   * Implement getInfo().
    */
   public static function getInfo() {
     return array(
-      'name' => t('Email registration.'),
-      'description' => t('Test the email registration module.'),
-      'group' => t('Email registration'),
+      'name' => 'Email registration.',
+      'description' => 'Test the email registration module.',
+      'group' => 'Email registration',
     );
   }
 
   /**
-   * Implementation of setUp().
+   * {@inheritdoc}
    */
   public function setUp() {
     parent::setUp('email_registration');
 
+    // Allow user registration.
+    variable_set('user_register', USER_REGISTER_VISITORS);
     // Configure to allow set password.
     variable_set('user_email_verification', FALSE);
   }
@@ -31,7 +34,6 @@ class EmailRegistrationTestCase extends DrupalWebTestCase {
    * Test various behaviors for anonymous users.
    */
   public function testRegistration() {
-    variable_set('user_register', USER_REGISTER_VISITORS);
     // Try to register a user.
     $name = $this->randomName();
     $pass = $this->randomName(10);
@@ -49,16 +51,15 @@ class EmailRegistrationTestCase extends DrupalWebTestCase {
     );
     $this->drupalPost('user/login', $login, t('Log in'));
 
-    // Get the uid.
-    $accounts = user_load_multiple(array(), array('mail' => $name . '@example.com'));
-    $new_user = reset($accounts);
+    // Get the account to get uid.
+    $new_user = user_load_by_mail($name . '@example.com');
+    $new_name = $name . '_' . $new_user->uid;
 
     // Confirm the user was created and logged in with expected username.
-    $this->assertRaw('<title>' . $name . '_' . $new_user->uid . ' | Drupal</title>', t('User properly created, logged in.'));
+    $this->assertTitle($new_name . ' | Drupal', 'User properly created, logged in.');
 
     // Now try the immediate login.
     $this->drupalLogout();
-    variable_set('user_email_verification', 0);
     $name = $this->randomName();
     $pass = $this->randomName(10);
     $register = array(
@@ -67,7 +68,27 @@ class EmailRegistrationTestCase extends DrupalWebTestCase {
       'pass[pass2]' => $pass,
     );
     $this->drupalPost('/user/register', $register, t('Create new account'));
-    $this->assertRaw('Registration successful. You are now logged in.', t('User properly created, immediately logged in.'));
+    $this->assertRaw('Registration successful. You are now logged in.', 'User properly created, immediately logged in.');
+
+    // Try to login with just username, should succeed by default.
+    $this->drupalLogout();
+
+    // User name appended with UID see email_registration_cleanup_username().
+    $new_user = user_load_by_mail($name . '@example.com');
+    $new_name = $name . '_' . $new_user->uid;
+    $login = array(
+      'name' => $new_name,
+      'pass' => $pass,
+    );
+    $this->drupalPost('user/login', $login, t('Log in'));
+
+    $this->assertTitle($new_name . ' | Drupal', 'By default, username can log in.');
+    $this->drupalLogout();
+
+    // Disallow logins with username and try to login with just username, should fail.
+    variable_set('email_registration_login_with_username', FALSE);
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertTitle('User account | Drupal', 'When disabled, a user cannot login with just their username.');
   }
 
 }

+ 7 - 2
sites/all/modules/contrib/views/views_php/plugins/views/views_php_handler_field.inc

@@ -225,8 +225,13 @@ class views_php_handler_field extends views_handler_field {
       $value = ob_get_clean();
     }
     else {
-      $value = check_plain($values->{$this->field_alias});
+      if (isset($values->{$this->field_alias})) {
+        $value = check_plain($values->{$this->field_alias});
+      }
+    }
+
+    if (isset($value)) {
+      return $value;
     }
-    return $value;
   }
 }

+ 12 - 0
sites/all/modules/contrib/views/views_php/plugins/views/views_php_plugin_pager.inc

@@ -47,9 +47,21 @@ class views_php_plugin_pager extends views_php_plugin_wrapper  {
         }
       }
     }
+    $this->update_wrapped_pager();
     $this->php_unwrap();
   }
 
+  protected function update_wrapped_pager() {
+    $this->wrapped->total_items = count($this->wrapped->view->result);
+    $this->wrapped->update_page_info();
+
+    $item_per_page = $this->wrapped->get_items_per_page();
+    if ($item_per_page > 0) {
+      $offset = $this->wrapped->get_current_page() * $item_per_page + $this->wrapped->get_offset();
+      $this->wrapped->view->result = array_slice($this->wrapped->view->result, $offset, $item_per_page);
+    }
+  }
+
   /**
    * Execute the count query, which will be done just prior to the query
    * itself being executed.

+ 0 - 24
sites/all/modules/contrib/views/views_php/views_php-2484407-10.patch

@@ -1,24 +0,0 @@
-diff --git a/plugins/views/views_php_plugin_pager.inc b/plugins/views/views_php_plugin_pager.inc
-index bb7d2d9..5ffa123 100644
---- a/plugins/views/views_php_plugin_pager.inc
-+++ b/plugins/views/views_php_plugin_pager.inc
-@@ -47,19 +47,7 @@
-         }
-       }
-     }
--    $this->update_wrapped_pager();
-     $this->php_unwrap();
--  }
--
--  protected function update_wrapped_pager() {
--    $this->wrapped->total_items = count($this->wrapped->view->result);
--    $this->wrapped->update_page_info();
--
--    $item_per_page = $this->wrapped->get_items_per_page();
--    if ($item_per_page > 0) {
--      $offset = $this->wrapped->get_current_page() * $item_per_page + $this->wrapped->get_offset();
--      $this->wrapped->view->result = array_slice($this->wrapped->view->result, $offset, $item_per_page);
--    }
-   }
- 
-   /**

+ 2 - 2
sites/all/modules/contrib/views/views_php/views_php.info

@@ -15,9 +15,9 @@ files[] = plugins/views/views_php_plugin_pager.inc
 files[] = plugins/views/views_php_plugin_query.inc
 files[] = plugins/views/views_php_plugin_wrapper.inc
 
-; Information added by Drupal.org packaging script on 2015-04-21
+; Information added by Drupal.org packaging script on 2015-11-13
 version = "7.x-2.x-dev"
 core = "7.x"
 project = "views_php"
-datestamp = "1429645983"
+datestamp = "1447432844"
 

+ 10 - 0
sites/all/modules/contrib/views/views_php/views_php.module

@@ -157,3 +157,13 @@ function views_php_views_post_render($view) {
     $view->query->php_unwrap();
   }
 }
+
+/**
+ * Implements hook_views_post_build().
+ */
+function views_php_views_post_build($view) {
+  // Clear the limit and offset
+  if (!empty($view->views_php) && !empty($view->build_info['query']) && is_object($view->build_info['query'])) {
+    $view->build_info['query']->range();
+  }
+}