AntonLV %!s(int64=10) %!d(string=hai) anos
pai
achega
0fa5f6a2f3

+ 21 - 0
modules/boonex/invites/classes/BxInvConfig.php

@@ -52,6 +52,19 @@ class BxInvConfig extends BxBaseModGeneralConfig
         $this->_bRequestInvite = true;
         $this->_sRequestsEmail = '';
         $this->_bRegistrationByInvitation = true;
+
+        $this->_aJsClass = array(
+        	'main' => 'BxInvMain',
+        );
+        $this->_aJsObjects = array(
+            'main' => 'oInvMain',
+        );
+
+        $sHtmlPrefix = str_replace('_', '-', $this->_sName);
+        $this->_aHtmlIds = array(
+        	'link_popup' => $sHtmlPrefix . '-link-popup',
+        	'link_input' => $sHtmlPrefix . '-link-input',
+        );
     }
 
     public function init(&$oDb)
@@ -96,6 +109,14 @@ class BxInvConfig extends BxBaseModGeneralConfig
     {
         return $this->_bRegistrationByInvitation;
     }
+
+	public function getHtmlIds($sKey = '')
+    {
+        if(empty($sKey))
+            return $this->_aHtmlIds;
+
+        return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
+    }
 }
 
 /** @} */

+ 58 - 4
modules/boonex/invites/classes/BxInvModule.php

@@ -26,6 +26,44 @@ class BxInvModule extends BxDolModule
         $this->_oConfig->init($this->_oDb);
     }
 
+	/**
+     * ACTION METHODS
+     */
+	function actionGetLink()
+    {
+    	$iProfileId = $this->getProfileId();
+		$iAccountId = $this->getAccountId($iProfileId);
+
+        $mixedAllowed = $this->isAllowedInvite($iProfileId);
+        if($mixedAllowed !== true)
+        	return $this->_echoResultJson(array('message' => $mixedAllowed));
+
+	    if(!isAdmin($iAccountId)) {
+			$iInvited = (int)$this->_oDb->getInvites(array('type' => 'count_by_account', 'value' => $iAccountId));
+			if(($this->_oConfig->getCountPerUser() - $iInvited) <= 0)
+				return $this->_echoResultJson(array('message' => _t('_bx_invites_err_limit_reached')));
+		}
+
+    	$oKeys = BxDolKey::getInstance();
+    	if(!$oKeys)
+    		return  $this->_echoResultJson(array('message' => _t('_bx_invites_err_not_available')));  		
+
+    	$sKey = $oKeys->getNewKey(false, $this->_oConfig->getKeyLifetime());
+
+    	$oForm = $this->getFormObjectInvite();
+    	$oForm->insert(array(
+			'account_id' => $iAccountId,
+			'profile_id' => $iProfileId,
+			'key' => $sKey,
+			'email' => '',
+			'date' => time()
+		));
+
+        $this->_echoResultJson(array('popup' => $this->_oTemplate->getLinkPopup(
+        	$this->getJoinLink($sKey)
+        )));
+    }
+
     /**
      * SERVICE METHODS
      */
@@ -192,7 +230,6 @@ class BxInvModule extends BxDolModule
 		if(!$oKeys || !in_array($sType, array(BX_INV_TYPE_FROM_MEMBER, BX_INV_TYPE_FROM_SYSTEM)))
 			return false;
 
-		$sKeyCode = $this->_oConfig->getKeyCode();
 		$iKeyLifetime = $this->_oConfig->getKeyLifetime();
 
 		$sEmailTemplate = '';
@@ -209,8 +246,6 @@ class BxInvModule extends BxDolModule
 		if(empty($oForm))
 			$oForm = $this->getFormObjectInvite();
 
-		$sJoinUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account');
-
 		$aMessage = BxDolEmailTemplates::getInstance()->parseTemplate($sEmailTemplate, array(
 			'text' => $sText
 		), $iAccountId, $iProfileId);
@@ -228,10 +263,11 @@ class BxInvModule extends BxDolModule
 					continue;
 
 				$sKey = $oKeys->getNewKey(false, $iKeyLifetime);
