[Mapbender-commits] r9494 - trunk/mapbender/tools

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri May 27 00:33:03 PDT 2016


Author: armin11
Date: 2016-05-27 00:33:03 -0700 (Fri, 27 May 2016)
New Revision: 9494

Removed:
   trunk/mapbender/tools/mod_runScheduler.php~
Log:
Fix wrong commit

Deleted: trunk/mapbender/tools/mod_runScheduler.php~
===================================================================
--- trunk/mapbender/tools/mod_runScheduler.php~	2016-05-27 07:30:15 UTC (rev 9493)
+++ trunk/mapbender/tools/mod_runScheduler.php~	2016-05-27 07:33:03 UTC (rev 9494)
@@ -1,148 +0,0 @@
-<?php
-require_once(dirname(__FILE__)."/../core/system.php");
-require_once(dirname(__FILE__)."/../http/classes/class_wms.php"); 
-
-$sql = <<<SQL
-SELECT scheduler_id, wms_id, wms_title, to_timestamp(wms_timestamp)::date AS last_change, last_status, fkey_upload_id, wms_upload_url, 
-scheduler_interval,scheduler_mail,scheduler_publish,scheduler_searchable,scheduler_overwrite, 
-scheduler_status FROM (SELECT scheduler_id, wms_id, fkey_wms_id, wms_title, wms_timestamp, 
-scheduler_interval,scheduler_mail,scheduler_publish,scheduler_searchable,scheduler_overwrite,
-scheduler_status,wms_upload_url FROM scheduler 
-INNER JOIN wms ON scheduler.fkey_wms_id=wms.wms_id ) AS test 
-LEFT OUTER JOIN mb_wms_availability ON test.fkey_wms_id = mb_wms_availability.fkey_wms_id;
-SQL;
-$res = db_query($sql);
-//$resultObj = array();
-//array containing all wms which should be updated
-$wmsToUpdate = array();
-
-while ($row = db_fetch_array($res)) {
-	$resultObj = array(
-		"scheduler_id" 	=> $row['scheduler_id'],
-		"wms_id"  =>  $row['wms_id'],
-		"wms_title"  =>  $row['wms_title'],
-	    "last_change"  =>  $row['last_change'],
-	    "last_status"  =>  $row['last_status'],
-		"wms_upload_url"  =>  $row['wms_upload_url'],
-	    "fkey_upload_id"  =>  $row['fkey_upload_id'],
-	    "scheduler_interval"  =>  $row['scheduler_interval'],
-	    "scheduler_mail"  =>  $row['scheduler_mail'],
-	    "scheduler_publish"  =>  $row['scheduler_publish'],
-	    "scheduler_searchable"  =>  $row['scheduler_searchable'],
-		"scheduler_overwrite"  =>  $row['scheduler_overwrite'],
-	    "scheduler_status"  =>  $row['scheduler_status']
-	);
-	
-	if($row['scheduler_interval'] == '1 mon') {
-	    $row['scheduler_interval'] = "1 month";
-	}
-    //check wms timestamp , schedule interval with current date for update
-    $currentDate = date('Y-m-d',time());
-    $schedulerDateTimestamp = date("Y-m-d",strtotime(date("Y-m-d", strtotime($row['last_change'])) . $row['scheduler_interval']));
-    //last monitoring date
-    $lastMonitorDate = date("Y-m-d",$row['fkey_upload_id']);
-    $schedulerDateMonitoring = date("Y-m-d",strtotime(date("Y-m-d", $row['fkey_upload_id']) . $row['scheduler_interval']));
-    
-    //if calculated $schedulerDateTimestamp is in the past 
-    //or last_status value of monitoring does not have the value 1 which means wms has been updated by monitoring
-    if($currentDate >= $schedulerDateTimestamp) {
-        if ($row['last_status'] == 1) {
-            if($currentDate >= $schedulerDateMonitoring) {
-                array_push($wmsToUpdate, $resultObj);
-            }
-        }
-        else{
-            array_push($wmsToUpdate, $resultObj);
-        }
-    }
-    else {
-        if ($row['last_status'] == 0) {
-            array_push($wmsToUpdate, $resultObj);
-        }
-    }
-}
-
-for ($i=0; $i<count($wmsToUpdate); $i++) {
-    #echo "WMS ID = ".$wmsToUpdate[$i]['wms_id']."\n";
-    #echo "WMS URL = ".$wmsToUpdate[$i]['wms_upload_url']."\n";
-     
-    //create new wms object
-    $updateWms = new wms();
-    $createObjFromXml = $updateWms->createObjFromXML($wmsToUpdate[$i]['wms_upload_url']);
-    if(!$createObjFromXml) {
-        $errorMsg = "Error while creating object from GetCapabilities XML";
-    }
-    //check scheduler_searchable attribute for layer searchable in class_wms.php
-    $updateWms->optimizeWMS($wmsToUpdate[$i]['scheduler_searchable']);
-    
-    //check overwrite attribute
-    if (!$wmsToUpdate[$i]['scheduler_overwrite']) {
-		$updateWms->overwrite=false;
-	}
-	
-	//check publish attribute for geoRss and twitter attribute in class_wms.php
-    if ($wmsToUpdate[$i]['scheduler_publish'] == 1) {
-        require_once dirname(__FILE__) . "/../http/classes/class_twitter.php";
-		$updateWms->twitterNews=true;
-		$updateWms->setGeoRss=true;
-	}
-	else {
-	    $updateWms->twitterNews=false;
-		$updateWms->setGeoRss=false;
-	}
-	
-    $updateObjInDb = $updateWms->updateObjInDB($wmsToUpdate[$i]['wms_id']);
-    if(!$updateObjInDb) {
-        $errorMsg = "Error while updating wms object in database";
-    }
-	
-	if($wmsToUpdate[$i]['scheduler_mail']) {
-	    $admin = new administration();
-		$ownerIds = $admin->getOwnerByWms($wmsToUpdate[$i]['wms_id']);
-		
-		if ($ownerIds && count($ownerIds) > 0) {
-			$ownerMailAddresses = array();
-			$j=0;
-			for ($k=0; $k<count($ownerIds); $k++) {
-				$adrTmp = $admin->getEmailByUserId($ownerIds[$k]);
-				if (!in_array($adrTmp, $ownerMailAddresses) && $adrTmp) {
-					$ownerMailAddresses[$j] = $adrTmp;
-					$j++;
-				} 
-			}
-			$adrRoot = $admin->getEmailByUserId("1");	
-			$from = $adrRoot;
-			if($from != "") {
-    			$body = "WMS '" . $admin->getWmsTitleByWmsId($wmsToUpdate[$i]['wms_id']) . "' has been updated by the scheduler update. \n\nYou may want to check the changes as you are an owner of this WMS.";
-    			$error_msg = "";
-    			for ($m=0; $m<count($ownerMailAddresses); $m++) {
-    				if (!$admin->sendEmail($from, $from, $ownerMailAddresses[$m], $ownerMailAddresses[$m], "[Mapbender Update Scheduler] One of your WMS has been updated", $body, $error)) {
-    					if ($error){
-    						$error_msg .= $error . " ";
-    					}
-    				}
-    			}
-			}
-		}
-	}
-	
-	if($errorMsg == "") {
-	    $status = 1;
-	}
-	else {
-	    $status = -1;
-	}
-	
-    $sql = <<<SQL
-UPDATE scheduler SET scheduler_status = $1, scheduler_status_error_message = $2 WHERE fkey_wms_id = $3;
-SQL;
-	$v = array($status, $errorMsg, $wmsToUpdate[$i]['wms_id']);
-	$t = array('i','s','i');
-	try {
-		$res = db_prep_query($sql,$v,$t);
-	}
-	catch (Exception $e){
-		echo "ERROR";
-	}
-}
-?>
\ No newline at end of file



More information about the Mapbender_commits mailing list