2 include_once $gfplugins.'webcalendar/www/includes/init.php';
6 $viewisglobal = getPostValue ( "is_global" );
7 if ( ! $is_admin || $viewisglobal != 'Y' )
8 $viewisglobal = 'N'; // only admin can create global view
9 //echo "viewisglobal = $viewisglobal"; exit;
11 if ( $action == "Delete" || $action == translate ("Delete") ) {
13 dbi_query ( "DELETE FROM webcal_view WHERE cal_view_id = $id " .
14 "AND cal_owner = '$login'" );
16 if ( empty ( $viewname ) ) {
17 $error = translate("You must specify a view name");
19 else if ( ! empty ( $id ) ) {
21 if ( ! dbi_query ( "UPDATE webcal_view SET cal_name = " .
22 "'$viewname', cal_view_type = '$viewtype', " .
23 "cal_is_global = '$viewisglobal' " .
24 "WHERE cal_view_id = $id AND cal_owner = '$login'" ) ) {
25 $error = translate ("Database error") . ": " . dbi_error();
28 # new... get new id first
29 $res = dbi_query ( "SELECT MAX(cal_view_id) FROM webcal_view" );
31 $row = dbi_fetch_row ( $res );
34 dbi_free_result ( $res );
35 $sql = "INSERT INTO webcal_view " .
36 "( cal_view_id, cal_owner, cal_name, cal_view_type, cal_is_global ) " .
37 " VALUES ( $id, '$login', '$viewname', '$viewtype', '$viewisglobal' )";
38 if ( ! dbi_query ( $sql ) ) {
39 $error = translate ("Database error") . ": " . dbi_error();
42 $error = translate ("Database error") . ": " . dbi_error();
48 dbi_query ( "DELETE FROM webcal_view_user WHERE cal_view_id = $id" );
49 // If selected "All", then just put "__all__" in for usernamne.
50 if ( getPostValue ( "viewuserall" ) == "Y" )
51 $users = array ( "__all__" );
52 for ( $i = 0; ! empty ( $users ) && $i < count ( $users ); $i++ ) {
53 dbi_query ( "INSERT INTO webcal_view_user ( cal_view_id, cal_login ) " .
54 "VALUES ( $id, '$users[$i]' )" );
62 do_redirect ( "views.php" );
67 <h2><?php etranslate("Error")?></h2>
74 // echo "<br /><br /><span style=\"font-weight:bold;\">SQL:</span> $sql";
78 <?php print_trailer(); ?>