Completed
Branch master (78c2af)
by Pierre-Henry
52:17 queued 17:37
created

forum/forms/processing/ReplyMsgFormProcess.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 17 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author         Pierre-Henry Soria <[email protected]>
4
 * @copyright      (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
5
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package        PH7 / App / System / Module / Forum / Form / Processing
7
 */
8
namespace PH7;
9
defined('PH7') or exit('Restricted access');
10
11
use
12
PH7\Framework\Mvc\Model\DbConfig,
13
PH7\Framework\Mvc\Request\Http,
14
PH7\Framework\Mvc\Router\Uri,
15
PH7\Framework\Url\Header;
16
17
class ReplyMsgFormProcess extends Form
18
{
19
20
    public function __construct()
21
    {
22
        parent::__construct();
23
24
        $oForumModel = new ForumModel;
25
26
        $sMessage = $this->httpRequest->post('message', Http::ONLY_XSS_CLEAN);
27
        $sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s');
28
        $iTimeDelay = (int) DbConfig::getSetting('timeDelaySendForumMsg');
29
        $iProfileId = (int) $this->session->get('member_id');
30
        $iForumId = $this->httpRequest->get('forum_id', 'int');
31
        $iTopicId = $this->httpRequest->get('topic_id', 'int');
32
33
        if (!$oForumModel->checkWaitReply($iTopicId, $iProfileId, $iTimeDelay, $sCurrentTime))
34
        {
35
            \PFBC\Form::setError('form_reply', Form::waitWriteMsg($iTimeDelay));
36
        }
37
        elseif ($oForumModel->isDuplicateMessage($iProfileId, $sMessage))
38
        {
39
            \PFBC\Form::setError('form_reply', Form::duplicateContentMsg());
40
        }
41
        else
42
        {
43
            $oForumModel->addMessage($iProfileId, $iTopicId, $sMessage, $sCurrentTime);
44
            Header::redirect(Uri::get('forum', 'forum', 'post', $this->httpRequest->get('forum_name').','.$iForumId.','.$this->httpRequest->get('topic_name').','.$iTopicId), t('Your message has been updated successfully!'));
45
        }
46
        unset($oForumModel);
47
    }
48
49
}
50