Przeglądaj źródła

WIP - do not update yet!
Added new globals - theme installed - theme version - installed plugins - root directory
New plugin functions for marketplace - WIP
New download function for marketplace
About plugin section
New API endpoint - v1/plugin/install
plugin marketplace js work

causefx 7 lat temu
rodzic
commit
215668ef06

+ 4 - 1
api/config/default.php

@@ -167,5 +167,8 @@ return array(
 	'lockoutSystem' => false,
 	'lockoutTimeout' => '60',
 	'lockoutMaxAuth' => '0',
-	'lockoutMinAuth' => '1'
+	'lockoutMinAuth' => '1',
+	'themeInstalled' => '',
+	'themeVersion' => '',
+	'installedPlugins' => ''
 );

+ 2 - 0
api/functions.php

@@ -7,6 +7,8 @@ require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'a
 foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . '*.php') as $filename) {
 	require_once $filename;
 }
+// Set Root Directory
+$GLOBALS['root'] = dirname(__DIR__, 1);
 // Add in default and custom settings
 configLazy();
 // Define Logs and files after db location is set

+ 3 - 0
api/functions/organizr-functions.php

@@ -64,6 +64,9 @@ function organizrSpecialSettings()
 			'agent' => isset($_SERVER ['HTTP_USER_AGENT']) ? $_SERVER ['HTTP_USER_AGENT'] : null
 		),
 		'misc' => array(
+			'installedPlugins' => $GLOBALS['installedPlugins'],
+			'themeInstalled' => $GLOBALS['themeInstalled'],
+			'themeVersion' => $GLOBALS['themeVersion'],
 			'return' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false,
 		)
 	);

+ 27 - 0
api/functions/plugin-functions.php

@@ -0,0 +1,27 @@
+<?php
+function installPlugin($plugin)
+{
+	//$array['data']['action']
+	/*
+	 *
+	 * if (downloadFileToPath($from, $to, $path)) {
+                writeLog('success', 'Update Function -  Downloaded Update File for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
+                return true;
+            } else {
+                writeLog('error', 'Update Function -  Downloaded Update File Failed  for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
+                return false;
+            }
+	 */
+	foreach ($plugin['data']['plugin']['downloadList'] as $k => $v) {
+		$file = array(
+			'from' => $v['githubPath'],
+			'to' => str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['root'] . $v['path'] . $v['fileName']),
+			'path' => str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['root'] . $v['path'])
+		);
+		if (!downloadFileToPath($file['from'], $file['to'], $file['path'])) {
+			writeLog('error', 'Update Function -  Downloaded File Failed  for: ' . $v['githubPath'], $GLOBALS['organizrUser']['username']);
+			return false;
+		}
+	}
+	return true;
+}

+ 160 - 126
api/functions/update-functions.php

@@ -1,146 +1,180 @@
 <?php
