Source for file DBMS_FIELD_EMAILADDR.phpclass

Documentation is available at DBMS_FIELD_EMAILADDR.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_EMAILADDR.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   string
  8.   *
  9.   * @author     Peter Krebs <p.krebs@lvus.at>
  10.   * @copyright  (c) 2002-2005 by LVUS
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   * @since pk-04-08-26
  14.   * @version pk-05-02-10
  15.   *
  16.   ***/
  17.  
  18. pcf_require_class('DBMS_FIELD',dirname(__FILE__)."/DBMS_FIELD.phpclass");
  19.  
  20. /**
  21.   * Class DBMS_FIELD_EMAILADDR
  22.   *
  23.   * @project    Open CSP-Management
  24.   * @package    dbms_field
  25.   * @category   string
  26.   *
  27.   * @author     Peter Krebs <p.krebs@lvus.at>
  28.   * @copyright  (c) 2002-2005 by LVUS
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @since pk-04-08-26
  32.   * @version pk-05-02-10
  33.   *
  34.   ***/
  35. class DBMS_FIELD_EMAILADDR extends DBMS_FIELD {
  36.  
  37.     // ###########################################################
  38.     // OBJECT (CONST) VAR DECLARATION
  39.     // ###########################################################
  40.  
  41.     /**
  42.       * @var string $className Label of the class
  43.       ***/
  44.     var $className     = "E-MailAddress";
  45.  
  46.     /**
  47.       * @var string $noAddrErrMsg error message if not a valid email address
  48.       ***/
  49.     var $noAddrErrMsg  = "Ihre Eingabe ist keine gltige E-Mail Adresse";
  50.  
  51.     /**
  52.       * @var boolean $dnsCheckDomain 
  53.       * @since pk-05-02-10
  54.       ***/
  55.     var $dnsCheckDomain = False;
  56.  
  57.     /**
  58.       * @var string $noMxErrMsg error message if no mx server was found for the domain
  59.       * @since pk-05-02-10
  60.       ***/
  61.     var $noMxErrMsg = "Es konnte kein Mailserver fr diese Adresse gefunden werden";
  62.  
  63.     /**
  64.       * source file of the class
  65.       * (without $GLOBALS['PROJECT']['PATH']
  66.       *
  67.       * @var string $classSrcFile 
  68.       * @since pk-05-01-11
  69.       ***/
  70.     var $classSrcFile=__FILE__;
  71.  
  72.  
  73.     // ###########################################################
  74.     // OBJECT SETTINGS METHODS
  75.     // ###########################################################
  76.  
  77.  
  78.     /**
  79.       * returns an array of field to bie shown in the edit form
  80.       * by using editTbl_echoForm
  81.       *
  82.       * the array is in the form:
  83.       *
  84.       * <code>
  85.       * [_sectionName_]
  86.       *      [TITLE] -> string
  87.       *      [_rowName_]
  88.       *         [FLDLAB]  (complete html code with <td></td>)
  89.       *         [FLDVAL] (complete html code with <td></td>)
  90.       *         [FLDTIT] (title of the label column)
  91.       * </code>
  92.       *
  93.       * NOTE as this is not implemented in the whole classTree at the moment ensure all parents use
  94.       * editTbl_echoForm() in theire editTblForm otherwise you'll get a mismatch of field order
  95.       *
  96.       * @param boolean $debug 
  97.       *
  98.       * @returns array
  99.       *
  100.       * @since pk-06-04-26
  101.       * @version pk-06-07-17 HIDDEN added to array
  102.       * @version pk-06-08-15 FLDTIT added
  103.       *
  104.       ***/
  105.     function editTbl_getFieldEditArr($debug=False{
  106.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_EMAILADDR::editTbl_getFieldEditArr");
  107.  
  108.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  109.  
  110.         $a_ret['VALCHECKS']['FLD_SYNTAXERRMSG']=array(
  111.             'FLDLAB'=>"Syntax Errormsg",
  112.             'FLDVAL'=>"<input name=\"noAddrErrMsg\" value=\"".htmlspecialchars($this->noAddrErrMsg)."\" size=\"50\">",
  113.             'FLDTIT'=>"Fehlermeldung die angezeigt wird wenn die E-Mail Adresse syntaktisch falsch ist (z.B. kein @)"
  114.         );
  115.         $a_ret['VALCHECKS']['FLD_DODNSCHECK']=array(
  116.             'FLDLAB'=>"DNS-Domain-Check",
  117.             'FLDTIT'=>"Prüfen ob es für die Domain einen MX-Eintrag gibt",
  118.             'FLDVAL'=>"<input name=\"dnsCheckDomain\" type=\"checkbox\" value=\"1\"".($this->dnsCheckDomain ? " checked " "")."> ja"
  119.         );
  120.         $a_ret['VALCHECKS']['FLD_DNSCHECKERRMSG']=array(
  121.             'FLDLAB'=>"DNS-Check Errormsg",
  122.             'FLDTIT'=>"Fehlermeldung wenn kein DNS Eintrag gefunden wurde",
  123.             'FLDVAL'=>"<input name=\"noMxErrMsg\" value=\"".htmlspecialchars($this->noMxErrMsg)."\" size=\"50\">"
  124.         );
  125.         return $a_ret;
  126.     }
  127.  
  128.  
  129.     /**
  130.       * save the filed definition form
  131.       *
  132.       * @param boolean $debug 
  133.       *
  134.       * @return boolean 
  135.       *
  136.       * @version pk-05-02-11
  137.       * @version pk-08-06-26
  138.       */
  139.     function save($debug=False{
  140.         $ret=parent::save();
  141.  
  142.         $this->noAddrErrMsg=    $_POST['noAddrErrMsg'];
  143.         $this->dnsCheckDomain=  ((isset($_POST['dnsCheckDomain']&& intval($_POST['dnsCheckDomain'])) True False );
  144.         $this->noMxErrMsg=      $_POST['noMxErrMsg'];
  145.  
  146.         return $ret;
  147.     }
  148.  
  149.     /**
  150.       * returns the field value if the two fields matches
  151.       *
  152.       * @param  string  $aValue     the value
  153.       * @param  array   $err        error array
  154.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  155.       * @param  bool    $debug 
  156.       *
  157.       * @return string 
  158.       *
  159.       * @version pk-05-02-11 included code to check email address from www.php.net/manual/en
  160.       *
  161.       ***/
  162.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=False{
  163.         $debug=($debug || $this->fldDebug || $this->fldDbgGetValue);
  164.         if ($debugecho "<hr><p><b>DBMS_FIELD_EMAILADDR::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  165.         if ($value=parent::getValue($aValue,$err,$arrName,$debug)) {
  166.             if ($debugprint("Checking$value<br>");
  167.  
  168.             if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$"strtolower($value))) {
  169.                 if ($debug{
  170.                     print("Format Test: PASSED<br>");
  171.                     print("Online host verification Test...<br><br>");
  172.                     print("MX Records for$value<br>");
  173.                 }
  174.  
  175.                 if ($this->dnsCheckDomain{
  176.                     list($alias$domainsplit("@"$value);
  177.                     if (checkdnsrr($domain"MX")) {
  178.                         if ($debugprint("Online host verification Test: PASSED<br><br>Email Status: VALID");
  179.                         return $value;
  180.                     else {
  181.                         $err['ERROR']=True;
  182.                         $err[$this->myName]['MSG']=$value.$this->dnsCheckDomain."<br />Online host verification Test: FAILED";
  183.                         $err[$this->myName]['LABEL']=$this->label;
  184.                         return NULL;
  185.                     }
  186.                 else {
  187.                     return $value;
  188.                 }
  189.             else {
  190.                 require_once __OCSP_PHPINCPATH__ "common" _OCSP_DIRSEP_ "pcf_templates.phpinc";
  191.                 global ${$arrName};
  192.                 $a_data=${$arrName};
  193.                 $a_data[$this->myName]=$aValue;
  194.                 $err['ERROR']=True;
  195.                 $err[$this->myName]['MSG']=pcf_tmpl_parse($this->noAddrErrMsg,$a_data);
  196.                 $err[$this->myName]['LABEL']=$this->label;
  197.                 return NULL;
  198.             }
  199.         }
  200.         return $value;
  201.     }
  202.  
  203. // end class DBMS_FIELD_EMAILADDR
  204. ?>

Documentation generated on Thu, 08 Jan 2009 17:41:25 +0100 by phpDocumentor 1.4.0a2