home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / tasks / do_updatetask.php < prev    next >
Encoding:
PHP Script  |  2004-01-28  |  3.2 KB  |  100 lines

  1. <?php /* TASKS $Id: do_updatetask.php,v 1.11 2004/01/28 07:06:48 ajdonnison Exp $ */
  2.  
  3. //There is an issue with international UTF characters, when stored in the database an accented letter
  4. //actually takes up two letters per say in the field length, this is a problem with costcodes since
  5. //they are limited in size so saving a costcode as REDACI╙N would actually save REDACI╙ since the accent takes 
  6. //two characters, so lets unaccent them, other languages should add to the replacements array too...
  7. function cleanText($text){
  8.     //This text file is not utf, its iso so we have to decode/encode
  9.     $text = utf8_decode($text);
  10.     $trade = array('ß'=>'a','α'=>'a','π'=>'a',
  11.                  'Σ'=>'a','Γ'=>'a',
  12.                  '┴'=>'A','└'=>'A','├'=>'A',
  13.                  '─'=>'A','┬'=>'A',
  14.                  'Θ'=>'e','Φ'=>'e',
  15.                  'δ'=>'e','Ω'=>'e',
  16.                  '╔'=>'E','╚'=>'E',
  17.                  '╦'=>'E','╩'=>'E',
  18.                  'φ'=>'i','∞'=>'i',
  19.                  '∩'=>'i','ε'=>'i',
  20.                  '═'=>'I','╠'=>'I',
  21.                  '╧'=>'I','╬'=>'I',
  22.                  '≤'=>'o','≥'=>'o','⌡'=>'o',
  23.                  '÷'=>'o','⌠'=>'o',
  24.                  '╙'=>'O','╥'=>'O','╒'=>'O',
  25.                  '╓'=>'O','╘'=>'O',
  26.                  '·'=>'u','∙'=>'u',
  27.                  'ⁿ'=>'u','√'=>'u',
  28.                  '┌'=>'U','┘'=>'U',
  29.                  '▄'=>'U','█'=>'U',
  30.                  '╤'=>'N','±'=>'n');
  31.     $text = strtr($text,$trade);
  32.     $text = utf8_encode($text);
  33.  
  34.     return $text;
  35. }
  36.  
  37. $notify_owner =  isset($_POST['task_log_notify_owner']) ? $_POST['task_log_notify_owner'] : 0;
  38.  
  39. // dylan_cuthbert: auto-transation system in-progress, leave this line commented out for now
  40. //include( '/usr/local/translator/translate.php' );
  41.  
  42. $del = dPgetParam( $_POST, 'del', 0 );
  43.  
  44. $obj = new CTaskLog();
  45.  
  46. if (!$obj->bind( $_POST )) {
  47.     $AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
  48.     $AppUI->redirect();
  49. }
  50.  
  51. // dylan_cuthbert: auto-transation system in-progress, leave these lines commented out for now
  52. //if ( $obj->task_log_description ) {
  53. //    $obj->task_log_description .= "\n\n[translation]\n".translator_make_translation( $obj->task_log_description );
  54. //}
  55.  
  56. if ($obj->task_log_date) {
  57.     $date = new CDate( $obj->task_log_date );
  58.     $obj->task_log_date = $date->format( FMT_DATETIME_MYSQL );
  59. }
  60.  
  61. // prepare (and translate) the module name ready for the suffix
  62. $AppUI->setMsg( 'Task Log' );
  63. if ($del) {
  64.     if (($msg = $obj->delete())) {
  65.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  66.     } else {
  67.         $AppUI->setMsg( "deleted", UI_MSG_ALERT );
  68.     }
  69.     $AppUI->redirect();
  70. } else {
  71.     $obj->task_log_costcode = cleanText($obj->task_log_costcode);
  72.     if (($msg = $obj->store())) {
  73.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  74.         $AppUI->redirect();
  75.     } else {
  76.         $AppUI->setMsg( @$_POST['task_log_id'] ? 'updated' : 'inserted', UI_MSG_OK, true );
  77.     }
  78. }
  79.  
  80. $task = new CTask();
  81. $task->load( $obj->task_log_task );
  82. $task->check();
  83.  
  84. $task->task_percent_complete = dPgetParam( $_POST, 'task_percent_complete', null );
  85.  
  86. if ($task->task_percent_complete >= 100 && $task->task_end_date == '0000-00-00 00:00:00')
  87.     $task->task_end_date = $obj->task_log_date;
  88.  
  89. if (($msg = $task->store())) {
  90.     $AppUI->setMsg( $msg, UI_MSG_ERROR, true );
  91. }
  92.  
  93. if ($notify_owner) {
  94.     if ($msg = $task->notifyOwner()) {
  95.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  96.     }
  97. }
  98. $AppUI->redirect();
  99. ?>
  100.