[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/form/field_types/email/ -> email.php (source)

   1  <?php
   2  class MP_Form_field_type_email extends MP_form_field_type_
   3  {
   4      var $file    = __FILE__;
   5  
   6      var $id    = 'email';
   7  
   8      var $category = 'html';
   9      var $order    = 15;
  10  
  11  	function submitted($field)
  12      {
  13          $value    = trim($_POST[$this->prefix][$field->form_id][$field->id]);
  14  
  15          $required     = (isset($field->settings['controls']['required']) && $field->settings['controls']['required']);
  16          $empty     = empty($value);
  17          $is_email     = is_email($value);
  18          if ($required)
  19          {
  20              if ($empty)
  21              {
  22                  $field->submitted['on_error'] = 1;
  23                  return $field;
  24              }
  25              if (!$is_email)
  26              {
  27                  $field->submitted['on_error'] = 2;
  28                  return $field;
  29              }
  30          }
  31          if (!$empty && !$is_email)
  32          {
  33              $field->submitted['on_error'] = 3;
  34              return $field;
  35          }
  36          return parent::submitted($field);
  37      }
  38  
  39  	function attributes_filter($no_reset)
  40      {
  41          $visitor_email = ( isset($this->field->settings['options']['visitor_email']) && $this->field->settings['options']['visitor_email'] );
  42          if ( $visitor_email )
  43          {
  44              global $user_ID; switch (true) { case ($user_ID != 0 && is_numeric($user_ID) ) : $user  = get_userdata($user_ID); $email = $user->user_email; break; default : $email = (isset($_COOKIE['comment_author_email_' . COOKIEHASH])) ? $_COOKIE['comment_author_email_' . COOKIEHASH] : ''; break; }
  45              if ( !empty($email) ) $this->field->settings['attributes']['value'] = $email;
  46          }
  47  
  48          if (!$no_reset) return;
  49  
  50          parent::attributes_filter($no_reset);
  51          $this->attributes_filter_css();
  52      }
  53  }
  54  new MP_Form_field_type_email(__('Email', MP_TXTDOM));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1