public function update(Category $category) { if ($this->find($category->getId())) { $catId = $category->getId(); $userId = $category->getUser()->getId(); $superCat = $category->getParentCategory()->getId(); $subCat = $category->getSubCategory(); $sql = "UPDATE " . $this->TABLE_NAME . " SET\n userId='{$userId}',superCategory='{$superCat}',subCategory='{$subCat}'\n WHERE id='{$catId}'"; if (mysql_query($sql, $this->connection)) { return true; } else { return false; } } else { return false; } }
public function feedNews($url, $min, $max) { if (!($news = $this->getNews('', $min, $max))) { return false; } $feed = '<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <atom:link href="' . $url . '" rel="self" type="application/rss+xml" /> <title>' . $this->config[0]->nomesito . '</title> <description>' . $this->config[0]->description . '</description> <link>' . $this->config[0]->url_index . '/index.php</link>'; foreach ($news as $v) { list($d, $m, $y) = explode('-', $v->data); list($h, $mn, $s) = explode(':', $v->ora); $nickname = parent::getUser($v->autore); $feed .= "\n\t<item>\n\t\t<title>" . parent::xmlentities(htmlentities($v->titolo)) . "</title>\n\t\t<description>" . parent::xmlentities(htmlentities($v->contenuto)) . "</description>\n\t\t<author>" . parent::xmlentities(htmlentities($nickname[0]->email)) . '(' . parent::xmlentities(htmlentities($v->autore)) . ")</author>\n\t\t<category>" . parent::xmlentities(htmlentities($v->categoria)) . "</category>\n\t\t<pubDate>" . str_replace('+0000', '+0200', date('r', mktime($h, $mn, $s, $m, $d, $y))) . "</pubDate>\n\t\t<link>{$this->config[0]->url_index}/news/{$v->minititolo}.html</link>\n\t\t<comments>{$this->config[0]->url_index}/news/{$v->minititolo}.html</comments>\n\t\t<guid>{$this->config[0]->url_index}/news/{$v->minititolo}.html</guid>\n\t</item>"; } $feed .= ' </channel> </rss>'; return $feed; }