[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/history/ -> addedit.php (source)

   1  <?php /* $Id: addedit.php 156 2008-04-11 15:47:40Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/history/addedit.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $history_id = defVal(w2PgetParam($_GET, 'history_id', null), 0);
   7  
   8  if (!$canEdit) {
   9      $AppUI->redirect('m=public&a=access_denied');
  10  }
  11  
  12  $action = $_REQUEST['action'];
  13  $q = new DBQuery;
  14  if ($action) {
  15      $history_description = w2PgetParam($_POST, 'history_description', '');
  16      $history_project = w2PgetParam($_POST, 'history_project', '');
  17      $userid = $AppUI->user_id;
  18  
  19      $perms = &$AppUI->acl();
  20  
  21      if ($action == 'add') {
  22          if (!$perms->checkModule('history', 'add')) {
  23              $AppUI->redirect('m=public&a=access_denied');
  24          }
  25          $q->addTable('history');
  26          $q->addInsert('history_table', "history");
  27          $q->addInsert('history_action', "add");
  28          $q->addInsert('history_date', str_replace("'", '', $db->DBTimeStamp(time())));
  29          $q->addInsert('history_description', $history_description);
  30          $q->addInsert('history_user', $userid);
  31          $q->addInsert('history_project', $history_project);
  32          $okMsg = 'History added';
  33      } elseif ($action == 'update') {
  34          if (!$perms->checkModule('history', 'edit')) {
  35              $AppUI->redirect('m=public&a=access_denied');
  36          }
  37          $q->addTable('history');
  38          $q->addUpdate('history_description', $history_description);
  39          $q->addUpdate('history_project', $history_project);
  40          $q->addWhere('history_id =' . $history_id);
  41          $okMsg = 'History updated';
  42      } elseif ($action == 'del') {
  43          if (!$perms->checkModule('history', 'delete')) {
  44              $AppUI->redirect('m=public&a=access_denied');
  45          }
  46          $q->setDelete('history');
  47          $q->addWhere('history_id =' . $history_id);
  48          $okMsg = 'History deleted';
  49      }
  50      if (!$q->exec()) {
  51          $AppUI->setMsg(db_error());
  52      } else {
  53          $AppUI->setMsg($okMsg);
  54          if ($action == 'add') {
  55              $q->clear();
  56          }
  57          $q->addTable('history');
  58          $q->addUpdate('history_item = history_id');
  59          $q->addWhere('history_table = \'history\'');
  60          $okMsg = 'History deleted';
  61      }
  62      $q->clear();
  63      $AppUI->redirect();
  64  }
  65  
  66  // pull the history
  67  $q->addTable('history');
  68  $q->addQuery('*');
  69  $q->addWhere('history_id =' . $history_id);
  70  $history = $q->loadHash();
  71  $q->clear();
  72  
  73  $titleBlock = new CTitleBlock($history_id ? 'Edit history' : 'New history', 'stock_book_blue_48.png', 'history', 'history.' . $a);
  74  if ($canDelete) {
  75      $titleBlock->addCrumbDelete('delete history', $canDelete, $msg);
  76  }
  77  $titleBlock->show();
  78  ?>
  79  
  80  <script>
  81  	function delIt() {
  82          document.AddEdit.action.value = 'del';
  83          document.AddEdit.submit();
  84      }    
  85  </script>
  86  
  87  <form name="AddEdit" method="post">                
  88  <input name="action" type="hidden" value="<?php echo $history_id ? 'update' : 'add' ?>" />
  89  <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
  90  <tr>
  91      <td>
  92          <table border="1" cellpadding="4" cellspacing="0" width="100%" class="std">        
  93          <tr>
  94              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Project'); ?>:</td>
  95              <td width="60%">
  96          <?php
  97          // pull the projects list
  98          $q->addTable('projects');
  99          $q->addQuery('project_id, project_name');
 100          $q->addOrder('project_name');
 101          $projects = arrayMerge(array(0 => '(' . $AppUI->_('any', UI_OUTPUT_RAW) . ')'), $q->loadHashList());
 102          echo arraySelect($projects, 'history_project', 'class="text"', $history['history_project']);
 103          ?>
 104              </td>
 105          </tr>
 106              
 107          <tr>
 108              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Description'); ?>:</td>
 109              <td width="60%">
 110                  <textarea name="history_description" class="textarea" cols="60" rows="5"><?php echo $history['history_description']; ?></textarea>
 111              </td>
 112          </tr>    
 113          </table>        
 114                  
 115          <table border="0" cellspacing="0" cellpadding="3" width="100%">
 116          <tr>
 117              <td height="40" width="30%">&nbsp;</td>
 118              <td  height="40" width="35%" align="right">
 119                  <table>
 120                  <tr>
 121                      <td>
 122                          <input class="button" type="button" name="cancel" value="<?php echo $AppUI->_('cancel'); ?>" onclick="javascript:if(confirm('<?php echo $AppUI->_('Are you sure you want to cancel?', UI_OUTPUT_JS); ?>')){location.href = '?<?php echo $AppUI->getPlace(); ?>';}" />
 123                      </td>
 124                      <td>
 125                          <input class="button" type="button" name="btnFuseAction" value="<?php echo $AppUI->_('save'); ?>" onclick="submit()" />
 126                      </td>
 127                  </tr>
 128                  </table>
 129              </td>
 130          </tr>
 131          </table>        
 132      </td>
 133  </tr>
 134  </form>


Generated: Fri Jan 9 03:00:02 2009 Cross-referenced by PHPXref 0.7