/** * Save the item(s) to the menu selected */ function moveCategorySave($cid, $sectionOld) { global $mainframe; // Check for request forgeries JRequest::checkToken() or die('Invalid Token'); $db =& JFactory::getDBO(); $sectionMove = JRequest::getCmd('sectionmove'); //Check to see of a section was selected to copy the items too if (!$sectionMove) { $msg = JText::_('Please select a section from the list'); moveCategorySelect('com_categories', $cid, $sectionOld); JError::raiseWarning(500, $msg); return; } JArrayHelper::toInteger($cid, array(0)); $sectionNew =& JTable::getInstance('section'); $sectionNew->load($sectionMove); //Remove the categories was in destination section $cids = implode(',', $cid); $query = 'SELECT id, title' . ' FROM #__categories' . ' WHERE id IN ( ' . $cids . ' )' . ' AND section = ' . $db->Quote($sectionMove); $db->setQuery($query); $scid = $db->loadResultArray(0); $title = $db->loadResultArray(1); $cid = array_diff($cid, $scid); // if (!empty($cid)) { $cids = implode(',', $cid); $total = count($cid); $query = 'UPDATE #__categories' . ' SET section = ' . $db->Quote($sectionMove) . ' WHERE id IN ( ' . $cids . ' )'; $db->setQuery($query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $query = 'UPDATE #__content' . ' SET sectionid = ' . $db->Quote($sectionMove) . ' WHERE catid IN ( ' . $cids . ' )'; $db->setQuery($query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $msg = JText::sprintf('Categories moved to', $sectionNew->title); $mainframe->enqueueMessage($msg); } if (!empty($title) && is_array($title)) { if (count($title) == 1) { $msg = JText::sprintf('Category already in', implode(',', $title), $sectionNew->title); } else { $msg = JText::sprintf('Categories already in', implode(',', $title), $sectionNew->title); } $mainframe->enqueueMessage($msg); } $mainframe->redirect('index.php?option=com_categories§ion=' . $sectionOld); }
require_once $mainframe->getPath('admin_html'); // get parameters from the URL or submitted form $section = mosGetParam($_REQUEST, 'section', ''); $cid = mosGetParam($_REQUEST, 'cid', array(0)); if (!is_array($cid)) { $cid = array(0); } switch ($task) { case "new": editCategory(0, $section); break; case "edit": editCategory(intval($cid[0])); break; case "moveselect": moveCategorySelect($option, $cid, $section); break; case "movesave": moveCategorySave($option, $cid, $section); break; case "copyselect": copyCategorySelect($option, $cid, $section); break; case "copysave": copyCategorySave($option, $cid, $section); break; case "save": saveCategory(); break; case "remove": removeCategories($section, $cid);