Dolphin Migration Errors

Migrate video from dolphin generate this error: in dolphin_migration/clases/BxDolMVideos.php And I really don't understand why it should be mandatory when someone uploads a video in UNA to be obliged to add a title or description. or title. Uploading a video should not force the user to give a title or description as it is with photos, an absurd rule.

This error clearly shows how much consideration the UNA team has for those who bought licenses from boonex and spent money on UNA development and want to migrate to UNA, after many years there is still no migration script , that allows them to migrate their content,

this is just an example but there are many errors. the result is that the migration script shows that all the videos have been transferred, but the reality is that only the databases have been transferred, but none of the videos work, only one shows that it has been transferred, but it never loads, the rest of the videos are missing, only the titles appear and the descriptions

Sep 07 05:01:04 [3] /grid.php?o=bx_dolphin_migration_transfers&a=run&skin=artificer&start=0&ids[]=videos&order_dir=ASC&csrf_token=fe0c00b7047ab0c5a77e630811f8589d&_r=0.2036714785414382 Database query error
  Error: Column 'text' cannot be nullQuery: 
                                INSERT INTO`bx_videos_entries`SET`author`            = ?,
                                    `added`             = ?,
                                    `changed`           = ?,
                                    `video`             = 0,
                                    `title`             = ?,
                                    `allow_view_to`     = ?,
                                    `text`              = ?,
                                    `status_admin`      = ?,
                                    `status`            = ?,
                                    `cat`               = ?
                             
  Account ID: 1


