Changeset dbd0c9dbeda6f50b3591b96efc2de01c606c0d25
- Timestamp:
- 11/01/10 18:30:04
(3 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1288636204 +0000
- git-parent:
[0c28d603d67bca2fd0190fb5509dc5e0733a8f2e]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1288636204 +0000
- Message:
fixes #197 -- thanks Michal Táborský
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r17cbef4 |
rdbd0c9d |
|
| 8 | 8 | RewriteRule ^json/worksheet/search$ worksheet_search_json.php [PT,QSA] |
|---|
| 9 | 9 | RewriteRule ^json/worksheet/deletegraph/([^/]+)/([^/]+)$ worksheet_graph_delete.php?wid=$1&gid=$2 [PT,QSA] |
|---|
| | 10 | RewriteRule ^json/worksheet/forget/([^/]+)/([^/]+)$ worksheet_delete.php?id=$1&force=$2 [PT,QSA] |
|---|
| 10 | 11 | RewriteRule ^json/graph/info/([^/]*)$ graph_info.php?id=$1 [PT,QSA] |
|---|
| 11 | 12 | RewriteRule ^json/graph/store$ graph_store.php [PT,QSA] |
|---|
| r7e749a2 |
rdbd0c9d |
|
| 877 | 877 | } |
|---|
| 878 | 878 | })(ws.sheetid)); |
|---|
| | 879 | var del = $('<a href="#"/>'); |
|---|
| | 880 | del.html('Forget').addClass('deletews'); |
|---|
| | 881 | del.click((function(sheetid, li) { |
|---|
| | 882 | return function() { |
|---|
| | 883 | $.getJSON('json/worksheet/forget/' + sheetid + '/0', function(r) { |
|---|
| | 884 | if (r.refed) { |
|---|
| | 885 | var msg = "This worksheet contains following graphs:<p>"; |
|---|
| | 886 | for (var g in r.refed) { |
|---|
| | 887 | msg += "<br>" + r.refed[g]; |
|---|
| | 888 | } |
|---|
| | 889 | msg += "<p>Are you sure you want to forget it?"; |
|---|
| | 890 | confirm(msg, function() { |
|---|
| | 891 | $.getJSON('json/worksheet/forget/' + sheetid + '/1', function(r) { |
|---|
| | 892 | if (r.error) { |
|---|
| | 893 | modal_warning("Database Error!", r.error); |
|---|
| | 894 | } |
|---|
| | 895 | else { |
|---|
| | 896 | perform_ws_search_edit(params); |
|---|
| | 897 | if (worksheet.get_sheetid() == sheetid) { |
|---|
| | 898 | worksheet.load(); |
|---|
| | 899 | } |
|---|
| | 900 | } |
|---|
| | 901 | }); |
|---|
| | 902 | }); |
|---|
| | 903 | } |
|---|
| | 904 | else { |
|---|
| | 905 | if (r.error) { |
|---|
| | 906 | modal_warning("Database Error!", r.error); |
|---|
| | 907 | } |
|---|
| | 908 | else { |
|---|
| | 909 | perform_ws_search_edit(params); |
|---|
| | 910 | if (worksheet.get_sheetid() == sheetid) { |
|---|
| | 911 | worksheet.load(); |
|---|
| | 912 | } |
|---|
| | 913 | } |
|---|
| | 914 | } |
|---|
| | 915 | }); |
|---|
| | 916 | return false; |
|---|
| | 917 | } |
|---|
| | 918 | })(ws.sheetid, li)); |
|---|
| 879 | 919 | var ul = $('<ul/>'); |
|---|
| 880 | 920 | ul.append($('<li/>').html(ws.last_update)); |
|---|
| 881 | 921 | ul.append($('<li/>').append(add)); |
|---|
| | 922 | ul.append($('<li/>').append(del)); |
|---|
| 882 | 923 | li.append($('<div class="worksheetlist-title"/>').html(ws.title)).append(ul); |
|---|
| 883 | 924 | } |
|---|
| … | … | |
| 1562 | 1603 | islocked: function() { |
|---|
| 1563 | 1604 | return locked; |
|---|
| | 1605 | }, |
|---|
| | 1606 | get_sheetid: function() { |
|---|
| | 1607 | return wsinfo.id; |
|---|
| 1564 | 1608 | } |
|---|
| 1565 | 1609 | }; |
|---|
| raa9764c |
rdbd0c9d |
|
| 499 | 499 | $sth->execute(array($ws_id, $graphid)); |
|---|
| 500 | 500 | } |
|---|
| | 501 | function deleteWorksheet($ws_id) { |
|---|
| | 502 | $this->db->beginTransaction(); |
|---|
| | 503 | try { |
|---|
| | 504 | // we have to delete the dependencies first, because the foreign |
|---|
| | 505 | // key has no ON DELETE CASCADE |
|---|
| | 506 | $sth = $this->db->prepare("delete from prism.saved_worksheets_dep |
|---|
| | 507 | where sheetid=?"); |
|---|
| | 508 | $sth->execute(array($ws_id)); |
|---|
| | 509 | // now it is safe to delete the worksheet itself |
|---|
| | 510 | $sth = $this->db->prepare("delete from prism.saved_worksheets |
|---|
| | 511 | where sheetid=?"); |
|---|
| | 512 | $sth->execute(array($ws_id)); |
|---|
| | 513 | $this->db->commit(); |
|---|
| | 514 | } catch(PDOException $e) { |
|---|
| | 515 | $this->db->rollback(); |
|---|
| | 516 | throw(new Exception('DB: ' . $e->getMessage())); |
|---|
| | 517 | } |
|---|
| | 518 | } |
|---|
| | 519 | function getGraphsByWorksheet($ws_id){ |
|---|
| | 520 | |
|---|
| | 521 | $sth = $this->db->prepare("select saved_graphs.title |
|---|
| | 522 | from prism.saved_graphs |
|---|
| | 523 | natural join prism.saved_worksheets_dep |
|---|
| | 524 | where prism.saved_worksheets_dep.sheetid=?"); |
|---|
| | 525 | |
|---|
| | 526 | $sth->execute(array($ws_id)); |
|---|
| | 527 | |
|---|
| | 528 | $rv = array(); |
|---|
| | 529 | while($row = $sth->fetch()) { |
|---|
| | 530 | $rv[] = $row['title']; |
|---|
| | 531 | } |
|---|
| | 532 | return $rv; |
|---|
| | 533 | } |
|---|
| 501 | 534 | function getWorksheetsByGraph($graphid){ |
|---|
| 502 | 535 | |
|---|