[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 include_once 'includes/init.php'; 3 load_user_layers (); 4 5 if ( ! $is_admin ) { 6 echo "<h2>" . translate("Error") . 7 "</h2>" . translate("You are not authorized") . ".\n"; 8 print_trailer (); 9 echo "</body></html>\n"; 10 exit; 11 } 12 $error = ""; 13 14 if ( $action == "Delete" || $action == translate ("Delete") ) { 15 // delete this nonuser calendar 16 $user = $nid; 17 18 // Get event ids for all events this user is a participant 19 $events = array (); 20 $res = dbi_query ( "SELECT webcal_entry.cal_id " . 21 "FROM webcal_entry, webcal_entry_user " . 22 "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . 23 "AND webcal_entry_user.cal_login = '$user'" ); 24 if ( $res ) { 25 while ( $row = dbi_fetch_row ( $res ) ) { 26 $events[] = $row[0]; 27 } 28 } 29 30 // Now count number of participants in each event... 31 // If just 1, then save id to be deleted 32 $delete_em = array (); 33 for ( $i = 0; $i < count ( $events ); $i++ ) { 34 $res = dbi_query ( "SELECT COUNT(*) FROM webcal_entry_user " . 35 "WHERE cal_id = " . $events[$i] ); 36 if ( $res ) { 37 if ( $row = dbi_fetch_row ( $res ) ) { 38 if ( $row[0] == 1 ) 39 $delete_em[] = $events[$i]; 40 } 41 dbi_free_result ( $res ); 42 } 43 } 44 // Now delete events that were just for this user 45 for ( $i = 0; $i < count ( $delete_em ); $i++ ) { 46 dbi_query ( "DELETE FROM webcal_entry WHERE cal_id = " . $delete_em[$i] ); 47 } 48 49 // Delete user participation from events 50 dbi_query ( "DELETE FROM webcal_entry_user WHERE cal_login = '$user'" ); 51 52 // Delete any layers other users may have that point to this user. 53 dbi_query ( "DELETE FROM webcal_user_layers WHERE cal_layeruser = '$user'" ); 54 55 // Delete user 56 if ( ! dbi_query ( "DELETE FROM webcal_nonuser_cals WHERE cal_login = '$user'" ) ) 57 $error = translate ("Database error") . ": " . dbi_error(); 58 59 } else { 60 if ( $action == "Save" || $action == translate ("Save") ) { 61 // Updating 62 $sql = "UPDATE webcal_nonuser_cals SET "; 63 if ($nlastname) $sql .= " cal_lastname = '$nlastname', "; 64 if ($nfirstname) $sql .= " cal_firstname = '$nfirstname', "; 65 $sql .= "cal_admin = '$nadmin' WHERE cal_login = '$nid'"; 66 if ( ! dbi_query ( $sql ) ) { 67 $error = translate ("Database error") . ": " . dbi_error(); 68 } 69 } else { 70 // Adding 71 if (preg_match( "/^[\w]+$/", $nid )) { 72 $nid = $NONUSER_PREFIX.$nid; 73 $sql = "INSERT INTO webcal_nonuser_cals " . 74 "( cal_login, cal_firstname, cal_lastname, cal_admin ) " . 75 "VALUES ( '$nid', '$nfirstname', '$nlastname', '$nadmin' )"; 76 if ( ! dbi_query ( $sql ) ) { 77 $error = translate ("Database error") . ": " . dbi_error(); 78 } 79 } else { 80 $error = translate ("Calendar ID")." ".translate ("word characters only")."."; 81 } 82 } 83 } 84 if ( empty ( $error ) ) do_redirect ( "nonusers.php" ); 85 86 print_header(); 87 ?> 88 89 <h2><?php etranslate("Error")?></h2> 90 91 <blockquote> 92 <?php 93 94 echo $error; 95 //if ( $sql != "" ) 96 // echo "<br /><br /><b>SQL:</b> $sql"; 97 //?> 98 </blockquote> 99 100 <?php print_trailer(); ?> 101 </body> 102 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Nov 30 19:09:19 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |