[ Index ]
 

Code source de WebCalendar 1.0.5

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables | Statistiques

title

Body

[fermer]

/ -> week_details.php (source)

   1  <?php
   2  include_once  'includes/init.php';
   3  send_no_cache_header ();
   4  
   5  if (($user != $login) && $is_nonuser_admin)
   6    load_user_layers ($user);
   7  else
   8    load_user_layers ();
   9  
  10  load_user_categories ();
  11  
  12  
  13  $next = mktime ( 2, 0, 0, $thismonth, $thisday + 7, $thisyear );
  14  $prev = mktime ( 2, 0, 0, $thismonth, $thisday - 7, $thisyear );
  15  
  16  // We add 2 hours on to the time so that the switch to DST doesn't
  17  // throw us off.  So, all our dates are 2AM for that day.
  18  if ( $WEEK_START == 1 )
  19    $wkstart = get_monday_before ( $thisyear, $thismonth, $thisday );
  20  else
  21    $wkstart = get_sunday_before ( $thisyear, $thismonth, $thisday );
  22  $wkend = $wkstart + ( 3600 * 24 * 6 );
  23  
  24  $startdate = date ( "Ymd", $wkstart );
  25  $enddate = date ( "Ymd", $wkend );
  26  
  27  if ( $DISPLAY_WEEKENDS == "N" ) {
  28    if ( $WEEK_START == 1 ) {
  29      $start_ind = 0;
  30      $end_ind = 5;
  31    } else {
  32      $start_ind = 1;
  33      $end_ind = 6;
  34    }
  35  } else {
  36    $start_ind = 0;
  37    $end_ind = 7;
  38  }
  39  
  40  $HeadX = '';
  41  if ( $auto_refresh == "Y" && ! empty ( $auto_refresh_time ) ) {
  42    $refresh = $auto_refresh_time * 60; // convert to seconds
  43    $HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; url=week_details.php?$u_url" .
  44      "date=$startdate$caturl\" />\n";
  45  }
  46  $INC = array('js/popups.php');
  47  print_header($INC,$HeadX);
  48  
  49  /* Pre-Load the repeated events for quckier access */
  50  $repeated_events = read_repeated_events ( strlen ( $user ) ? $user : $login, $cat_id, $startdate  );
  51  
  52  /* Pre-load the non-repeating events for quicker access */
  53  $events = read_events ( strlen ( $user ) ? $user : $login, $startdate, $enddate, $cat_id  );
  54  
  55  for ( $i = 0; $i < 7; $i++ ) {
  56    $days[$i] = $wkstart + ( 24 * 3600 ) * $i;
  57    $weekdays[$i] = weekday_short_name ( ( $i + $WEEK_START ) % 7 );
  58    $header[$i] = $weekdays[$i] . " " .
  59      date_to_str ( date ( "Ymd", $days[$i] ), $DATE_FORMAT_MD, false );
  60  }
  61  ?>
  62  
  63  <div class="title">
  64  <a title="Previous" class="prev" href="week_details.php?<?php echo $u_url; ?>date=<?php echo date("Ymd", $prev ) . $caturl;?>"><img src="leftarrow.gif" alt="Previous" /></a>
  65  <a title="Next" class="next" href="week_details.php?<?php echo $u_url;?>date=<?php echo date ("Ymd", $next ) . $caturl;?>"><img src="rightarrow.gif" alt="Next" /></a>
  66  <span class="date"><?php
  67    echo date_to_str ( date ( "Ymd", $wkstart ), "", false ) .
  68      "&nbsp;&nbsp;&nbsp; - &nbsp;&nbsp;&nbsp;" .
  69      date_to_str ( date ( "Ymd", $wkend ), "", false );
  70  ?></span>
  71  <?php
  72  if ( $GLOBALS["DISPLAY_WEEKNUMBER"] == "Y" ) {
  73    echo "<br />\n<span class=\"weeknumber\">(" .
  74      translate("Week") . " " . week_number ( $wkstart ) . ")</span>";
  75  }
  76  ?>
  77  <span class="user"><?php
  78    if ( $single_user == "N" ) {
  79      echo "<br />$user_fullname\n";
  80    }
  81    if ( $is_nonuser_admin )
  82      echo "<br />-- " . translate("Admin mode") . " --";
  83    if ( $is_assistant )
  84      echo "<br />-- " . translate("Assistant mode") . " --";
  85  ?></span>
  86  <?php
  87    if ( $categories_enabled == "Y" ) {
  88      echo "<br /><br />\n";
  89      print_category_menu('week', sprintf ( "%04d%02d%02d",$thisyear, $thismonth, $thisday ), $cat_id );
  90    } ?>
  91  </div>
  92  
  93  <center>
  94  <table class="main" cellspacing="0" cellpadding="0">
  95  <?php
  96  $untimed_found = false;
  97  for ( $d = 0; $d < 7; $d++ ) {
  98    $date = date ( "Ymd", $days[$d] );
  99    $thiswday = date ( "w", $days[$d] );
 100    $is_weekend = ( $thiswday == 0 || $thiswday == 6 );
 101  
 102    print "<tr><th";
 103    if ( $date == date ( "Ymd", $today ) ) {
 104      echo " class=\"today\">";
 105    } elseif ( $is_weekend ) {
 106      echo " class=\"weekend\">";
 107    } else {
 108      echo ">";
 109    }
 110  
 111    if ( $can_add ) {
 112      echo "<a title=\"" .
 113        translate("New Entry") . "\" href=\"edit_entry.php?" . 
 114        $u_url . "date=" . 
 115        date ( "Ymd", $days[$d] ) . "\"><img src=\"new.gif\" class=\"new\" alt=\"" .
 116        translate("New Entry") . "\" /></a>\n";
 117    }
 118    echo "<a title=\"" .
 119      $header[$d] . "\" href=\"day.php?" . 
 120      $u_url . "date=" . 
 121      date("Ymd", $days[$d] ) . "$caturl\">" .
 122      $header[$d] . "</a></th>\n</tr>\n";
 123  
 124    print "<tr>\n<td";
 125    if ( $date == date ( "Ymd", $today ) ) {
 126      echo " class=\"today\">";
 127    } elseif ( $is_weekend ) {
 128      echo " class=\"weekend\">";
 129    } else {
 130      echo ">";
 131    }
 132  
 133    print_det_date_entries ( $date, $user, true );
 134    echo "&nbsp;";
 135    echo "</td></tr>\n";
 136  }
 137  ?>
 138  </table>
 139  </center>
 140  
 141  <?php     if ( ! empty ( $eventinfo ) ) echo $eventinfo; ?>
 142  <br />
 143  <a title="<?php etranslate("Generate printer-friendly version")?>" class="printer" href="week_details.php?<?php
 144    echo $u_url;
 145    if ( $thisyear ) {
 146      echo "year=$thisyear&amp;month=$thismonth&amp;day=$thisday";
 147    }
 148    echo $caturl . "&amp;";
 149  ?>friendly=1" target="cal_printer_friendly" 
 150  onmouseover="window.status = '<?php etranslate("Generate printer-friendly version")?>'">[<?php 
 151      etranslate("Printer Friendly")
 152  ?>]</a>
 153  
 154  <?php print_trailer(); ?>
 155  </body>
 156  </html><?php
 157  
 158  // Print the HTML for one day's events in detailed view.
 159  // params:
 160  //   $id - event id
 161  //   $date - date (not used)
 162  //   $time - time (in HHMMSS format)
 163  //   $name - event name
 164  //   $description - long description of event
 165  //   $status - event status
 166  //   $pri - event priority
 167  //   $access - event access
 168  //   $event_owner - user associated with this event
 169  function print_detailed_entry ( $id, $date, $time, $duration,
 170    $name, $description, $status,
 171    $pri, $access, $event_owner ) {
 172    global $eventinfo, $login, $user, $TZ_OFFSET;
 173    static $key = 0;
 174  
 175    global $layers;
 176  
 177    if ( $login != $event_owner && strlen ( $event_owner ) ) {
 178      $class = "layerentry";
 179    } else {
 180      $class = "entry";
 181      if ( $status == "W" ) $class = "unapprovedentry";
 182    }
 183  
 184    if ( $pri == 3 ) echo "<strong>";
 185      $divname = "eventinfo-$id-$key";
 186      $key++;
 187      echo "<a title=\"" . 
 188          translate("View this entry") . "\" class=\"$class\" href=\"view_entry.php?id=$id&amp;date=$date";
 189      if ( strlen ( $user ) > 0 )
 190          echo "&amp;user=" . $user;
 191      echo "\" onmouseover=\"window.status='" . 
 192          translate("View this entry") .    "'; return true;\" onmouseout=\"window.status=''; return true;\">";
 193      echo "<img src=\"circle.gif\" class=\"bullet\" alt=\"view icon\" />";
 194  
 195    if ( $login != $event_owner && strlen ( $event_owner ) ) {
 196      if ($layers) foreach ($layers as $layer) {
 197        if($layer['cal_layeruser'] == $event_owner) {
 198          echo("<span style=\"color:#" . $layer['cal_color'] . ";\">");
 199        }
 200      }
 201    }
 202  
 203    $timestr = "";
 204    $my_time = $time + ( $TZ_OFFSET * 10000 );
 205    if ( $time >= 0 ) {
 206      if ( $GLOBALS["TIME_FORMAT"] == "24" ) {
 207        printf ( "%02d:%02d", $my_time / 10000, ( $my_time / 100 ) % 100 );
 208      } else {
 209        $h = ( (int) ( $my_time / 10000 ) ) % 12;
 210        if ( $h == 0 ) $h = 12;
 211        echo $h;
 212        $m = ( $my_time / 100 ) % 100;
 213        if ( $m > 0 )
 214          printf ( ":%02d", $m );
 215        else
 216          print (":00");
 217        echo ( (int) ( $my_time / 10000 ) ) < 12 ? translate("am") : translate("pm");
 218      }
 219      $timestr = display_time ( $time );
 220      if ( $duration > 0 ) {
 221        // calc end time
 222        $h = (int) ( $time / 10000 );
 223        $m = ( $time / 100 ) % 100;
 224        $m += $duration;
 225        $d = $duration;
 226        while ( $m >= 60 ) {
 227          $h++;
 228          $m -= 60;
 229        }
 230        $end_time = sprintf ( "%02d%02d00", $h, $m );
 231        $timestr .= " - " . display_time ( $end_time );
 232        echo " - " .display_time ( $end_time ). "";
 233        echo "&raquo;&nbsp;";
 234      } else {
 235      echo "&raquo;&nbsp;";
 236      }
 237    }
 238    if ( $login != $user && $access == 'R' && strlen ( $user ) ) {
 239      $PN = "(" . translate("Private") . ")"; $PD = "(" . translate("Private") . ")";
 240    } elseif ( $login != $event_owner && $access == 'R' && strlen ( $event_owner ) ) {
 241      $PN = "(" . translate("Private") . ")";$PD ="(" . translate("Private") . ")";
 242    } elseif ( $login != $event_owner && strlen ( $event_owner ) ) {
 243      $PN = htmlspecialchars ( $name ) ."</span>";
 244      $PD = activate_urls ( htmlspecialchars ( $description ) );
 245    } else {
 246      $PN = htmlspecialchars ( $name );
 247      $PD = activate_urls ( htmlspecialchars ( $description ) );
 248    }
 249    echo $PN;
 250    echo "</a>";
 251    if ( $pri == 3 ) echo "</strong>";
 252    # Only display description if it is different than the event name.
 253    if ( $PN != $PD )
 254      echo " - " . $PD;
 255    echo "<br />\n";
 256  }
 257  
 258  //
 259  // Print all the calendar entries for the specified user for the
 260  // specified date.  If we are displaying data from someone other than
 261  // the logged in user, then check the access permission of the entry.
 262  // params:
 263  //   $date - date in YYYYMMDD format
 264  //   $user - username
 265  //   $is_ssi - is this being called from week_ssi.php?
 266  function print_det_date_entries ( $date, $user, $ssi ) {
 267    global $events, $readonly, $is_admin;
 268  
 269    $year = substr ( $date, 0, 4 );
 270    $month = substr ( $date, 4, 2 );
 271    $day = substr ( $date, 6, 2 );
 272  
 273    $dateu = mktime ( 2, 0, 0, $month, $day, $year );
 274  
 275    // get all the repeating events for this date and store in array $rep
 276    $rep = get_repeating_entries ( $user, $date );
 277    $cur_rep = 0;
 278  
 279    // get all the non-repeating events for this date and store in $ev
 280    $ev = get_entries ( $user, $date );
 281  
 282    for ( $i = 0; $i < count ( $ev ); $i++ ) {
 283      // print out any repeating events that are before this one...
 284      while ( $cur_rep < count ( $rep ) &&
 285        $rep[$cur_rep]['cal_time'] < $ev[$i]['cal_time'] ) {
 286        if ( $GLOBALS["DISPLAY_UNAPPROVED"] != "N" ||
 287          $rep[$cur_rep]['cal_status'] == 'A' )
 288          print_detailed_entry ( $rep[$cur_rep]['cal_id'],
 289            $date, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'],
 290            $rep[$cur_rep]['cal_name'], $rep[$cur_rep]['cal_description'],
 291            $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'],
 292            $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login'] );
 293        $cur_rep++;
 294      }
 295      if ( $GLOBALS["DISPLAY_UNAPPROVED"] != "N" ||
 296        $ev[$i]['cal_status'] == 'A' )
 297        print_detailed_entry ( $ev[$i]['cal_id'],
 298          $date, $ev[$i]['cal_time'], $ev[$i]['cal_duration'],
 299          $ev[$i]['cal_name'], $ev[$i]['cal_description'],
 300          $ev[$i]['cal_status'], $ev[$i]['cal_priority'],
 301          $ev[$i]['cal_access'], $ev[$i]['cal_login'] );
 302    }
 303    // print out any remaining repeating events
 304    while ( $cur_rep < count ( $rep ) ) {
 305      if ( $GLOBALS["DISPLAY_UNAPPROVED"] != "N" ||
 306        $rep[$cur_rep]['cal_status'] == 'A' )
 307        print_detailed_entry ( $rep[$cur_rep]['cal_id'],
 308          $date, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'],
 309          $rep[$cur_rep]['cal_name'], $rep[$cur_rep]['cal_description'],
 310          $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'],
 311          $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login'] );
 312      $cur_rep++;
 313    }
 314  }
 315  ?>


Généré le : Fri Nov 30 19:09:19 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics