### Eclipse Workspace Patch 1.0 #P igeworkspace42 Index: typo3/sysext/version/mod2/locallang.xml =================================================================== --- typo3/sysext/version/mod2/locallang.xml (revision 0) +++ typo3/sysext/version/mod2/locallang.xml (revision 0) @@ -0,0 +1,14 @@ + + + + module + Language labels for module "user_txversionM2" - header, description + + + + + + + + + \ No newline at end of file Index: typo3/sysext/version/mod2/conf.php =================================================================== --- typo3/sysext/version/mod2/conf.php (revision 0) +++ typo3/sysext/version/mod2/conf.php (revision 0) @@ -0,0 +1,10 @@ + \ No newline at end of file Index: typo3/sysext/version/mod2/index.php =================================================================== --- typo3/sysext/version/mod2/index.php (revision 0) +++ typo3/sysext/version/mod2/index.php (revision 0) @@ -0,0 +1,570 @@ + +* All rights reserved +* +* This script is part of the TYPO3 project. The TYPO3 project is +* free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ +/** + * [CLASS/FUNCTION INDEX of SCRIPT] + * + * Hint: use extdeveval to insert/update function index above. + */ + +//unset($MCONF); +//require ('conf.php'); +//require ($BACK_PATH.'init.php'); +//require ($BACK_PATH.'template.php'); +$LANG->includeLLFile('EXT:version/mod2/locallang.xml'); +require_once(PATH_t3lib . 'class.t3lib_scbase.php'); +require_once(PATH_typo3 . 'mod/user/ws/class.wsstagelib.php'); +$BE_USER->modAccess($MCONF,1); // This checks permissions and exits if the users has no permission for entry. + // DEFAULT initialization of a module [END] + +/** + * Module 'Maintenance' for the 'cabag_sla' extension. + * + * @author cab services ag + * @package TYPO3 + * @subpackage tx_cabagsla + */ +class tx_version_module2 extends t3lib_SCbase{ + + + /** + * Initializes the Module + * @return void + */ + function init() { + global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; + + parent::init(); + } + + /** + * Adds items to the ->MOD_MENU array. Used for the function menu selector. + * + * @return void + */ + function menuConfig() { + global $LANG; + $this->MOD_MENU = Array ( + 'function' => Array ( + '1' => $LANG->getLL('function1'), + '2' => $LANG->getLL('function2'), + '3' => $LANG->getLL('function3'), + ) + ); + parent::menuConfig(); + } + + /** + * Main function of the module. Write the content to $this->content + * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree + * + * @return [type] ... + */ + function main() { + global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; + + // Access check! + // The page will show only if there is a valid page and if this page may be viewed by the user + //$this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause); + //$access = is_array($this->pageinfo) ? 1 : 0; + + // initialize doc + $this->doc = t3lib_div::makeInstance('template'); + $this->doc->setModuleTemplate(t3lib_extMgm::extPath('version') . 'mod2//mod_template.html'); + $this->doc->backPath = $BACK_PATH; + $docHeaderButtons = $this->getButtons(); + + //if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id)) { + + // Decide if the menu button was clicked or it was called by workspace module + if(!t3lib_div::GPvar('changeItems') && !t3lib_div::GPvar('items')) { + header('Location: '.$this->doc->packPath.'mod/user/ws/index.php'); + } + + // Draw the form + $this->doc->form = '
'; + + // JavaScript + $this->doc->JScode = ' + + '; + $this->doc->postCode=' + + '; + // Render content: + $this->moduleContent(); + /*} else { + // If no access or if ID == zero + $docHeaderButtons['save'] = ''; + $this->content.=$this->doc->spacer(10); + }*/ + + // compile document + $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']); + $markers['CONTENT'] = $this->content; + + // Build the for the module + $this->content = $this->doc->startPage($LANG->getLL('title')); + $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); + $this->content.= $this->doc->endPage(); + $this->content = $this->doc->insertStylesAndJS($this->content); + + } + + /** + * Prints out the module HTML + * + * @return void + */ + function printContent() { + + $this->content.=$this->doc->endPage(); + echo $this->content; + } + + /** + * Generates the module content + * + * @return void + */ + function moduleContent() { + global $LANG; + + // Initialize workspace stage object + $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); + + // header + $this->content .= '

