Project

General

Profile

Feature #2798 » patch-2798-2.txt

Sonja Schubert, 2009-03-30 14:52

 
### 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 @@
<label index="function1">Workspace Advanced Staging</label>
<label index="stage_editing">Editing</label>
<label index="stage_publish">Publish</label>
+ <label index="option_dontSendMail">Don't send an email notification, just change the stage.</label>
+ <label index="error_noRecordSelected">You have to select one or more records.</label>
+ <label index="error_differentStages">You can only change records with the same stage.</label>
+ <label index="error_differentWorkspace">You can only change records with the same workspace.</label>
+ <label index="error_noValidRecord">No valid record</label>
+ <label index="error_noPrevStage">There is no pevious stage.</label>
+ <label index="error_noNextStage">There is no next stage.</label>
+ <label index="error_noMailWasSent">Information mail could not be send. Stages were <strong>not</strong> changed.</label>
+ <label index="error_noRecipientsDefined">There are no recipients defined for this stage.</label>
+ <label index="header_changeRecords">Change records:</label>
+ <label index="header_switchStage">Switch stage:</label>
+ <label index="header_addRecipients">Additional recipients:</label>
+ <label index="header_comments">Comments:</label>
+ <label index="header_sendMail">Send mail:</label>
+ <label index="action_goBack">Go back</label>
+ <label index="action_submitButton">Send mail and change stage!</label>
+ <label index="mail_subject">%s - Please check page/changes</label>
+ <label index="mail_body_labelWorkspace">Workspace "%s"</label>
+ <label index="mail_body_labelStageChanged">The stage has changed to "%s" for the following element(s):</label>
+ <label index="mail_body_labelNewStage">New Stage:</label>
+ <label index="mail_body_labelUserComment">User Comment:</label>
+ <label index="mail_body_labelGuidance">Guidance:</label>
+ <label index="mail_body_labelGuidanceStep1">Step 1: Login into the TYPO3 backend: %s</label>
+ <label index="mail_body_labelGuidanceStep2">Step 2: Klick on the preview links above (preview) and check the changes of the elements.</label>
+ <label index="mail_body_labelGuidanceStep3">Step 3: Please set the stage for the checked elements to the next stage "%s",</label>
+ <label index="mail_body_labelGuidanceStep4">if the changes are ok for you or reject the stage back to the previous stage if they're not.</label>
+ <label index="mail_body_labelUser">Stage of the elements was changed by %s (username: %s)</label>
+ <label index="mail_body_labelGeneratedByT3">This mail was automated generated by TYPO3.</label>
+ <label index="mail_elementpart">"%s" (%s) at location "%s - preview: %s</label>
</languageKey>
</data>
</T3locallang>
\ 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 <ss@cabag.ch>
+* 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 <admin@cabag.ch>
+* (c) 2009 Sonja Scholz <ss@cabag.ch>
* 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 = '<form action="" method="post" enctype="multipart/form-data">';
-
- // JavaScript
- $this->doc->JScode = '
- <script language="javascript" type="text/javascript">
- script_ended = 0;
- function jumpToUrl(URL) {
- document.location = URL;
- }
- </script>
- ';
- $this->doc->postCode='
- <script language="javascript" type="text/javascript">
- script_ended = 1;
- if (top.fsMod) top.fsMod.recentIds["web"] = 0;
- </script>
- ';
- // 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 = '<form action="" method="post" enctype="multipart/form-data">';
+ $this->doc->loadJavascriptLib('contrib/prototype/prototype.js');
+ $this->doc->loadJavascriptLib('sysext/version/mod2/changeStage.js');
+
+ $this->doc->postCode='
+ <script language="javascript" type="text/javascript">
+ script_ended = 1;
+ if (top.fsMod) top.fsMod.recentIds["web"] = 0;
+ </script>
+ ';
+ // 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 .= '<h2>'.$LANG->getLL('function1').'</h2>';
@@ -168,30 +143,28 @@
//$this->content .= '<pre>'.print_r($_REQUEST,1).'</pre>';
// 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 .= '<span style="color: red;">'.$LANG->getLL('error_noRecordSelected').' <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>'.$LANG->getLL('action_goBack').'</strong></a></span>';
+ return false;
+ }
+
+ // --- Show records change ---
+ $content = '<ul>';
+ 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 .= '<span style="color: red;">'.$LANG->getLL('error_differentStages').' <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>'.$LANG->getLL('action_goBack').'</strong></a></span>';
+ return false;
+ }
- // Check if one or more checkboxes where selected in workspace module
- if(empty($changeRecords)) {
- $this->content .= '<span style="color: red;">You have to select one or more records. <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>Go back</strong></a></span>';
+ if($recordInfos['wsid'] !== $workspaceId) {
+ $this->content .= '<span style="color: red;">'.$LANG->getLL('error_differentWorkspace').' <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>'.$LANG->getLL('action_goBack').'</strong></a></span>';
return false;
}
- $content = '<ul>';
- 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 .= '<span style="color: red;">You can only change records with the same stage. <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>Go back</strong></a></span>';
- return false;
- }
-
- if($recordInfos['wsid'] !== $workspaceId) {
- $this->content .= '<span style="color: red;">You can only change records with the same workspace. <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>Go back</strong></a></span>';
- 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 .= '<li>'.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'</li>';
- } else {
- $content .= '<li>'.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'</li>';
- }
-
- // Add hidden informations about the element to the form - needed to forward to workspace module after submit
- $content .= '<input type="hidden" name="changeItems['.$recordTable.':'.$singleRecord['uid'].']" value="1"/>';
+ // 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 .= '<li>'.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'</li>';
} else {
- $content .= '<span style="color: red;">No valid record <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>Go back</strong></a></span>';
+ $content .= '<li>'.t3lib_BEfunc::getRecordTitle($recordTable,$singleRecord,true).'</li>';
}
-
+ // Add hidden informations about the element to the form - needed to forward to workspace module after submit
+ $content .= '<input type="hidden" name="changeItems['.$recordTable.':'.$singleRecord['uid'].']" value="1"/>';
+ } else {
+ $content .= '<span style="color: red;">'.$LANG->getLL('error_noValidRecord').' <a href="'.$this->doc->packPath.'mod/user/ws/index.php"><strong>'.$LANG->getLL('action_goBack').'</strong></a></span>';
}
- $content .= '</ul>';
- $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 .= '</ul><br />';
+ $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 .= '<span style="color: red;">There is no pevior stage.</span>';
- } else {
+ if(count($prevStageRecordArray) < 1) {
+ $content .= '<span style="color: red;">'.$LANG->getLL('error_noPrevStage').'</span>';
+ } 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 .= '<input type="radio" name="setStage" value="prev:editing_'.$prevStageRecord['uid'].'"><strong> Set back to "'.$LANG->getLL('stage_editing').'"</strong>';
+ $content .= '<input type="radio" class="radio" '.$checked.' name="setStage" onfocus="$(recipientContainer).innerHTML=$(recipientListFor_'.$prevStageRecord['uid'].').innerHTML" value="editing_'.$prevStageRecord['uid'].'"><strong>'.$LANG->getLL('stage_editing').'</strong><br /><br />';
} else {
- $content .= '<input type="radio" name="setStage" value="prev:'.$prevStageRecord['uid'].'"><strong> Set back to "'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$prevStageRecord,true).'"</strong>';
+ $content .= '<input type="radio" class="radio" '.$checked.' name="setStage" onfocus="$(recipientContainer).innerHTML=$(recipientListFor_'.$prevStageRecord['uid'].').innerHTML" value="'.$prevStageRecord['uid'].'"><strong>'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$prevStageRecord,true).'</strong><br /><br />';
}
- }
-
- // Show recipient list for prev stage
- if(t3lib_div::GPvar('sendMailSubmit')) {
- $content .= '<br /><span style="color: red;">Recipients for information mail:</span>';
- } else {
- $content .= '<br />Recipients for information mail:';
+
+ // get recipient list - display none
+ $content .= '<div id="recipientListFor_'.$prevStageRecord['uid'].'" style="display:none;">'.$this->getPrevStageRecipientList($prevStageRecord, $workspaceId).'</div>';
+
+ // get default comment from custom stage configuration - display none
+ $prevStageComments = (!empty($prevStageRecord['default_mailcomment'])) ? $prevStageRecord['default_mailcomment'] : '';
+ $content .= '<div id="commentFor_'.$prevStageRecord['uid'].'" style="display:none;">'.$prevStageComments.'</div>';
}
- 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 .= '<br /><input type="checkbox" class="checkbox" name="PrevStageRecipient[]" value="'.$prevUserRecord['email'].'"> '.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' ) ';
- }
+ }
+ }
+
+ // --- Current stage label ---
+ $content .= '<span style="padding:22px; line-height: 18px;"><strong>';
+ if($stageId !== '0' && $stageId !== '10') {
+ $currentStageRecord = t3lib_BEfunc::getRecord('sys_workspace_stage',$stageId-20);
+ $content .= t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$currentStageRecord,true).'<br />';
+ } elseif($stageId == '10') {
+ $content .= $LANG->getLL('stage_publish').'<br />';
+ } else {
+ $content .= $LANG->getLL('stage_editing').'<br />';
+ }
+ $content .= '</strong><br /></span>';
+
+ // --- 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 .= '<span style="color: red;">'.$LANG->getLL('error_noNextStage').'</span>';
+ } else {
+ $firstRun = 1;
+ foreach($nextStageRecordArray as $nextStageKey=>$nextStageRecord) {
+ if($firstRun == 1) {
+ $checked = 'checked="checked"';
+ $firstRun = 0;
} else {
- $content .= '<span style="color: red;">There are no recipients defined for this stage.</span>';
+ $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 .= '<br /><input type="checkbox" class="checkbox" name="PrevStageRecipient[]" value="'.$prevUserRecord['email'].'"> '.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' ) ';
- }
+ // next stage checkbox
+ if($nextStageRecord['uid'] == '10') {
+ $content .= '<input type="radio" class="radio" onfocus="$(recipientContainer).innerHTML=$(recipientListFor_'.$nextStageRecord['uid'].').innerHTML" '.$checked.' name="setStage" value="'.$nextStageRecord['uid'].'"><strong>'.$LANG->getLL('stage_publish').'</strong><br /><br />';
} else {
- $content .= '<span style="color: red;">There are no recipients defined for this stage.</span>';
+ $content .= '<input type="radio" class="radio" '.$checked.' onfocus="$(recipientContainer).innerHTML=$(recipientListFor_'.$nextStageRecord['uid'].').innerHTML" name="setStage" value="'.$nextStageRecord['uid'].'"><strong>'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$nextStageRecord,true).'</strong><br /><br />';
}
+ // get recipient list - display none
+ $content .= '<div id="recipientListFor_'.$nextStageRecord['uid'].'" style="display:none;">'.$this->getNextStageRecipientList($nextStageRecord, $workspaceId).'</div>';
+
+ // get default comment from custom stage configuration - display none
+ $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : '';
+ $content .= '<div id="commentFor_'.$nextStageRecord['uid'].'" style="display:none;">'.$nextStageComments.'</div>';
}
-
- $content .= '<br />Additional recipients: <br /><textarea name="PrevStageAddRecipients" cols="50" rows="5"></textarea>';
- $prevStageComments = (!empty($prevStageRecord['default_mailcomment'])) ? $prevStageRecord['default_mailcomment'] : '';
- $content .= '<br />Comments: <br /><textarea name="prevStageComments" cols="50" rows="5">'.$prevStageComments.'</textarea><br/>';
}
+ }
+ $this->content .= $this->doc->section($LANG->getLL('header_switchStage'),$content.'<br />',0,1);
+
+ // --- Send e-mail ---
+ $content = '';
+
+ // E-Mail recipients
+ if($stageId !== '10') {
+ $content .= '<div id="recipientContainer">'.$this->getNextStageRecipientList($this->wsstagelibObj->getNextStage($workspaceId,$stageId), $workspaceId).'</div>';
+ } else {
+ $content .= '<div id="recipientContainer">'.$this->getPrevStageRecipientList($this->wsstagelibObj->getPrevStage($workspaceId,$stageId), $workspaceId).'</div>';
+ }
- $content .= '<br />';
- $nextStageRecord = $wsstagelibObj->getNextStage($workspaceId,$stageId);
- if(empty($nextStageRecord) || !is_array($nextStageRecord)) {
- $content .= '<span style="color: red;">There is no next stage.</span>';
- } else {
- // next stage checkbox
- if($nextStageRecord['uid'] == '10') {
- $content .= '<input type="radio" checked="checked" name="setStage" value="next:'.$nextStageRecord['uid'].'"><strong> Set to "'.$LANG->getLL('stage_publish').'"</strong>';
- } else {
- $content .= '<input type="radio" checked="checked" name="setStage" value="next:'.$nextStageRecord['uid'].'"><strong> Set to "'.t3lib_BEfunc::getRecordTitle('sys_workspace_stage',$nextStageRecord,true).'"</strong>';
+ // Don't send email option
+ $content .= '<br /><input type="checkbox" class="checkbox" name="dontSendMail" value="1"> '.$LANG->getLL('option_dontSendMail');
+
+ // Additionial recipients
+ $content .= '<br />'.$LANG->getLL('header_addRecipients').' <br /><textarea name="addRecipients" cols="50" rows="5"></textarea>';
+
+ // Stage change comment for notification mail and sys_log
+ $nextStageRecord = $this->wsstagelibObj->getNextStage($workspaceId,$stageId);
+ $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : '';
+ $content .= '<br /><br />'.$LANG->getLL('header_comments').' <br /><textarea name="comments" cols="50" rows="5">'.$nextStageComments.'</textarea><br/>';
+
+ // --- form fields ---
+ $content .= '<input type="hidden" name="wsid" value="'.$workspaceId.'" />';
+ if(t3lib_div::GPvar('diffOnly')) {
+ $content .= '<input type="hidden" name="diffOnly" value="1" />';
+ $content .= '<input type="hidden" name="pageId" value="'.t3lib_div::GPvar('pageId').'" />';
+ }
+ $content .= '<br /><br /><input type="submit" name="sendMailSubmit" value="'.$LANG->getLL('action_submitButton').'" />';
+
+ $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 .= '<input type="checkbox" class="checkbox" name="'.$prevStageRecord['uid'].'_stageRecipient[]" value="'.$prevUserRecord['email'].'"> '.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' ) <br />';
}
-
- // Show recipient list for next stage
- if(t3lib_div::GPvar('sendMailSubmit')) {
- $content .= '<br /><span style="color: red;">Recipients for information mail:</span>';
- } else {
- $content .= '<br />Recipients for information mail:';
+ } else {
+ $content .= '<span style="color: red;">'.$LANG->getLL('error_noRecipientsDefined').'</span>';
+ }
+ } 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 .= '<input type="checkbox" class="checkbox" name="'.$prevStageRecord['uid'].'_stageRecipient[]" value="'.$prevUserRecord['email'].'"> '.$prevUserRecord['email'].' ( '.$prevUserRecord['realName'].' ) <br />';
}
- 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 .= '<br /><input type="checkbox" class="checkbox" name="NextStageRecipient[]" value="'.$nextUserRecord['email'].'"> '.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' ) ';
- }
- } else {
- $content .= '<span style="color: red;">There are no recipients defined for this stage.</span>';
- }
- } 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 .= '<br /><input type="checkbox" class="checkbox" name="NextStageRecipient[]" value="'.$nextUserRecord['email'].'"> '.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' ) ';
- }
- } else {
- $content .= '<span style="color: red;">There are no recipients defined for this stage.</span>';
- }
+ } else {
+ $content .= '<span style="color: red;">'.$LANG->getLL('error_noRecipientsDefined').'</span>';
+ }
+ }
+ 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 .= '<input type="checkbox" class="checkbox" name="'.$nextStageRecord['uid'].'_stageRecipient[]" value="'.$nextUserRecord['email'].'"> '.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' ) <br />';
}
-
- $content .= '<br />Additional recipients: <br /><textarea name="NextStageAddRecipients" cols="50" rows="5" ></textarea>';
- $nextStageComments = (!empty($nextStageRecord['default_mailcomment'])) ? $nextStageRecord['default_mailcomment'] : '';
- $content .= '<br />Comments: <br /><textarea name="nextStageComments" cols="50" rows="5">'.$nextStageComments.'</textarea>';
+ } else {
+ $content .= '<span style="color: red;">'.$LANG->getLL('error_noRecipientsDefined').'</span>';
}
-
- // --- form fields ---
- $content .= '<input type="hidden" name="wsid" value="'.$workspaceId.'" />';
- if(t3lib_div::GPvar('diffOnly')) {
- $content .= '<input type="hidden" name="diffOnly" value="1" />';
- $content .= '<input type="hidden" name="pageId" value="'.t3lib_div::GPvar('pageId').'" />';
+ } 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 .= '<input type="checkbox" class="checkbox" name="'.$nextStageRecord['uid'].'_stageRecipient[]" value="'.$nextUserRecord['email'].'"> '.$nextUserRecord['email'].' ( '.$nextUserRecord['realName'].' ) <br />';
+ }
+ } else {
+ $content .= '<span style="color: red;">'.$LANG->getLL('error_noRecipientsDefined').'</span>';
}
- $content .= '<br /><br /><input type="submit" name="sendMailSubmit" value="Send mail and change stage!" />';
-
- $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 <strong>not</strong> 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'] = '<input type="image" class="c-inputButton" name="submit" value="Update"' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/savedok.gif', '') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" />';
+ $buttons['save'] = '<input type="image" class="c-inputButton" name="submit" value="Update"' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/savedok.gif', '') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" />';
// Shortcut
if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
(2-2/5)