source: extensions/PWG_Stuffs/admin/manage.php @ 7340

Last change on this file since 7340 was 7340, checked in by patdenice, 14 years ago

Added feature: hide main block on home page.

File size: 2.5 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5// Enregistrement de l'ordre
6if (isset($_POST['submitOrder']) and !is_adviser())
7{
8  asort($_POST['position'], SORT_NUMERIC);
9  $pos = 1;
10  foreach($_POST['position'] as $id => $old_pos)
11  {
12    $id_line = !empty($_POST['id_line'][$id]) ? '"'.$_POST['id_line'][$id].'"' : 'NULL';
13    $width = (!empty($_POST['width'][$id]) and is_numeric($_POST['width'][$id])) ? '"'.$_POST['width'][$id].'"' : 'NULL';
14
15    pwg_query('
16UPDATE ' . STUFFS_TABLE . '
17SET pos=' . $pos++ . ' , id_line='.$id_line.', width='.$width.'
18WHERE id=' . $id . ' LIMIT 1');
19  }
20
21    pwg_query('
22UPDATE ' . STUFFS_TABLE . '
23SET datas = "'.addslashes(serialize(array('hide' => isset($_POST['hidemb'])))).'"
24WHERE id=0;');
25
26  array_push($page['infos'], l10n('stuffs_order_saved'));
27}
28
29// Affichage des modules et de leur position
30$q = 'SELECT id, name, descr, type, id_line, width, datas
31FROM ' . STUFFS_TABLE . '
32ORDER BY pos ASC;';
33$result = pwg_query($q);
34$num = 0;
35$pos = 1;
36$cat_mod = array('name' => l10n('Categories'), 'type' => '-', 'description' => '');
37$id_line_options = array(
38    '' => '-',
39    'A' => 'A',
40    'B' => 'B',
41    'C' => 'C',
42    'D' => 'D',
43    'E' => 'E',
44    'F' => 'F',
45    'G' => 'G',
46    'H' => 'H',
47    'I' => 'I',
48    'J' => 'J');
49
50while ($module = mysql_fetch_assoc($result))
51{
52        $module['name'] = $module['type'] != 'MainBlock' ? $module['name'] : l10n('stuffs_main_block');
53
54  $template->append('modules', array(
55    'ID' => $module['id'],
56    'NAME' => trigger_event('render_stuffs_name', $module['name']),
57    'DESC' => $module['descr'],
58    'TYPE' => $module['type'],
59    'TYPE_NAME' => (isset($modules[$module['type']]['name']) ? $modules[$module['type']]['name'] : ''),
60    'POS' => 10 * $pos++,
61    'ID_LINE_OPTIONS' => $id_line_options,
62    'ID_LINE_SELECTED' => $module['id_line'],
63                'WIDTH' => $module['width'],
64                'ID' => $module['id'],
65    'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . STUFFS_DIR . '%2Fadmin%2Fadd_module.php&amp;type=' . $module['type'] . '&amp;edit=' . $module['id'],
66    'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&amp;del=' . $module['id'] : '',
67  ));
68
69  if ($module['type'] == 'MainBlock' and !empty($module['datas']))
70  {
71    $datas = unserialize($module['datas']);
72    $template->assign('HIDEMB', $datas['hide']); 
73  }
74}
75
76$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/manage.tpl');
77$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
78
79?>
Note: See TracBrowser for help on using the repository browser.