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

/ -> edit_template.php (source)

   1  <?php
   2  /*
   3   * $Id: edit_template.php,v 1.9.2.1 2005/11/28 22:22:51 cknudsen Exp $
   4   *
   5   * Page Description:
   6   *    This page will present the HTML form to edit an entry
   7   *    in the cal_report table, and this page will also process the
   8   *    form.
   9   *    This is only used for editing the custom header/trailer.
  10   *    The report_id is always 0.
  11   *
  12   * Input Parameters:
  13   *    type - "header" or "trailer"
  14   *
  15   * Security:
  16   *    Admin permissions are checked in connect.php.
  17   */
  18  include_once  'includes/init.php';
  19  
  20  $report_id = 0;
  21  $error = '';
  22  
  23  $type = getValue ( "type", "S|H|T", true );
  24  $cur = '';
  25  $found = false;
  26  
  27  // Get existing value.
  28  $res = dbi_query ( "SELECT cal_template_text " .
  29    "FROM webcal_report_template " .
  30    "WHERE cal_template_type = '$type' AND caL_report_id = 0" );
  31  if ( $res ) {
  32    if ( $row = dbi_fetch_row ( $res ) ) {
  33      $cur = $row[0];
  34      $found = true;
  35    }
  36    dbi_free_result ( $res );
  37  }
  38  
  39  if ( empty ( $REQUEST_METHOD ) )
  40    $REQUEST_METHOD = $_SERVER['REQUEST_METHOD'];
  41  
  42  // Handle form submission
  43  if ( $REQUEST_METHOD == 'POST' ) {
  44    $template = getPostValue ( "template" );
  45    //echo "Template: " .  $template  . "<br />\n"; exit;
  46    if ( $found ) {
  47      $sql = "UPDATE webcal_report_template " .
  48        "SET cal_template_text = '$template' " .
  49        "WHERE cal_template_type = '$type' AND cal_report_id = 0";
  50    } else {
  51      $sql = "INSERT INTO webcal_report_template " .
  52        "( cal_template_type, cal_report_id, cal_template_text ) " .
  53        "VALUES ( '$type', 0, '$template' )";
  54    }
  55    if ( ! dbi_query ( $sql ) ) {
  56      $error = translate("Database error") . ": " . dbi_error ();
  57    } else {
  58      //echo "SQL: $sql <br />\n";
  59      echo "<html>\n<head>\n</head>\n<body onload=\"window.close();\">\nDone</body>\n</html>";
  60      exit;
  61    }
  62  }
  63  
  64  print_header( '', '', '', true );
  65  //echo "report_id: $report_id <br />\n";
  66  //echo "report_name: $report_name <br />\n";
  67  //echo "report_user: $report_user <br />\n";
  68  ?>
  69  
  70  <h2><?php
  71  if ( $type == 'S' )
  72    etranslate("Edit Custom Script/Stylesheet");
  73  else if ( $type == 'H' )
  74    etranslate("Edit Custom Header");
  75  else
  76    etranslate("Edit Custom Trailer");
  77  ?></h2>
  78  
  79  <?php
  80  if ( ! empty ( $error ) ) {
  81    echo "<h2>" . translate("Error") . "</h2>\n" .
  82      $error . "\n";
  83  } else {
  84  ?>
  85  <form action="edit_template.php" method="post" name="reportform">
  86  
  87  <input type="hidden" name="type" value="<?php echo $type;?>" />
  88  <textarea rows="15" cols="60" name="template"><?php echo htmlspecialchars ( $cur )?></textarea>
  89  
  90  <br />
  91  <input type="button" value="<?php etranslate("Cancel")?>" onclick="window.close();" />
  92  <input type="submit" value="<?php etranslate("Save")?>" />
  93  </form>
  94  
  95  <?php }
  96      print_trailer ( false, true, true );
  97  ?>
  98  </body>
  99  </html>


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