Location: PHPKode > projects > Course-manager > courseman-0.1.1/duplicate-course.php
<?php
  require('global-php.php');
  $verbindung = database_connection($lang_database_failure[$language]);
  $PHP_AUTH_USER = $_SERVER["PHP_AUTH_USER"];
  $PHP_AUTH_PW = $_SERVER["PHP_AUTH_PW"];
  $ergebnis = db_exec($verbindung,
			"SELECT * FROM staff_authorization,superuser "
				. "WHERE superuser.account"
				. "=staff_authorization.id "
				. "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 $lang_authentication_failure[$language];
    db_close($verbindung);
    exit;
  }
  $course = intval($_REQUEST["course"]);
  $course_period = option_value($course_period_option);
  db_exec($verbindung, "START TRANSACTION;");
  db_exec($verbindung, "LOCK TABLE course;");
  db_exec($verbindung, "LOCK TABLE $course_date;");
  db_exec($verbindung, "INSERT INTO course (name,category,course_period) "
			. "SELECT coalesce((SELECT max(name) "
				. "FROM course "
				. "WHERE course_period=$course_period "
				. "AND name like 'new course%'),"
					. "'new course')||' ',category,"
				. "course_period "
				. "FROM course,$course_date "
				. "WHERE course=course.id "
				. "AND $course_date.id=$course;");
  db_exec($verbindung, "INSERT INTO $course_date ($date_columns,course) "
			. "SELECT $date_columns,course.id "
				. "FROM course,$course_date "
				. "WHERE $course_date.id=$course "
				. "AND course.name=(SELECT max(name) "
					. "FROM course "
					. "WHERE course_period=$course_period "
					. "AND name like 'new course%');");
  db_exec($verbindung, "COMMIT;");
  db_close($verbindung);
?>
Return current item: Course-manager