Alex Trofimov 10 роки тому
батько
коміт
34e8a23f80
22 змінених файлів з 593 додано та 2 видалено
  1. 6 0
      modules/base/connect/classes/BxBaseModConnectModule.php
  2. 12 1
      modules/boonex/english/data/langs/system/en.xml
  3. 38 0
      modules/boonex/russian/data/langs/bx_twitter/ru.xml
  4. 12 1
      modules/boonex/russian/data/langs/system/ru.xml
  5. 21 0
      modules/boonex/twitter_connect/classes/BxTwitterAlerts.php
  6. 49 0
      modules/boonex/twitter_connect/classes/BxTwitterConfig.php
  7. 20 0
      modules/boonex/twitter_connect/classes/BxTwitterDb.php
  8. 140 0
      modules/boonex/twitter_connect/classes/BxTwitterModule.php
  9. 28 0
      modules/boonex/twitter_connect/classes/BxTwitterStudioPage.php
  10. 20 0
      modules/boonex/twitter_connect/classes/BxTwitterTemplate.php
  11. 68 0
      modules/boonex/twitter_connect/install/config.php
  12. 20 0
      modules/boonex/twitter_connect/install/installer.php
  13. 38 0
      modules/boonex/twitter_connect/install/langs/en.xml
  14. 25 0
      modules/boonex/twitter_connect/install/sql/disable.sql
  15. 48 0
      modules/boonex/twitter_connect/install/sql/enable.sql
  16. 21 0
      modules/boonex/twitter_connect/install/sql/install.sql
  17. 9 0
      modules/boonex/twitter_connect/install/sql/uninstall.sql
  18. 18 0
      modules/boonex/twitter_connect/request.php
  19. BIN
      modules/boonex/twitter_connect/template/images/icons/std-mi.png
  20. BIN
      modules/boonex/twitter_connect/template/images/icons/std-pi.png
  21. BIN
      modules/boonex/twitter_connect/template/images/icons/std-si.png
  22. BIN
      modules/boonex/twitter_connect/template/images/icons/std-wi.png

+ 6 - 0
modules/base/connect/classes/BxBaseModConnectModule.php

@@ -279,6 +279,12 @@ class BxBaseModConnectModule extends BxDolModule
 
         return $sRedirectUrl;
     }
+
+    protected function _redirect($sUrl, $iStatus = 302)
+    {
+        header("Location:{$sUrl}", true, $iStatus);
+        exit;
+    }
 }
 
 /** @} */

+ 12 - 1
modules/boonex/english/data/langs/system/en.xml