-				if(sendMail($sEmail, $aMessage['Subject'], $aMessage['Body'], 0, array('join_url' => bx_append_url_params($sJoinUrl, array($sKeyCode => $sKey))), BX_EMAIL_SYSTEM)) {
+				if(sendMail($sEmail, $aMessage['Subject'], $aMessage['Body'], 0, array('join_url' => $this->getJoinLink($sKey)), BX_EMAIL_SYSTEM)) {
 					$oForm->insert(array(
 						'account_id' => $iAccountId,
 						'profile_id' => $iProfileId,
+						'key' => $sKey,
 						'email' => $sEmail,
 						'date' => $iDate
 					));
@@ -314,6 +350,24 @@ class BxInvModule extends BxDolModule
         bx_import('FormCheckerHelper', $this->_aModule);
         return BxDolForm::getObjectInstance($this->_oConfig->getObject('form_invite'), $sDisplay);
     }
+
+	protected function getJoinLink($sKey)
+	{
+		$sKeyCode = $this->_oConfig->getKeyCode();
+
+		$sJoinUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account');
+		return bx_append_url_params($sJoinUrl, array($sKeyCode => $sKey));
+	}
+
+	protected function _echoResultJson($a, $isAutoWrapForFormFileSubmit = false)
+    {
+        header('Content-type: text/html; charset=utf-8');
+
+        $s = json_encode($a);
+        if ($isAutoWrapForFormFileSubmit && !empty($_FILES))
+            $s = '<textarea>' . $s . '</textarea>';
+        echo $s;
+    }
 }
 
 /** @} */

+ 40 - 4
modules/boonex/invites/classes/BxInvTemplate.php

