root/trunk/patForms/Rule/StorageProhibitAdd.php

Revision 321, 1.5 kB (checked in by argh, 3 years ago)

Fixed bugs #171 (Date element accepts invalid dates), #187 (french translations for storage rules) and #182 (switch element does not check for correct value)

Line 
1 <?php
2 /**
3  * patForms Rule that does not allow new entries to be added to a form
4  *
5  * $Id$
6  *
7  * @package        patForms
8  * @subpackage    Rules
9  */
10
11 /**
12  * patForms Rule that does not allow new entries to be added to a form
13  *
14  * @package        patForms
15  * @subpackage    Rules
16  * @author        Stephan Schmidt <schst@php-tools.net>
17  * @license        LGPL, see license.txt for details
18  * @link        http://www.php-tools.net
19  */
20 class patForms_Rule_StorageProhibitAdd extends patForms_Rule
21 {
22    /**
23     * define error codes and messages for the rule
24     *
25     * @access    private
26     * @var        array    $validatorErrorCodes
27     * @todo     translate error messages
28     */
29     var    $validatorErrorCodes  =   array(
30         'C'    =>    array(
31             1    =>    'The entry does not exist.',
32         ),
33         'de' =>    array(
34             1    =>    'Der Eintrag existiert nicht.',
35         ),
36         'fr' =>    array(
37             1    =>    'Cette entrĂ©e n\'existe pas.',
38         )
39     );
40
41    /**
42     * the storage container
43     * @access    private
44     * @var        array
45     */
46     var $_storage;
47
48    /**
49     * set the storage that can deliver if the entry exists
50     *
51     * @access    public
52     * @param    object    storage
53     */
54     function setStorage(&$storage)
55     {
56         $this->_storage    =& $storage;
57     }
58
59    /**
60     * method called by patForms or any patForms_Element to validate the
61     * element or the form.
62     *
63     * @access    public
64     * @param    object patForms    form object
65     */
66     function applyRule(&$form, $type = PATFORMS_AFTER_VALIDATION)
67     {
68         if ($this->_storage->entryExists(&$form) === false) {
69             $this->addValidationError(1);
70             return false;
71         }
72         return true;
73     }
74 }
75 ?>
Note: See TracBrowser for help on using the browser.