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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jul 9 08:05:23 PDT 2012


Author: armin11
Date: 2012-07-09 08:05:22 -0700 (Mon, 09 Jul 2012)
New Revision: 8442

Modified:
   trunk/mapbender/tools/mod_runScheduler.php
Log:
Error messages

Modified: trunk/mapbender/tools/mod_runScheduler.php
===================================================================
--- trunk/mapbender/tools/mod_runScheduler.php	2012-07-09 15:05:05 UTC (rev 8441)
+++ trunk/mapbender/tools/mod_runScheduler.php	2012-07-09 15:05:22 UTC (rev 8442)
@@ -15,91 +15,98 @@
 //$resultObj = array();
 //array containing all wms which should be updated
 $wmsToUpdate = array();
-
+echo "Scheduler for WMS start work...\n";
 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'],
+	    	"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'],
+	   	"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']
+	   	"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']));
+    	//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);
-        }
-    }
+    	//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 debugging purpose:
+/*for ($i=0; $i<count($wmsToUpdate); $i++) {
+	echo "wms_id: ".$wmsToUpdate[$i]['wms_id']."\n";
+}
 
+die();
+*/
 for ($i=0; $i<count($wmsToUpdate); $i++) {
-    #echo "WMS ID = ".$wmsToUpdate[$i]['wms_id']."\n";
-    #echo "WMS URL = ".$wmsToUpdate[$i]['wms_upload_url']."\n";
+    	#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']);
+    	//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']) {
+    	//check overwrite attribute
+    	if (!$wmsToUpdate[$i]['scheduler_overwrite']) {
+		echo "overwrite md = false\n";
 		$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";
+    	if ($wmsToUpdate[$i]['scheduler_publish'] == 1) {
+        	require_once dirname(__FILE__) . "/../http/classes/class_twitter.php";
 		$updateWms->twitterNews=true;
 		$updateWms->setGeoRss=true;
+		echo "publish = true\n";
 	}
 	else {
-	    $updateWms->twitterNews=false;
+	    	$updateWms->twitterNews=false;
 		$updateWms->setGeoRss=false;
+		echo "publish = false\n";
 	}
 	
-    $updateObjInDb = $updateWms->updateObjInDB($wmsToUpdate[$i]['wms_id']);
-    if(!$updateObjInDb) {
-        $errorMsg = "Error while updating wms object in database";
-    }
+   	$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();
+	    	$admin = new administration();
+		//get all users which have the wms integrated in their guis!
 		$ownerIds = $admin->getOwnerByWms($wmsToUpdate[$i]['wms_id']);
-		
 		if ($ownerIds && count($ownerIds) > 0) {
 			$ownerMailAddresses = array();
 			$j=0;
@@ -113,15 +120,16 @@
 			$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 . " ";
+    				$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++) {
+					echo $ownerMailAddresses[$m]."\n";
+    					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 . " ";
+    						}
     					}
     				}
-    			}
 			}
 		}
 	}
@@ -145,4 +153,4 @@
 		echo "ERROR";
 	}
 }
-?>
\ No newline at end of file
+?>



More information about the Mapbender_commits mailing list