Преглед на файлове

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

AntonLV преди 1 година
родител
ревизия
0de5d2ca05

+ 4 - 0
inc/classes/BxDolCmts.php

@@ -2534,6 +2534,10 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
             $oMenuManage->setCmtsData($this, $iCmtId, $aBp);
 
             $aData = $this->getCommentSimple($iCmtId);
+            
+            bx_import('BxDolEmbed');
+            $aData['embed'] = bx_linkify_embeded($aData['cmt_text']);
+            
             $aData = array_merge($this->getDataAPI($aData), [
                 'menu_actions' => $oMenuActions->getCodeAPI(),
                 'menu_manage' => $oMenuManage->getShortCodeAPI(),

+ 36 - 0
modules/base/profile/classes/BxBaseModProfileMenuViewActionsAll.php

@@ -123,6 +123,42 @@ class BxBaseModProfileMenuViewActionsAll extends BxBaseModGeneralMenuViewActions
         return $this->_getMenuItemByNameActions($aItem);
     }
 
+    protected function _getMenuItemProfileSetBadges($aItem)
+    {
+        $aItem = $this->_getMenuItemByNameActions($aItem);
+        if (!$aItem || !$this->_bIsApi)
+            return $aItem;
+        
+        $oBadges = BxDolBadges::getInstance();
+		$aBadges = $oBadges->getData(array('type' => 'by_module&object', 'object_id' => $this->_iContentId, 'module' => $this->_sModule));
+        
+        $aBadgesList = array_map(function ($aBadge) {
+            return [
+                "value" => $aBadge['id'],
+                "label" => $aBadge['text']
+            ];
+        }, $aBadges);
+        
+       $filteredBadges = array_filter($aBadges, function ($aBadge) {
+            return isset($aBadge['badge_id']);
+       });
+
+        $badgeIds = array_values(array_map(function ($aBadge2) {
+            return $aBadge2['id'];
+        }, $filteredBadges));
+
+        return array_merge($aItem, [
+            'display_type' => 'callback',
+            'content_type' => 'badges',
+            'data' => [
+                'content_id' => $this->_iContentId, 
+                'module' => $this->_sModule, 
+                'values' => $aBadgesList, 
+                'value' => $badgeIds
+            ]
+        ]);
+    }
+    
     protected function _getMenuItemProfileSetAclLevel($aItem)
     {
         $aItem = $this->_getMenuItemByNameActions($aItem);

+ 0 - 5
modules/boonex/courses/classes/BxCoursesMenuViewActionsAll.php

@@ -55,11 +55,6 @@ class BxCoursesMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
     {
         return $this->_getMenuItemByNameActionsMore($aItem);
     }
-    
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 0 - 5
modules/boonex/events/classes/BxEventsMenuViewActionsAll.php

@@ -88,11 +88,6 @@ class BxEventsMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
         }
         return $a;
     }
-
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 0 - 5
modules/boonex/groups/classes/BxGroupsMenuViewActionsAll.php

@@ -55,11 +55,6 @@ class BxGroupsMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
     {
         return $this->_getMenuItemByNameActionsMore($aItem);
     }
-
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 0 - 5
modules/boonex/jobs/classes/BxJobsMenuViewActionsAll.php

@@ -60,11 +60,6 @@ class BxJobsMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
     {
         return $this->_getMenuItemByNameActionsMore($aItem);
     }
-
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 0 - 5
modules/boonex/organizations/classes/BxOrgsMenuViewActionsAll.php

@@ -60,11 +60,6 @@ class BxOrgsMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
     {
         return $this->_getMenuItemByNameActionsMore($aItem);
     }
-    
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 0 - 5
modules/boonex/persons/classes/BxPersonsMenuViewActionsAll.php

@@ -45,11 +45,6 @@ class BxPersonsMenuViewActionsAll extends BxBaseModProfileMenuViewActionsAll
     {
         return $this->_getMenuItemByNameActionsMore($aItem);
     }
-    
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 0 - 5
modules/boonex/spaces/classes/BxSpacesMenuViewActionsAll.php

@@ -55,11 +55,6 @@ class BxSpacesMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
     {
         return $this->_getMenuItemByNameActionsMore($aItem);
     }
