Example #1
0
/**
* Save the item(s) to the menu selected
*/
function copyCategorySave($cid, $sectionOld)
{
    global $mainframe;
    // Check for request forgeries
    JRequest::checkToken() or die('Invalid Token');
    // Initialize variables
    $db =& JFactory::getDBO();
    $sectionMove = JRequest::getInt('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');
        copyCategorySelect('com_categories', $cid, $sectionOld);
        JError::raiseWarning(500, $msg);
        return;
    }
    $contentid = JRequest::getVar('item', null, '', 'array');
    JArrayHelper::toInteger($contentid);
    $category =& JTable::getInstance('category');
    foreach ($cid as $id) {
        $category->load($id);
        $category->id = NULL;
        $category->title = JText::sprintf('Copy of', $category->title);
        $category->name = JText::sprintf('Copy of', $category->name);
        $category->section = $sectionMove;
        if (!$category->check()) {
            JError::raiseError(500, $category->getError());
        }
        if (!$category->store()) {
            JError::raiseError(500, $category->getError());
        }
        $category->checkin();
        // 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->sectionid = $sectionMove;
        $content->hits = 0;
        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();
    }
    $sectionNew =& JTable::getInstance('section');
    $sectionNew->load($sectionMove);
    $msg = JText::sprintf('Categories copied to', count($cid), $sectionNew->title);
    $mainframe->redirect('index.php?option=com_categories&section=' . $sectionOld, $msg);
}
Example #2
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);
        break;
    case "publish":
        publishCategories($section, $id, $cid, 1);
        break;
    case "unpublish":
        publishCategories($section, $id, $cid, 0);