-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewGoalScript.php
75 lines (54 loc) · 1.84 KB
/
newGoalScript.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
<?php
require_once('cps_simple.php');
// Connection hubs
// Note, replace 'api-eu' with appropriate Cloud server you use - 'api-us' or 'api-uk'
//var_dump($_POST);
$connectionStrings = array(
'tcp://cloud-us-0.clusterpoint.com:9007',
'tcp://cloud-us-1.clusterpoint.com:9007',
'tcp://cloud-us-2.clusterpoint.com:9007',
'tcp://cloud-us-3.clusterpoint.com:9007'
);
// Creating a CPS_Connection instance
$cpsConn = new CPS_Connection(
new CPS_LoadBalancer($connectionStrings), 'DATABASENAME', 'USERNAME', 'PASSWORD', 'document',
'//document/id', array('account' => ID)
);
$cpsConn2 = new CPS_Connection(
new CPS_LoadBalancer($connectionStrings), 'DATABASENAME', 'USERNAME', 'PASSWORD', 'document',
'//document/id', array('account' => ID)
);
$cpsSimple = new CPS_Simple($cpsConn);
$cpsSimple2 = new CPS_Simple($cpsConn2);
$query = CPS_Term($_POST["user"]);
$documents = $cpsSimple->search($query, 0, 1, array(), null);
//var_dump($documents);
$document = reset($documents);
$id = key($documents);
//echo $id;
$goalPage = $cpsSimple2->retrieveSingle('size');
$newGoal = array(
'title' => $_POST["title"],
'description' => $_POST["description"],
'milestones' => "",
'achieved' => "false",
'date' => $_POST["date"]
);
//var_dump($goalPage);
$goalPage->title ++;
$cpsSimple2->updateSingle('size', $goalPage);
$oldData = ($document->goals);
//echo($oldData);
$cpsSimple2->insertSingle((string)$goalPage->title, $newGoal);
var_dump($oldData);
$xml = simplexml_load_string($oldData->asXML(), 'SimpleXMLElement', LIBXML_NOCDATA);
$array = json_decode(json_encode($xml), TRUE);
eval('$array = ' . reset($array) . ';');
array_push($array, (string)$goalPage->title);
ob_start();
var_export ($array);
$result = ob_get_clean();
$document->goals = $result;
$cpsSimple->updateSingle($id, $document);
header("Location: dashboard.php?user=" . $_POST["user"]);
?>