<?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(Error(13));
function arrShift($arr,$oObj,$strDir)
{
// Shifts an element up/down in the list. Keys are changed into numeric (0..n) except when $oObj is not found or impossible to move
$arrS = array_values($arr); // Keys are replaced by an integer (0..n)
$i = array_search($oObj,$arrS); // Search postition of $oObj, false if not found
if ( $i===FALSE ) return $arr;
if ( $i==0 && $strDir=='up' ) return $arr;
if ( $i==(count($arr)-1) && $strDir=='down' ) return $arr;
$arrO = $arrS;
$intDir = ($strDir=='up' ? -1 : 1);
$arrO[$i+$intDir] = $arrS[$i];
$arrO[$i] = $arrS[$i+$intDir];
return $arrO;
}
// INITIALISE
$a='';
$d=-1;
$s=-1;
QThttpvar('a d s','str int int');
$oVIP->selfurl = 'qtf_adm_sections.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_content'].'</span><br/>'.$L['Sections'];
// --------
// SUBMITTED
// --------
// ADD DOMAIN
if ( isset($_POST['add_dom']) )
{
// Check
$str = $_POST['title']; if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
$str = QTconv($str,'3',QTF_CONVERT_AMP,false);
if ( empty($str) ) $error = $L['Domain'].'/'.$L['Section'].' '.Error(1);
// Save
if ( empty($error) )
{
require_once('bin/qtf_class_dom.php');
cDomain::Add($str);
}
}
// ADD SECTION
if ( isset($_POST['add_sec']) )
{
// Check title
$str = $_POST['title']; if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
$str = QTconv($str,'3',QTF_CONVERT_AMP,true);
if ( empty($str) ) $error = $L['Domain'].'/'.$L['Section'].' '.Error(1);
// Add section
if ( empty($error) ) cSection::Add(intval($_POST['indomain']),$str);
}
// Move domain/forum
if ( !empty($a) )
{
if ( $a=='d_up' || $a=='d_down' )
{
$oDB->Query('SELECT id FROM '.TABDOMAIN.' ORDER BY titleorder');
$arrList = array();
while($row=$oDB->Getrow()) $arrList[]=intval($row['id']);
$arrO = array_values(arrShift($arrList,$d,substr($a,2)));
foreach($arrO as $intKey=>$intId) $oDB->Query('UPDATE '.TABDOMAIN.' SET titleorder='.$intKey.' WHERE id='.$intId);
if ( isset($_SESSION[QT]['sys_sections']) ) Unset($_SESSION[QT]['sys_sections']);
}
if ( $a=='f_up' || $a=='f_down' )
{
$oDB->Query('SELECT id FROM '.TABSECTION.' WHERE domainid='.$d.' ORDER BY titleorder');
$arrList = array();
while($row=$oDB->Getrow()) $arrList[]=intval($row['id']);
$arrO = array_values(arrShift($arrList,$s,substr($a,2)));
foreach($arrO as $intKey=>$intId) $oDB->Query('UPDATE '.TABSECTION.' SET titleorder='.$intKey.' WHERE id='.$intId);
if ( isset($_SESSION[QT]['sys_sections']) ) Unset($_SESSION[QT]['sys_sections']);
}
}
// --------
// HTML START
// --------
$bJava=true;
include('qtf_adm_p_header.php');
$arrDomains = GetDomains();
$strYes = '<b>'.$L['Y'].'</b>';
$strNo = '<span class="disabled">'.$L['N'].'</span>';
echo '<table class="data_s" cellspacing="0" summary="sections">
<colgroup span="6"><col width="50"></col><col></col><col></col><col></col><col></col><col></col></colgroup>
<tr class="data_s">
<td class="colhd" colspan="2">',$L['Domain'],'/',$L['Section'],'</td>
<td class="colhd">',$L['Userrole_MF'],'</td>
<td class="colhd">',$L['Ref'],'</td>
<td class="colhd">',$L['Action'],'</td>
<td class="colhd">',$L['Move'],'</td>
</tr>
';
$i=0;
foreach($arrDomains as $intDomain=>$strDomtitle)
{
// GET SECTIONS (with hidden)
$arrSections = GetSections('A',$intDomain);
// DISPLAY
echo '<tr class="data_s">',N;
echo '<td class="colgroup" colspan="2">',$strDomtitle,'</td>',N;
echo '<td class="colgroup"> </td>',N;
echo '<td class="colgroup"> </td>',N;
echo '<td class="colgroup" style="text-align:center"><a class="small" href="qtf_adm_domain.php?d=',$intDomain,'">',$L['Edit'],'</a>';
echo ' · ',($intDomain==0 ? '<span class="disabled">'.$L['Delete'].'</span>' : '<a class="small" href="qtf_adm_change.php?a=deletedomain&d='.$intDomain.'">'.$L['Delete'].'</a>'),'</td>';
echo '<td class="colgroup" style="text-align:center;">';
if ( $i==0 )
{
echo '<span class="disabled">',$L['Up'],'</span>';
}
else
{
echo '<a class="small" href="qtf_adm_sections.php?d=',$intDomain,'&a=d_up">',$L['Up'],'</a>';
}
echo ' · ';
if ( $i+1==count($arrDomains) )
{
echo '<span class="disabled">',$L['Down'],'</span>';
}
else
{
echo '<a class="small" href="qtf_adm_sections.php?d=',$intDomain,'&a=d_down">',$L['Down'],'</a>';
}
$i += 1;
$j = 0;
foreach($arrSections as $intSecid=>$strSectitle)
{
// GET SECTIONS
$oSEC = new cSection($intSecid);
echo '<tr class="data_s">';
echo '<td class="colct" style="text-align:center">',AsImg($oSEC->GetLogo(),'ico i_sec','','qtf_adm_section.php?d='.$intDomain.'&s='.$oSEC->id),'</td>';
echo '<td class="colct"><a class="bold" href="qtf_adm_section.php?d=',$intDomain,'&s=',$oSEC->id,'">',$oSEC->name,'</a><br/><span class="small">',$L['Section_type'][$oSEC->type],($oSEC->status==1 ? '('.$L['Section_status'][1].')' : ''),'</span></td>';
echo '<td class="colct" style="text-align:center">',$oSEC->modname,'</td>';
echo '<td class="colct" style="text-align:center">',( $oSEC->numfield=='N' ? $strNo : sprintf($oSEC->numfield,1) ),'</td>';
echo '<td class="colct" style="text-align:center"><a class="small" href="qtf_adm_section.php?d=',$intDomain,'&s=',$oSEC->id,'">',$L['Edit'],'</a>';
echo ' · ',($intSecid==0 ? '<span class="disabled">'.$L['Delete'].'</span>' : '<a class="small" href="qtf_adm_change.php?a=deletesection&s='.$intSecid.'">'.$L['Delete'].'</a>'),'</td>';
echo '<td class="colct" style="text-align:center">';
if ( $j==0 ) { echo '<span class="disabled">',$L['Up'],'</span>'; } else { echo '<a class="small" href="qtf_adm_sections.php?d=',$intDomain,'&s=',$intSecid,'&a=f_up">',$L['Up'],'</a>'; }
echo ' · ';
if ( $j+1==count($arrSections) ) { echo '<span class="disabled">',$L['Down'],'</span>'; } else { echo '<a class="small" href="qtf_adm_sections.php?d=',$intDomain,'&s=',$intSecid,'&a=f_down">',$L['Down'],'</a>'; }
$j += 1;
echo '</td></tr>',N;
}
}
echo '</table>',N,N;
echo '<h2>',$L['Section_add'],'</h2>',N;
echo '
<script type="text/javascript">
<!--
function ValidateForm(theForm)
{
if (theForm.title.value.length==0) { alert(qtHtmldecode("',$L['E_mandatory'],': ',$L['Domain'],'/',$L['Section'],'")); return false; }
return null;
}
-->
</script>
';
echo '<form method="post" action="qtf_adm_sections.php" onsubmit="return ValidateForm(this);">
<table class="data_s" cellspacing="0" summary="add domain">
<tr class="data_s">
<td class="colgroup" style="width:130px;">',$L['Domain_add'],'</td>
<td class="colgroup"><input name="title" type="text" size="30" maxlength="64" onKeyUp="handle_keypress(event,\'add_dom\')"/></td>
<td class="colgroup" style="width:75px;"><input id="add_dom" name="add_dom" type="submit" value="',$L['Add'],'"/></td>
</tr>
</table>
</form>
';
echo '<form method="post" action="qtf_adm_sections.php" onsubmit="return ValidateForm(this);">
<table class="data_o" cellspacing="0" summary="add section">
<tr class="data_s">
<td class="colct" style="width:130px;">',$L['Section_add'],'</td>
<td class="colct">
<input name="title" type="text" size="30" maxlength="64"/>
',$L['In_domain'],S,'<select name="indomain" size="1" class="small">',QTasTag($arrDomains),'</select>
</td>
<td class="colct" style="width:75px;"><input name="add_sec" type="submit" value="',$L['Add'],'"/></td>
</tr>
</table>
</form>
';
// HTML END
include('qtf_adm_p_footer.php');
?>