<?
$title = $l ="Редактировать - ".group :: getName($group)."";
$lBack = profile :: getLink($ank);
require (CORE."head.php");
if (isset($_POST['cfms']))
{
if (!isset($_POST['name']) || $_POST['name'] == NULL)
{
$errMsg = "Введите название для группы!";
}
else if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_subject`") > 0 && (!isset($_POST['subject']) || !is_numeric($_POST['subject']) || $_POST['subject'] == NULL || $_POST['subject']==0 || DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_subject` WHERE `id` = '".intval($_POST['subject'])."'") == 0))
{
$errMsg = "Выберите тематику!";
}else if (!isset($_POST['who_komm']) || !is_numeric($_POST['who_komm']) || $_POST['who_komm'] == NULL || $_POST['who_komm'] < 0 || $_POST['who_komm'] > 2)
{
$errMsg = "Выберите кто может писать на стене!";
}
if (!isset($errMsg))
{
$group['name'] = system :: check($_POST['name']);
if (isset($_POST['opis']) && $_POST['opis'] != NULL)
{
$group['opis'] = system :: check($_POST['opis']);
}
if (isset($_POST['deviz']) && $_POST['deviz'] != NULL)
{
$group['deviz'] = system :: check($_POST['deviz']);
}
$group['who_komm'] = intval($_POST['who_komm']);
if (isset($_POST['subject']))
{
$group['subject'] = intval($_POST['subject']);
}
DB :: $pdo -> query("UPDATE `groups` SET `name` = '".$group['name']."', `opis` = '".$group['opis']."', `deviz` = '".$group['deviz']."', `subject` = '".$group['subject']."', `who_komm` = '".$group['who_komm']."' WHERE `id` = '".$group['id']."' LIMIT 1");
system :: redirect("Данные успешно изменены.", "/groups/?group=".$group['id']."");
}
}
echo "<div class=\"app-block\">";
system :: show((isset($errMsg) ? $errMsg : NULL));
?>
<div class="list list-flex">
<div class="post-l">
<?=group :: Avatar($group,0)?>
</div>
<div class="post-c">
<a class="_gray _bold size--big" href="/groups/?group=<?=$group['id']?>">
<?=group :: getName($group)?>
</a>
</div>
</div>
<div class="list">
<form method="post" action="">
<div>
<div class="_gray _bold">Название:</div>
<div>
<input class="main-input _dbl _w-100" type="text" maxlength="50" value="<?=group :: getName($group)?>" name="name" />
</div>
</div>
<div>
<div class="_gray _bold">Описание:</div>
<div>
<textarea class="main-input _dbl _w-100" name="opis"><?=system :: check($group['opis'])?></textarea>
</div>
</div>
<div>
<div class="_gray _bold">Девиз:</div>
<div>
<textarea class="main-input _dbl _w-100" name="deviz"><?=system :: check($group['deviz'])?></textarea>
</div>
</div>
<div>
<?
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_subject`") > 0)
{
?>
<div class="_gray _bold">Тематика:</div>
<div>
<select class="main-input _dbl _w-100" name="subject">
<?
$query = DB :: $pdo -> query("SELECT * FROM `groups_subject` ORDER BY `name` ASC");
while($r = $query -> fetch())
{
?>
<option value="<?echo $r['id'];?>"<?echo "".($group['subject']==$r['id']?" selected='selected'":null)."";?>><?echo stripcslashes(htmlspecialchars($r['name']));?></option>
<?
}
?>
</select>
</div>
<?
}
?>
<div class="_gray _bold">Кто может писать на стене:</div>
<div>
<select class="main-input _dbl _w-100" name="who_komm">
<option value="0"<?echo "".($group['who_komm']==0?" selected='selected'":null)."";?>>Все</option>
<option value="1"<?echo "".($group['who_komm']==1?" selected='selected'":null)."";?>>Только участники</option>
<option value="2"<?echo "".($group['who_komm']==2?" selected='selected'":null)."";?>>Только администраторы</option>
</select>
</div>
</div>
<div>
<input class="main-btn" type="submit" name="cfms" value="Сохранить" />
</div>
</form>
</div>
<?php
echo system :: back("/groups/?group=".$group['id']."", "Назад");
echo "</div>";
require (CORE."foot.php");