Feature #23942 ยป 0016251.patch
typo3/sysext/version/ws/class.wslib.php (Arbeitskopie) | ||
---|---|---|
* @param boolean If set, then the currently online versions are swapped into the workspace in exchange for the offline versions. Otherwise the workspace is emptied.
|
||
* @param [type] $pageId: ...
|
||
* @return array Command array for tcemain
|
||
* @deprecated since TYPO3 4.5 - The functionality moved to a different class
|
||
*/
|
||
function getCmdArrayForPublishWS($wsid, $doSwap,$pageId=0) {
|
||
$wsid = intval($wsid);
|
||
$cmd = array();
|
||
if ($wsid>=-1 && $wsid!==0) {
|
||
// Define stage to select:
|
||
$stage = -99;
|
||
if ($wsid>0) {
|
||
$workspaceRec = t3lib_BEfunc::getRecord('sys_workspace',$wsid);
|
||
if ($workspaceRec['publish_access']&1) {
|
||
$stage = 10;
|
||
}
|
||
}
|
||
// Select all versions to swap:
|
||
$versions = $this->selectVersionsInWorkspace($wsid,0,$stage,($pageId?$pageId:-1));
|
||
// Traverse the selection to build CMD array:
|
||
foreach($versions as $table => $records) {
|
||
foreach($records as $rec) {
|
||
// Build the cmd Array:
|
||
$cmd[$table][$rec['t3ver_oid']]['version'] = array(
|
||
'action' => 'swap',
|
||
'swapWith' => $rec['uid'],
|
||
'swapIntoWS' => $doSwap ? 1 : 0
|
||
);
|
||
}
|
||
}
|
||
}
|
||
return $cmd;
|
||
t3lib_div::logDeprecatedFunction();
|
||
$wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Autopublish');
|
||
return $wsService->getCmdArrayForPublishWS($wsid, $doSwap,$pageId);
|
||
}
|
||
/**
|
||
... | ... | |
* @param integer Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10"
|
||
* @param integer Page id: Live page for which to find versions in workspace!
|
||
* @return array Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The REAL pid of the online record is found as "realpid"
|
||
* @deprecated since TYPO3 4.5 - The functionality moved to a different class
|
||
*/
|
||
function selectVersionsInWorkspace($wsid,$filter=0,$stage=-99,$pageId=-1) {
|
||
global $TCA;
|
||
$wsid = intval($wsid);
|
||
$filter = intval($filter);
|
||
$output = array();
|
||
// Traversing all tables supporting versioning:
|
||
foreach($TCA as $table => $cfg) {
|
||
if ($TCA[$table]['ctrl']['versioningWS']) {
|
||
// Select all records from this table in the database from the workspace
|
||
// This joins the online version with the offline version as tables A and B
|
||
$recs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows (
|
||
'A.uid, A.t3ver_oid,'.($table==='pages' ? ' A.t3ver_swapmode,':'').' B.pid AS realpid',
|
||
$table.' A,'.$table.' B',
|
||
'A.pid=-1'. // Table A is the offline version and pid=-1 defines offline
|
||
($pageId!=-1 ? ($table==='pages' ? ' AND B.uid='.intval($pageId) : ' AND B.pid='.intval($pageId)) : '').
|
||
($wsid>-98 ? ' AND A.t3ver_wsid='.$wsid : ($wsid===-98 ? ' AND A.t3ver_wsid!=0' : '')). // For "real" workspace numbers, select by that. If = -98, select all that are NOT online (zero). Anything else below -1 will not select on the wsid and therefore select all!
|
||
($filter===1 ? ' AND A.t3ver_count=0' : ($filter===2 ? ' AND A.t3ver_count>0' : '')). // lifecycle filter: 1 = select all drafts (never-published), 2 = select all published one or more times (archive/multiple)
|
||
($stage!=-99 ? ' AND A.t3ver_stage='.intval($stage) : '').
|
||
' AND B.pid>=0'. // Table B (online) must have PID >= 0 to signify being online.
|
||
' AND A.t3ver_oid=B.uid'. // ... and finally the join between the two tables.
|
||
t3lib_BEfunc::deleteClause($table,'A').
|
||
t3lib_BEfunc::deleteClause($table,'B'),
|
||
'',
|
||
'B.uid' // Order by UID, mostly to have a sorting in the backend overview module which doesn't "jump around" when swapping.
|
||
);
|
||
if (count($recs)) {
|
||
$output[$table] = $recs;
|
||
}
|
||
}
|
||
}
|
||
return $output;
|
||
t3lib_div::logDeprecatedFunction();
|
||
$wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
|
||
return $wsService->selectVersionsInWorkspace($wsid, $filter, $stage, $pageId);
|
||
}
|
||
/****************************
|
||
*
|
||
* Scheduler methods
|
||
... | ... | |
* and publishes them
|
||
*
|
||
* @return void
|
||
* @deprecated since TYPO3 4.5 - The functionality moved to a different class
|
||
*/
|
||
function autoPublishWorkspaces() {
|
||
global $TYPO3_CONF_VARS;
|
||
// Temporarily set admin rights
|
||
// FIXME: once workspaces are cleaned up a better solution should be implemented
|
||
$currentAdminStatus = $GLOBALS['BE_USER']->user['admin'];
|
||
$GLOBALS['BE_USER']->user['admin'] = 1;
|
||
// Select all workspaces that needs to be published / unpublished:
|
||
$workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'uid,swap_modes,publish_time,unpublish_time',
|
||
'sys_workspace',
|
||
'pid=0
|
||
AND
|
||
((publish_time!=0 AND publish_time<='.intval($GLOBALS['EXEC_TIME']).')
|
||
OR (publish_time=0 AND unpublish_time!=0 AND unpublish_time<='.intval($GLOBALS['EXEC_TIME']).'))'.
|
||
t3lib_BEfunc::deleteClause('sys_workspace')
|
||
);
|
||
foreach($workspaces as $rec) {
|
||
// First, clear start/end time so it doesn't get select once again:
|
||
$fieldArray = $rec['publish_time']!=0 ? array('publish_time'=>0) : array('unpublish_time'=>0);
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_workspace','uid='.intval($rec['uid']),$fieldArray);
|
||
// Get CMD array:
|
||
$cmd = $this->getCmdArrayForPublishWS($rec['uid'], $rec['swap_modes']==1); // $rec['swap_modes']==1 means that auto-publishing will swap versions, not just publish and empty the workspace.
|
||
// Execute CMD array:
|
||
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
|
||
$tce->stripslashes_values = 0;
|
||
$tce->start(array(),$cmd);
|
||
$tce->process_cmdmap();
|
||
}
|
||
// Restore admin status
|
||
$GLOBALS['BE_USER']->user['admin'] = $currentAdminStatus;
|
||
public function autoPublishWorkspaces() {
|
||
t3lib_div::logDeprecatedFunction();
|
||
$wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Autopublish');
|
||
return $wsService->autoPublishWorkspaces();
|
||
}
|
||
}
|
||