-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlooma-contentNav-databaseUpdate.php
More file actions
73 lines (59 loc) · 1.73 KB
/
looma-contentNav-databaseUpdate.php
File metadata and controls
73 lines (59 loc) · 1.73 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
72
73
<?php
include '../Looma/includes/mongo-connect.php';
//Get Command
$cmd = $_GET["cmd"];
//Update Command
if ($cmd == "update") {
//Get Query and Page To Load
$title = $_GET["title"];
$ch_id = $_GET["chid"];
$isDuplicate = $_GET["duplicate"];
$db_id = $_GET["dbid"];
if ($isDuplicate == "false") {
//Create Query For Activity
$toFind = array('_id' => new MongoId($db_id));
//Fields To Update
$updatedField = array(
"dn" => $title,
"ch_id" => $ch_id
);
//Type Of Update
$update = array('$set'=>$updatedField);
//Actually Update
$activities_collection->update (
$toFind, $update
);
} else {
//Create Query For Activity
$toFind = array('_id' => new MongoId($db_id));
$projection = array("_id" => false);
//Get Activity
$activity = $activities_collection->findOne($toFind, $projection);
//Update Fields
$activity['dn'] = $title;
$activity['ch_id'] = $ch_id;
//Actually Update
$activities_collection->insert($activity);
}
} else if ($cmd == "insert") {
//Get Terms
$title = $_GET["title"];
$ch_id = $_GET["chid"];
$fn = $_GET['fn'];
$ft = $_GET['ft'];
//Build Object
$toInsert = array("dn" => $title, "ch_id" => $ch_id, "fn" => $fn, "ft" => $ft);
//Insert Object
$activities_collection->insert($toInsert);
} else if ($cmd == "getChapterId") {
//Get Info
$fn = $_GET['fn'];
//Create Query
$toFind = array('fn' => $fn);
$projection = array("_id" => false, "ch_id" => true);
//Get Activity
$activity = $activities_collection->findOne($toFind, $projection);
//Return ch_id
echo $activity['ch_id'];
}
?>