$value)
{
if ($value) // == true
$datas[$key] = $value;
}
$datas = (!empty($datas) ? '"'.addslashes(serialize($datas)).'"' : NULL);
pwg_query('
UPDATE ' . FLASHGAL_TABLE . '
SET datas=' . $datas . '
WHERE id = ' . $_GET['edit'] . ';');
// Force le submit pour sauvegarder les données éventuellement modifiées lors du RAZ des paramètres. Pas de redirection dans ce cas
$_POST['submit'] = 'no_redirect';
}
// Enregistrement du module
if (isset($_POST['submit']) and !is_adviser())
{
include(FLASHGAL_PATH . 'modules/' . $type . '/admin/config.inc.php');
if (empty($page['errors']))
{
if (empty($_POST['module_name']))
{
array_push($page['errors'], l10n('flashgal_no_name'));
}
else
{
$module_name = $_POST['module_name'];
$desc = (!empty($_POST['module_desc']) ? '"' . $_POST['module_desc'] . '"' : 'NULL');
$groups = (!empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL');
$users = (!empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : 'NULL');
$show_title = isset($_POST['show_title']) ? '"true"' : '"false"';
$on_home = isset($_POST['on_home']) ? '"true"' : '"false"';
$on_home_global = $_POST['on_home_global'];
$on_cats = isset($_POST['on_cats']) ? '"true"' : '"false"';
// Selected categories
$select_cats = isset($_POST['categories']) ?
array_map("mysql_escape_string", $_POST['categories']) :
array();
$transparent = isset($_POST['flashgal_transparent']) ? '"true"' : '"false"';
$fullscreen = isset($_POST['flashgal_fullscreen']) ? '"true"' : '"false"';
$bgcolor = $_POST['flashgal_bgcolor'];
$recurs_cats = isset($_POST['flashgal_recurs_cats']) ? '"true"' : '"false"';
$replace_thumb = isset($_POST['replace_thumb']) ? '"true"' : '"false"';
$replace_cats = isset($_POST['replace_cats']) ? '"true"' : '"false"';
$height = (!empty($_POST['flashgal_height']) ? '"'.$_POST['flashgal_height'].'"' : "NULL");
$maxcomment = (!empty($_POST['flashgal_max_comment']) ? '"'.$_POST['flashgal_max_comment'].'"' : "0");;
$sav_ext_datas = (!empty($ext_datas) ? '"' . addslashes(serialize($ext_datas)) . '"' : 'NULL');
// Module parameters
include_once(FLASHGAL_PATH . 'modules/' . $type . '/module.inc.php');
foreach ($module_data['datas'] as $key => $value)
{
if ($value) // == true
$sav_datas[$key] = $_POST[$key];
}
$sav_datas = (!empty($sav_datas) ? '"'.addslashes(serialize($sav_datas)).'"' : NULL);
$cats = addslashes(serialize($select_cats));
if (isset($_GET['edit']))
{
pwg_query('
UPDATE ' . FLASHGAL_TABLE . '
SET name ="' . $module_name . '",
descr=' . $desc . ',
type="' . $type . '",
datas=' . $sav_datas . ',
ext_datas=' . $sav_ext_datas . ',
users=' . $users . ',
groups=' . $groups . ',
show_title=' . $show_title .',
on_home=' . $on_home .',
on_home_global="' . $on_home_global .'",
on_cats=' . $on_cats . ',
cats="' . $cats . '",
recurs_cats=' . $recurs_cats . ',
replace_thumb=' . $replace_thumb . ',
replace_cats=' . $replace_cats .',
height=' . $height . ',
transparent=' . $transparent .',
fullscreen=' . $fullscreen .',
bgcolor="' . $bgcolor .'",
maxcomment=' . $maxcomment . '
WHERE id = ' . $_GET['edit'] . ';');
}
else
{
$query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id FROM ' . FLASHGAL_TABLE . ' ;';
list($next_element_id) = mysql_fetch_array(pwg_query($query));
$query = 'SELECT MAX(pos)+1 AS next_pos FROM ' . FLASHGAL_TABLE . ' ;';
list($pos) = mysql_fetch_array(pwg_query($query));
if (!isset($pos)) $pos = 1;
$query = '
INSERT INTO ' . FLASHGAL_TABLE . ' ( id, pos, name, descr, type, datas, ext_datas, users, groups, show_title, on_home, on_home_global, on_cats, cats, recurs_cats, replace_thumb, replace_cats, height, transparent, fullscreen, bgcolor, maxcomment)
VALUES (' . $next_element_id . ' ,
' . $pos . ',
"' . $module_name . '",
' . $desc . ',
"' . $type . '",
' . $sav_datas . ',
' . $sav_ext_datas . ',
' . $users . ',
' . $groups . ',
' . $show_title . ',
' . $on_home . ',
"' . $on_home_global . '",
' . $on_cats . ',
"' . $cats . '",
' . $recurs_cats . ',
' . $replace_thumb . ',
' . $replace_cats .',
' . $height . ',
' . $transparent .',
' . $fullscreen .',
"' . $bgcolor .'",
' . $maxcomment . '
);';
pwg_query($query);
}
if ($_POST['submit'] != 'no_redirect')
redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin§ion=' . FLASHGAL_DIR . '%2Fadmin%2Fadmin.php');
}
}
}
// Récupération des données du module
if (isset($_GET['edit']))
{
$q = ('SELECT * FROM ' . FLASHGAL_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
$module = mysql_fetch_array(pwg_query($q));
$module['users'] = explode(',', $module['users']);
$module['groups'] = explode(',', $module['groups']);
$cats = (!empty($module['cats']) ? unserialize($module['cats']) : false);
$datas = (!empty($module['datas']) ? unserialize($module['datas']) : false);
$ext_datas = (!empty($module['ext_datas']) ? unserialize($module['ext_datas']) : false);
$template->assign(array(
'FLASHGAL_TITLE' => l10n('flashgal_edit_mod') . ' ' . trigger_event('render_flashgal_name', $module['name']) . '',
'MODULE_NAME' => $module['name'],
'DESC_VALUE' => (isset($module['descr']) ? $module['descr'] : ''),
'show_title_CHECKED' => ($module['show_title'] == 'true' ? 'checked="checked"' : ''),
'on_home_CHECKED' => ($module['on_home'] == 'true' ? 'checked="checked"' : ''),
$module['on_home_global'].'_CHECKED' => 'checked="checked"',
'on_cats_CHECKED' => ($module['on_cats'] == 'true' ? 'checked="checked"' : ''),
'FLASHGAL_HEIGHT' => (isset($module['height']) ? $module['height'] : ''),
'FLASHGAL_TRANSPARENT' => ($module['transparent'] == 'true' ? 'checked="checked"' : ''),
'FLASHGAL_FULLSCREEN' => ($module['fullscreen'] == 'true' ? 'checked="checked"' : ''),
'FLASHGAL_BGCOLOR' => $module['bgcolor'],
'FLASHGAL_RECURS_CATS' => ($module['recurs_cats'] == 'true' ? 'checked="checked"' : ''),
'replace_thumb_CHECKED' => ($module['replace_thumb'] == 'true' ? 'checked="checked"' : ''),
'replace_cats_CHECKED' => ($module['replace_cats'] == 'true' ? 'checked="checked"' : ''),
'ENABLERESTORE' => true,
'FLASHGAL_MAX_COMMENT' => (isset($module['maxcomment']) ? $module['maxcomment'] : '0')
));
}
else
{
$module['users'] = array('guest', 'generic', 'normal', 'admin', 'webmaster');
$module['groups'] = array();
$datas = array();
foreach ($module_data['datas'] as $key => $value)
{
if ($value) // == true
$datas[$key] = $value;
}
$template->assign(array(
'FLASHGAL_TITLE' => l10n('flashgal_add_mod'),
'MODULE_NAME' => l10n('module_name_' . $type),
'show_title_CHECKED' => 'checked="checked"',
'global_CHECKED' => 'checked="checked"',
'on_cats_CHECKED' => 'checked="checked"',
'FLASHGAL_HEIGHT' => '400',
'FLASHGAL_TRANSPARENT' => 'checked="checked"',
'FLASHGAL_FULLSCREEN' => 'checked="checked"',
'FLASHGAL_BGCOLOR' => '#FFFFFF',
'ENABLERESTORE' => false,
'FLASHGAL_MAX_COMMENT' => '0'
));
}
// Selection des utilisateurs
$template->assign('user_perm', array(
'GUEST' => (in_array('guest', $module['users']) ? 'checked="checked"' : ''),
'GENERIC' => (in_array('generic', $module['users']) ? 'checked="checked"' : ''),
'NORMAL' => (in_array('normal', $module['users']) ? 'checked="checked"' : ''),
'ADMIN' => (in_array('admin', $module['users']) ? 'checked="checked"' : ''),
'WEBMASTER' => (in_array('webmaster', $module['users']) ? 'checked="checked"' : '')));
// Selection des groupes
$groups = get_all_groups();
if (!empty($groups))
{
$template->assign('group_perm', array('GROUPSELECTION' => get_html_groups_selection($groups, 'groups', $module['groups'])));
}
// Recuperation des données pour les informations a parametrer dans le flux
foreach ($module_data['datas'] as $key => $value)
{
if ($value) // == true
{
$template->append( 'FlashGal_Param', array(
'name' => $key, // nom du parametre
'lib' => l10n($key), // libelle du parametre
'val' => $datas[$key] // valeur du parametre
));
}
}
// Affichage des categories
$query = '
SELECT id,name,uppercats,global_rank
FROM '.CATEGORIES_TABLE.';';
display_select_cat_wrapper($query,
(isset($module['cats']) ? unserialize($module['cats']) : ''),
'categories',
true);
// Configuration supplémentaire du module (dans le cas ou il y a d'autres parametres)
include_once(FLASHGAL_PATH . 'modules/' . $type . '/admin/config.inc.php');
$template->assign(array('OTHERS_SCRIPT' =>
'
'));
$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/add_module.tpl'));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
?>