| | 13 | |
|---|
| | 14 | //Create location table |
|---|
| | 15 | $query = " CREATE TABLE IF NOT EXISTS |
|---|
| | 16 | isymphony_location( admin_user_name VARCHAR(100), |
|---|
| | 17 | admin_password VARCHAR(100), |
|---|
| | 18 | originate_timeout INTEGER(10), |
|---|
| | 19 | auto_reload INTEGER(1), |
|---|
| | 20 | page_status_enabled INTEGER(1), |
|---|
| | 21 | jabber_host VARCHAR(100), |
|---|
| | 22 | jabber_domain VARCHAR(100), |
|---|
| | 23 | jabber_resource VARCHAR(100), |
|---|
| | 24 | jabber_port INTEGER(10))"; |
|---|
| | 25 | |
|---|
| | 26 | echo "Creating \"isymphony_location\" Table....<br>"; |
|---|
| | 27 | $results = $db->query($query); |
|---|
| | 28 | if(DB::IsError($results) && ($results->getCode() != DB_ERROR_ALREADY_EXISTS)) { |
|---|
| | 29 | echo "ERROR: could not create table.<br>"; |
|---|
| | 30 | } else { |
|---|
| | 31 | |
|---|
| | 32 | //Check to see if table already contains location information if not insert row of default values |
|---|
| | 33 | $result = $db->query("SELECT * FROM isymphony_location"); |
|---|
| | 34 | if($result->numRows() == 0) { |
|---|
| | 35 | |
|---|
| | 36 | //Populate with default values |
|---|
| | 37 | echo "Populating table.....<br>"; |
|---|
| | 38 | $prepStatement = $db->prepare("INSERT INTO isymphony_location (admin_user_name, admin_password, originate_timeout, auto_reload, page_status_enabled, jabber_port, jabber_resource) VALUES (?, ?, ?, ?, ?, ?, ?)"); |
|---|
| | 39 | $values = array("admin", "secret", "30000", 1, 1, 5222, "iSymphony"); |
|---|
| | 40 | $db->execute($prepStatement, $values); |
|---|
| | 41 | } |
|---|
| | 42 | } |
|---|
| | 43 | echo "Done<br>"; |
|---|
| | 69 | |
|---|
| | 70 | |
|---|
| | 71 | //If updating check if proper column entries exist. If not create them. Used for module upgrade purposes. |
|---|
| | 72 | $iSymphonyUserTableStringColumns = array("email", "cell_phone", "jabber_host", "jabber_domain", "jabber_resource", "jabber_user_name", "jabber_password"); |
|---|
| | 73 | $iSymphonyUserTableIntegerColumns = array("jabber_port"); |
|---|
| | 74 | $iSymphonyUserTableBooleanColumns= array("auto_answer"); |
|---|
| | 75 | |
|---|
| | 76 | foreach($iSymphonyUserTableStringColumns as $stringColumn) { |
|---|
| | 77 | $sql = "SELECT $stringColumn FROM isymphony_users"; |
|---|
| | 78 | $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 79 | if(DB::IsError($check)) { |
|---|
| | 80 | $sql = "ALTER TABLE isymphony_users ADD $stringColumn VARCHAR(200);"; |
|---|
| | 81 | $result = $db->query($sql); |
|---|
| | 82 | if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } |
|---|
| | 83 | } |
|---|
| | 84 | } |
|---|
| | 85 | |
|---|
| | 86 | foreach($iSymphonyUserTableIntegerColumns as $integerColumn) { |
|---|
| | 87 | $sql = "SELECT $integerColumn FROM isymphony_users"; |
|---|
| | 88 | $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 89 | if(DB::IsError($check)) { |
|---|
| | 90 | $sql = "ALTER TABLE isymphony_users ADD $integerColumn INTEGER(10);"; |
|---|
| | 91 | $result = $db->query($sql); |
|---|
| | 92 | if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } |
|---|
| | 93 | } |
|---|
| | 94 | } |
|---|
| | 95 | |
|---|
| | 96 | foreach($iSymphonyUserTableBooleanColumns as $booleanColumn) { |
|---|
| | 97 | $sql = "SELECT $booleanColumn FROM isymphony_users"; |
|---|
| | 98 | $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 99 | if(DB::IsError($check)) { |
|---|
| | 100 | $sql = "ALTER TABLE isymphony_users ADD $booleanColumn INTEGER(1);"; |
|---|
| | 101 | $result = $db->query($sql); |
|---|
| | 102 | if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } |
|---|
| | 103 | } |
|---|
| | 104 | } |
|---|
| 41 | | $prepStatement = $db->prepare("INSERT INTO isymphony_users (user_id, add_extension, add_profile, password, display_name, peer) VALUES (?, ?, ?, ?, ?, ?)"); |
|---|
| 42 | | $values = array($userId, 1, 1, "secret", $extensionDisplayName, $extensionPeer); |
|---|
| | 117 | $prepStatement = $db->prepare("INSERT INTO isymphony_users (user_id, add_extension, add_profile, password, display_name, peer, auto_answer, jabber_resource) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); |
|---|
| | 118 | $values = array($userId, 1, 1, "secret", $extensionDisplayName, $extensionPeer, 0, "iSymphony"); |
|---|