WebCalendar PHP Cross Reference Groupware Applications

Source: /category.php - 156 lines - 5617 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: category.php,v 1.45.2.3 2008/03/03 20:51:33 cknudsen Exp $ */
   3  
   4  include_once  'includes/init.php';
   5  // Load user and global cats.
   6  load_user_categories ();
   7  
   8  if ( $CATEGORIES_ENABLED == 'N' ) {
   9    send_to_preferred_view ();
  10    exit;
  11  }
  12  
  13  $catIcon = $catname = $error = $idStr = '';
  14  $catIconStr = translate ( 'Category Icon' );
  15  $globalStr = translate ( 'Global' );
  16  $icon_path = 'icons/';
  17  // If editing, make sure they are editing their own (or they are an admin user).
  18  if ( ! empty ( $id ) ) {
  19    if ( empty ( $categories[$id] ) )
  20      $error =
  21      str_replace ( 'XXX', $id, translate ( 'Invalid entry id XXX.' ) );
  22  
  23    $catcolor = $categories[$id]['cat_color'];
  24    $catname = $categories[$id]['cat_name'];
  25    $catowner = $categories[$id]['cat_owner'];
  26    $catIcon = $icon_path . 'cat-' . $id . '.gif';
  27    $idStr = '<input name="id" type="hidden" value="' . $id . '" />';
  28  } else
  29    $catcolor = '#000000';
  30  
  31  $showIcon = ( ! empty ( $catIcon ) && file_exists ( $catIcon )
  32    ? 'visible' : 'hidden' );
  33  
  34  print_header ( array ( 'js/visible.php' ) );
  35  
  36  ob_start ();
  37  
  38  echo '
  39      <h2>' . translate ( 'Categories' ) . '</h2>
  40      ' . display_admin_link ();
  41  
  42  $add = getGetValue ( 'add' );
  43  if ( empty ( $add ) )
  44    $add = 0;
  45  // Adding/Editing category.
  46  if ( ( ( $add == '1' ) || ( ! empty ( $id ) ) ) && empty ( $error ) ) {
  47    echo '
  48      <form action="category_handler.php" method="post" name="catform" '
  49     . 'enctype="multipart/form-data">' . $idStr . '
  50        <table cellspacing="2" cellpadding="3">
  51          <tr>
  52            <td width="25%"><label for="catname">' . translate ( 'Category Name' )
  53     . '</label></td>
  54            <td colspan="3"><input type="text" name="catname" size="20" value="'
  55     . htmlspecialchars ( $catname ) . '" /></td>
  56          </tr>' . ( $is_admin && empty ( $id ) ? '
  57          <tr>
  58            <td><label for="isglobal">' . $globalStr . ':</label></td>
  59            <td colspan="3">
  60              <label><input type="radio" name="isglobal" value="N" '
  61       . ( ! empty ( $catowner ) || empty ( $id ) ? ' checked = "checked"' : '' )
  62       . ' />&nbsp;' . translate ( 'No' ) . '</label>&nbsp;&nbsp;
  63              <label><input type="radio" name="isglobal" value="Y" '
  64       . ( empty ( $catowner ) && ! empty ( $id ) ? ' checked = "checked"' : '' )
  65       . ' />&nbsp;' . translate ( 'Yes' ) . '</label>
  66            </td>
  67          </tr>' : '' ) . '
  68          <tr>
  69            <td>'
  70     . print_color_input_html ( 'catcolor', translate ( 'Color' ), $catcolor )
  71     . '</td>
  72          </tr>
  73          <tr id="cat_icon" style="visibility: ' . $showIcon . '">
  74            <td><label>' . $catIconStr . ':</label></td>
  75            <td colspan="3"><img src="' . $catIcon
  76     . '" name="urlpic" id="urlpic" alt="' . $catIconStr . '" /></td>
  77          </tr>
  78          <tr id="remove_icon" style="visibility: ' . $showIcon . '">
  79            <td><label for="delIcon">' . translate ( 'Remove Icon' )
  80     . '</label></td>
  81            <td colspan="3"><input type="checkbox" name="delIcon" value="Y" /></td>
  82          </tr>
  83          <tr>
  84            <td colspan="4">
  85              <label for="FileName">' . ( is_dir ( $icon_path ) &&
  86      ( $ENABLE_ICON_UPLOADS == 'Y' || $is_admin )
  87      ? translate ( 'Add Icon to Category' ) . '</label><br />&nbsp;&nbsp;&nbsp;'
  88       . translate ( 'Upload' ) . '&nbsp;<span style="font-size:small;">'
  89       . translate ( 'gif 3kb max' ) . '</span>:
  90              <input type="file" name="FileName" id="fileupload" size="45" '
  91       . 'maxlength="50" value=""/>
  92            </td>
  93          </tr>
  94          </tr>
  95            <td colspan="4">
  96              <input type="hidden" name="urlname" size="50" />&nbsp;&nbsp;&nbsp;
  97              <input type="button" value="'
  98       . translate ( 'Search for existing icons' )
  99       . '" onclick="window.open( \'icons.php\', \'icons\',\''
 100       . 'dependent,menubar=no,scrollbars=n0,height=300,width=400,outerHeight=320'
 101       . ',outerWidth=420\' );" />
 102            </td>
 103          </tr>
 104          </tr>
 105            <td colspan="4">' : '' ) // end test of ENABLE_ICON_UPLOADS
 106    . '
 107              <input type="submit" name="action" value="'
 108     . ( $add == '1' ? translate ( 'Add' ) : translate ( 'Save' ) ) . '" />'
 109     . ( ! empty ( $id ) ? '
 110              <input type="submit" name="delete" value="'
 111       . translate ( 'Delete' ) . '" onclick="return confirm( '
 112       . str_replace ( 'XXX', translate ( 'entry', true ),
 113        translate ( 'Are you sure you want to delete this XXX?', true ) )
 114       . '\' )" />' : '' ) . '
 115            </td>
 116          </tr>
 117        </table>
 118      </form>';
 119  } else
 120  if ( empty ( $error ) ) {
 121    // Displaying Categories.
 122    $global_found = false;
 123    if ( ! empty ( $categories ) ) {
 124      echo '
 125      <ul>';
 126      foreach ( $categories as $K => $V ) {
 127        if ( $K < 1 )
 128          continue;
 129        $catIcon = $icon_path . 'cat-' . $K . '.gif';
 130        $catStr = '<span style="color: '
 131         . ( ! empty ( $V['cat_color'] ) ? $V['cat_color'] : '#000000' )
 132         . ';">' . $V['cat_name'] . '</span>';
 133        echo '
 134        <li>' . ( $V['cat_owner'] == $login || $is_admin
 135          ? '<a href="category.php?id=' . $K . '">' . $catStr . '</a>' : $catStr );
 136  
 137        if ( empty ( $V['cat_owner'] ) ) {
 138          echo '<sup>*</sup>';
 139          $global_found = true;
 140        }
 141  
 142        echo ( file_exists ( $catIcon ) ? '<img src="' . $catIcon . '" alt="'
 143           . $catIconStr . '" title="' . $catIconStr . '" />' : '' ) . '</li>';
 144      }
 145      echo '
 146      </ul>';
 147    }
 148    echo ( $global_found ? '<br /><br />
 149      <sup>*</sup> ' . $globalStr : '' ) . '
 150      <p><a href="category.php?add=1">' . translate ( 'Make New Category' )
 151     . '</a></p><br />';
 152  }
 153  ob_end_flush ();
 154  echo ( ! empty ( $error ) ? print_error ( $error ) : '' ) . print_trailer ();
 155  
 156  ?>

title

Description

title

Description

title

Description

title

title

Body