-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_task.php
More file actions
41 lines (33 loc) · 887 Bytes
/
Copy pathupdate_task.php
File metadata and controls
41 lines (33 loc) · 887 Bytes
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
<?php
session_start();
$file = "users.xml";
$fp = fopen($file, "rb") or die("Err - can't open file");
$str = fread($fp, filesize($file));
$xml = new DOMDocument();
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->loadXML($str) or die("Err - can't load XML data");
$root = $xml->documentElement;
$companies = $root;
$return = array();
function editTask($companies, $xml)
{
foreach ($companies->childNodes as $company)
{
if($company->getAttribute('id') == $_SESSION['company-id'])
{
$tasks = $company->childNodes->item(2);
foreach ($tasks->childNodes as $task)
{
if($task->getAttribute('id') == $_POST['id'])
{
$task->getElementsByTagName("status")->item(0)->nodeValue = $_POST['status'];
$xml->save("users.xml");
return true;
}
}
}
}
}
$return['success'] = editTask($companies, $xml);
echo json_encode($return);