/**
  * Setting stage of record
  *
  * @param	string		Table name
  * @param	integer		Record UID
  * @param	integer		Stage ID to set
  * @param	string		Comment that goes into log
  * @param	boolean		Accumulate state changes in memory for compiled notification email?
  * @return	void
  */
 function version_setStage($table, $id, $stageId, $comment = '', $accumulateForNotifEmail = FALSE)
 {
     if ($errorCode = $this->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
         $this->newlog('Attempt to set stage for record failed: ' . $errorCode, 1);
     } elseif ($this->checkRecordUpdateAccess($table, $id)) {
         $record = t3lib_BEfunc::getRecord($table, $id);
         $stat = $this->BE_USER->checkWorkspace($record['t3ver_wsid']);
         if (t3lib_div::inList('admin,online,offline,reviewer,owner', $stat['_ACCESS']) || $stageId <= 1 && $stat['_ACCESS'] === 'member') {
             // Set stage of record:
             $sArray = array();
             $sArray['t3ver_stage'] = $stageId;
             $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $sArray);
             $this->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!
             $this->log($table, $id, 6, 0, 0, 'Stage raised...', 30, array('comment' => $comment, 'stage' => $stageId));
             if ((int) $stat['stagechg_notification'] > 0) {
                 if ($accumulateForNotifEmail) {
                     $this->accumulateForNotifEmail[$stat['uid'] . ':' . $stageId . ':' . $comment]['shared'] = array($stat, $stageId, $comment);
                     $this->accumulateForNotifEmail[$stat['uid'] . ':' . $stageId . ':' . $comment]['elements'][] = $table . ':' . $id;
                 } else {
                     $this->notifyStageChange($stat, $stageId, $table, $id, $comment);
                 }
             }
         } else {
             $this->newlog('The member user tried to set a stage value "' . $stageId . '" that was not allowed', 1);
         }
     } else {
         $this->newlog('Attempt to set stage for record failed because you do not have edit access', 1);
     }
 }