Add email trigger to manual positioning
This commit is contained in:
@@ -33,12 +33,10 @@ class Converter extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function isGeoJsonValid($sCodeName) {
|
public static function isGeoJsonValid($sCodeName) {
|
||||||
$bResult = false;
|
|
||||||
$sGpxFilePath = Gpx::getFilePath($sCodeName);
|
$sGpxFilePath = Gpx::getFilePath($sCodeName);
|
||||||
$sGeoJsonFilePath = GeoJson::getFilePath($sCodeName);
|
$sGeoJsonFilePath = GeoJson::getFilePath($sCodeName);
|
||||||
|
|
||||||
//No need to generate if gpx is missing
|
//No need to generate if gpx is missing
|
||||||
if(!file_exists($sGpxFilePath) || file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Gpx::getFilePath($sCodeName))) $bResult = true;
|
return !file_exists($sGpxFilePath) || file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) >= filemtime($sGpxFilePath);
|
||||||
return $bResult;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
26
lib/Spot.php
26
lib/Spot.php
@@ -223,6 +223,15 @@ class Spot extends Main
|
|||||||
|
|
||||||
//Send Update Email
|
//Send Update Email
|
||||||
if($bNewMsg) {
|
if($bNewMsg) {
|
||||||
|
$bSuccess = $this->sendEmail();
|
||||||
|
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
||||||
|
}
|
||||||
|
else $sDesc = 'no_new_msg';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendEmail() {
|
||||||
$oEmail = new Email($this->asContext['serv_name'], 'email_update');
|
$oEmail = new Email($this->asContext['serv_name'], 'email_update');
|
||||||
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
||||||
|
|
||||||
@@ -250,12 +259,7 @@ class Spot extends Main
|
|||||||
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$bSuccess = $oEmail->send();
|
return $oEmail->send();
|
||||||
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
|
||||||
}
|
|
||||||
else $sDesc = 'no_new_msg';
|
|
||||||
|
|
||||||
return self::getJsonResult($bSuccess, $sDesc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function genCronFile() {
|
public function genCronFile() {
|
||||||
@@ -634,9 +638,15 @@ class Spot extends Main
|
|||||||
|
|
||||||
public function addPosition($sLat, $sLng, $iTimestamp) {
|
public function addPosition($sLat, $sLng, $iTimestamp) {
|
||||||
$oFeed = new Feed($this->oDb, $this->oProject->getFeedIds()[0]);
|
$oFeed = new Feed($this->oDb, $this->oProject->getFeedIds()[0]);
|
||||||
$bResult = ($oFeed->addManualPosition($sLat, $sLng, $iTimestamp) > 0);
|
$bSuccess = ($oFeed->addManualPosition($sLat, $sLng, $iTimestamp) > 0);
|
||||||
|
|
||||||
return self::getJsonResult($bResult, $bResult?'':$this->oDb->getLastError());
|
if($bSuccess) {
|
||||||
|
$bSuccess = $this->sendEmail();
|
||||||
|
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
||||||
|
}
|
||||||
|
else $sDesc = 'error_commit_db';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdminSettings($sType='') {
|
public function getAdminSettings($sType='') {
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ if($sAction!='')
|
|||||||
case 'add_position':
|
case 'add_position':
|
||||||
$sResult = $oSpot->addPosition($sLat, $sLng, $iTimestamp);
|
$sResult = $oSpot->addPosition($sLat, $sLng, $iTimestamp);
|
||||||
break;
|
break;
|
||||||
case 'admin_new':
|
|
||||||
$sResult = $oSpot->createProject();
|
|
||||||
break;
|
|
||||||
case 'admin_get':
|
case 'admin_get':
|
||||||
$sResult = $oSpot->getAdminSettings();
|
$sResult = $oSpot->getAdminSettings();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user