action.module.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 180 行
PHP
180 行
<?php
/**
* Article management for XOOPS
*
* @copyright The XOOPS project http://www.xoops.org/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
* @since 1.00
* @version $Id$
* @package module::article
*/
if (!defined('XOOPS_ROOT_PATH')){ exit(); }
include dirname(__FILE__)."/vars.php";
mod_loadFunctions("parse", $GLOBALS["artdirname"]);
art_parse_function('
function xoops_module_install_[DIRNAME](&$module)
{
$data_file = XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/sql/mysql.".$GLOBALS["xoopsConfig"]["language"].".sql";
if(!file_exists($data_file)){
$data_file = XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/sql/mysql.english.sql";
}
// The mysql data was exported with UTF-8, so restore it
$GLOBALS["xoopsDB"]->queryF("SET NAMES utf8");
if(!$GLOBALS["xoopsDB"]->queryFromFile($data_file)){
$module->setErrors("Pre-set data were not installed");
return true;
}
/* Set tags */
mod_loadFunctions("recon", $GLOBALS["artdirname"]);
art_updateTag($module->getVar("mid"));
require_once(XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/class/permission.php");
/* Set corresponding permissions for categories and articles */
$module_id = $module->getVar("mid") ;
$gperm_handler =& xoops_gethandler("groupperm");
$groups_view = array(XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
$groups_post = array(XOOPS_GROUP_USERS);
$groups_admin = array(XOOPS_GROUP_ADMIN);
$view_items = array("access", "view");
$post_items = array("submit", "rate");
$admin_items = array("publish", "moderate");
$category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
$cat_ids = $category_handler->getIds();
foreach ($groups_view as $group_id) {
$gperm_handler->addRight("global", $GLOBALS["perms_global"]["search"]["id"], $group_id, $module_id);
foreach($view_items as $item){
foreach($cat_ids as $id){
$gperm_handler->addRight($item, $id, $group_id, $module_id);
}
}
}
foreach ($groups_post as $group_id) {
$gperm_handler->addRight("global", $GLOBALS["perms_global"]["html"]["id"], $group_id, $module_id);
foreach($post_items as $item){
foreach($cat_ids as $id){
$gperm_handler->addRight($item, $id, $group_id, $module_id);
}
}
}
foreach ($groups_admin as $group_id) {
$gperm_handler->addRight("global", $GLOBALS["perms_global"]["upload"]["id"], $group_id, $module_id);
foreach($admin_items as $item){
foreach($cat_ids as $id){
$gperm_handler->addRight($item, $id, $group_id, $module_id);
}
}
}
return true;
}
function xoops_module_pre_install_[DIRNAME](&$module)
{
$mod_tables = $module->getInfo("tables");
foreach($mod_tables as $table){
$GLOBALS["xoopsDB"]->queryF("DROP TABLE IF EXISTS ".$GLOBALS["xoopsDB"]->prefix($table).";");
}
return [DIRNAME]_setModuleConfig($module);
}
function xoops_module_pre_update_[DIRNAME](&$module)
{
return [DIRNAME]_setModuleConfig($module);
}
function xoops_module_update_[DIRNAME](&$module, $prev_version = null)
{
if ($prev_version < 96) {
$GLOBALS["xoopsDB"]->queryFromFile(XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/sql/mysql.096.sql");
}
if ($prev_version < 97) {
include_once dirname(__FILE__)."/module.v097.php";
xoops_module_update_art_v097($module);
}
mod_loadFunctions("recon", $GLOBALS["artdirname"]);
art_synchronization();
// Update permissions
$permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
$permission_handler->createPermData();
// Clear caches
load_functions("cache");
$dirname = $GLOBALS["artdirname"];
mod_clearSmartyCache("/(^{$dirname}\^.*\.html$|blk_.*{$dirname}[^\.]*\.html$)/");
// Update templates
mod_loadFunctions("render", $GLOBALS["artdirname"]);
art_template_lookup();
art_template_lookup(true);
return true;
}
function [DIRNAME]_setModuleConfig(&$module)
{
return true;
/*
$modinfo =& $module->getInfo();
$modinfo["templates"] =& art_getTplPageList();
$forum_options = array(_NONE => 0);
$module_handler =& xoops_gethandler("module");
$newbb =& $module_handler->getByDirname("newbb");
if(is_object($newbb) && $newbb->getVar("isactive")){
$forum_handler =& xoops_getmodulehandler("forum", "newbb", true);
// the acient NewBB module is not supported
if(is_object($forum_handler) && method_exists($forum_handler, "getForumsByCategory")):
$forums = $forum_handler->getForumsByCategory(0, "", false);
foreach (array_keys($forums) as $c) {
foreach(array_keys($forums[$c]) as $f){
$forum_options[$forums[$c][$f]["title"]]=$f;
if(!isset($forums[$c][$f]["sub"])) continue;
foreach(array_keys($forums[$c][$f]["sub"]) as $s){
$forum_options["-- ".$forums[$c][$f]["sub"][$s]["title"]]=$s;
}
}
}
endif;
unset($forums);
}
$modconfig =& $modinfo["config"];
$count = count($modconfig);
$flag=0;
for($i=0;$i<$count;$i++){
if($modconfig[$i]["name"]=="template"){
$modconfig[$i]["options"] =& art_getTemplateList();
$flag ++;
}
if($modconfig[$i]["name"]=="forum"){
$modconfig[$i]["options"] =& $forum_options;
$flag ++;
}
if($modconfig[$i]["name"]=="theme_set"){
$modconfig[$i]["options"][_NONE] = "0";
foreach ($GLOBALS["xoopsConfig"]["theme_set_allowed"] as $theme) {
$modconfig[$i]["options"][$theme] = $theme;
}
$flag ++;
}
if($flag>=3) {
break;
}
}
return true;
*/
}
');
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?