<?php
/**
 *
 * @category        modules
 * @package         news
 * @author          WebsiteBaker Project
 * @copyright       WebsiteBaker Org. e.V.
 * @link            http://websitebaker.org/
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.3
 * @requirements    PHP 5.3.6 and higher
 * @version         $Id: modify_group.php 2 2017-07-02 15:14:29Z Manuela $
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/modules/news/modify_group.php $
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
 *
 */

if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }

// suppress to print the header, so no new FTAN will be set
//$admin_header = false;
// Tells script to update when this page was last updated
$update_when_modified = false;
// show the info banner
$print_info_banner = true;
// Include WB admin wrapper script
require(WB_PATH.'/modules/admin.php');
/* */
$group_id = intval($admin->checkIDKEY('group_id', false, 'GET'));
if (!$group_id) {
   $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
}

// Get header and footer
$sql  = 'SELECT * FROM '.TABLE_PREFIX.'mod_news_groups '
      . 'WHERE group_id = '.$group_id;
$query_content = $database->query( $sql );

$fetch_content = $query_content->fetchRow( MYSQLI_ASSOC );

?>

<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['GROUP']; ?></h2>

<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_group.php" method="post" enctype="multipart/form-data" style="margin: 0;">
<?php echo $admin->getFTAN(); ?>
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
<input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
<tr>
   <td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
   <td>
      <input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 98%;" maxlength="255" />
   </td>
</tr>
<tr>
   <td><?php echo $TEXT['IMAGE']; ?>:</td>
   <?php if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) { ?>
   <td>
      <a href="<?php echo WB_URL.MEDIA_DIRECTORY; ?>/.news/image<?php echo $group_id; ?>.jpg" target="_blank">View</a>
      &nbsp;
      <input type="checkbox" name="delete_image" id="delete_image" value="true" />
      <label for="delete_image">Delete</label>
   </td>
   <?php } else { ?>
   <td>
      <input type="file" name="image" />
   </td>
   <?php } ?>
</tr>
<tr>
   <td><?php echo $TEXT['ACTIVE']; ?>:</td>
   <td>
      <input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked="checked"'; } ?> />
      <a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
      <?php echo $TEXT['YES']; ?>
      </a>
      -
      <input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked="checked"'; } ?> />
      <a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
      <?php echo $TEXT['NO']; ?>
      </a>
   </td>
</tr>
</table>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
   <td align="left">
      <input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
   </td>
   <td align="right">
      <input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
   </td>
</tr>
</table>
</form>

<?php

// Print admin footer
$admin->print_footer();
