<?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.
*
* @category Troubleticket
* @package QuickTicket
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @license http://www.php.net/license PHP License 3.0
* @version 1.9.0.3 build:20081001
* @link http://www.qt-cute.org/doc/package/qti
* @since File available since Release 1.0.0
* @deprecated File deprecated in Release 2.0.0
*
*/
session_start();
require_once('bin/qti_init.php');
include(Translate('qti_lang_adm.inc'));
if ( $oVIP->role!='A' ) die($L['E_admin']);
// INITIALISE
function arrShift($arrSrc,$intObject,$strDir)
{
$arrTemp = $arrSrc;
// search for the value
foreach ($arrSrc as $intKey => $intValue)
{
if ( $intValue==$intObject ) $intNewkey = $intKey;
}
if ( !isset($intNewkey) ) return false;
if ( $intNewkey==0 && $strDir=='up' ) return $arrSrc;
if ( $intNewkey==(count($arrSrc)-1) && $strDir=='down' ) return $arrSrc;
// reorder the elements
if ( $strDir=='up' ) { $intDir = -1; } else { $intDir = 1; }
$arrTemp[$intNewkey+$intDir] = $arrSrc[$intNewkey];
$arrTemp[$intNewkey] = $arrSrc[$intNewkey+$intDir];
// return the ordered array
return $arrTemp;
}
$oVIP->selfurl = 'qti_adm_sections.php';
$oVIP->selfname = $L['Section_man'];
// --------
// SUBMITTED
// --------
// ADD DOMAIN
if ( isset($_POST['add_dom']) )
{
// Check
$str = $_POST['title']; if ( get_magic_quotes_gpc() ) $str = stripslashes($str);
$str = QTconv($str,'3',QTI_CONVERT_AMP,false);
if ( empty($str) ) $qti_error = $L['Domain'].'/'.$L['Section'].S.$L['E_invalid'];
// Save
if ( empty($qti_error) )
{
$intNewid = Nextid(TABDOMAIN);
$oDB->Query( 'INSERT INTO '.TABDOMAIN.' (id,title,titleorder) VALUES ('.$intNewid.',"'.addslashes($str).'",0)' );
// Register
$_SESSION['qtiDomains'][$intNewid] = addslashes($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',QTI_CONVERT_AMP);
if ( empty($str) ) $qti_error = $L['Domain'].'/'.$L['Section'].S.$L['E_invalid'];
// SAVE
if ( empty($qti_error) )
{
$intId = Nextid(TABSECTION);
$oDB->Query('INSERT INTO '.TABSECTION.' (domainid,id,title,type,status,notify,titleorder,moderator,moderatorname,topics,replies,titlefield,numfield,infofield,wisheddate,alternate,prefix)
VALUES ('.intval($_POST['indomain']).','.$intId.',"'.addslashes($str).'","0","0","1",0,0,"Admin",0,0,"1","%03s","replies","0","0","a")');
}
}
// Move domain/section
if ( isset($_GET['a']) )
{
if ( $_GET['a']=='d_up' )
{
$oDB->Query('SELECT id FROM '.TABDOMAIN.' ORDER BY titleorder');
$arrList = array();
while ($row = $oDB->Getrow())
{
$arrList[]=$row['id'];
}
$arrOrdered = arrShift($arrList,$_GET['d'],'up');
$i = 0;
foreach ($arrOrdered as $intId)
{
$oDB->Query('UPDATE '.TABDOMAIN." SET titleorder=$i WHERE id=$intId");
$i++;
}
}
if ( $_GET['a']=='d_down' )
{
$oDB->Query('SELECT id FROM '.TABDOMAIN.' ORDER BY titleorder');
$arrList = array();
while ($row = $oDB->Getrow())
{
$arrList[]=$row['id'];
}
$arrOrdered = arrShift($arrList,$_GET['d'],'down');
$i = 0;
foreach ($arrOrdered as $intId)
{
$oDB->Query('UPDATE '.TABDOMAIN." SET titleorder=$i WHERE id=$intId");
$i++;
}
}
if ( $_GET['a']=='f_up' )
{
$oDB->Query('SELECT id FROM '.TABSECTION.' ORDER BY titleorder');
$arrList = array();
while ( $row=$oDB->Getrow() )
{
$arrList[]=$row['id'];
}
$arrOrdered = arrShift($arrList,$_GET['s'],'up');
$i = 0;
foreach ($arrOrdered as $intId)
{
$oDB->Query('UPDATE '.TABSECTION." SET titleorder=$i WHERE id=$intId");
$i++;
}
}
if ( $_GET['a']=='f_down' )
{
$oDB->Query('SELECT id FROM '.TABSECTION.' ORDER BY titleorder');
$arrList = array();
while ($row = $oDB->Getrow())
{
$arrList[]=$row['id'];
}
$arrOrdered = arrShift($arrList,$_GET['s'],'down');
$i = 0;
foreach ($arrOrdered as $intId)
{
$oDB->Query('UPDATE '.TABSECTION.' SET titleorder='.$i.' WHERE id='.$intId);
$i++;
}
}
}
// --------
// HTML START
// --------
include('qti_adm_p_header.php');
include('qti_adm_p_title.php');
// CONTENT
$_SESSION['qtiDomains'] = GetDomains();
$_SESSION['qtiGoto'] = GetSectionTitles($oVIP->role,-1,-1,'',QTI_SHOW_DOMAIN);
$strYes = '<b>'.$L['Y'].'</b>';
$strNo = '<span class="disabled">'.$L['N'].'</span>';
echo '<table class="ta ta_s" cellspacing="0">
<colgroup span="7"><col width="50"></col><col></col><col></col><col></col><col></col><col></col><col></col></colgroup>
<tr class="tr_s tr_s0">
<th class="th_o" colspan="2">',$L['Domain'],'/',$L['Section'],'</th>
<th class="th_o">',$L['Userrole_MF'],'</th>
<th class="th_o">',$L['Ref'],'</th>
<th class="th_o">',$L['Notification'],'</th>
<th class="th_o">',$L['Action'],'</th>
<th class="th_o">',$L['Move'],'</th>
</tr>
';
$i=0;
foreach ($_SESSION['qtiDomains'] as $intDomid => $strDomtitle)
{
// GET FORUMS (with hidden)
$arrSections = GetSectionTitles('A',$intDomid);
// DISPLAY
echo '<tr class="tr_s tr_s1">',N;
echo '<td class="td_o_all" colspan="2">',$strDomtitle,'</td>',N;
echo '<td class="td_o_all"> </td>',N;
echo '<td class="td_o_all"> </td>',N;
echo '<td class="td_o_all"> </td>',N;
echo '<td class="td_o_all" style="text-align:center"><a class="small" href="qti_adm_domain.php?d=',$intDomid,'">',$L['Edit'],'</a>';
echo ' · ',($intDomid==0 ? '<span class="disabled">'.$L['Delete'].'</span>' : '<a class="small" href="qti_adm_cmd.php?a=deletedomain&s='.$intDomid.'">'.$L['Delete'].'</a>'),'</td>';
echo '<td class="td_o_all" style="text-align:center;">';
if ( $i==0 )
{
echo '<span class="disabled">',$L['Up'],'</span>';
}
else
{
echo '<a class="small" href="qti_adm_sections.php?d=',$intDomid,'&a=d_up">',$L['Up'],'</a>';
}
echo ' · ';
if ( $i+1==count($_SESSION['qtiDomains']) )
{
echo '<span class="disabled">',$L['Down'],'</span>';
}
else
{
echo '<a class="small" href="qti_adm_sections.php?d=',$intDomid,'&a=d_down">',$L['Down'],'</a>';
}
$i += 1;
$j = 0;
foreach ($arrSections as $intSecid => $strSectitle)
{
// GET SECTIONS
$oSEC = new cSection($intSecid);
echo '<tr class="tr_s tr_s2">';
echo '<td class="td_o" style="text-align:center">',AsImg($_SESSION[QT]['skin_dir'].'/ico_section_'.$oSEC->type.'_'.$oSEC->status.'.gif','S',$L['Ico_section_'.$oSEC->type.'_'.$oSEC->status],'ico ico_s',null,'qti_adm_section.php?d='.$intDomid.'&s='.$oSEC->id),'</td>';
echo '<td class="td_o"><a class="bold" href="qti_adm_section.php?d=',$intDomid,'&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="td_o" style="text-align:center">',$oSEC->modname,'</td>';
echo '<td class="td_o" style="text-align:center">',( $oSEC->numfield=='N' ? $strNo : sprintf($oSEC->numfield,1) ),'</td>';
echo '<td class="td_o" style="text-align:center">',( $oSEC->notify==1 ? $strYes : $strNo ),'</td>';
echo '<td class="td_o" style="text-align:center"><a class="small" href="qti_adm_section.php?d=',$intDomid,'&s=',$oSEC->id,'">',$L['Edit'],'</a>';
echo ' · ',($intSecid==0 ? '<span class="disabled">'.$L['Delete'].'</span>' : '<a class="small" href="qti_adm_cmd.php?a=deletesection&s='.$intSecid.'">'.$L['Delete'].'</a>'),'</td>';
echo '<td class="td_o" style="text-align:center">';
if ( $j==0 ) { echo '<span class="disabled">',$L['Up'],'</span>'; } else { echo '<a class="small" href="qti_adm_sections.php?d=',$intDomid,'&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="qti_adm_sections.php?d=',$intDomid,'&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(html_entity_decode("',$L['E_mandatory'],': ',$L['Domain'],'/',$L['Section'],'")); return false; }
return null;
}
-->
</script>
';
echo '<form method="post" action="qti_adm_sections.php" onsubmit="return ValidateForm(this);">
<table class="ta ta_s" cellspacing="0">
<tr class="tr_s tr_s0">
<td class="td_o_all" style="width:130px;">',$L['Domain_add'],'</td>
<td class="td_o_all"><input name="title" type="text" size="30" maxlength="64" onKeyUp="handle_keypress(event,\'add_dom\')"/></td>
<td class="td_o_all" style="width:75px;"><input id="add_dom" name="add_dom" type="submit" value="',$L['Add'],'"/></td>
</tr>
</table>
</form>
',N;
echo '<form method="post" action="qti_adm_sections.php" onsubmit="return ValidateForm(this);">
<table class="ta" cellspacing="0">
<tr class="tr_s tr_s1">
<td class="td_o" style="width:130px;">',$L['Section_add'],'</td>
<td class="td_o">
<input name="title" type="text" size="30" maxlength="64"/>
',$L['In_domain'],S,'<select name="indomain" size="1" class="small">',QTastags($_SESSION['qtiDomains']),'</select>
</td>
<td class="td_o" style="width:75px;"><input name="add_sec" type="submit" value="',$L['Add'],'"/></td>
</tr>
</table>
</form>
',N;
// HTML END
include('qti_adm_p_footer.php');
?>