WebCalendar PHP Cross Reference Groupware Applications

Source: /views_edit_handler.php - 66 lines - 2190 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: views_edit_handler.php,v 1.25.2.2 2012/02/28 02:07:45 cknudsen Exp $ */
   3  include_once  'includes/init.php';
   4  require_valide_referring_url ();
   5  
   6  $error = '';
   7  
   8  $viewisglobal = getPostValue ( 'is_global' );
   9  $viewname = getPostValue ( 'viewname' );
  10  $viewtype = getPostValue ( 'viewtype' );
  11  $users = getPostValue ( 'users' );
  12  $delete = getPostValue ( 'delete' );
  13  
  14  if ( ! $is_admin || $viewisglobal != 'Y' )
  15    $viewisglobal = 'N'; // Only admin can create global view.
  16    //.
  17  if ( ! empty ( $delete ) )
  18    // Delete this view.
  19    dbi_execute ( 'DELETE FROM webcal_view WHERE cal_view_id = ? AND cal_owner = ?',
  20      array ( $id, $login ) );
  21  else {
  22    if ( empty ( $viewname ) )
  23      $error = translate ( 'You must specify a view name' );
  24    else
  25    if ( ! empty ( $id ) ) {
  26      // update
  27      if ( ! dbi_execute ( 'UPDATE webcal_view SET cal_name = ?, cal_view_type = ?,
  28        cal_is_global = ? WHERE cal_view_id = ? AND cal_owner = ?',
  29          array ( $viewname, $viewtype, $viewisglobal, $id, $login ) ) )
  30        $error = db_error ();
  31    } else {
  32      # new... Get new id first.
  33      $res = dbi_execute ( 'SELECT MAX( cal_view_id ) FROM webcal_view',
  34        array () );
  35      if ( $res ) {
  36        $row = dbi_fetch_row ( $res );
  37        $id = $row[0];
  38        $id++;
  39        dbi_free_result ( $res );
  40        $sql_params = array ( $id, $login, $viewname, $viewtype, $viewisglobal );
  41        if ( ! dbi_execute ( 'INSERT INTO webcal_view ( cal_view_id, cal_owner,
  42          cal_name, cal_view_type, cal_is_global ) VALUES ( ?, ?, ?, ?, ? )',
  43            $sql_params ) )
  44          $error = db_error ();
  45      } else
  46        $error = db_error ();
  47    }
  48    # update user list
  49    if ( $error == '' ) {
  50      dbi_execute ( 'DELETE FROM webcal_view_user WHERE cal_view_id = ?',
  51        array ( $id ) );
  52      // If selected "All", then just put "__all__" in for username.
  53      if ( getPostValue ( 'viewuserall' ) == 'Y' )
  54        $users = array ( '__all__' );
  55  
  56      for ( $i = 0, $cnt = count ( $users );
  57        ! empty ( $users ) && $i < $cnt; $i++ ) {
  58        dbi_execute ( 'INSERT INTO webcal_view_user ( cal_view_id, cal_login )
  59          VALUES ( ?, ? )', array ( $id, $users[$i] ) );
  60      }
  61    }
  62  }
  63  
  64  echo error_check ( 'views.php', false );
  65  
  66  ?>

title

Description

title

Description

title

Description

title

title

Body