11 include
'../../../mainfile.php';
21 $data = array_merge(
$data, array(
'token'=>$xoopsSecurity->createToken()));
23 $data = array_merge(
$data, array(
'error'=>$error));
25 echo json_encode(
$data);
32 response(array(
'message'=>
__(
'Operation not allowed!',
'rmcommon')), 1, 0);
48 if (!$xoopsSecurity->check()){
49 response(array(
'message'=>
__(
'Sorry, you are not allowed to view this page',
'rmcommon')), 1, 0);
56 'message' =>
__(
'The block specified seems to be invalid. Please try again.',
'rmcommon')
64 response(array(
'message'=>
__(
'The specified module does not exists!',
'rmcommon')), 1, 0);
67 $module->loadInfoAsVar(
$mod);
68 $blocks = $module->getInfo(
'blocks');
69 $ms = $module->name().
'<br />';
71 foreach($blocks as $bk){
72 $str = isset($bk[
'show_func']) ? $bk[
'show_func'] :
'';
73 $str .= isset($bk[
'edit_func']) ? $bk[
'edit_func'] :
'';
74 $str .= isset($bk[
'dir']) ? $bk[
'dir'] :
$mod;
83 response(array(
'message'=>
__(
'The specified block does not exists, please verify your selection.',
'rmcommon')), 1, 1);
89 $db = XoopsDatabaseFactory::getDatabaseConnection();
91 $sql =
"SELECT id_position, name FROM ".$db->prefix(
"rmc_blocks_positions").
" ORDER BY id_position LIMIT 0, 1";
94 list($canvas, $canvas_name) =
$db->fetchRow(
$result);
97 $block->setReadGroups(array(0));
98 $block->setVar(
'name', $bk[
'name']);
99 $block->setVar(
'element',
$mod);
100 $block->setVar(
'element_type', $bk[
'plugin']==1 ?
'plugin' :
'module');
101 $block->setVar(
'canvas', $canvas);
102 $block->setVar(
'visible', 0);
103 $block->setVar(
'type', $bk[
'type']);
104 $block->setVar(
'isactive', 1);
105 $block->setVar(
'dirname', isset($bk[
'dir']) ? $bk[
'dir'] :
$mod);
106 $block->setVar(
'file', $bk[
'file']);
107 $block->setVar(
'show_func', $bk[
'show_func']);
108 $block->setVar(
'edit_func', $bk[
'edit_func']);
109 $block->setVar(
'description', $bk[
'description']);
110 $block->setVar(
'widget',
$id);
111 $block->setVar(
'options', is_array($bk[
'options']) ? serialize($bk[
'options']) : serialize(explode(
"|", $bk[
'options'])));
112 $block->setVar(
'template', $bk[
'template']);
113 $block->sections(array(0));
117 response(array(
'message'=>sprintf(
__(
'Block could not be created due to: %s. Please try again!',
'rmcommon'), $block->errors())), 1, 1);
126 'id' => $block->id(),
127 'name' => $block->getVar(
'name'),
128 'module' => $block->getVar(
'element'),
129 'description' => $block->getVar(
'description'),
130 'canvas' => $pos[$canvas],
131 'weight' => $block->getVar(
'weight'),
132 'message' =>
__(
'Block added successfully! Please configure it.',
'rmcommon')
145 if (!$xoopsSecurity->check()){
146 response(array(
'message'=>
__(
'Sorry, you are not allowed to view this page',
'rmcommon')), 1, 0);
154 response(array(
'message'=>
__(
'The block that you specified seems to be invalid. Please try again',
'rmcommon')), 1, 1);
159 response(array(
'message'=>
__(
'The block that you specified does not exists!. Please try again',
'rmcommon')), 1, 1);
163 $form =
new RMForm(
'',
'',
'');
164 $canvas =
new RMFormModules(
'',
'bk_mod', 1, 1, $block->sections(), 3, null,
false, 1);
167 $groups =
new RMFormGroups(
'',
'bk_groups',
true, 1, 3, $block->readGroups());
169 $block_options = $block->getOptions();
172 include
RMTemplate::get()->get_template(
'rmc_block_form.php',
'module',
'rmcommon');
173 $form = ob_get_clean();
188 foreach($_POST as $k => $v){
192 if(!$xoopsSecurity->check($XOOPS_TOKEN_REQUEST)){
193 response(array(
'message'=>
__(
'Session token expired. Please try again.',
'rmcommon')), 1, 0);
198 response(array(
'message'=>
__(
'You must provide a block ID!',
'rmcommon')), 1, 1);
204 response(array(
'message'=>
__(
'Specified block does not exists!',
'rmcommon')), 1, 1);
209 $block->setVar(
'name', $bk_name);
210 $block->setVar(
'canvas', $bk_pos);
211 $block->setVar(
'weight', $bk_weight);
212 $block->setVar(
'visible', $bk_visible);
213 $block->setVar(
'bcachetime', $bk_cache);
214 if(isset($bk_content)){
215 $block->setVar(
'content', $bk_content);
216 $block->setVar(
'content_type', $bk_ctype);
220 $block->sections($bk_mod);
222 $block->setReadGroups($bk_groups);
226 'message' =>
__(
'Block updated successfully!',
'rmcommon')
238 if(!$xoopsSecurity->check($XOOPS_TOKEN_REQUEST)){
239 response(array(
'message'=>
__(
'Session token expired. Please try again.',
'rmcommon')), 1, 0);
249 response(array(
'message'=>
__(
'Specified position is not valid!',
'rmcommon')), 1, 1);
253 if($name==
''||$tag==
''){
254 response(array(
'message'=>
__(
'You must fill name and tag input fields!',
'rmcommon')), 1, 1);
260 response(array(
'message'=>
__(
'Specified block position does not exists!',
'rmcommon')), 1, 1);
264 $db = XoopsDatabaseFactory::getDatabaseConnection();
265 $sql =
"SELECT COUNT(*) FROM ".$db->prefix(
"rmc_blocks_positions").
" WHERE (name='$name' OR tag='$tag') AND id_position<>$id";
270 response(array(
'message'=>
__(
'Already exists another block position with same name or tag!',
'rmcommon')), 1, 1);
274 $pos->setVar(
'name', $name);
275 $pos->setVar(
'tag', $tag);
276 $pos->setVar(
'active', $active);
279 response(array(
'message'=>
__(
'Changes saved successfully!',
'rmcommon')), 0, 1);
282 response(array(
'message'=>
__(
'Changes could not be saved!',
'rmcommon')), 1, 1);
294 if(!$xoopsSecurity->check())
295 response(array(
'message'=>
__(
'Session token expired!',
'rmcommon')), 1, 0);
300 response(array(
'message'=>
__(
'No items has been specified!',
'rmcommon')), 1, 1);
302 $db = XoopsDatabaseFactory::getDatabaseConnection();
305 foreach($item as
$id => $v){
306 $sql =
"UPDATE ".$db->prefix(
"rmc_blocks").
" SET weight=$i WHERE bid=$id";
311 showMessage(
__(
'Blocks order saved successfully!',
'rmcommon'), 0);
314 'message' =>
__(
'Changes saved successfully!',
'rmcommon')