<?php
/**
* Copyright (C) 2004 - 2006, John Tarlton.
*
* This file is part of AstWebPanel - A web management user interface for Asterisk.
*
* AstWebPanel is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. See the LICENSE file distributed
* with AstWebPanel.
*
* Database access object.
*/
require_once('./php/dbase.php');
/* Database access object for the server's time configuration.
*/
class ServerTimeDao
{
var $data = array ('ntp' => '', 'ntpserver' => '', 'timezone' => '');
function get(&$values)
{
global $db;
$result = $db->query("SELECT * FROM servertime");;
if ( $result->numRows() == 1 )
{
$row = $result->fetchRow();
foreach(array_keys($this->data) as $key)
{
if ($key == 'ntp')
$values[$key] = ($row[$key] == 't') ? TRUE : FALSE;
else
$values[$key] = $row[$key];
}
$result->free();
return TRUE;
}
$result->free();
return FALSE;
}
function update(&$values)
{
global $db;
foreach(array_keys($this->data) as $key)
{
if (isset($values[$key]))
{
if ($key == 'ntp')
$this->data[$key] = ($values[$key] == TRUE) ? 't' : 'f';
else
$this->data[$key] = $values[$key];
}
}
$query = "UPDATE servertime SET ntp = ?, ntpserver = ?, timezone = ?";
$stmt = $db->prepare($query);
$querydata = array($this->data['ntp'], $this->data['ntpserver'], $this->data['timezone']);
$result = $db->execute($stmt, $querydata);
return DB::isError ($result);
}
}
?>