WIP Address BMD Export

This commit is contained in:
Frank Schubert
2024-01-05 13:56:02 +01:00
parent 60f0461f79
commit 7646345779
11 changed files with 308 additions and 9 deletions

View File

@@ -0,0 +1,67 @@
<?php
class SystemController extends mfBaseController {
protected function init($reqeust) {
$me = new User();
$me->loadMe();
$this->layout()->set("me",$me);
$this->me = $me;
if(!$me->isAdmin()) {
// all users can call non-action methods
if($this->action != "" || $request != null) {
$this->redirect("Dashboard");
}
}
}
protected function indexAction() {
if(!$this->me->isAdmin()) {
$this->redirect("Dashboard");
}
$this->layout()->setTemplate("System/System");
}
protected function saveAction($request) {
if(!$this->me->isAdmin()) {
$this->redirect("Dashboard");
}
foreach($request as $name => $value) {
$m = [];
if(!preg_match('/^system_(.+)$/',$name,$m)) {
continue;
}
$name = str_replace("_", ".", $m[1]);
$config = new mfConfig($name);
$config->value($value);
$config->save();
}
$this->redirect("System");
}
public function getLastCommit() {
$git_path = BASEDIR."/.git";
$output = [];
if(defined("GIT_BIN_PATH") && GIT_BIN_PATH) {
$git = GIT_BIN_PATH;
} else {
$git = "/usr/bin/git";
}
$cmd = "$git --git-dir $git_path rev-parse HEAD";
if(!exec($cmd, $output)) {
$log = mfLoghandler::singleton();
$log->warn("Cannot read git ref!");
}
$ref = $output[0];
if(strlen($output[0]) > 8) {
$ref = substr($output[0], 0, 8);
}
return $ref;
}
}