WebCalendar PHP Cross Reference Groupware Applications

Source: /week_details.php - 233 lines - 7816 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: week_details.php,v 1.74.2.3 2012/02/20 22:22:12 cknudsen Exp $ */
   3  include_once  'includes/init.php';
   4  send_no_cache_header ();
   5  
   6  load_user_layers ( $user != $login && $is_nonuser_admin ? $user : '' );
   7  load_user_categories ();
   8  
   9  $next = mktime ( 0, 0, 0, $thismonth, $thisday + 7, $thisyear );
  10  $prev = mktime ( 0, 0, 0, $thismonth, $thisday - 7, $thisyear );
  11  
  12  $wkstart = get_weekday_before ( $thisyear, $thismonth, $thisday + 1 );
  13  
  14  $start_ind = 0;
  15  $thisdate = date ( 'Ymd', $wkstart );
  16  $wkend = $wkstart + ( 86400 * ( $DISPLAY_WEEKENDS == 'N' ? 5 : 7 ) );
  17  
  18  if ( $DISPLAY_WEEKENDS == 'N' ) {
  19    if ( $WEEK_START == 1 )
  20      $end_ind = 4;
  21    else {
  22      $start_ind = 1;
  23      $end_ind = 5;
  24    }
  25  } else
  26    $end_ind = 6;
  27  
  28  $printerStr = generate_printer_friendly ( 'week_details.php' );
  29  
  30  /* Pre-Load the repeated events for quckier access. */
  31  $repeated_events = read_repeated_events ( ( strlen ( $user )
  32    ? $user : $login ), $wkstart, $wkend, $cat_id );
  33  
  34  /* Pre-load the non-repeating events for quicker access. */
  35  $events = read_events ( ( strlen ( $user )
  36    ? $user : $login ), $wkstart, $wkend, $cat_id );
  37  
  38  if ( $WEEK_START == 0 && $DISPLAY_WEEKENDS == 'N' )
  39    $wkstart = $wkstart - 86400;
  40  
  41  for ( $i = 0; $i < 7; $i++ ) {
  42    $days[$i] = ( $wkstart + 86400 * $i ) + 43200;
  43    $weekdays[$i] = weekday_name ( ( $i + $WEEK_START ) % 7, $DISPLAY_LONG_DAYS );
  44    $header[$i] = $weekdays[$i] . ' '
  45     . date_to_str ( date ( 'Ymd', $days[$i] ), $DATE_FORMAT_MD, false );
  46  }
  47  
  48  $nextStr = translate ( 'Next' );
  49  $newEntryStr = translate ( 'New Entry' );
  50  $prevStr = translate ( 'Previous' );
  51  
  52  print_header ( array ( 'js/popups.php/true' ), generate_refresh_meta () );
  53  
  54  ob_start ();
  55  
  56  echo '
  57      <div class="title">
  58        <a title="' . $prevStr . '" class="prev" href="week_details.php?' . $u_url
  59   . 'date=' . date ( 'Ymd', $prev ) . $caturl
  60   . '"><img src="images/leftarrow.gif" alt="' . $prevStr . '" /></a>
  61        <a title="' . $nextStr . '" class="next" href="week_details.php?' . $u_url . 'date='
  62   . date ( 'Ymd', $next ) . $caturl
  63   . '"><img src="images/rightarrow.gif" alt="' . $nextStr . '" /></a>
  64        <span class="date">' . date_to_str ( date ( 'Ymd', $wkstart ), '', false )
  65   . '&nbsp;&nbsp;&nbsp; - &nbsp;&nbsp;&nbsp;'
  66   . date_to_str ( date ( 'Ymd', $wkend ), '', false ) . '</span>'
  67   . ( $DISPLAY_WEEKNUMBER == 'Y' ? '<br />
  68        <span class="titleweek">(' . translate ( 'Week' ) . ' '
  69     . date ( 'W', $wkstart + 86400 ) . ')</span>' : '' ) . '
  70        <span class="user">' . ( $single_user == 'N' ? '<br />
  71        ' . $user_fullname : '' ) . ( $is_nonuser_admin ? '<br />-- '
  72     . translate ( 'Admin mode' ) . ' --' : '' ) . ( $is_assistant ? '<br />-- '
  73     . translate ( 'Assistant mode' ) . ' --' : '' ) . '</span>'
  74   . ( $CATEGORIES_ENABLED == 'Y' ? '<br /><br />'
  75     . print_category_menu( 'week', sprintf ( "%04d%02d%02d", $thisyear,
  76        $thismonth, $thisday ), $cat_id ) : '' ) . '
  77      </div><br />
  78      <center>
  79        <table class="main">';
  80  
  81  $untimed_found = false;
  82  for ( $d = 0; $d < 7; $d++ ) {
  83    $date = date ( 'Ymd', $days[$d] );
  84    $thiswday = date ( 'w', $days[$d] );
  85    $is_weekend = ( $thiswday == 0 || $thiswday == 6 );
  86    if ( $is_weekend && $DISPLAY_WEEKENDS == 'N' )
  87      continue;
  88  
  89    $class = ( $date == date ( 'Ymd', $today )
  90      ? ' class="today">'
  91      : ( $is_weekend ? ' class="weekend">' : '>' ) );
  92    echo '
  93          <tr>
  94            <th' . $class . ( $can_add ? '
  95              <a title="' . $newEntryStr . '" href="edit_entry.php?' . $u_url
  96       . 'date=' . date ( 'Ymd', $days[$d] )
  97       . '"><img src="images/new.png" class="new" alt="' . $newEntryStr
  98       . '" /></a>' : '' ) . '
  99              <a title="' . $header[$d] . '" href="day.php?' . $u_url . 'date='
 100     . date ( 'Ymd', $days[$d] ) . $caturl . '">' . $header[$d] . '</a>
 101            </th>
 102          </tr>
 103          <tr>
 104            <td' . $class;
 105    print_det_date_entries ( $date, $user, true );
 106    echo '&nbsp;
 107            </td>
 108          </tr>';
 109  }
 110  
 111  echo '
 112        </table>
 113      </center>
 114      ' . ( empty ( $eventinfo ) ? '' : $eventinfo ) . '<br />';
 115  
 116  ob_end_flush ();
 117  
 118  echo $printerStr . print_trailer ();
 119  
 120  /* Prints the HTML for one event in detailed view.
 121   *
 122   * @param Event  $event The event
 123   * @param string $date  The date for which we're printing (in YYYYMMDD format)
 124   */
 125  function print_detailed_entry ( $event, $date ) {
 126    global $eventinfo, $layers, $login, $user;
 127    static $key = 0;
 128  
 129    $descStr = $event->getDescription ();
 130    $evAccessStr = $event->getAccess ();
 131    $evPri = ( $event->getPriority () < 4 );
 132    $getExtStr = $event->getExtForID ();
 133    $loginStr = $event->getLogin ();
 134    $name = $event->getName ();
 135  
 136    $class = ( $login != $loginStr && strlen ( $loginStr )
 137      ? 'layer' : ( $event->getStatus () == 'W' ? 'unapproved' : '' ) ) . 'entry';
 138  
 139    if ( $getExtStr != '' ) {
 140      $id = $getExtStr;
 141      $name .= ' (' . translate ( 'cont.' ) . ')';
 142    } else
 143      $id = $event->getID ();
 144  
 145    $linkid = 'pop' . "$id-$key";
 146    $key++;
 147  
 148    echo ( $evPri ? '
 149              <strong>' : '' ) . '
 150              <a title="' . translate ( 'View this entry' ) . '" class="' . $class
 151     . '" id="' . $linkid . '" href="view_entry.php?id=' . $id
 152     . '&amp;date=' . $date;
 153  
 154    if ( strlen ( $user ) > 0 )
 155      echo '&amp;user=' . $user;
 156    else
 157    if ( $class == 'layerentry' )
 158      echo '&amp;user=' . $loginStr;
 159  
 160    echo '<img src="images/circle.gif" class="bullet" alt="view icon" />';
 161    if ( $login != $loginStr && strlen ( $loginStr ) ) {
 162      if ( $layers ) {
 163        foreach ( $layers as $layer ) {
 164          if ( $layer['cal_layeruser'] == $loginStr ) {
 165            $in_span = true;
 166            echo '
 167                <span style="color:#' . $layer['cal_color'] . ';">';
 168          }
 169        }
 170      }
 171    }
 172  
 173    $timestr = '';
 174  
 175    if ( $event->isAllDay () )
 176      $timestr = translate ( 'All day event' );
 177    else
 178    if ( $event->getDuration () > 0 ) {
 179      $timestr = display_time ( $event->getDateTime () ) . ' - '
 180       . display_time ( $event->getEndDateTime () );
 181  
 182      echo $timestr . '&raquo;&nbsp;';
 183    }
 184  
 185    if ( $login != $user && $evAccessStr == 'R' && strlen ( $user ) )
 186      $PN = $PD = '(' . translate ( 'Private' ) . ')';
 187    elseif ( $login != $loginStr && $evAccessStr == 'R' &&
 188      strlen ( $loginStr ) )
 189      $PN = $PD = '(' . translate ( 'Private' ) . ')';
 190    elseif ( $login != $loginStr && strlen ( $loginStr ) ) {
 191      $PN = htmlspecialchars ( $name );
 192      $PD = activate_urls ( htmlspecialchars ( $descStr ) );
 193    } else {
 194      $PN = htmlspecialchars ( $name );
 195      $PD = activate_urls ( htmlspecialchars ( $descStr ) );
 196    }
 197    if ( ! empty ( $in_span ) )
 198      $PN .= '</span>';
 199  
 200    echo $PN . '</a>' . ( $evPri ? '
 201              </strong>' : '' )
 202    # Only display description if it is different than the event name.
 203    . ( $PN != $PD ? ' - ' . $PD : '' ) . '<br />';
 204  
 205    $eventinfo .= build_entry_popup ( 'eventinfo-' . $linkid, $loginStr,
 206      $descStr, $timestr, site_extras_for_popup ( $id ) );
 207  }
 208  
 209  /* Print all the calendar entries for the specified user for the specified date.
 210   * If we are displaying data from someone other than the logged in user,
 211   * then check the access permission of the entry.
 212   *
 213   *  @param string $date   - date in YYYYMMDD format
 214   *  @param string $user   - username
 215   *  @param bool   $is_ssi - is this being called from week_ssi.php?
 216   */
 217  function print_det_date_entries ( $date, $user, $ssi ) {
 218    global $events, $is_admin, $readonly;
 219  
 220    $date = mktime ( 0, 0, 0, substr ( $date, 4, 2 ),
 221      substr ( $date, 6, 2 ), substr ( $date, 0, 4 ) );
 222    // .
 223    // Get and sort all the repeating and non-repeating events for this date.
 224    $ev = combine_and_sort_events ( get_entries ( $date ),
 225      get_repeating_entries ( $user, $date ) );
 226    for ( $i = 0, $cnt = count ( $ev ); $i < $cnt; $i++ ) {
 227      if ( ( ! empty ( $DISPLAY_UNAPPROVED ) && $DISPLAY_UNAPPROVED != 'N' ) ||
 228        $ev[$i]->getStatus () == 'A' )
 229        print_detailed_entry ( $ev[$i], $date );
 230    }
 231  }
 232  
 233  ?>

title

Description

title

Description

title

Description

title

title

Body