本文整理匯總了PHP中XoopsBlock::xoopsClone方法的典型用法代碼示例。如果您正苦於以下問題:PHP XoopsBlock::xoopsClone方法的具體用法?PHP XoopsBlock::xoopsClone怎麽用?PHP XoopsBlock::xoopsClone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XoopsBlock
的用法示例。
在下文中一共展示了XoopsBlock::xoopsClone方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: XoopsBlock
function clone_block_ok($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
{
global $xoopsUser;
$block = new XoopsBlock($bid);
$clone =& $block->xoopsClone();
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('content', $bcontent);
//$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);
if ($block->getVar('block_type') == 'C' || $block->getVar('block_type') == 'E') {
$clone->setVar('block_type', 'E');
} else {
$clone->setVar('block_type', 'D');
}
$newid = $clone->store();
if (!$newid) {
xoops_cp_header();
$clone->getHtmlErrors();
xoops_cp_footer();
exit;
}
if ($clone->getVar('template') != '') {
$tplfile_handler =& xoops_gethandler('tplfile');
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
if (count($btemplate) > 0) {
$tplclone =& $btemplate[0]->xoopsClone();
$tplclone->setVar('tpl_id', 0);
$tplclone->setVar('tpl_refid', $newid);
$tplman->insert($tplclone);
}
}
$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);
}
$groups =& $xoopsUser->getGroups();
$count = count($groups);
for ($i = 0; $i < $count; $i++) {
$sql = "INSERT INTO " . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (" . $groups[$i] . ", " . $newid . ", 1, 'block_read')";
$db->query($sql);
}
redirect_header('admin.php?fct=blocksadmin&t=' . time(), 1, _AM_DBUPDATED);
}
示例2: clone_block_ok
function clone_block_ok($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bcachetime, $bmodule, $options = array(), $bgroups = array())
{
global $xoopsUser;
/*
if (empty($bmodule)) {
xoops_cp_header();
xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
xoops_cp_footer();
exit();
}
*/
$block = new XoopsBlock($bid);
$clone =& $block->xoopsClone();
$clone->setVar('side', $bside);
$clone->setVar('weight', $bweight);
$clone->setVar('visible', $bvisible);
$clone->setVar('content', $bcontent);
$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);
// Custom block
if ($block->isCustom()) {
$clone->setVar('block_type', 'C');
// Clone of system or module block
} else {
$clone->setVar('block_type', 'D');
}
$newid = $clone->store();
if (!$newid) {
xoops_cp_header();
$clone->getHtmlErrors();
xoops_cp_footer();
exit;
}
if ($clone->getVar('template') != '') {
$tplfile_handler =& xoops_gethandler('tplfile');
$btemplate = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
if (count($btemplate) > 0) {
$tplclone =& $btemplate[0]->xoopsClone();
$tplclone->setVar('tpl_id', 0);
$tplclone->setVar('tpl_refid', $newid);
$tplfile_handler->insert($tplclone);
}
}
$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);
}
$groupperm_handler =& xoops_gethandler('groupperm');
foreach ($bgroups as $groupid) {
$groupperm_handler->addRight("block_read", $newid, $groupid);
}
redirect_header('admin.php?fct=blocksadmin&t=' . time(), 1, _AM_DBUPDATED);
}