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

#251 Facebook connect: fixes, adding default privacy setting

Alex Trofimov 10 лет назад
Родитель
Сommit
1a8aeb3dd5

+ 14 - 0
modules/base/connect/classes/BxBaseModConnectModule.php

@@ -25,6 +25,19 @@ class BxBaseModConnectModule extends BxDolModule
         return $aModules;
     }
 
+    public function serviceGetPrivacyGroups ()
+    {
+        $oPrivacyQuery = new BxDolPrivacyQuery();
+        $a = $oPrivacyQuery->getGroupsBy(array('type' => 'active'));
+        $aGroups = array();
+        foreach ($a as $r) {
+            if (!(int)$r['active'])
+               continue;
+            $aGroups[$r['id']] = _t($r['title']);
+        }
+        return $aGroups;
+    }
+    
     /**
      * Logged profile
      *
@@ -173,6 +186,7 @@ class BxBaseModConnectModule extends BxDolModule
             if (isset($oFormProfile) && $oFormProfile) {
                 
                 $aFieldsProfile['picture'] = $this->_processImage($aFieldsProfile, $iAccountProfileId, $oFormHelperProfile);
+                $_POST['picture'] = $aFieldsProfile['picture']; // set POST variable to correctly process images in processFiles method in form object
 
                 if (!($iContentId = $oFormProfile->insert($aFieldsProfile)))
                     return _t('_sys_txt_error_account_creation');

+ 0 - 1
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -158,7 +158,6 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
         $iProfileId = $this->getContentOwnerProfileId($iContentId);
 
         $aGhostFiles = $oStorage->getGhosts ($iProfileId, $isAssociateWithContent ? 0 : $iContentId, true);
-
         if (!$aGhostFiles)
             return true;
 

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

@@ -383,6 +383,17 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolPro
     
     // ====== PERMISSION METHODS
 
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedView ($aDataEntry, $isPerformAction = false)
+    {
+        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
+        if ($oProfile && $oProfile->id() == $this->_iProfileId)
+            return CHECK_ACTION_RESULT_ALLOWED;
+        return parent::checkAllowedView ($aDataEntry, $isPerformAction);
+    }
+    
     /**
      * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
      */

+ 1 - 0
modules/boonex/facebook_connect/classes/BxFaceBookConnectModule.php

@@ -235,6 +235,7 @@ class BxFaceBookConnectModule extends BxBaseModConnectModule
             'country'       => isset($sCountry) ? $sCountry : '',
             'city'       	=> isset($sCity) ? $sCity : '',
             'picture'       => $aProfileInfo['picture'],
+            'allow_view_to' => getParam('bx_facebook_connect_privacy'),
         );
 
         return $aProfileFields;

+ 1 - 0
modules/boonex/facebook_connect/install/langs/en.xml

@@ -19,6 +19,7 @@
     <string name="_bx_facebook_option_auto_friends"><![CDATA[Auto-friend members if they are already friends on Facebook]]></string>
     <string name="_bx_facebook_option_fetch_extended_info"><![CDATA[Fetch extended profile info (facebook app review is required)]]></string>
     <string name="_bx_facebook_option_module"><![CDATA[Module to create profile in]]></string>
+    <string name="_bx_facebook_option_privacy"><![CDATA[Default privacy for created profiles]]></string>
     <string name="_bx_facebook_option_confirm_email"><![CDATA[Always confirm emails when joined using Facebook]]></string>
     <string name="_bx_facebook_option_approve"><![CDATA[Always approve profiles when joined using Facebook]]></string>
 

+ 1 - 0
modules/boonex/facebook_connect/install/sql/enable.sql

@@ -36,6 +36,7 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_facebook_connect_secret', '', @iCategId, '_bx_facebook_option_app_secret', 'digit', '', '', 20, ''),
 ('bx_facebook_connect_redirect_page', 'dashboard', @iCategId, '_bx_facebook_option_redirect', 'select', '', '', 30, 'join,settings,dashboard,index'),
 ('bx_facebook_connect_module', 'bx_persons', @iCategId, '_bx_facebook_option_module', 'select', '', '', 40, 'a:2:{s:6:"module";s:11:"bx_facebook";s:6:"method";s:20:"get_profiles_modules";}'),
+('bx_facebook_connect_privacy', '3', @iCategId, '_bx_facebook_option_privacy', 'select', '', '', 44, 'a:2:{s:6:"module";s:11:"bx_facebook";s:6:"method";s:18:"get_privacy_groups";}'),
 ('bx_facebook_connect_auto_friends', 'on', @iCategId, '_bx_facebook_option_auto_friends', 'checkbox', '', '', 50, ''),
 ('bx_facebook_connect_extended_info', '', @iCategId, '_bx_facebook_option_fetch_extended_info', 'checkbox', '', '', 60, ''),
 ('bx_facebook_connect_confirm_email', 'on', @iCategId, '_bx_facebook_option_confirm_email', 'checkbox', '', '', 70, ''),

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

@@ -19,6 +19,7 @@
     <string name="_bx_facebook_option_auto_friends"><![CDATA[Автоматически делать друзьями тех, что уже друг на Facebook'е]]></string>
     <string name="_bx_facebook_option_fetch_extended_info"><![CDATA[Получить расширенную информацию о профиле (приложение должно быть одобрено Facebook'ом)]]></string>
     <string name="_bx_facebook_option_module"><![CDATA[Модуль в котором создавать профили]]></string>
+    <string name="_bx_facebook_option_privacy"><![CDATA[Настройки конфиденциальности для созданных профилей]]></string>
     <string name="_bx_facebook_option_confirm_email"><![CDATA[Всегда подтверждать емейл, когда заходят через Facebook]]></string>
     <string name="_bx_facebook_option_approve"><![CDATA[Всегда одобрять профиль, когда заходят через Facebook]]></string>
 

+ 1 - 1
template/scripts/BxBaseServiceProfiles.php

@@ -203,7 +203,7 @@ class BxBaseServiceProfiles extends BxDol
         $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
         foreach ($aModules as $aModule) {
             $oModule = BxDolModule::getInstance($aModule['name']);
-            if ($oModule instanceof iBxDolProfileService)
+            if ($oModule instanceof iBxDolProfileService && $oModule->serviceActAsProfile())
                 $aRet[] = $aModule;
         }
         return $aRet;