-
-
Save anzenehansen/7d9b2121c1bdde36ae01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AdminManagePlugin extends AppController { | |
public function preAction(){ | |
parent::preAction(); | |
// Require login | |
$this->requireLogin(); | |
$this->uses(array("Backup")); | |
$this->view->view = "default"; | |
$this->orig_structure_view = $this->structure->view; | |
$this->structure->view = "default"; | |
} | |
private function init(){ | |
$this->view->setView(null, "DatabaseManager.default"); | |
Loader::loadComponents($this, array("Record", "Input")); | |
$this->plugin_id = (isset($this->get[0]) ? $this->get[0] : null); | |
$this->vars = array('plugin_id' => $this->plugin_id); | |
} | |
public function index(){ | |
$this->init(); | |
$tables = $this->Record->query("SHOW TABLES")->fetchAll(); | |
$this->vars['res'] = $tables; | |
return $this->partial("admin_manage_plugin", $this->vars); | |
} | |
public function backup(){ | |
$this->init(); | |
if(!isset($this->Backup)){ | |
$this->vars['errors'] = $this->setMessage("error", "Backup component not loaded!", true, null, false); | |
return $this->partial("admin_manage_plugin", $this->vars); | |
} | |
$this->Backup->download(); | |
if($errors = $this->Backup->errors()){ | |
$this->vars['errors'] = $this->setMessage("error", $errors, true, null, false); | |
return $this->partial("admin_manage_plugin", $this->vars); | |
} | |
} | |
public function test(){ | |
$this->init(); | |
return $this->partial("admin_test"); | |
} | |
public function purge(){ | |
$this->init(); | |
$tables = $this->Record->query("SHOW TABLES")->fetchAll(); | |
foreach($tables as $index=>$tbl){ | |
$this->Record->drop($tbl->tables_in_blesta); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment