[Tickets #3905] NEW: Add maxevents parameter to monthlist Block

bugs@bugs.horde.org bugs at bugs.horde.org
Tue May 9 08:43:50 PDT 2006


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

Ticket URL: http://bugs.horde.org/ticket/?id=3905
-----------------------------------------------------------------------
 Ticket             | 3905
 Created By         | dorm at dorm.org
 Summary            | Add maxevents parameter to monthlist Block
 Queue              | Kronolith
 Version            | FRAMEWORK_3
 State              | New
 Priority           | 1. Low
 Type               | Enhancement
 Owners             | 
-----------------------------------------------------------------------


dorm at dorm.org (2006-05-09 08:43) wrote:

The following patch adds a maxevents parameter to the monthlist Block, which
allows you to limit the total number of events displayed in the block.


--- monthlist.php       (revision 67)
+++ monthlist.php       (working copy)
@@ -23,7 +23,10 @@
                                             'default' => '__all'),
                         'months'   => array('name' => _("Months Ahead"),
                                             'type' => 'int',
-                                            'default' => 2));
+                                            'default' => 2),
+                        'maxevents' => array('name' => _("Maximum number of
events to display (0 = no limit)"),
+                                             'type' => 'int',
+                                             'default' => 0));
         $params['calendar']['values']['__all'] = _("All Visible");
         foreach (Kronolith::listCalendars() as $id => $cal) {
             $params['calendar']['values'][$id] = $cal->get('name');
@@ -79,6 +82,7 @@
                                     $endDate->mday, $endDate->month,
$endDate->year);
 
         /* Loop through the days. */
+        $totalevents = 0;
         for ($i = 0; $i < $days; $i++) {
             $day = &new Kronolith_Day($startDate->month, $today + $i);
             $today_stamp = $day->getStamp();
@@ -86,6 +90,10 @@
                 continue;
             }
 
+            if(($this->_params['maxevents'] > 0) && ($totalevents >=
$this->_params['maxevents'])) {
+                break;
+            }
+
             $firstevent = true;
 
             /* Output month header. */
@@ -156,6 +164,8 @@
                     $html .= '</strong>';
                 }
                 $html .= '</td></tr>';
+
+                $totalevents++;
             }
         }




More information about the bugs mailing list