$this->version_setStage($table, $elementId, $value['stageId'],
(isset($value['comment']) && $value['comment'] ? $value['comment'] : $this->generalComment),
TRUE,
- $tcemainObj
+ $tcemainObj,
+ $value['notificationAlternativeRecipients']
);
}
break;
public function processCmdmap_afterFinish(&$tcemainObj) {
// Empty accumulation array:
foreach ($this->notificationEmailInfo as $notifItem) {
- $this->notifyStageChange($notifItem['shared'][0], $notifItem['shared'][1], implode(', ', $notifItem['elements']), 0, $notifItem['shared'][2], $tcemainObj);
+ $this->notifyStageChange($notifItem['shared'][0], $notifItem['shared'][1], implode(', ', $notifItem['elements']), 0, $notifItem['shared'][2], $tcemainObj, $notifItem['alternativeRecipients']);
}
// Reset notification array
* @param string Table name of element (or list of element names if $id is zero)
* @param integer Record uid of element (if zero, then $table is used as reference to element(s) alone)
* @param string User comment sent along with action
+ * @param object TCEmain object
+ * @param string comma separated list of recipients to notificate instead of be_users selected by sys_workspace, list is generated by workspace extension module
* @return void
*/
- protected function notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj) {
+ protected function notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj, $notificationAlternativeRecipients = FALSE) {
$workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $stat['uid']);
// So, if $id is not set, then $table is taken to be the complete element name!
$elementName = $id ? $table . ':' . $id : $table;
if (is_array($workspaceRec)) {
- // TODO: CONSTANTS SHOULD BE USED - tx_service_workspace_workspaces
- // TODO: use localized labels
- // Compile label:
- switch ((int)$stageId) {
- case 1:
- $newStage = 'Ready for review';
- break;
- case 10:
- $newStage = 'Ready for publishing';
- break;
- case -1:
- $newStage = 'Element was rejected!';
- break;
- case 0:
- $newStage = 'Rejected element was noticed and edited';
- break;
- default:
- $newStage = 'Unknown state change!?';
- break;
+ // Get the new stage title from workspaces library, if workspaces extension is installed
+ if (t3lib_extMgm::isLoaded('workspaces')) {
+ $stageService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
+ $newStage = $stageService->getStageTitle((int)$stageId);
+ } else {
+ // TODO: CONSTANTS SHOULD BE USED - tx_service_workspace_workspaces
+ // TODO: use localized labels
+ // Compile label:
+ switch ((int)$stageId) {
+ case 1:
+ $newStage = 'Ready for review';
+ break;
+ case 10:
+ $newStage = 'Ready for publishing';
+ break;
+ case -1:
+ $newStage = 'Element was rejected!';
+ break;
+ case 0:
+ $newStage = 'Rejected element was noticed and edited';
+ break;
+ default:
+ $newStage = 'Unknown state change!?';
+ break;
+ }
}
- // Compile list of recipients:
- $emails = array();
- switch((int)$stat['stagechg_notification']) {
- case 1:
- switch((int)$stageId) {
- case 1:
- $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
- break;
- case 10:
- $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
- break;
- case -1:
-# $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
-# $emails = array_merge($emails,$this->getEmailsForStageChangeNotification($workspaceRec['members']));
-
- // List of elements to reject:
- $allElements = explode(',', $elementName);
- // Traverse them, and find the history of each
- foreach ($allElements as $elRef) {
- list($eTable, $eUid) = explode(':', $elRef);
-
- $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
- 'log_data,tstamp,userid',
- 'sys_log',
- 'action=6 and details_nr=30
- AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($eTable, 'sys_log') . '
- AND recuid=' . intval($eUid),
- '',
- 'uid DESC'
- );
- // Find all implicated since the last stage-raise from editing to review:
- foreach ($rows as $dat) {
- $data = unserialize($dat['log_data']);
-
- $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($dat['userid'], TRUE));
-
- if ($data['stage'] == 1) {
- break;
+ if ($notificationAlternativeRecipients == false) {
+ // Compile list of recipients:
+ $emails = array();
+ switch((int)$stat['stagechg_notification']) {
+ case 1:
+ switch((int)$stageId) {
+ case 1:
+ $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
+ break;
+ case 10:
+ $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
+ break;
+ case -1:
+# $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
+# $emails = array_merge($emails,$this->getEmailsForStageChangeNotification($workspaceRec['members']));
+
+ // List of elements to reject:
+ $allElements = explode(',', $elementName);
+ // Traverse them, and find the history of each
+ foreach ($allElements as $elRef) {
+ list($eTable, $eUid) = explode(':', $elRef);
+
+ $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+ 'log_data,tstamp,userid',
+ 'sys_log',
+ 'action=6 and details_nr=30
+ AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($eTable, 'sys_log') . '
+ AND recuid=' . intval($eUid),
+ '',
+ 'uid DESC'
+ );
+ // Find all implicated since the last stage-raise from editing to review:
+ foreach ($rows as $dat) {
+ $data = unserialize($dat['log_data']);
+
+ $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($dat['userid'], TRUE));
+
+ if ($data['stage'] == 1) {
+ break;
+ }
}
}
- }
- break;
+ break;
- case 0:
- $emails = $this->getEmailsForStageChangeNotification($workspaceRec['members']);
- break;
+ case 0:
+ $emails = $this->getEmailsForStageChangeNotification($workspaceRec['members']);
+ break;
- default:
- $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
- break;
- }
- break;
- case 10:
- $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
- $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']));
- $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['members']));
- break;
+ default:
+ $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
+ break;
+ }
+ break;
+ case 10:
+ $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
+ $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']));
+ $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['members']));
+ break;
+ }
+ } else {
+ $emails = array();
+ foreach ($notificationAlternativeRecipients as $emailAddress) {
+ $emails[] = array('email' => $emailAddress);
+ }
}
// prepare and then send the emails
* @param integer Stage ID to set
* @param string Comment that goes into log
* @param boolean Accumulate state changes in memory for compiled notification email?
+ * @param object TCEmain object
+ * @param string comma separated list of recipients to notificate instead of normal be_users
* @return void
*/
- protected function version_setStage($table, $id, $stageId, $comment = '', $notificationEmailInfo = FALSE, $tcemainObj) {
+ protected function version_setStage($table, $id, $stageId, $comment = '', $notificationEmailInfo = FALSE, $tcemainObj, $notificationAlternativeRecipients = FALSE) {
if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
$tcemainObj->newlog('Attempt to set stage for record failed: ' . $errorCode, 1);
} elseif ($tcemainObj->checkRecordUpdateAccess($table, $id)) {
if ($notificationEmailInfo) {
$this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['shared'] = array($stat, $stageId, $comment);
$this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['elements'][] = $table . ':' . $id;
+ $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['alternativeRecipients'] = $notificationAlternativeRecipients;
} else {
- $this->notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj);
+ $this->notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj, $notificationAlternativeRecipients);
}
}
} else $tcemainObj->newlog('The member user tried to set a stage value "' . $stageId . '" that was not allowed', 1);