1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | global $pwg_loaded_plugins; |
---|
6 | |
---|
7 | // Delete module |
---|
8 | if (isset($_GET['del']) and !is_adviser()) |
---|
9 | { |
---|
10 | pwg_query('DELETE FROM ' . STUFFS_TABLE . ' WHERE id = ' . $_GET['del'] . ' LIMIT 1;'); |
---|
11 | redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin§ion=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php'); |
---|
12 | } |
---|
13 | |
---|
14 | // Save order |
---|
15 | if (isset($_POST['submitOrder']) and !is_adviser()) |
---|
16 | { |
---|
17 | asort($_POST['position'], SORT_NUMERIC); |
---|
18 | $pos = 1; |
---|
19 | foreach($_POST['position'] as $id => $old_pos) |
---|
20 | { |
---|
21 | $id_line = !empty($_POST['id_line'][$id]) ? '"'.$_POST['id_line'][$id].'"' : 'NULL'; |
---|
22 | $width = (!empty($_POST['width'][$id]) and is_numeric($_POST['width'][$id])) ? '"'.$_POST['width'][$id].'"' : 'NULL'; |
---|
23 | |
---|
24 | pwg_query(' |
---|
25 | UPDATE ' . STUFFS_TABLE . ' |
---|
26 | SET pos=' . $pos++ . ' , id_line='.$id_line.', width='.$width.' |
---|
27 | WHERE id=' . $id . ' LIMIT 1'); |
---|
28 | } |
---|
29 | |
---|
30 | pwg_query(' |
---|
31 | UPDATE ' . STUFFS_TABLE . ' |
---|
32 | SET datas = "'.addslashes(serialize(array('hide' => isset($_POST['hidemb'])))).'" |
---|
33 | WHERE id=0;'); |
---|
34 | |
---|
35 | array_push($page['infos'], l10n('stuffs_order_saved')); |
---|
36 | } |
---|
37 | |
---|
38 | // Display |
---|
39 | $q = 'SELECT id, name, descr, path, parent, id_line, width, datas |
---|
40 | FROM ' . STUFFS_TABLE . ' |
---|
41 | ORDER BY pos ASC;'; |
---|
42 | $result = pwg_query($q); |
---|
43 | $num = 0; |
---|
44 | $pos = 1; |
---|
45 | $id_line_options = array( |
---|
46 | '' => '-', |
---|
47 | 'A' => 'A', |
---|
48 | 'B' => 'B', |
---|
49 | 'C' => 'C', |
---|
50 | 'D' => 'D', |
---|
51 | 'E' => 'E', |
---|
52 | 'F' => 'F', |
---|
53 | 'G' => 'G', |
---|
54 | 'H' => 'H', |
---|
55 | 'I' => 'I', |
---|
56 | 'J' => 'J'); |
---|
57 | |
---|
58 | while ($module = mysql_fetch_assoc($result)) |
---|
59 | { |
---|
60 | $module['name'] = !empty($module['path']) ? $module['name'] : l10n('stuffs_main_block'); |
---|
61 | |
---|
62 | $template->append('modules', array( |
---|
63 | 'ID' => $module['id'], |
---|
64 | 'NAME' => trigger_event('render_stuffs_name', $module['name']), |
---|
65 | 'DESC' => $module['descr'], |
---|
66 | 'PATH' => $module['path'], |
---|
67 | 'TYPE_NAME' => (isset($modules[$module['path']]['name']) ? $modules[$module['path']]['name'] : ''), |
---|
68 | 'POS' => 10 * $pos++, |
---|
69 | 'ID_LINE_OPTIONS' => $id_line_options, |
---|
70 | 'ID_LINE_SELECTED' => $module['id_line'], |
---|
71 | 'WIDTH' => $module['width'], |
---|
72 | 'ID' => $module['id'], |
---|
73 | 'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&tab=edit_module&edit='.$module['id'], |
---|
74 | 'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&del=' . $module['id'] : '', |
---|
75 | 'MISSING' => (isset($module['parent']) and !isset($pwg_loaded_plugins[$module['parent']])), |
---|
76 | ) |
---|
77 | ); |
---|
78 | |
---|
79 | if (empty($module['path']) and !empty($module['datas'])) |
---|
80 | { |
---|
81 | $datas = unserialize($module['datas']); |
---|
82 | $template->assign('HIDEMB', $datas['hide']); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/manage.tpl'); |
---|
87 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
88 | |
---|
89 | ?> |
---|