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

/ -> category.php (source)

   1  <?php
   2  include_once  'includes/init.php';
   3  
   4  // load user and global cats
   5  load_user_categories ();
   6  
   7  $error = "";
   8  
   9  if ( $categories_enabled == "N" ) {
  10    send_to_preferred_view ();
  11    exit;
  12  }
  13  
  14  // If editing, make sure they are editing their own
  15  // (or they are an admin user).
  16  if ( ! empty ( $id ) ) {
  17    $res = dbi_query ( "SELECT cat_id, cat_owner FROM webcal_categories WHERE " .
  18      "cat_id = $id" );
  19    if ( $res ) {
  20      if ( $row = dbi_fetch_row ( $res ) ) {
  21        if ( $row[0] != $id )
  22          $error = translate ( "Invalid entry id" ) . ": " . $id;
  23        else if ( $row[1] != $login && ! $is_admin )
  24          $error = translate ( "You are not authorized" ) . ".";
  25      }
  26      dbi_free_result ( $res );
  27    } else {
  28      $error = translate("Database error") . ": " . dbi_error ();
  29    }
  30  }
  31  
  32  print_header();
  33  ?>
  34  <h2><?php etranslate("Categories")?></h2>
  35  <a title="<?php etranslate("Admin") ?>" class="nav" href="adminhome.php">&laquo;&nbsp;<?php etranslate("Admin") ?></a><br /><br />
  36  <?php
  37  
  38  if ( empty ( $add ) )
  39    $add = 0;
  40  
  41  // Adding/Editing category
  42  if ( ( ( $add == '1' ) || ( ! empty ( $id ) ) ) && empty ( $error ) ) {
  43    $button = translate("Add");
  44    ?>
  45    <form action="category_handler.php" method="post">
  46    <?php
  47    if ( ! empty ( $id ) ) {
  48      echo "<input name=\"id\" type=\"hidden\" value=\"$id\" />";
  49      $button = translate("Save");
  50      $catname = $categories[$id];
  51      $catowner = $category_owners[$id];
  52    } else {
  53      $catname = '';
  54    }
  55    ?>
  56    <?php etranslate("Category Name")?>: <input type="text" name="catname" size="20" value="<?php echo htmlspecialchars ( $catname ); ?>" />
  57    <br />
  58    <?php if ( $is_admin && empty ( $id ) ) { ?>
  59      <?php etranslate("Global")?>:
  60        <label><input type="radio" name="isglobal" value="N" <?php if ( ! empty ( $catowner ) || empty ( $id ) ) echo " checked=\"checked\"";?> />&nbsp;<?php etranslate("No")?></label>&nbsp;&nbsp;
  61        <label><input type="radio" name="isglobal" value="Y" <?php if ( empty ( $catowner ) && ! empty ( $id ) ) echo " checked=\"checked\"";?> />&nbsp;<?php etranslate("Yes")?></label>
  62    <?php } ?>
  63    <br /><br />
  64    <input type="submit" name="action" value="<?php echo $button;?>" />
  65    <?php if ( ! empty ( $id ) ) {  ?>
  66      <input type="submit" name="action" value="<?php etranslate("Delete");?>" onclick="return confirm('<?php etranslate("Are you sure you want to delete this entry?"); ?>')" />
  67    <?php }  ?>
  68    </form>
  69    <?php
  70  } else if ( empty ( $error ) ) {
  71    // Displaying Categories
  72    $global_found = false;
  73    if ( ! empty ( $categories ) ) {
  74      echo "<ul>";
  75      foreach ( $categories as $K => $V ) {
  76        echo "<li>";
  77        if ( $category_owners[$K] == $login || $is_admin )
  78          echo "<a href=\"category.php?id=$K\">$V</a>";
  79        else
  80          echo $V;
  81        if ( empty ( $category_owners[$K] ) ) {
  82          echo "<sup>*</sup>";
  83      $global_found = true;
  84        }
  85        echo "</li>\n";
  86      }
  87      echo "</ul>";
  88    }
  89    if ( $global_found )
  90      echo "<br /><br />\n<sup>*</sup> " . translate ( "Global" );
  91    echo "<p><a href=\"category.php?add=1\">" . translate("Add New Category") . "</a></p><br />\n";
  92  }
  93  
  94  if ( ! empty ( $error ) ) {
  95    echo "<span style=\"font-weight:bold;\">" . translate ( "Error" ) . ":</span>" . $error;
  96  }
  97  ?>
  98  
  99  <?php print_trailer(); ?>
 100  </body>
 101  </html>


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