<?php
/**
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @package QuickTalk
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @version 2.5 build:20100924
*/
session_start();
require_once('bin/qtf_init.php');
include(Translate('qtf_adm.php'));
if ( $oVIP->role!='A' ) die($L['E_admin']);
// INITIALISE
$s = -1;
$tt = 0; // 0:definition, 1:display or 9:translation
QThttpvar('s tt','int int');
if ( $s<0 ) die('Missing parameters');
if ( $tt!=0 && $tt!=1 && $tt!=9 ) die('Missing parameters');
$oVIP->selfurl = 'qtf_adm_section.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_content'].'</span><br/>'.$L['Section_upd'];
$oVIP->exiturl = 'qtf_adm_sections.php';
$oVIP->exitname = '« '.$L['Sections'];
$arrDomains = GetDomains();
$arrStaff = GetUsers('M');
if ( count($arrStaff)>10 ) { $bAjax=true; } else { $bAjax=false; }
$oSEC = new cSection($s);
// --------
// SUBMITTED
// --------
if ( isset($_POST['ok']) && $tt==0 )
{
// CHECK MANDATORY VALUE
$str = trim($_POST['title']); if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
$str = QTconv($str,'3',QTF_CONVERT_AMP,false);
if ( empty($str) ) $error = $L['Title'].' '.$L['E_invalid'];
if ( empty($error) )
{
$oSEC->domid = intval($_POST['domain']);
$oSEC->idtitle = $str;
$oSEC->name = $str;
$oSEC->type = intval($_POST['type']);
$oSEC->status = intval($_POST['status']);
//$oSEC->notify = intval($_POST['notify']);
if ( isset($_POST['modname']) )
{
if ( $_POST['modname']!=$_POST['modnameold'] )
{
$oSEC->modname = $_POST['modname'];
$oSEC->modid = array_search($_POST['modname'],$arrStaff);
if ( $oSEC->modid==FALSE || empty($oSEC->modid) ) { $oSEC->modid=1; $oSEC->modname=$arrStaff[1]; $warning=$L['Userrole_MF'].' '.$L['E_invalid']; }
}
}
if ( isset($_POST['modid']) )
{
if ( $_POST['modid']!=$_POST['modidold'] )
{
$oSEC->modname = $arrStaff[$_POST['modid']];
$oSEC->modid = $_POST['modid'];
}
}
$oSEC->titlefield = intval($_POST['titlefield']);
$oSEC->numfield = trim($_POST['numfield']); if ( strlen($oSEC->numfield)==0 ) $oSEC->numfield='N';
$oSEC->prefix = $_POST['prefix'];
//$oSEC->eventdate = intval($_POST['eventdate']);
//$oSEC->wisheddate = intval($_POST['wisheddate']);
//$oSEC->notifycc = intval($_POST['alternate']);
}
// SAVE
if ( empty($error) )
{
// update
$strQ = 'UPDATE '.TABSECTION.' SET';
$strQ .= ' domainid='.$oSEC->domid;
$strQ .= ',title="'.$oSEC->idtitle.'"';
$strQ .= ',type="'.$oSEC->type.'"';
$strQ .= ',status="'.$oSEC->status.'"';
$strQ .= ',notify="'.$oSEC->notify.'"';
$strQ .= ',moderator='.$oSEC->modid;
$strQ .= ',moderatorname="'.$oSEC->modname.'"';
$strQ .= ',titlefield="'.$oSEC->titlefield.'"';
$strQ .= ',numfield="'.$oSEC->numfield.'"';
//$strQ .= ',alternate="'.$oSEC->notifycc.'"';
//$strQ .= ',eventdate="'.$oSEC->eventdate.'"';
//$strQ .= ',wisheddate="'.$oSEC->wisheddate.'"';
$strQ .= ',prefix="'.$oSEC->prefix.'"';
$strQ .= ' WHERE id='.$oSEC->id;
$oDB->Query($strQ);
// unregister and exit
$_SESSION['L'] = array();
if ( isset($_SESSION[QT]['sys_sections']) ) Unset($_SESSION[QT]['sys_sections']);
$strInfo = $L['S_save'];
}
}
if ( isset($_POST['ok']) && $tt==1 )
{
$oSEC->d_order = $_POST['d_order'];
$oSEC->d_last = $_POST['d_last'];
$oSEC->d_logo = $_POST['d_logo'];
$oSEC->options = 'order='.$oSEC->d_order.';last='.$oSEC->d_last.';logo='.$oSEC->d_logo;
$oDB->Query( 'UPDATE '.TABSECTION.' SET options="'.$oSEC->options.'" WHERE id='.$oSEC->id );
$strInfo = $L['S_save'];
}
if ( isset($_POST['ok']) && $tt==9 )
{
// translations
cVIP::LangDel(array('sec','secdesc'),'s'.$oSEC->id);
foreach($_POST as $strKey=>$strTranslation)
{
if ( substr($strKey,0,1)=='T' )
{
if ( !empty($strTranslation) )
{
if ( get_magic_quotes_gpc() ) $strTranslation = stripslashes($strTranslation);
cVIP::LangAdd('sec',substr($strKey,1),'s'.$oSEC->id,$strTranslation);
}
}
if ( substr($strKey,0,1)=='D' )
{
if ( !empty($strTranslation) )
{
if ( get_magic_quotes_gpc() ) $strTranslation = stripslashes($strTranslation);
cVIP::LangAdd('secdesc',substr($strKey,1),'s'.$oSEC->id,$strTranslation);
}
}
}
// unregister
if ( isset($_SESSION['L']) ) $_SESSION['L'] = array();
if ( isset($_SESSION[QT]['sys_sections']) ) Unset($_SESSION[QT]['sys_sections']);
// exit
$strInfo = $L['S_save'];
}
// --------
// HTML START
// --------
if ( $bAjax )
{
$strHeadScript = '
<link rel="stylesheet" type="text/css" href="bin/css/qt_jquery.css"/>
<script type="text/javascript" src="bin/qt_jquery.js"></script>
<script type="text/javascript" src="bin/qt_jquery_auto.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
$("#modname").autocomplete("qtf_j_name.php", {
selectFirst: false,
extraParams: { r:"M" }
});
});
-->
</script>';
}
include('qtf_adm_p_header.php');
$arrDest = $arrDomains;
Unset($arrDest[$oSEC->domid]);
// DISPLAY TABS
$arrTabs = array(0=>$L['Adm_settings'],1=>$L['Display_options'],9=>$L['Translations']);
echo HtmlTabs($arrTabs, $oVIP->selfurl.'?s='.$s, $tt, 6, true, true, $L['E_editing']);
// DISPLAY TAB PANEL
echo '<table class="pan" cellspacing="0" summary="tabs">
<tr class="pan">
<td class="pan">
<div class="pan_top">',$oSEC->idtitle,' · ',$arrTabs[$tt],'</div>
';
// FORM 0
if ( $tt==0 )
{
echo '
<script type="text/javascript">
<!--
function ValidateForm(theForm)
{
if (theForm.title.value.length==0) { alert(qtHtmldecode("',$L['E_mandatory'],': ',$L['Title'],'")); return false; }
return null;
}
-->
</script>
';
echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(this);">
<table class="data_o" cellspacing="0" summary="section">
<tr class="data_o">
<td class="colhd colhdgroup" style="text-align:left" colspan="2"><b>',$L['Definition'],'</b></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" style="width:150px; text-align:right"><span class="texthead"><label for="title">',$L['Title'],'</label></span></td>
<td class="colct"><input type="text" id="title" name="title" size="55" maxlength="64" value="',$oSEC->name,'" style="background-color:#FFFF99;" onchange="bEdited=true;"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" style="width:150px; text-align:right"><span class="texthead">',$L['Domain'],'</span></td>
<td class="colct"><select name="domain" onchange="bEdited=true;">
<option value="',$oSEC->domid,'"',QSEL,'>',$arrDomains[$oSEC->domid],'</option>',QTasTag($arrDest,'',array('format'=>$L['Move_to'].': %s')),'</select></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" style="text-align:left" colspan="2"><b>',$L['Properties'],'</b></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" style="text-align: right; width:150px"><span class="texthead"><label for="type">',$L['Type'],'</label></span></td>
<td class="colct">
<select id="type" name="type" onchange="bEdited=true;">
<option value="1"',($oSEC->type==1 ? QSEL : ''),'>',$L['Section_type'][1],'</option>
<option value="0"',($oSEC->type==0 ? QSEL : ''),'>',$L['Section_type'][0],'</option>
<option value="2"',($oSEC->type==2 ? QSEL : ''),'>',$L['Section_type'][2],'</option>
</select>
',$L['Status'],' <select id="status" name="status" onchange="bEdited=true;">
<option value="0"',($oSEC->status==0 ? QSEL : ''),'>',$L['Section_status'][0],'</option>
<option value="1"',($oSEC->status==1 ? QSEL : ''),'>',$L['Section_status'][1],'</option>
</select>
';
echo '</td>
</tr>
';
if ( $bAjax )
{
echo '<tr class="data_o">
<td class="colhd" style="width:150px; text-align:right"><span class="texthead">',$L['Userrole_MF'],'</span></td>
<td class="colct">
<input type="hidden" name="modnameold" value="',$oSEC->modname,'" onchange="bEdited=true;"/>
<input name="modname" id="modname" size="20" maxlength="24" value="',$oSEC->modname,'" onchange="bEdited=true;"/>
</td>
</tr>
';
}
else
{
echo '<tr class="data_o">
<td class="colhd" style="width:150px; text-align:right"><span class="texthead">',$L['Userrole_MF'],'</span></td>
<td class="colct">
<input type="hidden" name="modidold" value="',$oSEC->modid,'" onchange="bEdited=true;"/>
<select name="modid" id="modid" onchange="bEdited=true;">',QTasTag($arrStaff,$oSEC->modid,array('current'=>$oSEC->modid,'classC'=>'bold')),'</select>
</td>
</tr>
';
}
echo '<tr class="data_o">
<td class="colhd colhdgroup" style="text-align:left" colspan="2"><b>',$L['Specific_fields'],'</b></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" style="text-align: right; width:150px"><span class="texthead"><label for="numfield">',$L['Show_topic_id'],'</label></span></td>
<td class="colct"><input type="text" size="12" maxlength="24" name="numfield" value="',($oSEC->numfield=='N' ? '' : $oSEC->numfield),'" onchange="bEdited=true;"/> <span class="small">',$L['H_Show_topic_id'],'</span></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" style="text-align: right; width:150px"><span class="texthead"><label for="titlefield">',$L['Show_topic_title'],'</label></span></td>
<td class="colct"><select id="titlefield" name="titlefield" onchange="bEdited=true;">',QTasTag($L['Topic_title'],$oSEC->titlefield),'</select> <span class="small">',$L['H_Show_topic_title'],'</span></td>
</tr>
';
echo '<tr class="data_o" title="',$L['H_Topic_prefix'],'">
<td class="colhd" style="text-align: right; width:150px"><span class="texthead"><label for="prefix">',$L['Topic_prefix'],'</label></span></td>
<td class="colct">
<select id="prefix" name="prefix" onchange="bEdited=true;">
',QTasTag($L['Prefix_serie'],$oSEC->prefix),'
<option value="0"',($oSEC->prefix=='0' ? QSEL : ''),'>','(',$L['None'],')','</option>
</select> <a class="small" href="qtf_adm_prefix.php" target="_blank">',$L['Topic_prefix_demo'],'</a>
</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" colspan="2" style="padding:6px; text-align:center">
<input type="hidden" name="s" value="',$oSEC->id,'"/>
<input type="hidden" name="tt" value="',$tt,'"/>
<input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
';
echo '</table>
</form>
';
}
// FORM 1
if ( $tt==1 )
{
$str='';
$strFile='';
if ( file_exists('upload/section/'.$s.'.gif') ) $strFile = $s.'.gif';
if ( file_exists('upload/section/'.$s.'.jpg') ) $strFile = $s.'.jpg';
if ( file_exists('upload/section/'.$s.'.png') ) $strFile = $s.'.png';
if ( file_exists('upload/section/'.$s.'.jpeg') ) $strFile = $s.'.jpeg';
if ( !empty($strFile) ) $str = '<option value="'.$strFile.'"'.(!empty($oSEC->d_logo) ? QSEL : '').'>'.$L['Specific_image'].'</option>';
echo '
<script type="text/javascript">
<!--
function switchimage(strId)
{
var strDefault="'.$_SESSION[QT]['skin_dir'].'/ico_section_'.$oSEC->type.'_'.$oSEC->status.'.gif";
var strSpecific="upload/section/',$strFile,'";
document.getElementById(strId).src=(document.getElementById(strId).src.search(strDefault)==-1 ? strDefault : strSpecific);
return null;
}
-->
</script>
';
echo '<form method="post" action="',$oVIP->selfurl,'">
<table class="data_o" cellspacing="0" summary="section">
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" style="text-align:left" colspan="2"><b>',$L['Display_options'],'</b></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" style="width:150px; text-align:right"><span class="texthead">Logo</span></td>
<td class="colct"><select id="d_logo" name="d_logo" onchange="bEdited=true; switchimage(\'idlogo\');">
<option value=""',(empty($oSEC->d_logo) ? QSEL : ''),'>',$L['Default'],'</option>
',(empty($str) ? '' : $str).'
</select> ',AsImg($oSEC->GetLogo(),'S',$L['Ico_section_'.$oSEC->type.'_'.$oSEC->status],'ico i_sec','vertical-align:middle','','idlogo'),' <a class="small" href="qtf_adm_section_img.php?s=',$s,'">',$L['Add'],'/',$L['Remove'],'</a>
</td>
</tr>
';
$arr = array('lastpostdate'=>'Date of the last post','numid'=>'Reference number','title'=>'Title');
echo '<tr class="data_o">
<td class="colhd" style="width:150px; text-align:right"><span class="texthead">Tickets order</span></td>
<td class="colct">
<select name="d_order" id="d_order" onchange="bEdited=true;"/>',QTasTag($arr,$oSEC->d_order,array('current'=>$oSEC->d_order,'classC'=>'bold')),'</select>
</td>
</tr>
';
$arr = array('views'=>$L['Views'],'status'=>$L['Status'],'id'=>'Id'); if ( !empty($_SESSION[QT]['tags']) ) $arr['tags']=$L['Tags'];
echo '<tr class="data_o">
<td class="colhd" style="text-align: right; width:150px"><span class="texthead"><label for="d_last">',$L['Infofield'],'</label></span></td>
<td class="colct">
<select id="d_last" name="d_last" onchange="bEdited=true;">',QTasTag($arr,$oSEC->d_last),'<option value="none"',($oSEC->d_last=='none' ? QSEL : ''),'>(',$L['None'],')</option>
</select></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" colspan="2" style="padding:6px; text-align:center">
<input type="hidden" name="s" value="',$oSEC->id,'"/>
<input type="hidden" name="tt" value="',$tt,'"/>
<input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
';
echo '</table>
</form>
';
}
// FORM 9
if ( $tt==9 )
{
echo '<form method="post" action="',$oVIP->selfurl,'">
<table class="data_o" cellspacing="0" summary="section">
';
echo '<td class="colhd colhdgroup" colspan="3">',$L['Translations'],'</td>
<tr class="data_o">
<td class="colhd colhdfirst">',$L['Section_name_and_desc'],'</td>
<td class="colct" colspan="2">
<p class="help">',sprintf($L['E_no_translation'],$oSEC->idtitle),'</p>
<table cellspacing="0" class="hidden">';
$arrTrans = cVIP::LangGet('sec','*','s'.$oSEC->id);
$arrDescTrans = cVIP::LangGet('secdesc','*','s'.$oSEC->id);
include('bin/qtf_lang.php'); // this creates $arrLang
foreach($arrLang as $strIso=>$arr)
{
$str = '';
if ( isset($arrTrans[$strIso]) ) {
if ( !empty($arrTrans[$strIso]) ) {
$str = QTconv($arrTrans[$strIso],'I');
}}
echo '
<tr class="hidden">
<td class="hidden" style="width:30px"><span title="',$arr[1],'">',$arr[0],'</span></td>
<td class="hidden"><input class="small" title="',$L['Section'],' (',$strIso,')" type="text" id="T',$strIso,'" name="T',$strIso,'" size="30" maxlength="64" value="',$str,'" onchange="bEdited=true;"/> </td>';
$str = '';
if ( isset($arrDescTrans[$strIso]) ) {
if ( !empty($arrDescTrans[$strIso]) ) {
$str = QTconv($arrDescTrans[$strIso],'I');
}}
echo '<td class="hidden"><textarea class="small" title="',$L['Description'],' (',$strIso,')" type="text" id="D',$strIso,'" name="D',$strIso,'" cols="45" rows="2" onchange="bEdited=true;">',$str,'</textarea></td>
</tr>
';
}
echo '</table>
</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd" colspan="3" style="padding:6px; text-align:center">
<input type="hidden" name="s" value="',$oSEC->id,'"/>
<input type="hidden" name="tt" value="',$tt,'"/>
<input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
';
echo '</table>
</form>
';
}
// END TABS
echo '
</td>
</tr>
</table>
<p><a href="',$oVIP->exiturl,'" onclick="return qtEdited(bEdited,\'',$L['E_editing'],'\');">',$oVIP->exitname,'</a></p>
';
// HTML END
include('qtf_adm_p_footer.php');
?>