RomanL il y a 8 ans
Parent
commit
e43bf7df2e

+ 56 - 11
modules/boonex/attendant/classes/BxAttendantModule.php

@@ -9,6 +9,8 @@
  * @{
  */
 define('BX_ATTENDANT_ON_PROFILE_CREATION_METHOD', 'browse_recommended');
+define('BX_ATTENDANT_ON_PROFILE_CREATION_EVENT_AFTER_REGISTRATION', 'registration');
+define('BX_ATTENDANT_ON_PROFILE_CREATION_EVENT_AFTER_CONFIRMATION', 'confirmation');
 
 class BxAttendantModule extends BxDolModule
 {
@@ -51,6 +53,34 @@ class BxAttendantModule extends BxDolModule
         return $aResult;
     }
     
+    
+    /**
+     * @page service Service Calls
+     * @section bx_attendant Attendant
+     * @subsection bx_attendant-other Other
+     * @subsubsection bx_attendant-on-profile get_popup_with_recommended_on_event_show
+     * 
+     * @code bx_srv('bx_attendant', 'get_popup_with_recommended_on_event_show', [...]); @endcode
+     * 
+     * Get list of events for on_profile_creation show
+     * 
+     * @return an array with avaliable events. 
+     * 
+     * @see BxAttendantModule::serviceGetPopupWithRecommendedOnEventShow
+     */
+    /** 
+     * @ref bx_attendant-get_popup_with_recommended_on_event_show "get_popup_with_recommended_on_event_show"
+     */
+    public function serviceGetPopupWithRecommendedOnEventShow()
+    {
+        $aResult = array();
+        $aChoices = array(BX_ATTENDANT_ON_PROFILE_CREATION_EVENT_AFTER_CONFIRMATION, BX_ATTENDANT_ON_PROFILE_CREATION_EVENT_AFTER_REGISTRATION);
+        foreach($aChoices as $sChoice)
+            $aResult[$sChoice] = _t('_bx_attendant_popup_event_after_' . $sChoice);
+        
+        return $aResult;
+    }
+    
     /**
      * @page service Service Calls
      * @section bx_attendant Attendant
@@ -75,8 +105,11 @@ class BxAttendantModule extends BxDolModule
         $sRv = '';
         $aEvents = $this->_oDb->getEvents(array('type' => 'active_by_action_and_object_id', 'action' => 'view', 'object_id' => bx_get_logged_profile_id()));
         foreach($aEvents as $aEvent){
-            $sRv .= call_user_func_array(array($this, $aEvent['method']), array($aEvent['object_id']));
-            //$this->_oDb->setEventProcessed($aEvent['id']);
+            $oRv = call_user_func_array(array($this, $aEvent['method']), array($aEvent['object_id']));
+            if ($oRv !== false){
+                $sRv .= $oRv;
+                //$this->_oDb->setEventProcessed($aEvent['id']);
+            }
         }
         return $sRv;
     }
@@ -99,17 +132,29 @@ class BxAttendantModule extends BxDolModule
     public function processPopupWithRecommendedOnProfileAdd($iProfileId)
     {
         $sRv = '';
-        $aModules = explode(',', getParam('bx_attendant_on_profile_creation_modules'));
-        $aModulteData = array();
-        foreach($aModules as $sModuleName){
-            if(BxDolRequest::serviceExists($sModuleName, BX_ATTENDANT_ON_PROFILE_CREATION_METHOD)){
-                $aTmp = BxDolService::call($sModuleName, BX_ATTENDANT_ON_PROFILE_CREATION_METHOD, array('unit_view' => 'showcase', 'empty_message' => false, "ajax_paginate" => false));
-                if (isset($aTmp['content']))
-                    $aModulteData[$sModuleName] = $aTmp['content'];
+        $sEvent = getParam('bx_attendant_on_profile_event_list');
+        $oProfile = BxDolProfile::getInstance($iProfileId);
+        $oAccount = $oProfile ? $oProfile->getAccountObject() : null;
+        if ($sEvent == BX_ATTENDANT_ON_PROFILE_CREATION_EVENT_AFTER_REGISTRATION || ($sEvent == BX_ATTENDANT_ON_PROFILE_CREATION_EVENT_AFTER_CONFIRMATION  && $oAccount != null &&  $oAccount->isConfirmed())){
+            $aModules = explode(',', getParam('bx_attendant_on_profile_creation_modules'));
+            $aModulteData = array();
+            foreach($aModules as $sModuleName){
+                if(BxDolRequest::serviceExists($sModuleName, BX_ATTENDANT_ON_PROFILE_CREATION_METHOD)){
+                    $aTmp = BxDolService::call($sModuleName, BX_ATTENDANT_ON_PROFILE_CREATION_METHOD, array('unit_view' => 'showcase', 'empty_message' => false, "ajax_paginate" => false));
+                    if (isset($aTmp['content'])){
+                        $sTmp = $aTmp['content'];
+                        $sTmp = str_replace("bx_conn_action", 'bx_attendant_conn_action', $sTmp);
+                        $aModulteData[$sModuleName] = $sTmp;
+                    }
+                }
             }
+            if (count($aModulteData) > 0)
+                $sRv = $this->_oTemplate->popupWithRecommendedOnProfileAdd($aModulteData);
+            return $sRv;
+        }
+        else{
+            return false;
         }
-        $sRv = $this->_oTemplate->popupWithRecommendedOnProfileAdd($aModulteData);
-        return $sRv;
     }
 }
 

+ 1 - 1
modules/boonex/attendant/classes/BxAttendantTemplate.php

@@ -29,7 +29,7 @@ class BxAttendantTemplate extends BxBaseModGeneralTemplate
             array_push($aVars, array ('html' => $sModuleData, 'title' => $this->getStringValueByModuleOrDefault('_bx_attendant_popup_with_recommended_title_', $sModuleName) , 'description' => $this->getStringValueByModuleOrDefault('_bx_attendant_popup_with_recommended_description_', $sModuleName)));
         }
         $oBxBaseFunctions = BxBaseFunctions::getInstance();
-        return  $this->getJsCode('main') . $oBxBaseFunctions->transBox($this->sContainerId, $this->parseHtmlByName('popup_recommended.html', array ('bx_repeat:items' => $aVars)), true, true);
+        return  $this->getJsCode('main') . $oBxBaseFunctions->transBox($this->sContainerId, $this->parseHtmlByName('popup_recommended.html', array ('bx_repeat:items' => $aVars, 'button_text' => _t('_bx_attendant_popup_with_recommended_button_text'))), true, true);
     }
     
     public function getJsCode($sType, $aParams = array(), $bWrap = true)

+ 1 - 1
modules/boonex/attendant/install/config.php

@@ -18,7 +18,7 @@ $aConfig = array(
     'name' => 'bx_attendant',
     'title' => 'Attendant',
     'note' => 'Attendant module.',
-    'version' => '9.0.1.DEV',
+    'version' => '9.0.0.DEV',
     'vendor' => 'BoonEx',
     'help_url' => 'http://feed.una.io/?section={module_name}',
 

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

@@ -2,9 +2,12 @@
 <resources name="en" flag="gb" title="English">
 	<string name="_bx_attendant"><![CDATA[Attendant]]></string>
   <string name="_bx_attendant_adm_stg_cpt_type"><![CDATA[Attendant]]></string>
-  <string name="_bx_attendant_adm_stg_cpt_category_general"><![CDATA[General]]></string>
   <string name="_bx_attendant_adm_stg_cpt_category_on_profile_creation"><![CDATA[Popup with recomended profiles on profile add]]></string>
   <string name="_bx_attendant_adm_stg_on_profile_creation_modules_list"><![CDATA[Modules list]]></string>
+  <string name="_bx_attendant_adm_stg_on_profile_creation_event_list"><![CDATA[Show popup after]]></string>
   <string name="_bx_attendant_popup_with_recommended_title_default"><![CDATA[Default title]]></string>
   <string name="_bx_attendant_popup_with_recommended_description_default"><![CDATA[Default description]]></string>
+  <string name="_bx_attendant_popup_with_recommended_button_text"><![CDATA[Contunie]]></string>
+  <string name="_bx_attendant_popup_event_after_registration"><![CDATA[sign-up]]></string>
+  <string name="_bx_attendant_popup_event_after_confirmation"><![CDATA[account confirmation]]></string>
 </resources>

+ 2 - 3
modules/boonex/attendant/install/sql/enable.sql

@@ -8,13 +8,12 @@ VALUES('modules', @sName, '_bx_attendant_adm_stg_cpt_type', 'bx_attendant@module
 
 SET @iTypeId = LAST_INSERT_ID();
 
-INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `hidden`, `order`) VALUES(@iTypeId,  'bx_attendant_general', '_bx_attendant_adm_stg_cpt_category_general', 0, 1);
-
 INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `hidden`, `order`) VALUES(@iTypeId,  'bx_attendant_on_profile_creation', '_bx_attendant_adm_stg_cpt_category_on_profile_creation', 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_attendant_on_profile_creation_modules', '_bx_attendant_adm_stg_on_profile_creation_modules_list', '', 'list', 'a:2:{s:6:"module";s:12:"bx_attendant";s:6:"method";s:19:"get_profile_modules";}', '', '', '', 1);
+(@iCategoryId, 'bx_attendant_on_profile_creation_modules', '_bx_attendant_adm_stg_on_profile_creation_modules_list', '', 'list', 'a:2:{s:6:"module";s:12:"bx_attendant";s:6:"method";s:19:"get_profile_modules";}', '', '', '', 1),
+(@iCategoryId, 'bx_attendant_on_profile_event_list', '_bx_attendant_adm_stg_on_profile_creation_event_list', 'confirmation', 'select', 'a:2:{s:6:"module";s:12:"bx_attendant";s:6:"method";s:40:"get_popup_with_recommended_on_event_show";}', '', '', '', 2);
 
 -- INJECTION
 INSERT INTO `sys_injections`(`name`, `page_index`, `key`, `type`, `data`, `replace`, `active`) VALUES

+ 12 - 1
modules/boonex/attendant/js/main.js

@@ -44,4 +44,15 @@ BxAttendantPopupWithRecommendedOnProfileAdd.prototype.ReInitFlickity = function
 BxAttendantPopupWithRecommendedOnProfileAdd.prototype.Show = function () {
     var $this = oBxAttendantPopupWithRecommendedOnProfileAdd;
     $this.ReInitFlickity();
-}
+}
+
+BxAttendantPopupWithRecommendedOnProfileAdd.prototype.OnActionComplete = function (data, e) {
+    if (data.err == false) {
+        var $e = $(e);
+        $e.hide();
+    }
+}
+
+function bx_attendant_conn_action(e, sObj, sAction, iContentId, bConfirm, fOnComplete) {
+    return bx_conn_action(e, sObj, sAction, iContentId, bConfirm, oBxAttendantPopupWithRecommendedOnProfileAdd.OnActionComplete)
+}

+ 2 - 2
modules/boonex/attendant/template/popup_recommended.html

@@ -1,4 +1,4 @@
-<div class="bx-def-page-width bx-pwropa-container bx-def-padding bx-page-block-container">
+<div class="bx-def-page-width bx-pwropa-container bx-def-padding bx-page-block-container">
     <div class="bx-def-margin-bottom">
         <bx_repeat:items>
             <div class="bx-pwropa-item-container">
@@ -9,6 +9,6 @@
         </bx_repeat:items>
     </div>
     <div class="bx-pwropa-button-container">
-        <a class="bx-btn bx-btn-small bx-pwropa-button">Contunie</a>
+        <a class="bx-btn bx-btn-small bx-pwropa-button">__button_text__</a>
     </div>
 </div>