function miscapps_get($miscapps_id) { global $db; $sql = "SELECT miscapps_id, description, ext, dest FROM miscapps WHERE miscapps_id = " . $db->escapeSimple($miscapps_id); $row = $db->getRow($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($row)) { die_freepbx($row->getMessage() . "<br><br>Error selecting row from miscapps"); } // we want to get the ext from featurecodes $fc = new featurecode('miscapps', 'miscapp_' . $row['miscapps_id']); $row['ext'] = $fc->getDefault(); $row['enabled'] = $fc->isEnabled(); return $row; }
} } $sql = "CREATE TABLE IF NOT EXISTS daynight \n (\n\t\t\t\text varchar(10) NOT NULL default '',\n\t\t\t\tdmode varchar(40) NOT NULL default '',\n\t\t\t dest varchar(255) NOT NULL default '',\n\t\t\t\tPRIMARY KEY (ext, dmode, dest)\n\t\t\t );\n\t\t\t "; $check = $db->query($sql); if (DB::IsError($check)) { die_freepbx("Can not create daynight table"); } // Get the old feature code if it existed to determine // if it had been changed and if it was enabled // $delete_old = false; $fcc = new featurecode('daynight', 'toggle-mode'); $code = $fcc->getCode(); if ($code != '') { $delete_old = true; $enabled = $fcc->isEnabled(); $fcc->delete(); } unset($fcc); // If we found the old one then we must create all the new ones // if ($delete_old) { $list = daynight_list(); foreach ($list as $item) { $id = $item['ext']; $fc_description = $item['dest']; $fcc = new featurecode('daynight', 'toggle-mode-' . $id); if ($fc_description) { $fcc->setDescription("{$id}: {$fc_description}"); } else { $fcc->setDescription("{$id}: Day Night Control");
public function get($miscapps_id) { $db = $this->db; $sql = "SELECT miscapps_id, description, ext, dest FROM miscapps WHERE miscapps_id = ?"; $q = $db->prepare($sql); $q->execute(array($miscapps_id)); if ($q) { $row = $q->getRow(); } // we want to get the ext from featurecodes $fc = new featurecode('miscapps', 'miscapp_' . $row['miscapps_id']); $row['ext'] = $fc->getDefault(); $row['enabled'] = $fc->isEnabled(); return $row; }