PageRenderTime 134ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/guestlist/export.php

http://lansuite.googlecode.com/
PHP | 90 lines | 68 code | 20 blank | 2 comment | 15 complexity | c5d92b1dbbe7e680da430bfa92b3fd20 MD5 | raw file
Possible License(s): LGPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. include_once('modules/guestlist/class_guestlist.php');
  3. $guestlist = new guestlist;
  4. switch($_GET['step']) {
  5. // Export CSV
  6. case 10:
  7. if (!$_POST['action'] and $_GET['userid']) $_POST['action'][$_GET['userid']] = 1;
  8. if ($auth['type'] >= 2 and $_POST['action']) {
  9. header('Expires: 0');
  10. header('Cache-control: private');
  11. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  12. header('Content-Description: File Transfer');
  13. header('Content-Type: application/vnd.ms-excel; charset: UTF-8');
  14. header('Content-disposition: attachment; filename=user.csv');
  15. echo pack("CCC",0xef,0xbb,0xbf);
  16. echo "UserID;Username;Firstname;Lastname;Clan\n";
  17. foreach ($_POST['action'] as $key => $val) {
  18. echo $func->AllowHTML($guestlist->Export($key, $party->party_id)). "\n";
  19. }
  20. exit;
  21. }
  22. $func->information(t('Bitte markiere die User jetzt noch als exportiert.'));
  23. break;
  24. // Set Exported
  25. case 11:
  26. if (!$_POST['action'] and $_GET['userid']) $_POST['action'][$_GET['userid']] = 1;
  27. if ($auth['type'] >= 2 and $_POST['action']) {
  28. foreach ($_POST['action'] as $key => $val) {
  29. $guestlist->SetExported($key, $party->party_id);
  30. }
  31. $func->confirmation(t('Die User wurden für die aktuelle Party als exportiert markiert.'));
  32. }
  33. break;
  34. }
  35. include_once('modules/mastersearch2/class_mastersearch2.php');
  36. $ms2 = new mastersearch2();
  37. function ClanURLLink($clan_name) {
  38. global $line, $func;
  39. if ($clan_name == '') return '';
  40. elseif ($func->isModActive('clanmgr')) return '<a href="index.php?mod=clanmgr&action=clanmgr&step=2&clanid='. $line['clanid'] .'">'. $clan_name .'</a>';
  41. elseif ($clan_name != '' and $line['clanurl'] != '' and $line['clanurl'] != 'http://') {
  42. if (substr($line['clanurl'], 0, 7) != 'http://') $line['clanurl'] = 'http://'. $line['clanurl'];
  43. return '<a href="'. $line['clanurl'] .'" target="_blank">'. $clan_name .'</a>';
  44. } else return $clan_name;
  45. }
  46. if (!$party->party_id)
  47. $func->information(t('Bitte setzte zuerst eine aktive Party.'));
  48. else
  49. {
  50. $ms2->query['from'] = "%prefix%party_user pu
  51. INNER JOIN %prefix%user u ON u.userid = pu.user_id
  52. LEFT JOIN %prefix%clan c ON c.clanid = u.clanid";
  53. $ms2->query['where'] = 'pu.party_id = '. (int)$party->party_id . ' AND (exported IS NULL OR exported = 0)';
  54. $ms2->config['EntriesPerPage'] = 100;
  55. $ms2->AddResultField(t('Benutzername'), 'u.username');
  56. if ($auth['type'] >= 2 or !$cfg['sys_internet'] or $cfg['guestlist_shownames']) {
  57. $ms2->AddResultField(t('Vorname'), 'u.firstname');
  58. $ms2->AddResultField(t('Nachname'), 'u.name');
  59. }
  60. $ms2->AddSelect('c.url AS clanurl');
  61. $ms2->AddSelect('c.clanid AS clanid');
  62. $ms2->AddResultField('Clan', 'c.name AS clan', 'ClanURLLink');
  63. $ms2->AddIconField('details', 'index.php?mod=guestlist&action=details&userid=', t('Details'));
  64. if ($auth['type'] >= 2) {
  65. $ms2->AddMultiSelectAction(t('Exportieren'), "index.php?mod=guestlist&action=export&step=10", 1, 'export');
  66. $ms2->AddMultiSelectAction(t('Als exportiert markieren'), "index.php?mod=guestlist&action=export&step=11", 1, 'setexported');
  67. }
  68. $ms2->PrintSearch('index.php?mod=guestlist', 'u.userid');
  69. }
  70. ?>