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

#4558 - Build-in API support (recommendation)

roman.lesnikov@gmail.com 2 лет назад
Родитель
Сommit
464fe967d1

+ 6 - 0
inc/classes/BxDolProfile.php

@@ -277,6 +277,12 @@ class BxDolProfile extends BxDolFactory implements iBxDolProfile
         bx_alert('profile', 'profile_name', $iProfileId, 0, array('info' => $aInfo, 'display_name' => &$sDisplayName));
         return $sDisplayName;
     }
+    
+    public function getSettings($iProfileId = 0)
+    {
+        $aInfo = $this->getInfo($iProfileId);
+        return  BxDolService::call($aInfo['type'], 'profile_settings', array($aInfo['content_id']));
+    }
 
     /**
      * Get profile url

+ 19 - 1
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -508,7 +508,25 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         
         return $sDisplayName;
     }
-
+    
+    public function serviceProfileSettings ($iContentId)
+    {
+        if (!$iContentId)
+            return false;
+        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        if (!$aContentInfo)
+            return false;
+        
+       if (isset($aContentInfo['settings']))
+           return json_decode($aContentInfo['settings']);
+    }
+    
+    public function serviceProfileSettingsSet ($iContentId, $oValue)
+    {
+        $CNF = $this->_oConfig->CNF;
+        $this->_oDb->updateEntriesBy(['settings' => json_encode($oValue)], [$CNF['FIELD_ID'] => $iContentId]);
+    }
+  
     public function serviceProfileCreateUrl ($bAbsolute = true)
     {
     	$CNF = $this->_oConfig->CNF;

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

@@ -31,6 +31,7 @@ CREATE TABLE IF NOT EXISTS `bx_organizations_data` (
   `allow_post_to` varchar(16) NOT NULL DEFAULT '5',
   `allow_contact_to` varchar(16) NOT NULL DEFAULT '3',
   `status` enum('active','awaiting','hidden') NOT NULL DEFAULT 'active',
+  `settings` text NOT NULL,
   PRIMARY KEY (`id`),
   FULLTEXT KEY `search_fields` (`org_name`,`org_desc`)
 );

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

@@ -30,6 +30,7 @@ CREATE TABLE IF NOT EXISTS `bx_persons_data` (
   `allow_view_to` varchar(16) NOT NULL DEFAULT '3',
   `allow_post_to` varchar(16) NOT NULL DEFAULT '5',
   `allow_contact_to` varchar(16) NOT NULL DEFAULT '3',
+  `settings` text NOT NULL,
   PRIMARY KEY (`id`),
   FULLTEXT KEY `search_fields` (`fullname`,`description`)
 );

+ 1 - 0
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -964,6 +964,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             'Repost' => '',
             'Delete' => '',
             'GetEditForm' => '',
+            'GetLiveUpdate' => ''
         ));
     }
 

+ 1 - 0
template/scripts/BxBasePage.php

@@ -495,6 +495,7 @@ class BxBasePage extends BxDolPage
                 'display_name' => $o->getDisplayName(),
                 'url' => bx_api_get_relative_url($o->getUrl()),
                 'avatar' => $o->getAvatar(),
+                'settings' => $o->getSettings(),
                 'info' => $o->getInfo(),
                 'notifications' => 0,
                 'cart' => 0,

+ 17 - 0
template/scripts/BxBaseServiceProfiles.php

@@ -1085,6 +1085,23 @@ class BxBaseServiceProfiles extends BxDol
         return BxDolContentFilter::getInstance()->isEnabled();
     }
 
+    public function serviceUpdateSettings($iProfileId = false, $sSettings)
+    {
+        $oProfile = BxDolProfile::getInstance($iProfileId);
+        if(!$oProfile)
+            return '';
+        
+        $sModule = $oProfile->getModule();
+        
+        $sMethod = 'profile_settings_set';
+        echo $sModule.BxDolRequest::serviceExists($sModule, $sMethod).$sMethod;
+        if(!BxDolRequest::serviceExists($sModule, $sMethod))
+            return 'aaa';
+        echo $sMethod;
+        BxDolService::call($sModule, $sMethod, array($oProfile->getContentId(), json_decode( $sSettings)));
+    }
+
+    
     protected function _getIcon ($sIcon)
     {
         return BxTemplFunctions::getInstance()->getIcon($sIcon);

+ 2 - 1
template/scripts/BxBaseServices.php

@@ -79,7 +79,8 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
             'BrowseSubscribedMe' => 'BxBaseServiceProfiles',
             'BrowseSubscriptions' => 'BxBaseServiceProfiles',
             'BrowseMembers' => 'BxBaseServiceProfiles',
-
+            'UpdateSettings' => 'BxBaseServiceProfiles',
+            
             'GetChartGrowth' => 'BxBaseChartServices',
             'GetChartStats' => 'BxBaseChartServices',