-
-    protected function _getMenuItemProfileSetBadges($aItem)
-    {
-        return $this->_getMenuItemByNameActions($aItem);
-    }
 }
 
 /** @} */

+ 22 - 9
scripts/manage.php

@@ -20,6 +20,7 @@ class BxDolManageCmd
     protected $_sPathToUna;
     protected $_aSiteConfig;
     protected $_isQuiet = false;
+    protected $_isSkipFilesOperation = false;
     protected $_aReturnCodes = array(
         'success' => array ('code' => 0, 'msg' => 'Success.'),
         'una not found' => array ('code' => 1, 'msg' => 'UNA wasn\'t found in the specified path: '),
@@ -46,7 +47,7 @@ class BxDolManageCmd
     {
         // set neccessary options
 
-        $a = getopt('hqc:u:p:o:', $this->getOptions());
+        $a = getopt('hqic:u:p:o:', $this->getOptions());
 
         if (isset($a['h']))
             $this->finish($this->_aReturnCodes['success']['code'], $this->getHelp());
@@ -54,6 +55,9 @@ class BxDolManageCmd
         if (isset($a['q']))
             $this->_isQuiet = true;
 
+        if (isset($a['i']))
+            $this->_isSkipFilesOperation = true;
+
         if (isset($a['u']))
             $this->_sPathToUna = $a['u'];
 
@@ -96,9 +100,9 @@ class BxDolManageCmd
         $s .= str_pad("\t -q", 35) . "Quiet\n";
         $s .= str_pad("\t -u", 35) . "Path to UNA\n";
         $s .= str_pad("\t -c", 35) . "Command to run:\n";
+        $s .= str_pad("\t -i", 35) . "Skip files oprations, such copying and deleting when performing update commands\n";
         $s .= str_pad("\t", 39) . "- update - options:\n";
         $s .= str_pad("\t", 43) . "'ignore_version_check' to ignore version comparison in DB and files\n";
-        $s .= str_pad("\t", 43) . "'skip_files_op' skip files oprations, such copying and deleting\n";
         $s .= str_pad("\t", 39) . "- check_update - no options\n";
         $s .= str_pad("\t", 39) . "- update_modules - options:\n";
         $s .= str_pad("\t", 43) . "comma separated list of modules paths (ex: 'boonex/ads,boonex/wiki')\n";
@@ -121,9 +125,15 @@ class BxDolManageCmd
 
         $s .= "Examples:\n";
         $s .= "\tCheck if update is available:\n";
+        $s .= "\tphp ./manage.php -u ../../unafolder -c check_update\n\n";
+        $s .= "\tCheck if update is available using custom DB connection params:\n";
         $s .= "\tphp ./manage.php -u ../../unafolder --db_name=unadb --db_user=root --db_host=mysql --db_password=root -c check_update\n\n";
+        $s .= "\tUpdate system files by ignoring version check and skip files copying, it's necessary when the source code is maintained using VCS:\n";
+        $s .= "\tphp ./manage.php -u ../../unafolder --db_name=unadb --db_user=root --db_host=mysql --db_password=root -c update -i -o ignore_version_check\n\n";
         $s .= "\tCheck if updates for modules are available:\n";
         $s .= "\tphp ./manage.php -u ../../unafolder --db_name=unadb --db_user=root --db_host=mysql --db_password=root -c check_modules_updates\n\n";
+        $s .= "\tUpdate Nexus and Albums modules by ignoring files copying operation, update must be already exists in module's 'updates' folder, to update paid modules authorize the request first in Studio > Apps > Purchases:\n";
+        $s .= "\tphp ./manage.php -u ../../unafolder --db_name=unadb --db_user=root --db_host=mysql --db_password=root -c update_modules -i -o bx_nexus,bx_albums\n\n";
         $s .= "\tInstall Ads and Albums modules:\n";
         $s .= "\tphp ./manage.php -u ../../unafolder --db_name=unadb --db_user=root --db_host=mysql --db_password=root -c install_modules -o boonex/ads,boonex/albums\n\n";
 
@@ -230,7 +240,7 @@ class BxDolManageCmd
         $oController = new BxDolUpgradeController();
         if ($oController->setMaintenanceMode(true)) {
             $sFolder = $oController->getAvailableUpgrade();
-            if ($sFolder && $oController->runUpgrade($sFolder, in_array('ignore_version_check', $aOptions), in_array('skip_files_op', $aOptions))) {
+            if ($sFolder && $oController->runUpgrade($sFolder, in_array('ignore_version_check', $aOptions), $this->_isSkipFilesOperation)) {
                 setParam('sys_revision', getParam('sys_revision') + 1);
                 @bx_rrmdir($sUpgradeDir);
             }
@@ -254,11 +264,14 @@ class BxDolManageCmd
         $s = '';
         foreach ($a as $r) {
             $s .= str_pad($r['name'], 20) . str_pad($r['file_version'], 12) . str_pad($r['file_version_to'], 12);
+            $sDir = '';
             foreach ($aDownloaded as $j) {
                 if ($j['module_name'] == $r['name'])
-                    $s .= $j['dir'];
+                    $sDir .= $j['dir'];
             }
-            $s .= "\n";
+            if (!$sDir)
+                $sDir = "Downloaded update wasn't found";
+            $s .= "$sDir\n";
         }
         $this->finish($this->_aReturnCodes['success']['code'], trim($s));
     }
@@ -279,10 +292,10 @@ class BxDolManageCmd
         foreach ($a as $r) {
             if (!in_array($r['module_name'], $aModules) && !in_array($r['module_dir'], $aModules))
                 continue;
-            $aRes = BxDolStudioInstallerUtils::getInstance()->perform($r['dir'], 'update', [
-                'module_name' => $r['module_name'],
-                'disabled_actions' => ['update_files'],
-            ]);
+            $aParams = ['module_name' => $r['module_name']];
+            if ($this->_isSkipFilesOperation)
+                $aParams['disabled_actions'] = ['update_files'];
+            $aRes = BxDolStudioInstallerUtils::getInstance()->perform($r['dir'], 'update', $aParams);
 
             $s .= str_pad($r['module_name'], 20);
             if (!isset($aRes['code']) || $aRes['code'] !== BX_DOL_STUDIO_IU_RC_SUCCESS) {

+ 28 - 0
template/scripts/BxBaseServiceProfiles.php

@@ -919,6 +919,34 @@ class BxBaseServiceProfiles extends BxDol
         return $sCode;
     }
     
+    public function serviceSetBadges($iContentId, $sBadgesIds, $sModule)
+    {
+        $aSelectedBadges = explode(",", $sBadgesIds);
+        
+        $iPerformerId = bx_get_logged_profile_id();
+        $aCheck = checkActionModule($iPerformerId, 'set badge', 'system', false);
+        if(!isAdmin() && $aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return false;
+        
+        $oBadges = BxDolBadges::getInstance();
+
+        $aBadges = $oBadges->getData(array('type' => 'by_module&object', 'object_id' => $iContentId, 'module' => $sModule));
+
+        foreach ($aBadges as $aBadge) {
+            if (isset($aBadge['badge_id'])){
+                $oBadges->delete($aBadge['badge_id']);
+            }
+        }
+        
+        foreach ($aSelectedBadges as $iSelectedBadge) {
+           $oBadges->add($iSelectedBadge, $iContentId, $sModule);
+        }
+        
+        checkActionModule($iPerformerId, 'set badge', 'system', true); // perform action
+        
+        return true;
+    }
+    
     public function serviceSetMembership($mixedProfileId, $iAclLevelId, $iAclLevelDuration = 0)
     {
         if(!is_array($mixedProfileId))

+ 1 - 0
template/scripts/BxBaseServices.php

@@ -91,6 +91,7 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
             'UpdateSettings' => 'BxBaseServiceProfiles',
             'Befriend' => 'BxBaseServiceProfiles',
             'ProfileCounters' => 'BxBaseServiceProfiles',
+            'SetBadges' => 'BxBaseServiceProfiles',
             
             'GetChartGrowth' => 'BxBaseChartServices',
             'GetChartStats' => 'BxBaseChartServices',