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

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

RomanL 4 лет назад
Родитель
Сommit
9ea0048fe2

+ 12 - 5
inc/classes/BxDolPrivacy.php

@@ -15,7 +15,8 @@ define('BX_DOL_PG_FRIENDS', '5');
 define('BX_DOL_PG_FRIENDS_SELECTED', '6');
 define('BX_DOL_PG_RELATIONS', '7');
 define('BX_DOL_PG_RELATIONS_SELECTED', '8');
-define('BX_DOL_PG_CUSTOM', '9');
+define('BX_DOL_PG_ACL', '9');
+define('BX_DOL_PG_CUSTOM', '99');
 
 define('BX_DOL_PG_DEFAULT', BX_DOL_PG_ALL);
 
@@ -87,10 +88,16 @@ class BxDolPrivacy extends BxDolFactory implements iBxDolFactoryObject
         $this->_oDb = new BxDolPrivacyQuery();
         $this->_oDb->init($this->_aObject);
 
-        $this->_aGroupsSettings = array(
-            BX_DOL_PG_FRIENDS_SELECTED => array('connection' => 'sys_profiles_friends'),
-            BX_DOL_PG_RELATIONS_SELECTED => array('connection' => 'sys_profiles_relations')
-        );
+        $this->_aGroupsSettings = [
+            BX_DOL_PG_FRIENDS_SELECTED => [
+                'connection' => 'sys_profiles_friends', 
+                'js_method_create_group' => 'selectUsers'
+            ],
+            BX_DOL_PG_RELATIONS_SELECTED => [
+                'connection' => 'sys_profiles_relations', 
+                'js_method_create_group' => 'selectUsers'
+            ]
+        ];
 
         $this->_aGroupsExclude = array();
 

+ 5 - 1
inc/js/classes/BxDolPrivacy.js

@@ -84,7 +84,11 @@ BxDolPrivacy.prototype.selectGroup = function(oElement)
     if(!this._aGroupSettings[iGroupId])
         return;
 
-    this.selectUsers(oElement, iGroupId);
+    var sMethodCreateGroup = 'selectUsers';
+    if(this._aGroupSettings[iGroupId]['js_method_create_group'])
+        sMethodCreateGroup = this._aGroupSettings[iGroupId]['js_method_create_group'];
+
+    this[sMethodCreateGroup](oElement, iGroupId);
 };
 
 BxDolPrivacy.prototype.onSelectGroup = function(oData)

+ 2 - 1
install/sql/system.sql

@@ -2093,7 +2093,8 @@ INSERT INTO `sys_privacy_groups`(`id`, `title`, `check`, `active`, `visible`) VA
 ('6', '_sys_ps_group_title_friends_selected', '@friends_selected_by_object', 1, 1),
 ('7', '_sys_ps_group_title_relations', '@relations', 1, 1),
 ('8', '_sys_ps_group_title_relations_selected', '@relations_selected_by_object', 1, 1),
