forked from H3Gi/tatar-wars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalliancerole.php
153 lines (104 loc) · 3.09 KB
/
alliancerole.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
require( '.' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'boot.php' );
require_once( MODEL_PATH . 'alliance.php' );
class GPage extends SecureGamePage {
var $allianceData = null;
var $playerName = null;
var $playerRoles = null;
function GPage() {
$this->customLogoutAction = TRUE;
parent::securegamepage();
if ($this->player == NULL) {
exit( 0 );
}
$this->viewFile = 'alliancerole.phtml';
$this->layoutViewFile = 'layout' . DIRECTORY_SEPARATOR . 'popup.phtml';
$this->checkForGlobalMessage = FALSE;
}
function load() {
parent::load();
$allianceId = intval( $this->data['alliance_id'] );
if (( ( $allianceId == 0 || !$this->hasAllianceSetRoles() ) || !isset( $_GET['uid'] ) )) {
exit( 0 );
return null;
}
$uid = intval( $_GET['uid'] );
$m = new AllianceModel();
$this->allianceData = $m->getAllianceData( $allianceId );
if (!$this->isMemberOfAlliance( $uid )) {
exit( 0 );
return null;
}
if ($this->isPost()) {
$roleName = (isset( $_POST['a_titel'] ) ? $_POST['a_titel'] : '');
if (trim( $roleName ) == '') {
$roleName = '.';
}
$roleNumber = 0;
if (isset( $_POST['e1'] )) {
$roleNumber |= ALLIANCE_ROLE_SETROLES;
}
if (isset( $_POST['e2'] )) {
$roleNumber |= ALLIANCE_ROLE_REMOVEPLAYER;
}
if (isset( $_POST['e3'] )) {
$roleNumber |= ALLIANCE_ROLE_EDITNAMES;
}
if (isset( $_POST['e4'] )) {
$roleNumber |= ALLIANCE_ROLE_EDITCONTRACTS;
}
if (isset( $_POST['e5'] )) {
$roleNumber |= ALLIANCE_ROLE_SENDMESSAGE;
}
if (isset( $_POST['e6'] )) {
$roleNumber |= ALLIANCE_ROLE_INVITEPLAYERS;
}
$m->setPlayerAllianceRole( $uid, $roleName, $roleNumber );
}
$row = $m->getPlayerAllianceRole( $uid );
if ($row == NULL) {
exit( 0 );
return null;
}
$this->playerName = $row['name'];
$alliance_roles = trim( $row['alliance_roles'] );
if ($alliance_roles == '') {
$this->playerRoles = array( 'name' => '', 'roles' => 0 );
}
else {
list( $rolesNumber, $roleName ) = explode( ' ', $alliance_roles, 2 );
$this->playerRoles = array( 'name' => ($roleName == '.' ? '' : $roleName), 'roles' => $rolesNumber );
}
$m->dispose();
}
function isMemberOfAlliance($playerId) {
$players_ids = trim( $this->allianceData['players_ids'] );
if ($players_ids == '') {
return FALSE;
}
$arr = explode( ',', $players_ids );
foreach ($arr as $pid) {
if ($pid == $playerId) {
return TRUE;
}
}
return FALSE;
}
function _hasAllianceRole($role) {
$alliance_roles = trim( $this->data['alliance_roles'] );
if ($alliance_roles == '') {
return FALSE;
}
list( $roleNumber, $roleName ) = explode( ' ', $alliance_roles, 2 );
return $roleNumber & $role;
}
function hasAllianceSetRoles() {
return $this->_hasAllianceRole( ALLIANCE_ROLE_SETROLES );
}
function getAllianceRoleCheckValue($role) {
return ($this->playerRoles['roles'] & $role ? 'value="1" checked="checked"' : 'value="0"');
}
}
$p = new GPage();
$p->run();
?>