-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist.php
executable file
·84 lines (72 loc) · 1.9 KB
/
list.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once('LocalSettings.inc.php');
require_once(MCL_ROOT . 'ConceptListFactory.inc.php');
require_once(MCL_ROOT . 'ConceptListDefinition.inc.php');
// Get the parameters
$arr_concepts = null;
if (isset($_POST['concepts'])) {
$arr_concepts = json_decode($_POST['concepts']);
}
$action = $_POST['action'];
$list_name = '';
$list_description = '';
if ($action == 'new') {
$list_name = $_POST['name'];
//$list_description = $_POST['desc'];
}
// debug stuff
echo '<pre>', var_dump($_POST), '</pre>';
$i = 0;
echo '<table border="1">';
echo '<tr><th>#</th><th>dict_id</th><th>csrg_id</th><th>concept_id</th><th>name</th></tr>';
foreach ($arr_concepts as $c)
{
$i++;
echo '<tr><td>' . $i . '</td>';
echo '<td>' . $c -> dict_id . '</td>';
echo '<td>' . $c -> csrg_id . '</td>';
echo '<td>' . $c -> concept_id . '</td>';
echo '<td>' . $c -> name . '</td>';
echo '</tr>';
}
echo '</table>';
// open db connection
$cxn = mysql_connect($mcl_db_host, $mcl_db_uid, $mcl_db_pwd);
if (!$cxn) {
die('Could not connect to database: ' . mysql_error());
}
mysql_select_db($mcl_enhanced_db_name);
// New list
if ($_POST['action'] == 'new')
{
// Create the new list definition
$cld = new ConceptListDefinition();
$cld->setName($list_name);
$cld->setDescription($list_description);
// create the new list
$cl = new ConceptList($cld);
foreach ($arr_concepts as $c) {
$cl->addConcept($c->concept_id);
// TODO: $cl->addConcept($c->dict_id, $c->concept_id);
}
// Commit to database
$clf = new ConceptListFactory();
$clf->setConnection($cxn);
if (!$clf->insertConceptList($cl)) {
trigger_error('Could not create list', E_USER_ERROR);
} else {
echo 'successfully created list!';
}
}
// Add to list
elseif ($action == 'add')
{
//
}
// Remove from list
elseif ($action == 'remove')
{
//
}
else {
}