root/trunk/patForms/Rule/StorageProhibitUpdate.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 Retype
4  *
5  * $Id$
6  *
7  * @package        patForms
8  * @subpackage    Rules
9  */
10
11 /**
12  * patForms Rule NoUpdate
13  *
14  * Checks whether an entry exists and permits update of it by using the storage
15  * container which is responsible for saving.
16  *
17  * @package        patForms
18  * @subpackage    Rules
19  * @author        Frank Kleine <frank.kleine@schlund.de>
20  * @license        LGPL, see license.txt for details
21  * @link        http://www.php-tools.net
22  */
23 class patForms_Rule_StorageProhibitUpdate extends patForms_Rule
24 {
25    /**
26     * define error codes and messages for the rule
27     *
28     * @access    private
29     * @var        array    $validatorErrorCodes
30     * @todo     translate error messages
31     */
32     var    $validatorErrorCodes  =   array(
33         'C'    =>    array(
34             1    =>    'An entry with your data exists.',
35         ),
36         'de' =>    array(
37             1    =>    'Es besteht bereits ein Eintrag mit Ihren Daten.',
38         ),
39         'fr' =>    array(
40             1    =>    'Une entrée existe déjà pour vos données.',
41         )
42     );
43
44    /**
45     * the storage container
46     * @access    private
47     * @var        array
48     */
49     var $_storage;
50
51    /**
52     * set the storage that can deliver if the entry exists
53     *
54     * @access    public
55     * @param    object    storage
56     */
57     function setStorage(&$storage)
58     {
59         $this->_storage    =& $storage;
60     }
61
62    /**
63     * method called by patForms or any patForms_Element to validate the
64     * element or the form.
65     *
66     * @access    public
67     * @param    object patForms    form object
68     */
69     function applyRule(&$form, $type = PATFORMS_RULE_AFTER_VALIDATION)
70     {
71         if ($this->_storage->entryExists(&$form) === true) {
72             $this->addValidationError(1);
73             return false;
74         }
75         return true;
76     }
77 }
78 ?>
Note: See TracBrowser for help on using the browser.