<?PHP

/* ====================
Seditio - Website engine
Copyright Neocrome & Seditio Team
http://www.neocrome.net
http://www.seditio.org
[BEGIN_SED]
File=plugins/markhtml/markhtml.php
Version=161
Updated=2012-feb-15
Type=Plugin
Author=Neocrome
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=markhtml
Part=admin
File=markhtml.admin
Hooks=tools
Tags=
Order=10
[END_SED_EXTPLUGIN]
==================== */

if (!defined('SED_CODE') || !defined('SED_ADMIN')) { die('Wrong URL.'); }

$g = sed_import('g','G','INT');
$n = sed_import('n','G','TXT');

$cfg_value = sed_import('cfg_value','P','TXT');
$cfg_name = sed_import('cfg_name','P','TXT');
$cfg_usergroup = sed_import('cfg_usergroup','P','TXT');

if ($n == "update") {
     $sql = sed_sql_query("UPDATE $db_config SET config_value='".sed_sql_prep($cfg_value)."' 
                           WHERE config_name='".$cfg_name."' AND config_owner='plug'");
     if ($sql) {
        header("Location: admin.php?m=tools&p=markhtml");
		    exit;
     }   
}

if ($n == "add") {
     sed_sql_query("INSERT $db_config (config_owner, config_cat, config_order, config_name,
                    config_type, config_value, config_default, config_text) 
                    VALUES ('plug','markhtml','0".sed_sql_prep($cfg_usergroup)."','".sed_sql_prep($cfg_name)."','0','".sed_sql_prep($cfg_value)."','',
                    'Prohibited HTML tags for #USER_GROUP ".sed_sql_prep($cfg_usergroup)."')");
     if ($sql) {
        header("Location: admin.php?m=tools&p=markhtml");
		    exit;
     }   
}


$sql = sed_sql_query("SELECT grp_id, grp_title, grp_disabled, grp_hidden FROM $db_groups WHERE 1 order by grp_level DESC, grp_id DESC");

$adminmain .= "<table class=\"cells\">";
$adminmain .= "<tr>";
$adminmain .= "<td  class=\"coltop\">".$L['Groups']." ".$L['adm_clicktoedit']."</td>";
$adminmain .= "<td class=\"coltop\" style=\"width:10%;\"></td>";
$adminmain .= "</tr>";

if (sed_sql_numrows($sql)>0)
	{
	while ($row = sed_sql_fetchassoc($sql))
		{

    $adminmain .= "<tr>";
		$adminmain .= "<td><img src=\"system/img/admin/groups.png\" alt=\"\" /> ";
		$adminmain .= "<a href=\"admin.php?m=tools&amp;p=markhtml&amp;g=".$row['grp_id']."\">".sed_cc($row['grp_title'])."</a></td>";

		$adminmain .= "<td style=\"text-align:center;\"><a href=\"admin.php?m=tools&amp;p=markhtml&amp;g=".$row['grp_id']."\"><img src=\"plugins/markhtml/inc/distags.gif\" alt=\"\" /></a></td>";
		$adminmain .= "</tr>";
		}
	}
$adminmain .= "</table>";

if (!empty($g) && ($g > 0))
{
  $adminmain .= "<h4>Prohibited HTML tags for <strong>".$sed_groups[$g]['title']."</strong> (#USER_GROUP_ID ".$g.")</h4>"; 
  
  $usergroupconfig = "usergroup_".$g;
  
  if (isset($cfg['plugin']['markhtml'][$usergroupconfig])) {
    $adminmain .= "<form id=\"addlevel\" action=\"admin.php?m=tools&amp;p=markhtml&amp;n=update\" method=\"post\">";    
    $adminmain .= "<textarea name=\"cfg_value\" id=\"cfg_value\" cols=\"60\" rows=\"5\">".$cfg['plugin']['markhtml'][$usergroupconfig]."</textarea><br />";
    
    $adminmain .= "<input type=\"hidden\" name=\"cfg_name\" value=\"".$usergroupconfig."\" />";
    $adminmain .= "<input type=\"hidden\" name=\"cfg_usergroup\" value=\"".$g."\" />";
    
    $adminmain .= "<input type=\"submit\" class=\"submit\" value=\"".$L['Update']."\" />";    
    $adminmain .= "</form>";    
  }
  else {
    $adminmain .= "<form id=\"addlevel\" action=\"admin.php?m=tools&amp;p=markhtml&amp;n=add\" method=\"post\">";    
    $adminmain .= "<textarea name=\"cfg_value\" id=\"cfg_value\" cols=\"60\" rows=\"5\"></textarea><br />";
    
    $adminmain .= "<input type=\"hidden\" name=\"cfg_name\" value=\"".$usergroupconfig."\" />";
    $adminmain .= "<input type=\"hidden\" name=\"cfg_usergroup\" value=\"".$g."\" />";
    
    $adminmain .= "<input type=\"submit\" class=\"submit\" value=\"".$L['Add']."\" />";    
    $adminmain .= "</form>";    
  }
  
}


?>
