Skip to content
Products
Apps
Docs
Log in
Log in
Sign up
Sign up
Products
Apps
Docs
Docs
Docs
CODE
On this page

Code Convention

How UNA 15 code is written: Bx class names and where each prefix loads from, the BX_DOL file header, typed variable prefixes, next-line braces with 4-space indent, bound SQL, one-time CSRF tokens, singletons, language keys, database migrations, and the NEO TypeScript, ESLint and Prettier rules.
Android
iOS
Web
Core
~15.0
Copy Page
Note
<?php defined('BX_DOL') or die('hack attempt');
/**
 * Copyright (c) UNA, Inc - https://una.io
 * MIT License - https://opensource.org/licenses/MIT
 *
 * @defgroup    Posts Posts
 * @ingroup     UnaModules
 *
 * @{
 */
public function serviceCheckAllowedCommentsPost($iContentId, $sObjectComments)
{
    $CNF = &$this->_oConfig->CNF;
    $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
    if ($aContentInfo && $aContentInfo[$CNF['FIELD_ALLOW_COMMENTS']] == 0)
        return false;

    return parent::serviceCheckAllowedCommentsPost($iContentId, $sObjectComments);
}
class BxDolDb extends BxDolFactory implements iBxDolSingleton
{
    protected function __construct($aDbConf = false)
    {
        if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
            trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
$aBindings = array(
    'author' => $iAuthorId
);
$CNF = &$this->_oConfig->CNF;

return $this->getRow("SELECT COUNT(id) AS count, SUM(views) AS views, SUM(votes) AS votes, SUM(rvotes) AS rvotes FROM `" . $CNF['TABLE_ENTRIES'] . "` WHERE `author`=:author", $aBindings);
$sQuery = $this->prepare("SELECT `name` FROM `sys_options` WHERE `name` = ? LIMIT 1", $sKey);
return $this->getOne($sQuery) == $sKey;
$this->aInputs['csrf_token'] = array(
    'type' => 'hidden',
    'name' => 'csrf_token',
    'value' => $mixedCsrfToken,
    'db' => array ('pass' => 'Xss'),
    'visible_for_levels' => PHP_INT_MAX,
);
class BxDolDb extends BxDolFactory implements iBxDolSingleton
{
    public static function getInstance()
    {
        $null = null;
        return self::getInstanceWithConf(false, $null);
    }
}
14d
On this page
I want toWhere the rules are writtenClass names and loadingWhere each prefix loads fromFile headerClasses and methodsVariable prefixesBraces and indentationUNA coding restrictionsSQLCSRFSingletonsLanguage keysDatabase migrationsNEO codePull requestsTipsCommon mistakesFor developersGitHub SourcesRelated
Introduction
Getting Started
Configuration
Apps
CODE
Developer Architecture
Code Convention
Code Quality
Directory Structure
How to Add an App
Storage System
Common Mistakes
Payment Provider Integration
Module API
iOS Client
NEO Developer
Android Client
Web Client
Contributing
REST API
Analytics Developer
Auth
Connect
public function serviceCheckAllowedCommentsPost($iContentId, $sObjectComments)
{
    $CNF = &$this->_oConfig->CNF;
    $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
    if ($aContentInfo && $aContentInfo[$CNF['FIELD_ALLOW_COMMENTS']] == 0)
        return false;

    return parent::serviceCheckAllowedCommentsPost($iContentId, $sObjectComments);
}
class BxDolDb extends BxDolFactory implements iBxDolSingleton
{
    protected function __construct($aDbConf = false)
    {
        if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
            trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
$aBindings = array(
    'author' => $iAuthorId
);
$CNF = &$this->_oConfig->CNF;

return $this->getRow("SELECT COUNT(id) AS count, SUM(views) AS views, SUM(votes) AS votes, SUM(rvotes) AS rvotes FROM `" . $CNF['TABLE_ENTRIES'] . "` WHERE `author`=:author", $aBindings);
$this->aInputs['csrf_token'] = array(
    'type' => 'hidden',
    'name' => 'csrf_token',
    'value' => $mixedCsrfToken,
    'db' => array ('pass' => 'Xss'),
    'visible_for_levels' => PHP_INT_MAX,
);