supernova-ws /
SuperNova
| 1 | <?php |
||
| 2 | |||
| 3 | use Alliance\Alliance; |
||
| 4 | use Pages\Helpers\PageHelperAlly; |
||
| 5 | |||
| 6 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
| 7 | |||
| 8 | if (SN::$config->game_mode == GAME_BLITZ) { |
||
| 9 | SnTemplate::messageBox($lang['sys_blitz_page_disabled'], $lang['sys_error'], 'overview.php', 10); |
||
| 10 | die(); |
||
| 11 | } |
||
| 12 | |||
| 13 | define('SN_IN_ALLY', true); |
||
| 14 | |||
| 15 | // Main admin page save themes |
||
| 16 | lng_include('alliance'); |
||
| 17 | |||
| 18 | $mode = sys_get_param_str('mode'); |
||
| 19 | |||
| 20 | if ($mode == 'ainfo') { |
||
| 21 | include('includes/alliance/ali_info.inc'); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!$user['ally_id']) { |
||
| 25 | $user_request = doquery("SELECT * FROM {{alliance_requests}} WHERE `id_user` ='{$user['id']}' LIMIT 1;", '', true); |
||
| 26 | if ($user_request['id_user']) { |
||
| 27 | require('includes/alliance/ali_external_request.inc'); |
||
| 28 | } else { |
||
| 29 | switch ($mode) { |
||
| 30 | case 'search': |
||
| 31 | PageHelperAlly::pageExternalSearch($mode, $user, $lang); |
||
| 32 | break; |
||
| 33 | |||
| 34 | case 'apply': |
||
| 35 | require('includes/alliance/ali_external_request.inc'); |
||
| 36 | break; |
||
| 37 | |||
| 38 | case 'make': |
||
| 39 | require('includes/alliance/ali_external_create_ally.inc'); |
||
| 40 | break; |
||
| 41 | |||
| 42 | default: |
||
| 43 | $parsetemplate = SnTemplate::gettemplate('ali_external', true); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 44 | PageHelperAlly::externalSearchRecommend($user, $parsetemplate); |
||
| 45 | SnTemplate::display($parsetemplate, $lang['alliance']); |
||
| 46 | break; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | Alliance::sn_ali_fill_user_ally($user); |
||
| 52 | //$ally = doquery("SELECT * FROM {{alliance}} WHERE `id` ='{$user['ally_id']}'", '', true); |
||
| 53 | if (!isset($user['ally'])) { |
||
| 54 | db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_register_time` = 0, `ally_rank_id` = 0"); |
||
| 55 | SnTemplate::messageBox($lang['ali_sys_notFound'], $lang['your_alliance'], 'alliance.php'); |
||
| 56 | } |
||
| 57 | $ally = &$user['ally']; |
||
| 58 | /* |
||
| 59 | $ally_rights = array( |
||
| 60 | 0 => 'name', |
||
| 61 | 1 => 'mail', |
||
| 62 | 2 => 'online', |
||
| 63 | 3 => 'invite', |
||
| 64 | 4 => 'kick', |
||
| 65 | 5 => 'admin', |
||
| 66 | 6 => 'forum', |
||
| 67 | 7 => 'diplomacy' |
||
| 68 | ); |
||
| 69 | */ |
||
| 70 | $rights_old = array( |
||
| 71 | 0 => 'name', |
||
| 72 | 1 => 'mails', |
||
| 73 | 2 => 'onlinestatus', |
||
| 74 | 3 => 'bewerbungenbearbeiten', |
||
| 75 | 4 => 'kick', |
||
| 76 | 5 => 'rechtehand' |
||
| 77 | ); |
||
| 78 | |||
| 79 | // This piece converting old ally data to new one |
||
| 80 | // unset($ally['ranklist']); |
||
| 81 | if (!$ally['ranklist'] && $ally['ally_ranks']) { |
||
| 82 | $ally_ranks = unserialize($ally['ally_ranks']); |
||
| 83 | $i = 0; |
||
| 84 | foreach ($ally_ranks as $rank_id => $rank) { |
||
| 85 | foreach ($ally_rights as $key => $value) { |
||
| 86 | $ranks[$i][$value] = $rank[$rights_old[$key]]; |
||
| 87 | } |
||
| 88 | db_user_list_set_ally_deprecated_convert_ranks($user['ally_id'], $i, $rank_id); |
||
| 89 | $i++; |
||
| 90 | } |
||
| 91 | |||
| 92 | if (!empty($ranks)) { |
||
| 93 | ali_rank_list_save($ranks); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | $ranks = Alliance::ally_get_ranks($ally); |
||
| 98 | |||
| 99 | $isAllyOwner = $ally['ally_owner'] == $user['id']; |
||
| 100 | $user_can_send_mails = $ranks[$user['ally_rank_id']]['mail'] || $isAllyOwner; |
||
| 101 | $userCanPostForum = $ranks[$user['ally_rank_id']]['forum'] || $isAllyOwner; |
||
| 102 | $user_onlinestatus = $ranks[$user['ally_rank_id']]['online'] || $isAllyOwner; |
||
| 103 | $user_admin_applications = $ranks[$user['ally_rank_id']]['invite'] || $isAllyOwner; |
||
| 104 | $user_can_kick = $ranks[$user['ally_rank_id']]['kick'] || $isAllyOwner; |
||
| 105 | $user_can_negotiate = $ranks[$user['ally_rank_id']]['diplomacy'] || $isAllyOwner; |
||
| 106 | $user_can_edit_rights = $user_admin = $ranks[$user['ally_rank_id']]['admin'] || $isAllyOwner; |
||
| 107 | |||
| 108 | $edit = sys_get_param_str('edit'); |
||
| 109 | SN::$gc->pimp->allyInternalMainModel(); |
||
| 110 | switch ($mode) { |
||
| 111 | case 'admin': |
||
| 112 | if (!array_key_exists($edit, $sn_ali_admin_internal)) { |
||
| 113 | $edit = 'default'; |
||
| 114 | } |
||
| 115 | if ($sn_ali_admin_internal[$edit]['include']) { |
||
| 116 | require("includes/{$sn_ali_admin_internal[$edit]['include']}"); |
||
| 117 | } |
||
| 118 | if (isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) { |
||
| 119 | call_user_func($sn_ali_admin_internal[$edit]['function']); |
||
| 120 | } |
||
| 121 | break; |
||
| 122 | |||
| 123 | case 'memberslist': |
||
| 124 | require('includes/alliance/ali_internal_members.inc'); |
||
| 125 | break; |
||
| 126 | case 'circular': |
||
| 127 | require('includes/alliance/ali_internal_admin_mail.inc'); |
||
| 128 | break; |
||
| 129 | default: |
||
| 130 | require('includes/alliance/ali_info.inc'); |
||
| 131 | break; |
||
| 132 | } |
||
| 133 | |||
| 134 | function ally_pre_call() { |
||
| 135 | $func_args = func_get_args(); |
||
| 136 | |||
| 137 | return sn_function_call('ally_pre_call', $func_args); |
||
| 138 | } |
||
| 139 |