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

/plugins/corporation/plugin.php

http://ooe.googlecode.com/
PHP | 92 lines | 76 code | 15 blank | 1 comment | 30 complexity | 41310f69b023f4047d58f968bae554bc MD5 | raw file
  1. <?php
  2. class corporation extends Plugin {
  3. var $name = 'Corporation';
  4. var $level = 1;
  5. function corporation($db, $site) {
  6. $this->Plugin($db, $site);
  7. if ($this->site->plugins['mainmenu']->hasGroup('corp') || $this->site->plugins['users']->hasForcedMenu('corpSheet'))
  8. $this->site->plugins['mainmenu']->addLink('corp', 'Corporation', '?module=corporation', 'icon07_06');
  9. }
  10. function getContent() {
  11. if ($this->site->character->corporation) {
  12. $this->site->character->corporation->loadMembers(true);
  13. $corp = objectToArray($this->site->character->corporation, array('DBManager', 'eveDB', 'eveCharacter'));
  14. // no need to duplicate member list, it's not used again
  15. unset($corp['members']);
  16. if (!isset($_POST['active']))
  17. $_POST['active'] = 4;
  18. if (!isset($_POST['system']))
  19. $_POST['system'] = 0;
  20. if (!isset($_POST['title']))
  21. $_POST['title'] = '';
  22. $activeDay = 86400;
  23. $activeWeek = $activeDay * 7;
  24. $activeMonth = $activeWeek * 4;
  25. $active3Months = $activeMonth * 3;
  26. $members = array();
  27. $active = array(array('min' => 0, 'max' => $activeWeek, 'count' => 0, 'name' => 'Last 7 days'),
  28. array('min' => $activeWeek, 'max' => $activeMonth, 'count' => 0, 'name' => 'Last month'),
  29. array('min' => $activeMonth, 'max' => $active3Months, 'count' => 0, 'name' => 'Last 3 months'),
  30. array('min' => $active3Months, 'max' => $active3Months*1000 /*lol*/, 'count' => 0, 'name' => 'Longer than 3 months'));
  31. $systems = array();
  32. $titles = array();
  33. foreach ($this->site->character->corporation->members as $member) {
  34. if ($member->locationID) {
  35. $sys = null;
  36. if (isset($member->location->stationid)) {
  37. $sys = $member->location->solarSystem;
  38. } else if (isset($member->location->solarsystemid))
  39. $sys = $member->location;
  40. if ($sys) {
  41. if (isset($systems[$sys->solarsystemid])) {
  42. $systems[$sys->solarsystemid]['count'] ++;
  43. } else {
  44. $systems[$sys->solarsystemid] = array('name' => $sys->solarsystemname, 'count' => 1);
  45. }
  46. }
  47. }
  48. if ($member->title) {
  49. if (isset($titles[$member->title])) {
  50. $titles[$member->title] ++;
  51. } else {
  52. $titles[$member->title] = 1;
  53. }
  54. }
  55. for ($i = 0; $i < count($active); $i++) {
  56. if ((time()-$active[$i]['min'] >= ($member->logoffDateTime-$this->site->user->account->timeOffset))
  57. && (time()-$active[$i]['max'] <= ($member->logoffDateTime-$this->site->user->account->timeOffset))) {
  58. $member->activeTimeSlot = $i;
  59. $active[$i]['count'] ++;
  60. }
  61. }
  62. $n = array_push($members, $member);
  63. if (($_POST['title'] <> '') && ($member->title != $_POST['title']))
  64. array_pop($members);
  65. else if (($_POST['system'] > 0) && ($sys->solarsystemid != $_POST['system']))
  66. array_pop($members);
  67. else if (($_POST['active'] < 4) && ($member->activeTimeSlot != $_POST['active']))
  68. array_pop($members);
  69. }
  70. $members = objectToArray($members, array('DBManager', 'eveDB', 'eveCharacter'));
  71. return $this->render('corporation', array('corp' => $corp, 'members' => $members, 'systems' => $systems, 'titles' => $titles, 'active' => $active,
  72. 'selSystem' => $_POST['system'], 'selTitle' => $_POST['title'], 'selActive' => $_POST['active']));
  73. } else
  74. return '<h1>No corporation!</h1>';
  75. }
  76. }
  77. ?>