⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blocksadmin.inc.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		}
	} else {
		$msg = 'Failed update of block. ID:'.$bid;
	}
	redirect_header('myblocksadmin.php',1,$msg);
	exit();
}


if ( $op == "delete_ok" ) {
//	delete_block_ok($bid);
	$myblock = new XoopsBlock($bid);

	if ( $myblock->getVar('block_type') == 'S' ) {
		$message = _AM_SYSTEMCANT;
		redirect_header('admin.php?fct=blocksadmin',4,$message);
		exit();
	} elseif ($myblock->getVar('block_type') == 'M') {
		$message = _AM_MODULECANT;
		redirect_header('admin.php?fct=blocksadmin',4,$message);
		exit();
	} else {
		$myblock->delete();
		redirect_header('myblocksadmin.php',1,_AM_DBUPDATED);
		exit();
	}
}

if ( $op == "delete" ) {
    xoops_cp_header();

	$myblock = new XoopsBlock($bid);

	if ( $myblock->getVar('block_type') == 'S' ) {
		$message = _AM_SYSTEMCANT;
		redirect_header('admin.php?fct=blocksadmin',4,$message);
		exit();
	} elseif ($myblock->getVar('block_type') == 'M') {
		$message = _AM_MODULECANT;
		redirect_header('admin.php?fct=blocksadmin',4,$message);
		exit();
	} else {
		xoops_confirm(array('fct' => 'blocksadmin', 'op' => 'delete_ok', 'bid' => $myblock->getVar('bid')), 'admin.php', sprintf(_AM_RUSUREDEL,$myblock->getVar('title')));
	}

    xoops_cp_footer();
	exit();
}


