Practices gui - bootstrap light, no pure php in smarty, html escaping in smarty ...
[openemr.git] / library / registry.inc
bloba4cfe987551abd85e5330eaaf9ad24f1f9c31a9d
1 <?php
2 //these are the functions used to access the forms registry database
3 //
6 function registerForm ( $directory , $sql_run=0 , $unpackaged=1 , $state=0 )
8         $check = sqlQuery("select state from registry where directory='$directory'");
9         if ($check == false)
10         {
11                 $lines = @file($GLOBALS['srcdir']."/../interface/forms/$directory/info.txt");
12                 if ($lines)
13                         $name = $lines[0];
14                 else
15                         $name = $directory;
16                 return sqlInsert("insert into registry set
17                         name='$name',
18                         state='$state',
19                         directory='".add_escape_custom($directory)."',
20                         sql_run='$sql_run',
21                         unpackaged='$unpackaged',
22                         date=NOW()
23                 ");
24         }
25         return false;
28 function updateRegistered ( $id, $mod )
30         return sqlInsert("update registry set
31                 $mod,
32                 date=NOW()
33         where
34                 id='$id'
35         ");
38 function getRegistered ( $state="1", $limit="unlimited", $offset="0")
40         $sql = "select * from registry where state like \"$state\" order by priority, name";
41         if ($limit != "unlimited")
42                 $sql .= " limit $limit, $offset";
43         $res = sqlStatement($sql);
44         if ($res)
45         for($iter=0; $row=sqlFetchArray($res); $iter++)
46         {
47                 $all[$iter] = $row;
48         }
49         else
50                 return false;
51         return $all;
54 function getRegistryEntry ( $id, $cols = "*" )
56         $sql = "select $cols from registry where id='$id'";
57         return sqlQuery($sql);
60 function getRegistryEntryByDirectory($directory, $cols = "*") {
61         $sql = "select $cols from registry where directory = ?";
62         return sqlQuery($sql, $directory);
65 function installSQL ( $dir )
67         $sqltext = $dir."/table.sql";
68         if ($sqlarray = @file($sqltext))
69         {
70                 $sql = implode("", $sqlarray);
71                 //echo "<br>$sql<br><br>";
72                 $sqla = explode(";",$sql);
73                 foreach ($sqla as $sqlq) {
74                   if (strlen($sqlq) > 5) {
75                    sqlStatement(rtrim("$sqlq"));
76                   }
77                 }
79                 return true;
80         }else
81                 return false;
86  * is a form registered
87  *  (optional - and active)
88  * in the database?
89  *
90  * NOTE - sometimes the Name of a form has a line-break at the end, thus this function might be better
91  *
92  *  INPUT =   directory => form directory
93  *            state => 0=inactive / 1=active
94  *  OUTPUT = true or false
95  */
96 function isRegistered ( $directory, $state = 1)
98     $sql = "select id from registry where ".
99             "directory='".$directory.
100             "' and state=".$state;
101     $result = sqlQuery($sql);
102     if ($result['id'] != '') return true;
103     return false;
106 function getTherapyGroupCategories(){
108         return array('');