@@ -9,13 +9,25 @@
  * @{
  */
 
-class BxInvTemplate extends BxDolModuleTemplate
+class BxInvTemplate extends BxBaseModGeneralTemplate
 {
     function __construct(&$oConfig, &$oDb)
     {
         parent::__construct($oConfig, $oDb);
     }
 
+	public function getCssJs()
+    {
+        $this->addCss(array(
+            'main.css',
+        ));
+
+        $this->addJs(array(
+        	'clipboard.min.js',
+            'main.js'
+        ));
+    }
+
     public function getBlockRequestText($aRequest)
     {
     	return $this->parseHtmlByName('request_text.html', array(
@@ -38,11 +50,13 @@ class BxInvTemplate extends BxDolModuleTemplate
 
         $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_INVITE']);
 
-        $this->addCss(array('main.css'));
+        $this->getCssJs();
     	return $this->parseHtmlByName('block_invite.html', array(
     		'style_prefix' => $this->_oConfig->getPrefix('style'),
+    		'js_object' => $this->_oConfig->getJsObject('main'),
     		'text' => _t('_bx_invites_txt_invite_block_text', $sInvitesRemain),
-    		'url' => $sUrl
+    		'url' => $sUrl,
+    		'js_code' => $this->getJsCode('main')
     	));
     }
 
@@ -50,7 +64,7 @@ class BxInvTemplate extends BxDolModuleTemplate
     {
         $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_REQUEST']);
 
-    	$this->addCss(array('main.css'));
+    	$this->getCssJs();
     	return $this->parseHtmlByName('block_request.html', array(
     		'style_prefix' => $this->_oConfig->getPrefix('style'),
     		'text' => _t('_bx_invites_txt_request_block_text'),
@@ -62,6 +76,28 @@ class BxInvTemplate extends BxDolModuleTemplate
     		)
     	));
     }
+
+	public function getLinkPopup($sLink)
+    {
+        $sId = $this->_oConfig->getHtmlIds('link_popup');
+        $sTitle = _t('_bx_invites_txt_link_popup_title');
+        $sContent = $this->parseHtmlByName('popup_link.html', array(
+			'style_prefix' => $this->_oConfig->getPrefix('style'),
+        	'html_id_link' => $this->_oConfig->getHtmlIds('link_input'),
+        	'link' => $sLink
+        ));
+
+    	return BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $sContent, true);
+    }
+
+	public function getJsCode($sType, $aParams = array(), $bWrap = true)
+    {
+        $aParams = array_merge(array(
+            'aHtmlIds' => $this->_oConfig->getHtmlIds()
+        ), $aParams);
+
+        return parent::getJsCode($sType, $aParams, $bWrap);
+    }
 }
 
 /** @} */

+ 4 - 1
modules/boonex/invites/install/langs/en.xml

@@ -108,11 +108,14 @@
 
 
 	<!-- Common Texts -->
+	<string name="_bx_invites_txt_link_popup_title"><![CDATA[Invitation Link]]></string>
 	<string name="_bx_invites_txt_invite_block_text"><![CDATA[You can invite your friends to join. You have <b>{0}</b> invites to share.]]></string>
 	<string name="_bx_invites_txt_request_block_text"><![CDATA[Registration is by invitation only.]]></string>
 	<string name="_bx_invites_txt_unlimited"><![CDATA[unlimited]]></string>
 	
-	<string name="_bx_invites_btn_invite"><![CDATA[Invite]]></string>
+	<string name="_bx_invites_btn_invite_email"><![CDATA[Invite By Email]]></string>
+	<string name="_bx_invites_btn_invite_link"><![CDATA[Get Invitation Link]]></string>
+	<string name="_bx_invites_btn_copy"><![CDATA[Copy]]></string>
 	<string name="_bx_invites_btn_request"><![CDATA[Request Invitation]]></string>
 	<string name="_bx_invites_msg_invitation"><![CDATA[Hello! This site might be interesting for you.]]></string>
 	<string name="_bx_invites_msg_invitation_sent"><![CDATA[Invitation message was sent to {0} email addresses from the list.]]></string>

+ 1 - 0
modules/boonex/invites/install/sql/install.sql

@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS `bx_inv_invites` (
   `id` int(11) NOT NULL auto_increment,
   `account_id` int(11) collate utf8_unicode_ci NOT NULL,
   `profile_id` int(11) collate utf8_unicode_ci NOT NULL,
+  `key` varchar(128) collate utf8_unicode_ci NOT NULL,
   `email` varchar(128) collate utf8_unicode_ci NOT NULL,
   `date` int(11) NOT NULL default '0',
   PRIMARY KEY  (`id`)

+ 74 - 0
modules/boonex/invites/js/main.js

@@ -0,0 +1,74 @@
+function BxInvMain(oOptions) {
+	this._sActionsUri = oOptions.sActionUri;
+    this._sActionsUrl = oOptions.sActionUrl;
+    this._sObjName = oOptions.sObjName == undefined ? 'oInvMain' : oOptions.sObjName;
+    this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
+    this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
+}
+
+BxInvMain.prototype.showLinkPopup = function(oElement) {
+    var $this = this;
+
+    this.loadingInButton(oElement, true);
+
+    jQuery.get(
+        this._sActionsUrl + 'get_link/',
+        this._getDefaultData(),
+        function(oData) {
+        	$this.loadingInButton(oElement, false);
+
+        	if(oData && oData.popup != undefined) {
+        		var oPopup = $(oData.popup);
+        		var sPopupId = oPopup.attr('id');
+        		var oClipboard = null;
+
+            	$('#' + sPopupId).remove();
+                oPopup.hide().prependTo('body').dolPopup({
+                    fog: {
+        				color: '#fff',
+        				opacity: .7
+                    },
+                    onShow: function () {
+                    	oClipboard = new Clipboard('#' + $this._aHtmlIds['link_popup'] + ' .bx-btn[name = "clipboard"]', {
+                    	    target: function(oTrigger) {
+                    	        return $('#' + sPopupId).find('[name = "link"]').get(0);
+                    	    }
+                    	});
+                    	oClipboard.on('success', function(oObject) {
+                    		$this.hideLinkPopup();
+                    	});
+                    },
+                    onHide: function () {
+                    	if(oClipboard)
+                    		oClipboard.destroy();
+                    }
+                });
+        	}
+
+        	if(oData && oData.message != undefined)
+        		alert(oData.message);
+        },
+        'json'
+    );
+};
+
+BxInvMain.prototype.hideLinkPopup = function() {
+	$('#' + this._aHtmlIds['link_popup']).dolPopupHide();	
+};
+
+BxInvMain.prototype.loadingInButton = function(e, bShow) {
+	if($(e).length)
+		bx_loading_btn($(e), bShow);
+	else
+		bx_loading($('body'), bShow);	
+};
+
+BxInvMain.prototype._loading = function(e, bShow) {
+	var oParent = $(e).length ? $(e) : $('body'); 
+	bx_loading(oParent, bShow);
+};
+
+BxInvMain.prototype._getDefaultData = function () {
+	var oDate = new Date();
+    return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()});
+};

+ 9 - 5
modules/boonex/invites/template/block_invite.html

@@ -1,6 +1,10 @@
 <div class="__style_prefix__-invite-text">__text__</div>
