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 var $doc;
00100 var $content;
00101
00102
00103 var $isEditAction = false;
00104 var $workspaceId;
00105 var $tceforms;
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00123 function init() {
00124
00125 $this->MCONF = $GLOBALS['MCONF'];
00126
00127
00128 $this->doc = t3lib_div::makeInstance('mediumDoc');
00129 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00130 $this->doc->docType = 'xhtml_trans';
00131 $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);">';
00132
00133 $CMparts = $this->doc->getContextMenuCode();
00134 $this->doc->JScode.= $CMparts[0];
00135 $this->doc->JScode.= $this->doc->getDynTabMenuJScode();
00136 $this->doc->bodyTagAdditions = $CMparts[1];
00137 $this->doc->postCode.= $CMparts[2];
00138
00139
00140 t3lib_SCbase::init();
00141 }
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00158 function main() {
00159 global $LANG;
00160
00161
00162 $this->getModuleParameters();
00163
00164 $hasAccess = (
00165 $GLOBALS['BE_USER']->isAdmin() ||
00166 0 != ($GLOBALS['BE_USER']->groupData['workspace_perms'] & 4) ||
00167 ($this->isEditAction && $this->checkWorkspaceAccess())
00168 );
00169
00170 if (!$hasAccess) {
00171 $title = $this->getTitle();
00172 $this->content .= $this->doc->startPage($title);
00173 $this->content .= $this->doc->header($title);
00174 $this->content .= $this->doc->spacer(5);
00175 $this->content .= $LANG->getLL($this->isEditAction ? 'edit_workspace_no_permission' : 'create_workspace_no_permission');
00176 $this->content .= $this->doc->spacer(5);
00177 $goBack = $GLOBALS['LANG']->getLL('edit_workspace_go_back');
00178 $this->content .= '<img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/goback.gif', 'width="14" height="14"') . ' alt="' . $goBack . '" align="middle" hspace="2" />' .
00179 '<a href="javascript:history.back()">' .
00180 $goBack .
00181 '</a>';
00182 $this->content .= $this->doc->endPage();
00183 return;
00184 }
00185
00186
00187 if (t3lib_div::_GP('workspace_form_submited')) {
00188 $this->processData();
00189
00190 if (t3lib_div::_GP('_saveandclosedok_x')) {
00191
00192 header('Location: ' . t3lib_div::locationHeaderUrl('index.php?n=' . uniqid('')));
00193 exit();
00194 }
00195 }
00196
00197 $this->initTCEForms();
00198
00199
00200
00201
00202 $title = $this->getTitle();
00203 $this->content .= $this->doc->startPage($title);
00204 $this->content .= $this->doc->header($title);
00205 $this->content .= $this->doc->spacer(5);
00206
00207
00208
00209
00210 $this->content .= $this->tceforms->printNeededJSFunctions_top();
00211 $this->content .= $this->buildForm();
00212 $this->content .= $this->tceforms->printNeededJSFunctions();
00213
00214
00215
00216
00217 $this->content .= $this->doc->endPage();
00218 }
00219
00220
00221
00222
00223
00224
00225
00226
00227
00233 function printContent() {
00234 echo $this->content;
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00257 function initTCEForms() {
00258 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00259 $this->tceforms->initDefaultBEMode();
00260 $this->tceforms->backPath = $GLOBALS['BACK_PATH'];
00261 $this->tceforms->doSaveFieldName = 'doSave';
00262 $this->tceforms->localizationMode = t3lib_div::inList('text,media',$this->localizationMode) ? $this->localizationMode : '';
00263 $this->tceforms->returnUrl = $this->R_URI;
00264 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00265 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00266 $this->tceforms->enableClickMenu = true;
00267 $this->tceforms->enableTabMenu = true;
00268
00269
00270 if ($GLOBALS['BE_USER']->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
00271 }
00272
00273
00274
00275
00276
00277
00278
00284 function getModuleParameters(){
00285 $this->isEditAction = (t3lib_div::_GP('action') == 'edit');
00286 if ($this->isEditAction) {
00287 $this->workspaceId = intval(t3lib_div::_GP('wkspId'));
00288 }
00289 }
00290
00291
00292
00293
00294
00295
00296
00302 function getTitle() {
00303 $label = ($this->isEditAction ? 'edit_workspace_title_edit' : 'edit_workspace_title_new');
00304 return $GLOBALS['LANG']->getLL($label);
00305 }
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00321 function buildForm() {
00322 return $this->isEditAction ? $this->buildEditForm() : $this->buildNewForm();
00323 }
00324
00330 function buildEditForm() {
00331 $content = '';
00332 $table = 'sys_workspace';
00333 $prevPageID = '';
00334 $trData = t3lib_div::makeInstance('t3lib_transferData');
00335 $trData->addRawData = TRUE;
00336 $trData->defVals = $this->defVals;
00337 $trData->lockRecords=1;
00338 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00339 $trData->prevPageID = $prevPageID;
00340 $trData->fetchRecord($table, $this->workspaceId, '');
00341 reset($trData->regTableItems_data);
00342 $rec = current($trData->regTableItems_data);
00343
00344
00345 $this->tceforms->hiddenFieldList = '';
00346
00347 $this->tceforms->registerDefaultLanguageData($table,$rec);
00348
00349 $this->fixVariousTCAFields();
00350 if (!$GLOBALS['BE_USER']->isAdmin()) {
00351
00352 $this->fixTCAUserField('adminusers');
00353 $this->fixTCAUserField('members');
00354 $this->fixTCAUserField('reviewers');
00355 }
00356
00357
00358 $form = '';
00359 $form .= $this->tceforms->getMainFields($table,$rec);
00360 $form .= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00361 $form .= '<input type="hidden" name="workspace_form_submited" value="1" />';
00362 $form .= '<input type="hidden" name="returnUrl" value="index.php" />';
00363 $form .= '<input type="hidden" name="action" value="edit" />';
00364 $form .= '<input type="hidden" name="closeDoc" value="0" />';
00365 $form .= '<input type="hidden" name="doSave" value="0" />';
00366 $form .= '<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00367 $form .= '<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00368 $form .= '<input type="hidden" name="wkspId" value="' . htmlspecialchars($this->workspaceId) . '" />';
00369 $form = $this->tceforms->wrapTotal($form, $rec, $table);
00370
00371 $buttons = $this->createButtons() . $this->doc->spacer(5);
00372
00373
00374 $content .= $buttons . $form . $buttons;
00375 return $content;
00376 }
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00394 function buildNewForm() {
00395 $content = '';
00396 $table = 'sys_workspace';
00397 $prevPageID = '';
00398 $trData = t3lib_div::makeInstance('t3lib_transferData');
00399 $trData->addRawData = TRUE;
00400 $trData->defVals = $this->defVals;
00401 $trData->lockRecords=1;
00402 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00403 $trData->prevPageID = $prevPageID;
00404 $trData->fetchRecord($table, 0, 'new');
00405 reset($trData->regTableItems_data);
00406 $rec = current($trData->regTableItems_data);
00407 $rec['uid'] = uniqid('NEW');
00408 $rec['pid'] = 0;
00409 $rec['adminusers'] = $this->getOwnerUser($rec['uid']);
00410
00411
00412 $this->tceforms->hiddenFieldList = '';
00413
00414 $this->tceforms->registerDefaultLanguageData($table,$rec);
00415
00416 $this->fixVariousTCAFields();
00417 if (!$GLOBALS['BE_USER']->isAdmin()) {
00418
00419 $this->fixTCAUserField('adminusers');
00420 $this->fixTCAUserField('members');
00421 $this->fixTCAUserField('reviewers');
00422 }
00423
00424
00425
00426 $form = '';
00427 $form .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': ' . $this->tceforms->getRecordPath($table,$rec);
00428 $form .= $this->doc->spacer(5);
00429 $form .= $this->tceforms->getMainFields($table,$rec);
00430
00431 $form .= '<input type="hidden" name="workspace_form_submited" value="1" />';
00432 $form .= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00433 $form .= '<input type="hidden" name="returnUrl" value="index.php" />';
00434 $form .= '<input type="hidden" name="action" value="new" />';
00435 $form .= '<input type="hidden" name="closeDoc" value="0" />';
00436 $form .= '<input type="hidden" name="doSave" value="0" />';
00437 $form .= '<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00438 $form .= '<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00439 $form = $this->tceforms->wrapTotal($form, $rec, $table);
00440
00441 $buttons = $this->createButtons() . $this->doc->spacer(5);
00442
00443
00444 $content .= $buttons . $form . $buttons;
00445 return $content;
00446 }
00447
00453 function createButtons() {
00454 global $LANG;
00455
00456 $content = '';
00457 $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" />';
00458 $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" />';
00459
00460 $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>';
00461 return $content;
00462 }
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00479 function getOwnerUser($uid) {
00480 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00481
00482 t3lib_div::loadTCA('sys_workspace');
00483
00484 $config = &$GLOBALS['TCA']['sys_workspace']['columns']['adminusers']['config'];
00485
00486
00487 $loadDB->start($GLOBALS['BE_USER']->user['uid'], $config['allowed'], $config['MM'], $uid, 'sys_workspace', $config);
00488 $loadDB->getFromDB();
00489 return $loadDB->readyForInterface();
00490 }
00491
00492
00493
00494
00495
00496
00497
00498
00499
00505 function processData() {
00506 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00507 $tce->stripslashes_values = 0;
00508
00509 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
00510 if (is_array($TCAdefaultOverride)) {
00511 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
00512 }
00513 $tce->stripslashes_values = 0;
00514
00515
00516
00517 $inputData_tmp = t3lib_div::_GP('data');
00518 $inputData = array();
00519 if (is_array($inputData_tmp['sys_workspace'])) {
00520 reset($inputData_tmp['sys_workspace']);
00521 $inputData['sys_workspace'][key($inputData_tmp['sys_workspace'])] = current($inputData_tmp['sys_workspace']);
00522 }
00523
00524 $tce->start($inputData, array(), $GLOBALS['BE_USER']);
00525 $tce->admin = 1;
00526 $tce->bypassWorkspaceRestrictions = true;
00527 $tce->process_datamap();
00528
00529
00530 $script = t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT');
00531 $tce->printLogErrorMessages($script . '?' .
00532 ($this->isEditAction ? 'action=edit&wkspId=' . $this->workspaceId : 'action=new'));
00533
00534
00535 if (count($tce->substNEWwithIDs_table)) {
00536 reset($tce->substNEWwithIDs_table);
00537 $this->workspaceId = current($tce->substNEWwithIDs);
00538 $this->isEditAction = true;
00539 }
00540 }
00541
00542
00543
00549 function fixVariousTCAFields() {
00550
00551 $GLOBALS['TCA']['sys_workspace']['ctrl']['dividers2tabs'] = true;
00552 }
00553
00554
00561 function fixTCAUserField($fieldName) {
00562
00563 if (!$GLOBALS['BE_USER']->isAdmin()) {
00564
00565 t3lib_div::loadTCA('sys_workspace');
00566 $field = &$GLOBALS['TCA']['sys_workspace']['columns'][$fieldName];
00567 $newField = array (
00568 'label' => $field['label'],
00569 'config' => Array (
00570 'type' => 'select',
00571 'itemsProcFunc' => 'user_SC_mod_user_ws_workspaceForms->processUserAndGroups',
00572
00573 'size' => 10,
00574 'maxitems' => $field['config']['maxitems'],
00575 'autoSizeMax' => $field['config']['autoSizeMax'],
00576 'mod_ws_allowed' => $field['config']['allowed']
00577 )
00578 );
00579 $field = $newField;
00580 }
00581 }
00582
00588 function checkWorkspaceAccess() {
00589 $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'));
00590 if (is_array($workspaces) && count($workspaces) != 0 && false !== ($rec = $GLOBALS['BE_USER']->checkWorkspace($workspaces[0]))) {
00591 return ($rec['_ACCESS'] == 'owner' || $rec['_ACCESS'] == 'admin');
00592 }
00593 return false;
00594 }
00595 }
00596
00601 class user_SC_mod_user_ws_workspaceForms {
00602
00610 function processUserAndGroups($conf, $tceforms) {
00611
00612 $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
00613 $groupArray = array_keys($be_group_Array);
00614
00615 $be_user_Array = t3lib_BEfunc::getUserNames();
00616 $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,1);
00617
00618
00619 $title = $GLOBALS['LANG']->sL($GLOBALS['TCA']['be_users']['ctrl']['title']);
00620 foreach ($be_user_Array as $uid => $user) {
00621 $conf['items'][] = array(
00622 $user['username'] . ' (' . $title . ')',
00623 'be_users_' . $user['uid'],
00624 t3lib_iconWorks::getIcon('be_users', $user)
00625 );
00626 }
00627
00628
00629 if (strstr($conf['config']['mod_ws_allowed'], 'be_groups')) {
00630
00631
00632 $be_group_Array = $be_group_Array_o = t3lib_BEfunc::getGroupNames();
00633 $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o,$groupArray,1);
00634
00635 $title = $GLOBALS['LANG']->sL($GLOBALS['TCA']['be_groups']['ctrl']['title']);
00636 foreach ($be_group_Array as $uid => $group) {
00637 $conf['items'][] = array(
00638 $group['title'] . ' (' . $title . ')',
00639 'be_groups_' . $group['uid'],
00640 t3lib_iconWorks::getIcon('be_groups', $user)
00641 );
00642 }
00643 }
00644 }
00645 }
00646
00647
00648 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/workspaceforms.php']) {
00649 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/workspaceforms.php']);
00650 }
00651
00652
00653 $SOBE = t3lib_div::makeInstance('SC_mod_user_ws_workspaceForms');
00654 $SOBE->init();
00655 $SOBE->main();
00656 $SOBE->printContent();
00657 ?>