Skip to content
Products
Docs
Pricing
Blog
Log In
Sign Up
Docs
Docs
CODE
On this page

Code Convention

How UNA 15 code is written - PHP class names, file headers, SQL binds, CSRF, singletons and language keys, plus NEO TypeScript, lint 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);
    }
}
2d
On this page
Where the rules are writtenClass names and loadingFile headerClasses and methodsVariable prefixesBraces and indentationUNA coding restrictionsSQLCSRFSingletonsLanguage keysNEO codePull requestsTipsRelated
Auto
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,
);