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

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

AntonLV 2 лет назад
Родитель
Сommit
ba690fff40

+ 5 - 0
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -1102,6 +1102,11 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
         $aInput['custom']['only_once'] = 1;
         
         $aInput['ajax_get_suggestions'] = BX_DOL_URL_ROOT . "modules/?r=" . $this->_oModule->_oConfig->getUri() . "/ajax_get_profiles";
+        if (bx_is_api()){
+            $aInput['ajax_get_suggestions'] = $this->_oModule->_oConfig->getName() . "/get_profiles&params[]=";
+            $aProfile = BxDolProfile::getInstance($aInput['value'])->getUnitAPI(0, ['template' => 'unit_wo_info']);
+            $aInput['value_data'] = [$aProfile['author_data']];
+        }
         return $this->genCustomInputUsernamesSuggestions($aInput);
     }
     

+ 11 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -324,6 +324,15 @@ class BxBaseModGeneralModule extends BxDolModule
         header('Content-Type:text/javascript; charset=utf-8');
         echo(json_encode($a));
     }
+    
+    public function serviceGetProfiles ($sParams)
+    {
+        $aOptions = json_decode($sParams, true);
+        if (!$sParams || !isset($aOptions['term']))
+            return [];
+
+        return BxDolService::call('system', 'profiles_search', array($aOptions['term']), 'TemplServiceProfiles');
+    }
 
     public function actionGetBrowsingFilters()
     {
@@ -432,6 +441,8 @@ class BxBaseModGeneralModule extends BxDolModule
             'EntityActions' => '',
             'EntitySocialSharing' => '',
             'MyEntriesActions' => '',
+            
+            'GetProfiles' => '',
         );
     }
 

+ 4 - 0
modules/base/groups/classes/BxBaseModGroupsFormEntry.php

@@ -103,6 +103,10 @@ class BxBaseModGroupsFormEntry extends BxBaseModProfileFormEntry
     protected function genCustomInputInitialMembers ($aInput)
     {
         $aInput['ajax_get_suggestions'] = BX_DOL_URL_ROOT . "modules/?r=" . $this->_oModule->_oConfig->getUri() . "/ajax_get_initial_members";
+        if (bx_is_api()){
+            $aInput['ajax_get_suggestions'] = $this->_oModule->_oConfig->getName() . "/get_initial_members&params[]=";
+        }
+
         return $this->genCustomInputUsernamesSuggestions($aInput);
     }
 }

+ 10 - 6
modules/base/groups/classes/BxBaseModGroupsFormsEntryHelper.php

@@ -47,28 +47,29 @@ class BxBaseModGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
         list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
 
         if(!$aContentInfo)
-            return $bErrorMsg ? MsgBox(_t('_sys_txt_error_entry_is_not_defined')) : '';
+            return $bErrorMsg ? ($this->_bIsApi ? [bx_api_get_msg('_sys_txt_error_entry_is_not_defined')] : MsgBox('_sys_txt_error_entry_is_not_defined')) : '';
 
         // check access
         if(($sMsg = $this->_oModule->$sCheckFunction($aContentInfo)) !== CHECK_ACTION_RESULT_ALLOWED)
-            return $bErrorMsg ? MsgBox($sMsg) : '';
+            return $bErrorMsg ? ($this->_bIsApi ? [bx_api_get_msg($sMsg)] : MsgBox($sMsg)) : '';
 
         // check and display form
         $oForm = $this->getObjectFormInvite($sDisplay);
+
         if(!$oForm)
-            return $bErrorMsg ? MsgBox(_t('_sys_txt_error_occured')) : '';
+            return $bErrorMsg ? ($this->_bIsApi ? [bx_api_get_msg('_sys_txt_error_occured')] : MsgBox(_t('_sys_txt_error_occured'))) : '';
 
         $oForm->initChecker($aContentInfo);
         if (!$oForm->isSubmittedAndValid())
-            return $oForm->getCode();
+            return $this->_bIsApi ? [bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['name' => $this->_oModule->getName(), 'request' => ['url' => '/api.php?r=' . $this->_oModule->getName() . '/entity_invite&params[]=' . $iContentId . '&params[]=' . $sDisplay, 'immutable' => true]]])] : $oForm->getCode();
 
         $this->onDataInviteBefore($aContentInfo[$CNF['FIELD_ID']], $aContentInfo);
 
         if (!$oForm->update($aContentInfo[$CNF['FIELD_ID']])) {
             if (!$oForm->isValid())
-                return $oForm->getCode();
+                return $this->_bIsApi ? [bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['name' => $this->_oModule->getName(), 'request' => ['url' => '/api.php?r=' . $this->_oModule->getName() . '/entity_invit&params[]=' . $iContentId . '&params[]=' . $sDisplay, 'immutable' => true]]])] : $oForm->getCode();
             else
