Skip to content

Commit 7dae2ac

Browse files
committed
Merge branch 'classify_master' of https://github.com/jacobsen9026/AD-Accounts-Manager
2 parents fc4f96b + 05d1a9e commit 7dae2ac

File tree

13 files changed

+229
-65
lines changed

13 files changed

+229
-65
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controllers/Update.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
4+
namespace app\controllers;
5+
6+
7+
use App\App\AppUpdater;
8+
use System\Post;
9+
10+
class Update extends Controller
11+
{
12+
13+
public function indexPost()
14+
{
15+
$csrfCheck = Post::get();
16+
$updater = new AppUpdater();
17+
return $updater->update(false);
18+
19+
20+
}
21+
}

app/controllers/settings/Update.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @author cjacobsen
3333
*/
3434

35+
use App\App\AppUpdater;
3536
use App\Controllers\Controller;
3637
use System\App\AppLogger;
3738
use App\Models\Database\AppDatabase;
@@ -58,12 +59,15 @@ public function index()
5859

5960
public function indexPost()
6061
{
61-
AppLogger::get()->info('Editing Settings');
62-
$post = \system\Post::getAll();
63-
AppDatabase::saveSettings($post);
62+
if (Post::get('action') === 'updateApp') {
63+
$this->updateApp();
64+
}
65+
}
6466

65-
EmailDatabase::saveSettings($post);
66-
$this->redirect('/settings/application');
67+
private function updateApp()
68+
{
69+
$this->updater = new AppUpdater();
70+
return $this->updater->update(false);
6771
}
6872

6973
}

app/models/database/DatabaseModelInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
interface DatabaseModelInterface
3434
{
3535

36-
public static function saveSettings(array $postData);
36+
3737
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
4+
namespace App\Models\Database;
5+
6+
7+
class SchemaDatabase extends DatabaseModel
8+
{
9+
10+
/**
11+
* @return mixed
12+
*/
13+
public static function getSchemaVersion()
14+
{
15+
return self::getDatabaseValue('Schema_Version', 1);
16+
}
17+
}

app/models/view/Toast.php

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,37 @@ public function __construct(string $header, string $body, $timeout = 0)
1818
$this->setHeader($header)
1919
->addToBody($body)
2020
->setTimeout($timeout);
21-
$this->classes = 'position-fixed center top';
21+
$this->classes = 'position-fixed w-auto center top';
2222
}
2323

2424
/**
25-
* @return string
26-
*/
27-
public function getClasses(): string
28-
{
29-
return $this->classes;
30-
}
31-
32-
/**
33-
* @param string $classes
25+
* @param string $body
3426
*
3527
* @return Toast
3628
*/
37-
public function addClasses(string $classes): Toast
29+
public function addToBody($body)
3830
{
39-
if (is_string($classes)) {
40-
$this->classes = trim(str_replace(" ", " ", $this->classes)) . ' ' . trim($classes);
41-
} elseif (is_array($classes)) {
42-
foreach ($classes as $class) {
43-
$this->classes = trim(str_replace(" ", " ", $this->classes)) . ' ' . trim($class);
44-
}
45-
}
31+
$this->body .= $body;
4632
return $this;
4733
}
4834

49-
public function removeClasses(string $classes): Toast
35+
public function printToast()
5036
{
51-
$this->classes = str_replace($classes, '', $this->getClasses());
52-
return $this;
53-
}
37+
$toast = ['toastClasses' => $this->getClasses(), 'header' => $this->getHeader(), 'body' => $this->getBody(), 'timeout' => $this->getTimeout(), 'image' => $this->getImage(), 'closable' => $this->closable];
5438

55-
/**
56-
* @return mixed
57-
*/
58-
public function getImage()
59-
{
60-
return $this->image;
39+
$html = $this->view('layouts/toast', $toast);
40+
41+
return $html;
6142
}
6243

6344
/**
64-
* @param mixed $image
65-
*
66-
* @return Toast
45+
* @return string
6746
*/
68-
public function setImage($image)
47+
public function getClasses(): string
6948
{
70-
$this->image = $image;
71-
return $this;
49+
return $this->classes;
7250
}
7351

74-
7552
/**
7653
* @return string
7754
*/
@@ -99,17 +76,6 @@ public function getBody()
9976
return $this->body;
10077
}
10178

102-
/**
103-
* @param string $body
104-
*
105-
* @return Toast
106-
*/
107-
public function addToBody($body)
108-
{
109-
$this->body .= $body;
110-
return $this;
111-
}
112-
11379
/**
11480
* @return int
11581
*/
@@ -129,14 +95,23 @@ public function setTimeout($timeout)
12995
return $this;
13096
}
13197

132-
133-
public function printToast()
98+
/**
99+
* @return mixed
100+
*/
101+
public function getImage()
134102
{
135-
$toast = ['toastClasses' => $this->getClasses(), 'header' => $this->getHeader(), 'body' => $this->getBody(), 'timeout' => $this->getTimeout(), 'image' => $this->getImage(), 'closable' => $this->closable];
136-
137-
$html = $this->view('layouts/toast', $toast);
103+
return $this->image;
104+
}
138105

139-
return $html;
106+
/**
107+
* @param mixed $image
108+
*
109+
* @return Toast
110+
*/
111+
public function setImage($image)
112+
{
113+
$this->image = $image;
114+
return $this;
140115
}
141116

142117
public function closable()
@@ -150,5 +125,28 @@ public function bottom()
150125
->addClasses('bottom');
151126
}
152127

128+
/**
129+
* @param string $classes
130+
*
131+
* @return Toast
132+
*/
133+
public function addClasses(string $classes): Toast
134+
{
135+
if (is_string($classes)) {
136+
$this->classes = trim(str_replace(" ", " ", $this->classes)) . ' ' . trim($classes);
137+
} elseif (is_array($classes)) {
138+
foreach ($classes as $class) {
139+
$this->classes = trim(str_replace(" ", " ", $this->classes)) . ' ' . trim($class);
140+
}
141+
}
142+
return $this;
143+
}
144+
145+
public function removeClasses(string $classes): Toast
146+
{
147+
$this->classes = str_replace($classes, '', $this->getClasses());
148+
return $this;
149+
}
150+
153151

154152
}

app/views/homepage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
$toast = new Toast('New version available!', $toastBody, 10000);
2323
$toast->closable();
2424
echo $toast->printToast();
25+
echo "this will go away";
2526
}
2627
?>
2728

app/views/layouts/toast.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
<strong class="ml-1 mr-auto">
77
<?= $params['header'] ?></strong>
8-
98
<?php
109
if ($params['timeout'] === 0 || $params['closable']) {
1110
?>

app/views/settings/update.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151

5252

5353
$updateButton = new FormButton('Update to v' . $latestVersion);
54-
$updateButton->tiny()
55-
->addAJAXRequest('/api/update', 'settingsOutput', ['action' => 'updateApp']);
54+
$updateButton->tiny();
55+
// ->addAJAXRequest('/api/update', 'settingsOutput', ['action' => 'updateApp']);
5656
$updateForm->addElementToCurrentRow($updateButton)
5757
->addElementToNewRow($action);
5858
$closeModalFunction = '$(\'#' . $updateModal->getId() . '\').modal(\'hide\')';

config.db

140 KB
Binary file not shown.

0 commit comments

Comments
 (0)