Location: PHPKode > projects > QT-registrations > qtregistrations/qtr_adm_tab.php
<?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    QT-registerations
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.4 build:20100313
*/

session_start();
require_once('bin/qtr_init.php');
if ( $oVIP->role!='A' ) die(Error(13));

include(Translate('qtr_adm.php'));
include(Translate('qtr_adm_tf.php'));

// --------
// INITIALISE
// --------

$s = -1;
$id = '';
$oldid = '';
QThttpvar('s id oldid','int str str');
if ( $s<0 ) die('Missing parameters');
if ( empty($id) ) $id = $oldid; // the form can have the id disabled
if ( empty($id) ) die('Missing parameters');

include('bin/qtr_lang.php'); // this creates $arrLang

$oVIP->selfurl = 'qtr_adm_tab.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_content'].'</span><br/>'.$L['Tab_upd'];
$oVIP->exiturl = 'qtr_adm_tabs.php?s='.$s;
$oVIP->exitname = $L['Sectiontabs'];

// read tab information

$strVisible = '1';
$strFrame = '';
$oDB->Query('SELECT tabselect,tabframe FROM '.TABTAB.' WHERE section="'.$s.'" AND tabid="'.$id.'"');
$row=$oDB->Getrow();
if ( $row['tabselect']=='M' ) $strVisible='0';
$strFrame = $row['tabframe'];

// Tabs dictionary

CheckDico('tab tabdesc');

// --------
// SUBMITTED
// --------

if ( isset($_POST['ok']) )
{
  // check id

  if ( get_magic_quotes_gpc() ) { $oldid=stripslashes($oldid); $id=stripslashes($id); }
  $id = QTconv($id,'K');

  // check visibility

  if ( isset($_POST['visible']) ) $strVisible = substr($_POST['visible'],0,1);
  if ( $id=='ticket' || $id=='documents' || $id=='messages' ) $strVisible='1';

  // change id

  if ( empty($error) && $oldid!=$id )
  {
    // check unic id
    $oDB->Query('SELECT count(*) as countid FROM '.TABTAB.' WHERE tabid="'.$id.'"');
    $row = $oDB->Getrow();
    // change id
    if ( $row['countid']!=0 )
    {
    $error = "Tab id [$id] ".strtolower(error(3));
    }
    else
    {
    cTab::Rename($oldid,$id);
    }
  }

  //  save visibility and frame

  if ( empty($error) )
  {
    $oDB->Query('UPDATE '.TABTAB.' SET tabselect="'.$strVisible.'" WHERE section="'.$s.'" AND tabid="'.$id.'"');
    if ( isset($_POST['frame']) )
    {
      if ( get_magic_quotes_gpc() ) $_POST['frame'] = stripslashes($_POST['frame']);
      $oDB->Query('UPDATE '.TABTAB.' SET tabframe="'.QTconv($_POST['frame'],'2').'" WHERE section'.($_POST['copy']=='0' ? '='.$s : '>=0').' AND tabid="'.$id.'"');
    }
  }

  //  save translation

  if ( empty($error) )
  {
    cVIP::LangDel(array('tab','tabdesc'),$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('tab',substr($strKey,1),$id,$strTranslation);
        }
      }
      if ( substr($strKey,0,1)=='D' )
      {
        if ( !empty($strTranslation) )
        {
        if ( get_magic_quotes_gpc() ) $strTranslation = stripslashes($strTranslation);
        cVIP::LangAdd('tabdesc',substr($strKey,1),$id,$strTranslation);
        }
      }
    }

    // register tabs lang and description

    $_SESSION['L']['tab'] = cVIP::LangGet('tab',GetIso());
    $_SESSION['L']['tabdesc'] = cVIP::LangGet('tabdesc',GetIso());

    // exit

    $oVIP->EndMessage(NULL,$L['S_update'],'admin',2);
  }
}

// --------
// HTML START
// --------

// some tabs are alway visible
// tab documents is controled by the security settings
if ( !empty($oldid) ) $id = $oldid; // in case of error, restart with oldid
if ( in_array($id,array('ticket','messages','documents','gmap')) ) { $strVisible='1';  $strVisibleTip = ' <abbr class="helptip" title="'.$L['E_tabnothidden'].'">'.$L['i'].'</abbr>'; }
if ( $id=='documents' && $_SESSION[QT]['upload']=='0' ) { $strVisible='0'; $strVisibleTip = ' <abbr class="helptip" title="'.$L['E_docnotallowed'].'">'.$L['i'].'</abbr>'; }

// DISPLAY

include('qtr_adm_p_header.php');

echo '<h2>',$L['Prop_tab'],' &middot; ',ObjTrans('tab',$id),'</h2>';

