/
duplicate_item.php
55 lines (50 loc) · 2.64 KB
/
duplicate_item.php
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
<?php
/********************************************************************************
* *
* Copyright 2012 Nicolas CARPi (nicolas.carpi@gmail.com) *
* http://www.elabftw.net/ *
* *
********************************************************************************/
/********************************************************************************
* This file is part of eLabFTW. *
* *
* eLabFTW is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* eLabFTW is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
* PURPOSE. See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public *
* License along with eLabFTW. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
require_once('inc/common.php');
// Check ID
if (isset($_GET['id']) && !empty($_GET['id']) && is_pos_int($_GET['id'])) {
$id = $_GET['id'];
}
if ($_GET['type'] === 'exp'){
$type = 'experiments';
} elseif ($_GET['type'] === 'db') {
$type = 'items';
} else {
die('Bad type.');
}
$newid = duplicate_item($id, $type);
if ($newid) {
if ($type === 'experiments') {
$msg_arr[] = 'Experiment successfully duplicated';
$_SESSION['infos'] = $msg_arr;
header('location: experiments.php?mode=edit&id='.$newid.'');
} else {
$msg_arr[] = 'Successfully duplicated';
$_SESSION['infos'] = $msg_arr;
header('location: database.php?mode=edit&id='.$newid.'');
}
} else {
echo "Something went wrong in the database query. Check the flux capacitor.";
}