-<div class="__style_prefix__-invite-btn bx-def-margin-top">
-	<button type="button" onclick="javascript: window.open('__url__','_self');" class="bx-btn">
-		<bx_text:_bx_invites_btn_invite />
-	</button>
-</div>
+<div class="__style_prefix__-invite-btn bx-def-margin-sec-top">
+	<a class="bx-btn bx-def-margin-thd" href="__url__">
+		<bx_text:_bx_invites_btn_invite_email />
+	</a>
+	<a class="bx-btn bx-def-margin-thd" href="javascript:void(0)" onclick="javascript:__js_object__.showLinkPopup(this)">
+		<bx_text:_bx_invites_btn_invite_link />
+	</a>
+</div>
+__js_code__

+ 11 - 0
modules/boonex/invites/template/css/main.css

@@ -7,6 +7,17 @@ div.bx-inv-invite-btn .bx-btn {
 	display: inline-block;
 }
 
+
+/*--- Invitation Link popup ---*/
+div.bx-inv-link-actions {
+	text-align: center;
+}
+div.bx-inv-link-actions .bx-btn {
+	float: none;
+	display: inline-block;
+}
+
+
 /*--- Request Invite block ---*/
 div.bx-inv-request-btn  {}
 

+ 13 - 0
modules/boonex/invites/template/popup_link.html

@@ -0,0 +1,13 @@
+<div class="__style_prefix__-link bx-def-padding">
+	<div class="__style_prefix__-link-input bx-form-input-wrapper bx-form-input-wrapper-text">
+		<input id="__html_id_link__" class="bx-def-font-inputs bx-form-input-text" type="text" name="link" value="__link__" />
+	</div>
+	<div class="__style_prefix__-link-actions bx-def-margin-top bx-clearfix">
+		<button class="bx-btn bx-def-margin-thd" type="button" name="clipboard">
+			<bx_text:_bx_invites_btn_copy />
+		</button>
+		<button class="bx-btn bx-def-margin-thd" type="button" onclick="javascript:$('.bx-popup-applied:visible').dolPopupHide()">
+			<bx_text:_Cancel />
+		</button>
+	</div>
+</div>

+ 5 - 2
modules/boonex/russian/data/langs/bx_invites/ru.xml

@@ -108,11 +108,14 @@
 
 
 	<!-- Common Texts -->
+	<string name="_bx_invites_txt_link_popup_title"><![CDATA[Пригласительная ссылка]]></string>
 	<string name="_bx_invites_txt_invite_block_text"><![CDATA[Вы можете пригласить друзей для регистрации на сайте. У Вас осталось <b>{0}</b> приглашений.]]></string>
 	<string name="_bx_invites_txt_request_block_text"><![CDATA[Регистрация только по приглашению.]]></string>
 	<string name="_bx_invites_txt_unlimited"><![CDATA[неограниченное количество]]></string>
-	
-	<string name="_bx_invites_btn_invite"><![CDATA[Пригласить]]></string>
+
+	<string name="_bx_invites_btn_invite_email"><![CDATA[Пригласить по эл. адресу]]></string>
+	<string name="_bx_invites_btn_invite_link"><![CDATA[Пригласительная ссылка]]></string>
+	<string name="_bx_invites_btn_copy"><![CDATA[Скопировать]]></string>
 	<string name="_bx_invites_btn_request"><![CDATA[Запросить приглашение]]></string>
 	<string name="_bx_invites_msg_invitation"><![CDATA[Привет! Этот сайт может оказаться интересным для Вас.]]></string>
 	<string name="_bx_invites_msg_invitation_sent"><![CDATA[Пригласительное сообщение послано по {0} эл. адресам из списка.]]></string>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 6 - 0
plugins_public/clipboard.min.js


+ 5 - 5
template/css/common.css

@@ -404,6 +404,10 @@ body > .bx-popup-wrapper {
     -moz-transition: background-color 0.2s ease-in-out;
     -o-transition: background-color 0.2s ease-in-out;
     transition: background-color 0.2s ease-in-out;
+
+    text-transform: uppercase;
+    font-size:1rem;
+    color:#fff;
 }
 .bx-btn:active,
 .bx-btn:hover {	
@@ -416,11 +420,7 @@ body > .bx-popup-wrapper {
 button.bx-btn,
 input.bx-btn {
 	padding-top:0px;
-	padding-bottom:0px;
-
-	text-transform: uppercase;
-    font-size:1rem;
-    color:#fff;
+	padding-bottom:0px;    
 }
 
 .bx-btn img {

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio