فهرست منبع

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

AntonLV 8 سال پیش
والد
کامیت
5e994ca360

+ 14 - 0
inc/classes/BxDolProfile.php

@@ -95,6 +95,20 @@ class BxDolProfile extends BxDolFactory implements iBxDolProfile
         return self::getInstance($mixedProfileId);
         return self::getInstance($mixedProfileId);
     }
     }
 
 
+    /**
+     * Get singleton instance of Profile by profile id, if profile isn't found it returns instance of BxDolProfileAnonymous or BxDolProfileUndefined
+     */
+    public static function getInstanceMagic($mixedProfileId = false, $bClearCache = false)
+    {
+        if ($mixedProfileId < 0)
+            return BxDolProfileAnonymous::getInstance();
+
+        if (0 == $mixedProfileId || !($oProfile = self::getInstance($mixedProfileId, $bClearCache)))
+            return BxDolProfileUndefined::getInstance();
+        
+        return $oProfile;
+    }
+
     /**
     /**
      * Get singleton instance of Profile by profile id
      * Get singleton instance of Profile by profile id
      */
      */

+ 56 - 0
inc/classes/BxDolProfileAnonymous.php

@@ -0,0 +1,56 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * When profile is anonymous then use this special class.
+ *
+ * @section example Example of usage
+ *
+ * @code
+ * if (0 > $iId)
+ *     $oProfile = BxDolProfileAnonymous::getInstance();
+ * else
+ *     $oProfile = BxDolProfile::getInstance($iId);
+ *
+ * @endcode
+ */
+class BxDolProfileAnonymous extends BxDolProfileUndefined
+{
+    /**
+     * Prevent cloning the instance
+     */
+    public function __clone()
+    {
+        $sClass = get_class($this);
+        if (isset($GLOBALS['bxDolClasses'][$sClass]))
+            trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
+    }
+
+    /**
+     * Get singleton instance of the class
+     */
+    public static function getInstance()
+    {
+        $sClass = __CLASS__;
+        if(!isset($GLOBALS['bxDolClasses'][$sClass]))
+            $GLOBALS['bxDolClasses'][$sClass] = new $sClass();
+
+        return $GLOBALS['bxDolClasses'][$sClass];
+    }
+
+    /**
+     * Get profile display name
+     */
+    public function getDisplayName()
+    {
+        return _t('_anonymous');
+    }
+}
+
+/** @} */

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralDb.php

@@ -129,7 +129,7 @@ class BxBaseModGeneralDb extends BxDolModuleDb
 
 
         $aMethod['name'] = 'getColumn';
         $aMethod['name'] = 'getColumn';
 
 
-        $sSelectClause = "`" . $CNF['TABLE_ENTRIES'] . "`.`" . $CNF['FIELD_ID'] . "`";
+        $sSelectClause = " DISTINCT `" . $CNF['TABLE_ENTRIES'] . "`.`" . $CNF['FIELD_ID'] . "`";
 
 
         if (!empty($aParams['start']) && !empty($aParams['per_page']))
         if (!empty($aParams['start']) && !empty($aParams['per_page']))
             $sLimitClause = $this->prepareAsString("?, ?", $aParams['start'], $aParams['per_page']);
             $sLimitClause = $this->prepareAsString("?, ?", $aParams['start'], $aParams['per_page']);

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

@@ -93,6 +93,10 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
             $this->aInputs[$CNF['FIELD_LABELS']]['meta_object'] = $CNF['OBJECT_METATAGS'];
             $this->aInputs[$CNF['FIELD_LABELS']]['meta_object'] = $CNF['OBJECT_METATAGS'];
             $this->aInputs[$CNF['FIELD_LABELS']]['value'] = array_intersect($aLabels, $this->aInputs[$CNF['FIELD_LABELS']]['values']);
             $this->aInputs[$CNF['FIELD_LABELS']]['value'] = array_intersect($aLabels, $this->aInputs[$CNF['FIELD_LABELS']]['values']);
         }
         }
+
+        if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && isset($aValues[$CNF['FIELD_AUTHOR']])) {
+            $this->aInputs[$CNF['FIELD_ANONYMOUS']]['checked'] = $aValues[$CNF['FIELD_AUTHOR']] < 0;
+        }
         
         
         parent::initChecker ($aValues, $aSpecificValues);
         parent::initChecker ($aValues, $aSpecificValues);
     }
     }
@@ -102,7 +106,7 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
         if (isset($CNF['FIELD_AUTHOR']) && empty($aValsToAdd[$CNF['FIELD_AUTHOR']]))
         if (isset($CNF['FIELD_AUTHOR']) && empty($aValsToAdd[$CNF['FIELD_AUTHOR']]))
