public function active_snapins_post() { if (isset($_REQUEST['rmid'])) { // Get the snapin task. $SnapinTask = new SnapinTask($_REQUEST['rmid']); // Get the job associated with the task. $SnapinJob = new SnapinJob($SnapinTask->get('jobID')); // Get the referenced host. $Host = new Host($SnapinJob->get('hostID')); // Get the active task. $Task = current($this->getClass('TaskManager')->find(array('hostID' => $Host->get('id'), 'stateID' => array(1, 2, 3)))); // Check the Jobs to Snapin tasks to verify if this is the only one. $SnapinJobManager = $this->getClass('SnapinTaskManager')->find(array('jobID' => $SnapinJob->get('id'))); // This task is the last task, destroy the job and the task if (count($SnapinJobManager) <= 1) { $SnapinJob->destroy(); if ($Task) { $Task->cancel(); } } // Destroy the individual task. $SnapinTask->destroy(); // Redirect to the current page. $this->FOGCore->redirect("?node=" . $this->node . "&sub=active-snapins"); } }