Location: PHPKode > projects > Course-manager > courseman-0.1.1/delete_account.php
<?php
  require('global-php.php');
  header('Content-type: text/xml; charset=utf-8');
  $verbindung = database_connection(
  	      "<status>" . $lang_database_failure[$language] . "</status>");
  $PHP_AUTH_USER = $_SERVER["PHP_AUTH_USER"];
  $PHP_AUTH_PW = $_SERVER["PHP_AUTH_PW"];
  $ergebnis = db_exec($verbindung,
			"SELECT * FROM staff_authorization,superuser,"
					. "capability "
				. "WHERE superuser.account"
				. "=staff_authorization.id "
				. "AND superuser.capability=capability.id "
				. "AND capability.name='users' "
				. "AND "
				. login_query_clauses(
					$PHP_AUTH_USER,
					$PHP_AUTH_PW)
				. ";");
  if (pg_numrows($ergebnis) < 1) {
    header('WWW-Authenticate: Basic realm="Kursverwaltung"');
    header("HTTP/1.0 401 Unauthorized");
    echo '<status>' . $lang_authentication_failure[$language] . '</status>';
    db_close($verbindung);
    exit;
  }
  $account = intval($_REQUEST["account"]);
  db_exec($verbindung, "START TRANSACTION;");
  db_exec($verbindung, "LOCK TABLE staff_authorization;");
  db_exec($verbindung, "LOCK TABLE authorized_course;");
  db_exec($verbindung, "LOCK TABLE superuser;");
  db_exec($verbindung, "DELETE FROM superuser "
			. "WHERE account=$account "
			. "AND EXISTS (SELECT true FROM superuser AS other "
			. "WHERE NOT other.account=$account);");
  db_exec($verbindung, "DELETE FROM authorized_course "
			. "WHERE account=$account "
			. "AND EXISTS (SELECT true FROM superuser "
			. "WHERE NOT superuser.account=$account);");
  $ergebnis = db_exec($verbindung, "SELECT name FROM staff_authorization "
					. "WHERE id=$account;");
  if (0 < pg_numrows($ergebnis)) {
    $name = pg_result($ergebnis, 0, 0);
  }
  $deleted = pg_cmdtuples(db_exec($verbindung, "DELETE "
			. "FROM staff_authorization "
			. "WHERE id=$account "
			. "AND EXISTS (SELECT true FROM superuser "
			. "WHERE NOT account=$account);"));
  if ((pg_result_status(db_exec($verbindung, "COMMIT;")) == PGSQL_COMMAND_OK)
   && ($deleted > 0)) {
?>
<status><?=lang_account_deleted($language,$name)?></status>
<?php
  } else {
?>
<status><?=$lang_account_not_deleted[$language]?></status>
<?php
  }
  db_close($verbindung);
?>
Return current item: Course-manager