### Eclipse Workspace Patch 1.0 #P igeworkspace42 Index: typo3/sysext/version/mod2/locallang.xml =================================================================== --- typo3/sysext/version/mod2/locallang.xml (revision 290) +++ typo3/sysext/version/mod2/locallang.xml (working copy) @@ -9,6 +9,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: typo3/sysext/version/mod2/changeStage.js =================================================================== --- typo3/sysext/version/mod2/changeStage.js (revision 0) +++ typo3/sysext/version/mod2/changeStage.js (revision 0) @@ -0,0 +1,33 @@ +/*************************************************************** +* Copyright notice +* +* (c) 2009 Sonja Scholz +* 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. + */ + +// TYPO3 code extracted from index.php + +function jumpToUrl(URL) { + document.location = URL; +} \ No newline at end of file Index: typo3/sysext/version/mod2/index.php =================================================================== --- typo3/sysext/version/mod2/index.php (revision 324) +++ typo3/sysext/version/mod2/index.php (working copy) @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * -* (c) 2009 cab services ag +* (c) 2009 Sonja Scholz * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -27,10 +27,6 @@ * 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'); @@ -83,49 +79,30 @@ 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); - }*/ + // 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 = ''; + $this->doc->loadJavascriptLib('contrib/prototype/prototype.js'); + $this->doc->loadJavascriptLib('sysext/version/mod2/changeStage.js'); + + $this->doc->postCode=' + + '; + // Render content: + $this->moduleContent(); // compile document $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']); @@ -145,8 +122,6 @@ * @return void */ function printContent() { - - $this->content.=$this->doc->endPage(); echo $this->content; } @@ -159,7 +134,7 @@ global $LANG; // Initialize workspace stage object - $wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); + $this->wsstagelibObj = t3lib_div::makeInstance('wsstagelib'); // header $this->content .= '

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

