Procházet zdrojové kódy

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

AntonLV před 7 roky
rodič
revize
8a2fbd9f8e

+ 1 - 1
modules/base/groups/classes/BxBaseModGroupsFormsEntryHelper.php

@@ -41,7 +41,7 @@ class BxBaseModGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
         $this->makeAuthorAdmin ($oGroupProfile, bx_get('initial_members'));
 
         $this->inviteMembers ($oGroupProfile, bx_get('initial_members'));
-        
+
         return '';
     }
 

+ 19 - 1
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -263,6 +263,14 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
         // new fan was added
         if ($oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId, true)) {
+            // follow group on join
+            if (BxDolService::call($oGroupProfile->getModule(), 'act_as_profile')){
+                 $this->addFollower($oGroupProfile->id(), (int)$iInitiatorId);
+            }
+            else{
+                 $this->addFollower((int)$iInitiatorId, $oGroupProfile->id()); 
+            }
+            
             bx_alert($this->getName(), 'fan_added', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
             	'object_author_id' => $iGroupProfileId,
             	'performer_id' => $iProfileId,
@@ -299,7 +307,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
         return $oGrid->getCode();
     }
-
+    
     public function serviceFans ($iContentId = 0, $bAsArray = false)
     {
         if (!$iContentId)
@@ -650,6 +658,16 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         return parent::_checkAllowedConnect ($aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap);
     }
 
+    public function addFollower ($iProfileId1, $iProfileId2)
+    {
+        $oConnectionFollow = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
+        if($oConnectionFollow && !$oConnectionFollow->isConnected($iProfileId1, $iProfileId2)){
+            $oConnectionFollow->addConnection($iProfileId1, $iProfileId2);
+            return true;
+        }
+        return false;
+    }
+    
     public function isFan ($iContentId, $iProfileId = false) 
     {
         $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());

+ 35 - 1
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -114,6 +114,40 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
         return $this->genCustomViewRowValueProfileEmailOrIp($aInput);
     }
     
+    protected function genCustomViewRowValueFriendsCount($aInput)
+    {
+        if (isset($this->_oModule->_oConfig->CNF['URI_VIEW_FRIENDS'])){
+            $oProfile = $this->_oModule->getProfileByCurrentUrl();
+            if ($oProfile){
+                $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
+                $iCount = $oConnection->getConnectedContentCount($oProfile->id(), true);
+                return $this->_oModule->_oTemplate->parseHtmlByName('name_link.html', array(
+                    'href' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oModule->_oConfig->CNF['URI_VIEW_FRIENDS'] . '&profile_id=' . $oProfile->id()),
+                    'title' => '',
+                    'content' => $iCount
+                ));
+            }
+        }
+        return '';
+    }
+    
+    protected function genCustomViewRowValueFollowersCount($aInput)
+    {
+        if (isset($this->_oModule->_oConfig->CNF['URI_VIEW_SUBSCRIPTIONS'])){
+            $oProfile = $this->_oModule->getProfileByCurrentUrl();
+            if ($oProfile){
+                $oConnectionFollow = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
+                $iCount = $oConnectionFollow->getConnectedInitiatorsCount($oProfile->id());
+                return $this->_oModule->_oTemplate->parseHtmlByName('name_link.html', array(
+                    'href' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oModule->_oConfig->CNF['URI_VIEW_SUBSCRIPTIONS'] . '&profile_id=' . $oProfile->id()),
+                    'title' => '',
+                    'content' => $iCount
+                ));
+            }
+        }
+        return '';
+    }
+    
     private function genCustomViewRowValueProfileEmailOrIp($aInput)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
@@ -138,7 +172,7 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
             'content' => $sValue
         ));
     }
-
+    
     protected function genCustomViewRowValueProfileStatus($aInput)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;

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

@@ -1269,6 +1269,20 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
 		return $oProfile->id() == $iLogged;
     }
+    
+    public function getProfileByCurrentUrl ()
+    {
+        $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+        
+        if ($iProfileId)
+            return  BxDolProfile::getInstance($iProfileId);
+
+        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if ($iContentId)
+            return BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());
+        
+        return false;
+    }
 
     // ====== PROTECTED METHODS
 

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

@@ -69,7 +69,8 @@ class BxOrgsConfig extends BxBaseModProfileConfig
             'URI_EDIT_COVER' => 'edit-organization-cover',
             'URI_JOINED_ENTRIES' => 'joined-organizations',
             'URI_MANAGE_COMMON' => 'organizations-manage',
