[ Index ]

PHP Cross Reference of Yamoon 0.9.0

title

Body

[close]

/ -> service.php (source)

   1  <?php
   2  require_once ('Yamoon/Global.php');
   3  include ('header.php');
   4  
   5  $service_id = $_GET['service_id'];
   6  
   7  // ===================== DELETE
   8  if (isset($_GET['action']) && $_GET['action'] == "delete") {
   9      $service = new Service($config, $service_id);
  10      $timeout = $config->redir_timeout;
  11      $message = "";
  12      if ($service->delete()) {
  13          $message = "Service '".$service->name."' deleted!";
  14      } else {
  15          $timeout = $config->redir_timeout_error;
  16          $message = "Service '".$service->name."' could not be deleted. Assure there's no probes with that!";
  17      }
  18      $link = "admin.php";
  19      include ('message.php');
  20  
  21  // ===================== EDIT
  22  } else if (isset($_GET['action']) && $_GET['action'] == "edit") {
  23      $timeout = $config->redir_timeout;
  24      if (isset($_GET['servicename']) && $_GET['servicename'] != "" &&
  25          isset($_GET['code']) && $_GET['code'] != "" &&
  26          isset($_GET['language']) && $_GET['language'] != "") {
  27          if ($service_id) {
  28              $service = new Service($config, $service_id);
  29              $service->name = $_GET['servicename'];
  30              $service->code = (get_magic_quotes_gpc() ? stripslashes($_GET['code']) : $_GET['code']);
  31              $service->result = (get_magic_quotes_gpc() ? stripslashes($_GET['result']) : $_GET['result']);
  32              $service->quality = (get_magic_quotes_gpc() ? stripslashes($_GET['quality']) : $_GET['quality']);
  33              $service->language = $_GET['language'];
  34              $service->update();
  35              $link = "service.php?action=edit&service_id=$service_id";
  36              $message = "Service '".$service->name."' updated!";
  37          } else {
  38              $name = $_GET['servicename'];
  39              $code = $_GET['code'];
  40              $result = $_GET['result'];
  41              $quality = $_GET['quality'];
  42              $language = $_GET['language'];
  43              $service = new Service($config);
  44              if ($service->create($name, $language, $code, $result, $quality))
  45                  $message = "Service '".$name."' created!";
  46              else {
  47                  $timeout = $config->redir_timeout_error;
  48                  $message = "Cannot create duplicated services!";
  49              }
  50              $link = "admin.php";
  51          }
  52          include ('message.php');
  53      } else {
  54          $service = new Service($config, $service_id);
  55  ?>
  56  
  57  <p>
  58  <form action="service.php">
  59  <input type=hidden name=action value=edit>
  60  <input type=hidden name=service_id value="<?php print $service->id ?>">
  61  <table>
  62      <tr>
  63          <td class='title'>Service</td><td class='field'><input type=text name=servicename value="<?php print $service->name ?>"></td>
  64      </tr>
  65      <tr>
  66          <td class='title'>Code</td><td class='field'><textarea name=code><?php print $service->code ?></textarea></td>
  67      </tr>
  68      <tr>
  69          <td class='title'>Expected Result (regex)</td><td class='field'><input type=text name=result value="<?php print $service->result ?>"></td>
  70      </tr>
  71      <tr>
  72          <td class='title'>Quality (regex)</td><td class='field'><input type=text name=quality value="<?php print $service->quality ?>"></td>
  73      </tr>
  74      <tr>
  75          <td class='title'>Language</td><td class='field'>
  76              <select name=language>
  77              <?php foreach (getLanguages() as $language) {
  78                  if ($language->id == $service->language->id)
  79                      $selected = "selected";
  80                  else
  81                      $selected = "";
  82                  print "<option value=\"$language->id\" $selected>$language->name</option>\n";
  83              } ?>
  84              </select>
  85          </td>
  86      </tr>
  87      <tr>
  88          <td class='link' colspan=2><input type=submit value="Update"></td>
  89      </tr>
  90  </table>
  91  </form>
  92  <p>
  93  
  94  <?php
  95  // ===================== VIEW
  96      }
  97  } else {
  98  ?>
  99  
 100  <p>
 101  <table>
 102      <tr>
 103          <td class='title'>Service</td><td class='field'><?php print $service->name ?></td>
 104      </tr>
 105      <tr>
 106          <td class='title'>Code</td><td class='field'><?php print $service->code ?></td>
 107      </tr>
 108      <tr>
 109          <td class='title'>Expected Result</td><td class='field'><?php print $service->result ?></td>
 110      </tr>
 111      <tr>
 112          <td class='title'>Language</td><td class='field'><?php print $service->language->name ?></td>
 113      </tr>
 114  </table>
 115  <p>
 116  
 117  <?php
 118  }
 119  include ('footer.php');
 120  ?>


Generated: Sat Feb 19 17:29:53 2005 Cross-referenced by PHPXref 0.6