[#3134] emptyDateArray assumes 3 date components
Summary emptyDateArray assumes 3 date components
Queue Horde Framework Packages
Queue Version HEAD
Type Enhancement
State Resolved
Priority 2. Medium
Owners
Requester robin (at) rainton (dot) com
Created 12/13/2005 (1122 days ago)
Due
Updated 11/16/2006 (784 days ago)
Assigned
Resolved 11/16/2006 (784 days ago)
Attachments
Milestone
Patch No

History
11/16/2006 Chuck Hagenbuch Comment #2
State ⇒ Resolved
Reply to this comment
Done, slightly simpler but same idea. Thanks!
12/13/2005 Chuck Hagenbuch State ⇒ Accepted
Priority ⇒ 2. Medium
Type ⇒ Enhancement
 
12/13/2005 robin (at) rainton (dot) com Comment #1
Type ⇒ Bug
Summary ⇒ emptyDateArray assumes 3 date components
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Queue ⇒ Horde Framework Packages
Reply to this comment
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;
         }
     }