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
00070
00071 unset($MCONF);
00072 require('conf.php');
00073 require($BACK_PATH.'init.php');
00074 require($BACK_PATH.'template.php');
00075 $BE_USER->modAccess($MCONF,1);
00076
00077
00078 $LANG->includeLLFile('EXT:lang/locallang_mod_user_ws.xml');
00079 require_once(PATH_t3lib.'class.t3lib_scbase.php');
00080
00081 require_once(PATH_t3lib.'class.t3lib_tcemain.php');
00082 require_once(PATH_t3lib.'class.t3lib_tceforms.php');
00083 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
00084 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00085
00093 class SC_mod_user_ws_workspaceForms extends t3lib_SCbase {
00094
00095
00096 var $MCONF = array();
00097 var $MOD_MENU = array();
00098 var $MOD_SETTINGS = array();
00099
00105 var $doc;
00106 var $content;
00107
00108
00109 var $isEditAction = false;
00110 var $workspaceId;
00111
00117 var $tceforms;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00135 function init() {
00136
00137 $this->MCONF = $GLOBALS['MCONF'];
00138
00139
00140 $this->doc = t3lib_div::makeInstance('mediumDoc');
00141 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00142 $this->doc->docType = 'xhtml_trans';
00143 $this->doc->form = '<form action="' . t3lib_div::getIndpEnv('SCRIPT_NAME').'" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
00144
00145 $CMparts = $this->doc->getContextMenuCode();
00146 $this->doc->JScode.= $CMparts[0];
00147 $this->doc->JScode.= $this->doc->getDynTabMenuJScode();
00148 $this->doc->bodyTagAdditions = $CMparts[1];
00149 $this->doc->postCode.= $CMparts[2];
00150
00151
00152 t3lib_SCbase::init();
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00170 function main() {
00171 global $LANG;
00172
00173
00174 $this->getModuleParameters();
00175
00176 $hasAccess = (
00177 $GLOBALS['BE_USER']->isAdmin() ||
00178 0 != ($GLOBALS['BE_USER']->groupData['workspace_perms'] & 4) ||
00179 ($this->isEditAction && $this->checkWorkspaceAccess())
00180 );
00181
00182 if (!$hasAccess) {
00183 $title = $this->getTitle();
00184 $this->content .= $this->doc->startPage($title);
00185 $this->content .= $this->doc->header($title);
00186 $this->content .= $this->doc->spacer(5);
00187 $this->content .= $LANG->getLL($this->isEditAction ? 'edit_workspace_no_permission' : 'create_workspace_no_permission');
00188 $this->content .= $this->doc->spacer(5);
00189 $goBack = $GLOBALS['LANG']->getLL('edit_workspace_go_back');
00190 $this->content .= '<img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/goback.gif', 'width="14" height="14"') . ' alt="' . $goBack . '" align="middle" hspace="2" />' .
00191 '<a href="javascript:history.back()">' .
00192 $goBack .
00193 '</a>';
00194 $this->content .= $this->doc->endPage();
00195 return;
00196 }
00197
00198
00199 if (t3lib_div::_GP('workspace_form_submited')) {
00200 $this->processData();
00201
00202 if (t3lib_div::_GP('_saveandclosedok_x')) {
00203
00204 header('Location: ' . t3lib_div::locationHeaderUrl('index.php?n=' . uniqid('')));
00205 exit();
00206 }
00207 }
00208
00209 $this->initTCEForms();
00210
00211
00212
00213
00214 $title = $this->getTitle();
00215 $this->content .= $this->doc->startPage($title);
00216 $this->content .= $this->doc->header($title);
00217 $this->content .= $this->doc->spacer(5);
00218
00219
00220
00221
00222 $this->content .= $this->tceforms->printNeededJSFunctions_top();
00223 $this->content .= $this->buildForm();
00224 $this->content .= $this->tceforms->printNeededJSFunctions();
00225
00226
00227
00228
00229 $this->content .= $this->doc->endPage();
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00245 function printContent() {
00246 echo $this->content;
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00269 function initTCEForms() {
00270 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00271 $this->tceforms->initDefaultBEMode();
00272 $this->tceforms->backPath = $GLOBALS['BACK_PATH'];
00273 $this->tceforms->doSaveFieldName = 'doSave';
00274 $this->tceforms->localizationMode = t3lib_div::inList('text,media',$this->localizationMode) ? $this->localizationMode : '';
00275 $this->tceforms->returnUrl = $this->R_URI;
00276 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00277 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00278 $this->tceforms->enableClickMenu = true;
00279 $this->tceforms->enableTabMenu = true;
00280
00281
00282 if ($GLOBALS['BE_USER']->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
00283 }
00284
00285
00286
00287
00288
00289
00290
00296 function getModuleParameters(){
00297 $this->isEditAction = (t3lib_div::_GP('action') == 'edit');
00298 if ($this->isEditAction) {
00299 $this->workspaceId = intval(t3lib_div::_GP('wkspId'));
00300 }
00301 }
00302
00303
00304
00305
00306
00307
00308
00314 function getTitle() {
00315 $label = ($this->isEditAction ? 'edit_workspace_title_edit' : 'edit_workspace_title_new');
00316 return $GLOBALS['LANG']->getLL($label);
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00333 function buildForm() {
00334 return $this->isEditAction ? $this->buildEditForm() : $this->buildNewForm();
00335 }
00336
00342 function buildEditForm() {
00343 $content = '';
00344 $table = 'sys_workspace';
00345 $prevPageID = '';
00346 $trData = t3lib_div::makeInstance('t3lib_transferData');
00347 $trData->addRawData = TRUE;
00348 $trData->defVals = $this->defVals;
00349 $trData->lockRecords=1;
00350 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00351 $trData->prevPageID = $prevPageID;
00352 $trData->fetchRecord($table, $this->workspaceId, '');
00353 reset($trData->regTableItems_data);
00354 $rec = current($trData->regTableItems_data);
00355
00356
00357 $this->tceforms->hiddenFieldList = '';
00358
00359 $this->tceforms->registerDefaultLanguageData($table,$rec);
00360
00361 $this->fixVariousTCAFields();
00362 if (!$GLOBALS['BE_USER']->isAdmin()) {
00363
00364 $this->fixTCAUserField('adminusers');
00365 $this->fixTCAUserField('members');
00366 $this->fixTCAUserField('reviewers');
00367 }
00368
00369
00370 $form = '';
00371 $form .= $this->tceforms->getMainFields($table,$rec);
00372 $form .= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00373 $form .= '<input type="hidden" name="workspace_form_submited" value="1" />';
00374 $form .= '<input type="hidden" name="returnUrl" value="index.php" />';
00375 $form .= '<input type="hidden" name="action" value="edit" />';
00376 $form .= '<input type="hidden" name="closeDoc" value="0" />';
00377 $form .= '<input type="hidden" name="doSave" value="0" />';
00378 $form .= '<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00379 $form .= '<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00380 $form .= '<input type="hidden" name="wkspId" value="' . htmlspecialchars($this->workspaceId) . '" />';
00381 $form = $this->tceforms->wrapTotal($form, $rec, $table);
00382
00383 $buttons = $this->createButtons() . $this->doc->spacer(5);
00384
00385
00386 $content .= $buttons . $form . $buttons;
00387 return $content;
00388 }
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00406 function buildNewForm() {
00407 $content = '';
00408 $table = 'sys_workspace';
00409 $prevPageID = '';
00410 $trData = t3lib_div::makeInstance('t3lib_transferData');
00411 $trData->addRawData = TRUE;
00412 $trData->defVals = $this->defVals;
00413 $trData->lockRecords=1;
00414 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00415 $trData->prevPageID = $prevPageID;
00416 $trData->fetchRecord($table, 0, 'new');
00417 reset($trData->regTableItems_data);
00418 $rec = current($trData->regTableItems_data);
00419 $rec['uid'] = uniqid('NEW');
00420 $rec['pid'] = 0;
00421 $rec['adminusers'] = $this->getOwnerUser($rec['uid']);
00422
00423
00424 $this->tceforms->hiddenFieldList = '';
00425
00426 $this->tceforms->registerDefaultLanguageData($table,$rec);
00427
00428 $this->fixVariousTCAFields();
00429 if (!$GLOBALS['BE_USER']->isAdmin()) {
00430
00431 $this->fixTCAUserField('adminusers');
00432 $this->fixTCAUserField('members');
00433 $this->fixTCAUserField('reviewers');
00434 }
00435
00436
00437
00438 $form = '';
00439 $form .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': ' . $this->tceforms->getRecordPath($table,$rec);
00440 $form .= $this->doc->spacer(5);
00441 $form .= $this->tceforms->getMainFields($table,$rec);
00442
00443 $form .= '<input type="hidden" name="workspace_form_submited" value="1" />';
00444 $form .= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00445 $form .= '<input type="hidden" name="returnUrl" value="index.php" />';
00446 $form .= '<input type="hidden" name="action" value="new" />';
00447 $form .= '<input type="hidden" name="closeDoc" value="0" />';
00448 $form .= '<input type="hidden" name="doSave" value="0" />';
00449 $form .= '<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00450 $form .= '<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00451 $form = $this->tceforms->wrapTotal($form, $rec, $table);
00452
00453 $buttons = $this->createButtons() . $this->doc->spacer(5);
00454
00455
00456 $content .= $buttons . $form . $buttons;
00457 return $content;
00458 }
00459
00465 function createButtons() {
00466 global $LANG;
00467
00468 $content = '';
00469 $content .= '<input type="image" class="c-inputButton" name="_savedok"' . t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" value="_savedok" />';
00470 $content .= '<input type="image" class="c-inputButton" name="_saveandclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" value="_saveandclosedok" />';
00471
00472 $content .= '<a href="index.php?n=' . uniqid('wksp') . '"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" alt="" /></a>';
00473 return $content;
00474 }
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00491 function getOwnerUser($uid) {
00492 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00493
00494 t3lib_div::loadTCA('sys_workspace');
00495
00496 $config = &$GLOBALS['TCA']['sys_workspace']['columns']['adminusers']['config'];
00497
00498
00499 $loadDB->start($GLOBALS['BE_USER']->user['uid'], $config['allowed'], $config['MM'], $uid, 'sys_workspace', $config);
00500 $loadDB->getFromDB();
00501 return $loadDB->readyForInterface();
00502 }
00503
00504
00505
00506
00507
00508
00509
00510
00511
00517 function processData() {
00518 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00519 $tce->stripslashes_values = 0;
00520
00521 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
00522 if (is_array($TCAdefaultOverride)) {
00523 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
00524 }
00525 $tce->stripslashes_values = 0;
00526
00527
00528
00529 $inputData_tmp = t3lib_div::_GP('data');
00530 $inputData = array();
00531 if (is_array($inputData_tmp['sys_workspace'])) {
00532 reset($inputData_tmp['sys_workspace']);
00533 $inputData['sys_workspace'][key($inputData_tmp['sys_workspace'])] = current($inputData_tmp['sys_workspace']);
00534 }
00535
00536 $tce->start($inputData, array(), $GLOBALS['BE_USER']);
00537 $tce->admin = 1;
00538 $tce->bypassWorkspaceRestrictions = true;
00539 $tce->process_datamap();
00540
00541
00542 $script = t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT');
00543 $tce->printLogErrorMessages($script . '?' .
00544 ($this->isEditAction ? 'action=edit&wkspId=' . $this->workspaceId : 'action=new'));
00545
00546
00547 if (count($tce->substNEWwithIDs_table)) {
00548 reset($tce->substNEWwithIDs_table);
00549 $this->workspaceId = current($tce->substNEWwithIDs);
00550 $this->isEditAction = true;
00551 }
00552 }
00553
00554
00555
00561 function fixVariousTCAFields() {
00562
00563 $GLOBALS['TCA']['sys_workspace']['ctrl']['dividers2tabs'] = true;
00564 }
00565
00566
00573 function fixTCAUserField($fieldName) {
00574
00575 if (!$GLOBALS['BE_USER']->isAdmin()) {
00576
00577 t3lib_div::loadTCA('sys_workspace');
00578 $field = &$GLOBALS['TCA']['sys_workspace']['columns'][$fieldName];
00579 $newField = array (
00580 'label' => $field['label'],
00581 'config' => Array (
00582 'type' => 'select',
00583 'itemsProcFunc' => 'user_SC_mod_user_ws_workspaceForms->processUserAndGroups',
00584
00585 'size' => 10,
00586 'maxitems' => $field['config']['maxitems'],
00587 'autoSizeMax' => $field['config']['autoSizeMax'],
00588 'mod_ws_allowed' => $field['config']['allowed']
00589 )
00590 );
00591 $field = $newField;
00592 }
00593 }
00594
00600 function checkWorkspaceAccess() {
00601 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','uid=' . intval($this->workspaceId) . ' AND pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'));
00602 if (is_array($workspaces) && count($workspaces) != 0 && false !== ($rec = $GLOBALS['BE_USER']->checkWorkspace($workspaces[0]))) {
00603 return ($rec['_ACCESS'] == 'owner' || $rec['_ACCESS'] == 'admin');
00604 }
00605 return false;
00606 }
00607 }
00608
00613 class user_SC_mod_user_ws_workspaceForms {
00614
00622 function processUserAndGroups($conf, $tceforms) {
00623
00624 $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
00625 $groupArray = array_keys($be_group_Array);
00626
00627 $be_user_Array = t3lib_BEfunc::getUserNames();
00628 $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,1);
00629
00630
00631 $title = $GLOBALS['LANG']->sL($GLOBALS['TCA']['be_users']['ctrl']['title']);
00632 foreach ($be_user_Array as $uid => $user) {
00633 $conf['items'][] = array(
00634 $user['username'] . ' (' . $title . ')',
00635 'be_users_' . $user['uid'],
00636 t3lib_iconWorks::getIcon('be_users', $user)
00637 );
00638 }
00639
00640
00641 if (strstr($conf['config']['mod_ws_allowed'], 'be_groups')) {
00642
00643
00644 $be_group_Array = $be_group_Array_o = t3lib_BEfunc::getGroupNames();
00645 $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o,$groupArray,1);
00646
00647 $title = $GLOBALS['LANG']->sL($GLOBALS['TCA']['be_groups']['ctrl']['title']);
00648 foreach ($be_group_Array as $uid => $group) {
00649 $conf['items'][] = array(
00650 $group['title'] . ' (' . $title . ')',
00651 'be_groups_' . $group['uid'],
00652 t3lib_iconWorks::getIcon('be_groups', $user)
00653 );
00654 }
00655 }
00656 }
00657 }
00658
00659
00660 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/workspaceforms.php']) {
00661 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/workspaceforms.php']);
00662 }
00663
00664
00665 $SOBE = t3lib_div::makeInstance('SC_mod_user_ws_workspaceForms');
00666 $SOBE->init();
00667 $SOBE->main();
00668 $SOBE->printContent();
00669 ?>
This documentation has been generated automatically from TYPO3 source code using
Doxygen and is provided as is by
Cast Iron Coding
as a courtesy to other TYPO3 developers and users. Please consider
Cast Iron Coding — a full-service web development
agency in Portland, Oregon specializing in TYPO3 extension development — for all of your TYPO3 development and consulting needs!