-('9', '_sys_ps_group_title_custom', '@custom_by_object', 0, 0);
+('9', '_sys_ps_group_title_acl_selected', '@acl_selected_by_object', 1, 1),
+('99', '_sys_ps_group_title_custom', '@custom_by_object', 0, 0);
 
 CREATE TABLE `sys_privacy_groups_custom` (
   `id` int(11) unsigned NOT NULL auto_increment,

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

@@ -84,7 +84,7 @@ class BxBaseModGroupsAlertsResponse extends BxBaseModProfileAlertsResponse
             if(!$oConnection->isConnected($iInviter, $oAlert->iSender))
                 return;
 
-            if($this->_oModule->_oDb->getInviteByInvited($iInvited, $oAlert->iSender) != 0)
+            if($this->_oModule->_oDb->isInviteByInvited($iInvited, $oAlert->iSender))
                 return;
 
             $sKey = BxDolKey::getInstance()->getNewKey(false, $CNF["INVITES_KEYS_LIFETIME"]);

+ 16 - 10
modules/base/groups/classes/BxBaseModGroupsDb.php

@@ -370,24 +370,30 @@ class BxBaseModGroupsDb extends BxBaseModProfileDb
     
     public function getInviteByKey($sKey, $iGroupProfileId)
     {
-        $aBindings = array(
+        $CNF = &$this->_oConfig->CNF;
+
+        return $this->getRow("SELECT * FROM `" . $CNF["TABLE_INVITES"] . "` WHERE `key` = :key AND group_profile_id = :group_profile_id", [
             'key' => $sKey,
             'group_profile_id' => $iGroupProfileId
-        );
-        $CNF = $this->_oConfig->CNF; 
-        return $this->getRow("SELECT * FROM `" . $CNF["TABLE_INVITES"] . "` WHERE `key` = :key AND group_profile_id = :group_profile_id", $aBindings);
+        ]);
     }
-    
+
     public function getInviteByInvited($iInvitedProfileId, $iGroupProfileId)
     {
-        $aBindings = array(
+        $CNF = &$this->_oConfig->CNF; 
+
+        return $this->getRow("SELECT * FROM `" . $CNF["TABLE_INVITES"] . "` WHERE `invited_profile_id` = :invited_profile_id AND group_profile_id = :group_profile_id", [
             'invited_profile_id' => $iInvitedProfileId,
             'group_profile_id' => $iGroupProfileId
-        );
-        $CNF = $this->_oConfig->CNF; 
-        return $this->getOne("SELECT COUNT(*) FROM `" . $CNF["TABLE_INVITES"] . "` WHERE `invited_profile_id` = :invited_profile_id AND group_profile_id = :group_profile_id", $aBindings);
+        ]);
     }
-    
+
+    public function isInviteByInvited($iInvitedProfileId, $iGroupProfileId)
+    {
+        $aInvite = $this->getInviteByInvited($iInvitedProfileId, $iGroupProfileId);
+        return !empty($aInvite) && is_array($aInvite);
+    }
+
     public function updateInviteByKey($sKey, $iGroupProfileId, $sColumn, $sValue)
     {
         $aBindings = array(

+ 17 - 3
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -1514,19 +1514,33 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         return false;
     }
 
-    public function isInvited ($sKey, $iProfileId) 
+    public function isInvited ($sKey, $iGroupProfileId) 
     {
         $CNF = &$this->_oConfig->CNF;
-        $aData = $this->_oDb->getInviteByKey($sKey,  $iProfileId);
+        $aData = $this->_oDb->getInviteByKey($sKey,  $iGroupProfileId);
         if (!isset($aData['invited_profile_id']))
             return _t($CNF['T']['txt_invitation_popup_error_invitation_absent']);
         
         if ($aData['invited_profile_id'] != bx_get_logged_profile_id())
-            return  _t($CNF['T']['txt_invitation_popup_error_wrong_user']);
+            return _t($CNF['T']['txt_invitation_popup_error_wrong_user']);
         
         return true;
     }
 
+    public function isInvitedByProfileId ($iProfileId, $iGroupProfileId) 
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $aData = $this->_oDb->getInviteByInvited($iProfileId,  $iGroupProfileId);
+        if (!isset($aData['invited_profile_id']))
+            return _t($CNF['T']['txt_invitation_popup_error_invitation_absent']);
+
+        if ($aData['invited_profile_id'] != bx_get_logged_profile_id())
+            return _t($CNF['T']['txt_invitation_popup_error_wrong_user']);
+
+        return true;
+    }
+
     public function getRole($iGroupProfileId, $iFanProfileId)
     {
         if(!$this->isFanByGroupProfileId($iGroupProfileId, $iFanProfileId))

+ 32 - 17
modules/base/groups/classes/BxBaseModGroupsPageEntry.php

@@ -74,32 +74,47 @@ class BxBaseModGroupsPageEntry extends BxBaseModProfilePageEntry
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $sRv = '';
-        $sKey = '';
-        if(!empty($CNF['TABLE_INVITES']) && ($sKey = bx_get('key')) !== false) {
-            $sId = $this->_oModule->getName() . '_popup_invite';
+        $sInvitation = '';
+        if(!empty($CNF['TABLE_INVITES'])) {
+            $sKey = '';
+            $iProfileId = bx_get_logged_profile_id();
+            $iGroupProfileId = $this->_oProfile->id();
+
+            if(($sKey = bx_get('key')) !== false) {
+                $sKey = bx_process_input($sKey);
+                $mixedInvited = $this->_oModule->isInvited($sKey, $iGroupProfileId);
+            }
+            else if($iProfileId !== false)
+                $mixedInvited = $this->_oModule->isInvitedByProfileId($iProfileId, $iGroupProfileId);
 
-            $mixedInvited = $this->_oModule->isInvited($sKey, $this->_oProfile->id());
             if ($mixedInvited === true) {
-                $sRv = $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
+                $sId = $this->_oModule->getName() . '_popup_invite';
+
+                if(empty($sKey)) {
+                    $aInvite = $this->_oModule->_oDb->getInviteByInvited($iProfileId, $iGroupProfileId);
+                    if(!empty($aInvite) && is_array($aInvite))
+                        $sKey = $aInvite['key'];
+                }
+
+                $this->_oTemplate->addJs(array('invite_popup.js'));
+
+                $sInvitation .= $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
+                    'sPopupId' => $sId,
+                    'sKey' => $sKey,
+                    'sAcceptUrl' =>  BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
+                    'sDeclineUrl' => BX_DOL_URL_ROOT,
+                    'iGroupProfileId' => $this->_oProfile->id(),
+                ));
+                $sInvitation .= BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
                     'popup_id' => $sId,
                     'text' => _t($CNF['T']['txt_invitation_popup_text']),
                     'button_accept' => _t($CNF['T']['txt_invitation_popup_accept_button']),
                     'button_decline' => _t($CNF['T']['txt_invitation_popup_decline_button']),
-                ));
+                )), true);
             }
