<?php

/*
////////////////////////////////////////////////////////////////////////////////
// JohnCMS                Mobile Content Management System                    //
// Project site:          http://johncms.com                                  //
// Support site:          http://gazenwagen.com                               //
////////////////////////////////////////////////////////////////////////////////
// Lead Developer:        Oleg Kasyanov   (AlkatraZ)  alkatraz@gazenwagen.com //
// Development Team:      Eugene Ryabinin (john77)    john77@gazenwagen.com   //
//                        Dmitry Liseenko (FlySelf)   flyself@johncms.com     //
////////////////////////////////////////////////////////////////////////////////
*/

defined('_IN_JOHNCMS') or die('Error: restricted access');

$textl = $lng_profile['events_set'];
require('../incfiles/head.php');
echo '<div class="phdr"><b>' . $lng_profile['events_set'] . '</b></div>';
$filter = Functions::eventsFilterDef();
$key = 'events';

if(isset($_POST['submit'])) {
	$filter['photo'] = isset($_POST['photo']) && $_POST['photo'] == 1 ? 1 : 0;
	$filter['friends'] = isset($_POST['friends']) && $_POST['friends'] == 1 ? 1 : 0;
	$filter['guestbook'] = isset($_POST['guestbook']) && $_POST['guestbook'] == 1 ? 1 : 0;
	$filter['karma'] = isset($_POST['karma']) && $_POST['karma'] == 1 ? 1 : 0;
	$filter['avatar'] = isset($_POST['avatar']) && $_POST['avatar'] == 1 ? 1 : 0;
	$filter['forum'] = isset($_POST['forum']) && $_POST['forum'] == 1 ? 1 : 0;
	$filter['download'] = isset($_POST['download']) && $_POST['download'] == 1 ? 1 : 0;
	$filter['library'] = isset($_POST['library']) && $_POST['library'] == 1 ? 1 : 0;
	$val = mysql_real_escape_string(serialize($filter));
	mysql_query("INSERT INTO `cms_events_data` SET
		`user_id` = '" . $user_id . "',
		`key` = '$key',
		`value` = '$val'
		ON DUPLICATE KEY UPDATE `value` = '$val'
	");
	echo '<div class="rmenu">Настройки изменены</div>';
}

echo '<div class="list1">Настройка меню "Фильтр событий"</div>
<div class="gmenu">
<form action="' . $home . '/users/profile.php?act=events_set" method="post">
<div>
<input name="photo" type="checkbox" value="1"'.($filter['photo'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['photo_album'] . '<br />
<input name="friends" type="checkbox" value="1"'.($filter['friends'] == 1 ? ' checked="checked"' : '').'/>&nbsp;Дружба<br />
<input name="guestbook" type="checkbox" value="1"'.($filter['guestbook'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['guestbook'] . '<br />
<input name="karma" type="checkbox" value="1"'.($filter['karma'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['karma'] . '<br />
<input name="avatar" type="checkbox" value="1"'.($filter['avatar'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['avatar'] . '<br />
<input name="forum" type="checkbox" value="1"'.($filter['forum'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['forum'] . '<br />
<input name="download" type="checkbox" value="1"'.($filter['download'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['downloads'] . '<br />
<input name="library" type="checkbox" value="1"'.($filter['library'] == 1 ? ' checked="checked"' : '').'/>&nbsp;' . $lng['library'] . '<br />
<input type="submit" name="submit" value="' . $lng['save'] . '"/></div>
</form></div>
<div class="phdr">&raquo; <a class="font13" href="' . $home . '/users/profile.php?act=events">' . $lng['back'] . '</a></div>';
