<commit_before><?php defined('BX_DOL') or die('hack attempt');
/**
 * Copyright (c) UNA, Inc - https://una.io
 * MIT License - https://opensource.org/licenses/MIT
 *
 * @defdroup    Channels Channels
 * @indroup     UnaModules
 *
 * @{
 */

/**
 * Channels profiles module.
 */

class BxCnlModule extends BxBaseModGroupsModule
{
    function __construct(&$aModule)
    {
        parent::__construct($aModule);
    }
   
    public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
    {
        return parent::_checkAllowedSubscribeAdd ($aDataEntry, $isPerformAction);
    }
    
    function processHashtag($sHashtag, $sModuleName, $iContentId, $iAuthorId)
    {
        $mixedCnlId = $this->_oDb->getChannelIdByName($sHashtag);
        if (empty($mixedCnlId)){
            $CNF = &$this->_oConfig->CNF;
            $oAccountQuery = BxDolAccountQuery::getInstance();
            $aOperators = $oAccountQuery->getOperators();
            if(count($aOperators) > 0){
                $oProfile = BxDolProfile::getInstanceByAccount($aOperators[0]);
                $aContent = $this->serviceEntityAdd($oProfile->id(), array($CNF['FIELD_NAME'] => $sHashtag));
                if (isset($aContent['content']) && isset($aContent['content']['id']))
                    $mixedCnlId = $aContent['content']['id'];
            }
        }
        
        if (!empty($mixedCnlId)){
            if (0 == (int) $this->_oDb->checkContentInChannel($iContentId, $mixedCnlId, $sModuleName, $iAuthorId)){
                $iId = $this->_oDb->addContentToChannel($iContentId, $mixedCnlId, $sModuleName, $iAuthorId);
                $oModule = BxDolModule::getInstance($sModuleName);
                if ($oModule){
                    $aInfo = $oModule->_getContent($iContentId);
                    if (is_array($aInfo)){
                        $oDolProfileQuery = BxDolProfileQuery::getInstance();
                        $iProfileInfo = $oDolProfileQuery->getProfileByContentAndType($mixedCnlId, $this->_aModule['name']);
                        if(is_array($iProfileInfo)){
                            $sPrivacyKey = 'allow_view_to';
                            if ($sModuleName == 'bx_timeline'){
                                $sPrivacyKey ='object_privacy_view';
                            }
                            bx_alert($this->_aModule['name'], 'hashtag_added', $iId, $iProfileInfo['id'], array('object_author_id' => $iAuthorId, 'privacy_view' => $aInfo[1][$sPrivacyKey]));
                            bx_alert($this->_aModule['name'], 'hashtag_added_notif', $mixedCnlId, $iProfileInfo['id'], array('object_author_id' => $iAuthorId, 'privacy_view' => $aInfo[1][$sPrivacyKey], 'subobject_id' => $iId));
                        }
                    }
                }
            }
        }
    }
    
    function removeContentFromChannel($iContentId, $sModuleName)
    {
        $oDolProfileQuery = BxDolProfileQuery::getInstance();
        
        $aData = $this->_oDb->getDataByContent($iContentId, $sModuleName);
        foreach ($aData as $aRow) {
            $iProfileInfo = $oDolProfileQuery->getProfileByContentAndType($aRow['cnl_id'], $this->_aModule['name']);
            if(is_array($iProfileInfo)){
                bx_alert($this->_aModule['name'], 'hashtag_deleted', $aRow['id'], $iProfileInfo['id']);
                bx_alert($this->_aModule['name'], 'hashtag_deleted_notif', $aRow['cnl_id'], $iProfileInfo['id'], array('subobject_id' => $aRow['id']));
            }<commit_msg>Ticket #1547 - Point №1<commit_after><?php defined('BX_DOL') or die('hack attempt');
/**
 * Copyright (c) UNA, Inc - https://una.io
 * MIT License - https://opensource.org/licenses/MIT
 *
 * @defdroup    Channels Channels
 * @indroup     UnaModules
 *
 * @{
 */

/**
 * Channels profiles module.
 */

class BxCnlModule extends BxBaseModGroupsModule
{
    function __construct(&$aModule)
    {
        parent::__construct($aModule);
    }
   
    public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
    {
        return parent::_checkAllowedSubscribeAdd ($aDataEntry, $isPerformAction);
    }
    
    function processHashtag($sHashtag, $sModuleName, $iContentId, $iAuthorId)
    {
        $mixedCnlId = $this->_oDb->getChannelIdByName($sHashtag);
        if (empty($mixedCnlId)){
            $CNF = &$this->_oConfig->CNF;
            $oAccountQuery = BxDolAccountQuery::getInstance();
            $aOperators = $oAccountQuery->getOperators();
            if(count($aOperators) > 0){
                $oProfile = BxDolProfile::getInstanceByAccount($aOperators[0]);
                $aContent = $this->serviceEntityAdd($oProfile->id(), array($CNF['FIELD_NAME'] => $sHashtag));
                if (isset($aContent['content']) && isset($aContent['content']['id']))
                    $mixedCnlId = $aContent['content']['id'];
            }
        }

        if (!empty($mixedCnlId)){
            if (0 == (int) $this->_oDb->checkContentInChannel($iContentId, $mixedCnlId, $sModuleName, $iAuthorId)){
                $iId = $this->_oDb->addContentToChannel($iContentId, $mixedCnlId, $sModuleName, $iAuthorId);
                $oModule = BxDolModule::getInstance($sModuleName);
                if ($oModule){
                    $aInfo = $oModule->_getContent($iContentId);
                    if (is_array($aInfo)){
                        $oDolProfileQuery = BxDolProfileQuery::getInstance();
                        $iProfileInfo = $oDolProfileQuery->getProfileByContentAndType($mixedCnlId, $this->_aModule['name']);
                        if(is_array($iProfileInfo)){
                            bx_alert($this->_aModule['name'], 'hashtag_added', $iId, $iProfileInfo['id'], array('object_author_id' => $iAuthorId, 'privacy_view' => -$iProfileInfo['id']));
                            bx_alert($this->_aModule['name'], 'hashtag_added_notif', $mixedCnlId, $iProfileInfo['id'], array('object_author_id' => $iAuthorId, 'privacy_view' => -$iProfileInfo['id'], 'subobject_id' => $iId));
                        }
                    }
                }
            }
        }
    }
    
    function removeContentFromChannel($iContentId, $sModuleName)
    {
        $oDolProfileQuery = BxDolProfileQuery::getInstance();
        
        $aData = $this->_oDb->getDataByContent($iContentId, $sModuleName);
        foreach ($aData as $aRow) {
            $iProfileInfo = $oDolProfileQuery->getProfileByContentAndType($aRow['cnl_id'], $this->_aModule['name']);
            if(is_array($iProfileInfo)){
                bx_alert($this->_aModule['name'], 'hashtag_deleted', $aRow['id'], $iProfileInfo['id']);
                bx_alert($this->_aModule['name'], 'hashtag_deleted_notif', $aRow['cnl_id'], $iProfileInfo['id'], array('subobject_id' => $aRow['id']));
            }
{'fraction_non_alphanumeric': 0.1574386840945807, 'fraction_numerical': 0.001909237773535027, 'mean_word_length': 2.5248447204968945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4256209', 'n_tokens_mistral': 2126, 'n_tokens_neox': 2077, 'n_words': 286}