-            else
-                $sRv = $mixedInvited;
         }
 
-        $this->_oTemplate->addJs(array('invite_popup.js'));
-        return ($sRv != '' ? $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
-            'sPopupId' => $sId,
-            'sKey' => $sKey,
-            'sAcceptUrl' =>  BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
-            'sDeclineUrl' => BX_DOL_URL_ROOT,
-            'iGroupProfileId' => $this->_oProfile->id(),
-        )) .  BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $sRv, true) : '') . parent::getCode();
+        return $sInvitation . parent::getCode();
     }
 }
 

+ 14 - 13
modules/boonex/english/data/langs/system/en.xml

@@ -3227,19 +3227,20 @@ If it is not enabled then please consider implement this optimization, since it
             <li><b>{0}</b> total</li>
             <li><b>{1}</b> deleted</li>
         </ul>]]></string>
-        <string name="_sys_ps_group_title_custom"><![CDATA[Custom]]></string>
-        <string name="_sys_ps_group_title_followers"><![CDATA[Followers]]></string>
-	<string name="_sys_ps_group_title_friends"><![CDATA[Friends]]></string>
-        <string name="_sys_ps_group_title_friends_selected"><![CDATA[Selected Friends...]]></string>
-        <string name="_sys_ps_group_title_relations"><![CDATA[Relationships]]></string>
-        <string name="_sys_ps_group_title_relations_selected"><![CDATA[Selected Relationships...]]></string>
-	<string name="_sys_ps_group_title_me_only"><![CDATA[Me only]]></string>
-	<string name="_sys_ps_group_title_members"><![CDATA[Members]]></string>
-	<string name="_sys_ps_group_title_public"><![CDATA[Public]]></string>
-        <string name="_sys_ps_group_title_participants"><![CDATA[Participants]]></string>
-	<string name="_sys_ps_group_title_closed"><![CDATA[Closed]]></string>
-	<string name="_sys_ps_group_title_secret"><![CDATA[Secret]]></string>
-        <string name="_sys_ps_group_title_unknown"><![CDATA[Unknown]]></string>
+    <string name="_sys_ps_group_title_acl_selected"><![CDATA[Selected Membership Levels...]]></string>
+    <string name="_sys_ps_group_title_custom"><![CDATA[Custom]]></string>
+    <string name="_sys_ps_group_title_followers"><![CDATA[Followers]]></string>
+    <string name="_sys_ps_group_title_friends"><![CDATA[Friends]]></string>
+    <string name="_sys_ps_group_title_friends_selected"><![CDATA[Selected Friends...]]></string>
+    <string name="_sys_ps_group_title_relations"><![CDATA[Relationships]]></string>
+    <string name="_sys_ps_group_title_relations_selected"><![CDATA[Selected Relationships...]]></string>
+    <string name="_sys_ps_group_title_me_only"><![CDATA[Me only]]></string>
+    <string name="_sys_ps_group_title_members"><![CDATA[Members]]></string>
+    <string name="_sys_ps_group_title_public"><![CDATA[Public]]></string>
+    <string name="_sys_ps_group_title_participants"><![CDATA[Participants]]></string>
+    <string name="_sys_ps_group_title_closed"><![CDATA[Closed]]></string>
+    <string name="_sys_ps_group_title_secret"><![CDATA[Secret]]></string>
+    <string name="_sys_ps_group_title_unknown"><![CDATA[Unknown]]></string>
     <string name="_sys_ps_ferr_incorrect_gc_not_allowed"><![CDATA[Custom privacy groups aren't allowed.]]></string>
     <string name="_sys_ps_ferr_incorrect_gc_owner"><![CDATA[You are not an owner of the content.]]></string>
     <string name="_sys_ps_ferr_incorrect_select"><![CDATA[You need to select some value]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -3191,6 +3191,7 @@
             <li><b>{0}</b> всего</li>
             <li><b>{1}</b> удалено</li>
         </ul>]]></string>
+    <string name="_sys_ps_group_title_acl_selected"><![CDATA[Избранные уровни членства...]]></string>
     <string name="_sys_ps_group_title_custom"><![CDATA[Индивидуально]]></string>
     <string name="_sys_ps_group_title_followers"><![CDATA[Подписчики]]></string>
     <string name="_sys_ps_group_title_friends"><![CDATA[Друзья]]></string>

+ 1 - 2
template/comments_uploader_bs.html

@@ -1,4 +1,3 @@
 <a __attrs__ href="javascript:void(0);" class="bx-btn bx-def-margin-sec-top bx-def-margin-sec-left cmts-uploader-button __btn_class__">
     <i class="sys-icon __button_title__"></i>
-</a>
-<bx_include_auto:uploader_button_html5_js.html />
+</a>