2 include_once $gfplugins.'webcalendar/www/includes/init.php';
6 if ( $allow_view_other != 'Y' ) {
7 $error = translate("You are not authorized");
10 if ( empty ( $dups ) )
13 $updating_public = false;
14 if ( $is_admin && ! empty ( $public ) && $public_access == "Y" ) {
15 $updating_public = true;
16 $layer_user = "__public__";
21 if ( $layer_user == $layeruser )
22 $error = translate ("You cannot create a layer for yourself") . ".";
24 load_user_layers ( $layer_user, 1 );
26 if ( ! empty ( $layeruser ) && $error == "" ) {
27 // existing layer entry
28 if ( ! empty ( $layers[$id]['cal_layeruser'] ) ) {
29 // update existing layer entry for this user
30 $layerid = $layers[$id]['cal_layerid'];
32 dbi_query ( "UPDATE webcal_user_layers SET cal_layeruser = '$layeruser', cal_color = '$layercolor', cal_dups = '$dups' WHERE cal_layerid = '$layerid'");
36 // check for existing layer for user. can only have one layer per user
37 $res = dbi_query ( "SELECT COUNT(cal_layerid) FROM webcal_user_layers " .
38 "WHERE cal_login = '$layer_user' AND cal_layeruser = '$layeruser'" );
40 $row = dbi_fetch_row ( $res );
42 $error = translate ("You can only create one layer for each user") . ".";
44 dbi_free_result ( $res );
47 $res = dbi_query ( "SELECT MAX(cal_layerid) FROM webcal_user_layers" );
49 $row = dbi_fetch_row ( $res );
50 $layerid = $row[0] + 1;
54 dbi_query ( "INSERT INTO webcal_user_layers ( ".
55 "cal_layerid, cal_login, cal_layeruser, cal_color, cal_dups ) " .
56 "VALUES ('$layerid', '$layer_user', '$layeruser', " .
57 "'$layercolor', '$dups')");
63 if ( $updating_public )
64 do_redirect ( "layers.php?public=1" );
66 do_redirect ( "layers.php" );
73 <h2><?php etranslate("Error")?></h2>
78 <?php print_trailer(); ?>