/** * @desc Modifica el orden de las secciones **/ function changeOrderSections() { global $xoopsSecurity, $xoopsModuleConfig; $orders = rmc_server_var($_POST, 'orders', array()); $id = rmc_server_var($_POST, 'id', 0); if ($xoopsModuleConfig['permalinks']) { $url_ret = RDfunctions::url() . '/list/' . $id . '/'; } else { $url_ret = RDFunctions::url() . '?page=edit&action=list&id=' . $id; } if (!$xoopsSecurity->check()) { redirect_header($url_ret, 0, __('Session token expired!', 'docs')); die; } if (!is_array($orders) || empty($orders)) { redirect_header($url_ret, 1, __('Sorry, the data provided contains some errors!', 'docs'), 1); die; } $errors = ''; foreach ($orders as $k => $v) { if ($k <= 0) { continue; } //Comprueba si la sección es existente $sec = new RDSection($k); if ($sec->isNew()) { continue; } $sec->setVar('order', $v); if (!$sec->save()) { $errors .= sprintf(__('Order could not be saved for section %s', 'docs'), $sec->getVar('title')) . '<br />'; } } if ($errors != '') { redirect_header($url_ret, 1, __('Errors ocurred while trying to update orders') . '<br />' . $errors); } else { redirect_header($url_ret, 0, __('Sections updated successfully!', 'docs')); } }