]> dev.renevier.net Git - syj.git/blob - application/forms/User.php
fixes: some error were not handled correctly when uploading path as file
[syj.git] / application / forms / User.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_Form_User extends Syj_Form_TableAbstract
6 {
7     public function init() {
8         $translator = $this->getTranslator();
9
10         $desc = $translator->translate("only letters, numbers, underscores or dots");
11         $name = array('Text', 'user_pseudo', array(
12             'label' => __("user name"),
13             'attribs' => array('maxlength' => '20', 'autocomplete' => 'off'),
14             'description' => $desc,
15             'validators' => array(new Zend_Validate_StringLength(0, 20),
16                                  new Zend_Validate_Regex('/^[a-zA-Z0-9_\.]+$/')),
17             'required' => true
18         ));
19
20         $desc = $translator->translate("At least %d characters");
21         $desc = vsprintf($desc, 6);
22         $pass = array('Password', 'user_password', array(
23             'label' => __("password"),
24             'required' => true,
25             'description' => $desc,
26             'validators' => array(new Zend_Validate_StringLength(6))
27         ));
28
29         $pass_confirm = array('Password', 'user_password_confirm', array(
30                 'label' => __("confirm password"),
31                 'validators' => array(new Zend_Validate_Identical('user_password')),
32                 'required' => true
33         ));
34
35         $email = array('Text', 'user_email', array(
36             'label' => __("email"),
37             'description' => __("After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account will be deleted."),
38             'required' => true
39             ));
40
41         $this->setMainElements(array($name, $pass, $pass_confirm, $email));
42
43         $anchor = $this->getView()->Anchor("termsofuse?format=raw",
44                                            $translator->translate("terms of use"),
45                                            array('id' => 'user_termsofuse_anchor'));
46         $text = $translator->translate("I've read and accepted %s");
47         $text = vsprintf($text, $anchor);
48         $this->addElement('Checkbox', 'user_accept', array("label" => $text,
49                             'helper' => 'SyjFormCheckbox', // similar to FormCheckbox without a hidden input
50                             'decorators' => array(
51                                   'ViewHelper',
52                                   'label',
53                                   array('HtmlTag', array('tag' => 'div', 'id' => 'user_accept_container'))),
54                             'validators' => array(new Zend_Validate_Identical('1'))));
55
56         $decorator = $this->user_accept->getDecorator('Zend_Form_Decorator_Label');
57         $decorator->setOption('escape', false);
58
59         $this->addElement('Submit', 'user_submit', array('label' => __("create account")));
60     }
61 }