'.$LANG->getLL('function1').'

'; + + // debug + //$this->content .= '
'.print_r($_REQUEST,1).'
'; + + // Check if form was submitted and all needed informations are available + if(t3lib_div::GPvar('sendMailSubmit') && t3lib_div::GPvar('setStage') && + (t3lib_div::GPvar('NextStageRecipient') || t3lib_div::GPvar('PrevStageRecipient'))) { + + // Set submited stage id and change mode - prev or next stage id + list($changeMode,$setStageId) = explode(':',t3lib_div::GPvar('setStage'),2); + $setStageId = str_replace('editing_','',$setStageId); + + // merge recipients and choose right comments + switch($changeMode) { + case 'prev': + // Set comments + $comments = t3lib_div::GPvar('prevStageComments'); + $additionalRecipients = explode("\n",t3lib_div::GPvar('PrevStageAddRecipients')); + $recipients = array_merge(t3lib_div::GPvar('PrevStageRecipient'),$additionalRecipients); + $recipients = array_unique($recipients); + break; + case 'next': + // Set comments + $comments = t3lib_div::GPvar('nextStageComments'); + $additionalRecipients = explode("\n",t3lib_div::GPvar('NextStageAddRecipients')); + $recipients = array_merge(t3lib_div::GPvar('NextStageRecipient'),$additionalRecipients); + $recipients = array_unique($recipients); + break; + } + + // Create URL to forward to + if(t3lib_div::GPvar('diffOnly')) { // If module was called by preview mode - return to it + $cmdArray = array(); + $URL = $this->doc->packPath.'sysext/version/cm1/index.php?diffOnly=1&id='.t3lib_div::GPvar('pageId'); + + foreach(t3lib_div::GPvar('changeItems') as $tableKey => $boolValue) { + list($table,$uid) = explode(':',$tableKey,2); + $cmdArray[$table][$uid]['version']['action'] = 'setStage'; + $cmdArray[$table][$uid]['version']['stageId'] = $setStageId; + $cmdArray[$table][$uid]['version']['comment'] = $comments; + } + } else { + $URL = $this->doc->packPath.'mod/user/ws/index.php?'; + + foreach(t3lib_div::GPvar('changeItems') as $tableKey => $boolValue) { + $URL .= 'items['.$tableKey.']='.$boolValue.'&'; + } + + $URL .= '_with_selected_do=stage_'.$setStageId.'&wsid='.t3lib_div::GPvar('wsid'); + + // Set comments + $URL .= '&comments='.$comments; + } + + // Send information mail to selected recipients + $sendMail = $this->sendInformationMail($recipients,t3lib_div::GPvar('changeItems'),t3lib_div::GPvar('wsid'),$setStageId,$comments); + if($sendMail === true) { + if(t3lib_div::GPvar('diffOnly')) { // If module was called by preview mode - return to it + $tce = t3lib_div::makeInstance('t3lib_TCEmain'); + $tce->stripslashes_values = 0; + $tce->start(array(), $cmdArray); + $tce->process_cmdmap(); + } + + // Forward back to workspace module to save the new stage + header('Location: '.$this->doc->packPath.$URL); + } else { + $this->content .= ''.$sendMail.' Go back'; + return false; + } + } else { + // --- list of records to change --- + $changeRecords = t3lib_div::GPvar('items'); + $firstRun = 1; + $stageId = null; + $workspaceId = null; + + // Check if one or more checkboxes where selected in workspace module + if(empty($changeRecords)) { + $this->content .= 'You have to select one or more records. Go back'; + return false; + } + + $content = ''; + $this->content .= $this->doc->section('Change elements:',$content,0,1); + + // --- Current stage label --- + if($stageId !== '0' && $stageId !== '10') { + $currentStageRecord = t3lib_BEfunc::getRecord('sys_workspace_stage',$stageId-20); + $content = ''; + $this->content .= $this->doc->section('Current stage: "'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$currentStageRecord,true).'"',$content,0,1); + } elseif($stageId == '10') { + $content = ''; + $this->content .= $this->doc->section('Current stage: "'.$LANG->getLL('stage_publish').'"',$content,0,1); + } else { + $content = ''; + $this->content .= $this->doc->section('Current stage: "'.$LANG->getLL('stage_editing').'"',$content,0,1); + } + + // --- show stage switch possibilities --- + $content = ''; + + // If the current stage is the standart edit stage, there is no prev stage + if($stageId !== '0') { + $prevStageRecord = $wsstagelibObj->getPrevStage($workspaceId,$stageId); + if(empty($prevStageRecord) || !is_array($prevStageRecord)) { + $content .= 'There is no pevior stage.'; + } else { + // prev stage checkbox + if($prevStageRecord['uid'] == '0') { + // prev stage would be 0 = editing + $content .= ' Set back to "'.$LANG->getLL('stage_editing').'"'; + } else { + $content .= ' Set back to "'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$prevStageRecord,true).'"'; + } + } + + // Show recipient list for prev stage + if(t3lib_div::GPvar('sendMailSubmit')) { + $content .= '
Recipients for information mail:'; + } else { + $content .= '
Recipients for information mail:'; + } + if($prevStageRecord['uid'] == '0') { + // The prev stage would be the standart edit stage use possible recipients from workspace config field adminusers + $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace',$workspaceId); + $prevUserRecords = t3lib_BEfunc::getUserNames('username, uid, email','AND uid IN ('.str_replace('be_users_','',$workspaceRec['adminusers']).')'); + if(!empty($prevUserRecords) && is_array($prevUserRecords)) { + foreach($prevUserRecords as $prevUserUid => $prevUserRecord) { + $content .= '
'.$prevUserRecord['email'].''; + } + } else { + $content .= 'There are no recipients defined for this stage.'; + } + } else { + $prevUserRecords = t3lib_BEfunc::getUserNames('username, uid, email','AND uid IN ('.$prevStageRecord['responsible_persons'].')'); + if(!empty($prevUserRecords) && is_array($prevUserRecords)) { + foreach($prevUserRecords as $prevUserUid => $prevUserRecord) { + $content .= '
'.$prevUserRecord['email'].''; + } + } else { + $content .= 'There are no recipients defined for this stage.'; + } + + } + + $content .= '
Additional recipients:
'; + $prevStageComments = (!empty($prevStageRecord['default_mailcomment'])) ? $prevStageRecord['default_mailcomment'] : ''; + $content .= '
Comments:

'; + } + + $content .= '
'; + $nextStageRecord = $wsstagelibObj->getNextStage($workspaceId,$stageId); + if(empty($nextStageRecord) || !is_array($nextStageRecord)) { + $content .= 'There is no next stage.'; + } else { + // next stage checkbox + if($nextStageRecord['uid'] == '10') { + $content .= ' Set to "'.$LANG->getLL('stage_publish').'"'; + } else { + $content .= ' Set to "'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$nextStageRecord,true).'"'; + } + + // Show recipient list for next stage + if(t3lib_div::GPvar('sendMailSubmit')) { + $content .= '
Recipients for information mail:'; + } else { + $content .= '
Recipients for information mail:'; + } + if($nextStageRecord['uid'] == '10') { + // The prev stage would be the standart edit stage use possible recipients from workspace config field adminusers + $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace',$workspaceId); + $nextUserRecords = t3lib_BEfunc::getUserNames('username, uid, email','AND uid IN ('.str_replace('be_users_','',$workspaceRec['adminusers']).')'); + if(!empty($nextUserRecords) && is_array($nextUserRecords)) { + foreach($nextUserRecords as $nextUserUid => $nextUserRecord) { + $content .= '
'.$nextUserRecord['email'].''; + } + } else { + $content .= 'There are no recipients defined for this stage.'; + } + } else { + $nextUserRecords = t3lib_BEfunc::getUserNames('username, uid, email','AND uid IN ('.$nextStageRecord['responsible_persons'].')'); + if(!empty($nextUserRecords) && is_array($nextUserRecords)) { + foreach($nextUserRecords as $nextUserUid => $nextUserRecord) { + $content .= '
'.$nextUserRecord['email'].''; + } + } else { + $content .= 'There are no recipients defined for this stage.'; + } + } + + $content .= '
Additional recipients:
'; + $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : ''; + $content .= '
Comments:
'; + } + + // --- form fields --- + $content .= ''; + if(t3lib_div::GPvar('diffOnly')) { + $content .= ''; + $content .= ''; + } + $content .= '

'; + + $this->content .= $this->doc->section('Switch stage:',$content,0,1); + } + } + + /** + * Send the informationmail if custom staging is activated and a stage was changed + * + * @param array mail recipients + * @param array elements to change the stage + * @param int workspace uid + * @param int uid + * @return bool true on success or error message on failure + */ + protected function sendInformationMail($recipients, $changeItems, $wsid, $newStageId, $comments) { + global $LANG; + + $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $wsid); + if($newStageId !== '0' && $newStageId !== '10') { + $stageRec = t3lib_BEfunc::getRecord('sys_workspace_stage', $newStageId-20); + $title = t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$stageRec,true); + } else { + $title = ($newStageId == '0') ? $LANG->getLL('stage_editing') : $LANG->getLL('stage_publish'); + } + + $elements = ''; + foreach($changeItems as $tableKey => $boolValue) { + list($eTable,$eUid) = explode(':',$tableKey); + $eUid = intval($eUid); + $rr = t3lib_BEfunc::getRecord($eTable,$eUid); + $recTitle = t3lib_BEfunc::getRecordTitle($eTable,$rr); + if ($eTable!='pages') { + t3lib_BEfunc::fixVersioningPid($eTable,$rr); + $eUid=$rr['pid']; + } + $path = t3lib_BEfunc::getRecordPath($eUid,'',20); + + $page_id = ($eTable =='pages') ? $rr['t3_origuid'] : $rr['pid']; + $previewURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').'typo3/mod/user/ws/wsol_preview.php?id='.$page_id; + + // Create rows + $elements .= sprintf('"%s" (%s) at location "%s - preview: %s +',$recTitle, $tableKey, $path, $previewURL); + } + + /* + * + * + * 3.) send mail + * 3.6.) set from address to current user + * 3.7.) add inital text "automated generated mail from TYPO3" + * + */ + + $body = ' +TYPO3 site "%s" - workspace "%s" (#%s) + +The stage has changed for the element(s) + +%s + +New Stage: +==> %s + +User Comment: +"%s" + +Please do the following now: +Step 1: Login into the TYPO3 backend: %s + +Step 2: Klick on the preview links above or check the changed elements via backend. + +Step 3: Please set the stage for the elements to the next stage, +if the changes are ok for you or reject the stage back to the previous stage if they\'re not. + +State was changed by %s (username: %s) + +This mail was automated generated by TYPO3. + '; + $subject = 'TYPO3 Workspace Note: Stage Change for %s'; + + // Send email: + $message = sprintf($body, + $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], + $workspaceRec['title'], + $workspaceRec['uid'], + $elements, + $title, + $comments, + t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir, + $GLOBALS['BE_USER']->user['realName'], + $GLOBALS['BE_USER']->user['username']); + + $headers = 'From: '. $GLOBALS['BE_USER']->user['email'] . "\r\n" . + 'Reply-To: ' . $GLOBALS['BE_USER']->user['email']; + + if(t3lib_div::plainMailEncoded( + implode(',',$recipients), + sprintf($subject,$tableKey), + trim($message), + $headers + )) { + return true; + } else { + return 'Information mail could not be send. Stages were not changed.'; + } + + } + + /** + * Create the panel of buttons for submitting the form or otherwise perform operations. + * + * @return array all available buttons as an assoc. array + */ + protected function getButtons() { + + $buttons = array( + 'csh' => '', + 'shortcut' => '', + 'save' => '' + ); + // CSH + $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']); + + // SAVE button + //$buttons['save'] = ''; + + // Shortcut + if ($GLOBALS['BE_USER']->mayMakeShortcut()) { + $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']); + } + + return $buttons; + } +} + + + +if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/mod2/index.php']) { + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/mod2/index.php']); +} + + + +try { + + // Make instance: + $SOBE = t3lib_div::makeInstance('tx_version_module2'); + $SOBE->init(); + + // Include files? + foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE); + + $SOBE->main(); + $SOBE->printContent(); + + +} catch (Exception $ex){ + echo '
'.htmlspecialchars($ex->getMessage()).'
'; + echo '
'.htmlspecialchars($ex->getTraceAsString()).'
'; +} +?> \ No newline at end of file Index: typo3/sysext/version/mod2/moduleicon.gif =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: typo3/sysext/version/mod2/moduleicon.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: typo3/sysext/version/mod2/mod_template.html =================================================================== --- typo3/sysext/version/mod2/mod_template.html (revision 0) +++ typo3/sysext/version/mod2/mod_template.html (revision 0) @@ -0,0 +1,35 @@ + +
+ +
+
+
###BUTTONLIST_LEFT###
+
###BUTTONLIST_RIGHT###
+
+
+
###FUNC_MENU###
+
###PAGEPATH######PAGEINFO###
+
+
+ +
+
+ ###CONTENT### +
+
+
+ + + + + +
###BUTTONS###
+ + + +###SAVE### + + + +###SHORTCUT### + \ No newline at end of file Index: typo3/sysext/version/mod2/clear.gif =================================================================== Index: typo3/sysext/version/mod2/moduleicon.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: typo3/sysext/version/mod2/moduleicon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: typo3/sysext/version/ext_tables.php =================================================================== --- typo3/sysext/version/ext_tables.php (revision 270) +++ typo3/sysext/version/ext_tables.php (working copy) @@ -7,6 +7,15 @@ 'path' => t3lib_extMgm::extPath($_EXTKEY).'class.tx_version_cm1.php' ); + // add version module to the module navigation t3lib_extMgm::addModule('web','txversionM1','',t3lib_extMgm::extPath($_EXTKEY).'cm1/'); + + // add mod2 to the mod.php? module list + t3lib_extMgm::addModulePath('user_txversionM2', t3lib_extMgm::extPath($_EXTKEY) . 'mod2/'); + + // add version module to the module navigation + t3lib_extMgm::addModule('user', 'txversionM2', 'first', t3lib_extMgm::extPath($_EXTKEY).'mod2/'); } + + ?> \ No newline at end of file Index: typo3/sysext/version/ext_emconf.php =================================================================== --- typo3/sysext/version/ext_emconf.php (revision 270) +++ typo3/sysext/version/ext_emconf.php (working copy) @@ -20,7 +20,7 @@ 'dependencies' => '', 'conflicts' => '', 'priority' => '', - 'module' => 'cm1', + 'module' => 'cm1,mod2', 'state' => 'beta', 'internal' => '', 'uploadfolder' => 0, Index: typo3/sysext/version/mod2/locallang_mod.xml =================================================================== --- typo3/sysext/version/mod2/locallang_mod.xml (revision 0) +++ typo3/sysext/version/mod2/locallang_mod.xml (revision 0) @@ -0,0 +1,14 @@ + + + + module + Language labels for module "user_txversionM2" - header, description + + + + + + + + + \ No newline at end of file