11 define(
'RMCLOCATION',
'blocks');
12 include
'../../include/cp_header.php';
16 $mid = isset($_GET[
'mid']) ? intval($_GET[
'mid']) : 0;
17 $subpage = isset($_GET[
'subpage']) ? $_GET[
'subpage'] :
'';
18 $group = isset($_GET[
'group']) ? intval($_GET[
'group']) : 0;
19 $visible = isset($_GET[
'visible']) ? intval($_GET[
'visible']) : -1;
20 $pos = isset($_GET[
'pos']) ? intval($_GET[
'pos']) : -1;
29 $db = XoopsDatabaseFactory::getDatabaseConnection();
32 $tblw =
$db->prefix(
"rmc_blocks");
33 $tbll =
$db->prefix(
"rmc_bkmod");
34 $tblp =
$db->prefix(
"group_permission");
36 $sql =
"SELECT $tblw.* FROM $tblw ".($subpage!=
'' ||
$mid>0 ?
", $tbll" :
'').($group > 0 ?
", $tblp" :
'');
41 $sql .=
" WHERE ($tbll.mid='$mid' AND $tblw.bid=$tbll.bid ".($subpage!=
'' ?
" AND $tbll.subpage='$subpage'" :
'').
") ";
46 $sql .= $and ?
" AND " :
" WHERE ";
47 $sql .=
" ($tblp.gperm_itemid=$tblw.bid AND $tblp.gperm_name='rmblock_read' AND $tblp.gperm_groupid='$group')";
51 $sql .= $and ?
" AND " :
' WHERE ';
52 $sql .=
" $tblw.canvas='$pos'";
57 $sql .= $and ?
" AND " :
" WHERE ";
58 $sql .=
" $tblw.visible=$visible";
62 $sql .=
" ORDER BY weight";
71 define(
'RMCSUBLOCATION',
'blocks');
72 $db = XoopsDatabaseFactory::getDatabaseConnection();
81 $sql =
"SELECT groupid, name FROM " .
$db->prefix(
"groups") .
" ORDER BY name";
85 $groups[] = array(
'id' => $row[
'groupid'],
'name' => $row[
'name']);
94 $used_blocks = array();
98 $used_blocks[] = array(
100 'title' => $row[
'name'],
101 'module' => array(
'id' =>
$mod->mid(),
'dir' =>
$mod->dirname(),
'name' =>
$mod->name()),
102 'canvas' => $bpos[$row[
'canvas']],
103 'weight' => $row[
'weight'],
104 'visible'=>$row[
'visible'],
105 'active'=>$row[
'isactive'],
106 'type'=>$row[
'type'],
107 'options'=>$row[
'edit_func']!=
'' ? 1 : 0,
108 'description'=>$row[
'description']
114 $used_blocks =
RMEvents::get()->run_event(
'rmcommon.used.blocks.list', $used_blocks);
116 $positions = array();
117 foreach ($bpos as $row){
118 $positions[] = array(
119 'id' => $row[
'id_position'],
120 'name' => $row[
'name'],
121 'tag' => $row[
'tag'],
122 'active' => $row[
'active']
126 $positions =
RMEvents::get()->run_event(
'rmcommon.block.positions.list', $positions);
129 RMTemplate::get()->add_local_script(
'jquery.sort.js',
'rmcommon',
'include');
133 '</a> » ' .
__(
'Blocks',
'rmcommon'));
135 RMTemplate::get()->add_local_script(
'blocks.js',
'rmcommon',
'include');
136 RMTemplate::get()->add_local_script(
'jkmenu.js',
'rmcommon',
'include');
138 RMTemplate::get()->add_local_script(
'jquery-ui.min.js',
'rmcommon',
'include');
140 if(!$rmc_config[
'blocks_enable']){
141 showMessage(
__(
'Internal blocks manager is currenlty disabled!',
'rmcommon'), 0);
144 RMTemplate::get()->add_local_script(
'jquery.checkboxes.js',
'rmcommon',
'include');
145 RMTemplate::get()->add_head(
'<script type="text/javascript">var bks_message = "'.
__(
'Do you really wish to delete selected items?',
'rmcommon').
'";
146 var bks_select_message = "'.
__(
'Select at least one item to delete it!',
'rmcommon').
'";
147 var lang_save = "'.
__(
'Save',
'rmcommon').
'";
148 var lang_cancel = "'.
__(
'Cancel',
'rmcommon').
'";
149 var lang_positions = "'.
__(
'Show Positions',
'rmcommon').
'";
150 var lang_blocks = "'.
__(
'Show Blocks',
'rmcommon').
'";</script>');
160 foreach($blocks as
$id => $block){
161 if(empty($block[
'blocks']))
continue;
162 foreach($block[
'blocks'] as $bid => $val){
163 $str = isset($val[
'show_func']) ? $val[
'show_func'] :
'';
164 $str .= isset($val[
'edit_func']) ? $val[
'edit_func'] :
'';
165 $str .= isset($val[
'dir']) ? $val[
'dir'] :
$id;
166 $val[
'id'] = md5(
$str);
167 $blocks[
$id][
'blocks'][$bid] = $val;
172 $the_position = isset($_GET[
'pos']) ? intval($_GET[
'pos']) :
'';
176 $subpage = isset($_GET[
'subpage']) ? $_GET[
'subpage'] :
'';
177 $group = isset($_GET[
'group']) ? intval($_GET[
'group']) : 0;
181 include
RMTemplate::get()->get_template(
"rmc_blocks.php",
'module',
'rmcommon');
192 if (!$xoopsSecurity->check()){
193 redirectMsg(
'blocks.php',
__(
'You are not allowed to do this action!',
'rmcommon'), 1);
200 if($name==
'' || $tag==
''){
201 redirectMsg(
__(
'Please provide a name and tag for this new position!',
'rmcommon'));
209 redirectMsg(
'blocks.php',
__(
'You must specify a valid position ID!',
'rmcommon'), 1);
213 redirectMsg(
'blocks.php',
__(
'Specified position does not exists!',
'rmcommon'), 1);
219 $db = XoopsDatabaseFactory::getDatabaseConnection();
221 $pos->setVar(
'name',$name);
222 $pos->setVar(
'tag',$tag);
223 $pos->setVar(
'active',1);
225 $sql =
"SELECT COUNT(*) FROM ".$db->prefix(
"rmc_blocks_positions").
" WHERE name='$name' OR tag='$tag'";
226 if($edit)
$sql .=
" AND id_position<>$id";
231 redirectMsg(
'blocks.php',
__(
'Already exists another position with same name or same tag!',
'rmcommon'), 1);
234 redirectMsg(
'blocks.php?from=positions',
__(
'Database updated successfully!',
'rmcommon'));
236 redirectMsg(
'blocks.php',
__(
'Errors ocurred while trying to save data',
'rmcommon').
'<br />'.$pos->errors());
246 if (!$xoopsSecurity->check()){
247 redirectMsg(
'blocks.php',
__(
'You are not allowed to do this action!',
'rmcommon'), 1);
253 if(empty($ids) || !is_array($ids)){
254 redirectMsg(
'blocks.php',
__(
'Select at least a block!',
'rmcommon'), 1);
258 $db = XoopsDatabaseFactory::getDatabaseConnection();
259 $db->queryF(
"UPDATE ".
$db->prefix(
"rmc_blocks").
" SET visible=$s WHERE bid IN (".join(
",",$ids).
")");
261 if (
$db->error()==
''){
262 redirectMsg(
'blocks.php',
__(
'Database updated successfully',
'rmcommon'), 0);
264 redirectMsg(
'blocks.php',
__(
'Errors ocurred while trying to do this action',
'rmcommon').
'<br />'.
$db->error(), 1);
276 if (!$xoopsSecurity->check()){
277 redirectMsg(
'blocks.php',
__(
'You are not allowed to do this action!',
'rmcommon'), 1);
283 if(empty($ids) || !is_array($ids)){
284 redirectMsg(
'blocks.php',
__(
'You must select at least one block!',
'rmcommon'), 1);
289 foreach ($ids as
$id){
292 $block =
RMEvents::get()->run_event(
'rmcommon.deleting.block',$block);
293 if (!$block->delete()) $error .= $block->errors();
297 redirectMsg(
'blocks.php',
__(
'There was some errors:',
'rmcommon').
'<br />'.$error, 1);
299 redirectMsg(
'blocks.php',
__(
'Database updated successfully',
'rmcommon'), 0);
307 if (!$xoopsSecurity->check()){
308 redirectMsg(
'blocks.php?from=positions',
__(
'You are not allowed to do this action!',
'rmcommon'), 1);
314 if(empty($ids) || !is_array($ids)){
315 redirectMsg(
'blocks.php?from=positions',
__(
'You must select at least one position!',
'rmcommon'), 1);
320 foreach ($ids as
$id){
323 $pos =
RMEvents::get()->run_event(
'rmcommon.deleting.block.position',$pos);
324 if (!$pos->delete()) $error .= $pos->errors();
328 redirectMsg(
'blocks.php?from=positions',
__(
'There was some errors:',
'rmcommon').
'<br />'.$error, 1);
330 redirectMsg(
'blocks.php?from=positions',
__(
'Database updated successfully',
'rmcommon'), 0);
335 $action = isset($_REQUEST[
'action']) ? $_REQUEST[
'action'] :
'';
338 case 'save_position':
353 case 'upload-widget':