-
+            'URI_VIEW_SUBSCRIPTIONS' => 'organization-profile-subscriptions',
+            
             'URL_HOME' => 'page.php?i=organizations-home',
             'URL_CREATE' => 'page.php?i=create-organization-profile',
             'URL_ENTRY_FANS' => 'page.php?i=organization-profile-fans',

+ 4 - 0
modules/boonex/organizations/install/langs/en.xml

@@ -67,6 +67,10 @@
     <string name="_bx_orgs_form_profile_input_date_added"><![CDATA[Added]]></string>
     <string name="_bx_orgs_form_profile_input_sys_date_changed"><![CDATA[Updated]]></string>
     <string name="_bx_orgs_form_profile_input_date_changed"><![CDATA[Updated]]></string>
+    <string name="_bx_orgs_form_profile_input_sys_friends_count"><![CDATA[Friends count]]></string>
+    <string name="_bx_orgs_form_profile_input_friends_count"><![CDATA[Friends count]]></string>
+    <string name="_bx_orgs_form_profile_input_sys_followers_count"><![CDATA[Followers count]]></string>
+    <string name="_bx_orgs_form_profile_input_followers_count"><![CDATA[Followers count]]></string>
 
 	<string name="_bx_orgs_acl_action_create_profile"><![CDATA[Create Organization's Profile]]></string>
 	<string name="_bx_orgs_acl_action_delete_profile"><![CDATA[Delete Organization's Profile]]></string>

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

@@ -261,7 +261,9 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_organization', 'bx_organizations', 'profile_ip', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_profile_ip', '_bx_orgs_form_profile_input_profile_ip', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_organization', 'bx_organizations', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_organization', 'bx_organizations', 'added', '', '', 0, 'datetime', '_bx_orgs_form_profile_input_sys_date_added', '_bx_orgs_form_profile_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
-('bx_organization', 'bx_organizations', 'changed', '', '', 0, 'datetime', '_bx_orgs_form_profile_input_sys_date_changed', '_bx_orgs_form_profile_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
+('bx_organization', 'bx_organizations', 'changed', '', '', 0, 'datetime', '_bx_orgs_form_profile_input_sys_date_changed', '_bx_orgs_form_profile_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_organization', 'bx_organizations', 'friends_count', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_friends_count', '_bx_orgs_form_profile_input_friends_count', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_organization', 'bx_organizations', 'followers_count', '', '', 0, 'text', '_bx_orgs_form_profile_input_sys_followers_count', '_bx_orgs_form_profile_input_followers_count', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
 
 INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES
 ('bx_organization_add', 'initial_members', 2147483647, 1, 1),
@@ -301,6 +303,8 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_organization_view', 'profile_ip', 192, 1, 5),
 ('bx_organization_view', 'added', 192, 1, 6),
 ('bx_organization_view', 'changed', 192, 1, 7),
+('bx_organization_view', 'friends_count', 2147483647, 1, 8),
+('bx_organization_view', 'followers_count', 2147483647, 1, 9),
 
 ('bx_organization_view_full', 'org_name', 2147483647, 1, 1),
 ('bx_organization_view_full', 'org_cat', 2147483647, 1, 2),

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

@@ -63,6 +63,7 @@ class BxPersonsConfig extends BxBaseModProfileConfig
             'URI_EDIT_ENTRY' => 'edit-persons-profile',
             'URI_EDIT_COVER' => 'edit-persons-cover',
             'URI_MANAGE_COMMON' => 'persons-manage',
+            'URI_VIEW_SUBSCRIPTIONS' => 'persons-profile-subscriptions',
 
             'URL_HOME' => 'page.php?i=persons-home',
             'URL_CREATE' => 'page.php?i=create-persons-profile',

+ 4 - 0
modules/boonex/persons/install/langs/en.xml

@@ -63,6 +63,10 @@
     <string name="_bx_persons_form_profile_input_date_added"><![CDATA[Added]]></string>
     <string name="_bx_persons_form_profile_input_sys_date_changed"><![CDATA[Updated]]></string>
     <string name="_bx_persons_form_profile_input_date_changed"><![CDATA[Updated]]></string>
+    <string name="_bx_persons_form_profile_input_sys_friends_count"><![CDATA[Friends count]]></string>
+    <string name="_bx_persons_form_profile_input_friends_count"><![CDATA[Friends count]]></string>
+    <string name="_bx_persons_form_profile_input_sys_followers_count"><![CDATA[Followers count]]></string>
+    <string name="_bx_persons_form_profile_input_followers_count"><![CDATA[Followers count]]></string>
 
 	<string name="_bx_persons_acl_action_create_profile"><![CDATA[Create Person's Profile]]></string>
 	<string name="_bx_persons_acl_action_delete_profile"><![CDATA[Delete Person's Profile]]></string>

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

@@ -237,7 +237,10 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_person', 'bx_persons', 'profile_ip', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_profile_ip', '_bx_persons_form_profile_input_profile_ip', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_person', 'bx_persons', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_person', 'bx_persons', 'added', '', '', 0, 'datetime', '_bx_persons_form_profile_input_sys_date_added', '_bx_persons_form_profile_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
-('bx_person', 'bx_persons', 'changed', '', '', 0, 'datetime', '_bx_persons_form_profile_input_sys_date_changed', '_bx_persons_form_profile_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
+('bx_person', 'bx_persons', 'changed', '', '', 0, 'datetime', '_bx_persons_form_profile_input_sys_date_changed', '_bx_persons_form_profile_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_person', 'bx_persons', 'friends_count', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_friends_count', '_bx_persons_form_profile_input_friends_count', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_person', 'bx_persons', 'followers_count', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_followers_count', '_bx_persons_form_profile_input_followers_count', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
+
 
 INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES 
 ('bx_person_add', 'picture', 2147483647, 1, 1),
@@ -280,6 +283,8 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_person_view', 'profile_ip', 192, 1, 6),
 ('bx_person_view', 'added', 192, 1, 7),
 ('bx_person_view', 'changed', 192, 1, 8),
+('bx_person_view', 'friends_count', 2147483647, 1, 9),
+('bx_person_view', 'followers_count', 2147483647, 1, 10),
 
 ('bx_person_view_full', 'gender', 2147483647, 1, 1),
 ('bx_person_view_full', 'birthday', 2147483647, 1, 2),

+ 4 - 0
modules/boonex/russian/data/langs/bx_organizations/ru.xml

@@ -67,6 +67,10 @@
     <string name="_bx_orgs_form_profile_input_date_added"><![CDATA[Дата создания]]></string>
     <string name="_bx_orgs_form_profile_input_sys_date_changed"><![CDATA[Дата обновления]]></string>
     <string name="_bx_orgs_form_profile_input_date_changed"><![CDATA[Дата обновления]]></string>
+    <string name="_bx_orgs_form_profile_input_sys_friends_count"><![CDATA[Количество друзей]]></string>
+    <string name="_bx_orgs_form_profile_input_friends_count"><![CDATA[Количество друзей]]></string>
+    <string name="_bx_orgs_form_profile_input_sys_followers_count"><![CDATA[Количество подписчиков]]></string>
+    <string name="_bx_orgs_form_profile_input_followers_count"><![CDATA[Количество подписчиков]]></string>
 
 	<string name="_bx_orgs_acl_action_create_profile"><![CDATA[Создать профиль организации]]></string>
 	<string name="_bx_orgs_acl_action_delete_profile"><![CDATA[Удалить профиль организации]]></string>

+ 4 - 0
modules/boonex/russian/data/langs/bx_persons/ru.xml

@@ -63,6 +63,10 @@
     <string name="_bx_persons_form_profile_input_date_added"><![CDATA[Дата создания]]></string>
     <string name="_bx_persons_form_profile_input_sys_date_changed"><![CDATA[Дата обновления]]></string>
     <string name="_bx_persons_form_profile_input_date_changed"><![CDATA[Дата обновления]]></string>
+    <string name="_bx_persons_form_profile_input_sys_friends_count"><![CDATA[Количество друзей]]></string>
+    <string name="_bx_persons_form_profile_input_friends_count"><![CDATA[Количество друзей]]></string>
+    <string name="_bx_persons_form_profile_input_sys_followers_count"><![CDATA[Количество подписчиков]]></string>
+    <string name="_bx_persons_form_profile_input_followers_count"><![CDATA[Количество подписчиков]]></string>
 
 	<string name="_bx_persons_acl_action_create_profile"><![CDATA[Создать персональный профиль]]></string>
 	<string name="_bx_persons_acl_action_delete_profile"><![CDATA[Удалить персональный профиль]]></string>