/** * Save the item(s) to the menu selected */ function copySectionSave($sectionid, $scope) { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $db =& JFactory::getDBO(); $title = JRequest::getString('title'); $contentid = JRequest::getVar('content'); $categoryid = JRequest::getVar('category'); JArrayHelper::toInteger($contentid); JArrayHelper::toInteger($categoryid); // copy section $section =& JTable::getInstance('section'); foreach ($sectionid as $id) { $section->load($id); $section->id = NULL; $section->title = $title; $section->name = $title; if (!$section->check()) { copySectionSelect('com_sections', $sectionid, $scope); JError::raiseWarning(500, $section->getError()); return; } if (!$section->store()) { JError::raiseError(500, $section->getError()); } $section->checkin(); $section->reorder('scope = ' . $db->Quote($section->scope)); // stores original catid $newsectids[]["old"] = $id; // pulls new catid $newsectids[]["new"] = $section->id; } $sectionMove = $section->id; // copy categories $category =& JTable::getInstance('category'); foreach ($categoryid as $id) { $category->load($id); $category->id = NULL; $category->section = $sectionMove; foreach ($newsectids as $newsectid) { if ($category->section == $newsectid["old"]) { $category->section = $newsectid["new"]; } } if (!$category->check()) { JError::raiseError(500, $category->getError()); } if (!$category->store()) { JError::raiseError(500, $category->getError()); } $category->checkin(); $category->reorder('section = ' . $db->Quote($category->section)); // stores original catid $newcatids[]["old"] = $id; // pulls new catid $newcatids[]["new"] = $category->id; } $content =& JTable::getInstance('content'); foreach ($contentid as $id) { $content->load($id); $content->id = NULL; $content->hits = 0; foreach ($newsectids as $newsectid) { if ($content->sectionid == $newsectid["old"]) { $content->sectionid = $newsectid["new"]; } } foreach ($newcatids as $newcatid) { if ($content->catid == $newcatid["old"]) { $content->catid = $newcatid["new"]; } } if (!$content->check()) { JError::raiseError(500, $content->getError()); } if (!$content->store()) { JError::raiseError(500, $content->getError()); } $content->checkin(); } $sectionOld =& JTable::getInstance('section'); $sectionOld->load($sectionMove); $msg = JText::sprintf('DESCCATANDITEMSCOPIED', $sectionOld->name, $title); $mainframe->redirect('index.php?option=com_sections&scope=content', $msg); }
break; case 'editA': editSection($id, '', $option); break; case 'go2menu': case 'go2menuitem': case 'menulink': case 'save': case 'apply': saveSection($option, $scope, $task); break; case 'remove': removeSections($cid, $scope, $option); break; case 'copyselect': copySectionSelect($option, $cid, $section); break; case 'copysave': copySectionSave($cid); break; case 'publish': publishSections($scope, $cid, 1, $option); break; case 'unpublish': publishSections($scope, $cid, 0, $option); break; case 'cancel': cancelSection($option, $scope); break; case 'orderup': orderSection(intval($cid[0]), -1, $option, $scope);