Completed
Push — trunk ( d06df9...f48ee3 )
by SuperNova.WS
11:23
created

alliance.php (3 issues)

1
<?php
2
3
include('common.' . substr(strrchr(__FILE__, '.'), 1));
4
5
if (SN::$config->game_mode == GAME_BLITZ) {
6
  messageBox($lang['sys_blitz_page_disabled'], $lang['sys_error'], 'overview.php', 10);
7
  die();
8
}
9
10
define('SN_IN_ALLY', true);
11
12
// Main admin page save themes
13
lng_include('alliance');
14
15
$mode = sys_get_param_str('mode');
16
17
if ($mode == 'ainfo') {
18
  include('includes/alliance/ali_info.inc');
19
}
20
21
if (!$user['ally_id']) {
22
  $user_request = doquery("SELECT * FROM {{alliance_requests}} WHERE `id_user` ='{$user['id']}' LIMIT 1;", '', true);
23
  if ($user_request['id_user']) {
24
    require('includes/alliance/ali_external_request.inc');
25
  } else {
26
    switch ($mode) {
27
      case 'search':
28
        require('includes/alliance/ali_external_search.inc');
29
      break;
30
31
      case 'apply':
32
        require('includes/alliance/ali_external_request.inc');
33
      break;
34
35
      case 'make':
36
        require('includes/alliance/ali_external_create_ally.inc');
37
      break;
38
39
      default:
40
        $parsetemplate = gettemplate('ali_external', true);
0 ignored issues
show
true of type true is incompatible with the type null|template expected by parameter $template of gettemplate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        $parsetemplate = gettemplate('ali_external', /** @scrutinizer ignore-type */ true);
Loading history...
41
        display($parsetemplate, $lang['alliance']);
42
      break;
43
    }
44
  }
45
}
46
47
\Alliance\Alliance::sn_ali_fill_user_ally($user);
0 ignored issues
show
Deprecated Code introduced by
The function Alliance\Alliance::sn_ali_fill_user_ally() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
/** @scrutinizer ignore-deprecated */ \Alliance\Alliance::sn_ali_fill_user_ally($user);
Loading history...
48
//$ally = doquery("SELECT * FROM {{alliance}} WHERE `id` ='{$user['ally_id']}'", '', true);
49
if (!isset($user['ally'])) {
50
  db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_register_time` = 0, `ally_rank_id` = 0");
51
  messageBox($lang['ali_sys_notFound'], $lang['your_alliance'], 'alliance.php');
52
}
53
$ally = &$user['ally'];
54
/*
55
$ally_rights = array(
56
  0 => 'name',
57
  1 => 'mail',
58
  2 => 'online',
59
  3 => 'invite',
60
  4 => 'kick',
61
  5 => 'admin',
62
  6 => 'forum',
63
  7 => 'diplomacy'
64
);
65
*/
66
$rights_old = array(
67
  0 => 'name',
68
  1 => 'mails',
69
  2 => 'onlinestatus',
70
  3 => 'bewerbungenbearbeiten',
71
  4 => 'kick',
72
  5 => 'rechtehand'
73
);
74
75
// This piece converting old ally data to new one
76
//  unset($ally['ranklist']);
77
if (!$ally['ranklist'] && $ally['ally_ranks']) {
78
  $ally_ranks = unserialize($ally['ally_ranks']);
79
  $i = 0;
80
  foreach ($ally_ranks as $rank_id => $rank) {
81
    foreach ($ally_rights as $key => $value) {
82
      $ranks[$i][$value] = $rank[$rights_old[$key]];
83
    }
84
    db_user_list_set_ally_deprecated_convert_ranks($user['ally_id'], $i, $rank_id);
85
    $i++;
86
  }
87
88
  if (!empty($ranks)) {
89
    ali_rank_list_save($ranks);
90
  }
91
}
92
93
$ranks = \Alliance\Alliance::ally_get_ranks($ally);
0 ignored issues
show
Deprecated Code introduced by
The function Alliance\Alliance::ally_get_ranks() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

93
$ranks = /** @scrutinizer ignore-deprecated */ \Alliance\Alliance::ally_get_ranks($ally);
Loading history...
94
95
$isAllyOwner = $ally['ally_owner'] == $user['id'];
96
$user_can_send_mails = $ranks[$user['ally_rank_id']]['mail'] || $isAllyOwner;
97
$userCanPostForum = $ranks[$user['ally_rank_id']]['forum'] || $isAllyOwner;
98
$user_onlinestatus = $ranks[$user['ally_rank_id']]['online'] || $isAllyOwner;
99
$user_admin_applications = $ranks[$user['ally_rank_id']]['invite'] || $isAllyOwner;
100
$user_can_kick = $ranks[$user['ally_rank_id']]['kick'] || $isAllyOwner;
101
$user_can_negotiate = $ranks[$user['ally_rank_id']]['diplomacy'] || $isAllyOwner;
102
$user_can_edit_rights = $user_admin = $ranks[$user['ally_rank_id']]['admin'] || $isAllyOwner;
103
104
$edit = sys_get_param_str('edit');
105
SN::$gc->pimp->allyInternalMainModel();
106
switch ($mode) {
107
  case 'admin':
108
    if (!array_key_exists($edit, $sn_ali_admin_internal)) {
109
      $edit = 'default';
110
    }
111
    if ($sn_ali_admin_internal[$edit]['include']) {
112
      require("includes/{$sn_ali_admin_internal[$edit]['include']}");
113
    }
114
    if (isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) {
115
      call_user_func($sn_ali_admin_internal[$edit]['function']);
116
    }
117
  break;
118
119
  case 'memberslist':
120
    require('includes/alliance/ali_internal_members.inc');
121
  break;
122
  case 'circular':
123
    require('includes/alliance/ali_internal_admin_mail.inc');
124
  break;
125
  default:
126
    require('includes/alliance/ali_info.inc');
127
  break;
128
}
129
130
function ally_pre_call() {
131
  $func_args = func_get_args();
132
133
  return sn_function_call('ally_pre_call', $func_args);
134
}
135