/**
  * Setting stage of record
  *
  * @param string $table Table name
  * @param integer $integer Record UID
  * @param integer $stageId Stage ID to set
  * @param string $comment Comment that goes into log
  * @param boolean $notificationEmailInfo Accumulate state changes in memory for compiled notification email?
  * @param t3lib_TCEmain $tcemainObj TCEmain object
  * @param string $notificationAlternativeRecipients comma separated list of recipients to notificate instead of normal be_users
  * @return void
  */
 protected function version_setStage($table, $id, $stageId, $comment = '', $notificationEmailInfo = FALSE, t3lib_TCEmain $tcemainObj, $notificationAlternativeRecipients = FALSE)
 {
     if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
         $tcemainObj->newlog('Attempt to set stage for record failed: ' . $errorCode, 1);
     } elseif ($tcemainObj->checkRecordUpdateAccess($table, $id)) {
         $record = t3lib_BEfunc::getRecord($table, $id);
         $stat = $tcemainObj->BE_USER->checkWorkspace($record['t3ver_wsid']);
         // check if the usere is allowed to the current stage, so it's also allowed to send to next stage
         if ($GLOBALS['BE_USER']->workspaceCheckStageForCurrent($record['t3ver_stage'])) {
             // Set stage of record:
             $updateData = array('t3ver_stage' => $stageId);
             $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $updateData);
             $tcemainObj->newlog2('Stage for record was changed to ' . $stageId . '. Comment was: "' . substr($comment, 0, 100) . '"', $table, $id);
             // TEMPORARY, except 6-30 as action/detail number which is observed elsewhere!
             $tcemainObj->log($table, $id, 6, 0, 0, 'Stage raised...', 30, array('comment' => $comment, 'stage' => $stageId));
             if ((int) $stat['stagechg_notification'] > 0) {
                 if ($notificationEmailInfo) {
                     $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['shared'] = array($stat, $stageId, $comment);
                     $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['elements'][] = $table . ':' . $id;
                     $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['alternativeRecipients'] = $notificationAlternativeRecipients;
                 } else {
                     $this->notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj, $notificationAlternativeRecipients);
                 }
             }
         } else {
             $tcemainObj->newlog('The member user tried to set a stage value "' . $stageId . '" that was not allowed', 1);
         }
     } else {
         $tcemainObj->newlog('Attempt to set stage for record failed because you do not have edit access', 1);
     }
 }