Example #1
0
        if (isset($_POST['start']) && isset($_POST['num']) && is_numeric($_POST['start']) && is_numeric($_POST['num'])) {
            $_list = $comments->getLastComments($hpid, $_POST['num'], $_POST['start'], $prj);
        } else {
            if (isset($_POST['hcid']) && is_numeric($_POST['hcid'])) {
                $_list = $comments->getCommentsAfterHcid($hpid, $_POST['hcid'], $prj);
            } else {
                $_list = $comments->getAll($hpid, $prj);
            }
        }
        $doShowForm = !isset($_POST['hcid']) && (!isset($_POST['start']) || $_POST['start'] == 0) && !isset($_POST['forceNoForm']);
        if (empty($_list) && !$doShowForm) {
            die;
        }
        $vals = [];
        $vals['currentuserprofile_n'] = \NERDZ\Core\Utils::userLink($_SESSION['id']);
        $vals['currentusergravatar_n'] = $user->getGravatar($_SESSION['id']);
        $vals['currentusername_n'] = User::getUsername();
        $vals['onerrorimgurl_n'] = System::getResourceDomain() . '/static/images/red_x.png';
        $vals['list_a'] = $_list;
        $vals['showform_b'] = $doShowForm;
        $vals['hpid_n'] = $hpid;
        $vals['commentcount_n'] = (new Messages())->countComments($hpid, $prj);
        $vals['needmorebtn_b'] = $doShowForm && $vals['commentcount_n'] > 10;
        $vals['needeverycommentbtn_b'] = $doShowForm && $vals['commentcount_n'] > 20;
        $user->getTPL()->assign($vals);
        $user->getTPL()->draw(($prj ? 'project' : 'profile') . '/comments');
        break;
    default:
        die($user->lang('ERROR'));
        break;
}