コード例 #1
0
ファイル: blockHandlerTest.php プロジェクト: RanLee/XoopsCore
 public function test_insertBlock()
 {
     $block = new XoopsBlock();
     $block->setNew();
     $instance = new XoopsBlockHandler($this->conn);
     $value = $instance->insertBlock($block);
     $bid = $block->bid();
     $this->assertEquals($bid, $value);
     $value = $instance->get($bid);
     $this->assertEquals($bid, $value->bid());
     $value = $instance->deleteBlock($block);
     $this->assertSame(true, $value);
     $value = $instance->get($bid);
     $this->assertSame(null, $value);
 }
コード例 #2
0
ファイル: block.php プロジェクト: geekwright/XoopsCore25
 /**
  * create a new block
  *
  * @see XoopsBlock
  * @param  bool $isNew is the new block new??
  * @return XoopsBlock XoopsBlock reference to the new block
  **/
 public function create($isNew = true)
 {
     $block = new XoopsBlock();
     if ($isNew) {
         $block->setNew();
     }
     return $block;
 }
コード例 #3
0
 if (empty($_POST['options'])) {
     $options = array();
 } else {
     if (is_array($_POST['options'])) {
         $options = $_POST['options'];
     } else {
         $options = explode('|', $_POST['options']);
     }
 }
 // for backward compatibility
 // $cblock =& $block->clone(); or $cblock =& $block->xoopsClone();
 $cblock = new XoopsBlock();
 foreach ($block->vars as $k => $v) {
     $cblock->assignVar($k, $v['value']);
 }
 $cblock->setNew();
 $myts =& MyTextSanitizer::getInstance();
 $cblock->setVar('side', $_POST['bside']);
 $cblock->setVar('weight', $_POST['bweight']);
 $cblock->setVar('visible', $_POST['bvisible']);
 $cblock->setVar('title', $_POST['btitle']);
 $cblock->setVar('content', @$_POST['bcontent']);
 $cblock->setVar('c_type', @$_POST['bctype']);
 $cblock->setVar('bcachetime', $_POST['bcachetime']);
 if (isset($options) && count($options) > 0) {
     $options = implode('|', $options);
     $cblock->setVar('options', $options);
 }
 $cblock->setVar('bid', 0);
 $cblock->setVar('block_type', $block_type == 'C' ? 'C' : 'D');
 $cblock->setVar('func_num', 255);
コード例 #4
0
 function do_edit($bid)
 {
     $bid = intval($bid);
     if ($bid <= 0) {
         // new custom block
         $new_block = new XoopsBlock();
         $new_block->setNew();
         $new_block->setVar('name', $this->get_blockname_from_ctype('C'));
         $new_block->setVar('block_type', 'C');
         $new_block->setVar('func_num', 0);
         $bid = $new_block->store();
         $request = $this->fetchRequest4Block(0);
         // permission copy
         foreach ($GLOBALS['xoopsUser']->getGroups() as $gid) {
             $sql = "INSERT INTO " . $this->db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ({$gid}, {$bid}, 1, 'block_read')";
             $this->db->query($sql);
         }
     } else {
         $request = $this->fetchRequest4Block($bid);
     }
     // update the block by the request
     $msg = $this->update_block($bid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array());
     // block_module_link update
     $this->updateBlockModuleLink($bid, $request['bmodule']);
     // group_permission update
     $this->updateBlockReadGroupPerm($bid, $request['bgroup']);
     return $msg;
 }