00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00109 class t3lib_pageSelect {
00110 var $urltypes = Array('','http:
00111 var $where_hid_del = ' AND pages.deleted=0';
00112 var $where_groupAccess = '';
00113 var $sys_language_uid = 0;
00114
00115
00116 var $versioningPreview = FALSE;
00117 var $versioningWorkspaceId = 0;
00118 var $workspaceCache = array();
00119
00120
00121
00122 var $error_getRootLine = '';
00123 var $error_getRootLine_failPid = 0;
00124
00125
00134 function init($show_hidden) {
00135 $this->where_groupAccess = '';
00136 $this->where_hid_del = ' AND pages.deleted=0 ';
00137 if (!$show_hidden) {
00138 $this->where_hid_del.= 'AND pages.hidden=0 ';
00139 }
00140 $this->where_hid_del.= 'AND (pages.starttime<='.$GLOBALS['SIM_EXEC_TIME'].') AND (pages.endtime=0 OR pages.endtime>'.$GLOBALS['SIM_EXEC_TIME'].') ';
00141
00142
00143 if (!$this->versioningPreview) {
00144 $this->where_hid_del.= ' AND NOT(pages.t3ver_state>0)';
00145 } else {
00146
00147 $this->versioningPreview_where_hid_del = $this->where_hid_del;
00148 $this->where_hid_del = ' AND pages.deleted=0 ';
00149 }
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00184 function getPage($uid, $disableGroupAccessCheck=FALSE) {
00185 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($uid).$this->where_hid_del.($disableGroupAccessCheck ? '' : $this->where_groupAccess));
00186 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00187 $this->versionOL('pages',$row);
00188 if (is_array($row)) return $this->getPageOverlay($row);
00189 }
00190 return Array();
00191 }
00192
00200 function getPage_noCheck($uid) {
00201 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($uid).$this->deleteClause('pages'));
00202 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00203 $this->versionOL('pages',$row);
00204 if (is_array($row)) return $this->getPageOverlay($row);
00205 }
00206 return Array();
00207 }
00208
00216 function getFirstWebPage($uid) {
00217 $output = '';
00218 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($uid).$this->where_hid_del.$this->where_groupAccess, '', 'sorting', '1');
00219 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00220 $this->versionOL('pages',$row);
00221 if (is_array($row)) $output = $this->getPageOverlay($row);
00222 }
00223 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00224 return $output;
00225 }
00226
00234 function getPageIdFromAlias($alias) {
00235 $alias = strtolower($alias);
00236 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'alias='.$GLOBALS['TYPO3_DB']->fullQuoteStr($alias, 'pages').' AND pid>=0 AND pages.deleted=0');
00237 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00238 return $row['uid'];
00239 }
00240 return 0;
00241 }
00242
00250 function getPageOverlay($pageInput,$lUid=-1) {
00251
00252
00253 if ($lUid<0) $lUid = $this->sys_language_uid;
00254 $row = NULL;
00255
00256
00257 if ($lUid) {
00258 $fieldArr = explode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
00259 if (is_array($pageInput)) {
00260 $page_id = $pageInput['uid'];
00261 $fieldArr = array_intersect($fieldArr,array_keys($pageInput));
00262 } else {
00263 $page_id = $pageInput;
00264 }
00265
00266 if (count($fieldArr)) {
00267
00268
00269
00270
00271
00272
00273
00274 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00275 implode(',',$fieldArr),
00276 'pages_language_overlay',
00277 'pid='.intval($page_id).'
00278 AND sys_language_uid='.intval($lUid).
00279 $this->enableFields('pages_language_overlay'),
00280 '',
00281 '',
00282 '1'
00283 );
00284 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00285 $this->versionOL('pages_language_overlay',$row);
00286
00287 if (is_array($row)) {
00288 $row['_PAGES_OVERLAY'] = TRUE;
00289
00290
00291 unset($row['uid']);
00292 unset($row['pid']);
00293 }
00294 }
00295 }
00296
00297
00298 if (is_array($pageInput)) {
00299 return is_array($row) ? array_merge($pageInput,$row) : $pageInput;
00300 } else {
00301 return is_array($row) ? $row : array();
00302 }
00303 }
00304
00314 function getRecordOverlay($table,$row,$sys_language_content,$OLmode='') {
00315 global $TCA;
00316
00317 if ($row['uid']>0 && $row['pid']>0) {
00318 if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
00319 if (!$TCA[$table]['ctrl']['transOrigPointerTable']) {
00320
00321
00322 if ($sys_language_content>0) {
00323
00324
00325 if ($row[$TCA[$table]['ctrl']['languageField']]<=0) {
00326
00327
00328 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00329 '*',
00330 $table,
00331 'pid='.intval($row['pid']).
00332 ' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
00333 ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
00334 $this->enableFields($table),
00335 '',
00336 '',
00337 '1'
00338 );
00339 $olrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00340 $this->versionOL($table,$olrow);
00341 #debug($row);
00342 #debug($olrow);
00343
00344 if (is_array($olrow)) {
00345 foreach($row as $fN => $fV) {
00346 if ($fN!='uid' && $fN!='pid' && isset($olrow[$fN])) {
00347
00348 if ($GLOBALS['TSFE']->TCAcachedExtras[$table]['l10n_mode'][$fN]!='exclude'
00349 && ($GLOBALS['TSFE']->TCAcachedExtras[$table]['l10n_mode'][$fN]!='mergeIfNotBlank' || strcmp(trim($olrow[$fN]),''))) {
00350 $row[$fN] = $olrow[$fN];
00351 }
00352 } elseif ($fN=='uid') {
00353 $row['_LOCALIZED_UID'] = $olrow['uid'];
00354 }
00355 }
00356 } elseif ($OLmode==='hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']]==0) {
00357 unset($row);
00358 }
00359
00360
00361 } elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']]) {
00362 unset($row);
00363 }
00364 } else {
00365
00366 if ($row[$TCA[$table]['ctrl']['languageField']]>0) {
00367 unset($row);
00368 }
00369 }
00370 }
00371 }
00372 }
00373
00374 return $row;
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00413 function getMenu($uid,$fields='*',$sortField='sorting',$addWhere='',$checkShortcuts=1) {
00414
00415 $output = Array();
00416 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'pages', 'pid='.intval($uid).$this->where_hid_del.$this->where_groupAccess.' '.$addWhere, '', $sortField);
00417 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00418 $this->versionOL('pages',$row,TRUE);
00419 if (is_array($row)) {
00420
00421 $origUid = $row['uid'];
00422 $mount_info = $this->getMountPointInfo($origUid, $row);
00423 if (is_array($mount_info) && $mount_info['overlay']) {
00424 $mp_row = $this->getPage($mount_info['mount_pid']);
00425 if (count($mp_row)) {
00426 $row = $mp_row;
00427 $row['_MP_PARAM'] = $mount_info['MPvar'];
00428 } else unset($row);
00429 }
00430
00431
00432 if ($row['doktype'] == 4 && ($row['shortcut'] || $row['shortcut_mode']) && $checkShortcuts) {
00433 if ($row['shortcut_mode'] == 0) {
00434 $searchField = 'uid';
00435 $searchUid = intval($row['shortcut']);
00436 } else {
00437 $searchField = 'pid';
00438
00439 $searchUid = intval($row['shortcut'])?intval($row['shortcut']):$row['uid'];
00440 }
00441 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', $searchField.'='.$searchUid.$this->where_hid_del.$this->where_groupAccess.' '.$addWhere, '', $sortField);
00442 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res2)) {
00443 unset($row);
00444 }
00445 $GLOBALS['TYPO3_DB']->sql_free_result($res2);
00446 } elseif ($row['doktype'] == 4 && $checkShortcuts) {
00447
00448 unset($row);
00449 }
00450
00451
00452 if (is_array($row)) {
00453 $output[$origUid] = $this->getPageOverlay($row);
00454 }
00455 }
00456 }
00457 return $output;
00458 }
00459
00470 function getDomainStartPage($domain, $path='',$request_uri='') {
00471 $domain = explode(':',$domain);
00472 $domain = strtolower(ereg_replace('\.$','',$domain[0]));
00473
00474 $path = trim(ereg_replace('\/[^\/]*$','',$path));
00475
00476 $domain.= $path;
00477 $domain = ereg_replace('\
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00761 function checkRecord($table,$uid,$checkPage=0) {
00762 global $TCA;
00763 $uid = intval($uid);
00764 if (is_array($TCA[$table])) {
00765 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.intval($uid).$this->enableFields($table));
00766 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00767 $this->versionOL($table,$row);
00768 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00769
00770 if (is_array($row)) {
00771 if ($checkPage) {
00772 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($row['pid']).$this->enableFields('pages'));
00773 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
00774 return $row;
00775 } else {
00776 return 0;
00777 }
00778 } else {
00779 return $row;
00780 }
00781 }
00782 }
00783 }
00784 }
00785
00796 function getRawRecord($table,$uid,$fields='*',$noWSOL=FALSE) {
00797 global $TCA;
00798 $uid = intval($uid);
00799 if (is_array($TCA[$table]) || $table=='pages') {
00800 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid='.intval($uid).$this->deleteClause($table));
00801 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00802 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00803 if ($row) {
00804 if (!$noWSOL) {
00805 $this->versionOL($table,$row);
00806 }
00807 if (is_array($row)) return $row;
00808 }
00809 }
00810 }
00811
00824 function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='') {
00825 global $TCA;
00826 if (is_array($TCA[$theTable])) {
00827 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00828 '*',
00829 $theTable,
00830 $theField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($theValue, $theTable).
00831 $this->deleteClause($theTable).' '.
00832 $whereClause,
00833 $groupBy,
00834 $orderBy,
00835 $limit
00836 );
00837 $rows = array();
00838 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00839 #$this->versionOL($theTable,$row); // not used since records here are fetched based on other fields than uid!
00840 if (is_array($row)) $rows[] = $row;
00841 }
00842 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00843 if (count($rows)) return $rows;
00844 }
00845 }
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00876 function getHash($hash,$expTime=0) {
00877
00878 $expTime = intval($expTime);
00879 if ($expTime) {
00880 $whereAdd = ' AND tstamp > '.(time()-$expTime);
00881 }
00882 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').$whereAdd);
00883 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00884 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00885 return $row['content'];
00886 }
00887 }
00888
00899 function storeHash($hash,$data,$ident) {
00900 $insertFields = array(
00901 'hash' => $hash,
00902 'content' => $data,
00903 'ident' => $ident,
00904 'tstamp' => time()
00905 );
00906 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
00907 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
00908 }
00909
00917 function deleteClause($table) {
00918 global $TCA;
00919 if (!strcmp($table,'pages')) {
00920 return ' AND pages.deleted=0';
00921 } else {
00922 return $TCA[$table]['ctrl']['delete'] ? ' AND '.$table.'.'.$TCA[$table]['ctrl']['delete'].'=0' : '';
00923 }
00924 }
00925
00937 function enableFields($table,$show_hidden=-1,$ignore_array=array(),$noVersionPreview=FALSE) {
00938 global $TYPO3_CONF_VARS;
00939
00940 if ($show_hidden==-1 && is_object($GLOBALS['TSFE'])) {
00941 $show_hidden = $table=='pages' ? $GLOBALS['TSFE']->showHiddenPage : $GLOBALS['TSFE']->showHiddenRecords;
00942 }
00943 if ($show_hidden==-1) $show_hidden=0;
00944
00945 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
00946 $query='';
00947 if (is_array($ctrl)) {
00948
00949
00950 if ($ctrl['delete']) {
00951 $query.=' AND '.$table.'.'.$ctrl['delete'].'=0';
00952 }
00953
00954
00955 if ($ctrl['versioningWS'] && !$this->versioningPreview) {
00956 $query.=' AND '.$table.'.t3ver_state<=0';
00957 }
00958
00959
00960 if (is_array($ctrl['enablecolumns'])) {
00961 if (!$this->versioningPreview || !$ctrl['versioningWS'] || $noVersionPreview) {
00962 if ($ctrl['enablecolumns']['disabled'] && !$show_hidden && !$ignore_array['disabled']) {
00963 $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
00964 $query.=' AND '.$field.'=0';
00965 }
00966 if ($ctrl['enablecolumns']['starttime'] && !$ignore_array['starttime']) {
00967 $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
00968 $query.=' AND ('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00969 }
00970 if ($ctrl['enablecolumns']['endtime'] && !$ignore_array['endtime']) {
00971 $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
00972 $query.=' AND ('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00973 }
00974 if ($ctrl['enablecolumns']['fe_group'] && !$ignore_array['fe_group']) {
00975 $field = $table.'.'.$ctrl['enablecolumns']['fe_group'];
00976 $query.= $this->getMultipleGroupsWhereClause($field, $table);
00977 }
00978
00979
00980
00981 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_page.php']['addEnableColumns'])) {
00982 $_params = array(
00983 'table' => $table,
00984 'show_hidden' => $show_hidden,
00985 'ignore_array' => $ignore_array,
00986 'ctrl' => $ctrl
00987 );
00988 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_page.php']['addEnableColumns'] as $_funcRef) {
00989 $query .= t3lib_div::callUserFunction($_funcRef,$_params,$this);
00990 }
00991 }
00992 }
00993 }
00994 } else {
00995 die ('NO entry in the $TCA-array for the table "'.$table.'". This means that the function enableFields() is called with an invalid table name as argument.');
00996 }
00997
00998 return $query;
00999 }
01000
01009 function getMultipleGroupsWhereClause($field, $table) {
01010 $memberGroups = t3lib_div::intExplode(',',$GLOBALS['TSFE']->gr_list);
01011 $orChecks=array();
01012 $orChecks[]=$field.'=\'\'';
01013 $orChecks[]=$field.' IS NULL';
01014 $orChecks[]=$field.'=\'0\'';
01015
01016 foreach($memberGroups as $value) {
01017 $orChecks[] = $GLOBALS['TYPO3_DB']->listQuery($field, $value, $table);
01018 }
01019
01020 return ' AND ('.implode(' OR ',$orChecks).')';
01021 }
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01055 function fixVersioningPid($table,&$rr) {
01056 global $TCA;
01057
01058 if ($this->versioningPreview && is_array($rr) && $rr['pid']==-1 && ($table=='pages' || $TCA[$table]['ctrl']['versioningWS'])) {
01059
01060
01061 if (isset($rr['t3ver_oid']) && isset($rr['t3ver_wsid'])) {
01062 $oid = $rr['t3ver_oid'];
01063 $wsid = $rr['t3ver_wsid'];
01064 } else {
01065 $newPidRec = $this->getRawRecord($table,$rr['uid'],'t3ver_oid,t3ver_wsid',TRUE);
01066 if (is_array($newPidRec)) {
01067 $oid = $newPidRec['t3ver_oid'];
01068 $wsid = $newPidRec['t3ver_wsid'];
01069 }
01070 }
01071
01072
01073 if ($oid && (($this->versioningWorkspaceId == 0 && $this->checkWorkspaceAccess($wsid)) || !strcmp((int)$wsid,$this->versioningWorkspaceId))) {
01074 $oidRec = $this->getRawRecord($table,$oid,'pid',TRUE);
01075
01076 if (is_array($oidRec)) {
01077 # SWAP uid as well? Well no, because when fixing a versioning PID happens it is assumed that this is a "branch" type page and therefore the uid should be kept (like in versionOL()). However if the page is NOT a branch version it should not happen - but then again, direct access to that uid should not happen!
01078 $rr['_ORIG_pid'] = $rr['pid'];
01079 $rr['pid'] = $oidRec['pid'];
01080 }
01081 }
01082 }
01083
01084
01085 if ($movePlhRec = $this->getMovePlaceholder($table,$rr['uid'],'pid')) {
01086 $rr['pid'] = $movePlhRec['pid'];
01087 }
01088 }
01089
01102 function versionOL($table,&$row,$unsetMovePointers=FALSE) {
01103 global $TCA;
01104
01105 if ($this->versioningPreview && is_array($row)) {
01106 $movePldSwap = $this->movePlhOL($table,$row);
01107 if ($wsAlt = $this->getWorkspaceVersionOfRecord($this->versioningWorkspaceId, $table, $row['uid'], implode(',',array_keys($row)))) {
01108 if (is_array($wsAlt)) {
01109
01110
01111 $wsAlt['_ORIG_pid'] = $wsAlt['pid'];
01112 $wsAlt['pid'] = $row['pid'];
01113
01114
01115
01116
01117 if ($table!=='pages' || $wsAlt['t3ver_swapmode']<=0) {
01118 $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
01119 $wsAlt['uid'] = $row['uid'];
01120
01121
01122 if ($table==='pages') {
01123 $wsAlt['alias'] = $row['alias'];
01124 }
01125 } else {
01126
01127
01128 $wsAlt['_ONLINE_uid'] = $row['uid'];
01129 }
01130
01131
01132 $row = $wsAlt;
01133
01134
01135 if ((int)$row['t3ver_state']===1 || (int)$row['t3ver_state']===2) {
01136 $row = FALSE;
01137 }
01138
01139
01140
01141 if ((int)$row['t3ver_state']===4 && !$movePldSwap && $unsetMovePointers) {
01142 $row = FALSE;
01143 }
01144 } else {
01145
01146 if ($wsAlt==-1 || (int)$row['t3ver_state']>0) {
01147 $row = FALSE;
01148 }
01149 }
01150 }
01151 }
01152 }
01153
01163 function movePlhOL($table,&$row) {
01164 global $TCA;
01165
01166 if (($table=='pages' || (int)$TCA[$table]['ctrl']['versioningWS']>=2) && (int)$row['t3ver_state']===3) {
01167
01168
01169 if (!isset($row['t3ver_move_id'])) {
01170 $moveIDRec = $this->getRawRecord($table,$row['uid'],'t3ver_move_id',TRUE);
01171 $moveID = $moveIDRec['t3ver_move_id'];
01172 } else {
01173 $moveID = $row['t3ver_move_id'];
01174 }
01175
01176
01177 if ($moveID) {
01178 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',array_keys($row)), $table, 'uid='.intval($moveID).$this->enableFields($table));
01179 if ($origRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01180 $row = $origRow;
01181 return TRUE;
01182 }
01183 }
01184 }
01185 return FALSE;
01186 }
01187
01197 function getMovePlaceholder($table,$uid,$fields='*') {
01198 global $TCA;
01199
01200 if ($this->versioningPreview) {
01201 $workspace = (int)$this->versioningWorkspaceId;
01202 if (($table=='pages' || (int)$TCA[$table]['ctrl']['versioningWS']>=2) && $workspace!==0) {
01203
01204
01205 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01206 $fields,
01207 $table,
01208 'pid!=-1 AND
01209 t3ver_state=3 AND
01210 t3ver_move_id='.intval($uid).' AND
01211 t3ver_wsid='.intval($workspace).
01212 $this->deleteClause($table)
01213 );
01214
01215 if (is_array($rows[0])) return $rows[0];
01216 }
01217 }
01218 return FALSE;
01219 }
01220
01231 function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields='*') {
01232 global $TCA;
01233
01234 if ($workspace!==0 && ($table=='pages' || $TCA[$table]['ctrl']['versioningWS'])) {
01235
01236
01237 if ($table=='pages') {
01238 $enFields = $this->versioningPreview_where_hid_del;
01239 } else {
01240 $enFields = $this->enableFields($table,-1,array(),TRUE);
01241 }
01242
01243
01244 list($newrow) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01245 $fields,
01246 $table,
01247 'pid=-1 AND
01248 t3ver_oid='.intval($uid).' AND
01249 t3ver_wsid='.intval($workspace).
01250 $this->deleteClause($table)
01251 );
01252
01253
01254 if (is_array($newrow)) {
01255 if ($GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01256 'uid',
01257 $table,
01258 'pid=-1 AND
01259 t3ver_oid='.intval($uid).' AND
01260 t3ver_wsid='.intval($workspace).
01261 $enFields
01262 )) {
01263 return $newrow;
01264 } else {
01265 return -1;
01266 }
01267 } else {
01268
01269 if ($GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01270 'uid',
01271 $table,
01272 'uid='.intval($uid).$enFields
01273 )) {
01274 return 1;
01275 } else {
01276 return -1;
01277 }
01278 }
01279 }
01280
01281 return FALSE;
01282 }
01283
01290 function checkWorkspaceAccess($wsid) {
01291 if (!$GLOBALS['BE_USER']) {
01292 return false;
01293 }
01294 if (isset($this->workspaceCache[$wsid])) {
01295 $ws = $this->workspaceCache[$wsid];
01296 }
01297 else {
01298 if ($wsid > 0) {
01299 $ws = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_workspace', 'uid='.intval($wsid).' AND deleted=0');
01300 if (count($ws)) {
01301 $ws = $ws[0];
01302 }
01303 else {
01304 return false;
01305 }
01306 }
01307 else {
01308 $ws = $wsid;
01309 }
01310 $ws = $GLOBALS['BE_USER']->checkWorkspace($ws);
01311 $this->workspaceCache[$wsid] = $ws;
01312 }
01313 return ($ws['_ACCESS'] != '');
01314 }
01315 }
01316
01317
01318
01319 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_page.php']) {
01320 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_page.php']);
01321 }
01322 ?>