-                return MsgBox(_t('_sys_txt_error_entry_update'));
+                return $this->_bIsApi ?  [bx_api_get_msg('_sys_txt_error_entry_update')] : MsgBox(_t('_sys_txt_error_entry_update'));
         }
 
         list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
@@ -81,6 +82,9 @@ class BxBaseModGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
         $this->_oModule->$sCheckFunction($aContentInfo, true);
 
         // Redirect
+         if (bx_is_api())
+            return [$this->redirectAfterEdit($aContentInfo)];
+        else
         $this->redirectAfterEdit($aContentInfo);
     }
 

+ 12 - 0
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -60,6 +60,17 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         echo(json_encode($a));
     }
     
+    public function serviceGetInitialMembers ($sParams)
+    {
+        $aOptions = json_decode($sParams, true);
+        if (!$sParams || !isset($aOptions['term']))
+            return [];
+        
+        $a = BxDolService::call('system', 'profiles_search', [$aOptions['term'], ['module' => $this->_oConfig->getName()]], 'TemplServiceProfiles');
+
+        return $a;
+    }
+    
     /**
      * Process Process Invitation
      */
@@ -211,6 +222,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
     {
         return array_merge(parent::serviceGetSafeServices(), [
             'GetQuestionnaire' => '',
+            'GetInitialMembers' => '',
         ]);
     }
 

+ 1 - 1
modules/base/profile/classes/BxBaseModProfileDb.php

@@ -75,7 +75,7 @@ class BxBaseModProfileDb extends BxBaseModGeneralDb
         
         $sWhere = '';
         foreach ($this->_oConfig->CNF['FIELDS_QUICK_SEARCH'] as $sField) {
-        	$aBindings[$sField] = $sTerm . '%';
+        	$aBindings[$sField] = '%' . $sTerm . '%';
 
             $sWhere .= " OR `c`.`$sField` LIKE :" . $sField;
         }

+ 5 - 0
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -370,6 +370,10 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         foreach ($a as $r) {
             $oProfile = BxDolProfile::getInstance($r['profile_id']);
 
+            if (bx_is_api()){
+                $aRet[] = $oProfile->getUnitAPI(0, ['template' => 'unit_wo_info']);
+            }
+            else{
             $aRet[] = array (
             	'label' => $this->serviceProfileName($r['content_id']), 
                 'value' => $r['profile_id'], 
@@ -378,6 +382,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
                 'unit' => $oProfile->getUnit(0, ['template' => ['name' => 'unit_wo_info', 'size' => 'icon']])
             );
         }
+        }
 
         return $aRet;
     }

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

@@ -1751,6 +1751,7 @@
     <string name="_adm_stg_cpt_option_sys_api_cookie_samesite"><![CDATA[Cookies SameSite attribute]]></string>
     <string name="_adm_stg_cpt_option_sys_api_menu_top"><![CDATA[Top Menu]]></string>
     <string name="_adm_stg_cpt_option_sys_api_comments_flat"><![CDATA[Flat comments]]></string>
+    <string name="_adm_stg_cpt_option_sys_api_comments_modal"><![CDATA[Comments in modal]]></string>
     <string name="_adm_stg_cpt_option_sys_api_search_sections"><![CDATA[Search sections]]></string>
     <string name="_adm_stg_cpt_option_sys_api_extended_units"><![CDATA[Use extended units]]></string>
     <string name="_adm_stg_cpt_option_sys_api_conn_in_prof_units"><![CDATA[Use connections lists in profiles/groups units]]></string>

+ 11 - 0
template/scripts/BxBaseFormView.php

@@ -369,6 +369,12 @@ class BxBaseFormView extends BxDolForm
                     $aInput['values_src'] = '';
                 }
                 
+                if (isset($aInput['type']) && 'custom' == $aInput['type']){
+                    $sCustomMethod = 'genCustomInput' . $this->_genMethodName($aInput['name']);
+                    if (method_exists($this, $sCustomMethod))
+                         $aInput = $this->$sCustomMethod($aInput);
+                }
+                
                 if (isset($aInput['type']) && 'block_header' == $aInput['type']){
                     $aInput['name'] = $key;
                 }
@@ -1699,6 +1705,11 @@ BLAH;
             $aTmplVarsInputText['input'] = $this->genInputStandard($aInputText);
         }
 
+       if (bx_is_api()){
+           $aInput['type'] = 'initial_members';
+           return $aInput;
+       }
+        
         $this->addCssJsUi();
 
         $sJsCode = '';