@@ -1545,7 +1545,18 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_conn_err_connection_does_not_exists"><![CDATA[Connection doesn't exist]]></string>
 	<string name="_sys_conn_err_connection_is_awaiting_confirmation"><![CDATA[Connection request is awaiting confirmation]]></string>
 	<string name="_sys_conn_err_input_data_is_not_defined"><![CDATA[Input data isn't defined]]></string>
-	<string name="_sys_conn_msg_success"><![CDATA[Operation has beed successfully completed]]></string>
+    <string name="_sys_conn_msg_success"><![CDATA[Operation has beed successfully completed]]></string>
+
+    <string name="_sys_connect_information"><![CDATA[Configuration info]]></string>
+    <string name="_sys_connect_error_join_unavailable"><![CDATA[Sorry but join is unavailable now. Please try again later.]]></string>
+    <string name="_sys_connect_profile_error_info"><![CDATA[Can't define your profile information]]></string>
+    <string name="_sys_connect_state_invalid"><![CDATA[State parameter isn't matching]]></string>
+    <string name="_sys_connect_adm_stg_cpt_category_general"><![CDATA[General]]></string>
+    <string name="_sys_connect_option_redirect"><![CDATA[Redirect page after first sign in]]></string>
+    <string name="_sys_connect_option_module"><![CDATA[Module to create profile in]]></string>
+    <string name="_sys_connect_option_confirm_email"><![CDATA[Always confirm emails when joined using this module]]></string>
+    <string name="_sys_connect_option_approve"><![CDATA[Always approve profiles when joined using this module]]></string>
+
 	<string name="_sys_currency"><![CDATA[{0}{1}]]></string>
 	<string name="_sys_designbox_0"><![CDATA[Content]]></string>
 	<string name="_sys_designbox_1"><![CDATA[Content + Title + Background]]></string>

+ 38 - 0
modules/boonex/russian/data/langs/bx_twitter/ru.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="ru" flag="ru" title="Russian">
+	<string name="_sys_module_twitter"><![CDATA[Twitter соединение]]></string>
+	<string name="_bx_twitter"><![CDATA[Twitter соединение]]></string>
+	<string name="_bx_twitter_settings"><![CDATA[Twitter соединение]]></string>
+	<string name="_bx_twitter_information_block"><![CDATA[
+        <pЭтот модуль может использоваться для входа на сайт используя Twitter профиль.</p>
+        <p>Чтобы он заработал, нужно <a target="_blank" href="https://apps.twitter.com">создать Twitter приложение</a> и указать всю необходимую информацию, в частности:
+            <ul>
+                <li>Callback URL: <strong>{0}</strong></li>
+            </ul>
+            Когда приложение создано, нужно изменить слудующие настройки:
+            <ul>
+                <li>Settings &gt; Privacy Policy URL</li>
+                <li>Settings &gt; Terms of Service URL</li>
+                <li>Settings &gt; Enable "Allow this application to be used to Sign in with Twitter"</li>
+                <li>Permissions &gt; Access &gt; Read only</li>
+                <li>Permissions &gt; Additional Permissions &gt; Enable "Request email addresses from users"</li>
+            </ul>
+            Затем нужно ввести полученную пару API Key & Secret в настройках этого модуля.
+        </p>]]></string>
+    
+	<string name="_bx_twitter_profile_error_api_keys"><![CDATA[Нужно настроить модуль - указать API Key & Secret]]></string>
+	<string name="_bx_twitter_auth_title"><![CDATA[Twitter соединение]]></string>
+	<string name="_bx_twitter_error_no_oauth_token"><![CDATA[Отсутствует "Auth token"]]></string>
+
+    <string name="_bx_twitter_adm_stg_cpt_type"><![CDATA[Twitter соединение]]></string>
+    <string name="_bx_twitter_option_app_id"><![CDATA[API Key]]></string>
+    <string name="_bx_twitter_option_app_secret"><![CDATA[API Secret]]></string>
+
+	<string name="_bx_twitter_et_password_generated"><![CDATA[Twitter соединение: временный пароль]]></string>
+	<string name="_bx_twitter_et_password_generated_subject"><![CDATA[Временный пароль]]></string>
+	<string name="_bx_twitter_et_password_generated_body"><![CDATA[<bx_include_auto:_email_header.html />
+<p>Временный пароль - <b>{password}</b></p>
+<p>Его нужно изменить, после первого захода на сайт.</p>
+<bx_include_auto:_email_footer.html />]]></string>
+    
+</resources>

+ 12 - 1
modules/boonex/russian/data/langs/system/ru.xml

@@ -1543,7 +1543,18 @@
 	<string name="_sys_conn_err_connection_does_not_exists"><![CDATA[Связь не существует]]></string>
 	<string name="_sys_conn_err_connection_is_awaiting_confirmation"><![CDATA[Запрос на связь ожидает подтверждения]]></string>
 	<string name="_sys_conn_err_input_data_is_not_defined"><![CDATA[Входные данные не определены]]></string>
-	<string name="_sys_conn_msg_success"><![CDATA[Операция удачно завершена]]></string>
+    <string name="_sys_conn_msg_success"><![CDATA[Операция удачно завершена]]></string>
+
+    <string name="_sys_connect_information"><![CDATA[Информация о настройке]]></string>
+    <string name="_sys_connect_error_join_unavailable"><![CDATA[Извините, но регистрация на данный момент недоступна. Пожалуйста попробуйте снова попозже.]]></string>
+    <string name="_sys_connect_profile_error_info"><![CDATA[Невозможно получить информацию о профиле]]></string>
+	<string name="_sys_connect_state_invalid"><![CDATA["State" параметр не совпадает]]></string>
+    <string name="_sys_connect_adm_stg_cpt_category_general"><![CDATA[Общие]]></string>
+    <string name="_sys_connect_option_redirect"><![CDATA[Перенаправление после захода на сайт]]></string>
+    <string name="_sys_connect_option_module"><![CDATA[Модуль в котором создавать профили]]></string>
+    <string name="_sys_connect_option_confirm_email"><![CDATA[Всегда подтверждать емейл, когда заходят через это соединение]]></string>
+    <string name="_sys_connect_option_approve"><![CDATA[Всегда одобрять профиль, когда заходят через это соединение]]></string>
+
 	<string name="_sys_currency"><![CDATA[{0}{1}]]></string>
 	<string name="_sys_designbox_0"><![CDATA[Содержимое]]></string>
 	<string name="_sys_designbox_1"><![CDATA[Содержимое + заголовок + фон]]></string>

+ 21 - 0
modules/boonex/twitter_connect/classes/BxTwitterAlerts.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTwitterAlerts extends BxBaseModConnectAlerts
+{
+    function __construct()
+    {
+        parent::__construct();
+        $this -> oModule = BxDolModule::getInstance('bx_twitter');
+    }
+}
+
+/** @} */

+ 49 - 0
modules/boonex/twitter_connect/classes/BxTwitterConfig.php

@@ -0,0 +1,49 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTwitterConfig extends BxBaseModConnectConfig
+{
+    public $sApiID;
+    public $sApiSecret;
+    public $sApiUrl = 'https://api.twitter.com/v1';
+    public $sOauthUrl = 'https://www.twitter.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_twitter_api_key');
+        $this -> sApiSecret = getParam('bx_twitter_secret');
+
+        $this -> sSessionUid = 'twitter_session';
+        $this -> sSessionProfile = 'twitter_session_profile';
+
+        $this -> sEmailTemplatePasswordGenerated = 'bx_twitter_password_generated';
+        $this -> sDefaultTitleLangKey = '_bx_twitter';
+
+        $this -> sRedirectPage = getParam('bx_twitter_redirect_page');
+        $this -> sProfilesModule = getParam('bx_twitter_module');
+        $this -> isAlwaysConfirmEmail = (bool)getParam('bx_twitter_confirm_email'); 
+        $this -> isAlwaysAutoApprove = (bool)getParam('bx_twitter_approve');
+
+        $this -> sPageStart = BX_DOL_URL_ROOT . $this -> getBaseUri() . 'start';
+        $this -> sPageHandle = BX_DOL_URL_ROOT . $this -> getBaseUri() . 'handle';
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/twitter_connect/classes/BxTwitterDb.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTwitterDb extends BxBaseModConnectDb
+{
+    function __construct(&$oConfig)
+    {
+        parent::__construct($oConfig);
+    }
+}
+
+/** @} */

+ 140 - 0
modules/boonex/twitter_connect/classes/BxTwitterModule.php

@@ -0,0 +1,140 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+use OAuth\OAuth1\Service\Twitter;
+use OAuth\Common\Storage\Session;
+use OAuth\Common\Consumer\Credentials;
+
+require_once (BX_DIRECTORY_PATH_PLUGINS . 'OAuth/bootstrap.php');
+require_once (BX_DIRECTORY_PATH_PLUGINS . 'OAuth/ServiceFactory.php');
+
+class BxTwitterModule extends BxBaseModConnectModule
+{
+    protected $_oStorage;
+    protected $_oCredentials;
+
+    function __construct(&$aModule)
+    {
+        parent::__construct($aModule);
+    }
+
+    /**
+     * Redirect to remote site login form
+     *
+     * @return n/a - redirect or HTML page in case of error
+     */
+    function actionStart()
+    {
+        if (isLogged())
+            $this->_redirect ($this -> _oConfig -> sDefaultRedirectUrl);
+        
+        if (!$this->_oConfig->sApiID || !$this->_oConfig->sApiSecret) {
+            require_once(BX_DIRECTORY_PATH_INC . 'design.inc.php');
+            bx_import('BxDolLanguages');
+            $sCode =  MsgBox( _t('_bx_twitter_profile_error_api_keys') );
+            $this->_oTemplate->getPage(_t('_bx_twitter'), $sCode);            
+        } 
+        else {
+            $this->_init();
+            $oToken = $this->_oTwitterService->requestRequestToken();
+            $sUrl = $this->_oTwitterService->getAuthorizationUri(array('oauth_token' => $oToken->getRequestToken()));
+            $this->_redirect($sUrl);
+        }
+    }
+
+    function actionHandle()
+    {
+        require_once(BX_DIRECTORY_PATH_INC . 'design.inc.php');
+
+        // check CSRF token
+        if (empty($_GET['oauth_token'])) {
+            $this->_oTemplate->getPage(_t('_Error'), MsgBox(_t('_bx_twitter_error_no_oauth_token')));
+            return;
+        }
+
+        $this->_init();
+
+        $oToken = $this->_oStorage->retrieveAccessToken('Twitter');
+        
+        $this->_oTwitterService->requestAccessToken(
+            $_GET['oauth_token'],
+            $_GET['oauth_verifier'],
+            $oToken->getRequestTokenSecret()
+        );
+
+        $s = $this->_oTwitterService->request('account/verify_credentials.json?include_email=true');
+
+        // handle error
+        if (!$s || NULL === ($aResponse = json_decode($s, true)) || !$aResponse || !isset($aResponse['id'])) {
+            $sErrorDescription = _t('_error occured'); 
+            $this->_oTemplate->getPage(_t('_Error'), MsgBox($sErrorDescription));
+            return;
+        }
+
+        $aRemoteProfileInfo = $aResponse;
+
+        if ($aRemoteProfileInfo) {
+
+            // check if user logged in before
+            $iLocalProfileId = $this->_oDb->getProfileId($aRemoteProfileInfo['id']);
+            
+            if ($iLocalProfileId && $oProfile = BxDolProfile::getInstance($iLocalProfileId)) {
+                // user already exists
+                $this->setLogged($oProfile ->id());
+            }             
+            else {  
+                // register new user
+                $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 = '')
+    {
+        $aProfileFields = $aProfileInfo;
+
+        $aProfileFields['name'] = $aProfileInfo['screen_name'];
+        $aProfileFields['fullname'] = $aProfileInfo['name'];
+        $aProfileFields['email'] = isset($aProfileInfo['email']) ? $aProfileInfo['email'] : '';
+        $aProfileFields['picture'] = isset($aProfileInfo['profile_image_url']) ? str_replace('_normal', '', $aProfileInfo['profile_image_url']) : '';
+        
+        return $aProfileFields;
+    }
+
+    protected function _init() 
+    {
+        if ($this->_oStorage)
+            return;
+
+        $this->_oStorage = new Session();
+
+        $this->_oCredentials = new Credentials(
+            $this->_oConfig->sApiID,
+            $this->_oConfig->sApiSecret,
+            $this->_oConfig->sPageHandle
+        );
+
+        $oServiceFactory = new OAuth\ServiceFactory();
+
+        $this->_oTwitterService = $oServiceFactory->createService('twitter', $this->_oCredentials, $this->_oStorage);
+    }
+
+}
+
+/** @} */

+ 28 - 0
modules/boonex/twitter_connect/classes/BxTwitterStudioPage.php

@@ -0,0 +1,28 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTwitterStudioPage extends BxTemplStudioModule
+{
+    function getHelp ()
+    {
+        $oModule = BxDolModule::getInstance('bx_twitter'); 
+        return _t('_bx_twitter_information_block', BX_DOL_URL_ROOT . $oModule -> _oConfig -> getBaseUri() . 'handle');
+    }
+
+    protected function getPageCaptionHelp()
+    {
+        $oTemplate = BxDolStudioTemplate::getInstance();
+        $sContent = '<a href="' . BX_DOL_URL_STUDIO . 'module.php?name=bx_twitter&page=help">' . _t('_sys_connect_information') . "</a>";
+        return $oTemplate->parseHtmlByName('page_caption_help.html', array('content' => $sContent));
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/twitter_connect/classes/BxTwitterTemplate.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTwitterTemplate extends BxBaseModConnectTemplate
+{
+    function __construct(&$oConfig, &$oDb)
+    {
+        parent::__construct($oConfig, $oDb);
+    }
+}
+
+/** @} */

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

@@ -0,0 +1,68 @@
+<?php 
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_twitter',
+    'title' => 'Twitter connect',
+    'note' => 'Join the site using Twitter account.',
+    'version' => '9.0.0.DEV',
+    '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/twitter_connect/',
+    'home_uri' => 'twitter',
+
+    'db_prefix' => 'bx_twitter_',
+    'class_prefix' => 'BxTwitter',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Twitter 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/twitter_connect/install/installer.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTwitterInstaller extends BxDolStudioInstaller
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}
+
+/** @} */

+ 38 - 0
modules/boonex/twitter_connect/install/langs/en.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+	<string name="_sys_module_twitter"><![CDATA[Twitter Connect]]></string>
+	<string name="_bx_twitter"><![CDATA[Twitter Connect]]></string>
+	<string name="_bx_twitter_settings"><![CDATA[Twitter Connect]]></string>
+	<string name="_bx_twitter_information_block"><![CDATA[
+        <p>This module can be used to login to this site using Twitter credentials.</p>
+        <p>To make it work, <a target="_blank" href="https://apps.twitter.com">create Twitter app</a> and specify all the details, particularly:
+            <ul>
+                <li>Callback URL: <strong>{0}</strong></li>
+            </ul>
+            When the app is created make sure to specify the following fields:
+            <ul>
+                <li>Settings &gt; Privacy Policy URL</li>
+                <li>Settings &gt; Terms of Service URL</li>
+                <li>Settings &gt; Enable "Allow this application to be used to Sign in with Twitter"</li>
+                <li>Permissions &gt; Access &gt; Read only</li>
+                <li>Permissions &gt; Additional Permissions &gt; Enable "Request email addresses from users"</li>
+            </ul>
+            Then enter generated API Key & Secret pair in this module settings.
+        </p>]]></string>
+		
+	<string name="_bx_twitter_profile_error_api_keys"><![CDATA[Please configure the module in admin panel (can't define API key, secret & URL)]]></string>
+	<string name="_bx_twitter_auth_title"><![CDATA[Twitter Connect]]></string>
+	<string name="_bx_twitter_error_no_oauth_token"><![CDATA[Auth token is missing]]></string>
+
+    <string name="_bx_twitter_adm_stg_cpt_type"><![CDATA[Twitter Connect]]></string>    
+    <string name="_bx_twitter_option_app_id"><![CDATA[API Key]]></string>
+    <string name="_bx_twitter_option_app_secret"><![CDATA[API Secret]]></string>
+
+	<string name="_bx_twitter_et_password_generated"><![CDATA[Twitter connect temporary password]]></string>
+	<string name="_bx_twitter_et_password_generated_subject"><![CDATA[Temporary password]]></string>
+	<string name="_bx_twitter_et_password_generated_body"><![CDATA[<bx_include_auto:_email_header.html />
+<p>Temporary password - <b>{password}</b></p>
+<p>Change it after logging-in.</p>
+<bx_include_auto:_email_footer.html />]]></string>
+    
+</resources>

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

@@ -0,0 +1,25 @@
+
+-- Email template
+
+DELETE FROM `sys_email_templates` WHERE `Name` = 'bx_twitter_password_generated';
+
+-- Auth objects
+
+DELETE FROM `sys_objects_auths` WHERE `Name` = 'bx_twitter';
+
+-- Alerts
+
+SET @iHandlerId := (SELECT `id` FROM `sys_alerts_handlers`  WHERE `name`  =  'bx_twitter');
+
+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_twitter';
+
+-- Pages
+
+DELETE FROM `sys_objects_page` WHERE `module` = 'bx_twitter';
+DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_twitter';
+

+ 48 - 0
modules/boonex/twitter_connect/install/sql/enable.sql

@@ -0,0 +1,48 @@
+
+-- Email template
+
+INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES
+('bx_twitter', '_bx_twitter_et_password_generated', 'bx_twitter_password_generated', '_bx_twitter_et_password_generated_subject', '_bx_twitter_et_password_generated_body');
+
+-- Auth objects
+
+INSERT INTO `sys_objects_auths` (`Name`, `Title`, `Link`, `Icon`) VALUES
+('bx_twitter', '_bx_twitter_auth_title', 'modules/?r=twitter/start', 'twitter');
+
+-- Alerts
+
+INSERT INTO `sys_alerts_handlers` SET `name` = 'bx_twitter', `class` = 'BxTwitterAlerts', `file` = 'modules/boonex/dolphin_connect/classes/BxTwitterAlerts.php';
+
+SET @iHandlerId := (SELECT `id` FROM `sys_alerts_handlers`  WHERE `name` = 'bx_twitter');
+
+INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
+('account', 'logout', @iHandlerId),
+('profile', 'delete', @iHandlerId),
+('profile', 'add', @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_twitter', '_bx_twitter_adm_stg_cpt_type', 'bx_twitter@modules/boonex/twitter/|std-mi.png', 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_twitter_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_twitter_api_key', '', @iCategId, '_bx_twitter_option_app_id', 'digit', '', '', 10, ''),
+('bx_twitter_secret', '', @iCategId, '_bx_twitter_option_app_secret', 'digit', '', '', 20, ''),
+('bx_twitter_redirect_page', 'dashboard', @iCategId, '_sys_connect_option_redirect', 'select', '', '', 40, 'join,settings,dashboard,index'),
+('bx_twitter_module', 'bx_persons', @iCategId, '_sys_connect_option_module', 'select', '', '', 50, 'a:2:{s:6:"module";s:10:"bx_twitter";s:6:"method";s:20:"get_profiles_modules";}'),
+('bx_twitter_confirm_email', 'on', @iCategId, '_sys_connect_option_confirm_email', 'checkbox', '', '', 70, ''),
+('bx_twitter_approve', '', @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_twitter_error', 'twitter-error', '_bx_twitter_error', '_bx_twitter_error', 'bx_twitter', 5, 2147483647, 0, '', '', '', '', 0, 1, 0, 'BxTwitterPage', 'modules/boonex/twitter/classes/BxTwitterPage.php');
+
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
+('bx_twitter_error', 1, 'bx_twitter', '_bx_twitter_error', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:\"bx_twitter\";s:6:\"method\";s:10:\"last_error\";}', 0, 0, 1, 1);

+ 21 - 0
modules/boonex/twitter_connect/install/sql/install.sql

@@ -0,0 +1,21 @@
+
+CREATE TABLE `bx_twitter_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;
+
+-- Studio page and widget
+
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, 'bx_twitter', '_bx_twitter', '_bx_twitter', 'bx_twitter@modules/boonex/twitter_connect/|std-pi.png');
+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_twitter', '{url_studio}module.php?name=bx_twitter', '', 'bx_twitter@modules/boonex/twitter_connect/|std-wi.png', '_bx_twitter', '', '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));
+

+ 9 - 0
modules/boonex/twitter_connect/install/sql/uninstall.sql

@@ -0,0 +1,9 @@
+
+DROP TABLE IF EXISTS `bx_twitter_accounts`;
+
+-- 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_twitter';
+

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

@@ -0,0 +1,18 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TwitterConnect Twitter Connect
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+require_once(BX_DIRECTORY_PATH_INC . 'profiles.inc.php');
+
+check_logged();
+
+BxDolRequest::processAsAction($GLOBALS['aModule'], $GLOBALS['aRequest']);
+
+/** @} */

BIN
modules/boonex/twitter_connect/template/images/icons/std-mi.png


BIN
modules/boonex/twitter_connect/template/images/icons/std-pi.png


BIN
modules/boonex/twitter_connect/template/images/icons/std-si.png


BIN
modules/boonex/twitter_connect/template/images/icons/std-wi.png