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

Improvements for photos, profiles fields, category transferring and timeline modules.
Favorite photos now are transferring. Profiles automatically subscribe on friends' profiles.

AlexeyUna 7 лет назад
Родитель
Сommit
3b9bf1ffb7

+ 1 - 1
modules/boonex/dolphin_migration/classes/BxDolMBlogs.php

@@ -108,7 +108,7 @@ class BxDolMBlogs extends BxDolMData
         return BX_MIG_SUCCESSFUL;
     }
 	
-	protected function transferCategory($sCategory, $sPrefix = 'bx_posts', $sPreValueCateg = 'bx_posts_cats')
+	protected function transferCategory($sCategory, $sPrefix = 'bx_posts', $sPreValueCateg = 'bx_posts_cats', $iValue = 0, $sData = '')
 	{
 		return parent::transferCategory($sCategory, $sPrefix, $sPreValueCateg);
 	}

+ 7 - 3
modules/boonex/dolphin_migration/classes/BxDolMData.php

@@ -219,7 +219,7 @@ class BxDolMData
 	 *  @param int $sCategory module's category's pre values Name
 	 *  @return string value of the added category
 	 */
-	protected function transferCategory($sName, $sPrefix, $sCategory)
+    protected function transferCategory($sName, $sPrefix, $sCategory, $iValue = 0, $sData = '')
 	{
 		if (strpos($sName, ';') !== false)
 			$sName = substr($sName, 0, strpos($sName, ';'));
@@ -231,13 +231,16 @@ class BxDolMData
 			return $aValues['Value'];
 		
 		$aValues = $this -> _oDb -> getRow("SELECT MAX(`Value`) + 1 as `Value`, MAX(`Order`) + 1 as `Order` FROM `sys_form_pre_values` WHERE `Key` = :cat", array('cat' => $sCategory));
+        if ($iValue)
+            $aValues['Value'] = $iValue;
 		
 		$sQuery = $this -> _oDb -> prepare("
 			INSERT INTO `sys_form_pre_values` SET
 				`Key`	= ?, 
 				`Value`	= ?,
 				`Order`	= ?,
-				`LKey`	= ?", $sCategory, $aValues['Value'], $aValues['Order'], "_{$sPrefix}_cat_{$sTitle}");
+				`LKey` = ?,
+				`Data` = ?", $sCategory, $aValues['Value'], $aValues['Order'], "_{$sPrefix}_cat_{$sTitle}", $sData);
 				
 		$this -> _oDb -> query($sQuery);
 		BxDolStudioLanguagesUtils::getInstance() -> addLanguageString("_{$sPrefix}_cat_{$sTitle}", $sName);
@@ -304,7 +307,7 @@ class BxDolMData
 				INSERT INTO `sys_form_pre_values` SET
 					`Key`	= ?, 
 					`Value`	= ?,
-					`Order`		= ?,
+					`Order`	= ?,
 					`LKey`	= ?", $sName, $mixedKey, $i++, $sLangKey);
 				
 				$this -> _oDb -> query($sQuery);
@@ -505,6 +508,7 @@ class BxDolMData
         return $this -> _oDb -> query("ALTER TABLE `{$sTableName}` ADD `{$sIdentFieldName}` int(11) unsigned NOT NULL default '0'");
     }
 
+
 	/**
 	 *  Returns last migration field value
      * @param string $sIdentFieldName

+ 1 - 1
modules/boonex/dolphin_migration/classes/BxDolMEvents.php

@@ -119,7 +119,7 @@ class BxDolMEvents extends BxDolMData
         return BX_MIG_SUCCESSFUL;
     }
 	
-	protected function transferCategory($sCategory, $sPrefix = 'bx_events', $sPreValueCateg = 'bx_events_cats')
+	protected function transferCategory($sCategory, $sPrefix = 'bx_events', $sPreValueCateg = 'bx_events_cats', $iValue = 0, $sData = '')
 	{
 		return parent::transferCategory($sCategory, $sPrefix, $sPreValueCateg);
 	}

+ 1 - 1
modules/boonex/dolphin_migration/classes/BxDolMFiles.php

@@ -139,7 +139,7 @@ class BxDolMFiles extends BxDolMData
 		return false;		
     }
    
-	protected function transferCategory($sCategory, $sPrefix = 'bx_files', $sPreValueCateg = 'bx_files_cats')
+	protected function transferCategory($sCategory, $sPrefix = 'bx_files', $sPreValueCateg = 'bx_files_cats', $iValue = 0, $sData = '')
 	{
 		return parent::transferCategory($sCategory, $sPrefix, $sPreValueCateg);
 	}

+ 2 - 4
modules/boonex/dolphin_migration/classes/BxDolMForum.php

@@ -190,11 +190,9 @@ class BxDolMForum extends BxDolMData
 		return $iProfileId ? $this -> getProfileId($iProfileId) : 0;
 	}
 	
-	protected function transferCategory($sTitle, $sPrefix = 'bx_forum', $sCategory = 'bx_forum_cats')
+	protected function transferCategory($sTitle, $sPrefix = 'bx_forum', $sCategory = 'bx_forum_cats', $iValue = 0, $sData = '')
 	{
-		$iId = parent::transferCategory($sTitle, $sPrefix, $sCategory);
-		$sQuery = $this -> _oDb -> prepare("INSERT IGNORE INTO `bx_forum_categories` SET `category`=? ", $iId);
-		return $this -> _oDb-> query($sQuery) ? $iId : false;
+		return parent::transferCategory($sTitle, $sPrefix, $sCategory);
 	}	
 
 	/**

+ 1 - 1
modules/boonex/dolphin_migration/classes/BxDolMGroups.php

@@ -116,7 +116,7 @@ class BxDolMGroups extends BxDolMData
         return BX_MIG_SUCCESSFUL;
     }
 	
-	protected function transferCategory($sCategory, $sPrefix = 'bx_groups', $sPreValueCateg = 'bx_groups_cats')
+	protected function transferCategory($sCategory, $sPrefix = 'bx_groups', $sPreValueCateg = 'bx_groups_cats', $iValue = 0, $sData = '')
 	{
 		return parent::transferCategory($sCategory, $sPrefix, $sPreValueCateg);
 	}

+ 1 - 1
modules/boonex/dolphin_migration/classes/BxDolMMarket.php

@@ -162,7 +162,7 @@ class BxDolMMarket extends BxDolMData
 		return $aResult;
     }
 	
-	protected function transferCategory($sCategory, $sPrefix = 'bx_market', $sPreValueCateg = 'bx_market_cats')
+	protected function transferCategory($sCategory, $sPrefix = 'bx_market', $sPreValueCateg = 'bx_market_cats', $iValue = 0, $sData = '')
 	{
 		return parent::transferCategory($sCategory, $sPrefix, $sPreValueCateg);
 	}

+ 15 - 1
modules/boonex/dolphin_migration/classes/BxDolMPhotoAlbums.php

@@ -146,13 +146,27 @@ class BxDolMPhotoAlbums extends BxDolMData
 						$iTransferred++;
 						
 						$this -> transferTags((int)$aValue['ID'], $iId, $this -> _oConfig -> _aMigrationModules[$this -> _sModuleName]['type'], $this -> _oConfig -> _aMigrationModules[$this -> _sModuleName]['keywords']);
+						$this -> transferFavorites((int)$aValue['ID'], $iId);
 					}
 				}
 			}	
 				  
 	  return $iTransferred;
    }
-       	
+
+    private function transferFavorites($iPhotoId, $iNewID){
+        $aData = $this->_mDb->getRow("SELECT * FROM `bx_photos_favorites` WHERE `ID`=:id LIMIT 1", array('id' => $iPhotoId));
+        if (empty($aData))
+            return false;
+
+        $iProfileId = $this -> getProfileId((int)$aData['Profile']);
+        if (!$iProfileId)
+            return false;
+
+        $sQuery = $this -> _oDb -> prepare("INSERT INTO `bx_albums_favorites_media_track` SET `object_id` = ?, `author_id` = ?, `date` = ?", $iNewID, $iProfileId, ($aData['Date'] ? $aData['Date'] : time()));
+        return $this -> _oDb -> query($sQuery);
+    }
+
 	private function isFileExisted($iAuthor, $sTitle, $iDate){    	
     	$sQuery  = $this -> _oDb ->  prepare("SELECT COUNT(*) FROM `bx_albums_files` WHERE `profile_id` = ? AND `file_name` = ? AND `added` = ? LIMIT 1", $iAuthor, $sTitle, $iDate);
         return (bool)$this -> _oDb -> getOne($sQuery);

+ 1 - 1
modules/boonex/dolphin_migration/classes/BxDolMPolls.php

@@ -110,7 +110,7 @@ class BxDolMPolls extends BxDolMData
         return BX_MIG_SUCCESSFUL;
     }
 	
-	protected function transferCategory($sCategory, $sPrefix = 'bx_polls', $sPreValueCateg = 'bx_polls_cats')
+	protected function transferCategory($sCategory, $sPrefix = 'bx_polls', $sPreValueCateg = 'bx_polls_cats', $iValue = 0, $sData = '')
 	{
 		return parent::transferCategory($sCategory, $sPrefix, $sPreValueCateg);
 	}

+ 29 - 4
modules/boonex/dolphin_migration/classes/BxDolMProfiles.php

@@ -230,13 +230,15 @@ class BxDolMProfiles extends BxDolMData
                             $sQuery = $this->_oDb->prepare("UPDATE `bx_persons_data` SET `author` = ? WHERE `id` = ?", $iProfile, $iContentId);
                             $this->_oDb->query($sQuery);
 
-                         if (isset($aValue['Country']) || isset($aValue['City']) || isset($aValue['zip'])) {
-                                $this->_oDb->query("INSERT INTO `bx_persons_meta_locations` SET `object_id`=:object, `country`=:country, `city`=:city, zip = :zip",
+                         if (isset($aValue['Country']) || isset($aValue['City']) || isset($aValue['zip']) || isset($aValue['State'])) {
+                                $this->_oDb->query("INSERT INTO `bx_persons_meta_locations` 
+                                                    SET `object_id`=:object, `country`=:country, `city`=:city, zip = :zip, `state`=:state",
                                     array(
                                         'object' => $iContentId,
                                         'country' => isset($aValue['Country']) ? $aValue['Country'] : '',
                                         'city' => isset($aValue['City']) ? $aValue['City'] : '',
-                                        'zip' => isset($aValue['zip']) ? $aValue['zip'] : ''
+                                        'zip' => isset($aValue['zip']) ? $aValue['zip'] : '',
+                                        'state' => isset($aValue['State']) ? $aValue['State'] : '',
                                 ));
                             }
                         }
@@ -371,6 +373,19 @@ class BxDolMProfiles extends BxDolMData
 				   ", $iUserId, $iFriendId, $aValue['Check']);
                 $iResult = $this -> _oDb -> query($sQuery);
 
+                // make initiator to follow content
+                $this->_oDb->query("
+						INSERT IGNORE INTO
+							`sys_profiles_conn_subscriptions`
+						SET
+						   `initiator`	=:initiator,
+						   `content`    =:content ,
+						   `added`     	= UNIX_TIMESTAMP()
+				   ", array('initiator' => $iUserId, 'content' => $iFriendId));
+
+                $iResult = $this -> _oDb -> query($sQuery);
+
+
 				if ($iResult && (int)$aValue['Check']){
                     $sQuery = $this->_oDb->prepare("
                             INSERT IGNORE INTO
@@ -382,7 +397,17 @@ class BxDolMProfiles extends BxDolMData
                                `added`     	= UNIX_TIMESTAMP()
                        ", $iFriendId, $iUserId, 1);
                         $this->_oDb->query($sQuery);
-                    }
+
+                         // make content to follow initiator
+                        $this->_oDb->query("
+                            INSERT IGNORE INTO
+                                `sys_profiles_conn_subscriptions`
+                            SET
+                               `initiator`	=:initiator,
+                               `content`    =:content ,
+                               `added`     	= UNIX_TIMESTAMP()
+                       ", array('initiator' => $iFriendId, 'content' => $iUserId));
+                 }
 			}
 		}
 	}

+ 8 - 6
modules/boonex/dolphin_migration/classes/BxDolMProfilesFields.php

@@ -247,7 +247,9 @@ class BxDolMProfilesFields extends BxDolMData
 	private function convertValues($aFiled, $sFiledValue)
 	{
 		$aOriginalFields = $this -> getAssocFields();
-		if (!$aOriginalFields[$aFiled['name']]['values'] || $aOriginalFields[$aFiled['name']]['values'] && substr($aOriginalFields[$aFiled['name']]['values'], 0, 2) != '#!')
+		if (!$aOriginalFields[$aFiled['name']]['values'] ||
+            ($aOriginalFields[$aFiled['name']]['values'] && substr($aOriginalFields[$aFiled['name']]['values'], 0, 2) != '#!')
+               || $aOriginalFields[$aFiled['name']]['type'] !== 'select_set')
 			return $sFiledValue;
 		
 		$aItems = explode(',', $sFiledValue);
@@ -325,10 +327,10 @@ class BxDolMProfilesFields extends BxDolMData
 			if ($this -> isKeyPreKeyExits($sKey) && $bGetKeyIfExists)
 				return $sValues;
 			
-			$aValues = $this -> getPreValuesBy($sKey);
-			foreach($aValues as $iKey => $sValue) {
-				$aItems[$iKey] = $this -> getLKeyTranslations($sValue);
-                $aItems[$iKey] = $aItems[$iKey] ? $aItems[$iKey] : $sValue;
+			$aValues = $this -> getPreValuesBy($sKey, 'Value');
+			foreach($aValues as $mixedKey => $sValue) {
+				$aItems[$mixedKey] = $this -> getLKeyTranslations($sValue);
+                $aItems[$mixedKey] = $aItems[$mixedKey] ? $aItems[$mixedKey] : $sValue;
             }
 		}
 		else
@@ -347,9 +349,9 @@ class BxDolMProfilesFields extends BxDolMData
 			return false;
 
 		$aRecords = $this -> _oDb -> getAll("SELECT  * FROM `sys_form_inputs` WHERE `object` =  'bx_person' AND `{$this -> _sTransferFieldIdent}` != 0");
+        $iNumber = 0;
 		if (!empty($aRecords))
 		{
-			$iNumber = 0;		
 			foreach($aRecords as $iKey => $aValue)
 			{
 				$sSql = $this -> _oDb -> prepare("DELETE `td`, `tdi` FROM `sys_form_display_inputs` AS `tdi` LEFT JOIN `sys_form_inputs` AS `td` ON `tdi`.`input_name`=`td`.`name` WHERE `td`.`object`='bx_person' AND `td`.`name` = ?", $aValue['name']);

+ 2 - 2
modules/boonex/dolphin_migration/classes/BxDolMTimeline.php

@@ -365,7 +365,7 @@ class BxDolMTimeline extends BxDolMData
 								`description`			= ?,		
 								`date`					= ?,
 								`active`				= ?,
-								`hidden`				= ?
+								`status`				= ?
 						 ", 
 							$aInfo['owner_id'], 
 							$aInfo['type'],
@@ -377,7 +377,7 @@ class BxDolMTimeline extends BxDolMData
 							$aInfo['description'],
 							$aInfo['date'],
 							$aInfo['active'],
-							$aInfo['hidden']
+							$aInfo['hidden'] ? 'hidden' : 'active'
 							);			
 			
 				$this -> _oDb -> query($sQuery);