[ 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 echo "</body>\n</html>"; 9 exit; 10 } 11 $error = ""; 12 13 if ( $action == "Delete" || $action == translate ("Delete") ) { 14 // delete this nonuser calendar 15 $user = $nid; 16 17 // Get event ids for all events this user is a participant 18 $events = array (); 19 $res = dbi_query ( "SELECT webcal_entry.cal_id " . 20 "FROM webcal_entry, webcal_entry_user " . 21 "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . 22 "AND webcal_entry_user.cal_login = '$user'" ); 23 if ( $res ) { 24 while ( $row = dbi_fetch_row ( $res ) ) { 25 $events[] = $row[0]; 26 } 27 } 28 29 // Now count number of participants in each event... 30 // If just 1, then save id to be deleted 31 $delete_em = array (); 32 for ( $i = 0; $i < count ( $events ); $i++ ) { 33 $res = dbi_query ( "SELECT COUNT(*) FROM webcal_entry_user " . 34 "WHERE cal_id = " . $events[$i] ); 35 if ( $res ) { 36 if ( $row = dbi_fetch_row ( $res ) ) { 37 if ( $row[0] == 1 ) 38 $delete_em[] = $events[$i]; 39 } 40 dbi_free_result ( $res ); 41 } 42 } 43 // Now delete events that were just for this user 44 for ( $i = 0; $i < count ( $delete_em ); $i++ ) { 45 dbi_query ( "DELETE FROM webcal_entry WHERE cal_id = " . $delete_em[$i] ); 46 } 47 48 // Delete user participation from events 49 dbi_query ( "DELETE FROM webcal_entry_user WHERE cal_login = '$user'" ); 50 51 // Delete any layers other users may have that point to this user. 52 dbi_query ( "DELETE FROM webcal_user_layers WHERE cal_layeruser = '$user'" ); 53 54 // Delete user 55 if ( ! dbi_query ( "DELETE FROM webcal_nonuser_cals WHERE cal_login = '$user'" ) ) 56 $error = translate ("Database error") . ": " . dbi_error(); 57 58 } else { 59 if ( $action == "Save" || $action == translate ("Save") ) { 60 // Updating 61 $sql = "UPDATE webcal_nonuser_cals SET "; 62 if ($nlastname) $sql .= " cal_lastname = '$nlastname', "; 63 if ($nfirstname) $sql .= " cal_firstname = '$nfirstname', "; 64 $sql .= "cal_admin = '$nadmin' WHERE cal_login = '$nid'"; 65 if ( ! dbi_query ( $sql ) ) { 66 $error = translate ("Database error") . ": " . dbi_error(); 67 } 68 } else { 69 // Adding 70 if (preg_match( "/^[\w]+$/", $nid )) { 71 $nid = $NONUSER_PREFIX.$nid; 72 $sql = "INSERT INTO webcal_nonuser_cals " . 73 "( cal_login, cal_firstname, cal_lastname, cal_admin ) " . 74 "VALUES ( '$nid', '$nfirstname', '$nlastname', '$nadmin' )"; 75 if ( ! dbi_query ( $sql ) ) { 76 $error = translate ("Database error") . ": " . dbi_error(); 77 } 78 } else { 79 $error = translate ("Calendar ID")." ".translate ("word characters only")."."; 80 } 81 } 82 } 83 84 if ( ! empty ( $error ) ) { 85 print_header( '', '', '', true ); 86 ?> 87 88 <h2><?php etranslate("Error")?></h2> 89 90 <blockquote> 91 <?php 92 echo $error; 93 //if ( $sql != "" ) 94 // echo "<br /><br /><b>SQL:</b> $sql"; 95 //?> 96 </blockquote> 97 </body> 98 </html> 99 <?php } else if ( empty ( $error ) ) { 100 ?><html><head></head><body onload="alert('<?php etranslate("Changes successfully saved");?>'); window.parent.location.href='users.php';"> 101 </body></html> 102 <?php } ?>
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 |
![]() |