Newer
Older
<?php
/**
* This File contains QUI\Cron\Crons
*/
namespace QUI\Cron;
/**
* Cron Manager
*
* @author www.pcsg.de (Henning Leutz)
*/
class QuiqqerCrons
{
/**
* Clear the temp folder
*/
static function clearTempFolder()
{
$Temp->clear();
}
/**
* Clear complete cache
*/
static function clearCache()
{
}
/**
* Purge the cache
*/
static function purgeCache()
{
* Check project sites release dates
* Activate or deactivate sites
*
* @param Array $params - Cron Parameter
* @param \QUI\Cron\Manager $CronManager
*/
static function realeaseDate($params, $CronManager)
{
if ( !isset( $params['project'] ) ) {
throw new QUI\Exception( 'Need a project parameter to search release dates' );
throw new QUI\Exception( 'Need a lang parameter to search release dates' );
$Project = QUI::getProject( $params['project'], $params['lang'] );
$now = date('Y-m-d H:i:s');
// search sites with release dates
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
$deactivate = array();
$activate = array();
/**
* deactivate sites
*/
$Statment = $PDO->prepare("
SELECT id
FROM {$Project->getAttribute('db_table')}
WHERE active = 1 AND
release_from != :empty AND
release_to != :empty AND
(release_from > :date OR release_to < :date)
;
");
$Statment->bindValue( ':date', $now, \PDO::PARAM_STR );
$Statment->bindValue( ':empty', '0000-00-00 00:00:00', \PDO::PARAM_STR );
$Statment->execute();
$result = $Statment->fetchAll( \PDO::FETCH_ASSOC );
foreach ( $result as $entry )
{
try
{
$Site = $Project->get( (int)$entry['id'] );
$Site->deactivate();
$deactivate[] = (int)$entry['id'];
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
}
}
/**
* activate sites
*/
$Statment = $PDO->prepare("
SELECT id
FROM {$Project->getAttribute('db_table')}
WHERE active = 0 AND
release_from != :empty AND
release_to != :empty AND
release_to >= :date AND
release_from <= :date
;
");
$Statment->bindValue( ':date', $now, \PDO::PARAM_STR );
$Statment->bindValue( ':empty', '0000-00-00 00:00:00', \PDO::PARAM_STR );
$Statment->execute();
$result = $Statment->fetchAll( \PDO::FETCH_ASSOC );
foreach ( $result as $entry )
{
try
{
$Site = $Project->get( (int)$entry['id'] );
$Site->activate();
$activate[] = (int)$entry['id'];
'Folgende Seiten wurden deaktiviert: '. implode(',', $deactivate)
);
'Folgende Seiten wurden aktiviert: '. implode(',', $activate)
);
}
* @param array $params
* @param \QUI\Cron\Manager $CronManager
*/
static function mailQueue($params, $CronManager)
{
if ( $MailQueue->count() ) {
$MailQueue->send();
}
}