-
 // Upgrade the installation
 function upgradeInstall($branch = 'v2-master', $stage)
 {
-    ini_set('max_execution_time', 0);
-    set_time_limit(0);
-    $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
-    $file = "upgrade.zip";
-    $source = dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'upgrade'.DIRECTORY_SEPARATOR.'Organizr-'.str_replace('v2', '2', $branch).DIRECTORY_SEPARATOR;
-    $cleanup = dirname(__DIR__, 2) .DIRECTORY_SEPARATOR."upgrade".DIRECTORY_SEPARATOR;
-    $destination = dirname(__DIR__, 2).DIRECTORY_SEPARATOR;
-    switch ($stage) {
-        case '1':
-            writeLog('success', 'Update Function -  Started Upgrade Process', $GLOBALS['organizrUser']['username']);
-            if (downloadFile($url, $file)) {
-                writeLog('success', 'Update Function -  Downloaded Update File for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return true;
-            } else {
-                writeLog('error', 'Update Function -  Downloaded Update File Failed  for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return false;
-            }
-            break;
-        case '2':
-            if (unzipFile($file)) {
-                writeLog('success', 'Update Function -  Unzipped Update File for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return true;
-            } else {
-                writeLog('error', 'Update Function -  Unzip Failed for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return false;
-            }
-            break;
-        case '3':
-            if (rcopy($source, $destination)) {
-                writeLog('success', 'Update Function -  Overwrited Files using Updated Files from Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return true;
-            } else {
-                writeLog('error', 'Update Function -  Overwrite Failed for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return false;
-            }
-            break;
-        case '4':
-            if (rrmdir($cleanup)) {
-                writeLog('success', 'Update Function -  Deleted Update Files from Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                writeLog('success', 'Update Function -  Update Completed', $GLOBALS['organizrUser']['username']);
-                return true;
-            } else {
-                writeLog('error', 'Update Function -  Removal of Update Files Failed for Branch: '.$branch, $GLOBALS['organizrUser']['username']);
-                return false;
-            }
-            break;
-        default:
-            return false;
-            break;
-    }
-    return false;
+	ini_set('max_execution_time', 0);
+	set_time_limit(0);
+	$url = 'https://github.com/causefx/Organizr/archive/' . $branch . '.zip';
+	$file = "upgrade.zip";
+	$source = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . 'Organizr-' . str_replace('v2', '2', $branch) . DIRECTORY_SEPARATOR;
+	$cleanup = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . "upgrade" . DIRECTORY_SEPARATOR;
+	$destination = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR;
+	switch ($stage) {
+		case '1':
+			writeLog('success', 'Update Function -  Started Upgrade Process', $GLOBALS['organizrUser']['username']);
+			if (downloadFile($url, $file)) {
+				writeLog('success', 'Update Function -  Downloaded Update File for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return true;
+			} else {
+				writeLog('error', 'Update Function -  Downloaded Update File Failed  for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return false;
+			}
+			break;
+		case '2':
+			if (unzipFile($file)) {
+				writeLog('success', 'Update Function -  Unzipped Update File for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return true;
+			} else {
+				writeLog('error', 'Update Function -  Unzip Failed for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return false;
+			}
+			break;
+		case '3':
+			if (rcopy($source, $destination)) {
+				writeLog('success', 'Update Function -  Overwrited Files using Updated Files from Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return true;
+			} else {
+				writeLog('error', 'Update Function -  Overwrite Failed for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return false;
+			}
+			break;
+		case '4':
+			if (rrmdir($cleanup)) {
+				writeLog('success', 'Update Function -  Deleted Update Files from Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				writeLog('success', 'Update Function -  Update Completed', $GLOBALS['organizrUser']['username']);
+				return true;
+			} else {
+				writeLog('error', 'Update Function -  Removal of Update Files Failed for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				return false;
+			}
+			break;
+		default:
+			return false;
+			break;
+	}
+	return false;
 }
+
 function downloadFile($url, $path)
 {
-    ini_set('max_execution_time', 0);
-    set_time_limit(0);
-    $folderPath = dirname(__DIR__, 2).DIRECTORY_SEPARATOR."upgrade".DIRECTORY_SEPARATOR;
-    if (!mkdir($folderPath)) {
-        //writeLog("error", "organizr could not create upgrade folder");
-    }
-    $newfname = $folderPath . $path;
-    $file = fopen($url, 'rb');
-    if ($file) {
-        $newf = fopen($newfname, 'wb');
-        if ($newf) {
-            while (!feof($file)) {
-                fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
-            }
-        }
-    } else {
-        //writeLog("error", "organizr could not download $url");
-    }
-
-    if ($file) {
-        fclose($file);
-    //writeLog("success", "organizr finished downloading the github zip file");
-    } else {
-        //writeLog("error", "organizr could not download the github zip file");
-    }
+	ini_set('max_execution_time', 0);
+	set_time_limit(0);
+	$folderPath = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . "upgrade" . DIRECTORY_SEPARATOR;
+	if (!mkdir($folderPath)) {
+		//writeLog("error", "organizr could not create upgrade folder");
+	}
+	$newfname = $folderPath . $path;
+	$file = fopen($url, 'rb');
+	if ($file) {
+		$newf = fopen($newfname, 'wb');
+		if ($newf) {
+			while (!feof($file)) {
+				fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
+			}
+		}
+	} else {
+		//writeLog("error", "organizr could not download $url");
+	}
+	if ($file) {
+		fclose($file);
+		//writeLog("success", "organizr finished downloading the github zip file");
+	} else {
+		//writeLog("error", "organizr could not download the github zip file");
+	}
+	if ($newf) {
+		fclose($newf);
+		//writeLog("success", "organizr created upgrade zip file from github zip file");
+	} else {
+		//writeLog("error", "organizr could not create upgrade zip file from github zip file");
+	}
+	return true;
+}
 
-    if ($newf) {
-        fclose($newf);
-    //writeLog("success", "organizr created upgrade zip file from github zip file");
-    } else {
-        //writeLog("error", "organizr could not create upgrade zip file from github zip file");
-    }
-    return true;
+function downloadFileToPath($from, $to, $path)
+{
+	ini_set('max_execution_time', 0);
+	set_time_limit(0);
+	if (@!mkdir($path)) {
+		//writeLog("error", "organizr could not create upgrade folder");
+	}
+	$file = fopen($from, 'rb');
+	if ($file) {
+		$newf = fopen($to, 'wb');
+		if ($newf) {
+			while (!feof($file)) {
+				fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
+			}
+		}
+	} else {
+		//writeLog("error", "organizr could not download $url");
+	}
+	if ($file) {
+		fclose($file);
+		//writeLog("success", "organizr finished downloading the github zip file");
+	} else {
+		//writeLog("error", "organizr could not download the github zip file");
+	}
+	if ($newf) {
+		fclose($newf);
+		//writeLog("success", "organizr created upgrade zip file from github zip file");
+	} else {
+		//writeLog("error", "organizr could not create upgrade zip file from github zip file");
+	}
+	return true;
 }
+
 function unzipFile($zipFile)
 {
-    ini_set('max_execution_time', 0);
-    set_time_limit(0);
-    $zip = new ZipArchive;
-    $extractPath = dirname(__DIR__, 2).DIRECTORY_SEPARATOR."upgrade/";
-    if ($zip->open($extractPath . $zipFile) != "true") {
-        //writeLog("error", "organizr could not unzip upgrade.zip");
-    } else {
-        //writeLog("success", "organizr unzipped upgrade.zip");
-    }
-    /* Extract Zip File */
-    $zip->extractTo($extractPath);
-    $zip->close();
-    return true;
+	ini_set('max_execution_time', 0);
+	set_time_limit(0);
+	$zip = new ZipArchive;
+	$extractPath = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . "upgrade/";
+	if ($zip->open($extractPath . $zipFile) != "true") {
+		//writeLog("error", "organizr could not unzip upgrade.zip");
+	} else {
+		//writeLog("success", "organizr unzipped upgrade.zip");
+	}
+	/* Extract Zip File */
+	$zip->extractTo($extractPath);
+	$zip->close();
+	return true;
 }
+
 // Function to remove folders and files
 function rrmdir($dir)
 {
-    ini_set('max_execution_time', 0);
-    set_time_limit(0);
-    if (is_dir($dir)) {
-        $files = scandir($dir);
-        foreach ($files as $file) {
-            if ($file != "." && $file != "..") {
-                rrmdir("$dir/$file");
-            }
-        }
-        rmdir($dir);
-    } elseif (file_exists($dir)) {
-        unlink($dir);
-    }
-    return true;
+	ini_set('max_execution_time', 0);
+	set_time_limit(0);
+	if (is_dir($dir)) {
+		$files = scandir($dir);
+		foreach ($files as $file) {
+			if ($file != "." && $file != "..") {
+				rrmdir("$dir/$file");
+			}
+		}
+		rmdir($dir);
+	} elseif (file_exists($dir)) {
+		unlink($dir);
+	}
+	return true;
 }
+
 // Function to Copy folders and files
 function rcopy($src, $dst)
 {
-    ini_set('max_execution_time', 0);
-    set_time_limit(0);
-    if (is_dir($src)) {
-        if (!file_exists($dst)) : mkdir($dst);
-        endif;
-        $files = scandir($src);
-        foreach ($files as $file) {
-            if ($file != "." && $file != "..") {
-                rcopy("$src/$file", "$dst/$file");
-            }
-        }
-    } elseif (file_exists($src)) {
-        copy($src, $dst);
-    }
-    return true;
+	ini_set('max_execution_time', 0);
+	set_time_limit(0);
+	if (is_dir($src)) {
+		if (!file_exists($dst)) : mkdir($dst);
+		endif;
+		$files = scandir($src);
+		foreach ($files as $file) {
+			if ($file != "." && $file != "..") {
+				rcopy("$src/$file", "$dst/$file");
+			}
+		}
+	} elseif (file_exists($src)) {
+		copy($src, $dst);
+	}
+	return true;
 }

+ 19 - 0
api/index.php

@@ -897,6 +897,25 @@ switch ($function) {
 				break;
 		}
 		break;
+	case 'v1_plugin_install':
+		switch ($method) {
+			case 'POST':
+				if (qualifyRequest(1)) {
+					$result['status'] = 'success';
+					$result['statusText'] = 'success';
+					$result['data'] = installPlugin($_POST);
+				} else {
+					$result['status'] = 'error';
+					$result['statusText'] = 'API/Token invalid or not set';
+					$result['data'] = null;
+				}
+				break;
+			default:
+				$result['status'] = 'error';
+				$result['statusText'] = 'The function requested is not defined for method: ' . $method;
+				break;
+		}
+		break;
 	case 'v1_user_edit':
 		switch ($method) {
 			case 'POST':

+ 8 - 2
api/pages/settings-plugins.php

@@ -1,9 +1,15 @@
 <?php
-if(file_exists('config'.DIRECTORY_SEPARATOR.'config.php')){
-$pageSettingsPlugins = '
+if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
+	$pageSettingsPlugins = '
 <script>
 	buildPlugins();
 </script>
+<script src="plugins/bower_components/bootstrap-treeview-master/dist/bootstrap-treeview.min.js"></script>
 <div id="main-plugin-area"></div>
+<form id="about-plugin-form" class="mfp-hide white-popup-block mfp-with-anim">
+    <h2 id="about-plugin-title">Loading...</h2>
+    <div class="clearfix"></div>
+    <div id="about-plugin-body" class=""></div>
+</form>
 ';
 }

+ 284 - 0
js/functions.js

@@ -721,6 +721,8 @@ function buildPluginsItem(array){
 		</li>
 		<li onclick="changeSettingsMenu('Settings::Plugins::Inactive')" role="presentation" class=""><a href="#settings-plugins-inactive" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="false"><span class="visible-xs"><i class="ti-layout-list-thumb"></i></span><span class="hidden-xs" lang="en">Inactive</span></a>
 		</li>
+		<li onclick="changeSettingsMenu('Settings::Plugins::Marketplace');loadMarketplace('plugins');" role="presentation" class=""><a href="#settings-plugins-marketplace" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="false"><span class="visible-xs"><i class="ti-layout-list-thumb"></i></span><span class="hidden-xs" lang="en">Marketplace</span></a>
+		</li>
 	</ul>
 	<!-- Tab panes -->
 	<div class="tab-content">
@@ -749,12 +751,288 @@ function buildPluginsItem(array){
 				</div>
 			</div>
 		</div>
+		<div role="tabpanel" class="tab-pane fade" id="settings-plugins-marketplace">
+			<div class="panel bg-org panel-info">
+				<div class="panel-heading">
+					<span lang="en">Plugin Marketplace</span>
+				</div>
+				<div class="panel-wrapper collapse in" aria-expanded="true">
+					<div class="table-responsive">
+                        <table class="table table-hover manage-u-table">
+                            <thead>
+                                <tr>
+                                    <th width="70" class="text-center" lang="en">PLUGIN</th>
+                                    <th></th>
+                                    <th lang="en">CATEGORY</th>
+                                    <th lang="en">STATUS</th>
+                                    <th lang="en" style="text-align:center">INFO</th>
+                                    <th lang="en" style="text-align:center">INSTALL</th>
+                                    <th lang="en" style="text-align:center">DELETE</th>
+                                </tr>
+                            </thead>
+                            <tbody id="managePluginTable"></tbody>
+                        </table>
+                    </div>
+				</div>
+			</div>
+		</div>
 	</div>
 
 	`;
 
 	return panes;
 }
+function loadMarketplace(type){
+    marketplaceJSON(type).success(function(data) {
+        var json = JSON.parse(data);
+        switch (type) {
+            case 'plugins':
+                loadMarketplacePluginsItems(json);
+                break;
+            case 'themes':
+                loadMarketplaceThemesItems(json);
+                break;
+            default:
+        }
+        console.log(json);
+    }).fail(function(xhr) {
+        console.error("Organizr Function: Github Connection Failed");
+    });
+}
+function loadMarketplacePluginsItems(plugins){
+    var pluginList = '';
+    $.each(plugins, function(i,v) {
+        if(v.icon == null || v.icon == ''){ v.icon = 'test.png'; }
+        v.status = pluginStatus(i,v.version);
+        var installButton = (v.status == 'Update Available') ? 'fa fa-download' : 'fa fa-plus';
+        var removeButton = (v.status == 'Not Installed') ? 'disabled' : '';
+        v.name = i;
+        pluginList += `
+            <tr class="pluginManagement" data-name="`+i+`" data-version="`+v.version+`">
+                <td class="text-center el-element-overlay">
+                    <div class="el-card-item p-0">
+                        <div class="el-card-avatar el-overlay-1 m-0">
+                            <img alt="user-img" src="`+v.icon+`" width="45">
+                        </div>
+                    </div>
+                </td>
+                <td>`+i+`
+                    <br><span class="text-muted">`+v.version+`</span></td>
+                <td>`+v.category+`</td>
+                <td>`+v.status+`</td>
+                <td style="text-align:center"><button type="button" onclick='aboutPlugin(`+JSON.stringify(v)+`);' class="btn btn-success btn-outline btn-circle btn-lg popup-with-form" href="#about-plugin-form" data-effect="mfp-3d-unfold"><i class="fa fa-info"></i></button></td>
+                <td style="text-align:center"><button type="button" onclick='installPlugin(`+JSON.stringify(v)+`);' class="btn btn-info btn-outline btn-circle btn-lg"><i class="`+installButton+`"></i></button></td>
+                <td style="text-align:center"><button type="button" onclick='removePlugin(`+JSON.stringify(v)+`);' class="btn btn-danger btn-outline btn-circle btn-lg" `+removeButton+`><i class="fa fa-trash"></i></button></td>
+            </tr>
+        `;
+
+    });
+    $('#managePluginTable').html(pluginList);
+}
+function aboutPluginImages(images){
+    var imageList = '';
+    if(Object.keys(images).length !== 0){
+        var imageCount = 0;
+        $.each(images, function(i,v) {
+            imageCount++;
+            var active = (imageCount == 1) ? 'active' : '';
+            imageList += `
+            <div class="`+active+` item">
+                <div class="overlaybg"><img src="`+v+`" /></div>
+                <div class="news-content"><span class="label label-info label-rounded">`+i+`</span></div>
+            </div>
+            `;
+        });
+    }else{
+        imageList += `
+            <div class="active item">
+                <div class="overlaybg"><img src="https://via.placeholder.com/350x150" /></div>
+            </div>
+        `;
+    }
+    return imageList;
+}
+function aboutPluginFiles(fileList){
+    var files = [];
+    $.each(fileList, function(i,v) {
+        var splitFiles = v.split('|');
+        var formattedSplit = [];
+        $.each(splitFiles, function(i,v) {
+            var arrayFilePush = {
+                "text": v
+            };
+            formattedSplit.push(arrayFilePush);
+        });
+        var arrayPush = {
+            "text": i,
+            "nodes": formattedSplit,
+        };
+        files.push(arrayPush);
+    });
+    return files;
+}
+function pluginFileList(fileList,folder){
+    var files = [];
+    $.each(fileList, function(i,v) {
+        var splitFiles = v.split('|');
+        var formattedSplit = [];
+        var prePath = (i.length !== 1) ? i+'/' : i;
+        $.each(splitFiles, function(i,v) {
+            var arrayPush = {
+                "fileName": v,
+                "path": prePath,
+                "githubPath": 'https://raw.githubusercontent.com/causefx/Organizr/v2-plugins/'+folder+prePath+v,
+            };
+            files.push(arrayPush);
+        });
+    });
+    return files;
+}
+function aboutPlugin(plugin){
+    var files = aboutPluginFiles(plugin.files);
+    var imageList = aboutPluginImages(plugin.images);
+    var homepageLink = (plugin.website !== '' || plugin.website !== null) ? 'onclick="window.open(\''+plugin.website+'\',\'_blank\');"' : ' ';
+
+    var infoBox = `
+    <div class="row">
+        <div class="col-lg-6 col-sm-12 col-xs-12">
+            <div class="row">
+                <div class="col-lg-12 col-sm-12 col-xs-12">
+                    <div class="white-box p-10" id="aboutPluginScroll">
+                        `+plugin.description+`
+                    </div>
+                </div>
+                <div class="clearfix">&nbsp;</div>
+                <div class="col-lg-4 col-sm-4 col-xs-12">
+                    <div class="white-box mouse">
+                        <ul class="list-inline two-part text-center m-b-0">
+                            <li><i class="icon-envelope-open text-info"></i></li>
+                        </ul>
+                    </div>
+                </div>
+                <div class="col-lg-4 col-sm-4 col-xs-12">
+                    <div class="white-box mouse" `+homepageLink+`>
+                        <ul class="list-inline two-part text-center m-b-0">
+                            <li><i class="icon-home text-danger"></i></li>
+                        </ul>
+                    </div>
+                </div>
+                <div class="col-lg-4 col-sm-4 col-xs-12">
+                    <div class="white-box mouse" onclick="$('.pluginFileList').toggleClass('hidden');">
+                        <ul class="list-inline two-part text-center m-b-0">
+                            <li><i class="icon-folder text-purple"></i></li>
+                        </ul>
+                    </div>
+                </div>
+                <div class="col-sm-12 col-xs-12 pluginFileList hidden">
+                    <div id="treeview5" class=""></div>
+                </div>
+            </div>
+        </div>
+        <div class="col-lg-6 col-sm-12 col-xs-12">
+            <div class="news-slide m-b-15">
+                <div class="vcarousel slide">
+                    <!-- Carousel items -->
+                    <div class="carousel-inner">
+                        `+imageList+`
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>`;
+    $('#about-plugin-title').html(plugin.name+'&nbsp;<small>'+plugin.version+'</small>');
+    $('#about-plugin-body').html(infoBox);
+    $('.vcarousel').carousel({
+        interval: 3000
+    });
+    $('#treeview5').treeview({
+        levels: 1,
+        expandIcon: 'ti-angle-right',
+        onhoverColor: "rgba(0, 0, 0, 0.05)",
+        selectedBackColor: "#03a9f3",
+        collapseIcon: 'ti-angle-down',
+        data: JSON.stringify(files)
+    });
+    $('#aboutPluginScroll').slimScroll({
+        height: '225px'
+    });
+}
+function installPlugin(plugin=null){
+    if(plugin == null){
+        return false;
+    }
+    console.log(plugin);
+    var installedPluginsList = [];
+    var installedPlugins = [];
+    if(activeInfo.settings.misc.installedPlugins !== ''){
+        installedPlugins = activeInfo.settings.misc.installedPlugins.split("|");
+        $.each(installedPlugins, function(i,v) {
+            var plugin = v.split(":");
+            installedPluginsList[plugin[0]] = plugin[1];
+        });
+        if(typeof installedPluginsList[plugin.name] !== 'undefined'){
+            console.log(plugin.version);
+            installedPluginsList[plugin.name] = plugin.version;
+            activeInfo.settings.misc.installedPlugins = installedPlugins.toString().replace(/,/g , "|");
+        }else{
+            activeInfo.settings.misc.installedPlugins = activeInfo.settings.misc.installedPlugins + '|' + plugin.name + ':' + plugin.version;
+        }
+    }else{
+        activeInfo.settings.misc.installedPlugins = plugin.name + ':' + plugin.version;
+    }
+    //loadMarketplace('plugins');
+
+    plugin.downloadList = pluginFileList(plugin.files,plugin.github_folder);
+    organizrAPI('POST','api/?v1/plugin/install',{plugin:plugin}).success(function(data) {
+        var html = JSON.parse(data);
+        console.log(html);
+        /*if(html.data == true){
+            message('Path',' Path is good to go',activeInfo.settings.notifications.position,'#FFF','success','10000');
+        }else{
+            message('Path Error',' Path is not writable',activeInfo.settings.notifications.position,'#FFF','warning','10000');
+        }*/
+        message('Plugin Installed',plugin.name,activeInfo.settings.notifications.position,"#FFF","success","5000");
+    }).fail(function(xhr) {
+        console.error("Organizr Function: Connection Failed");
+    });
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+function pluginStatus(name=null,version=null){
+    var installedPlugins = [];
+    var installedPluginsList = [];
+    if(activeInfo.settings.misc.installedPlugins !== ''){
+        installedPlugins = activeInfo.settings.misc.installedPlugins.split("|");
+        $.each(installedPlugins, function(i,v) {
+            var plugin = v.split(":");
+            installedPluginsList[plugin[0]] = plugin[1];
+        });
+        if(typeof installedPluginsList[name] !== 'undefined'){
+            if(version !== installedPluginsList[name]){
+                return 'Update Available';
+            }else{
+                return 'Up to date';
+            }
+        }else{
+            return 'Not Installed';
+        }
+    }else{
+        return 'Not Installed';
+    }
+}
 function buildHomepageItem(array){
 	var listing = '';
 	if (Array.isArray(array)) {
@@ -1416,6 +1694,7 @@ function buildTabTypeSelect(tabID, typeID){
 		}
 		typeSelect += '<option '+selected+' value="'+v.type_id+'">'+v.type+'</option>';
 	});
+	console.log(tabID);
 	return '<td><select name="tab['+tabID+'].type" class="form-control tabTypeSelect">'+typeSelect+'</select></td>';
 }
 function buildTabCategorySelect(array,tabID, categoryID){
@@ -1895,6 +2174,11 @@ function githubVersions() {
 		url: "https://raw.githubusercontent.com/causefx/Organizr/"+activeInfo.branch+"/js/version.json",
 	});
 }
+function marketplaceJSON(type) {
+    return $.ajax({
+        url: "https://raw.githubusercontent.com/causefx/Organizr/v2-"+type+"/"+type+".json",
+    });
+}
 function allIcons() {
     return $.ajax({
         url: "/js/icons.json",