I tried to change the values ​​in the migration script, for the enhanced title but for the description I have the same error

          $iTransferred = 0;
          foreach($aResult as $iKey => $aValue)
          {
                $iVideoId = $this -> isItemExisted($aValue['ID']);
                if ($iVideoId)
                    continue;
                // Sugestion start$sVideoTitle = !empty($aValue['Title']) ? $aValue['Title'] : 'Untitled Video'; // Default title if missing$sVideoDescription = !empty($aValue['Description']) ? $aValue['Description'] : 'No description'; // Default description if missing// Sugestion finish// $sVideoTitle = $aValue['Title']; // original code


                $sQuery = $this -> _oDb -> prepare(
                        "
                                INSERT INTO
                                    `bx_videos_entries`
                                SET
                                    `author`            = ?,
                                    `added`             = ?,
                                    `changed`           = ?,
                                    `video`             = 0,
                                    `title`             = ?,
                                    `allow_view_to`     = ?,
                                    `text`              = ?,
                                    `status_admin`      = ?,
                                    `status`            = ?,
                                    `cat`               = ?
                             ",
                        $iProfileId,
                        $aValue['Date'] ? $aValue['Date'] : time(),
                        $aValue['Date'] ? $aValue['Date'] : time(),
                        $sVideoTitle,
                        $this -> getPrivacy($aValue['Owner'], (int)$aValue['AllowAlbumView'], 'videos', 'album_view'),
                        // $aValue['Description'], //ORIGINAL CODE$sVideoDescription,$aValue['admin_status'] == 'active' ? 'active' : 'hidden',$aValue['status'] == 'approved' ? 'active' : 'hidden',
                        $this -> transferCategory($aValue['Categories'], 'bx_videos', 'bx_videos_cats')
                    );

Any sugestion? another error another error that I could not solve:

Sep 07 06:09:20 [3] /grid.php?o=bx_dolphin_migration_transfers&a=run&skin=artificer&start=10&ids[]=simple_messenger&ids[]=timeline&ids[]=membership_levels&order_dir=ASC&csrf_token=28785c6e70e82a3c85e228545fbf192c&_r=0.6021135109759834 Database query error
  Error: Duplicate entry '' for key 'hash'Query: INSERT INTO `bx_messenger_lots` SET `created` = UNIX_TIMESTAMP(), `author`= :author, `participants` = :parts, `type` = 2Account ID: 1


  • 804
  • More
Replies (9)
    • Hello!

      It seems like the Description field is missing in the RayVideoFiles table. Could you let me know which version of Dolphin you're using? There might be some database modifications involved.

      You could try replacing:

      INSERT INTO
      

      with:

      INSERT IGNORE INTO
      

      However, before making these changes, it would be better to first remove any transferred content for the videos.

      Additionally, please ensure that the video files in the Dolphin folder physically exist and can be accessed by the script. They need to have the correct permissions to be processed correctly.

      Regarding the Messenger module: the field `hash` was introduced recently and hasn't been added to the migration tool, because there haven't been attempted to use it. The module is not as commonly used by clients anymore. I will try to release an update for the Messenger module in this script soon.

      • i traing to migrate from the latest version 7.4.2 , the folder permisons for the old site is 777 and my folder permison for the storage folder i set to

        sudo find ./storage -type d -exec chmod 775 {} \;  
        

        I can upload videos and they are processed correctly, so it should import the old ones correctly too.

        • Video migration generate this error:

          Sep 06 07:06:09 [3] /grid.php?o=bx_dolphin_migration_transfers&a=run&skin=artificer&start=0&ids[]=videos&order_dir=ASC&csrf_token=9dedda057142a32303707b18fd38d4e7&_r=0.8000806461387326 Database query error
            Error: Column 'title' cannot be null
            QueryINSERT INTO
          									`bx_videos_entries`
          								SET
          									`author`   			= ?,
          									`added`      		= ?,
          									`changed`   		= ?,
          									`video`				= 0,
          									`title`				= ?,
          									`allow_view_to` 	= ?,
          									`text`				= ?,
          									`status_admin`		= ?,
                                              `status`            = ?,
                                              `cat`               = ?
          							 
            Account ID: 1
          

          I solved the error with the title this way, in the BxDolMVideos.php I don't know if it's correct but I no longer have the error for the title:

          // $sVideoTitle = $aValue['Title']; // original code
          $sVideoTitle = !empty($aValue['Title']) ? $aValue['Title'] : 'Untitled Video'; // Set default title if missing
          
          • The problem is this error:

            Sep 07 04:15:43 [3] /grid.php?o=bx_dolphin_migration_transfers&a=run&skin=artificer&start=0&ids[]=videos&order_dir=ASC&csrf_token=2612cd030eff77fc1ef8869e67ccecc3&_r=0.796265849563556 Database query error
              Error: Column 'text' cannot be null
              QueryINSERT INTO
            									`bx_videos_entries`
            								SET
            									`author`   			= ?,
            									`added`      		= ?,
            									`changed`   		= ?,
            									`video`				= 0,
            									`title`				= ?,
            									`allow_view_to` 	= ?,
            									`text`				= ?,
            									`status_admin`		= ?,
                                                `status`            = ?,
                                                `cat`               = ?
            							 
              Account ID: 1
            

            I tried several solutions but none of them work like

                            $sVideoDescription = !empty($aValue['Description']) ? $aValue['Description'] : 'No description'; // Default description if missing
            
            • Some videos from the old site have a title some don't, also some videos have a description some don't, that's why these errors occur.

              • the bx_videos_entries table

                DESCRIBE bx_videos_entries;
                

                sow me this structure:

                | Field             | Type                                          | Null | Key | Default  | Extra          |
                |-------------------|-----------------------------------------------|------|-----|----------|----------------|
                | id                | int(10) unsigned                              | NO   | PRI | NULL     | auto_increment |
                | author            | int(10) unsigned                              | NO   |     | 0        |                |
                | added             | int(11)                                       | NO   |     | 0        |                |
                | changed           | int(11)                                       | NO   |     | 0        |                |
                | thumb             | int(11)                                       | NO   |     | 0        |                |
                | poster            | int(11)                                       | NO   |     | 0        |                |
                | video_source      | enum('upload','embed')                        | NO   |     | upload   |                |
                | video             | int(11)                                       | NO   |     | 0        |                |
                | video_embed       | text                                          | YES  |     | NULL     |                |
                | video_embed_data  | text                                          | YES  |     | NULL     |                |
                | title             | varchar(255)                                  | NO   | MUL | NULL     |                |
                | cat               | int(11)                                       | NO   |     | NULL     |                |
                | multicat          | text                                          | NO   |     | NULL     |                |
                | text              | text                                          | NO   |     | NULL     |                |
                | duration          | int(11)                                       | NO   |     | NULL     |                |
                | labels            | text                                          | NO   |     | NULL     |                |
                | location          | text                                          | NO   |     | NULL     |                |
                | views             | int(11)                                       | NO   |     | 0        |                |
                | rate              | float                                         | NO   |     | 0        |                |
                | votes             | int(11)                                       | NO   |     | 0        |                |
                | srate             | float                                         | NO   |     | 0        |                |
                | svotes            | int(11)                                       | NO   |     | 0        |                |
                | rrate             | float                                         | NO   |     | 0        |                |
                | rvotes            | int(11)                                       | NO   |     | 0        |                |
                | score             | int(11)                                       | NO   |     | 0        |                |
                | sc_up             | int(11)                                       | NO   |     | 0        |                |
                | sc_down           | int(11)                                       | NO   |     | 0        |                |
                | favorites         | int(11)                                       | NO   |     | 0        |                |
                | comments          | int(11)                                       | NO   |     | 0        |                |
                | reports           | int(11)                                       | NO   |     | 0        |                |
                | featured          | int(11)                                       | NO   |     | 0        |                |
                | cf                | int(11)                                       | NO   |     | 1        |                |
                | allow_view_to     | varchar(16)                                   | NO   |     | 3        |                |
                | status            | enum('active','awaiting','failed','hidden')   | NO   |     | active   |                |
                | status_admin      | enum('active','hidden','pending')             | NO   |     | active   |                |
                
                
                

                and the ray video files

                DESCRIBE RayVideoFiles;
                

                show me this structure so the description field exists the difference between the title and description fields is that one has a null key, the other does not. so is the database from UNA the some diference the problem is in the UNA video description the field name is text not description as in the original code // $aValue['Description'], //ORIGINAL CODE I think there is a mistake here because this field does not actually exist, or maybe I don't understand well, you should know better than me how UNA works. So the transfer for description need to be            $aValue['text'] as it is in the UNA database in line 110 https://github.com/unacms/una/edit/master/modules/boonex/dolphin_migration/classes/BxDolMVideos.php to make sense or to rename the field from UNA video from the text in Description as it was in ray video, or video description it seems more logical to me.

                | Field          | Type                                                       | Null | Key | Default    | Extra          |
                |----------------|------------------------------------------------------------|------|-----|------------|----------------|
                | ID             | int(11)                                                    | NO   | PRI | NULL       | auto_increment |
                | Categories     | text                                                       | NO   | MUL | NULL       |                |
                | Title          | varchar(255)                                               | NO   | MUL | NULL       |                |
                | Uri            | varchar(255)                                               | NO   | UNI | NULL       |                |
                | Tags           | text                                                       | NO   | MUL | NULL       |                |
                | Description    | text                                                       | NO   |     | NULL       |                |
                | Time           | int(11)                                                    | NO   |     | 0          |                |
                | Date           | int(20)                                                    | NO   |     | 0          |                |
                | Owner          | varchar(64)                                                | NO   | MUL | NULL       |                |
                | Views          | int(12)                                                    | YES  |     | 0          |                |
                | Rate           | float                                                      | NO   |     | NULL       |                |
                | RateCount      | int(11)                                                    | NO   |     | NULL       |                |
                | CommentsCount  | int(11)                                                    | NO   |     | NULL       |                |
                | Featured       | tinyint(4)                                                 | NO   |     | NULL       |                |
                | Status         | enum('approved','disapproved','pending','processing','failed') | NO   |     | pending    |                |
                | Source         | varchar(20)                                                | NO   |     | NULL       |                |
                | Video          | varchar(32)                                                | NO   |     | NULL       |                |
                
                
                
                • so this is my solution for the mistake, transfers the videos nut not all for BxDolMVideos.php my sugestion;

                            {
                                  $iVideoId = $this -> isItemExisted($aValue['ID']);
                                  if ($iVideoId)
                                      continue;
                                  // Sugestion start
                                  // $sVideoTitle = $aValue['Title']; // original code
                                  $sVideoTitle = !empty($aValue['Title']) ? $aValue['Title'] : 'Untitled Video'; // Default title if missing
                                  // Sugestion finish
                                  // Sugestion start
                                  $sVideoText = !empty($aValue['Description']) ? $aValue['Description'] : 'No description available'; // Default description if missing
                                  // Sugestion finish
                  
                  
                                  $sQuery = $this -> _oDb -> prepare(
                                          "
                                                  INSERT INTO
                                                      `bx_videos_entries`
                                                  SET
                                                      `author`            = ?,
                                                      `added`             = ?,
                                                      `changed`           = ?,
                                                      `video`             = 0,
                                                      `title`             = ?,
                                                      `allow_view_to`     = ?,
                                                      `text`              = ?,
                                                      `status_admin`      = ?,
                                                      `status`            = ?,
                                                      `cat`               = ?
                                               ",
                                          $iProfileId,
                                          $aValue['Date'] ? $aValue['Date'] : time(),
                                          $aValue['Date'] ? $aValue['Date'] : time(),
                                          $sVideoTitle,
                                          $this -> getPrivacy($aValue['Owner'], (int)$aValue['AllowAlbumView'], 'videos', 'album_view'),
                                          // $aValue['Description'], original code
                                          // Sugestion start
                                          $sVideoText,  // Aici folosești descrierea din Dolphin
                                          // Sugestion finish
                                          $aValue['admin_status'] == 'active' ? 'active' : 'hidden',
                                          $aValue['status'] == 'approved' ? 'active' : 'hidden',
                                          $this -> transferCategory($aValue['Categories'], 'bx_videos', 'bx_videos_cats')
                                      );
                  

                  BxDolMVideoAlbums.php i have edit some line:

                              {
                                  // Sugestion start
                                  // $sAlbumTitle = isset($aValue['Caption']) && $aValue['Caption'] ? $aValue['Caption'] : 'Profile Videos';  
                                  $sAlbumTitle = !empty($aValue['Caption']) ? $aValue['Caption'] : 'Profile Videos';
                                  // Sugestion finish
                                  // Sugestion start
                                  $sAlbumText = isset($aValue['Description']) && $aValue['Description'] ? $aValue['Description'] : ''; // Description migration
                                  // Sugestion finish
                                  $sQuery = $this -> _oDb -> prepare( 
                                               "
                                                  INSERT INTO
                                                      `bx_albums_albums`
                                                  SET
                                                      `author`            = ?,
                                                      `added`             = ?,
                                                      `changed`           = ?,
                                                      `thumb`             = 0,
                                                      `title`             = ?,
                                                      `allow_view_to`     = ?,
                                                      `text`              = ?,
                                                      `status_admin`      = ?
                                               ", 
                                                  $iProfileId, 
                                                  $aValue['Date'] ? $aValue['Date'] : time(), 
                                                  $aValue['Date'] ? $aValue['Date'] : time(), 
                                                  $sAlbumTitle,
                                                  $this -> getPrivacy($aValue['Owner'], (int)$aValue['AllowAlbumView'], 'videos', 'album_view'),
                                                  // $aValue['Description'], //original code to be replace
                                                  // Sugestion start
                                                  $sAlbumText,
                                                  // Sugestion finish
                                                  $aValue['Status'] == 'active' ? 'active' : 'hidden'
                                                  );          
                  

                  if you have beter solition add your sugestion from Videos 643 pnly 44 videos were transferred and most transfered are embed practcal is emty only some real videos have ben transfered i'm waiting to see if will be transcoded

                  • Also i not see in the code any reference regarding mp4 or vlf anly about .mp4v, I ask this because out of several hundreds of videos, the transfer script only transfers 3

                    
                                    $sFileName = "{$aValue['ID']}.m4v";
                                    $sVideoPath = $this -> _sVideoFilesPath . $sFileName;
                                    if (file_exists($sVideoPath))
                                    {
                                        $oStorage = BxDolStorage::getObjectInstance('bx_videos_videos');
                                        $iId = $oStorage -> storeFileFromPath($sVideoPath, false, $iProfileId, $iVideoId);
                                        if ($iId)
                                        { 
                                            $this -> _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);
                                            $this->transferSVotes((int)$aValue['ID'], $iId);
                    
                    
                                            $this->_oDb->query("UPDATE `bx_videos_entries` SET `comments` = :comments, `video`=:video WHERE `id` = :id", array('id' => $iVideoId, 'video' => $iId, 'comments' => $this->transferComments($iVideoId, $aValue['ID'], 'videos')));
                                        }
                                    }
                    
                    • Also i sugest to add the transferViews function, for the users is very important the content vievs:

                          // Sugestion start
                      
                          /**
                      
                           * Transfers the view count of a video.
                      
                           * @param int $iItemId original video ID
                      
                           * @param int $iNewID new video ID in UNA
                      
                           * @return boolean
                      
                           */
                      
                          private function transferViews($iItemId, $iNewID) {
                      
                              // Get the view count from RayVideoFiles
                      
                              $aData = $this->_mDb->getRow("SELECT `Views` FROM `RayVideoFiles` WHERE `ID` = :id LIMIT 1", array('id' => $iItemId));
                      
                              if (empty($aData))
                      
                                  return false;
                      
                      
                      
                      
                      
                      
                      
                              // Update the view count in bx_videos_entries
                      
                              $sQuery = $this->_oDb->prepare("UPDATE `bx_videos_entries` SET `views` = ? WHERE `id` = ?", $aData['Views'], $iNewID);
                      
                              return $this->_oDb->query($sQuery);
                      
                          }
                      
                          // Sugestion finish
                      

                      and:

                       // Sugestion start
                      // Transfer the view count
                      
                      $this->transferViews((int)$aValue['ID'], $iVideoId);
                      
                      // Sugestion finish
                      

                      so the file BxDolMVideos.php become:

                       defined('BX_DOL') or die('hack attempt');
                      /**
                       * Copyright (c) UNA, Inc - https://una.io
                       * MIT License - https://opensource.org/licenses/MIT
                       *
                       * @defgroup    DolphinMigration  Dolphin Migration
                       * @ingroup     UnaModules
                       *
                       * @{
                       */
                      
                      
                      require_once('BxDolMData.php');
                      bx_import('BxDolStorage');
                          
                      class BxDolMVideos extends BxDolMData
                      {
                          private $_sVideoFilesPath;
                      
                      
                          public function __construct(&$oMigrationModule, &$oDb)
                          {
                              parent::__construct($oMigrationModule, $oDb);
                              $this -> _sModuleName = 'videos';
                              $this -> _sTableWithTransKey = 'bx_videos_entries';
                              $this -> _sVideoFilesPath = $this -> _oDb -> getExtraParam('root') . 'flash' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . "video" . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR;
                      
                      
                          }
                          
                          public function getTotalRecords()
                          {
                              return $this -> _mDb -> getOne("SELECT SUM(`ObjCount`) as `obj` 
                                                                  FROM `" . $this -> _oConfig -> _aMigrationModules[$this -> _sModuleName]['table_name_videos'] ."` 
                                                                  WHERE `Type` = 'bx_videos' AND `Uri` <> 'Hidden'");
                          }
                          
                          public function runMigration()
                          {
                              if (!$this -> getTotalRecords())
                              {
                                    $this -> setResultStatus(_t('_bx_dolphin_migration_no_data_to_transfer'));
                                    return BX_MIG_SUCCESSFUL;
                              }
                      
                      
                              $sWhereCount = '';
                              if ($this -> _oConfig -> _bTransferEmpty)
                                  $sWhereCount = " AND `ObjCount` <> 0";
                      
                      
                              $this -> setResultStatus(_t('_bx_dolphin_migration_started_migration_videos'));
                              
                              $this -> createMIdField();
                              $aResult = $this -> _mDb -> getAll("SELECT * FROM `" . $this -> _oConfig -> _aMigrationModules[$this -> _sModuleName]['table_name_videos'] ."` 
                                                                  WHERE `Type` = 'bx_videos' AND `Uri` <> 'Hidden' {$sWhereCount} ORDER BY `ID` ASC");
                      
                      
                              foreach($aResult as $iKey => $aValue)
                              {           
                                  $iProfileId = $this -> getProfileId((int)$aValue['Owner']);
                                  if (!$iProfileId) 
                                      continue;
                      
                      
                                  $this -> migrateVideo($aValue['ID'], $iProfileId);
                             }
                      
                      
                              // set as finished;$this -> setResultStatus(_t('_bx_dolphin_migration_started_migration_videos_finished', $this -> _iTransferred));
                              return BX_MIG_SUCCESSFUL;
                          }
                          
                         /**
                          * Migrates all photo albums and users photos
                          * @param int $iAlbumId original albums id
                          * @param int $iProfileId una profile ID
                          * @param int $iNewPhotoId created una Album
                          * @return Integer
                               */  
                         private function migrateVideo($iAlbumId, $iProfileId){
                                $aResult = $this -> _mDb -> getAll("SELECT  `m`.*, `a`.`AllowAlbumView`, `a`.`Status` as `admin_status`, `m`.`Status` as `status`
                                                                          FROM  `sys_albums_objects` as `o`
                                                                          LEFT JOIN `sys_albums` as `a` ON `o`.`id_album` = `a`.`ID`
                                                                          LEFT JOIN `" . $this -> _oConfig -> _aMigrationModules[$this -> _sModuleName]['table_name'] ."` as `m` ON `o`.`id_object` = `m`.`ID`
                                                                          WHERE  `o`.`id_album` = :album ORDER BY `o`.`id_object` ASC", array('album' => $iAlbumId));
                      
                      
                                $iTransferred = 0;
                                foreach($aResult as $iKey => $aValue)
                                {
                                      $iVideoId = $this -> isItemExisted($aValue['ID']);
                                      if ($iVideoId)
                                          continue;
                                      // Sugestion start// $sVideoTitle = $aValue['Title']; // original code$sVideoTitle = !empty($aValue['Title']) ? $aValue['Title'] : 'Untitled Video'; // Default title if missing// Sugestion finish// Sugestion start$sVideoText = !empty($aValue['Description']) ? $aValue['Description'] : 'No description available'; // Default description if missing// Sugestion finish
                      
                      
                                      $sQuery = $this -> _oDb -> prepare(
                                              "
                                                      INSERT INTO
                                                          `bx_videos_entries`
                                                      SET
                                                          `author`            = ?,
                                                          `added`             = ?,
                                                          `changed`           = ?,
                                                          `video`             = 0,
                                                          `title`             = ?,
                                                          `allow_view_to`     = ?,
                                                          `text`              = ?,
                                                          `status_admin`      = ?,
                                                          `status`            = ?,
                                                          `cat`               = ?
                                                   ",
                                              $iProfileId,
                                              $aValue['Date'] ? $aValue['Date'] : time(),
                                              $aValue['Date'] ? $aValue['Date'] : time(),
                                              $sVideoTitle,
                                              $this -> getPrivacy($aValue['Owner'], (int)$aValue['AllowAlbumView'], 'videos', 'album_view'),
                                              // $aValue['Description'], original code// Sugestion start$sVideoText,  // Aici folosești descrierea din Dolphin// Sugestion finish$aValue['admin_status'] == 'active' ? 'active' : 'hidden',
                                              $aValue['status'] == 'approved' ? 'active' : 'hidden',
                                              $this -> transferCategory($aValue['Categories'], 'bx_videos', 'bx_videos_cats')
                                          );
                      
                      
                                          $this -> _oDb -> query($sQuery);
                                          if ($iVideoId = $this -> _oDb -> lastId())
                                              $this -> setMID($iVideoId, $aValue['ID']);
                                          elsecontinue;
                      
                      
                                      $sFileName = "{$aValue['ID']}.m4v";
                                      $sVideoPath = $this -> _sVideoFilesPath . $sFileName;
                                      if (file_exists($sVideoPath))
                                      {
                                          $oStorage = BxDolStorage::getObjectInstance('bx_videos_videos');
                                          $iId = $oStorage -> storeFileFromPath($sVideoPath, false, $iProfileId, $iVideoId);
                                          if ($iId)
                                          { 
                                              $this -> _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);
                                              $this->transferSVotes((int)$aValue['ID'], $iId);
                                              // Sugestion start// Transfer the view count$this->transferViews((int)$aValue['ID'], $iVideoId);
                                              // Sugestion finish
                      
                      
                                              $this->_oDb->query("UPDATE `bx_videos_entries` SET `comments` = :comments, `video`=:video WHERE `id` = :id", array('id' => $iVideoId, 'video' => $iId, 'comments' => $this->transferComments($iVideoId, $aValue['ID'], 'videos')));
                                          }
                                      }
                                  }   
                                        
                            return $iTransferred;
                         }
                      
                      
                          // Sugestion start/**
                           * Transfers the view count of a video.
                           * @param int $iItemId original video ID
                           * @param int $iNewID new video ID in UNA
                           * @return boolean
                           */private function transferViews($iItemId, $iNewID) {
                              // Get the view count from RayVideoFiles$aData = $this->_mDb->getRow("SELECT `Views` FROM `RayVideoFiles` WHERE `ID` = :id LIMIT 1", array('id' => $iItemId));
                              if (empty($aData))
                                  return false;
                      
                      
                              // Update the view count in bx_videos_entries$sQuery = $this->_oDb->prepare("UPDATE `bx_videos_entries` SET `views` = ? WHERE `id` = ?", $aData['Views'], $iNewID);
                              return $this->_oDb->query($sQuery);
                          }
                          // Sugestion finish
                      
                      
                          private function transferFavorites($iItemId, $iNewID){
                              $aData = $this->_mDb->getRow("SELECT * FROM `bx_videos_favorites` WHERE `ID`=:id LIMIT 1", array('id' => $iItemId));
                              if (empty($aData))
                                  return false;
                      
                      
                              $iProfileId = $this -> getProfileId((int)$aData['Profile']);
                              if (!$iProfileId)
                                  return false;
                      
                      
                              $sQuery = $this -> _oDb -> prepare("INSERT INTO `bx_videos_favorites_track` SET `object_id` = ?, `author_id` = ?, `date` = ?", $iNewID, $iProfileId, ($aData['Date'] ? $aData['Date'] : time()));
                              return $this -> _oDb -> query($sQuery);
                          }
                      
                      
                          private function transferSVotes($iItemId, $iNewID){
                              $aData = $this->_mDb->getRow("SELECT * FROM `bx_videos_rating` WHERE `gal_id`=:id LIMIT 1", array('id' => $iItemId));
                              if (empty($aData))
                                  return false;
                      
                      
                              $sQuery = $this->_oDb->prepare("INSERT INTO `bx_videos_svotes` SET `object_id` = ?, `count` = ?, `sum` = ?", $iNewID, $aData['gal_rating_count'], $aData['gal_rating_sum']);
                              $this->_oDb->query("UPDATE `bx_videos_entries` SET `svotes` = :votes WHERE `id` = :id", array('id' => $iItemId, 'votes' => $aData['gal_rating_count']));
                              return $this->_oDb->query($sQuery);
                          }
                      
                      
                          public function removeContent()
                          {
                              if (!$this -> _oDb -> isTableExists($this -> _sTableWithTransKey) || !$this -> _oDb -> isFieldExists($this -> _sTableWithTransKey, $this -> _sTransferFieldIdent))
                                  return false;
                              
                              $aRecords = $this -> _oDb -> getAll("SELECT * FROM `{$this -> _sTableWithTransKey}` WHERE `{$this -> _sTransferFieldIdent}` !=0");
                              $iNumber = 0;       
                              if (!empty($aRecords))
                              {       
                                  foreach($aRecords as $iKey => $aValue)
                                  {
                                      BxDolService::call('bx_videos', 'delete_entity', array($aValue['id']));
                                      $iNumber++;
                                  }
                              }
                      
                      
                              parent::removeContent();
                              return $iNumber;
                          }
                      }
                      
                      
                      /** @} */
                      
                      
                      
                      Login or Join to comment.