Changeset 9369 for extensions/PWG_Stuffs/admin/add_module.php
- Timestamp:
- Feb 24, 2011, 4:45:43 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PWG_Stuffs/admin/add_module.php
r7855 r9369 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 global $template, $conf; 6 7 include_once(STUFFS_PATH . 'include/functions.inc.php'); 8 include_once(STUFFS_PATH . 'admin/functions.inc.php'); 9 load_language('plugin.lang', STUFFS_PATH); 10 11 if (!isset($_GET['type']) or !is_dir(STUFFS_PATH . 'modules/' . $_GET['type'])) 5 if ($page['tab'] == 'add_module') 12 6 { 13 die('Wrong parameters...'); 14 } 15 else 16 { 17 $type = $_GET['type']; 7 if (!isset($_GET['path']) or !isset($modules[$_GET['path']])) 8 { 9 die('Wrong module path.'); 10 } 11 else 12 { 13 $module_path = $_GET['path']; 14 } 18 15 } 19 16 20 // Cas particulier des News 21 if ($type == 'News') include(STUFFS_PATH . 'modules/News/config.inc.php'); 22 23 // Enregistrement du module 17 // Save module 24 18 if (isset($_POST['submit']) and !is_adviser()) 25 19 { 26 include( STUFFS_PATH . 'modules/' . $type . '/config.inc.php');20 include($module_path.'config.inc.php'); 27 21 if (empty($page['errors'])) 28 22 { … … 34 28 { 35 29 $module_name = $_POST['module_name']; 36 $desc = (!empty($_POST['module_desc']) ? '"' . $_POST['module_desc'] . '"' : 'NULL');37 $groups = (!empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL');38 $users = (!empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : 'NULL');30 $desc = !empty($_POST['module_desc']) ? '"' . $_POST['module_desc'] . '"' : 'NULL'; 31 $groups = !empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL'; 32 $users = !empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : 'NULL'; 39 33 $show_title = isset($_POST['show_title']) ? '"true"' : '"false"'; 40 34 $on_home = isset($_POST['on_home']) ? '"true"' : '"false"'; … … 42 36 $on_picture = isset($_POST['on_picture']) ? '"true"' : '"false"'; 43 37 44 38 $sav_datas = (!empty($datas) ? '"' . addslashes(serialize($datas)) . '"' : 'NULL'); 45 39 46 40 if (isset($_GET['edit'])) 47 { 41 { 48 42 pwg_query(' 49 43 UPDATE ' . STUFFS_TABLE . ' 50 44 SET name ="' . $module_name . '", 51 descr=' . $desc . ', 52 type="' . $type . '", 53 datas=' . $sav_datas . ', 54 users=' . $users . ', 55 groups=' . $groups . ', 45 descr=' . $desc . ', 46 datas=' . $sav_datas . ', 47 users=' . $users . ', 48 groups=' . $groups . ', 56 49 show_title=' . $show_title .', 57 50 on_home=' . $on_home .', … … 59 52 on_picture='. $on_picture . ' 60 53 WHERE id = ' . $_GET['edit'] . ';'); 54 if (isset($_GET['redirect'])) 55 { 56 redirect(urldecode($_GET['redirect'])); 57 } 61 58 } 62 59 else … … 69 66 70 67 $query = ' 71 INSERT INTO ' . STUFFS_TABLE . ' ( id, pos, name, descr, type, datas, users, groups, show_title, on_home, on_cats, on_picture, id_line, width )68 INSERT INTO ' . STUFFS_TABLE . ' ( id, pos, name, descr, path, parent, datas, users, groups, show_title, on_home, on_cats, on_picture, id_line, width ) 72 69 VALUES (' . $next_element_id . ' , 73 ' . $pos . ', 74 "' . $module_name . '", 75 ' . $desc . ', 76 "' . $type . '", 77 ' . $sav_datas . ', 78 ' . $users . ', 79 ' . $groups . ', 70 ' . $pos . ', 71 "' . $module_name . '", 72 ' . $desc . ', 73 "' . $module_path . '", 74 ' . (isset($modules[$module_path]['parent']) ? '"'.$modules[$module_path]['parent'].'"' : 'NULL') .', 75 ' . $sav_datas . ', 76 ' . $users . ', 77 ' . $groups . ', 80 78 ' . $show_title . ', 81 79 ' . $on_home . ', … … 86 84 pwg_query($query); 87 85 } 88 89 86 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin§ion=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php'); 90 87 } … … 92 89 } 93 90 94 // Récupération des données du module 95 if (isset($_GET['edit'])) 96 { 97 $q = ('SELECT * FROM ' . STUFFS_TABLE . ' WHERE id = ' . $_GET['edit'] . ';'); 98 $module = mysql_fetch_array(pwg_query($q)); 99 100 $module['users'] = explode(',', $module['users']); 101 $module['groups'] = explode(',', $module['groups']); 102 103 $datas = (!empty($module['datas']) ? unserialize($module['datas']) : false); 104 105 $template->assign(array( 106 'STUFFS_TITLE' => l10n('stuffs_edit_mod') . ' <i>' . trigger_event('render_stuffs_name', $module['name']) . '</i>', 107 'MODULE_NAME' => $module['name'], 108 'DESC_VALUE' => (isset($module['descr']) ? $module['descr'] : ''), 109 'show_title_CHECKED' => ($module['show_title'] == 'true' ? 'checked="checked"' : ''), 110 'on_home_CHECKED' => ($module['on_home'] == 'true' ? 'checked="checked"' : ''), 111 'on_cats_CHECKED' => ($module['on_cats'] == 'true' ? 'checked="checked"' : ''), 112 'on_picture_CHECKED' => ($module['on_picture'] == 'true' ? 'checked="checked"' : ''))); 113 } 114 else 91 // Default module data 92 if ($page['tab'] == 'add_module') 115 93 { 116 94 $module['users'] = array('guest', 'generic', 'normal', 'admin', 'webmaster'); … … 118 96 $template->assign(array( 119 97 'STUFFS_TITLE' => l10n('stuffs_add_mod'), 120 'MODULE_NAME' => l10n('module_name_' . strtolower($type)),98 'MODULE_NAME' => $modules[$module_path]['name'], 121 99 'show_title_CHECKED' => 'checked="checked"', 122 100 'on_home_CHECKED' => 'checked="checked"')); 123 101 } 124 102 125 // Selection des utilisateurs103 // Users perm 126 104 $template->assign('user_perm', array( 127 105 'GUEST' => (in_array('guest', $module['users']) ? 'checked="checked"' : ''), … … 131 109 'WEBMASTER' => (in_array('webmaster', $module['users']) ? 'checked="checked"' : ''))); 132 110 133 // Selection des groupes111 // Groups perm 134 112 $groups = get_all_groups(); 135 113 if (!empty($groups)) … … 138 116 } 139 117 140 // Configuration du module141 include_once( STUFFS_PATH . 'modules/' . $type . '/config.inc.php');118 // Module configuration 119 include_once($module_path.'config.inc.php'); 142 120 143 121 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/add_module.tpl'));
Note: See TracChangeset
for help on using the changeset viewer.