'; @@ -168,30 +143,28 @@ //$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'))) { - + if(t3lib_div::GPvar('sendMailSubmit') && t3lib_div::GPvar('setStage')) { + // 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); + $setStageId = t3lib_div::GPvar('setStage'); + $setStageId = str_replace('editing_','',$setStageId); + + // --- mail recipients --- + $recipients = t3lib_div::GPvar($setStageId.'_stageRecipient'); + // Show the form again if there are no recipients given + if(!t3lib_div::GPvar('dontSendMail')) { + if(empty($recipients) || !is_array($recipients)) { + $this->showForm(); + return false; + } else { + $additionalRecipients = explode("\n",t3lib_div::GPvar('addRecipients')); + $finalRecipients = array_merge($recipients,$additionalRecipients); + $finalRecipients = array_unique($finalRecipients); + } + } - // 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; - } + // --- mail comments --- + $comments = t3lib_div::GPvar('comments'); // Create URL to forward to if(t3lib_div::GPvar('diffOnly')) { // If module was called by preview mode - return to it @@ -217,9 +190,12 @@ $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) { + // Send information mail to selected recipients if not deselected by donSendMail checkbox + if(!t3lib_div::GPvar('dontSendMail')) { + $sendMail = $this->sendInformationMail($recipients,t3lib_div::GPvar('changeItems'),t3lib_div::GPvar('wsid'),$setStageId,$comments); + } + + if(($sendMail === true) || (t3lib_div::GPvar('dontSendMail') == '1')) { 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; @@ -234,181 +210,255 @@ return false; } } else { - // --- list of records to change --- - $changeRecords = t3lib_div::GPvar('items'); - $firstRun = 1; - $stageId = null; - $workspaceId = null; + // Stage change form wasn't sent - show the form + $this->showForm(); + } + } + + /** + * Shows the change stage form + * + * @return string output + */ + function showForm() { + global $LANG; + + // --- 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 .= ''.$LANG->getLL('error_noRecordSelected').' '.$LANG->getLL('action_goBack').''; + return false; + } + + // --- Show records change --- + $content = '
    '; + foreach($changeRecords as $item => $v) { + list($recordTable,$recordInfos['uid'],$recordInfos['stage'],$recordInfos['wsid']) = explode(':',$item,4); + + if($firstRun == 1) { + $stageId = $recordInfos['stage']; + $workspaceId = $recordInfos['wsid']; + $firstRun = 0; + } + + // show an error if records have not all the same stage + if($recordInfos['stage'] !== $stageId) { + $this->content .= ''.$LANG->getLL('error_differentStages').' '.$LANG->getLL('action_goBack').''; + return false; + } - // 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'; + if($recordInfos['wsid'] !== $workspaceId) { + $this->content .= ''.$LANG->getLL('error_differentWorkspace').' '.$LANG->getLL('action_goBack').''; return false; } - $content = '
      '; - foreach($changeRecords as $item => $v) { - list($recordTable,$recordInfos['uid'],$recordInfos['stage'],$recordInfos['wsid']) = explode(':',$item,4); - - if($firstRun == 1) { - $stageId = $recordInfos['stage']; - $workspaceId = $recordInfos['wsid']; - $firstRun = 0; - } - - // show an error if records have not all the same stage - if($recordInfos['stage'] !== $stageId) { - $this->content .= 'You can only change records with the same stage. Go back'; - return false; - } - - if($recordInfos['wsid'] !== $workspaceId) { - $this->content .= 'You can only change records with the same workspace. Go back'; - return false; - } - - // get records from db - $singleRecord = t3lib_BEfunc::getRecord($recordTable,$recordInfos['uid']); - - if(!empty($singleRecord) && is_array($singleRecord)) { - if($recordTable == 'tt_content' || ($recordTable == 'pages' && $singleRecord['doktype'] == 1)) { - $page_id = ($recordTable == 'pages') ? $singleRecord['t3_origuid'] : $singleRecord['pid']; - $content .= '
    • '.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'
    • '; - } else { - $content .= '
    • '.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'
    • '; - } - - // Add hidden informations about the element to the form - needed to forward to workspace module after submit - $content .= ''; + // get records from db + $singleRecord = t3lib_BEfunc::getRecord($recordTable,$recordInfos['uid']); + + if(!empty($singleRecord) && is_array($singleRecord)) { + if($recordTable == 'tt_content' || ($recordTable == 'pages' && $singleRecord['doktype'] == 1)) { + $page_id = ($recordTable == 'pages') ? $singleRecord['t3_origuid'] : $singleRecord['pid']; + $content .= '
    • '.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'
    • '; } else { - $content .= 'No valid record Go back'; + $content .= '
    • '.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'
    • '; } - + // Add hidden informations about the element to the form - needed to forward to workspace module after submit + $content .= ''; + } else { + $content .= ''.$LANG->getLL('error_noValidRecord').' '.$LANG->getLL('action_goBack').''; } - $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); - } + } + $content .= '

'; + $this->content .= $this->doc->section($LANG->getLL('header_changeRecords'),$content,0,1); + + // --- show stage switch possibilities --- + $content = ''; - // --- show stage switch possibilities --- - $content = ''; + // --- prev stages --- + // If the current stage is the standart edit stage, there is no prev stage + if($stageId !== '0') { + // Get all previous stages for the record and for which the user has the permission + $prevStageRecordArray = array(); + $prevStageRecordArray = $this->wsstagelibObj->getPrevStages(&$prevStageRecordArray, $workspaceId, $stageId, $stageId); - // 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 { + if(count($prevStageRecordArray) < 1) { + $content .= ''.$LANG->getLL('error_noPrevStage').''; + } else { + $prevStageRecordArray = array_reverse($prevStageRecordArray); + foreach($prevStageRecordArray as $prevStageKey=>$prevStageRecord) { + // If current stage is "ready to publish" set the first prev stage to checked + if($stageId == '10') { + $checked = 'checked="checked"'; + } + // prev stage checkbox if($prevStageRecord['uid'] == '0') { // prev stage would be 0 = editing - $content .= ' Set back to "'.$LANG->getLL('stage_editing').'"'; + $content .= ''.$LANG->getLL('stage_editing').'

'; } else { - $content .= ' Set back to "'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$prevStageRecord,true).'"'; + $content .= ''.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:'; + + // get recipient list - display none + $content .= ''; + + // get default comment from custom stage configuration - display none + $prevStageComments = (!empty($prevStageRecord['default_mailcomment'])) ? $prevStageRecord['default_mailcomment'] : ''; + $content .= ''; } - 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, realName','AND uid IN ('.str_replace('be_users_','',$workspaceRec['adminusers']).')'); - if(!empty($prevUserRecords) && is_array($prevUserRecords)) { - foreach($prevUserRecords as $prevUserUid => $prevUserRecord) { - $content .= '
'.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' ) '; - } + } + } + + // --- Current stage label --- + $content .= ''; + if($stageId !== '0' && $stageId !== '10') { + $currentStageRecord = t3lib_BEfunc::getRecord('sys_workspace_stage',$stageId-20); + $content .= t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$currentStageRecord,true).'
'; + } elseif($stageId == '10') { + $content .= $LANG->getLL('stage_publish').'
'; + } else { + $content .= $LANG->getLL('stage_editing').'
'; + } + $content .= '

'; + + // --- next stages --- + // If current stage is "ready to publish" there is no next stage + if($stageId !== '10') { + $nextStageRecordArray = array(); + $nextStageRecordArray = $this->wsstagelibObj->getNextStages($nextStageRecordArray, $workspaceId, $stageId); + if(count($nextStageRecordArray) < 1) { + $content .= ''.$LANG->getLL('error_noNextStage').''; + } else { + $firstRun = 1; + foreach($nextStageRecordArray as $nextStageKey=>$nextStageRecord) { + if($firstRun == 1) { + $checked = 'checked="checked"'; + $firstRun = 0; } else { - $content .= 'There are no recipients defined for this stage.'; + $checked = ''; } - } else { - $prevUserRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName','AND uid IN ('.$prevStageRecord['responsible_persons'].')'); - if(!empty($prevUserRecords) && is_array($prevUserRecords)) { - foreach($prevUserRecords as $prevUserUid => $prevUserRecord) { - $content .= '
'.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' ) '; - } + // next stage checkbox + if($nextStageRecord['uid'] == '10') { + $content .= ''.$LANG->getLL('stage_publish').'

'; } else { - $content .= 'There are no recipients defined for this stage.'; + $content .= ''.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$nextStageRecord,true).'

'; } + // get recipient list - display none + $content .= ''; + + // get default comment from custom stage configuration - display none + $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : ''; + $content .= ''; } - - $content .= '
Additional recipients:
'; - $prevStageComments = (!empty($prevStageRecord['default_mailcomment'])) ? $prevStageRecord['default_mailcomment'] : ''; - $content .= '
Comments:

'; } + } + $this->content .= $this->doc->section($LANG->getLL('header_switchStage'),$content.'
',0,1); + + // --- Send e-mail --- + $content = ''; + + // E-Mail recipients + if($stageId !== '10') { + $content .= '
'.$this->getNextStageRecipientList($this->wsstagelibObj->getNextStage($workspaceId,$stageId), $workspaceId).'
'; + } else { + $content .= '
'.$this->getPrevStageRecipientList($this->wsstagelibObj->getPrevStage($workspaceId,$stageId), $workspaceId).'
'; + } - $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).'"'; + // Don't send email option + $content .= '
'.$LANG->getLL('option_dontSendMail'); + + // Additionial recipients + $content .= '
'.$LANG->getLL('header_addRecipients').'
'; + + // Stage change comment for notification mail and sys_log + $nextStageRecord = $this->wsstagelibObj->getNextStage($workspaceId,$stageId); + $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : ''; + $content .= '

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

'; + + // --- form fields --- + $content .= ''; + if(t3lib_div::GPvar('diffOnly')) { + $content .= ''; + $content .= ''; + } + $content .= '

'; + + $this->content .= $this->doc->section($LANG->getLL('header_sendMail'),$content,0,1); + } + + /** + * Creates the list of recipients for the given stage + * + * @param array prev stage record + * @return string HTML output + */ + function getPrevStageRecipientList($prevStageRecord, $workspaceId) { + global $LANG; + + 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, realName','AND uid IN ('.$this->wsstagelibObj->getResponsibleUser($workspaceRec['members']).')'); + if(!empty($prevUserRecords) && is_array($prevUserRecords)) { + foreach($prevUserRecords as $prevUserUid => $prevUserRecord) { + $content .= ' '.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' )
'; } - - // Show recipient list for next stage - if(t3lib_div::GPvar('sendMailSubmit')) { - $content .= '
Recipients for information mail:'; - } else { - $content .= '
Recipients for information mail:'; + } else { + $content .= ''.$LANG->getLL('error_noRecipientsDefined').''; + } + } else { + $prevUserRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName','AND uid IN ('.$prevStageRecord['responsible_persons'].')'); + if(!empty($prevUserRecords) && is_array($prevUserRecords)) { + foreach($prevUserRecords as $prevUserUid => $prevUserRecord) { + $content .= ' '.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' )
'; } - 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, realName','AND uid IN ('.str_replace('be_users_','',$workspaceRec['adminusers']).')'); - if(!empty($nextUserRecords) && is_array($nextUserRecords)) { - foreach($nextUserRecords as $nextUserUid => $nextUserRecord) { - $content .= '
'.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' ) '; - } - } else { - $content .= 'There are no recipients defined for this stage.'; - } - } else { - $nextUserRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName','AND uid IN ('.$nextStageRecord['responsible_persons'].')'); - if(!empty($nextUserRecords) && is_array($nextUserRecords)) { - foreach($nextUserRecords as $nextUserUid => $nextUserRecord) { - $content .= '
'.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' ) '; - } - } else { - $content .= 'There are no recipients defined for this stage.'; - } + } else { + $content .= ''.$LANG->getLL('error_noRecipientsDefined').''; + } + } + return $content; + } + + /** + * Creates the list of recipients for the given stage + * + * @param array next stage record + * @return string HTML output + */ + function getNextStageRecipientList($nextStageRecord, $workspaceId) { + global $LANG; + + 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, realName','AND uid IN ('.$workspaceRec['adminusers'].')'); + if(!empty($nextUserRecords) && is_array($nextUserRecords)) { + foreach($nextUserRecords as $nextUserUid => $nextUserRecord) { + $content .= ' '.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' )
'; } - - $content .= '
Additional recipients:
'; - $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : ''; - $content .= '
Comments:
'; + } else { + $content .= ''.$LANG->getLL('error_noRecipientsDefined').''; } - - // --- form fields --- - $content .= ''; - if(t3lib_div::GPvar('diffOnly')) { - $content .= ''; - $content .= ''; + } else { + $nextUserRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName','AND uid IN ('.$nextStageRecord['responsible_persons'].')'); + if(!empty($nextUserRecords) && is_array($nextUserRecords)) { + foreach($nextUserRecords as $nextUserUid => $nextUserRecord) { + $content .= ' '.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' )
'; + } + } else { + $content .= ''.$LANG->getLL('error_noRecipientsDefined').''; } - $content .= '

'; - - $this->content .= $this->doc->section('Switch stage:',$content,0,1); - } + } + return $content; } /** @@ -420,7 +470,7 @@ * @param int uid * @return bool true on success or error message on failure */ - protected function sendInformationMail($recipients, $changeItems, $wsid, $newStageId, $comments) { + function sendInformationMail($recipients, $changeItems, $wsid, $newStageId, $comments) { global $LANG; $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $wsid); @@ -436,6 +486,8 @@ list($eTable,$eUid) = explode(':',$tableKey); $eUid = intval($eUid); $rr = t3lib_BEfunc::getRecord($eTable,$eUid); + $currentStage = $rr['t3ver_stage']; + $currentStageTitle = t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$currentStage); $recTitle = t3lib_BEfunc::getRecordTitle($eTable,$rr); if ($eTable!='pages') { t3lib_BEfunc::fixVersioningPid($eTable,$rr); @@ -447,55 +499,53 @@ $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 + $elements .= sprintf($LANG->getLL('mail_elementpart').' ',$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) +'.$LANG->getLL('mail_body_labelWorkspace').' -The stage has changed for the element(s) +'.$LANG->getLL('mail_body_labelStageChanged').' %s -New Stage: -==> %s +'.$LANG->getLL('mail_body_labelNewStage').' +==> %s - %s -User Comment: +'.$LANG->getLL('mail_body_labelUserComment').' "%s" -Please do the following now: -Step 1: Login into the TYPO3 backend: %s +'.$LANG->getLL('mail_body_labelGuidance').' +'.$LANG->getLL('mail_body_labelGuidanceStep1').' -Step 2: Klick on the preview links above or check the changed elements via backend. +'.$LANG->getLL('mail_body_labelGuidanceStep2').' -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. +'.$LANG->getLL('mail_body_labelGuidanceStep3').' +'.$LANG->getLL('mail_body_labelGuidanceStep4').' -State was changed by %s (username: %s) +'.$LANG->getLL('mail_body_labelUser').' -This mail was automated generated by TYPO3. - '; - $subject = 'TYPO3 Workspace Note: Stage Change for %s'; +'.$LANG->getLL('mail_body_labelGeneratedByT3'); + + $elements .= sprintf($LANG->getLL('mail_elementpart'),$recTitle, $tableKey, $path, $previewURL); + + + $subject = $LANG->getLL('mail_subject'); + + $prevStageRecord = $this->wsstagelibObj->getPrevStage($wsid,$stageid); // Send email: $message = sprintf($body, - $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], $workspaceRec['title'], - $workspaceRec['uid'], + $title, $elements, + $workspaceRec['title'], $title, $comments, t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir, + $title, + $currentStageTitle, $GLOBALS['BE_USER']->user['realName'], $GLOBALS['BE_USER']->user['username']); @@ -504,13 +554,13 @@ if(t3lib_div::plainMailEncoded( implode(',',$recipients), - sprintf($subject,$tableKey), + sprintf($subject,$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']), trim($message), $headers )) { return true; } else { - return 'Information mail could not be send. Stages were not changed.'; + return $LANG->getLL('error_noMailWasSent'); } } @@ -531,7 +581,7 @@ $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']); // SAVE button - //$buttons['save'] = ''; + $buttons['save'] = ''; // Shortcut if ($GLOBALS['BE_USER']->mayMakeShortcut()) {