43 lines
835 B
PHP
43 lines
835 B
PHP
<?php
|
|
|
|
namespace Drone\Controller;
|
|
|
|
use \Cockpit\AuthController;
|
|
|
|
|
|
/**
|
|
* Settings controller class.
|
|
*/
|
|
class Settings extends AuthController {
|
|
|
|
/**
|
|
* Default index controller.
|
|
*/
|
|
public function index() {
|
|
if (!$this->app->module('cockpit')->hasaccess('drone', 'manage.settings')) {
|
|
return FALSE;
|
|
}
|
|
|
|
$drone = $this->app->storage->findOne('drone/settings');
|
|
|
|
return $this->render('drone:views/settings/index.php', compact('drone'));
|
|
}
|
|
|
|
public function save() {
|
|
if ($data = $this->param('drone', false)) {
|
|
|
|
$data['_modified'] = time();
|
|
|
|
if (!isset($data['_id'])) {
|
|
$data['_created'] = $data['_modified'];
|
|
}
|
|
|
|
$this->app->storage->save('drone/settings', $data);
|
|
|
|
return json_encode($data);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|