<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=ProcessWire_-_Cronjob</id>
	<title>ProcessWire - Cronjob - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=ProcessWire_-_Cronjob"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=ProcessWire_-_Cronjob&amp;action=history"/>
	<updated>2026-05-06T15:22:03Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=ProcessWire_-_Cronjob&amp;diff=27290&amp;oldid=prev</id>
		<title>109.193.152.88 am 3. April 2025 um 10:33 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=ProcessWire_-_Cronjob&amp;diff=27290&amp;oldid=prev"/>
		<updated>2025-04-03T10:33:47Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 3. April 2025, 10:33 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l50&quot; &gt;Zeile 50:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 50:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Zugangsschutz:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Hier gibt es verschiedene Methoden. Wenn es bei all-inkl läuft kannst du einfach einen htaccess Passwortschutz auf das Verzeichnis legen (über das kasserver Backend)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>109.193.152.88</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=ProcessWire_-_Cronjob&amp;diff=27289&amp;oldid=prev</id>
		<title>109.193.152.88: Die Seite wurde neu angelegt: „Damit ein Cronjob Skript Zugriff auf die ProcessWire Funktionen hat kannst du einfach die index.php inkludieren.  Beachte, dass du bei Selektoren z.B. include=…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=ProcessWire_-_Cronjob&amp;diff=27289&amp;oldid=prev"/>
		<updated>2025-04-03T10:32:18Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „Damit ein Cronjob Skript Zugriff auf die ProcessWire Funktionen hat kannst du einfach die index.php inkludieren.  Beachte, dass du bei Selektoren z.B. include=…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Damit ein Cronjob Skript Zugriff auf die ProcessWire Funktionen hat kannst du einfach die index.php inkludieren.&lt;br /&gt;
&lt;br /&gt;
Beachte, dass du bei Selektoren z.B. include=all angeben musst, wenn du auf Templates mit Zugriffsbeschränkungen zugreifst (z.B. wenn diese nur für eine Benutzergruppe zugelassen sind.&lt;br /&gt;
&lt;br /&gt;
Beispiel Archivierungsskript für DEKRA Gewinnspiel:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php namespace ProcessWire;&lt;br /&gt;
/**&lt;br /&gt;
 * &lt;br /&gt;
 * job.php&lt;br /&gt;
 * Maintenance tasks called via cronjob&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
//require_once(&amp;#039;../index.php&amp;#039;); // Bootstrapping ProcessWire&lt;br /&gt;
//$pw_path = $_SERVER[&amp;#039;DOCUMENT_ROOT&amp;#039;] . &amp;#039;index.php&amp;#039;;&lt;br /&gt;
$pw_path = __DIR__ . &amp;#039;/../index.php&amp;#039;; // passe den Pfad ggf. an&lt;br /&gt;
require_once($pw_path);&lt;br /&gt;
$archivedCount = moveAnswersToArchive(10);&lt;br /&gt;
echo &amp;quot;Verschobene Antworten: &amp;quot; . $archivedCount . chr(10);&lt;br /&gt;
echo &amp;quot; nomail&amp;quot;; // uncomment if you don&amp;#039;t want cronjob mails&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * moveAnswersToArchive&lt;br /&gt;
 * bewegt Antworten zu Fragen ins Archiv (Checkbox gewählt)&lt;br /&gt;
 * Bewegt nur eine begrenzte Anzahl aus Effizienzgründen&lt;br /&gt;
 * Wird vom export Tool automatisch aufgerufen&lt;br /&gt;
 */&lt;br /&gt;
function moveAnswersToArchive($limit = 3, $parentPage = 30321, $archieveTemplate = &amp;#039;user-archieved-answer&amp;#039;) {&lt;br /&gt;
	$lockedQuestions = pages()-&amp;gt;find(&amp;quot;template=question, checkbox=1, sort=date, limit=3, include=all&amp;quot;); // include ist wichtig, da template zugriff eingeschränkt&lt;br /&gt;
  //var_dump($lockedQuestions);&lt;br /&gt;
	$c = 0;&lt;br /&gt;
	$parent = pages()-&amp;gt;get($parentPage);&lt;br /&gt;
	if($lockedQuestions-&amp;gt;count) {&lt;br /&gt;
			foreach($lockedQuestions as $question) {&lt;br /&gt;
					$answers = pages()-&amp;gt;find(&amp;quot;template=user-answer, pr_question={$question-&amp;gt;id}, sort=date, limit={$limit}&amp;quot;);&lt;br /&gt;
					foreach($answers as $answer) {&lt;br /&gt;
							$answer-&amp;gt;template = $archieveTemplate;&lt;br /&gt;
							$answer-&amp;gt;parent = $parent;&lt;br /&gt;
							if($answer-&amp;gt;save()) {&lt;br /&gt;
									$c++;&lt;br /&gt;
							}&lt;br /&gt;
					}&lt;br /&gt;
			}&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Rückgabe der Anzahl der verschobenen Antworten&lt;br /&gt;
  wire(&amp;#039;log&amp;#039;)-&amp;gt;save(&amp;#039;cronjob&amp;#039;, &amp;#039;Antworten archiviert: &amp;#039;. $c);&lt;br /&gt;
	return $c;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>109.193.152.88</name></author>
	</entry>
</feed>