root/dev/common/admin/admin_navmanager.php @ 226

Revision 226, 8.8 KB (checked in by exi, 15 years ago)

if ($_POSTpassword? == config::get('post_mailto')).... NC

Line 
1<?php
2@set_time_limit(0);
3require_once('common/includes/class.parser.php');
4require_once('common/includes/class.kill.php');
5require_once('common/admin/admin_menu.php');
6
7$page = new Page();
8$page->setAdmin();
9$page->setTitle('Administration - Navigation - Top Navigation');
10
11if ($_GET['incPrio'])
12{
13    increasePriority($_GET['incPrio']);
14}
15elseif ($_GET['decPrio'])
16{
17    decreasePriority($_GET['decPrio']);
18}
19elseif ($_POST['new'])
20{
21    newPage($_POST['name'], $_POST['url'], $_POST['target']);
22}
23elseif ($_POST['name'])
24{
25    renamePage($_POST['id'], $_POST['name']);
26}
27elseif ($_POST['target'])
28{
29    changeTarget($_POST['id'], $_POST['target']);
30}
31elseif ($_POST['newUrl'])
32{
33    changeUrl($_POST['id'], $_POST['newUrl']);
34}
35elseif ($_POST['delete'])
36{
37    delPage($_POST['id']);
38}
39elseif ($_POST['syncStat'])
40{
41    repairStatLink();
42}
43
44$html .= "<div class=block-header2>Navigation for intern pages</div>";
45$qry = new DBQuery();
46$query = "select * from kb3_navigation WHERE intern = 1 AND KBSITE = '".KB_SITE."';";
47$result = $qry->execute($query);
48
49if ($result)
50{
51    $html .= "<table class=kb-table>";
52    $html .= "<tr><td width=100><u><b>Page</b></u></td><th colspan=2><u>Actions</u></th></tr>";
53    $odd = false;
54    while ($row = $qry->getRow())
55    {
56        $html .= "<tr class=$class><td>".$row['descr']."</td><form action ='?a=admin_navmanager' method='POST'><td><input name='name' type='text' value='".$row['descr']."'></td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='rename'></td></form></tr>";
57        if (!$odd)
58        {
59            $odd = true;
60            $class = 'kb-table-row-odd';
61        }
62        else
63        {
64            $odd = false;
65            $class = 'kb-table-row-even';
66        }
67    }
68    $html .= "<tr class=$class>";
69    if (!$odd)
70    {
71        $odd = true;
72        $class = 'kb-table-row-odd';
73    }
74    else
75    {
76        $odd = false;
77        $class = 'kb-table-row-even';
78    }
79    $html .= "<tr class=$class><form action ='?a=admin_navmanager' method='POST'><td  colspan=2>Statlink must have the name \"Stats\"<br> during repair</td><td><input type='hidden' name='syncStat' value='1'><center><input type='submit' value='Repair Stats'></center></td></form></tr>";
80    $html .= "</table>";
81}
82$html .= "<div class=block-header2>Navigation for extern pages</div>";
83$qry = new DBQuery();
84$query = "select * from kb3_navigation WHERE intern = 0 AND KBSITE = '".KB_SITE."';";
85$result = $qry->execute($query);
86
87if ($result)
88{
89    $html .= "<table class=kb-table>";
90    $html .= "<tr><td width=100><u><b>Page</b></u></td><th colspan=2>Rename</th><th colspan=2>URL</th><th colspan=2>Target</th></tr>";
91    $odd = false;
92    while ($row = $qry->getRow())
93    {
94        $html .= "<tr class=$class><td>".$row['descr']."</td>";
95        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='name' type='text' value='".$row['descr']."'></td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='rename'></td></form>";
96        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='newUrl' type='text' value='".$row['url']."'></td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='change'></td></form>";
97        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><select name='target'>";
98        $html .= "<option value='_self' ";
99        if ($row['target'] == '_self')
100        {
101            $html .= "selected";
102        }
103        $html .= ">_self</option>";
104        $html .= "<option value='_blank' ";
105        if ($row['target'] == '_blank')
106        {
107            $html .= "selected";
108        }
109        $html .= ">_blank</option></select>";
110        $html .= "</td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='change'></td></form>";
111        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='delete' type='hidden' value='1'><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='delete'></td></form>";
112        $html .= "</tr>";
113        if (!$odd)
114        {
115            $odd = true;
116            $class = 'kb-table-row-odd';
117        }
118        else
119        {
120            $odd = false;
121            $class = 'kb-table-row-even';
122        }
123    }
124    $html .= "<tr class=$class><td colspan=10><b><u>New Page:</b></u></td></tr>";
125    if (!$odd)
126    {
127        $odd = true;
128        $class = 'kb-table-row-odd';
129    }
130    else
131    {
132        $odd = false;
133        $class = 'kb-table-row-even';
134    }
135    $html .= "<tr class=$class><td>Description:</td>";
136    $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='name' type='text'></td>";
137    $html .= "<td>URL:</td><td><input name='url' type='text' value='http://'></td><td>Target:</td>";
138    $html .= "<td><select name='target'><option value='_self'>_self</option><option value='_blank'>_blank</option></select>";
139    $html .= "</td><td><input type='hidden' name='new' value='1'><input type='submit' value='add'></td></form>";
140    $html .= "</tr>";
141    $html .= "</table>";
142}
143
144$html .= "<div class=block-header2>Order of the pages in Top Navigation Bar</div>";
145$qry = new DBQuery();
146$query = "select * from kb3_navigation WHERE nav_type = 'top' AND KBSITE = '".KB_SITE."' ORDER BY posnr ;";
147$result = $qry->execute($query);
148
149if ($result)
150{
151    $html .= "<table class=kb-table>";
152    $html .= "<tr><th><u>Nr</u></th><td><u><b>Page</b></u></td><th colspan=2><u>Actions</u></th></tr>";
153    $odd = false;
154    while ($row = $qry->getRow())
155    {
156        if (!$odd)
157        {
158            $odd = true;
159            $class = 'kb-table-row-odd';
160        }
161        else
162        {
163            $odd = false;
164            $class = 'kb-table-row-even';
165        }
166        $html .= "<tr class=$class><td align=right>".$row['posnr']."</td><td>".$row['descr']."</td>";
167        $html .= "<td><a href='?a=admin_navmanager&decPrio=".$row['ID']."'><b> move up </b></a></td>";
168        $html .= "<td><a href='?a=admin_navmanager&incPrio=".$row['ID']."'><b> down </b></a></td>";
169        $html .= "<tr>" ;
170    }
171    $html .= "</table>";
172}
173$page->addContext($menubox->generate());
174$page->setContent($html);
175$page->generate();
176
177function increasePriority($id)
178{
179    $qry = new DBQuery();
180    $query = "SELECT posnr FROM kb3_navigation WHERE ID = $id AND KBSITE = '".KB_SITE."'";
181    $qry->execute($query);
182    $row = $qry->getRow();
183    $next = $row['posnr'] + 1;
184
185    $qry = new DBQuery();
186    $query = "UPDATE kb3_navigation SET posnr = (posnr-1) WHERE nav_type = 'top' AND posnr = $next AND KBSITE = '".KB_SITE."'";
187    $qry->execute($query);
188
189    $qry = new DBQuery();
190    $query = "UPDATE kb3_navigation SET posnr = (posnr+1) WHERE ID = $id";
191    $qry->execute($query);
192}
193function decreasePriority($id)
194{
195    $qry = new DBQuery();
196    $query = "SELECT posnr FROM kb3_navigation WHERE ID = $id AND KBSITE = '".KB_SITE."'";
197    $qry->execute($query);
198    $row = $qry->getRow();
199    $prev = $row['posnr']-1;
200
201    $qry = new DBQuery();
202    $query = "UPDATE kb3_navigation SET posnr = (posnr+1) WHERE nav_type = 'top' AND posnr = $prev AND KBSITE = '".KB_SITE."'";
203    $qry->execute($query);
204
205    $qry = new DBQuery();
206    $query = "UPDATE kb3_navigation SET posnr = (posnr-1) WHERE ID = $id";
207    $qry->execute($query);
208}
209
210function renamePage($id, $name)
211{
212    $qry = new DBQuery();
213    $query = "UPDATE kb3_navigation SET descr ='$name' WHERE ID=$id";
214    $qry->execute($query);
215}
216
217function changeUrl($id, $url)
218{
219    $qry = new DBQuery();
220    $query = "UPDATE kb3_navigation SET url ='$url' WHERE ID=$id";
221    $qry->execute($query);
222}
223function changeTarget($id, $target)
224{
225    $qry = new DBQuery();
226    $query = "UPDATE kb3_navigation SET target ='$target' WHERE ID=$id";
227    $qry->execute($query);
228}
229function newPage($descr, $url, $target)
230{
231    $qry = new DBQuery();
232    $query = "SELECT max(posnr) as nr FROM kb3_navigation WHERE nav_type='top' AND KBSITE = '".KB_SITE."'";
233    $qry->execute($query);
234    $row = $qry->getRow();
235    $posnr = $row['nr'] + 1;
236    $query = "INSERT INTO kb3_navigation SET descr='$descr', intern=0, nav_type='top',url='$url', target ='$target', posnr=$posnr, page='ALL_PAGES', KBSITE = '".KB_SITE."'";
237    $qry->execute($query);
238}
239function delPage($id)
240{
241    $qry = new DBQuery();
242    $query = "DELETE FROM kb3_navigation WHERE ID=$id";
243    $qry->execute($query);
244}
245function repairStatLink()
246{
247    if (CORP_ID)
248    {
249        $statlink = '?a=corp_detail&crp_id='.CORP_ID;
250    }elseif (ALLIANCE_ID)
251    {
252        $statlink = '?a=alliance_detail&all_id='.ALLIANCE_ID;
253    }
254    $qry = new DBQuery();
255    $query = "UPDATE kb3_navigation SET url ='$statlink' WHERE descr='Stats' AND KBSITE = '".KB_SITE."'";
256    $qry->execute($query);
257}
258?>
Note: See TracBrowser for help on using the browser.