forked from projectsend/projectsend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-assets-add.php
More file actions
71 lines (59 loc) · 1.92 KB
/
custom-assets-add.php
File metadata and controls
71 lines (59 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Show the form to add a new asset.
*
*/
require_once 'bootstrap.php';
check_access_enhanced(['create_assets']);
$asset = new \ProjectSend\Classes\CustomAsset();
$language = (!empty($_POST)) ? $_POST['language'] : $_GET['language'];
if (!in_array($language, array_keys(get_asset_languages()))) {
exit_with_error_code(403);
}
$active_nav = 'tools';
$page_title = sprintf(__('Add new %s asset', 'cftp_admin'), format_asset_language_name($language));
$page_id = 'asset_editor';
add_codemirror_assets();
include_once ADMIN_VIEWS_DIR . DS . 'header.php';
if ($_POST) {
/**
* Clean the posted form values to be used on the actions,
* and again on the form if validation failed.
*/
$asset_arguments = [
'title' => $_POST['title'],
'content' => $_POST['content'],
'language' => $language,
'location' => $_POST['location'],
'position' => $_POST['position'],
'enabled' => (isset($_POST["enabled"])) ? 1 : 0,
];
/** Validate the information from the posted form. */
$asset->set($asset_arguments);
$create = $asset->create();
if ($create['status'] === 'success') {
$flash->success($create['message']);
$redirect_to = BASE_URI . 'custom-assets-edit.php?id=' . $create['id'];
} else {
$flash->error($create['message']);
$redirect_to = BASE_URI . 'custom-assets-add.php';
}
ps_redirect($redirect_to);
}
?>
<div class="row">
<div class="col-12 col-sm-12 col-lg-6">
<div class="white-box">
<div class="white-box-interior">
<?php
// If the form was submitted with errors, show them here.
echo $asset->getValidationErrors();
$asset_form_type = 'new';
include_once FORMS_DIR . DS . 'assets.php';
?>
</div>
</div>
</div>
</div>
<?php
include_once ADMIN_VIEWS_DIR . DS . 'footer.php';