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

#5229 Remake account menu to have non-personalized links: profile, friends & relations menu items

Alex Trofimov 1 год назад
Родитель
Сommit
9a4542e839

+ 1 - 1
install/sql/system.sql

@@ -5073,7 +5073,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 
 -- profile stats
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES
-('sys_profile_stats', 'system', 'profile-stats-profile', '_sys_menu_item_title_system_profile', '_sys_menu_item_title_profile', '{member_url}', '', '', 'user', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:27:"get_menu_addon_profile_edit";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', '', 2147483646, 1, 0, 0),
+('sys_profile_stats', 'system', 'profile-stats-profile', '_sys_menu_item_title_system_profile', '_sys_menu_item_title_profile', '{own_profile_url}', '', '', 'user', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:27:"get_menu_addon_profile_edit";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', '', 2147483646, 1, 0, 0),
 ('sys_profile_stats', 'system', 'friend-suggestions', '_sys_menu_item_title_system_connections', '_sys_menu_item_title_connections', 'page.php?i=friend-suggestions', '', '', 'users', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 1, 1);
 
 -- wiki menu

+ 19 - 0
modules/base/profile/classes/BxBaseModProfilePageEntry.php

@@ -48,6 +48,25 @@ class BxBaseModProfilePageEntry extends BxBaseModGeneralPageEntry
             $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']);
         }
 
+        if (!$this->_oProfile && isLogged()) { // if no params are given, then redirect to own profile pages
+            $a = [];
+            if (isset($CNF['URI_VIEW_ENTRY']))
+                $a[$CNF['URI_VIEW_ENTRY']] = ['id', 'getContentId'];
+            if (isset($CNF['URI_VIEW_FRIENDS']))
+                $a[$CNF['URI_VIEW_FRIENDS']] = ['profile_id', 'id'];
+            if (isset($CNF['URI_VIEW_RELATIONS']))
+                $a[$CNF['URI_VIEW_RELATIONS']] = ['profile_id', 'id'];
+            
+            foreach ($a as $sUri => $r) {
+                if ($this->_aObject['uri'] == $sUri) {
+                    $oProfile = BxDolProfile::getInstance();
+                    $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $sUri . '&' . $r[0] . '=' . $oProfile->{$r[1]}()));
+                    header("Location: " . $sUrl);
+                    exit;
+                }
+            }
+        }
+
         if (!$this->_isAvailablePage($this->_aObject) || !$this->_oProfile) {
             $this->setPageCover(false);
             return;

+ 1 - 0
modules/boonex/organizations/classes/BxOrgsConfig.php

@@ -91,6 +91,7 @@ class BxOrgsConfig extends BxBaseModGroupsConfig
             'URI_VIEW_ENTRY' => 'view-organization-profile',
             'URI_VIEW_FRIENDS' => 'organization-profile-friends',
             'URI_VIEW_FRIEND_REQUESTS' => 'organization-friend-requests',
+            'URI_VIEW_RELATIONS' => 'organization-profile-relations',
             'URI_VIEW_FAVORITES' => 'organization-profile-favorites',
             'URI_ADD_ENTRY' => 'create-organization-profile',
             'URI_EDIT_ENTRY' => 'edit-organization-profile',

+ 2 - 2
modules/boonex/organizations/install/sql/enable.sql

@@ -464,8 +464,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 -- MENU: notifications menu in account popup
 SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_account_notifications' AND `active` = 1 AND `order` < 9999 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `visibility_custom`, `active`, `copyable`, `order`) VALUES
-('sys_account_notifications', 'bx_organizations', 'notifications-friend-requests', '_bx_orgs_menu_item_title_system_friends', '_bx_orgs_menu_item_title_friends', 'page.php?i=organization-profile-friends&profile_id={member_id}', '', '', 'users col-red2', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:16:"bx_organizations";s:6:"method";s:17:"is_enable_friends";}', 1, 0, @iNotifMenuOrder + 1),
-('sys_account_notifications', 'bx_organizations', 'notifications-relation-requests', '_bx_orgs_menu_item_title_system_relations', '_bx_orgs_menu_item_title_relations', 'page.php?i=organization-profile-relations&profile_id={member_id}', '', '', 'sync col-red2', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:22:"sys_profiles_relations";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:16:"bx_organizations";s:6:"method";s:19:"is_enable_relations";}', 1, 0, @iNotifMenuOrder + 2);
+('sys_account_notifications', 'bx_organizations', 'notifications-friend-requests', '_bx_orgs_menu_item_title_system_friends', '_bx_orgs_menu_item_title_friends', 'page.php?i=organization-profile-friends', '', '', 'users col-red2', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:16:"bx_organizations";s:6:"method";s:17:"is_enable_friends";}', 1, 0, @iNotifMenuOrder + 1),
+('sys_account_notifications', 'bx_organizations', 'notifications-relation-requests', '_bx_orgs_menu_item_title_system_relations', '_bx_orgs_menu_item_title_relations', 'page.php?i=organization-profile-relations', '', '', 'sync col-red2', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:22:"sys_profiles_relations";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:16:"bx_organizations";s:6:"method";s:19:"is_enable_relations";}', 1, 0, @iNotifMenuOrder + 2);
 
 -- MENU: profile stats
 SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_profile_stats' AND `active` = 1 LIMIT 1);

+ 1 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -73,6 +73,7 @@ class BxPersonsConfig extends BxBaseModProfileConfig
             'URI_VIEW_ENTRY' => 'view-persons-profile',
             'URI_VIEW_FRIENDS' => 'persons-profile-friends',
             'URI_VIEW_FRIEND_REQUESTS' => 'persons-friend-requests',
+            'URI_VIEW_RELATIONS' => 'persons-profile-relation',
             'URI_VIEW_FAVORITES' => 'persons-profile-favorites',
             'URI_ADD_ENTRY' => 'create-persons-profile',
             'URI_EDIT_ENTRY' => 'edit-persons-profile',

+ 2 - 2
modules/boonex/persons/install/sql/enable.sql

@@ -376,8 +376,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 -- MENU: notifications menu in account popup
 SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_account_notifications' AND `active` = 1 AND `order` < 9999 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `visibility_custom`, `active`, `copyable`, `order`) VALUES
-('sys_account_notifications', 'bx_persons', 'notifications-friend-requests', '_bx_persons_menu_item_title_system_friends', '_bx_persons_menu_item_title_friends', 'page.php?i=persons-profile-friends&profile_id={member_id}', '', '', 'users col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:10:"bx_persons";s:6:"method";s:17:"is_enable_friends";}', 1, 0, @iNotifMenuOrder + 1),
-('sys_account_notifications', 'bx_persons', 'notifications-relation-requests', '_bx_persons_menu_item_title_system_relations', '_bx_persons_menu_item_title_relations', 'page.php?i=persons-profile-relations&profile_id={member_id}', '', '', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:22:"sys_profiles_relations";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:10:"bx_persons";s:6:"method";s:19:"is_enable_relations";}', 1, 0, @iNotifMenuOrder + 2);
+('sys_account_notifications', 'bx_persons', 'notifications-friend-requests', '_bx_persons_menu_item_title_system_friends', '_bx_persons_menu_item_title_friends', 'page.php?i=persons-profile-friends', '', '', 'users col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:10:"bx_persons";s:6:"method";s:17:"is_enable_friends";}', 1, 0, @iNotifMenuOrder + 1),
+('sys_account_notifications', 'bx_persons', 'notifications-relation-requests', '_bx_persons_menu_item_title_system_relations', '_bx_persons_menu_item_title_relations', 'page.php?i=persons-profile-relation', '', '', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:22:"sys_profiles_relations";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 'a:2:{s:6:"module";s:10:"bx_persons";s:6:"method";s:19:"is_enable_relations";}', 1, 0, @iNotifMenuOrder + 2);
 
 -- MENU: profile stats
 SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_profile_stats' AND `active` = 1 LIMIT 1);

+ 5 - 2
template/scripts/BxBaseMenuAccountNotifications.php

@@ -17,8 +17,11 @@ class BxBaseMenuAccountNotifications extends BxTemplMenu
     {
         parent::__construct ($aObject, $oTemplate);
 
+        $oProfile = BxDolProfile::getInstance();
+        $oModule = BxDolModule::getInstance($oProfile->getModule());
         $this->addMarkers(array(
-            'studio_url' => BX_DOL_URL_STUDIO
+            'studio_url' => BX_DOL_URL_STUDIO,
+            'own_profile_url' => 'page.php?i=' . $oModule->_oConfig->CNF['URI_VIEW_ENTRY'],
         ));        
     }
 
@@ -30,7 +33,7 @@ class BxBaseMenuAccountNotifications extends BxTemplMenu
         ));
 
         $aDuplicates = $this->_oQuery->getMenuItemsBy(array(
-            'type' => 'set_name_duplicates', 
+            'type' => 'set_name_duplicates',
             'set_name' => $this->_aObject['set_name']
         ));