Add update emails
This commit is contained in:
45
inc/spot.php
45
inc/spot.php
@@ -163,12 +163,45 @@ class Spot extends Main
|
||||
|
||||
public function setProjectId($iProjectId=0) {
|
||||
$this->oProject->setProjectId($iProjectId);
|
||||
}
|
||||
|
||||
public function updateProject() {
|
||||
$bNewMsg = false;
|
||||
|
||||
//Update all feeds belonging to the project
|
||||
$asFeeds = $this->oProject->getFeedIds();
|
||||
foreach($asFeeds as $iFeedId) {
|
||||
$oFeed = new Feed($this->oDb, $iFeedId);
|
||||
$oFeed->checkUpdateFeed($this->oProject->getMode());
|
||||
$bNewMsg = $bNewMsg || $oFeed->checkUpdateFeed($this->oProject->getMode());
|
||||
}
|
||||
|
||||
//Send Update Email
|
||||
if($bNewMsg) {
|
||||
$oEmail = new Email($this->asContext['serv_name'], 'email_update');
|
||||
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
||||
|
||||
//Add Position
|
||||
$asMessages = $this->getSpotMessages();
|
||||
$asLastMessage = end($asMessages);
|
||||
$asLastMessage['token'] = Settings::GEO_SERVER_TOKEN;
|
||||
$oEmail->oTemplate->setTags($asLastMessage);
|
||||
$oEmail->oTemplate->setTag('date_time', 'lang:date_time', array(date('d/m/Y', $asLastMessage['unix_time']), date('H:i', $asLastMessage['unix_time'])));
|
||||
|
||||
//Add latest news feed
|
||||
$asNews = $this->getNewsFeed(0, true);
|
||||
$iPostCount = 0;
|
||||
foreach($asNews as $asPost) {
|
||||
if($asPost['type'] != 'message') {
|
||||
$oEmail->oTemplate->newInstance('news');
|
||||
$oEmail->oTemplate->setInstanceTag('news', 'local_server', $this->asContext['serv_name']);
|
||||
$oEmail->oTemplate->addInstance($asPost['type'], $asPost);
|
||||
$oEmail->oTemplate->setInstanceTag($asPost['type'], 'local_server', $this->asContext['serv_name']);
|
||||
$iPostCount++;
|
||||
}
|
||||
if($iPostCount==5) break;
|
||||
}
|
||||
|
||||
$oEmail->send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +210,7 @@ class Spot extends Main
|
||||
$sFileName = 'spot_cron.sh';
|
||||
$sContent =
|
||||
'#!/bin/bash'."\n".
|
||||
'wget -qO- '.$this->asContext['serv_name'].'index.php?a=dummy > /dev/null'."\n".
|
||||
'wget -qO- '.$this->asContext['serv_name'].'index.php?a=update_project > /dev/null'."\n".
|
||||
'#Crontab job: 0 * * * * . '.dirname($_SERVER['SCRIPT_FILENAME']).'/'.$sFileName.' > /dev/null'."\n";
|
||||
$bSuccess = (file_put_contents($sFileName, $sContent)!==false);
|
||||
return self::getJsonResult($bSuccess, '');
|
||||
@@ -220,7 +253,7 @@ class Spot extends Main
|
||||
|
||||
//Send Confirmation Email
|
||||
if($asResult['result'] && $asResult['desc']=='lang:nl_subscribed') {
|
||||
$oConfEmail = new Email($this->asContext['serv_name'], 'email_confirmation');
|
||||
$oConfEmail = new Email($this->asContext['serv_name'], 'email_conf');
|
||||
$oConfEmail->setDestInfo($asUserInfo);
|
||||
$oConfEmail->send();
|
||||
}
|
||||
@@ -331,7 +364,7 @@ class Spot extends Main
|
||||
$asData['formatted_time'] = $this->getTimeFormat($iTime);
|
||||
}
|
||||
|
||||
public function getNewsFeed($iChunk=0)
|
||||
public function getNewsFeed($iChunk=0, $bInternal=false)
|
||||
{
|
||||
$bHistoMode = ($this->oProject->getMode() == Project::MODE_HISTO);
|
||||
$asFeeds = array();
|
||||
@@ -368,9 +401,9 @@ class Spot extends Main
|
||||
else ksort($asFeeds);
|
||||
|
||||
//Split chunks
|
||||
$asFeeds = array_slice($asFeeds, $iChunk*self::FEED_CHUNK_SIZE, self::FEED_CHUNK_SIZE);
|
||||
$asFeeds = array_slice($asFeeds, $iChunk * self::FEED_CHUNK_SIZE, self::FEED_CHUNK_SIZE);
|
||||
|
||||
return self::getJsonResult(true, '', $asFeeds);
|
||||
return $bInternal?$asFeeds:self::getJsonResult(true, '', $asFeeds);
|
||||
}
|
||||
|
||||
public function syncMedias() {
|
||||
|
||||
Reference in New Issue
Block a user