Sponsorenverwaltung - Team StarCraft e.V.
 All Data Structures Files Functions Variables
export_mail.php
Go to the documentation of this file.
1 <?php
2  /**
3  * @file export_mail.php
4  *
5  * @brief Downloads a *.csv file with contact information of contact persons.
6 
7  * @copyright (c) 2013, Team StarCraft e.V.
8  * @version 1.1
9  * @author Niklas Engelhardt
10  * @author Alexander Vorndran
11  * @author Clemens Heinrich
12  * @date 02.07.2013
13  */
14 
15  /// @cond MAINPART
16  // include
17  include("inc/common.php");
18 
19  // UserCake
20  if (!accessGranted($_SERVER['PHP_SELF'])) {
21  if (isUserLoggedIn()) {
22  exitWithErrorTemplate(array('Die angeforderte Seite ist gesperrt.'));
23  } else {
24  exitWithErrorTemplateAndRedirect(array('Die angeforderte Seite ist gesperrt oder geschützt.'), 'login.php', 2);
25  }
26  }
27 
28  if (isset($_GET['result'])) {
29  // this result identifier is the key to obtain the data the user has selected for export
30  $resultIdentifier = $_GET['result'];
31  if (ctype_alnum($resultIdentifier)) {
32  $sponsorIds = $loggedInUser->loadResult($_GET['result']);
33  $mailaddresses = fetchContactPersonsWithMailAdresses($sponsorIds);
34  } else {
35  $err[] = "Token ungültig!";
37  }
38  } else {
39  $mailaddresses = (fetchContactPersonsWithMailAdresses());
40  }
41 
42  downloadCsvFile("Mail_Ansprechpartner_" . date("Y-m-d") . ".csv");
43  echo writeCsvFile($mailaddresses);
44  die();
45  /// @endcond
46 ?>
47 
48 
49