/**
  * Creates a move placeholder for workspaces.
  * USE ONLY INTERNALLY
  * Moving placeholder: Can be done because the system sees it as a placeholder for NEW elements like t3ver_state=1
  * Moving original: Will either create the placeholder if it doesn't exist or move existing placeholder in workspace.
  *
  * @param string $table Table name to move
  * @param integer $uid Record uid to move (online record)
  * @param integer $destPid Position to move to: $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
  * @param integer $wsUid UID of offline version of online record
  * @param t3lib_TCEmain $tcemainObj TCEmain object
  * @return void
  * @see moveRecord()
  */
 protected function moveRecord_wsPlaceholders($table, $uid, $destPid, $wsUid, t3lib_TCEmain $tcemainObj)
 {
     global $TCA;
     if ($plh = t3lib_BEfunc::getMovePlaceholder($table, $uid, 'uid')) {
         // If already a placeholder exists, move it:
         $tcemainObj->moveRecord_raw($table, $plh['uid'], $destPid);
     } else {
         // First, we create a placeholder record in the Live workspace that
         // represents the position to where the record is eventually moved to.
         $newVersion_placeholderFieldArray = array();
         if ($TCA[$table]['ctrl']['crdate']) {
             $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
         }
         if ($TCA[$table]['ctrl']['cruser_id']) {
             $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['cruser_id']] = $tcemainObj->userid;
         }
         if ($TCA[$table]['ctrl']['tstamp']) {
             $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
         }
         if ($table == 'pages') {
             // Copy page access settings from original page to placeholder
             $perms_clause = $tcemainObj->BE_USER->getPagePermsClause(1);
             $access = t3lib_BEfunc::readPageAccess($uid, $perms_clause);
             $newVersion_placeholderFieldArray['perms_userid'] = $access['perms_userid'];
             $newVersion_placeholderFieldArray['perms_groupid'] = $access['perms_groupid'];
             $newVersion_placeholderFieldArray['perms_user'] = $access['perms_user'];
             $newVersion_placeholderFieldArray['perms_group'] = $access['perms_group'];
             $newVersion_placeholderFieldArray['perms_everybody'] = $access['perms_everybody'];
         }
         $newVersion_placeholderFieldArray['t3ver_label'] = 'MOVE-TO PLACEHOLDER for #' . $uid;
         $newVersion_placeholderFieldArray['t3ver_move_id'] = $uid;
         // Setting placeholder state value for temporary record
         $newVersion_placeholderFieldArray['t3ver_state'] = 3;
         // Setting workspace - only so display of place holders can filter out those from other workspaces.
         $newVersion_placeholderFieldArray['t3ver_wsid'] = $tcemainObj->BE_USER->workspace;
         $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[MOVE-TO PLACEHOLDER for #' . $uid . ', WS#' . $tcemainObj->BE_USER->workspace . ']';
         // moving localized records requires to keep localization-settings for the placeholder too
         if (array_key_exists('languageField', $GLOBALS['TCA'][$table]['ctrl']) && array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl'])) {
             $l10nParentRec = t3lib_BEfunc::getRecord($table, $uid);
             $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['languageField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
             $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
             unset($l10nParentRec);
         }
         // Initially, create at root level.
         $newVersion_placeholderFieldArray['pid'] = 0;
         $id = 'NEW_MOVE_PLH';
         // Saving placeholder as 'original'
         $tcemainObj->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE);
         // Move the new placeholder from temporary root-level to location:
         $tcemainObj->moveRecord_raw($table, $tcemainObj->substNEWwithIDs[$id], $destPid);
         // Move the workspace-version of the original to be the version of the move-to-placeholder:
         // Setting placeholder state value for version (so it can know it is currently a new version...)
         $updateFields = array('t3ver_state' => 4);
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($wsUid), $updateFields);
     }
     // Check for the localizations of that element and move them as well
     $tcemainObj->moveL10nOverlayRecords($table, $uid, $destPid);
 }