-            $aValsToAdd[$CNF['FIELD_AUTHOR']] = bx_get_logged_profile_id ();
+            $aValsToAdd[$CNF['FIELD_AUTHOR']] = (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && $this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * bx_get_logged_profile_id ();
 
 
         if (isset($CNF['FIELD_ADDED']) && empty($aValsToAdd[$CNF['FIELD_ADDED']]) && empty($this->getCleanValue($CNF['FIELD_ADDED'])))
         if (isset($CNF['FIELD_ADDED']) && empty($aValsToAdd[$CNF['FIELD_ADDED']]) && empty($this->getCleanValue($CNF['FIELD_ADDED'])))
             $aValsToAdd[$CNF['FIELD_ADDED']] = time();
             $aValsToAdd[$CNF['FIELD_ADDED']] = time();
@@ -124,6 +128,11 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
+        if (isset($CNF['FIELD_AUTHOR']) && isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']])) {
+            $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($iContentId);
+            $aValsToAdd[$CNF['FIELD_AUTHOR']] = ($this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * abs($aContentInfo[$CNF['FIELD_AUTHOR']]);
+        }
+        
         if (isset($CNF['FIELD_CHANGED']) && empty($aValsToAdd[$CNF['FIELD_CHANGED']]) && empty($this->getCleanValue($CNF['FIELD_CHANGED'])))
         if (isset($CNF['FIELD_CHANGED']) && empty($aValsToAdd[$CNF['FIELD_CHANGED']]) && empty($this->getCleanValue($CNF['FIELD_CHANGED'])))
             $aValsToAdd[$CNF['FIELD_CHANGED']] = time();
             $aValsToAdd[$CNF['FIELD_CHANGED']] = time();
 
 

+ 1 - 3
modules/base/general/classes/BxBaseModGeneralMenuSnippetMeta.php

@@ -49,9 +49,7 @@ class BxBaseModGeneralMenuSnippetMeta extends BxTemplMenuCustom
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
-        $oProfile = BxDolProfile::getInstance($this->_aContentInfo[$CNF['FIELD_AUTHOR']]);
-        if(!$oProfile) 
-            $oProfile = BxDolProfileUndefined::getInstance();
+        $oProfile = BxDolProfile::getInstanceMagic($this->_aContentInfo[$CNF['FIELD_AUTHOR']]);
 
 
         return $this->_oTemplate->getUnitMetaItemLink($oProfile->getDisplayName(), array(
         return $this->_oTemplate->getUnitMetaItemLink($oProfile->getDisplayName(), array(
             'href' => $oProfile->getUrl(),
             'href' => $oProfile->getUrl(),

+ 5 - 12
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -1055,7 +1055,7 @@ class BxBaseModGeneralModule extends BxDolModule
     public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
     public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
     {
     {
         // moderator and owner always have access
         // moderator and owner always have access
-        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || -$aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
             return CHECK_ACTION_RESULT_ALLOWED;
             return CHECK_ACTION_RESULT_ALLOWED;
         return _t('_sys_txt_access_denied');
         return _t('_sys_txt_access_denied');
     }
     }
@@ -1071,7 +1071,7 @@ class BxBaseModGeneralModule extends BxDolModule
 
 
         // check ACL
         // check ACL
         $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
         $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
-        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+        if (($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || -$aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId) && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
             return CHECK_ACTION_RESULT_ALLOWED;
             return CHECK_ACTION_RESULT_ALLOWED;
 
 
         return _t('_sys_txt_access_denied');
         return _t('_sys_txt_access_denied');
@@ -1174,7 +1174,7 @@ class BxBaseModGeneralModule extends BxDolModule
         $oProfile = $this->getObjectUser($iUserId);
         $oProfile = $this->getObjectUser($iUserId);
 
 
         $oAccount = null;
         $oAccount = null;
-        if($oProfile && !($oProfile instanceof BxDolProfileUndefined))
+        if($oProfile && !($oProfile instanceof BxDolProfileUndefined) && !($oProfile instanceof BxDolProfileAnonymous))
             $oAccount = $oProfile->getAccountObject();
             $oAccount = $oProfile->getAccountObject();
         $bAccount = !empty($oAccount);
         $bAccount = !empty($oAccount);
 
 
@@ -1194,12 +1194,7 @@ class BxBaseModGeneralModule extends BxDolModule
     public function getObjectUser($iUserId = 0)
     public function getObjectUser($iUserId = 0)
     {
     {
     	bx_import('BxDolProfile');
     	bx_import('BxDolProfile');
-        $oProfile = BxDolProfile::getInstance($iUserId);
-        if (!$oProfile) {
-            bx_import('BxDolProfileUndefined');
-            $oProfile = BxDolProfileUndefined::getInstance();
-        }
-
+        $oProfile = BxDolProfile::getInstanceMagic($iUserId);
         return $oProfile;
         return $oProfile;
     }
     }
 
 
@@ -1231,9 +1226,7 @@ class BxBaseModGeneralModule extends BxDolModule
 
 
     public function getUserInfo($iUserId = 0)
     public function getUserInfo($iUserId = 0)
     {
     {
-        $oProfile = BxDolProfile::getInstance($iUserId);
-        if (!$oProfile)
-            $oProfile = BxDolProfileUndefined::getInstance();
+        $oProfile = BxDolProfile::getInstanceMagic($iUserId);
 
 
         return array(
         return array(
             $oProfile->getDisplayName(),
             $oProfile->getDisplayName(),

+ 8 - 1
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -80,7 +80,14 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
             return false;
             return false;
 
 
         $iProfileAuthor = $oProfileAuthor->id();
         $iProfileAuthor = $oProfileAuthor->id();
-        $this->aCurrent['restriction']['author']['value'] = $iProfileAuthor;
+        if (bx_get_logged_profile_id() == $iProfileAuthor || $this->oModule->_isModerator()) {
+            // for real owner and for moderators show anonymous posts
+            $this->aCurrent['restriction']['author']['operator'] = 'in';
+            $this->aCurrent['restriction']['author']['value'] = array($iProfileAuthor, -$iProfileAuthor);
+        } 
+        else {
+           $this->aCurrent['restriction']['author']['value'] = $iProfileAuthor;
+        }
 
 
         if(!empty($aParams['except']))
         if(!empty($aParams['except']))
         	$this->aCurrent['restriction']['except']['value'] = is_array($aParams['except']) ? $aParams['except'] : array($aParams['except']); 
         	$this->aCurrent['restriction']['except']['value'] = is_array($aParams['except']) ? $aParams['except'] : array($aParams['except']); 

+ 8 - 6
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -39,8 +39,12 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         if (!$iProfileId)
         if (!$iProfileId)
             $iProfileId = $aData[$CNF['FIELD_AUTHOR']];
             $iProfileId = $aData[$CNF['FIELD_AUTHOR']];
 
 
-        $oProfile = BxDolProfile::getInstance($iProfileId);
-        if (!$oProfile) 
+        // if post is anonymous then don't show author block for regular members
+        if ($aData[$CNF['FIELD_AUTHOR']] < 0 && !$this->getModule()->_isModerator())
+            return '';
+        
+        $oProfile = BxDolProfile::getInstance($iProfileId >= 0 ? $iProfileId : -$iProfileId);
+        if (!$oProfile || !$iProfileId) 
             $oProfile = BxDolProfileUndefined::getInstance();
             $oProfile = BxDolProfileUndefined::getInstance();
 
 
         if (!$oProfile)
         if (!$oProfile)
@@ -210,10 +214,8 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         // get entry url
         // get entry url
         $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
         $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
 
 
-        $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
-        if (!$oProfile) 
-            $oProfile = BxDolProfileUndefined::getInstance();
-
+        $oProfile = BxDolProfile::getInstanceMagic($aData[$CNF['FIELD_AUTHOR']]);
+        
         $sTitle = $this->getTitle($aData);
         $sTitle = $this->getTitle($aData);
         $sText = $this->getText($aData);
         $sText = $this->getText($aData);
         $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);
         $sSummary = $this->getSummary($aData, $sTitle, $sText, $sUrl);

+ 5 - 2
modules/boonex/english/data/langs/system/en.xml

@@ -11,7 +11,8 @@
 	<string name="_all"><![CDATA[All]]></string>
 	<string name="_all"><![CDATA[All]]></string>
 	<string name="_Allowed Since"><![CDATA[Allowed Since]]></string>
 	<string name="_Allowed Since"><![CDATA[Allowed Since]]></string>
 	<string name="_Allowed Until"><![CDATA[Allowed Until]]></string>
 	<string name="_Allowed Until"><![CDATA[Allowed Until]]></string>
-	<string name="_Allowed actions"><![CDATA[Allowed actions]]></string>
+    <string name="_Allowed actions"><![CDATA[Allowed actions]]></string>
+    <string name="_anonymous"><![CDATA[anonymous]]></string>
 	<string name="_Are_you_sure"><![CDATA[Are you sure?]]></string>
 	<string name="_Are_you_sure"><![CDATA[Are you sure?]]></string>
 	<string name="_Auth type"><![CDATA[Auth type]]></string>
 	<string name="_Auth type"><![CDATA[Auth type]]></string>
 	<string name="_Basic"><![CDATA[Basic]]></string>
 	<string name="_Basic"><![CDATA[Basic]]></string>
@@ -1985,7 +1986,9 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_form_input_sys_location"><![CDATA[Location]]></string>
 	<string name="_sys_form_input_sys_location"><![CDATA[Location]]></string>
 	<string name="_sys_form_input_location"><![CDATA[Location]]></string>
 	<string name="_sys_form_input_location"><![CDATA[Location]]></string>
 	<string name="_sys_form_input_sys_labels"><![CDATA[Labels]]></string>
 	<string name="_sys_form_input_sys_labels"><![CDATA[Labels]]></string>
-	<string name="_sys_form_input_labels"><![CDATA[Labels]]></string>
+    <string name="_sys_form_input_labels"><![CDATA[Labels]]></string>
+	<string name="_sys_form_input_sys_anonymous"><![CDATA[Post as anonymous]]></string>
+	<string name="_sys_form_input_anonymous"><![CDATA[Post as anonymous]]></string>
 	<string name="_sys_form_login"><![CDATA[Log in]]></string>
 	<string name="_sys_form_login"><![CDATA[Log in]]></string>
 	<string name="_sys_form_login_input_caption_system_agreement"><![CDATA[Agreement]]></string>
 	<string name="_sys_form_login_input_caption_system_agreement"><![CDATA[Agreement]]></string>
 	<string name="_sys_form_login_input_caption_system_captcha"><![CDATA[Captcha]]></string>
 	<string name="_sys_form_login_input_caption_system_captcha"><![CDATA[Captcha]]></string>

+ 2 - 1
modules/boonex/forum/classes/BxForumConfig.php

@@ -55,7 +55,8 @@ class BxForumConfig extends BxBaseModTextConfig
         	'FIELD_LOCK' => 'lock',
         	'FIELD_LOCK' => 'lock',
         	'FIELD_STATUS' => 'status',
         	'FIELD_STATUS' => 'status',
             'FIELD_STATUS_ADMIN' => 'status_admin',
             'FIELD_STATUS_ADMIN' => 'status_admin',
-            'FIELD_LABELS' => 'labels',            
+            'FIELD_LABELS' => 'labels',
+            'FIELD_ANONYMOUS' => 'anonymous',
 	        'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
 	        'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
 
 
             // page URIs
             // page URIs

+ 12 - 1
modules/boonex/forum/classes/BxForumFormEntry.php

@@ -25,10 +25,21 @@ class BxForumFormEntry extends BxBaseModTextFormEntry
     	$CNF = $this->_oModule->_oConfig->CNF;
     	$CNF = $this->_oModule->_oConfig->CNF;
 
 
         $aValsToAdd['lr_timestamp'] = time();
         $aValsToAdd['lr_timestamp'] = time();
-        $aValsToAdd['lr_profile_id'] = bx_get_logged_profile_id();
+        $aValsToAdd['lr_profile_id'] = (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && $this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * bx_get_logged_profile_id();
 
 
         return parent::insert($aValsToAdd, $isIgnore);
         return parent::insert($aValsToAdd, $isIgnore);
     }
     }
+
+    function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
+    {
+        $CNF = $this->_oModule->_oConfig->CNF;
+
+        $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($iContentId);
+        if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && !$aContentInfo['lr_comment_id'])
+            $aValsToAdd['lr_profile_id'] = ($this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * abs($aContentInfo['lr_profile_id']);
+            
+        return parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
+    }
     
     
     public function delete ($iContentId, $aContentInfo = array())
     public function delete ($iContentId, $aContentInfo = array())
     {
     {

+ 1 - 1
modules/boonex/forum/classes/BxForumModule.php

@@ -663,7 +663,7 @@ class BxForumModule extends BxBaseModTextModule
 
 
         // send notification to author
         // send notification to author
         if($iProfileId != $aContentInfo[$CNF['FIELD_AUTHOR']]) {
         if($iProfileId != $aContentInfo[$CNF['FIELD_AUTHOR']]) {
-	        $oProfile = BxDolProfile::getInstance($iProfileId);
+	        $oProfile = BxDolProfile::getInstanceMagic($iProfileId);
 	        if($oProfile) 
 	        if($oProfile) 
                 sendMailTemplate('bx_forum_new_reply', 0, $aContentInfo[$CNF['FIELD_AUTHOR']], array(
                 sendMailTemplate('bx_forum_new_reply', 0, $aContentInfo[$CNF['FIELD_AUTHOR']], array(
                     'SenderDisplayName' => $oProfile->getDisplayName(),
                     'SenderDisplayName' => $oProfile->getDisplayName(),

+ 4 - 12
modules/boonex/forum/classes/BxForumTemplate.php

@@ -80,9 +80,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
         );
         );
         $i = 0;
         $i = 0;
         foreach ($aParticipants as $iProfileId => $iComments) {
         foreach ($aParticipants as $iProfileId => $iComments) {
-            $oProfile = BxDolProfile::getInstance($iProfileId);
-            if (!$oProfile)
-                continue;
+            $oProfile = BxDolProfile::getInstanceMagic($iProfileId);
 
 
             $sInfo = '';
             $sInfo = '';
             if ($iAuthorId == $iProfileId)
             if ($iAuthorId == $iProfileId)
@@ -137,9 +135,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
 
 
 	function getEntryAuthor($aRow)
 	function getEntryAuthor($aRow)
     {
     {
-    	$oProfileAuthor = BxDolProfile::getInstance($aRow['author']);
-		if(!$oProfileAuthor)
-			$oProfileAuthor = BxDolProfileUndefined::getInstance();
+    	$oProfileAuthor = BxDolProfile::getInstanceMagic($aRow['author']);
 
 
     	return $this->parseHtmlByName('entry-author.html', array(
     	return $this->parseHtmlByName('entry-author.html', array(
 			'unit' => $oProfileAuthor->getUnit(0, array('template' => 'unit_wo_info')),
 			'unit' => $oProfileAuthor->getUnit(0, array('template' => 'unit_wo_info')),
@@ -150,9 +146,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
     {
     {
     	$bShowCount = isset($aParams['show_count']) ? (int)$aParams['show_count'] == 1 : false;
     	$bShowCount = isset($aParams['show_count']) ? (int)$aParams['show_count'] == 1 : false;
 
 
-		$oProfileLast = BxDolProfile::getInstance($aRow['lr_profile_id']);
-		if(!$oProfileLast)
-			$oProfileLast = BxDolProfileUndefined::getInstance();
+        $oProfileLast = BxDolProfile::getInstanceMagic($aRow['lr_profile_id']);
 
 
         return $this->parseHtmlByName('entry-label.html', array(
         return $this->parseHtmlByName('entry-label.html', array(
         	'bx_if:show_count' => array(
         	'bx_if:show_count' => array(
@@ -173,9 +167,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
         $oModule = BxDolModule::getInstance($this->MODULE);
         $oModule = BxDolModule::getInstance($this->MODULE);
         $CNF = &$oModule->_oConfig->CNF;
         $CNF = &$oModule->_oConfig->CNF;
 
 
-        $oProfileLast = BxDolProfile::getInstance($aRow['lr_profile_id']);
-        if(!$oProfileLast)
-            $oProfileLast = BxDolProfileUndefined::getInstance();
+        $oProfileLast = BxDolProfile::getInstanceMagic($aRow['lr_profile_id']);
 
 
 		$sTitle = strmaxtextlen($aRow['title'], 100);
 		$sTitle = strmaxtextlen($aRow['title'], 100);
         $sText = strmaxtextlen(!empty($aRow['cmt_text']) ? $aRow['cmt_text'] : $aRow['text'], 100);
         $sText = strmaxtextlen(!empty($aRow['cmt_text']) ? $aRow['cmt_text'] : $aRow['text'], 100);

+ 3 - 2
modules/boonex/forum/install/sql/install.sql

@@ -4,7 +4,7 @@ SET @sStorageEngine = (SELECT `value` FROM `sys_options` WHERE `name` = 'sys_sto
 -- TABLE: entries
 -- TABLE: entries
 CREATE TABLE IF NOT EXISTS `bx_forum_discussions` (
 CREATE TABLE IF NOT EXISTS `bx_forum_discussions` (
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `author` int(10) unsigned NOT NULL,
+  `author` int(11) NOT NULL,
   `added` int(11) NOT NULL,
   `added` int(11) NOT NULL,
   `changed` int(11) NOT NULL,
   `changed` int(11) NOT NULL,
   `thumb` int(11) NOT NULL,
   `thumb` int(11) NOT NULL,
@@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS `bx_forum_discussions` (
   `text` text NOT NULL,
   `text` text NOT NULL,
   `text_comments` text NOT NULL,
   `text_comments` text NOT NULL,
   `lr_timestamp` int(11) NOT NULL,
   `lr_timestamp` int(11) NOT NULL,
-  `lr_profile_id` int(10) unsigned NOT NULL,
+  `lr_profile_id` int(11) NOT NULL,
   `lr_comment_id` int(11) NOT NULL,
   `lr_comment_id` int(11) NOT NULL,
   `views` int(11) NOT NULL default '0',
   `views` int(11) NOT NULL default '0',
   `rate` float NOT NULL default '0',
   `rate` float NOT NULL default '0',
@@ -235,6 +235,7 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 (@sName, @sName, 'cat', '', '#!bx_forum_cats', 0, 'select', '_bx_forum_form_entry_input_sys_cat', '_bx_forum_form_entry_input_cat', '', 1, 0, 0, '', '', '', 'avail', '', '_bx_forum_form_entry_input_cat_err', 'Xss', '', 1, 0),
 (@sName, @sName, 'cat', '', '#!bx_forum_cats', 0, 'select', '_bx_forum_form_entry_input_sys_cat', '_bx_forum_form_entry_input_cat', '', 1, 0, 0, '', '', '', 'avail', '', '_bx_forum_form_entry_input_cat_err', 'Xss', '', 1, 0),
 (@sName, @sName, 'attachments', 'a:1:{i:0;s:14:"bx_forum_html5";}', 'a:2:{s:15:"bx_forum_simple";s:26:"_sys_uploader_simple_title";s:14:"bx_forum_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_forum_form_entry_input_sys_attachments', '_bx_forum_form_entry_input_attachments', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 (@sName, @sName, 'attachments', 'a:1:{i:0;s:14:"bx_forum_html5";}', 'a:2:{s:15:"bx_forum_simple";s:26:"_sys_uploader_simple_title";s:14:"bx_forum_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_forum_form_entry_input_sys_attachments', '_bx_forum_form_entry_input_attachments', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 (@sName, @sName, 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 (@sName, @sName, 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+(@sName, @sName, 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 
 
 ('bx_forum_search', @sName, 'author', '', '', 0, 'custom', '_bx_forum_form_search_input_sys_author', '_bx_forum_form_search_input_author', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_forum_search', @sName, 'author', '', '', 0, 'custom', '_bx_forum_form_search_input_sys_author', '_bx_forum_form_search_input_author', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_forum_search', @sName, 'category', '', '#!bx_forum_cats', 0, 'select', '_bx_forum_form_search_input_sys_category', '_bx_forum_form_search_input_category', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_forum_search', @sName, 'category', '', '#!bx_forum_cats', 0, 'select', '_bx_forum_form_search_input_sys_category', '_bx_forum_form_search_input_category', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),

+ 9 - 1
modules/boonex/froala/classes/BxFroalaModule.php

@@ -34,7 +34,15 @@ class BxFroalaModule extends BxDolModule
 
 
         $oStorage->afterUploadCleanup($iId, $iProfileId);
         $oStorage->afterUploadCleanup($iId, $iProfileId);
 
 
-        $sUrl = $oStorage->getFileUrlById($iId);
+        $aFileInfo = $oStorage->getFile($iId);
+        if ($aFileInfo && in_array($aFileInfo['ext'], array('jpg', 'jpeg', 'jpe', 'png'))) {
+            $oTranscoder = BxDolTranscoderImage::getObjectInstance('bx_froala_image');
+            $sUrl = $oTranscoder->getFileUrl($iId);
+        }
+        else {
+            $sUrl = $oStorage->getFileUrlById($iId);
+        }
+
         echo json_encode(array('link' => $sUrl));
         echo json_encode(array('link' => $sUrl));
     }
     }
 }
 }

+ 24 - 1
modules/boonex/froala/install/sql/install.sql

@@ -19,10 +19,33 @@ CREATE TABLE `bx_froala_files` (
   UNIQUE KEY `remote_id` (`remote_id`)
   UNIQUE KEY `remote_id` (`remote_id`)
 );
 );
 
 
+CREATE TABLE `bx_froala_images_resized` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `profile_id` int(10) unsigned NOT NULL,
+  `remote_id` varchar(128) NOT NULL,
+  `path` varchar(255) NOT NULL,
+  `file_name` varchar(255) NOT NULL,
+  `mime_type` varchar(128) NOT NULL,
+  `ext` varchar(32) NOT NULL,
+  `size` int(11) NOT NULL,
+  `added` int(11) NOT NULL,
+  `modified` int(11) NOT NULL,
+  `private` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `remote_id` (`remote_id`)
+);
+
 -- STORAGES & TRANSCODERS
 -- STORAGES & TRANSCODERS
 
 
 INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `cache_control`, `levels`, `table_files`, `ext_mode`, `ext_allow`, `ext_deny`, `quota_size`, `current_size`, `quota_number`, `current_number`, `max_file_size`, `ts`) VALUES
 INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `cache_control`, `levels`, `table_files`, `ext_mode`, `ext_allow`, `ext_deny`, `quota_size`, `current_size`, `quota_number`, `current_number`, `max_file_size`, `ts`) VALUES
-('bx_froala_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_froala_files', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0);
+('bx_froala_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_froala_files', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0),
+('bx_froala_images_resized', @sStorageEngine, '', 360, 2592000, 3, 'bx_froala_images_resized', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0);
+
+INSERT INTO `sys_objects_transcoder` (`object`, `storage_object`, `source_type`, `source_params`, `private`, `atime_tracking`, `atime_pruning`, `ts`) VALUES 
+('bx_froala_image', 'bx_froala_images_resized', 'Storage', 'a:1:{s:6:"object";s:15:"bx_froala_files";}', 'no', '1', '2592000', '0');
+
+INSERT INTO `sys_transcoder_filters` (`transcoder_object`, `filter`, `filter_params`, `order`) VALUES 
+('bx_froala_image', 'Resize', 'a:2:{s:1:"w";s:4:"1600";s:1:"h";s:4:"1600";}', '0');
 
 
 -- Studio page and widget
 -- Studio page and widget
 
 

+ 2 - 2
modules/boonex/notifications/install/sql/install.sql

@@ -4,11 +4,11 @@ SET @sName = 'bx_notifications';
 -- TABLES
 -- TABLES
 CREATE TABLE IF NOT EXISTS `bx_notifications_events` (
 CREATE TABLE IF NOT EXISTS `bx_notifications_events` (
   `id` int(11) NOT NULL auto_increment,
   `id` int(11) NOT NULL auto_increment,
-  `owner_id` int(11) unsigned NOT NULL default '0',
+  `owner_id` int(11) NOT NULL default '0',
   `type` varchar(255) NOT NULL,
   `type` varchar(255) NOT NULL,
   `action` varchar(255) NOT NULL,
   `action` varchar(255) NOT NULL,
   `object_id` text NOT NULL,
   `object_id` text NOT NULL,
-  `object_owner_id` int(11) unsigned NOT NULL default '0',
+  `object_owner_id` int(11) NOT NULL default '0',
   `object_privacy_view` varchar(32) NOT NULL default '3',
   `object_privacy_view` varchar(32) NOT NULL default '3',
   `subobject_id` int(11) NOT NULL default '0',
   `subobject_id` int(11) NOT NULL default '0',
   `content` text NOT NULL,
   `content` text NOT NULL,

+ 1 - 0
modules/boonex/posts/classes/BxPostsConfig.php

@@ -49,6 +49,7 @@ class BxPostsConfig extends BxBaseModTextConfig
         	'FIELD_STATUS_ADMIN' => 'status_admin',
         	'FIELD_STATUS_ADMIN' => 'status_admin',
             'FIELD_LOCATION_PREFIX' => 'location',
             'FIELD_LOCATION_PREFIX' => 'location',
             'FIELD_LABELS' => 'labels',
             'FIELD_LABELS' => 'labels',
+            'FIELD_ANONYMOUS' => 'anonymous',
             'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
             'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
 
 
             // page URIs
             // page URIs

+ 3 - 2
modules/boonex/posts/install/sql/install.sql

@@ -1,7 +1,7 @@
 -- TABLE: entries
 -- TABLE: entries
 CREATE TABLE IF NOT EXISTS `bx_posts_posts` (
 CREATE TABLE IF NOT EXISTS `bx_posts_posts` (
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `author` int(10) unsigned NOT NULL,
+  `author` int(11) NOT NULL,
   `added` int(11) NOT NULL,
   `added` int(11) NOT NULL,
   `changed` int(11) NOT NULL,
   `changed` int(11) NOT NULL,
   `published` int(11) NOT NULL,
   `published` int(11) NOT NULL,
@@ -247,7 +247,8 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_posts', 'bx_posts', 'added', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_added', '_bx_posts_form_entry_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_posts', 'bx_posts', 'added', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_added', '_bx_posts_form_entry_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_posts', 'bx_posts', 'changed', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_changed', '_bx_posts_form_entry_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_posts', 'bx_posts', 'changed', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_changed', '_bx_posts_form_entry_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_posts', 'bx_posts', 'published', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_published', '_bx_posts_form_entry_input_date_published', '_bx_posts_form_entry_input_date_published_info', 0, 0, 0, '', '', '', '', '', '', 'DateTimeUtc', '', 1, 0),
 ('bx_posts', 'bx_posts', 'published', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_published', '_bx_posts_form_entry_input_date_published', '_bx_posts_form_entry_input_date_published_info', 0, 0, 0, '', '', '', '', '', '', 'DateTimeUtc', '', 1, 0),
-('bx_posts', 'bx_posts', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
+('bx_posts', 'bx_posts', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_posts', 'bx_posts', 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
 
 
 
 
 INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES 
 INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES 

+ 5 - 2
modules/boonex/russian/data/langs/system/ru.xml

@@ -11,7 +11,8 @@
 	<string name="_all"><![CDATA[Все]]></string>
 	<string name="_all"><![CDATA[Все]]></string>
 	<string name="_Allowed Since"><![CDATA[Разрешено с]]></string>
 	<string name="_Allowed Since"><![CDATA[Разрешено с]]></string>
 	<string name="_Allowed Until"><![CDATA[Разрешено до]]></string>
 	<string name="_Allowed Until"><![CDATA[Разрешено до]]></string>
-	<string name="_Allowed actions"><![CDATA[Разрешённые действия]]></string>
+    <string name="_Allowed actions"><![CDATA[Разрешённые действия]]></string>
+    <string name="_anonymous"><![CDATA[Аноним]]></string>
 	<string name="_Are_you_sure"><![CDATA[Вы уверены?]]></string>
 	<string name="_Are_you_sure"><![CDATA[Вы уверены?]]></string>
 	<string name="_Auth type"><![CDATA[Тип авторизации]]></string>
 	<string name="_Auth type"><![CDATA[Тип авторизации]]></string>
 	<string name="_Basic"><![CDATA[Базовая]]></string>
 	<string name="_Basic"><![CDATA[Базовая]]></string>
@@ -1984,7 +1985,9 @@
 	<string name="_sys_form_input_sys_location"><![CDATA[Расположение]]></string>
 	<string name="_sys_form_input_sys_location"><![CDATA[Расположение]]></string>
     <string name="_sys_form_input_location"><![CDATA[Расположение]]></string>
     <string name="_sys_form_input_location"><![CDATA[Расположение]]></string>
 	<string name="_sys_form_input_sys_labels"><![CDATA[Метки]]></string>
 	<string name="_sys_form_input_sys_labels"><![CDATA[Метки]]></string>
-	<string name="_sys_form_input_labels"><![CDATA[Метки]]></string>
+    <string name="_sys_form_input_labels"><![CDATA[Метки]]></string>
+	<string name="_sys_form_input_sys_anonymous"><![CDATA[Анонимная публикация]]></string>
+	<string name="_sys_form_input_anonymous"><![CDATA[Анонимная публикация]]></string>
 	<string name="_sys_form_login"><![CDATA[Вход]]></string>
 	<string name="_sys_form_login"><![CDATA[Вход]]></string>
 	<string name="_sys_form_login_input_caption_system_agreement"><![CDATA[Соглашение]]></string>
 	<string name="_sys_form_login_input_caption_system_agreement"><![CDATA[Соглашение]]></string>
 	<string name="_sys_form_login_input_caption_system_captcha"><![CDATA[Капча]]></string>
 	<string name="_sys_form_login_input_caption_system_captcha"><![CDATA[Капча]]></string>

+ 1 - 1
modules/boonex/timeline/install/sql/install.sql

@@ -3,7 +3,7 @@ SET @sName = 'bx_timeline';
 -- TABLES
 -- TABLES
 CREATE TABLE IF NOT EXISTS `bx_timeline_events` (
 CREATE TABLE IF NOT EXISTS `bx_timeline_events` (
   `id` int(11) NOT NULL auto_increment,
   `id` int(11) NOT NULL auto_increment,
-  `owner_id` int(11) unsigned NOT NULL default '0',
+  `owner_id` int(11) NOT NULL default '0',
   `type` varchar(255) NOT NULL,
   `type` varchar(255) NOT NULL,
   `action` varchar(255) NOT NULL,
   `action` varchar(255) NOT NULL,
   `object_id` text NOT NULL,
   `object_id` text NOT NULL,

+ 14 - 11
template/scripts/BxBaseAccountForms.php

@@ -104,19 +104,22 @@ class BxBaseAccountForms extends BxDolProfileForms
             )));
             )));
             
             
             $a = BxDolService::call($sProfileModule, 'entity_add', array($iProfileId, $aProfileInfo));
             $a = BxDolService::call($sProfileModule, 'entity_add', array($iProfileId, $aProfileInfo));
-            if (0 != $a['code'])
-                return MsgBox(_t($a['message']));
 
 
-            BxDolService::call($sProfileModule, 'redirect_after_add', array($a['content']));
-        }
-        else {
-            $sRedirectUrl = !empty($sProfileModule) ? BxDolService::call($sProfileModule, 'profile_create_url', array(false)) : '';
-        
-            $this->_redirectAndExit(!empty($sRedirectUrl) ? $sRedirectUrl : getParam('sys_redirect_after_account_added'), true, array(
-                'account_id' => $iAccountId,
-                'profile_id' => $iProfileId,
-            ));
+            // in case of successful profile add redirect to the page after profile creation
+            if (0 == $a['code']) { 
+                BxDolService::call($sProfileModule, 'redirect_after_add', array($a['content']));
+                return;
+            }
+            // if creation failed, redirect to create profile form
         }
         }
+
+        $sRedirectUrl = !empty($sProfileModule) ? BxDolService::call($sProfileModule, 'profile_create_url', array(false)) : '';
+    
+        $this->_redirectAndExit(!empty($sRedirectUrl) ? $sRedirectUrl : getParam('sys_redirect_after_account_added'), true, array(
+            'account_id' => $iAccountId,
+            'profile_id' => $iProfileId,
+        ));
+
     }
     }
 
 
     public function onAccountCreated ($iAccountId, $isSetPendingApproval, $iAction = BX_PROFILE_ACTION_MANUAL)
     public function onAccountCreated ($iAccountId, $isSetPendingApproval, $iAction = BX_PROFILE_ACTION_MANUAL)