<?php

//////////////////////////////////////////////////////////////////////////////80
// Active Controller
//////////////////////////////////////////////////////////////////////////////80
// Copyright (c) 2020 Liam Siira (liam@siira.io), distributed as-is and without
// warranty under the MIT License. See [root]/license.md for more.
// This information must remain intact.
//////////////////////////////////////////////////////////////////////////////80
// Authors: Codiad Team, @Fluidbyte, Atheos Team, @hlsiira
//////////////////////////////////////////////////////////////////////////////80

require_once('class.active.php');

$path = POST("path");
$Active = new Active();

switch ($action) {
	//////////////////////////////////////////////////////////////////////////80
	// Add active record
	//////////////////////////////////////////////////////////////////////////80
	case "add":
		$Active->add($path);
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Check if file is active
	//////////////////////////////////////////////////////////////////////////80
	case "check":
		$Active->check($path);
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Get user's active files
	//////////////////////////////////////////////////////////////////////////80
	case "list":
		$Active->listActive();
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Rename
	//////////////////////////////////////////////////////////////////////////80
	case "rename":
		$newPath = POST("newPath");
		$Active->rename($path, $newPath);
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Remove active record
	//////////////////////////////////////////////////////////////////////////80
	case "remove":
		$Active->remove($path);
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Remove all active record
	//////////////////////////////////////////////////////////////////////////80
	case "removeall":
		$Active->removeAll();
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Mark file as focused
	//////////////////////////////////////////////////////////////////////////80
	case "setFocus":
		$Active->setFocus($path);
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Default: Invalid Action
	//////////////////////////////////////////////////////////////////////////80
	default:
		Common::send("error", "Invalid action.");
		break;
}