فهرست منبع

System update (better update)

markseu 9 سال پیش
والد
کامیت
c46f2f446b
2فایلهای تغییر یافته به همراه31 افزوده شده و 22 حذف شده
  1. 10 15
      system/plugins/core.php
  2. 21 7
      system/plugins/update.php

+ 10 - 15
system/plugins/core.php

@@ -2281,11 +2281,6 @@ class YellowLookup
 		return $fileName;
 	}
 	
-	function findFileNew($fileName, $fileNew, $pathBase, $nameDefault)
-	{
-		return $this->findFileFromConfig($fileName, $fileNew, $nameDefault); //TODO: Remove later
-	}
-	
 	// Return file path from title
 	function findFileFromTitle($titlePrefix, $titleText, $fileName, $fileDefault, $fileExtension)
 	{
@@ -2819,13 +2814,6 @@ class YellowToolbox
 		return $ok;
 	}
 	
-	// Set file modification date, Unix time
-	function modifyFile($fileName, $modified)
-	{
-		clearstatcache(true, $fileName);
-		return @touch($fileName, $modified);
-	}
-	
 	// Copy file
 	function copyFile($fileNameSource, $fileNameDest, $mkdir = false)
 	{
@@ -2896,10 +2884,11 @@ class YellowToolbox
 		return $ok;
 	}
 	
-	// Return file extension
-	function getFileExtension($fileName)
+	// Set file modification date, Unix time
+	function modifyFile($fileName, $modified)
 	{
-		return strtoloweru(($pos = strrposu($fileName, '.')) ? substru($fileName, $pos+1) : "");
+		clearstatcache(true, $fileName);
+		return @touch($fileName, $modified);
 	}
 	
 	// Return file modification date, Unix time
@@ -2908,6 +2897,12 @@ class YellowToolbox
 		return is_file($fileName) ? filemtime($fileName) : 0;
 	}
 	
+	// Return file extension
+	function getFileExtension($fileName)
+	{
+		return strtoloweru(($pos = strrposu($fileName, '.')) ? substru($fileName, $pos+1) : "");
+	}
+	
 	// Return lines from text string
 	function getTextLines($text)
 	{

+ 21 - 7
system/plugins/update.php

@@ -5,7 +5,7 @@
 // Update plugin
 class YellowUpdate
 {
-	const VERSION = "0.6.9";
+	const VERSION = "0.6.10";
 	var $yellow;					//access to API
 	
 	// Handle initialisation
@@ -75,11 +75,15 @@ class YellowUpdate
 	// Update pending software
 	function updateCommandPending($args)
 	{
-		$statusCode = $this->update();
-		if($statusCode!=0)
+		$statusCode = 0;
+		if($this->isSoftwarePending())
 		{
-			if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
-			echo "Yellow has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n";
+			$statusCode = $this->update();
+			if($statusCode!=0)
+			{
+				if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
+				echo "Yellow has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n";
+			}
 		}
 		return $statusCode;
 	}
@@ -265,7 +269,7 @@ class YellowUpdate
 	function processRequestPending($serverScheme, $serverName, $base, $location, $fileName)
 	{
 		$statusCode = 0;
-		if($this->isContentFile($fileName))
+		if($this->isContentFile($fileName) && $this->isSoftwarePending())
 		{
 			$statusCode = $this->update();
 			if($statusCode==200)
@@ -282,7 +286,7 @@ class YellowUpdate
 	function processRequestInstallation($serverScheme, $serverName, $base, $location, $fileName)
 	{
 		$statusCode = 0;
-		if($this->isContentFile($fileName))
+		if($this->isContentFile($fileName) && $this->isInstallation())
 		{
 			$this->yellow->pages->pages["root/"] = array();
 			$this->yellow->page = new YellowPage($this->yellow);
@@ -516,6 +520,16 @@ class YellowUpdate
 		return !is_null($data[$software]);
 	}
 	
+	// Check if pending software exists
+	function isSoftwarePending()
+	{
+		$path = $this->yellow->config->get("pluginDir");
+		$foundPlugins = count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false))>0;
+		$path = $this->yellow->config->get("themeDir");
+		$foundThemes = count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false))>0;
+		return $foundPlugins || $foundThemes;
+	}
+	
 	// Check if installation requested
 	function isInstallation()
 	{