Minahito
minah****@users*****
2005年 12月 30日 (金) 17:21:52 JST
Index: xoops2jp/html/kernel/block.php diff -u xoops2jp/html/kernel/block.php:1.2.8.3 xoops2jp/html/kernel/block.php:1.2.8.4 --- xoops2jp/html/kernel/block.php:1.2.8.3 Tue Dec 27 19:35:50 2005 +++ xoops2jp/html/kernel/block.php Fri Dec 30 17:21:52 2005 @@ -1,5 +1,5 @@ <?php -// $Id: block.php,v 1.2.8.3 2005/12/27 10:35:50 minahito Exp $ +// $Id: block.php,v 1.2.8.4 2005/12/30 08:21:52 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -254,9 +254,10 @@ * write a new block into the database * * @param object XoopsBlock $block reference to the block to insert + * @param $autolink temp * @return bool TRUE if succesful **/ - function insert(&$block) + function insert(&$block, $autolink=false) { if (strtolower(get_class($block)) != 'xoopsblock') { return false; @@ -270,7 +271,11 @@ foreach ($block->cleanVars as $k => $v) { ${$k} = $v; } + + $isNew = false; + if ($block->isNew()) { + $isNew = true; $bid = $this->db->genId('newblocks_bid_seq'); $sql = sprintf("INSERT INTO %s (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified) VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %u, %u, %u, '%s', '%s', %u, '%s', '%s', '%s', '%s', '%s', %u, %u)", $this->db->prefix('newblocks'), $bid, $mid, $func_num, $options, $name, $title, $content, $side, $weight, $visible, $block_type, $c_type, 1, $dirname, $func_file, $show_func, $edit_func, $template, $bcachetime, time()); } else { @@ -283,6 +288,15 @@ $bid = $this->db->getInsertId(); } $block->assignVar('bid', $bid); + + // + // $autolink is temp variable. + // + if ($isNew && $autolink) { + $link_sql = "INSERT INTO " . $this->db->prefix('block_module_link') . " (block_id, module_id) VALUES (${bid}, -1)"; + return $this->db->query($sql); + } + return true; }