Browse Source

added checkForPluginUpdate to default config file
added checkForPluginUpdate setting to marketplace settings
added checkPluginUpdates function to functions js file

CauseFX 4 years ago
parent
commit
4055322bd1
3 changed files with 30 additions and 1 deletions
  1. 1 0
      api/classes/organizr.class.php
  2. 2 1
      api/config/default.php
  3. 27 0
      js/functions.js

+ 1 - 0
api/classes/organizr.class.php

@@ -1653,6 +1653,7 @@ class Organizr
 			'Marketplace' => [
 				$this->settingsOption('notice', null, ['notice' => 'danger', 'body' => '3rd Party Repositories are not affiliated with Organizr and therefore the code on these repositories are not inspected.  Use at your own risk.']),
 				$this->settingsOption('multiple-url', 'externalPluginMarketplaceRepos', ['override' => 12, 'label' => 'External Marketplace Repo', 'help' => 'Only supports Github repos']),
+				$this->settingsOption('switch', 'checkForPluginUpdate', ['label' => 'Check for Plugin Updates', ['help' => 'Check for updates on page load']])
 			]
 		];
 	}

+ 2 - 1
api/config/default.php

@@ -617,5 +617,6 @@ return [
 	'logLiveUpdateRefresh' => '5000',
 	'logPageSize' => '50',
 	'includeDatabaseQueriesInDebug' => false,
-	'externalPluginMarketplaceRepos' => ''
+	'externalPluginMarketplaceRepos' => '',
+	'checkForPluginUpdate' => true
 ];

+ 27 - 0
js/functions.js

@@ -3770,6 +3770,32 @@ function newsLoad(){
 	    OrganizrApiError(xhr);
     });
 }
+function checkPluginUpdates(){
+	if(!activeInfo.user.loggedin || activeInfo.user.groupID > 1){
+		return false;
+	}
+	organizrAPI2('get','api/v2/plugins/marketplace').success(function(data) {
+		try {
+			let update = false;
+			let pluginsNeedingUpdate = [];
+			let plugins = data.response.data;
+			$.each(plugins, function(i,v) {
+				if(v.needs_update){
+					update = true;
+					pluginsNeedingUpdate.push(i);
+				}
+			});
+			if(update){
+				pluginsNeedingUpdate = '[' + pluginsNeedingUpdate.join(', ') + ']';
+				messageSingle(window.lang.translate('Update Available'), 'The following plugin(s) need updates: ' + pluginsNeedingUpdate, activeInfo.settings.notifications.position, '#FFF', 'update', '600000');
+			}
+		}catch(e) {
+			organizrCatchError(e,data);
+		}
+	}).fail(function(xhr) {
+		OrganizrApiError(xhr, 'News');
+	});
+}
 function checkCommitLoad(){
     if(activeInfo.settings.misc.docker && activeInfo.settings.misc.githubCommit !== 'n/a' && activeInfo.settings.misc.githubCommit !== null) {
 	    if(checkCommitLoadStatus == false) {
@@ -11266,6 +11292,7 @@ function checkForUpdates(){
 	if(activeInfo.user.loggedin && activeInfo.user.groupID <= 1){
 		updateCheck();
 		checkCommitLoad();
+		checkPluginUpdates();
 	}
 }