Просмотр исходного кода

Merge branch 'master' of https://github.com/unaio/una

AntonLV 8 лет назад
Родитель
Сommit
1f8388add2

+ 2 - 0
modules/base/general/classes/BxBaseModGeneralMenuView.php

@@ -35,6 +35,8 @@ class BxBaseModGeneralMenuView extends BxTemplMenu
      */
     protected function _isVisible ($a)
     {
+        if(!parent::_isVisible($a))
+            return false;
         return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
     }
 

+ 2 - 0
modules/base/general/classes/BxBaseModGeneralMenuViewActions.php

@@ -70,6 +70,8 @@ class BxBaseModGeneralMenuViewActions extends BxTemplMenuCustom
      */
     protected function _isVisible ($a)
     {
+        if(!parent::_isVisible($a))
+            return false;
         return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
     }
 

+ 55 - 0
modules/boonex/anon_follow/classes/BxAnonFollowAlertsResponse.php

@@ -0,0 +1,55 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowAlertsResponse extends BxDolAlertsResponse
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+    
+    public function response($oAlert)
+    {
+        if ($oAlert->sUnit == 'sys_profiles_subscriptions'){
+            if ($oAlert->sAction == 'connection_added'){
+                if (isset($oAlert->aExtras['initiator']) && isset($oAlert->aExtras['content']) && bx_get('anon') == '1'){
+                    $oModule = BxDolModule::getInstance('bx_anon_follow');
+                    $oModule->_oDb->addFollower($oAlert->aExtras['initiator'], $oAlert->aExtras['content']);
+                }
+            }
+            
+            if ($oAlert->sAction == 'connection_removed'){
+                if (isset($oAlert->aExtras['initiator']) && isset($oAlert->aExtras['content'])){
+                    $oModule = BxDolModule::getInstance('bx_anon_follow');
+                    $oModule->_oDb->removeFollower($oAlert->aExtras['initiator'], $oAlert->aExtras['content']);
+                }
+            }
+        }
+        
+        if ($oAlert->sAction == 'menu_custom_item'){
+            if($oAlert->aExtras['item']['module'] == 'bx_anon_follow' && $oAlert->aExtras['item']['name'] == 'anon-follow'){
+                $oModule = BxDolModule::getInstance('bx_anon_follow');
+                $oAlert->aExtras['res'] = 'xcvxc';
+                $bIsSubscribed = $oModule->checkIsSubscribed($oAlert->aExtras['content_data']['profile_id']);
+                if ($bIsSubscribed){
+                    $oAlert->aExtras['res'] = '';
+                    return;
+                }
+                $oAlert->aExtras['res'] = $oModule->_oTemplate->parseHtmlByName('follow_button.html', array(
+                    'profile_id' => $oAlert->aExtras['content_data']['profile_id'],
+                    'title' => _t('_bx_anon_follow_txt_button')
+                ));
+            }
+        }
+    }
+}
+
+/** @} */

+ 30 - 0
modules/boonex/anon_follow/classes/BxAnonFollowConfig.php

@@ -0,0 +1,30 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowConfig extends BxDolModuleConfig
+{
+    public function __construct($aModule)
+    {
+        parent::__construct($aModule);
+        $this->CNF = array (
+           // database tables
+           'TABLE_ENTRIES' => $aModule['db_prefix'] . 'subscriptions',
+           
+            // database fields
+           'FIELD_ID' => 'id',
+           'FIELD_INITIATOR' => 'initiator',
+           'FIELD_CONTENT' => 'content',
+           'FIELD_ADDED' => 'added',
+       );
+    }
+}
+
+/** @} */

+ 41 - 0
modules/boonex/anon_follow/classes/BxAnonFollowDb.php

