';
if ($Action == 'add2') $Output .= $this->AddFinish('ForumThread');
if ($User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread();
$Output .= $this->ShowListThread();
}
return $Output;
}
function Edit()
{
$User = ModuleUser::Cast($this->System->GetModule('User'))->User;
$Output = '';
$this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$User->Id.' AND `ID` = '.$_GET['Edit']);
$Output .= ShowMessage(T('Text edited.'));
return $Output;
}
function ShowEditForm()
{
$User = ModuleUser::Cast($this->System->GetModule('User'))->User;
$Output = '';
if ($User->Licence(LICENCE_USER))
{
$DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `User` = '.$User->Id.' AND `ID` = '.$_GET['Edit']);
if ( $DbResult->num_rows > 0) {
$DbRow = $DbResult->fetch_assoc();
$Output .= '';
} else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL);
} else $Output .= ShowMessage(T('You can edit only your own message.'), MESSAGE_CRITICAL);
return $Output;
}
function ShowSearchForum()
{
$Output = '';
$Output .= '
';
$where = '`ForumText`.`Text` LIKE "%'.($_GET['search'] ).'%" OR '.
' `ForumThread`.`Text` LIKE "%'.($_GET['search'] ).'%" OR `ForumThread`.`UserName` LIKE "%'.($_GET['search'] ).'%" OR '.
' `ForumText`.`UserName` LIKE "%'.($_GET['search'] ).'%"';
$join = ' JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread`';
$DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ForumText` '.$join.' WHERE '.$where);
$DbRow = $DbResult->fetch_row();
$PageList = GetPageList($DbRow[0]);
$Output .= $PageList['Output'];
$DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,'.
'`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` '.$join.' WHERE '.$where.' ORDER BY `ForumText`.`Date` DESC '.$PageList['SQLLimit']);
while ($Line = $DbResult->fetch_assoc())
$Output .= '
'.$PageList['Output'];
return $Output;
}
function ShowListThread()
{
$Output = '';
$DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ForumThread` WHERE 1');
$DbRow = $DbResult->fetch_row();
$PageList = GetPageList($DbRow[0]);
$Output .= $PageList['Output'];
$Output .= '
';
$DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE 1 ORDER BY `ID` DESC '.$PageList['SQLLimit']);
while ($Line = $DbResult->fetch_assoc())
{
$Output .= '