if ( $op == "edit" ) {
    xoops_cp_header();

	$myblock = new XoopsBlock($bid);
	$db =& Database::getInstance();
	$sql = 'SELECT module_id FROM '.$db->prefix('block_module_link').' WHERE block_id='.intval($bid);
	$result = $db->query($sql);
	$modules = array();
	while ($row = $db->fetchArray($result)) {
		$modules[] = intval($row['module_id']);
	}
	$is_custom = ($myblock->getVar('block_type') == 'C' || $myblock->getVar('block_type') == 'E') ? true : false;
	$block = array('form_title' => _AM_EDITBLOCK, 'name' => $myblock->getVar('name'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'title' => $myblock->getVar('title', 'E'), 'content' => $myblock->getVar('content', 'E'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'update', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'));
	echo '<a href="myblocksadmin.php">'. _AM_BADMIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'._AM_EDITBLOCK.'<br /><br />';
	include 'blockform.php';
	$form->display();

    xoops_cp_footer();
	exit();
}


if ($op == 'clone') {
	xoops_cp_header();
	$myblock = new XoopsBlock($bid);

	$db =& Database::getInstance();
	$sql = 'SELECT module_id FROM '.$db->prefix('block_module_link').' WHERE block_id='.intval($bid);
	$result = $db->query($sql);
	$modules = array();
	while ($row = $db->fetchArray($result)) {
		$modules[] = intval($row['module_id']);
	}
	$is_custom = ($myblock->getVar('block_type') == 'C' || $myblock->getVar('block_type') == 'E') ? true : false;
	$block = array('form_title' => _AM_CLONEBLOCK, 'name' => $myblock->getVar('name'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'content' => $myblock->getVar('content', 'N'), 'title' => $myblock->getVar('title','E'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'clone_ok', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'));
	echo '<a href="admin.php?fct=blocksadmin">'. _AM_BADMIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'._AM_CLONEBLOCK.'<br /><br />';
	include 'blockform.php';
	$form->display();
	xoops_cp_footer();
	exit();
}


if ($op == 'clone_ok') {
	$block = new XoopsBlock($bid);

	if( empty($options) ) $options = array();
	elseif( ! is_array( $options ) ) $options = explode( '|' , $options ) ;

	$clone =& $block->clone();
	if (empty($bmodule)) {
		xoops_cp_header();
		xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
		xoops_cp_footer();
		exit();
	}
	$clone->setVar('side', $bside);
	$clone->setVar('weight', $bweight);
	$clone->setVar('visible', $bvisible);
	$clone->setVar('title', $btitle);
	$clone->setVar('bcachetime', $bcachetime);
	if ( isset($options) && (count($options) > 0) ) {
		$options = implode('|', $options);
		$clone->setVar('options', $options);
	}
	$clone->setVar('bid', 0);
	$clone->setVar('block_type', 'D');
	$newid = $clone->store();
	if (!$newid) {
		xoops_cp_header();
		$clone->getHtmlErrors();
		xoops_cp_footer();
		exit();
	}
	$db =& Database::getInstance();
	foreach ($bmodule as $bmid) {
		$sql = 'INSERT INTO '.$db->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newid.', '.$bmid.')';
		$db->query($sql);
	}

	$sql = "SELECT gperm_groupid FROM ".$db->prefix('group_permission')." WHERE gperm_name='block_read' AND gperm_modid='1' AND gperm_itemid='$bid'" ;
	$result = $db->query($sql);
	while( list( $gid ) = $db->fetchRow( $result ) ) {
		$sql = "INSERT INTO ".$db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $newid, 1, 'block_read')";
		$db->query($sql);
	}

	redirect_header('myblocksadmin.php',1,_AM_DBUPDATED);
}

	// import from modules/system/admin/blocksadmin/blocksadmin.php
	function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options=array())
	{
		global $xoopsConfig;
		if (empty($bmodule)) {
			xoops_cp_header();
			xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
			xoops_cp_footer();
			exit();
		}
		$myblock = new XoopsBlock($bid);
		if( $bside >= 0 ) $myblock->setVar('side', $bside);
		$myblock->setVar('weight', $bweight);
		$myblock->setVar('visible', $bvisible);
		$myblock->setVar('title', $btitle);
		$myblock->setVar('content', $bcontent);
		$myblock->setVar('bcachetime', $bcachetime);
		if ( isset($options) && (count($options) > 0) ) {
			$options = implode('|', $options);
			$myblock->setVar('options', $options);
		}
		if ($myblock->getVar('block_type') == 'C') {
			switch ($bctype) {
			case 'H':
				$name = _AM_CUSTOMHTML;
				break;
			case 'P':
				$name = _AM_CUSTOMPHP;
				break;
			case 'S':
				$name = _AM_CUSTOMSMILE;
				break;
			default:
				$name = _AM_CUSTOMNOSMILE;
				break;
			}
			$myblock->setVar('name', $name);
			$myblock->setVar('c_type', $bctype);
		} else {
			$myblock->setVar('c_type', 'H');
		}
		$msg = _AM_DBUPDATED;
		if ($myblock->store() != false) {
			$db =& Database::getInstance();
			$sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
			$db->query($sql);
			foreach ($bmodule as $bmid) {
				$sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid));
				$db->query($sql);
			}
			include_once XOOPS_ROOT_PATH.'/class/template.php';
			$xoopsTpl = new XoopsTpl();
			$xoopsTpl->xoops_setCaching(2);
			if ($myblock->getVar('template') != '') {
				if ($xoopsTpl->is_cached('db:'.$myblock->getVar('template'))) {
					if (!$xoopsTpl->clear_cache('db:'.$myblock->getVar('template'))) {
						$msg = 'Unable to clear cache for block ID'.$bid;
					}
				}
			} else {
				if ($xoopsTpl->is_cached('db:system_dummy.html', 'block'.$bid)) {
					if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block'.$bid)) {
						$msg = 'Unable to clear cache for block ID'.$bid;
					}
				}
			}
		} else {
			$msg = 'Failed update of block. ID:'.$bid;
		}
		return $msg ;
	}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -