Zum Inhalt springen

Workspace Email mit Namen des Elementes

Erstellt am 9. Mai 2007 · 5 Antworten · letzte Antwort am 6. August 2007

Tags: E-Mail-Versand, Tipp

Merlin732 ·

Hallo,

ich bin kein großer Freund der Umsetzung des Workspaces in Typo3 und hoffe auf eine Verbesserung der Bedienung.

Mich störte, dass die Emails, welche durch den Workspace verschickt werden, eigentlich keinen Nutzen haben, da ich/ein Redakteur mit Daten wie "changes in tt_content:1165" nicht viel anfangen kann, da in der Workspaceliste die Elemente mit Namen und nicht mit ihrer uid eingetragen sind.

Da ich keine Lösung für dieses Problem finden konnte habe ich die Methode in typo3lib/class.t3lib_tcemain.php selbst editiert.
Da es gut funktioniert und meine Nutzer die Elemente nun besser trennen können, wollte ich die Lösung zur Diskusion stellen.
Falls sie jemand weiterhilft umso besser 🙂

	function notifyStageChange($stat,$stageId,$table,$id,$comment)	{
		$workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $stat['uid']);

		if (is_array($workspaceRec))	{

				// 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->notifyStageChange_getEmails($workspaceRec['reviewers']);
						break;
						case 10:
							$emails = $this->notifyStageChange_getEmails($workspaceRec['adminusers'], TRUE);
						break;
						case -1:
							$emails = $this->notifyStageChange_getEmails($workspaceRec['reviewers']);
							$emails = array_merge($emails,$this->notifyStageChange_getEmails($workspaceRec['members']));
						break;
						case 0:
							$emails = $this->notifyStageChange_getEmails($workspaceRec['members']);
						break;
 						default:
							$emails = $this->notifyStageChange_getEmails($workspaceRec['adminusers'], TRUE);
						break;
					}
				break;
				case 10:
					$emails = $this->notifyStageChange_getEmails($workspaceRec['adminusers'], TRUE);
					$emails = array_merge($emails,$this->notifyStageChange_getEmails($workspaceRec['reviewers']));
					$emails = array_merge($emails,$this->notifyStageChange_getEmails($workspaceRec['members']));
				break;
			}
			$emails = array_unique($emails);

			// Read Site name
			if( $table == 'pages')
				$field = 'title';
			else 
				$field = 'header';
			
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 	$field, // SELECT ...
															$table, // FROM ...
															'uid = '.$id // WHERE
            );
			
			$row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
            $title = $row[0];
			
			if(empty($title))
				$title = '[No title]';
 
			// Send email:
			if (count($emails))	{
				$message = sprintf('
At the TYPO3 site "%s" (%s)
in workspace "%s" (#%s)
the stage has changed for the element %s

==> %s

User Comment:
"%s"

State was change by %s (username: %s)
				',
				$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
				t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir,
				$workspaceRec['title'],
				$workspaceRec['uid'],
				'"'.$title.'" ('.$table.':'.$id.')',
				$newStage,
				$comment,
				$this->BE_USER->user['realName'],
				$this->BE_USER->user['username']);

				t3lib_div::plainMailEncoded(
					implode(',',$emails),
					'Typo3 Workspace Note: Stage Change for '.$title.'('.$table.':'.$id.')',
					trim($message)
				);
			}
		}
	}

Das Resultat ist simpel. Statt der Meldung ...changed for the element tt_content:1487 bekommt man nun die Meldung ...changed for the element "Hochverfügbarkeit, Datenreplikation und Disaster Recovery für VMware ESX Server" (tt_content:1487)

matthias_k ·

Auch Danke, wirklich guter Tipp 🙂
Du brauchst aber ansonsten auch nur "tt_content:1165" in das Bearbeiten/Suchen Feld unten links im Typo3 Backend eingeben/kopieren danach ENTER drücken, und schon bist Du beim entsprechenden Datensatz. Toll wenn man wirklich viele Seiten und Artikel im System hat.

pika ·

(sorry, english only)

Thank you for the very useful code! It works fine!

Can anyboby comment this: I configured a group as reviewers in my custom workspace. Could this be a reason why none of the group members receive the e-mail notification on changing a element status? Other (admin as a workspace owner, and another user which is workspace member) do receive the nofifications.

I am checking notifyStageChange_getEmails(), but I am too newbie to say definetly.

Thank you in advance!

Merlin732 ·

Hi pika,

did you insert a group of people or each person for its own to the reviewer list?
If you insert a group no one will receive an email.
You have to specify each reviewer and add him/her to the list.

pika ·
Merlin732 schrieb

If you insert a group no one will receive an email.
You have to specify each reviewer and add him/her to the list.

Yes, when I insert every member from a group, it works.
Thank you.