1 | <?php |
---|
2 | require_once('common/includes/class.contract.php'); |
---|
3 | require_once('common/includes/class.http.php'); |
---|
4 | require_once('common/admin/admin_menu.php'); |
---|
5 | |
---|
6 | $page = new Page(); |
---|
7 | $page->setAdmin(); |
---|
8 | $page->setTitle('Administration - Post Permissions'); |
---|
9 | |
---|
10 | if ($_REQUEST['searchphrase'] != "" && strlen($_REQUEST['searchphrase']) >= 3) |
---|
11 | { |
---|
12 | switch ($_REQUEST['searchtype']) |
---|
13 | { |
---|
14 | case "pilot": |
---|
15 | $sql = "select plt.plt_id, plt.plt_name, crp.crp_name |
---|
16 | from kb3_pilots plt, kb3_corps crp |
---|
17 | where lower( plt.plt_name ) like lower( '%".slashfix($_REQUEST['searchphrase'])."%' ) |
---|
18 | and plt.plt_crp_id = crp.crp_id |
---|
19 | order by plt.plt_name"; |
---|
20 | break; |
---|
21 | case "corp": |
---|
22 | $sql = "select crp.crp_id, crp.crp_name, ali.all_name |
---|
23 | from kb3_corps crp, kb3_alliances ali |
---|
24 | where lower( crp.crp_name ) like lower( '%".slashfix($_REQUEST['searchphrase'])."%' ) |
---|
25 | and crp.crp_all_id = ali.all_id |
---|
26 | order by crp.crp_name"; |
---|
27 | break; |
---|
28 | case "alliance": |
---|
29 | $sql = "select ali.all_id, ali.all_name |
---|
30 | from kb3_alliances ali |
---|
31 | where lower( ali.all_name ) like lower( '%".slashfix($_REQUEST['searchphrase'])."%' ) |
---|
32 | order by ali.all_name"; |
---|
33 | break; |
---|
34 | } |
---|
35 | |
---|
36 | $qry = new DBQuery(); |
---|
37 | if (!$qry->execute($sql)) |
---|
38 | { |
---|
39 | die($qry->getErrorMsg()); |
---|
40 | } |
---|
41 | |
---|
42 | while ($row = $qry->getRow()) |
---|
43 | { |
---|
44 | switch ($_REQUEST['searchtype']) |
---|
45 | { |
---|
46 | case 'pilot': |
---|
47 | $link = '?a=admin_postperm&add=p'.$row['plt_id']; |
---|
48 | $descr = 'Pilot '.$row['plt_name'].' from '.$row['crp_name']; |
---|
49 | break; |
---|
50 | case 'corp': |
---|
51 | $link = "?a=admin_postperm&add=c".$row['crp_id']; |
---|
52 | $descr = 'Corp '.$row['crp_name'].', member of '.$row['all_name']; |
---|
53 | break; |
---|
54 | case 'alliance': |
---|
55 | $link = '?a=admin_postperm&add=a'.$row['all_id']; |
---|
56 | $descr = 'Alliance '.$row['all_name']; |
---|
57 | break; |
---|
58 | } |
---|
59 | $results[] = array('descr' => $descr, 'link' => $link); |
---|
60 | } |
---|
61 | $smarty->assign_by_ref('results', $results); |
---|
62 | $smarty->assign('search', true); |
---|
63 | } |
---|
64 | |
---|
65 | if (isset($_REQUEST['authall'])) |
---|
66 | { |
---|
67 | if ($_REQUEST['authall']) |
---|
68 | { |
---|
69 | config::set('post_permission', 'all'); |
---|
70 | } |
---|
71 | else |
---|
72 | { |
---|
73 | config::set('post_permission', ''); |
---|
74 | } |
---|
75 | } |
---|
76 | if (!$string = config::get('post_permission')) |
---|
77 | { |
---|
78 | $string = ''; |
---|
79 | } |
---|
80 | if ($string != 'all') |
---|
81 | { |
---|
82 | $tmp = explode(',', $string); |
---|
83 | $permissions = array('a' => array(), 'c' => array(), 'p' => array()); |
---|
84 | foreach ($tmp as $item) |
---|
85 | { |
---|
86 | if (!$item) |
---|
87 | { |
---|
88 | continue; |
---|
89 | } |
---|
90 | $typ = substr($item, 0, 1); |
---|
91 | $id = substr($item, 1); |
---|
92 | $permissions[$typ][$id] = $id; |
---|
93 | } |
---|
94 | |
---|
95 | if ($_REQUEST['add']) |
---|
96 | { |
---|
97 | $typ = substr($_REQUEST['add'], 0, 1); |
---|
98 | $id = intval(substr($_REQUEST['add'], 1)); |
---|
99 | $permissions[$typ][$id] = $id; |
---|
100 | $configstr = ''; |
---|
101 | foreach ($permissions as $typ => $id_array) |
---|
102 | { |
---|
103 | foreach ($id_array as $id) |
---|
104 | { |
---|
105 | $conf[] = $typ.$id; |
---|
106 | } |
---|
107 | } |
---|
108 | config::set('post_permission', implode(',', $conf)); |
---|
109 | } |
---|
110 | |
---|
111 | if ($_REQUEST['del']) |
---|
112 | { |
---|
113 | $typ = substr($_REQUEST['del'], 0, 1); |
---|
114 | $id = intval(substr($_REQUEST['del'], 1)); |
---|
115 | unset($permissions[$typ][$id]); |
---|
116 | $conf = array(); |
---|
117 | foreach ($permissions as $typ => $id_array) |
---|
118 | { |
---|
119 | foreach ($id_array as $id) |
---|
120 | { |
---|
121 | $conf[] = $typ.$id; |
---|
122 | } |
---|
123 | } |
---|
124 | config::set('post_permission', implode(',', $conf)); |
---|
125 | } |
---|
126 | |
---|
127 | asort($permissions['a']); |
---|
128 | asort($permissions['c']); |
---|
129 | asort($permissions['p']); |
---|
130 | |
---|
131 | $permt = array(); |
---|
132 | foreach ($permissions as $typ => $ids) |
---|
133 | { |
---|
134 | foreach ($ids as $id) |
---|
135 | { |
---|
136 | if ($typ == 'a') |
---|
137 | { |
---|
138 | $alliance = new Alliance($id); |
---|
139 | $text = $alliance->getName(); |
---|
140 | $link = '?a=admin_postperm&del='.$typ.$id; |
---|
141 | $permt[$typ][] = array('text' => $text, 'link' => $link); |
---|
142 | } |
---|
143 | if ($typ == 'p') |
---|
144 | { |
---|
145 | $pilot = new Pilot($id); |
---|
146 | $text = $pilot->getName(); |
---|
147 | $link = '?a=admin_postperm&del='.$typ.$id; |
---|
148 | $permt[$typ][] = array('text' => $text, 'link' => $link); |
---|
149 | } |
---|
150 | if ($typ == 'c') |
---|
151 | { |
---|
152 | $corp = new Corporation($id); |
---|
153 | $text = $corp->getName(); |
---|
154 | $link = '?a=admin_postperm&del='.$typ.$id; |
---|
155 | $permt[$typ][] = array('text' => $text, 'link' => $link); |
---|
156 | } |
---|
157 | } |
---|
158 | } |
---|
159 | $perm = array(); |
---|
160 | if ($permt['a']) |
---|
161 | { |
---|
162 | $perm[] = array('name' => 'Alliances', 'list' => $permt['a']); |
---|
163 | } |
---|
164 | if ($permt['p']) |
---|
165 | { |
---|
166 | $perm[] = array('name' => 'Pilots', 'list' => $permt['p']); |
---|
167 | } |
---|
168 | if ($permt['c']) |
---|
169 | { |
---|
170 | $perm[] = array('name' => 'Corporations', 'list' => $permt['c']); |
---|
171 | } |
---|
172 | |
---|
173 | $smarty->assign_by_ref('permissions', $perm); |
---|
174 | } |
---|
175 | $html = $smarty->fetch(get_tpl('admin_postperm')); |
---|
176 | |
---|
177 | $page->addContext($menubox->generate()); |
---|
178 | $page->setContent($html); |
---|
179 | $page->generate(); |
---|
180 | ?> |
---|