@@ -0,0 +1,41 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowDb extends BxBaseModGeneralDb
+{
+    function __construct(&$oConfig)
+    {
+        parent::__construct($oConfig);
+    }
+    
+    public function addFollower($iInitiator, $iContent)
+    {
+        $CNF = &$this->_oConfig->CNF;
+        $aBindings = array(
+            'initiator' => $iInitiator,
+            'content' => $iContent,
+            'added' => time()
+        );
+        $this->query("INSERT INTO `" . $CNF['TABLE_ENTRIES'] . "` (`" . $CNF['FIELD_INITIATOR'] . "`, `" . $CNF['FIELD_CONTENT'] . "`, `" . $CNF['FIELD_ADDED'] . "`) values (:initiator, :content, :added)", $aBindings);
+    }
+    
+    public function removeFollower($iInitiator, $iContent)
+    {
+        $CNF = &$this->_oConfig->CNF;
+        $aBindings = array(
+            'initiator' => $iInitiator,
+            'content' => $iContent
+        );
+        $this->query("DELETE FROM `" . $CNF['TABLE_ENTRIES'] . "` WHERE `" . $CNF['FIELD_INITIATOR'] . "` = :initiator AND `" . $CNF['FIELD_CONTENT'] . "`= :content", $aBindings);
+    }
+}
+
+/** @} */

+ 72 - 0
modules/boonex/anon_follow/classes/BxAnonFollowGridSubscribedMe.php

@@ -0,0 +1,72 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowGridSubscribedMe extends BxDolGridSubscribedMe
+{
+    protected $MODULE;
+    protected $_oModule;
+    
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        $this->MODULE = 'bx_anon_follow';
+        $this->_oModule = BxDolModule::getInstance($this->MODULE);
+        parent::__construct ($aOptions, $oTemplate);
+        $CNF = $this->_oModule->_oConfig->CNF;
+        
+        $this->addMarkers(array(
+            'join_connections2' => 'INNER JOIN `' . $CNF['TABLE_ENTRIES'] . '` AS `c2` ON `c`.`' . $CNF['FIELD_INITIATOR'] . '` = `c2`.`' . $CNF['FIELD_INITIATOR'] . '` AND `c`.`' . $CNF['FIELD_CONTENT'] . '` = `c2`.`' . $CNF['FIELD_CONTENT'] . '` '
+        ));
+    }
+    
+    protected function _getCellName($mixedValue, $sKey, $aField, $aRow)
+    {
+        $mixedValue = strip_tags(htmlspecialchars_decode($mixedValue));
+        $aTitle = array();
+        $oProfile = BxDolProfile::getInstance($aRow['id']);
+        $aProfile = $oProfile->getInfo();
+        $oModule = BxDolModule::getInstance($aProfile['type']);
+        $aFields = $oModule->serviceGetSearchableFieldsExtended();
+        $aProfileData = $oModule->serviceGetContentInfoById($aProfile['content_id']);
+        $sShowFields = $aProfile['type'] == 'bx_persons' ? getParam('bx_anon_follow_persons_fields') : getParam('bx_anon_follow_orgs_fields');
+        $aShowFields = explode(',', $sShowFields);
+        $sTitle = '';
+        foreach($aShowFields as $aField){
+            $sValue = "";
+            if (isset($aProfileData[$aField]))
+            {
+                if (isset($aFields[$aField]) && $aFields[$aField]['type'] == 'select' && substr_count($aFields[$aField]['values'], '#!')){
+                    $aValuesList = BxDolForm::getDataItems(str_replace('#!', '', 'mylist'));
+                    if (isset($aValuesList[$aProfileData[$aField]])){
+                        $sValue = $aValuesList[$aProfileData[$aField]];
+                    }
+                }
+                else{
+                    $sValue = $aProfileData[$aField];
+                }
+            }
+            if (trim($sValue) != '')
+                $aTitle[] = $sValue;
+        }
+        $sTitle = implode(getParam('bx_anon_follow_fields_separator'), $aTitle);
+        if ($sTitle == '')
+        {
+            $sTitle = _t('_bx_anon_follow_txt_grid_title_default');
+        }
+        return parent::_getCellDefault ($sTitle, $sKey, $aField, $aRow);
+    }
+    
+    protected function _getCellActions($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault ('', $sKey, $aField, $aRow);
+    }
+}
+
+/** @} */

