Alex Trofimov %!s(int64=8) %!d(string=hai) anos
pai
achega
4a59a95e41

+ 31 - 0
modules/boonex/drupal_connect/classes/BxDrupalAlerts.php

@@ -0,0 +1,31 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalAlerts extends BxBaseModConnectAlerts
+{
+    function __construct()
+    {
+        parent::__construct();
+        $this->oModule = BxDolModule::getInstance('bx_drupal');
+    }
+
+    public function response($o)
+    {
+        parent::response($o);
+        
+        if ('profile' == $o->sUnit && 'show_login_form' == $o->sAction) {
+            $o->aExtras['sParams'] .= ' no_auth_buttons no_join_text';
+            $o->aExtras['oForm'] = BxDolForm::getObjectInstance('bx_drupal_login', 'bx_drupal_login');
+        }
+    }
+}
+
+/** @} */

+ 49 - 0
modules/boonex/drupal_connect/classes/BxDrupalConfig.php

@@ -0,0 +1,49 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalConfig extends BxBaseModConnectConfig
+{
+    public $sApiID;
+    public $sApiSecret;
+    public $sApiUrl = 'https://api.linkedin.com/v1';
+    public $sOauthUrl = 'https://www.linkedin.com/oauth/v2';
+
+    public $sFields = 'id,firstName,lastName,picture-url,email-address';
+
+    public $sPageStart;
+    public $sPageHandle;
+
+    public $sScope = 'r_basicprofile r_emailaddress';
+
+    function __construct($aModule)
+    {
+        parent::__construct($aModule);
+
+        $this -> sApiID = getParam('bx_drupal_api_key');
+        $this -> sApiSecret = getParam('bx_drupal_secret');
+
+        $this -> sSessionUid = 'linkedin_session';
+        $this -> sSessionProfile = 'linkedin_session_profile';
+
+        $this -> sEmailTemplatePasswordGenerated = 'bx_drupal_password_generated';
+        $this -> sDefaultTitleLangKey = '_bx_drupal';
+
+        $this -> sRedirectPage = getParam('bx_drupal_redirect_page');
+        $this -> sProfilesModule = getParam('bx_drupal_module');
+        $this -> isAlwaysConfirmEmail = (bool)getParam('bx_drupal_confirm_email'); 
+        $this -> isAlwaysAutoApprove = (bool)getParam('bx_drupal_approve');
+
+        $this -> sPageStart = BX_DOL_URL_ROOT . $this -> getBaseUri() . 'start';
+        $this -> sPageHandle = BX_DOL_URL_ROOT . $this -> getBaseUri() . 'handle';
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/drupal_connect/classes/BxDrupalDb.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    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalDb extends BxBaseModConnectDb
+{
+    function __construct(&$oConfig)
+    {
+        parent::__construct($oConfig);
+    }
+}
+
+/** @} */

+ 93 - 0
modules/boonex/drupal_connect/classes/BxDrupalFormLogin.php

@@ -0,0 +1,93 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+class BxDrupalFormLogin extends BxTemplFormLogin
+{
+    public function __construct($aInfo, $oTemplate)
+    {
+        parent::__construct($aInfo, $oTemplate);
+    }
+
+    function isValid ()
+    {
+        if (!BxTemplFormView::isValid ())
+            return false;
+        
+		$sId = trim($this->getCleanValue('ID'));
+        $sPassword = $this->getCleanValue('Password');
+
+        if ($sId != '') {
+            $sErrorString = $this->checkPassword($sId, $sPassword, $this->getRole());
+            $this->_setCustomError ($sErrorString);
+            return $sErrorString ? false : true;
+        } 
+        else {
+            $this->_setCustomError (_t('_sys_txt_error_occured'));
+            return false;
+        }
+    }
+
+    function checkPassword ($sEmail, $sPassword, $iRole = 1)
+    {
+        $mixedData = $this->call(array(
+            'username' => $sEmail,
+            'password' => $sPassword,   
+        ));
+
+        if (empty($mixedData) || is_string($mixedData) || !is_array($mixedData))
+            return empty($mixedData) ? _t('_sys_txt_error_occured') : $mixedData;
+
+        // create user if their doesn't exists
+        bx_srv('bx_drupal', 'handle_user', array($mixedData));
+
+        return '';
+    }
+    
+    function call ($aData)
+    {
+        $rCurl = curl_init();
+        curl_setopt($rCurl, CURLOPT_URL, getParam('bx_drupal_login_url'));
+        curl_setopt($rCurl, CURLOPT_POST, 1);
+        curl_setopt($rCurl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
+        curl_setopt($rCurl, CURLOPT_POSTFIELDS, json_encode($aData));
+        curl_setopt($rCurl, CURLOPT_HEADER, FALSE);
+        curl_setopt($rCurl, CURLOPT_RETURNTRANSFER, TRUE);
+        curl_setopt($rCurl, CURLOPT_FAILONERROR, TRUE);
+
+        $s = curl_exec($rCurl);
+        $iHttpCode = curl_getinfo($rCurl, CURLINFO_HTTP_CODE);
+
+        $mixedResult = '';
+        
+        // Check if login was successful
+        if ($iHttpCode == 200) {
+            // Convert json response as array
+            $aData = @json_decode($s, TRUE);
+            if (null === $aData)
+                $mixedResult = _t('_bx_drupal_json_decode_failed', $mixedResult);
+            else
+                $mixedResult = $aData;
+        }
+        else {
+            // Get error msg
+            switch ($iHttpCode) {
+            case 401:
+                $mixedResult = _t('_bx_drupal_wrong_username_or_pass');
+                break;
+            default:                
+                $mixedResult = curl_error($rCurl);
+            }
+        }
+
+        curl_close($rCurl);
+
+        return $mixedResult;
+    }
+}
+/** @} */

+ 115 - 0
modules/boonex/drupal_connect/classes/BxDrupalModule.php

@@ -0,0 +1,115 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalModule extends BxBaseModConnectModule
+{
+    function __construct(&$aModule)
+    {
+        parent::__construct($aModule);
+    }    
+
+    function actionLoginSubmit()
+    {
+        require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+        $oForm = BxDolForm::getObjectInstance('bx_drupal_login', 'bx_drupal_login');
+
+        $oForm->initChecker();
+        $oForm->setRole(bx_get('role'));
+        $bLoginSuccess = $oForm->isSubmittedAndValid();
+
+        $bAjxMode = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') ? true : false;
+        if ($bAjxMode) {
+
+            header( 'Content-type: text/html; charset=utf-8' );
+            echo $bLoginSuccess ? 'OK' : $oForm->getLoginError();
+            exit;
+
+        } 
+        elseif ($bLoginSuccess) {
+            
+            $sId = trim($oForm->getCleanValue('ID'));
+
+            $oAccount = BxDolAccount::getInstance($sId);
+            $aAccount = bx_login($oAccount->id(), ($oForm->getCleanValue('rememberMe') ? true : false));
+
+            $sUrlRelocate = $oForm->getCleanValue('relocate');
+            if (!$sUrlRelocate || 0 !== strncmp($sUrlRelocate, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT)))
+                $sUrlRelocate = BX_DOL_ROLE_ADMIN == $oForm->getRole() ? BX_DOL_URL_STUDIO . 'launcher.php' : BX_DOL_URL_ROOT . 'member.php';
+
+            BxDolTemplate::getInstance()->setPageNameIndex (BX_PAGE_TRANSITION);
+            BxDolTemplate::getInstance()->setPageHeader (_t('_Please Wait'));
+            BxDolTemplate::getInstance()->setPageContent ('page_main_code', MsgBox(_t('_Please Wait')));
+            BxDolTemplate::getInstance()->setPageContent ('url_relocate', bx_html_attribute($sUrlRelocate, BX_ESCAPE_STR_QUOTE));
+
+            BxDolTemplate::getInstance()->getPageCode();
+            exit;
+        }        
+
+        bx_require_authentication();
+
+        header('Location: ' . BX_DOL_URL_ROOT);
+    }
+
+    public function serviceHandleUser($aRemoteProfileInfo)
+    {
+        if ($aRemoteProfileInfo && isset($aRemoteProfileInfo['user']) && isset($aRemoteProfileInfo['user']['uid'])) {
+
+            // check if user logged in before
+            $iLocalProfileId = $this->_oDb->getProfileId($aRemoteProfileInfo['user']['uid']);
+            
+            if ($iLocalProfileId && $oProfile = BxDolProfile::getInstance($iLocalProfileId)) {
+                // user already exists
+                $this->setLogged($oProfile->id());
+            }             
+            else {  
+                // register new user
+                if (isset($aRemoteProfileInfo['user']) && isset($aRemoteProfileInfo['user']['uid']))
+                    $aRemoteProfileInfo['id'] = $aRemoteProfileInfo['user']['uid'];
+                $this->_createProfile($aRemoteProfileInfo);
+            }
+        } 
+        else {
+            $this->_oTemplate->getPage(_t('_Error'), MsgBox(_t('_sys_connect_profile_error_info')));
+        }
+    }
+
+    /**
+     * @param $aProfileInfo - remote profile info
+     * @param $sAlternativeName - suffix to add to NickName to make it unique
+     * @return profile array info, ready for the local database
+     */
+    protected function _convertRemoteFields($aProfileInfo, $sAlternativeName = '')
+    {
+        $sFirstName = '';
+        if (isset($aProfileInfo['user']) && isset($aProfileInfo['user']['field_first_name'])) {
+            $a = array_pop($aProfileInfo['user']['field_first_name']['und']);
+            $sFirstName = $a['value'];
+        }
+        
+        $sLastName = '';
+        if (isset($aProfileInfo['user']) && isset($aProfileInfo['user']['field_last_name'])) {
+            $a = array_pop($aProfileInfo['user']['field_last_name']['und']);
+            $sLastName = $a['value'];
+        }
+
+        $aProfileFields['id'] = $aProfileInfo['user']['uid'];
+        $aProfileFields['name'] = $sFirstName;
+        $aProfileFields['fullname'] = $sFirstName . (empty($sLastName) ? '' : ' ' . $sLastName);
+        $aProfileFields['email'] = isset($aProfileInfo['user']['mail']) ? $aProfileInfo['user']['mail'] : '';
+        $aProfileFields['picture'] = isset($aProfileInfo['user']['picture']) ? $aProfileInfo['user']['picture'] : '';
+        $aProfileFields['allow_view_to'] = getParam('bx_drupal_privacy');
+        
+        return $aProfileFields;
+    }
+}
+
+/** @} */

+ 31 - 0
modules/boonex/drupal_connect/classes/BxDrupalStudioPage.php

@@ -0,0 +1,31 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalStudioPage extends BxTemplStudioModule
+{
+    function __construct($sModule = "", $sPage = "")
+    {
+        parent::__construct($sModule, $sPage);
+
+        $this->aMenuItems = array(
+            array('name' => 'settings', 'icon' => 'cogs', 'title' => '_adm_lmi_cpt_settings'),
+            array('name' => 'help', 'icon' => 'question', 'title' => '_sys_connect_information'),
+        );
+    }
+
+    function getHelp ()
+    {
+        $oModule = BxDolModule::getInstance('bx_drupal'); 
+        return _t('_bx_drupal_information_block', BX_DOL_URL_ROOT . $oModule -> _oConfig -> getBaseUri() . 'handle');
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/drupal_connect/classes/BxDrupalTemplate.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    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalTemplate extends BxBaseModConnectTemplate
+{
+    function __construct(&$oConfig, &$oDb)
+    {
+        parent::__construct($oConfig, $oDb);
+    }
+}
+
+/** @} */

+ 68 - 0
modules/boonex/drupal_connect/install/config.php

@@ -0,0 +1,68 @@
+<?php 
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_drupal',
+    'title' => 'Drupal connect',
+    'note' => 'Join the site using Drupal account.',
+    'version' => '9.0.0.DEV',
+    'vendor' => 'Boonex',
+    'help_url' => 'http://feed.una.io/?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/drupal_connect/',
+    'home_uri' => 'drupal',
+
+    'db_prefix' => 'bx_drupal_',
+    'class_prefix' => 'BxDrupal',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Drupal Connect',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'enable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array (
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(),
+);
+
+/** @} */

+ 20 - 0
modules/boonex/drupal_connect/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    DrupalConnect Drupal Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDrupalInstaller extends BxDolStudioInstaller
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}
+
+/** @} */

+ 28 - 0
modules/boonex/drupal_connect/install/langs/en.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+	<string name="_sys_module_drupal"><![CDATA[Drupal Connect]]></string>
+	<string name="_bx_drupal"><![CDATA[Drupal Connect]]></string>
+	<string name="_bx_drupal_settings"><![CDATA[Drupal Connect]]></string>
+	<string name="_bx_drupal_information_block"><![CDATA[
+        <p>This module can be used to login to this site using Drupal credentials.</p>]]></string>
+	<string name="_bx_drupal_profile_error_api_keys"><![CDATA[Please configure the module in admin panel (can't define Client ID and Secret)]]></string>
+    <string name="_bx_drupal_auth_title"><![CDATA[Drupal Connect]]></string>
+    <string name="_bx_drupal_json_decode_failed"><![CDATA[JSON decode failed]]></string>	
+    <string name="_bx_drupal_wrong_username_or_pass"><![CDATA[Wrong username or password]]></string>	
+
+	<string name="_bx_drupal_form_login"><![CDATA[Drupal Login Form]]></string>
+    <string name="_bx_drupal_display_login"><![CDATA[Drupal Login Form]]></string>
+
+	<string name="_bx_drupal_block_system_title_login"><![CDATA[Drupal Login Form]]></string>
+	<string name="_bx_drupal_block_title_login"><![CDATA[Login]]></string>
+
+    <string name="_bx_drupal_adm_stg_cpt_type"><![CDATA[Drupal Connect]]></string>
+    <string name="_bx_drupal_option_login_url"><![CDATA[Drupal JSON API login URL]]></string>
+
+	<string name="_bx_drupal_et_password_generated"><![CDATA[Drupal connect temporary password]]></string>
+	<string name="_bx_drupal_et_password_generated_subject"><![CDATA[Temporary password]]></string>
+	<string name="_bx_drupal_et_password_generated_body"><![CDATA[{email_header}
+<p>Temporary password - <b>{password}</b></p>
+<p>Change it after logging-in.</p>
+{email_footer}]]></string>
+</resources>

+ 25 - 0
modules/boonex/drupal_connect/install/sql/disable.sql

@@ -0,0 +1,25 @@
+
+-- Email template
+
+DELETE FROM `sys_email_templates` WHERE `Name` = 'bx_drupal_password_generated';
+
+-- Auth objects
+
+DELETE FROM `sys_objects_auths` WHERE `Name` = 'bx_drupal';
+
+-- Alerts
+
+SET @iHandlerId := (SELECT `id` FROM `sys_alerts_handlers`  WHERE `name`  =  'bx_drupal');
+
+DELETE FROM `sys_alerts_handlers` WHERE `id` = @iHandlerId;
+DELETE FROM `sys_alerts` WHERE `handler_id` =  @iHandlerId;
+
+-- Options
+
+DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name` = 'bx_drupal';
+
+-- Pages
+
+DELETE FROM `sys_objects_page` WHERE `module` = 'bx_drupal';
+DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_drupal';
+

+ 54 - 0
modules/boonex/drupal_connect/install/sql/enable.sql

@@ -0,0 +1,54 @@
+
+-- Email template
+
+INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES
+('bx_drupal', '_bx_drupal_et_password_generated', 'bx_drupal_password_generated', '_bx_drupal_et_password_generated_subject', '_bx_drupal_et_password_generated_body');
+
+-- Auth objects
+
+INSERT INTO `sys_objects_auths` (`Name`, `Title`, `Link`, `Icon`) VALUES
+('bx_drupal', '_bx_drupal_auth_title', 'modules/?r=drupal/start', 'fab drupal');
+
+-- Alerts
+
+INSERT INTO `sys_alerts_handlers` SET `name` = 'bx_drupal', `class` = 'BxDrupalAlerts', `file` = 'modules/boonex/drupal_connect/classes/BxDrupalAlerts.php';
+
+SET @iHandlerId := (SELECT `id` FROM `sys_alerts_handlers`  WHERE `name` = 'bx_drupal');
+
+INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
+('account', 'logout', @iHandlerId),
+('profile', 'delete', @iHandlerId),
+('profile', 'add', @iHandlerId),
+('profile', 'show_login_form', @iHandlerId);
+
+-- Options
+
+SET @iTypeOrder = (SELECT MAX(`order`) FROM `sys_options_types` WHERE `group` = 'modules');
+INSERT INTO `sys_options_types` (`group`, `name`, `caption`, `icon`, `order`) VALUES 
+('modules', 'bx_drupal', '_bx_drupal_adm_stg_cpt_type', 'bx_drupal@modules/boonex/drupal_connect/|std-icon.svg', IF(NOT ISNULL(@iTypeOrder), @iTypeOrder + 1, 1));
+SET @iTypeId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order` )  
+VALUES (@iTypeId, 'bx_drupal_general', '_sys_connect_adm_stg_cpt_category_general', 1);
+SET @iCategId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_error`, `order`, `extra`) VALUES
+('bx_drupal_login_url', '', @iCategId, '_bx_drupal_option_login_url', 'digit', '', '', 10, ''),
+('bx_drupal_redirect_page', 'index', @iCategId, '_sys_connect_option_redirect', 'select', '', '', 40, 'join,settings,dashboard,index'),
+('bx_drupal_module', 'bx_persons', @iCategId, '_sys_connect_option_module', 'select', '', '', 50, 'a:2:{s:6:"module";s:9:"bx_drupal";s:6:"method";s:20:"get_profiles_modules";}'),
+('bx_drupal_privacy', '3', @iCategId, '_sys_connect_option_privacy', 'select', '', '', 54, 'a:2:{s:6:"module";s:9:"bx_drupal";s:6:"method";s:18:"get_privacy_groups";}'),
+('bx_drupal_confirm_email', 'on', @iCategId, '_sys_connect_option_confirm_email', 'checkbox', '', '', 70, ''),
+('bx_drupal_approve', 'on', @iCategId, '_sys_connect_option_approve', 'checkbox', '', '', 80, '');
+
+-- Pages
+
+INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
+('bx_drupal_error', 'drupal-error', '_bx_drupal_error', '_bx_drupal_error', 'bx_drupal', 5, 2147483647, 0, '', '', '', '', 0, 1, 0, 'BxDrupalPage', 'modules/boonex/drupal_connect/classes/BxDrupalPage.php');
+
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
+('bx_drupal_error', 1, 'bx_drupal', '_bx_drupal_error', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_drupal\";s:6:\"method\";s:10:\"last_error\";}', 0, 0, 1, 1);
+
+-- SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = 'sys_login' AND `cell_id` = 1 ORDER BY `order` DESC LIMIT 1);
+-- INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
+-- ('sys_login', 1, 'bx_drupal', '_bx_drupal_block_system_title_login', '_bx_drupal_block_title_login', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_drupal";s:6:"method";s:10:"login_form";}', 0, 1, 1, @iBlockOrder + 1);
+

+ 46 - 0
modules/boonex/drupal_connect/install/sql/install.sql

@@ -0,0 +1,46 @@
+
+CREATE TABLE `bx_drupal_accounts` (
+  `local_profile` int(10) unsigned NOT NULL,
+  `remote_profile` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  PRIMARY KEY (`local_profile`),
+  KEY `remote_profile` (`remote_profile`)
+) ENGINE=MyISAM;
+
+-- Forms
+
+INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
+('bx_drupal_login', 'bx_drupal', '_bx_drupal_form_login', 'modules/?r=drupal/login_submit', 'a:3:{s:2:"id";s:14:"sys-form-login";s:6:"action";s:30:"modules/?r=drupal/login_submit";s:8:"onsubmit";s:31:"return validateLoginForm(this);";}', 'a:3:{i:0;s:4:"role";i:1;s:10:"do_sendsms";i:2;s:12:"do_checkcode";}', '', '', '', '', 'a:1:{s:14:"checker_helper";s:24:"BxFormLoginCheckerHelper";}', 0, 1, 'BxDrupalFormLogin', 'modules/boonex/drupal_connect/classes/BxDrupalFormLogin.php');
+
+INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `view_mode`) VALUES
+('bx_drupal_login', 'bx_drupal', 'bx_drupal_login', '_bx_drupal_display_login', 0);
+
+INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES
+('bx_drupal_login', 'bx_drupal', 'role', '1', '', 0, 'hidden', '_sys_form_login_input_caption_system_role', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_drupal_login', 'bx_drupal', 'relocate', '', '', 0, 'hidden', '_sys_form_login_input_caption_system_relocate', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_drupal_login', 'bx_drupal', 'ID', '', '', 0, 'text', '_sys_form_login_input_caption_system_id', '_sys_form_login_input_email', '', 1, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_drupal_login', 'bx_drupal', 'Password', '', '', 0, 'password', '_sys_form_login_input_caption_system_password', '_sys_form_login_input_password', '', 1, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_drupal_login', 'bx_drupal', 'rememberMe', '1', '', 0, 'switcher', '_sys_form_login_input_caption_system_remember_me', '_sys_form_login_input_remember_me', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_drupal_login', 'bx_drupal', 'login', '_sys_form_login_input_submit', '', 0, 'submit', '_sys_form_login_input_caption_system_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_drupal_login', 'bx_drupal', 'submit_text', '', '', 0, 'custom', '_sys_form_login_input_caption_system_submit_text', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0);
+
+INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES
+('bx_drupal_login', 'role', 2147483647, 1, 1),
+('bx_drupal_login', 'relocate', 2147483647, 1, 2),
+('bx_drupal_login', 'ID', 2147483647, 1, 3),
+('bx_drupal_login', 'Password', 2147483647, 1, 4),
+('bx_drupal_login', 'rememberMe', 2147483647, 1, 5),
+('bx_drupal_login', 'login', 2147483647, 1, 6);
+
+-- Studio page and widget
+
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, 'bx_drupal', '_bx_drupal', '_bx_drupal', 'bx_drupal@modules/boonex/drupal_connect/|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_drupal', '{url_studio}module.php?name=bx_drupal', '', 'bx_drupal@modules/boonex/drupal_connect/|std-icon.svg', '_bx_drupal', '', '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));
+

+ 16 - 0
modules/boonex/drupal_connect/install/sql/uninstall.sql

@@ -0,0 +1,16 @@
+
+DROP TABLE IF EXISTS `bx_drupal_accounts`;
+
+-- Forms
+
+DELETE FROM `sys_objects_form` WHERE `module` = 'bx_drupal';
+DELETE FROM `sys_form_displays` WHERE `module` = 'bx_drupal';
+DELETE FROM `sys_form_inputs` WHERE `module` = 'bx_drupal';
+DELETE FROM `sys_form_display_inputs` WHERE `display_name` = 'bx_drupal_login';
+
+-- Studio page and 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_drupal';
+

+ 18 - 0
modules/boonex/drupal_connect/request.php

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

+ 26 - 0
modules/boonex/drupal_connect/template/images/icons/std-icon.svg

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="606px" height="606px" viewBox="0 0 606 606" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <title>Drupal</title>
+    <desc>Created with Sketch.</desc>
+    <defs>
+        <linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
+            <stop stop-color="#FFFFFF" stop-opacity="0.2" offset="0%"></stop>
+            <stop stop-color="#000000" stop-opacity="0.2" offset="100%"></stop>
+        </linearGradient>
+        <path d="M552.268958,552.268958 C600,504.537813 600,431.458333 600,300 C600,168.541667 600,95.4621875 552.268958,47.7310417 C504.537813,0 431.458333,0 300,0 C168.541667,0 95.4621875,0 47.7310417,47.7310417 C0,95.4621875 0,168.541667 0,300 C0,431.458333 0,504.537813 47.7310417,552.268958 C95.4621875,600 168.541667,600 300,600 C431.458333,600 504.537813,600 552.268958,552.268958 Z" id="path-2"></path>
+    </defs>
+    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
+        <g id="linkedin" transform="translate(3.000000, 3.000000)">
+            <g id="Squircle2-Copy-7">
+                <g id="Shape">
+                    <use fill="#0678be" xlink:href="#path-2"></use>
+                </g>
+            </g>
+            <g id="In-White-0p5in-R" opacity="0.9" transform="translate(75.000000, 20.000000)" fill="#FFFFFF">
+                <g id="Group-5">
+                    <path fill="#FFFFFF" d="M319.5 114.7c-22.2-14-43.5-19.5-64.7-33.5-13-8.8-31.3-30-46.5-48.3-2.7 29.3-11.5 41.2-22 49.5-21.3 17-34.8 22.2-53.5 32.3C117 123 32 181.5 32 290.5 32 399.7 123.8 480 225.8 480 327.5 480 416 406 416 294c0-112.3-83-171-96.5-179.3zm2.5 325.6c-20.1 20.1-90.1 28.7-116.7 4.2-4.8-4.8.3-12 6.5-12 0 0 17 13.3 51.5 13.3 27 0 46-7.7 54.5-14 6.1-4.6 8.4 4.3 4.2 8.5zm-54.5-52.6c8.7-3.6 29-3.8 36.8 1.3 4.1 2.8 16.1 18.8 6.2 23.7-8.4 4.2-1.2-15.7-26.5-15.7-14.7 0-19.5 5.2-26.7 11-7 6-9.8 8-12.2 4.7-6-8.2 15.9-22.3 22.4-25zM360 405c-15.2-1-45.5-48.8-65-49.5-30.9-.9-104.1 80.7-161.3 42-38.8-26.6-14.6-104.8 51.8-105.2 49.5-.5 83.8 49 108.5 48.5 21.3-.3 61.8-41.8 81.8-41.8 48.7 0 23.3 109.3-15.8 106z"></path>
+                </g>
+            </g>
+        </g>
+    </g>
+</svg>