[ 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]

/ -> view_d.php (source)

   1  <?php
   2  /*
   3   * $Id: view_d.php,v 1.38 2005/03/06 23:06:20 umcesrjones Exp $
   4   *
   5   * Page Description:
   6   * Display a timebar view of a single day.
   7   *
   8   * Input Parameters:
   9   * id (*) - specify view id in webcal_view table
  10   * date - specify the starting date of the view.
  11   *   If not specified, current date will be used.
  12   * friendly - if set to 1, then page does not include links or
  13   *   trailer navigation.
  14   * (*) required field
  15   *
  16   * Security:
  17   * Must have "allow view others" enabled ($allow_view_other) in
  18   *   System Settings unless the user is an admin user ($is_admin).
  19   * If the view is not global, the user must be owner of the view.
  20   * If the view is global, then and user_sees_only_his_groups is
  21   * enabled, then we remove users not in this user's groups
  22   * (except for nonuser calendars... which we allow regardless of group).
  23   */
  24  //$start = microtime();
  25  
  26  include_once  'includes/init.php';
  27  
  28  $error = "";
  29  // Don't allow users to use this feature if "allow view others" is
  30  // disabled.
  31  if ( $allow_view_other == "N" && ! $is_admin ) {
  32    // not allowed...
  33    send_to_preferred_view ();
  34  }
  35  
  36  if ( empty ( $id ) ) {
  37    do_redirect ( "views.php" );
  38  }
  39  
  40  // Find view name in $views[]
  41  $view_name = "";
  42  for ( $i = 0; $i < count ( $views ); $i++ ) {
  43    if ( $views[$i]['cal_view_id'] == $id ) {
  44      $view_name = $views[$i]['cal_name'];
  45    }
  46  }
  47  
  48  // If view_name not found, then the specified view id does not
  49  // belong to current user. 
  50  if ( empty( $view_name ) ) {
  51    $error = translate ( "You are not authorized" );
  52  }
  53  
  54  $INC = array ( 'js/view_d.php' );
  55  print_header ( $INC );
  56  
  57  // get users in this view
  58  $res = dbi_query (
  59    "SELECT cal_login FROM webcal_view_user WHERE cal_view_id = $id" );
  60  $participants = array ();
  61  $all_users = false;
  62  if ( $res ) {
  63    while ( $row = dbi_fetch_row ( $res ) ) {
  64      $participants[] = $row[0];
  65      if ( $row[0] == "__all__" )
  66        $all_users = true;
  67    }
  68    dbi_free_result ( $res );
  69  } else {
  70    $error = translate ( "Database error" ) . ": " . dbi_error ();
  71  }
  72  
  73  if ( $all_users ) {
  74    $participants = array ();
  75    $users = get_my_users ();
  76    for ( $i = 0; $i < count ( $users ); $i++ ) {
  77      $participants[] = $users[$i]['cal_login'];
  78    }
  79  } else {
  80    // Make sure this user is allowed to see all users in this view
  81    // If this is a global view, it may include users that this user
  82    // is not allowed to see.
  83    if ( ! empty ( $user_sees_only_his_groups ) &&
  84      $user_sees_only_his_groups == 'Y' ) {
  85      $myusers = get_my_users ();
  86      if ( ! empty ( $nonuser_enabled ) && $nonuser_enabled == "Y" ) {
  87        $myusers = array_merge ( $myusers, get_nonuser_cals () );
  88      }
  89      $userlookup = array ();
  90      for ( $i = 0; $i < count ( $myusers ); $i++ ) {
  91        $userlookup[$myusers[$i]['cal_login']] = 1;
  92      }
  93      $newlist = array ();
  94      for ( $i = 0; $i < count ( $participants ); $i++ ) {
  95        if ( ! empty ( $userlookup[$participants[$i]] ) )
  96          $newlist[] = $participants[$i];
  97      }
  98      $participants = $newlist;
  99    }
 100  }
 101  if ( count ( $participants ) == 0 ) {
 102    // This could happen if user_sees_only_his_groups  = Y and
 103    // this user is not a member of any  group assigned to this view
 104    $error = translate ( "No users for this view" );
 105  }
 106  
 107  if ( ! empty ( $error ) ) {
 108    echo "<h2>" . translate ( "Error" ) .
 109      "</h2>\n" . $error;
 110    print_trailer ();
 111    exit;
 112  }
 113  
 114  set_today($date);
 115  if (!$date) {
 116    $date = $thisdate;
 117  }
 118  
 119  $wday = strftime ( "%w", mktime ( 2, 0, 0, $thismonth, $thisday, $thisyear ) );
 120  $now = mktime ( 2, 0, 0, $thismonth, $thisday, $thisyear );
 121  $nowYmd = date ( "Ymd", $now );
 122  
 123  $next = mktime ( 2, 0, 0, $thismonth, $thisday + 1, $thisyear );
 124  $nextyear = date ( "Y", $next );
 125  $nextmonth = date ( "m", $next );
 126  $nextday = date ( "d", $next );
 127  $nextdate = sprintf ( "%04d%02d%02d", $nextyear, $nextmonth, $nextday );
 128  
 129  $prev = mktime ( 2, 0, 0, $thismonth, $thisday - 1, $thisyear );
 130  $prevyear = date ( "Y", $prev );
 131  $prevmonth = date ( "m", $prev );
 132  $prevday = date ( "d", $prev );
 133  $prevdate = sprintf ( "%04d%02d%02d", $prevyear, $prevmonth, $prevday );
 134  
 135  $thisdate = sprintf ( "%04d%02d%02d", $thisyear, $thismonth, $thisday );
 136  ?>
 137  
 138  <div style="border-width:0px; width:99%;">
 139  <a title="<?php etranslate("Previous")?>" class="prev" href="view_d.php?id=
 140  <?php echo $id . "&amp;date=" . $prevdate?>"><img src="leftarrow.gif" 
 141    class="prevnext" alt="<?php etranslate("Previous")?>" /></a>
 142  
 143  <a title="<?php etranslate("Next")?>" class="next" href="view_d.php?id=
 144  <?php echo $id . "&amp;date=" . $nextdate?>"><img src="rightarrow.gif" 
 145    class="prevnext" alt="<?php etranslate("Next")?>" /></a>
 146  <div class="title">
 147  <span class="date"><?php 
 148    printf ( "%s, %s %d, %d", weekday_name ( $wday ),
 149      month_name ( $thismonth - 1 ), $thisday, $thisyear ); 
 150  ?></span><br />
 151  <span class="viewname"><?php echo $view_name; ?></span>
 152  </div></div>
 153  
 154  <?php
 155  daily_matrix($date,$participants);
 156  ?>
 157  <br />
 158  
 159  <!-- Hidden form for booking events -->
 160  <form action="edit_entry.php" method="post" name="schedule">
 161  <input type="hidden" name="date" value="
 162    <?php echo $thisyear.$thismonth.$thisday;?>" />
 163  <input type="hidden" name="defusers" value="
 164    <?php echo implode ( ",", $participants ); ?>" />
 165  <input type="hidden" name="hour" value="" />
 166  <input type="hidden" name="minute" value="" />
 167  </form>
 168  
 169  <?php
 170  echo "<br /><a title=\"" . translate ( "Generate printer-friendly version" ) . 
 171    "\" class=\"printer\" href=\"view_d.php?id=$id&amp;";
 172  echo ( empty ( $u_url ) ? '' : $u_url ) . "date=$nowYmd";
 173  echo ( empty ( $caturl ) ? '' : $caturl );
 174  echo "&amp;friendly=1\" target=\"cal_printer_friendly\" " .
 175    "onmouseover=\"window.status='" .
 176    translate ( "Generate printer-friendly version" ) .
 177    "'\">[" . translate ( "Printer Friendly" ) . "]</a>";
 178  
 179  print_trailer ();?>
 180  </body>
 181  </html>


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