funchat/modules/news/news.module.php

69 lines
2 KiB
PHP

<?php
class module_news extends admin_module{
function admin_panels(){
$panels=array(array("add_news","News schreiben","newspaper_add"),array("edit_news","News editieren","newspaper_go"),array("group_only","Newskategorien"),array("addcategory_news","Newskategorie hinzuf&uuml;gen","tag_blue_add"),array("editcategory_news","Newskategorie editieren","tag_blue_edit"));
return $panels;
}
function get_info(){
$info["name"]="Newsmodul";
$info["file"]="news";
$info["author"]="BeCast";
$info["version"]="1.0.1";
$info["url"]="http://www.becast.at";
return $info;
}
function install(){
global $config, $db;
$db->query("CREATE TABLE `" . $config['prefix'] . "news` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(60) NOT NULL default '',
`text` text NOT NULL,
`author` int(11) NOT NULL default '0',
`date` int(11) NOT NULL default '0',
`category` mediumint(9) NOT NULL default '0',
`active` enum('false','true') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM");
$db->query("CREATE TABLE `" . $config['prefix'] . "news_category` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(60) NOT NULL default '',
`picture` varchar(60) NOT NULL,
`active` enum('false','true') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM");
mkdir ($_SERVER["DOCUMENT_ROOT"] . $config['path']."/newsimages", 0777);
return TRUE;
}
function uninstall(){
global $config, $db;
$db->query("DELETE FROM `" . $config["prefix"] . "navigation` WHERE file='frontpage_news'");
$db->query("DROP TABLE `" . $config["prefix"] . "news`");
$db->query("DROP TABLE `" . $config["prefix"] . "news_category`");
@$this->recursive($_SERVER["DOCUMENT_ROOT"]. $config['path']."/newsimages");
return TRUE;
}
function recursive($dest){
$list = array_diff(scandir($dest), array('.', '..'));
foreach ($list as $value) {
$file = $dest.'/'.$value;
if (is_dir($file)) {
recursive($file);
}else{
unlink($file);
}
}
return rmdir($dest);
}
}
?>