[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/calendar/ -> view.php (source)

   1  <?php /* $Id: view.php 118 2008-03-23 19:44:47Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/calendar/view.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $event_id = intval(w2PgetParam($_GET, 'event_id', 0));
   7  
   8  // check permissions for this record

   9  $perms = &$AppUI->acl();
  10  $canRead = $perms->checkModuleItem($m, 'view', $event_id);
  11  if (!$canRead) {
  12      $AppUI->redirect('m=public&a=access_denied');
  13  }
  14  $canEdit = $perms->checkModuleItem($m, 'edit', $event_id);
  15  
  16  // check if this record has dependencies to prevent deletion

  17  $msg = '';
  18  $obj = new CEvent();
  19  $canDelete = $obj->canDelete($msg, $event_id);
  20  
  21  // load the record data

  22  if (!$obj->load($event_id)) {
  23      $AppUI->setMsg('Event');
  24      $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
  25      $AppUI->redirect();
  26  } else {
  27      $AppUI->savePlace();
  28  }
  29  
  30  //check if the user has view permission over the project

  31  if ($obj->event_project && !$perms->checkModuleItem('projects', 'view', $obj->event_project)) {
  32      $AppUI->redirect('m=public&a=access_denied');
  33  }
  34  
  35  // load the event types

  36  $types = w2PgetSysVal('EventType');
  37  
  38  // load the event recurs types

  39  $recurs = array('Never', 'Hourly', 'Daily', 'Weekly', 'Bi-Weekly', 'Every Month', 'Quarterly', 'Every 6 months', 'Every Year');
  40  
  41  $assigned = $obj->getAssigned();
  42  
  43  if (($obj->event_owner != $AppUI->user_id) && !($perms->checkModule('admin', 'view'))) {
  44      $canEdit = false;
  45  }
  46  
  47  $df = $AppUI->getPref('SHDATEFORMAT');
  48  $tf = $AppUI->getPref('TIMEFORMAT');
  49  
  50  $start_date = $obj->event_start_date ? new CDate($obj->event_start_date) : new CDate();
  51  $end_date = $obj->event_end_date ? new CDate($obj->event_end_date) : new CDate();
  52  if ($obj->event_project) {
  53      $q = new DBQuery;
  54      $q->addTable('projects');
  55      $q->addQuery('project_name');
  56      $q->addWhere('project_id = ' . (int)$obj->event_project);
  57      $event_project = $q->loadResult();
  58  }
  59  
  60  // setup the title block

  61  $titleBlock = new CTitleBlock('View Event', 'myevo-appointments.png', $m, $m . '.' . $a);
  62  if ($canEdit) {
  63      $titleBlock->addCell();
  64      $titleBlock->addCell('
  65          <form action="?m=calendar&amp;a=addedit" method="post">
  66              <input type="submit" class="button" value="' . $AppUI->_('new event') . '" />
  67          </form>', '', '', '');
  68  }
  69  $titleBlock->addCrumb('?m=calendar&amp;date=' . $start_date->format(FMT_TIMESTAMP_DATE), 'month view');
  70  $titleBlock->addCrumb('?m=calendar&amp;a=day_view&amp;date=' . $start_date->format(FMT_TIMESTAMP_DATE) . '&amp;tab=0', 'day view');
  71  if ($canEdit) {
  72      $titleBlock->addCrumb('?m=calendar&amp;a=addedit&amp;event_id=' . $event_id, 'edit this event');
  73      if ($canDelete) {
  74          $titleBlock->addCrumbDelete('delete event', $canDelete, $msg);
  75      }
  76  }
  77  $titleBlock->show();
  78  ?>
  79  <script language="javascript">
  80  <?php
  81  // security improvement:

  82  // some javascript functions may not appear on client side in case of user not having write permissions

  83  // else users would be able to arbitrarily run 'bad' functions

  84  if ($canDelete) {
  85  ?>
  86  function delIt() {
  87      if (confirm( "<?php echo $AppUI->_('eventDelete', UI_OUTPUT_JS); ?>" )) {
  88          document.frmDelete.submit();
  89      }
  90  }
  91  <?php } ?>
  92  </script>
  93  
  94  <form name="frmDelete" action="./index.php?m=calendar" method="post">
  95      <input type="hidden" name="dosql" value="do_event_aed" />
  96      <input type="hidden" name="del" value="1" />
  97      <input type="hidden" name="event_id" value="<?php echo $event_id; ?>" />
  98  </form>
  99  <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
 100  <tr>
 101      <td valign="top" width="50%">
 102          <strong><?php echo $AppUI->_('Details'); ?></strong>
 103          <table cellspacing="1" cellpadding="2" width="100%">
 104          <tr>
 105              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Event Title'); ?>:</td>
 106              <td class="hilite" width="100%"><?php echo $obj->event_title; ?></td>
 107          </tr>
 108          <tr>
 109              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Type'); ?>:</td>
 110              <td class="hilite" width="100%"><?php echo $AppUI->_($types[$obj->event_type]); ?></td>
 111          </tr>    
 112          <tr>
 113              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Project'); ?>:</td>
 114              <td class="hilite" width="100%"><a href='?m=projects&a=view&project_id=<?php echo $obj->event_project ?>'><?php echo $event_project; ?></a></td>
 115          </tr>
 116          <tr>
 117              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Starts'); ?>:</td>
 118              <td class="hilite"><?php echo $start_date ? $start_date->format($df . ' ' . $tf) : '-'; ?></td>
 119          </tr>
 120          <tr>
 121              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Ends'); ?>:</td>
 122              <td class="hilite"><?php echo $end_date ? $end_date->format($df . ' ' . $tf) : '-'; ?></td>
 123          </tr>
 124          <tr>
 125              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Recurs'); ?>:</td>
 126              <td class="hilite"><?php echo $AppUI->_($recurs[$obj->event_recurs]) . ($obj->event_recurs ? ' (' . $obj->event_times_recuring . '&nbsp;' . $AppUI->_('times') . ')' : ''); ?></td>
 127          </tr>
 128          <tr>
 129              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Attendees'); ?>:</td>
 130              <td class="hilite"><?php
 131  if (is_array($assigned)) {
 132      $start = false;
 133      foreach ($assigned as $user) {
 134          if ($start)
 135              echo '<br/>';
 136          else
 137              $start = true;
 138          echo $user;
 139      }
 140  }
 141  ?>
 142          </tr>
 143          </table>
 144      </td>
 145      <td width="50%" valign="top">
 146          <strong><?php echo $AppUI->_('Description'); ?></strong>
 147          <table cellspacing="0" cellpadding="2" border="0" width="100%">
 148          <tr>
 149              <td class="hilite">
 150                  <?php echo str_replace(chr(10), '<br />', $obj->event_description); ?>&nbsp;
 151              </td>
 152          </tr>
 153          </table>
 154          <?php
 155  require_once $AppUI->getSystemClass('CustomFields');
 156  $custom_fields = new CustomFields($m, $a, $obj->event_id, 'view');
 157  $custom_fields->printHTML();
 158  ?>
 159  
 160      </td>
 161  </tr>
 162  </table>


Generated: Wed Jan 7 03:00:01 2009 Cross-referenced by PHPXref 0.7