} } else { if (!$objUser || $objUser->get('is_admin') != 1) { throw new Exception("exception_accessdenied"); } $objNews = new clsDB('news'); $objNews->getFromRequest(array('id', 'title', 'text')); if ($strSubAction == 'edit') { $objNews->load(); echo "<form action='index.php' method='post'>"; echo "<input type='hidden' name='subaction' value='save'>"; echo $objNews->getHiddenField('id'); echo "Title:<br>"; echo $objNews->getTextField('title', new clsParameters('size', 40)) . "<br><br>"; echo "Post:<br>"; echo $objNews->getTextArea('text', 4, 45) . "<br><br>"; echo $objNews->getSubmit('Post'); } else { if ($strSubAction == 'save') { if ($objNews->isNew()) { $objNews->set('user_id', $objUser->get('id')); $objNews->set('date', date('Y-m-d H:i:s')); } $objNews->save(); header("Location: index.php"); } else { if ($strSubAction == 'delete') { $objNews->delete(); $objNews->save(); header("Location: index.php"); }