db = $db;
$this->conf = $conf;
}
public function saveSettings($fieldsArray)
{
if ($this->db->modificarDeFormulario($this->conf->tablePrefix."config", $fieldsArray)) {
header("Location: ".$this->conf->urlSorbet."/admin/settings.php?modified=true");
die();
} else {
header("Location: ".$this->conf->urlSorbet."/admin/settings.php?error=1&des=".$this->db->merror);
die();
}
}
public function saveOption($value, $name)
{
$sqlStr = "UPDATE ".$this->conf->tablePrefix."options SET val='".$value."' WHERE name='".$name."' LIMIT 1";
if ($this->db->ejecutarConsulta($sqlStr)) {
return true;
} else {
return true;
}
}
public function addPost($fieldsArray)
{
if ($this->db->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
return true;
} else {
return false;
}
}
public function modifyPost($fieldsArray, $id_post)
{
if ($this->db->modificarDeFormulario($this->conf->tablePrefix."data", $fieldsArray, "id_post=$id_post")) {
header("Location: ".$this->conf->urlSorbet."/admin/index.php?modified=true");
die();
} else {
header("Location: ".$this->conf->urlSorbet."/admin/index.php?error=2&des=".$this->db->merror);
die();
}
}
public function deletePost($idPost)
{
$this->db->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."data WHERE id_post=".$idPost);
}
public function getPosts($limit="10", $from="0")
{
$sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
$this->db->ejecutarConsulta($sqlStr);
return $this->db->mid_consulta;
}
public function getPost($id="")
{
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
return $this->db->mid_consulta->fetch();
}
public function getPostsNumber()
{
$this->db->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
$row = $this->db->mid_consulta->fetch();
return $row['total'];
}
public function getType($id)
{
if ($this->db->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
if ($this->db->contarRegistros()>0) {
while ($registro = $this->db->mid_consulta->fetch()) {
return $registro[0];
}
}
} else {
return "0";
}
}
public function formatConversation($text)
{
$formatedText = "";
$odd=true;
$lines = explode("\n", $text);
$formatedText .= "