+ 164 - 0
modules/boonex/anon_follow/classes/BxAnonFollowModule.php

@@ -0,0 +1,164 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowModule extends BxDolModule
+{
+    public function __construct(&$aModule)
+    {
+        parent::__construct($aModule);
+    }
+    
+    /**
+     * SERVICE METHODS
+     */
+    
+    /**
+     * @page service Service Calls
+     * @section bx_anon_follow Mass mailer
+     * @subsection bx_anon_follow-page_blocks Page Blocks
+     * @subsubsection bx_anon_follow-get_profile_fields get_profile_fields
+     * 
+     * @code bx_srv('bx_anon_follow', 'get_profile_fields', [...]); @endcode
+     * 
+     * Get array with module filelds
+     *
+     * @param $aParams an array with search params.
+     * @return array with module filelds
+     * 
+     * @see BxAnonFollowModule::GetProfileFields
+     */
+    /** 
+     * @ref bx_anon_follow-get_profile_fields "get_profile_fields"
+     */
+    public function serviceGetProfileFields($sModule)
+    {
+        $aResult = array();
+        $oModule = BxDolModule::getInstance($sModule);
+        $aFields = $oModule->serviceGetSearchableFieldsExtended();
+        foreach($aFields as $sKey => $aField){
+            if ($aField['type'] == 'text' || $aField['type'] == 'select')
+            $aResult[$sKey] = _t($aField['caption']);
+        }
+        return $aResult;
+    }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_anon_follow Mass mailer
+     * @subsection bx_anon_follow-page_blocks Page Blocks
+     * @subsubsection bx_anon_follow-check_is_subscribed check_is_subscribed
+     * 
+     * @code bx_srv('bx_anon_follow', 'check_is_subscribed', [...]); @endcode
+     * 
+     * Get subscribed connection for specified profile
+     *
+     * @param $aParams an array with search params.
+     * @return boolean connection for specified profile
+     * 
+     * @see BxAnonFollowModule::CheckIsSubscribed
+     */
+    /** 
+     * @ref bx_anon_follow-check_is_subscribed "check_is_subscribed"
+     */
+    public function serviceCheckIsSubscribed ($iProfileId)
+    {
+        if(isset($iProfileId)){
+            return !$this->checkIsSubscribed($iProfileId);
+        }
+        return false;
+    }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_anon_follow Mass mailer
+     * @subsection bx_anon_follow-page_blocks Page Blocks
+     * @subsubsection bx_anon_follow-subscribed_me_table subscribed_me_table
+     * 
+     * @code bx_srv('bx_anon_follow', 'subscribed_me_table', [...]); @endcode
+     * 
+     * Get grid with subscribers list
+     *
+     * @param $aParams an array with search params.
+     * @return HTML string with block content to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
+     * 
+     * @see BxAnonFollowModule::SubscribedMeTable
+     */
+    /** 
+     * @ref bx_anon_follow-subscribed_me_table "subscribed_me_table"
+     */
+    public function serviceSubscribedMeTable ($iProfileId = 0)
+    {
+        if(!$iProfileId && bx_get('profile_id') !== false)
+            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+
+        $aProfile = BxDolProfile::getInstance($iProfileId)->getInfo();
+        if(empty($aProfile) || !is_array($aProfile))
+            return false;
+
+        $CNF = &BxDolModule::getInstance($aProfile['type'])->_oConfig->CNF;
+        if(getParam($CNF['PARAM_PUBLIC_SBSD']) != 'on' && $aProfile['id'] != bx_get_logged_profile_id())
+            return false;
+
+        $oGrid = BxDolGrid::getObjectInstance('bx_anon_follow_subscribed_me');
+
+        if(!$oGrid)
+            return false;
+
+        $oGrid->setProfileId($iProfileId);
+        $sContent = $oGrid->getCode();
+        if(empty($sContent))
+            return false;
+
+        return $this->_oTemplate->parseHtmlByName('connections_list.html', array(
+            'name' => 'subscribers',
+            'content' => $sContent
+        ));
+    }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_anon_follow Mass mailer
+     * @subsection bx_anon_follow-page_blocks Page Blocks
+     * @subsubsection bx_anon_follow-include_js include_js
+     * 
+     * @code bx_srv('bx_anon_follow', 'include_js', [...]); @endcode
+     * 
+     * Add js to injection in head
+     *
+     * @param $aParams an array with search params.
+     * @return void
+     * 
+     * @see BxAnonFollowModule::serviceIncludeJs
+     */
+    /** 
+     * @ref bx_anon_follow-include_js "include_js"
+     */
+    public function serviceIncludeJs ()
+    {
+        $this->_oTemplate->addJs(array('main.js'));
+        return ;
+    }
+    
+    public function checkIsSubscribed($iProfileId)
+    {
+        $bRv = false;
+        $oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
+        if(!$oConnection){
+            $bRv = false;
+        }
+        if($oConnection->isConnected(bx_get_logged_profile_id(), $iProfileId)){
+            $bRv = true;
+        }
+        return $bRv;
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/anon_follow/classes/BxAnonFollowTemplate.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowTemplate extends BxDolModuleTemplate
+{
+    function __construct(&$oConfig, &$oDb)
+    {
+        parent::__construct($oConfig, $oDb);
+    }
+}
+
+/** @} */

+ 78 - 0
modules/boonex/anon_follow/install/config.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_anon_follow',
+    'title' => 'Anonymous Follow',
+    'note' => 'This module add ability to follow anonymousy',
+    'version' => '9.0.0',
+    'vendor' => 'BoonEx',
+    'help_url' => 'http://feed.boonex.com/?section={module_name}',
+
+    'compatible_with' => array(
+        '9.0.x'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/anon_follow/',
+    'home_uri' => 'anon_follow',
+
+    'db_prefix' => 'bx_anon_follow_',
+    'class_prefix' => 'BxAnonFollow',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Anonymous Follow',
+
+    
+    /**
+      * Menu triggers.
+      */
+    'menu_triggers' => array(
+        'trigger_profile_view_actions',
+        'trigger_profile_snippet_meta',
+    ),
+    
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'check_dependencies' => 1,
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'enable' => array(
+        'check_dependencies' => 1,
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'enable_success' => array(
+        'process_menu_triggers' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+);
+
+/** @} */

+ 20 - 0
modules/boonex/anon_follow/install/installer.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxAnonFollowInstaller extends BxDolStudioInstaller
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}
+
+/** @} */

+ 14 - 0
modules/boonex/anon_follow/install/langs/en.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+	<string name="_bx_anon_follow"><![CDATA[Anonymous Follow]]></string>
+  <string name="_bx_anon_follow_page_block_title_sys_anon_follow"><![CDATA[Followers]]></string>
+  <string name="_bx_anon_follow_page_block_title_anon_follow"><![CDATA[Followers]]></string>
+  <string name="_bx_anon_follow_menu_item_title_system_follow"><![CDATA[Follow anonymously]]></string>
+  <string name="_bx_anon_follow_menu_item_title_follow"><![CDATA[Follow anonymously]]></string>
+  <string name="_bx_anon_follow_persons_fields"><![CDATA[Persons filelds]]></string>
+  <string name="_bx_anon_follow_orgs_fields"><![CDATA[Organisations filelds]]></string>
+  <string name="_bx_anon_follow_fields_separator"><![CDATA[Filelds separator]]></string>
+  
+  <string name="_bx_anon_follow_txt_button"><![CDATA[Follow anonimus]]></string>
+  <string name="_bx_anon_follow_txt_grid_title_default"><![CDATA[Follow anonimus]]></string>
+</resources>

+ 27 - 0
modules/boonex/anon_follow/install/sql/disable.sql

@@ -0,0 +1,27 @@
+SET @sName = 'bx_anon_follow';
+
+-- SETTINGS
+SET @iTypeId = (SELECT `ID` FROM `sys_options_types` WHERE `name` = @sName LIMIT 1);
+SET @iCategId = (SELECT `ID` FROM `sys_options_categories` WHERE `type_id` = @iTypeId LIMIT 1);
+DELETE FROM `sys_options` WHERE `category_id` = @iCategId;
+DELETE FROM `sys_options_categories` WHERE `type_id` = @iTypeId;
+DELETE FROM `sys_options_types` WHERE `id` = @iTypeId;
+
+-- PAGES
+DELETE FROM `sys_pages_blocks` WHERE `module` = @sName;
+
+-- MENUS
+DELETE FROM `sys_menu_items` WHERE `module` = @sName;
+
+-- GRIDS
+DELETE FROM `sys_objects_grid` WHERE `object` IN ('bx_anon_follow_subscribed_me');
+DELETE FROM `sys_grid_fields` WHERE `object` IN ('bx_anon_follow_subscribed_me');
+DELETE FROM `sys_grid_actions` WHERE `object` IN ('bx_anon_follow_subscribed_me');
+
+-- INJECTION
+DELETE FROM `sys_injections` WHERE `name`= @sName;
+
+-- ALERTS
+SET @iHandler := (SELECT `id` FROM `sys_alerts_handlers` WHERE `name` = @sName LIMIT 1);
+DELETE FROM `sys_alerts` WHERE `handler_id` = @iHandler;
+DELETE FROM `sys_alerts_handlers` WHERE `id` = @iHandler;

+ 53 - 0
modules/boonex/anon_follow/install/sql/enable.sql

@@ -0,0 +1,53 @@
+SET @sName = 'bx_anon_follow';
+
+-- SETTINGS
+SET @iTypeOrder = (SELECT IFNULL(MAX(`order`), 0) + 1 FROM `sys_options_types` WHERE `group` = 'modules');
+
+INSERT INTO `sys_options_types` (`group`, `name`, `caption`, `icon`, `order`) 
+VALUES('modules', @sName, '_bx_anon_follow', 'bx_anon_follow@modules/boonex/anon_follow/|std-icon.svg', IF(ISNULL(@iTypeOrder), 1, @iTypeOrder + 1));
+
+SET @iTypeId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `hidden`, `order`) VALUES(@iTypeId,  'bx_anon_follow', '_bx_anon_follow', 0, 2);
+SET @iCategoryId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_params`, `check_error`, `order`) VALUES
+(@iCategoryId, 'bx_anon_follow_persons_fields', '_bx_anon_follow_persons_fields', '', 'list', 'a:3:{s:6:"module";s:14:"bx_anon_follow";s:6:"method";s:18:"get_profile_fields";s:6:"params";a:1:{i:0;s:10:"bx_persons";}}', '', '', '', 0),
+(@iCategoryId, 'bx_anon_follow_orgs_fields', '_bx_anon_follow_orgs_fields', '', 'list', 'a:3:{s:6:"module";s:14:"bx_anon_follow";s:6:"method";s:18:"get_profile_fields";s:6:"params";a:1:{i:0;s:16:"bx_organizations";}}', '', '', '', 1),
+(@iCategoryId, 'bx_anon_follow_fields_separator', '_bx_anon_follow_fields_separator', ', ', 'digit', '', '', '', '', 2);
+
+-- PAGES
+INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
+('', 2, @sName, '_bx_anon_follow_page_block_title_sys_anon_follow', '_bx_anon_follow_page_block_title_anon_follow', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:14:"bx_anon_follow";s:6:"method";s:19:"subscribed_me_table";}', 0, 1, 1, 0);
+
+-- MENU: add menu item to profiles modules actions menu (trigger* menu sets are processed separately upon modules enable/disable)
+INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visibility_custom`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
+('trigger_profile_view_actions', @sName, 'anon-follow', '_bx_anon_follow_menu_item_title_system_follow', '_bx_anon_follow_menu_item_title_follow', 'javascript:void(0)', 'bx_conn_action_anon(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'user-secret', '', 'a:3:{s:6:"module";s:14:"bx_anon_follow";s:6:"method";s:19:"check_is_subscribed";s:6:"params";a:1:{i:0;s:12:"{profile_id}";}}', 2147483646, 1, 0, 0),
+('trigger_profile_snippet_meta', @sName, 'anon-follow', '_bx_anon_follow_menu_item_title_system_follow', '_bx_anon_follow_menu_item_title_follow', 'javascript:void(0)', 'bx_conn_action_anon(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'user-secret', '', '', 2147483646, 1, 0, 0);
+
+-- GRID: connections
+INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
+('bx_anon_follow_subscribed_me', 'Sql', 'SELECT `p`.`id`, `c`.`added` FROM `sys_profiles` AS `p` INNER JOIN `sys_accounts` AS `a` ON (`a`.`id` = `p`.`account_id`) {join_connections} {join_connections2}', 'sys_profiles', 'id', 'c`.`added', '', '', 10, NULL, 'start', '', 'name,email', '', 'auto', '', '', 2147483647, 'BxAnonFollowGridSubscribedMe', 'modules/boonex/anon_follow/classes/BxAnonFollowGridSubscribedMe.php');
+
+INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
+('bx_anon_follow_subscribed_me', 'name', '_sys_name', '70%', '', 1),
+('bx_anon_follow_subscribed_me', 'actions', '', '30%', '', 2);
+
+INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `confirm`, `order`) VALUES
+('bx_anon_follow_subscribed_me', 'single', 'subscribe', '_sys_subscribe', 'check', 0, 1);
+
+-- ALERTS
+INSERT INTO `sys_alerts_handlers` (`name`, `class`, `file`, `service_call`) VALUES 
+(@sName, 'BxAnonFollowAlertsResponse', 'modules/boonex/anon_follow/classes/BxAnonFollowAlertsResponse.php', '');
+SET @iHandler := LAST_INSERT_ID();
+
+INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
+('sys_profiles_subscriptions', 'connection_added', @iHandler),
+('sys_profiles_subscriptions', 'connection_removed', @iHandler),
+('bx_persons', 'menu_custom_item', @iHandler),
+('bx_organizations', 'menu_custom_item', @iHandler);
+
+-- INJECTION
+INSERT INTO `sys_injections`(`name`, `page_index`, `key`, `type`, `data`, `replace`, `active`) VALUES
+(@sName, 0, 'injection_header', 'service', 'a:2:{s:6:"module";s:14:"bx_anon_follow";s:6:"method";s:10:"include_js";}', '0', '1');
+

+ 24 - 0
modules/boonex/anon_follow/install/sql/install.sql

@@ -0,0 +1,24 @@
+-- TABLES
+CREATE TABLE `bx_anon_follow_subscriptions` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `initiator` int(11) NOT NULL,
+  `content` int(11) NOT NULL,
+  `added` int(10) UNSIGNED NOT NULL,
+  PRIMARY KEY (`id`),
+  INDEX `content` (`content`),
+  UNIQUE INDEX `initiator` (`initiator`, `content`)
+);
+
+-- STUDIO WIDGET
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, 'bx_anon_follow', '_bx_anon_follow', '_bx_anon_follow', 'bx_anon_follow@modules/boonex/anon_follow/|std-icon.svg');
+SET @iPageId = LAST_INSERT_ID();
+
+SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
+SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
+INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
+(@iPageId, 'bx_anon_follow', '{url_studio}module.php?name=bx_anon_follow', '', 'bx_anon_follow@modules/boonex/anon_follow/|std-icon.svg', '_bx_anon_follow', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
+
+INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
+(@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));
+

+ 8 - 0
modules/boonex/anon_follow/install/sql/uninstall.sql

@@ -0,0 +1,8 @@
+-- TABLES
+DROP TABLE IF EXISTS `bx_anon_follow_subscriptions`;
+
+-- STUDIO WIDGET
+DELETE FROM `tp`, `tw`, `tpw`
+USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`
+WHERE `tp`.`id` = `tw`.`page_id` AND `tw`.`id` = `tpw`.`widget_id` AND `tp`.`name` = 'bx_anon_follow';
+

+ 60 - 0
modules/boonex/anon_follow/js/main.js

@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+/**
+ * Perform connections AJAX request. 
+ * In case of error - it shows js alert with error message.
+ * In case of success - the page is reloaded.
+ * 
+ * @param sObj - connections object
+ * @param sAction - 'add', 'remove' or 'reject'
+ * @param iContentId - content id, initiator is always current logged in user
+ * @param bConfirm - show confirmation dialog
+ */
+function bx_conn_action_anon(e, sObj, sAction, iContentId, bConfirm, fOnComplete) {
+    var fPerform = function() {
+		var aParams = {
+		    obj: sObj,
+		    act: sAction,
+		    id: iContentId,
+			anon: 1,
+		};
+		var fCallback = function (data) {
+		    bx_loading_btn(e, 0);
+		    if ('object' != typeof(data))
+		        return;
+		    if (data.err) {
+		        bx_alert(data.msg);
+		    } else {
+		        if ('function' == typeof(fOnComplete))
+		            fOnComplete(data, e);
+		        else if (!loadDynamicBlockAuto(e))
+		            location.reload();
+		        else
+		            $('#bx-popup-ajax-wrapper-bx_persons_view_actions_more').remove();
+		    }
+		};
+		
+		bx_loading_btn(e, 1);
+		
+		$.ajax({
+		    dataType: 'json',
+		    url: sUrlRoot + 'conn.php',
+		    data: aParams,
+		    type: 'POST',
+		    success: fCallback
+		});
+    };
+
+    if (typeof(bConfirm) != 'undefined' && bConfirm)
+    	bx_confirm(_t('_Are_you_sure'), fPerform);
+    else
+    	fPerform();
+}

+ 16 - 0
modules/boonex/anon_follow/request.php

@@ -0,0 +1,16 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    AnonymousFollow Anonymous Follow
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+check_logged();
+
+BxDolRequest::processAsAction($GLOBALS['aModule'], $GLOBALS['aRequest']);
+
+/** @} */

+ 2 - 0
modules/boonex/anon_follow/template/connections_list.html

@@ -0,0 +1,2 @@
+<a class="bx-anchor-invisible" name="__name__"></a>
+__content__

+ 1 - 0
modules/boonex/anon_follow/template/follow_button.html

@@ -0,0 +1 @@
+<a class='bx-btn bx-btn-small' onclick="bx_conn_action_anon(this, 'sys_profiles_subscriptions', 'add', '__profile_id__')">__title__</a>

Разница между файлами не показана из-за своего большого размера
+ 18 - 0
modules/boonex/anon_follow/template/images/icons/std-icon.svg


+ 7 - 0
template/scripts/BxBaseFormAccount.php

@@ -144,6 +144,13 @@ class BxBaseFormAccount extends BxTemplFormView
             array (self::$FIELD_CHANGED => time()),
             $sPwd ? array (self::$FIELD_PASSWORD => $sPasswordHash, self::$FIELD_SALT => $sSalt) : array()
         );
+        
+        $oAccount = BxDolAccount::getInstance($val);
+        if ($oAccount) { 
+            $aAccountInfo = $oAccount->getInfo();
+            bx_alert('account', 'change_receive_news', 0, false, array('account_id' => $val,'old_value' =>  $aAccountInfo['receive_news'],'new_value' =>  $this->getCleanValue('receive_news'),'email' =>  $aAccountInfo['email']));
+        }
+
         return parent::update ($val, $aValsToAdd, $aTrackTextFieldsChanges);
     }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов