[Tickets #3134] NEW: emptyDateArray assumes 3 date components

bugs@bugs.horde.org bugs at bugs.horde.org
Tue Dec 13 18:31:31 PST 2005


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=3134
-----------------------------------------------------------------------
 Ticket             | 3134
 Created By         | robin at rainton.com
 Summary            | emptyDateArray assumes 3 date components
 Queue              | Horde Framework Packages
 Version            | FRAMEWORK_3
 State              | Unconfirmed
 Priority           | 2. Medium
 Type               | Bug
 Owners             | 
-----------------------------------------------------------------------


robin at rainton.com (2005-12-13 18:31) wrote:

It is possible to have a number of date parts other than 3. For example,
when initialising a form ($this):

    $this->addVariable(_("Start Date"), 'start', 'monthDayYear', true);
    $this->addVariable(_("Start Time"), 'start', 'hourMinuteSecond', true);

Which works as expected, but breaks the validation function, which should
probably read:

    function emptyDateArray($date)
    {
        if (!is_array($date)) {
            return empty($date);
        }

        $empty = 0;
        $parts = 0;
        /* Check each date array component. */
        foreach ($date as $key => $val) {
            $parts++;
            if (empty($val)) {
                $empty++;
            }
        }
        /* Check state of empty. */
        if ($empty == 0) {
            /* If no empty parts return 0. */
            return 0;
        } elseif ($empty == $parts) {
            /* If all empty parts return 1. */
            return 1;
        } else {
            /* If some empty parts return -1. */
            return -1;
        }
    }





More information about the bugs mailing list