Access control for individual issue types and document categories. (#580)
[openemr.git] / library / classes / CategoryTree.class.php
blobd5ce0f0b0d8f97002ffc09bcaf40d372df16d616
1 <?php
4 /**
5 * class CategoryTree
6 * This is a class for storing document categories using the MPTT implementation
7 */
9 class CategoryTree extends Tree {
12 * This just sits on top of the parent constructor, only a shell so that the _table var gets set
14 function __construct($root,$root_type = ROOT_TYPE_ID) {
15 $this->_table = "categories";
16 parent::__construct($root,$root_type);
19 function _get_categories_array($patient_id, $user='') {
20 $categories = array();
21 $sql = "SELECT c.id, c.name, c.aco_spec, d.id AS document_id, d.type, d.url, d.docdate"
22 . " FROM categories AS c, documents AS d, categories_to_documents AS c2d"
23 . " WHERE c.id = c2d.category_id"
24 . " AND c2d.document_id = d.id";
26 if (is_numeric($patient_id)) {
27 if ($patient_id == "00") {
28 // Collect documents that are not assigned to a patient
29 $sql .= " AND (d.foreign_id = 0 OR d.foreign_id IS NULL) ";
31 else {
32 // Collect documents for a specific patient
33 $sql .= " AND d.foreign_id = '" . $patient_id . "'";
36 $sql .= " ORDER BY c.id ASC, d.docdate DESC, d.url ASC";
38 //echo $sql;
39 $result = $this->_db->Execute($sql);
41 while ($result && !$result->EOF) {
42 $categories[$result->fields['id']][$result->fields['document_id']] = $result->fields;
43 $result->MoveNext();
46 return $categories;