echo '<form method="post" action="',$oVIP->selfurl,'">
<table cellspacing="0" class="data_o">
<colgroup span="3"><col width="150"></col><col width="300"><col></col></colgroup>
<td class="th_o th_o_all" colspan="3">',$L['Definition'],'</td>
<tr class="data_o">
<td class="th_o th_o_first">Id</td>
<td class="td_o"><input type="text" id="id" name="id" size="24" maxlength="24" value="',$id,'"',(in_array($id,array('ticket','documents','messages')) ? QDIS : ''),' style="background-color:#FFFF99"/></td>
<td class="td_o">&nbsp;</td>
</tr>
<tr class="data_o">
<td class="th_o th_o_first"><label for="visible">',$L['Visible'],'</label></td>
<td class="td_o">
<select id="visible" name="visible"',($id=='ticket' || $id=='documents' || $id=='messages'  ? QDIS : ''),'>
',QTasTag(array($L['N'],$L['Y']),$strVisible),'
</select>',(isset($strVisibleTip) ? $strVisibleTip : ''),'
</td>
<td class="td_o">&nbsp;</td>
</tr>
';
if ( !in_array($id,array('ticket','documents','messages')) )
{
$arr = cTab::GetFields($id);
$str = $L['None']; if ( count($arr)>0 ) $str = implode(', ',$arr); if ( strlen($str)>255 ) $str = substr($str,0,255).'...';
echo '<tr class="data_o">
<td class="th_o th_o_first">',$L['Fields'],'</td>
<td class="td_o small" colspan="2">
',$str,' &middot; <a href="qtr_adm_fields.php?tt=',$id,'">',$L['Edit'],'</a></td>
</tr>
';
}
echo '<td class="th_o th_o_all" colspan="3">',$L['Translations'],'</td>
<tr class="data_o">
<td class="th_o th_o_first">',$L['Tab_name_and_desc'],'</td>
<td class="td_o" colspan="2">
<p class="help">',sprintf($L['E_no_translation'],ucfirst(str_replace('_',' ',$id))),'</p>
<table cellspacing="0" class="hidden">';

$arrTrans = cVIP::LangGet('tab','*',$id);
$arrDescTrans = cVIP::LangGet('tabdesc','*',$id);
foreach($arrLang as $strIso=>$arr)
{
  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['Field'],' (',$strIso,')" type="text" id="T',$strIso,'" name="T',$strIso,'" size="24" maxlength="64" value="',(isset($arrTrans[$strIso]) ? $arrTrans[$strIso] : ''),'"/>
  <input class="small" title="',$L['Description'],' (',$strIso,')" type="text" id="D',$strIso,'" name="D',$strIso,'" size="50" maxlength="255" value="',(isset($arrDescTrans[$strIso]) ? $arrDescTrans[$strIso] : ''),'"/>
  </td>
  </tr>
  ';
}

echo '
</table>
</td>
</tr>
';

if ( !in_array($id,array('ticket','messages','documents')) )
{
echo '<td class="th_o th_o_all" colspan="3">Help frame</td>
<tr class="data_o">
<td class="th_o th_o_first">Frame code</td>
<td class="td_o" colspan="2">
<p class="help">You can enter html code. To make an iframe just type <span class="bold">@</span> and the url.<br>Example: <span class="bold">@http://www.google.com</span></p>
<p class="help">Note that some websites do not accept to be viewed in an iframe. In this case you can tell the application to open this url only in a separate window by typing <span class="bold">@@</span> and the url.</p>
<textarea id="frame" name="frame" cols="75" rows="15">',$strFrame,'</textarea>
</td>
</tr>
<tr class="data_o">
<td class="th_o th_o_first">',$L['Apply'],'</td>
<td class="td_o" colspan="2">
<input type="radio" id="copy0" name="copy" value="0" checked="checked"/> <label for="copy0">',sprintf($L['Apply_section_only'],$oVIP->sections[$s]),'</label><br/>
<input type="radio" id="copy1" name="copy" value="1"/> <label for="copy1">',$L['Apply_all_sections'],'</label>
</td>
</tr>
';
}
echo'<tr class="data_o">
<td class="th_o th_o_all" colspan="3" style="padding:6px; text-align:center">
<input type="hidden" name="oldid" value="',$id,'"/>
<input type="hidden" name="s" value="',$s,'"/>
<input type="submit" name="ok" value="',$L['Save'],'"/></td>
</tr>
</table>

<p><a href="',$oVIP->exiturl,'">&laquo; ',$oVIP->exitname,'</a></p>
';

// --------
// HTML END
// --------

include('qtr_adm_p_footer.php');

?>
Return current item: QT-registrations