summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/bureaucracy/helper/fieldemail.php
blob: 7857bd7fc5302de2ed27052af379f08ce734ec05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
 * Class helper_plugin_bureaucracy_fieldemail
 *
 * Creates a single line input field where the input is validated to be a valid email address
 */
class helper_plugin_bureaucracy_fieldemail extends helper_plugin_bureaucracy_fieldtextbox {

    /**
     * Arguments:
     *  - cmd
     *  - label
     *  - @@ (optional)
     *  - ^ (optional)
     */

    /**
     * Validate field value
     *
     * @throws Exception when empty or not valid email address
     */
    function _validate() {
        parent::_validate();

        $value = $this->getParam('value');
        if(!is_null($value) && $value !== '@MAIL@' && !mail_isvalid($value)){
            throw new Exception(sprintf($this->getLang('e_email'),hsc($this->getParam('display'))));
        }
    }
}