WebCalendar PHP Cross Reference Groupware Applications

Source: /group_edit_handler.php - 60 lines - 1977 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: group_edit_handler.php,v 1.27.2.3 2012/02/28 02:07:45 cknudsen Exp $ */
   3  include_once  'includes/init.php';
   4  require_valide_referring_url ();
   5  
   6  $id = getPostValue ( 'id' );
   7  $groupname = getPostValue ( 'groupname' );
   8  $users = getPostValue ( 'users' );
   9  
  10  if ( ! $is_admin )
  11    $error = print_not_auth (3);
  12  else {
  13    $delete = getPostValue ( 'delete' );
  14    if ( ! empty ( $delete ) ) {
  15      // Delete this group.
  16      dbi_execute ( 'DELETE FROM webcal_group WHERE cal_group_id = ? ',
  17        array ( $id ) );
  18      dbi_execute ( 'DELETE FROM webcal_group_user WHERE cal_group_id = ? ',
  19        array ( $id ) );
  20    } else {
  21      $dateYmd = date ( 'Ymd' );
  22      if ( empty ( $groupname ) )
  23        $error = translate ( 'You must specify a group name' );
  24      else
  25      if ( ! empty ( $id ) ) {
  26        # update
  27        if ( ! dbi_execute ( 'UPDATE webcal_group SET cal_name = ?,
  28          cal_last_update = ? WHERE cal_group_id = ?',
  29            array ( $groupname, $dateYmd, $id ) ) )
  30          $error = db_error ();
  31      } else {
  32        # new... get new id first
  33        $res = dbi_execute ( 'SELECT MAX( cal_group_id ) FROM webcal_group' );
  34        if ( $res ) {
  35          $row = dbi_fetch_row ( $res );
  36          $id = $row[0];
  37          $id++;
  38          dbi_free_result ( $res );
  39          if ( ! dbi_execute ( 'INSERT INTO webcal_group ( cal_group_id, cal_owner,
  40            cal_name, cal_last_update ) VALUES ( ?, ?, ?, ? )',
  41              array ( $id, $login, $groupname, $dateYmd ) ) )
  42            $error = db_error ();
  43        } else
  44          $error = db_error ();
  45      }
  46      # update user list
  47      if ( empty ( $error ) && ! empty ( $users ) ) {
  48        dbi_execute ( 'DELETE FROM webcal_group_user WHERE cal_group_id = ?',
  49          array ( $id ) );
  50        for ( $i = 0, $cnt = count ( $users ); $i < $cnt; $i++ ) {
  51          dbi_execute ( 'INSERT INTO webcal_group_user ( cal_group_id, cal_login )
  52            VALUES ( ?, ? )', array ( $id, $users[$i] ) );
  53        }
  54      }
  55    }
  56  }
  57  
  58  echo error_check ( 'users.php', false );
  59  
  60  ?>

title

Description

title

Description

title

Description

title

title

Body