예제 #1
0
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosSection($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "scope = " . $database->Quote($row->scope);
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'New ordering saved';
    mosRedirect('index2.php?option=com_sections&scope=content', $msg);
}
예제 #2
0
/**
* Save the item(s) to the menu selected
*/
function copyCategorySave($option, $cid, $sectionOld)
{
    global $database, $my;
    global $adminLanguage;
    $sectionMove = mosGetParam($_REQUEST, 'sectionmove', '');
    $contentid = mosGetParam($_REQUEST, 'item', '');
    $total = count($contentid);
    $category = new mosCategory($database);
    foreach ($cid as $id) {
        $category->load($id);
        $category->id = NULL;
        $category->title = $adminLanguage->A_COMP_CATEG_COPY_OF . " " . $category->title;
        $category->name = $adminLanguage->A_COMP_CATEG_COPY_OF . " " . $category->name;
        $category->section = $sectionMove;
        if (!$category->check()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$category->store()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $category->checkin();
        // stores original catid
        $newcatids[]["old"] = $id;
        // pulls new catid
        $newcatids[]["new"] = $category->id;
    }
    $content = new mosContent($database);
    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()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$content->store()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $content->checkin();
    }
    $sectionNew = new mosSection($database);
    $sectionNew->load($sectionMove);
    $msg = $total . " " . $adminLanguage->A_COMP_CATEG_COPIED_TO . " " . $sectionNew->name;
    mosRedirect('index2.php?option=com_categories&section=' . $sectionOld . '&mosmsg=' . $msg);
}
예제 #3
0
파일: admin.content.php 프로젝트: cwcw/cms
/**
* Shows a list of archived content items
* @param int The section id
*/
function viewArchive($sectionid, $option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $catid = $mainframe->getUserStateFromRequest("catidarc{$option}{$sectionid}", 'catid', 0);
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("viewarc{$option}{$sectionid}limitstart", 'limitstart', 0);
    $search = $mainframe->getUserStateFromRequest("searcharc{$option}{$sectionid}", 'search', '');
    $filter_sectionid = $mainframe->getUserStateFromRequest("filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0);
    $search = $database->getEscaped(trim(strtolower($search)));
    $redirect = $sectionid;
    if ($sectionid == 0) {
        $where = array("c.state = -1", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'");
        $filter = "\n , #__sections AS s WHERE s.id = c.section";
        $all = 1;
    } else {
        $where = array("c.state = -1", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'", "c.sectionid='{$sectionid}'");
        $filter = "\n WHERE section = '{$sectionid}'";
        $all = NULL;
    }
    // used by filter
    if ($filter_sectionid > 0) {
        $where[] = "c.sectionid = '{$filter_sectionid}'";
    }
    if ($catid > 0) {
        $where[] = "c.catid='{$catid}'";
    }
    if ($search) {
        $where[] = "LOWER(c.title) LIKE '%{$search}%'";
    }
    // get the total number of records
    $query = "SELECT count(*)" . "FROM #__content AS c, #__categories AS cc, #__sections AS s" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '');
    $database->setQuery($query);
    $total = $database->loadResult();
    require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    $query = "SELECT c.*, g.name AS groupname, cc.name" . "\n FROM #__content AS c, #__categories AS cc, #__sections AS s" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : '') . "\n ORDER BY c.catid, c.ordering" . "\n LIMIT {$pageNav->limitstart},{$pageNav->limit}";
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    // get list of categories for dropdown filter
    $query = "SELECT c.id AS value, c.title AS text" . "\n FROM #__categories AS c" . $filter . "\n ORDER BY c.ordering";
    $lists['catid'] = filterCategory($query, $catid);
    // get list of sections for dropdown filter
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['sectionid'] = mosAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript);
    $section = new mosSection($database);
    $section->load($sectionid);
    HTML_content::showArchive($rows, $section, $lists, $search, $pageNav, $option, $all, $redirect);
}
예제 #4
0
파일: content.php 프로젝트: cwcw/cms
function BlogOutput(&$rows, &$params, $gid, &$access, $pop, &$menu, $archive = NULL)
{
    global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site;
    // parameters
    if ($params->get('page_title', 1)) {
        $header = $params->def('header', $menu->name);
    } else {
        $header = '';
    }
    $columns = $params->def('columns', 2);
    if ($columns == 0) {
        $columns = 1;
    }
    $intro = $params->def('intro', 4);
    $leading = $params->def('leading', 1);
    $links = $params->def('link', 4);
    $pagination = $params->def('pagination', 2);
    $pagination_results = $params->def('pagination_results', 1);
    $pagination_results = $params->def('pagination_results', 1);
    $descrip = $params->def('description', 1);
    $descrip_image = $params->def('description_image', 1);
    // needed for back button for page
    $back = $params->get('back_button', $mainframe->getCfg('back_button'));
    // needed to disable back button for item
    $params->set('back_button', 0);
    $params->def('pageclass_sfx', '');
    $params->set('intro_only', 1);
    $total = count($rows);
    // pagination support
    $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0));
    $limit = $intro + $leading + $links;
    if ($total <= $limit) {
        $limitstart = 0;
    }
    $i = $limitstart;
    // needed to reduce queries used by getItemid
    $ItemidCount['bs'] = $mainframe->getBlogSectionCount();
    $ItemidCount['bc'] = $mainframe->getBlogCategoryCount();
    $ItemidCount['gbs'] = $mainframe->getGlobalBlogSectionCount();
    // used to display section/catagory description text and images
    // currently not supported in Archives
    if ($menu->componentid && ($descrip || $descrip_image)) {
        switch ($menu->type) {
            case 'content_blog_section':
                $description = new mosSection($database);
                $description->load($menu->componentid);
                break;
            case 'content_blog_category':
                $description = new mosCategory($database);
                $description->load($menu->componentid);
                break;
            case 'content_blog_category':
            case 'components':
            default:
                $menu->componentid = 0;
                break;
        }
    }
    // Page Output
    // page header
    if ($header) {
        echo '<div class="componentheading' . $params->get('pageclass_sfx') . '">' . $header . '</div>';
    }
    if ($archive) {
        echo '<br />';
        echo mosHTML::monthSelectList('month', 'size="1" class="inputbox"', $params->get('month'));
        echo mosHTML::integerSelectList(2000, 2010, 1, 'year', 'size="1" class="inputbox"', $params->get('year'), "%04d");
        echo '<input type="submit" class="button" />';
    }
    // checks to see if there are there any items to display
    if ($total) {
        $col_with = 100 / $columns;
        // width of each column
        $width = 'width="' . $col_with . '%"';
        if ($archive) {
            // Search Success message
            $msg = sprintf(_ARCHIVE_SEARCH_SUCCESS, $params->get('month'), $params->get('year'));
            echo "<br /><br /><div align='center'>" . $msg . "</div><br /><br />";
        }
        echo '<table class="' . $params->get('pageclass_sfx') . '" cellpadding="0" cellspacing="0">';
        // Secrion/Category Description & Image
        if ($menu->componentid && ($descrip || $descrip_image)) {
            $link = $mosConfig_live_site . '/images/stories/' . $description->image;
            echo '<tr>';
            echo '<td valign="top">';
            if ($descrip_image) {
                echo '<img src="' . $link . '" align="' . $description->image_position . '" hspace="6" alt="" />';
            }
            if ($descrip) {
                echo $description->description;
            }
            echo '<br/><br/>';
            echo '</td>';
            echo '</tr>';
        }
        // Leading story output
        if ($leading) {
            echo '<tr>';
            echo '<td valign="top">';
            for ($z = 0; $z < $leading; $z++) {
                if ($i >= $total) {
                    // stops loop if total number of items is less than the number set to display as leading
                    break;
                }
                echo '<div>';
                show($rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount);
                echo '</div>';
                $i++;
            }
            echo '</td>';
            echo '</tr>';
        }
        if ($intro && $i < $total) {
            echo '<tr>';
            echo '<td valign="top">';
            echo '<table width="100%"  cellpadding="0" cellspacing="0">';
            // intro story output
            for ($z = 0; $z < $intro; $z++) {
                if ($i >= $total) {
                    // stops loop if total number of items is less than the number set to display as intro + leading
                    break;
                }
                if (!($z % $columns) || $columns == 1) {
                    echo '<tr>';
                }
                echo '<td valign="top" ' . $width . '>';
                // outputs either intro or only a link
                if ($z < $intro) {
                    show($rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount);
                } else {
                    echo '</td>';
                    echo '</tr>';
                    break;
                }
                echo '</td>';
                if (!(($z + 1) % $columns) || $columns == 1) {
                    echo '</tr>';
                }
                $i++;
            }
            // this is required to output a final closing </tr> tag when the number of items does not fully
            // fill the last row of output - a blank column is left
            if ($intro % $columns) {
                echo '</tr>';
            }
            echo '</table>';
            echo '</td>';
            echo '</tr>';
        }
        // Links output
        if ($links && $i < $total) {
            echo '<tr>';
            echo '<td valign="top">';
            echo '<div class="blog_more' . $params->get('pageclass_sfx') . '">';
            HTML_content::showLinks($rows, $links, $total, $i, 1, $ItemidCount);
            echo '</div>';
            echo '</td>';
            echo '</tr>';
        }
        // Pagination output
        if ($pagination) {
            if ($pagination == 2 && $total <= $limit) {
                // not visible when they is no 'other' pages to display
            } else {
                // get the total number of records
                $limitstart = $limitstart ? $limitstart : 0;
                require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
                $pageNav = new mosPageNav($total, $limitstart, $limit);
                if ($option == 'com_frontpage') {
                    $link = 'index.php?option=com_frontpage&amp;Itemid=' . $Itemid;
                } else {
                    if ($archive) {
                        $year = $params->get('year');
                        $month = $params->get('month');
                        $link = 'index.php?option=com_content&amp;task=' . $task . '&amp;id=' . $id . '&amp;Itemid=' . $Itemid . '&amp;year=' . $year . '&amp;month=' . $month;
                    } else {
                        $link = 'index.php?option=com_content&amp;task=' . $task . '&amp;id=' . $id . '&amp;Itemid=' . $Itemid;
                    }
                }
                echo '<tr>';
                echo '<td valign="top" align="center">';
                echo $pageNav->writePagesLinks($link);
                echo '<br /><br />';
                echo '</td>';
                echo '</tr>';
                if ($pagination_results) {
                    echo '<tr>';
                    echo '<td valign="top" align="center">';
                    echo $pageNav->writePagesCounter();
                    echo '</td>';
                    echo '</tr>';
                }
            }
        }
        echo '</table>';
    } else {
        if ($archive && !$total) {
            // Search Failure message for Archives
            $msg = sprintf(_ARCHIVE_SEARCH_FAILURE, $params->get('month'), $params->get('year'));
            echo '<br /><br /><div align="center">' . $msg . '</div><br />';
        } else {
            // Generic blog empty display
            echo _EMPTY_BLOG;
        }
    }
    // Back Button
    $params->set('back_button', $back);
    mosHTML::BackButton($params);
}
예제 #5
0
파일: admin.sections.php 프로젝트: cwcw/cms
function menuLink($option)
{
    global $database, $adminLanguage;
    $section = new mosSection($database);
    $section->bind($_POST);
    $section->checkin();
    $menu = mosGetParam($_POST, 'menuselect', '');
    $name = mosGetParam($_POST, 'link_name', '');
    $id = mosGetParam($_POST, 'id', '');
    $type = mosGetParam($_POST, 'link_type', '');
    switch ($type) {
        case 'content_section':
            $link = 'index.php?option=com_content&task=section&id=' . $id;
            $menutype = 'Section Table';
            break;
        case 'content_blog_section':
            $link = 'index.php?option=com_content&task=blogsection&id=' . $id;
            $menutype = 'Section Blog';
            break;
        case 'content_archive_section':
            $link = 'index.php?option=com_content&task=archivesection&id=' . $id;
            $menutype = 'Section Blog Archive';
            break;
    }
    $row = new mosMenu($database);
    $row->menutype = $menu;
    $row->name = $name;
    $row->type = $type;
    $row->published = 1;
    $row->componentid = $id;
    $row->link = $link;
    $row->ordering = 9999;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder('scope="' . $row->scope . '"');
    $msg = $name . " ( " . $menutype . " ) " . $adminLanguage->A_COMP_SECT_IN_MENU . ": " . $menu . " " . $adminLanguage->A_COMP_CONTENT_SUCCESS;
    mosRedirect('index2.php?option=com_sections&scope=content', $msg);
}
예제 #6
0
/**
* Shows a list of archived content items
* @param int The section id
*/
function viewArchive($sectionid, $option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $catid = intval($mainframe->getUserStateFromRequest("catidarc{$option}{$sectionid}", 'catid', 0));
    $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit));
    $limitstart = intval($mainframe->getUserStateFromRequest("viewarc{$option}{$sectionid}limitstart", 'limitstart', 0));
    $filter_authorid = intval($mainframe->getUserStateFromRequest("filter_authorid{$option}{$sectionid}", 'filter_authorid', 0));
    $filter_sectionid = intval($mainframe->getUserStateFromRequest("filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0));
    $search = $mainframe->getUserStateFromRequest("searcharc{$option}{$sectionid}", 'search', '');
    if (get_magic_quotes_gpc()) {
        $search = stripslashes($search);
    }
    $redirect = $sectionid;
    if ($sectionid == 0) {
        $where = array("c.state \t= -1", "c.catid\t= cc.id", "cc.section = s.id", "s.scope  \t= 'content'");
        $filter = "\n , #__sections AS s WHERE s.id = c.section";
        $all = 1;
    } else {
        $where = array("c.state \t= -1", "c.catid\t= cc.id", "cc.section\t= s.id", "s.scope\t= 'content'", "c.sectionid= " . (int) $sectionid);
        $filter = "\n WHERE section = '" . (int) $sectionid . "'";
        $all = NULL;
    }
    // used by filter
    if ($filter_sectionid > 0) {
        $where[] = "c.sectionid = " . (int) $filter_sectionid;
    }
    if ($filter_authorid > 0) {
        $where[] = "c.created_by = " . (int) $filter_authorid;
    }
    if ($catid > 0) {
        $where[] = "c.catid = " . (int) $catid;
    }
    if ($search) {
        $where[] = "LOWER( c.title ) LIKE '%" . $database->getEscaped(trim(strtolower($search))) . "%'";
    }
    // get the total number of records
    $query = "SELECT COUNT(*)" . "\n FROM #__content AS c" . "\n LEFT JOIN #__categories AS cc ON cc.id = c.catid" . "\n LEFT JOIN #__sections AS s ON s.id = c.sectionid" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '');
    $database->setQuery($query);
    $total = $database->loadResult();
    require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    $query = "SELECT c.*, g.name AS groupname, cc.name, v.name AS author" . "\n FROM #__content AS c" . "\n LEFT JOIN #__categories AS cc ON cc.id = c.catid" . "\n LEFT JOIN #__sections AS s ON s.id = c.sectionid" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n LEFT JOIN #__users AS v ON v.id = c.created_by" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . "\n ORDER BY c.catid, c.ordering";
    $database->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return;
    }
    // get list of categories for dropdown filter
    $query = "SELECT c.id AS value, c.title AS text" . "\n FROM #__categories AS c" . $filter . "\n ORDER BY c.ordering";
    $lists['catid'] = filterCategory($query, $catid);
    // get list of sections for dropdown filter
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['sectionid'] = mosAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript);
    $section = new mosSection($database);
    $section->load((int) $sectionid);
    // get list of Authors for dropdown filter
    $query = "SELECT c.created_by, u.name" . "\n FROM #__content AS c" . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" . "\n WHERE c.state = -1" . "\n GROUP BY u.name" . "\n ORDER BY u.name";
    $authors[] = mosHTML::makeOption('0', _SEL_AUTHOR, 'created_by', 'name');
    $database->setQuery($query);
    $authors = array_merge($authors, $database->loadObjectList());
    $lists['authorid'] = mosHTML::selectList($authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid);
    HTML_content::showArchive($rows, $section, $lists, $search, $pageNav, $option, $all, $redirect);
}
예제 #7
0
/**
* Save the item(s) to the menu selected
*/
function copyCategorySave($cid, $sectionOld)
{
    global $database;
    josSpoofCheck();
    $sectionMove = intval(mosGetParam($_REQUEST, 'sectionmove', ''));
    if (!$sectionMove) {
        mosRedirect('index.php?option=com_categories&mosmsg=An error has occurred');
    }
    $contentid = josGetArrayInts('item', $_REQUEST);
    $total = count($contentid);
    $category = new mosCategory($database);
    foreach ($cid as $id) {
        $category->load((int) $id);
        $category->id = NULL;
        $category->title = 'Copy of ' . $category->title;
        $category->name = 'Copy of ' . $category->name;
        $category->section = $sectionMove;
        if (!$category->check()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$category->store()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $category->checkin();
        // stores original catid
        $newcatids[]["old"] = $id;
        // pulls new catid
        $newcatids[]["new"] = $category->id;
    }
    $content = new mosContent($database);
    foreach ($contentid as $id) {
        $content->load((int) $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()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$content->store()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $content->checkin();
    }
    $sectionNew = new mosSection($database);
    $sectionNew->load($sectionMove);
    if ($sectionOld == 'content') {
        // clean any existing cache files
        mosCache::cleanCache('com_content');
    }
    $msg = (count($cid) - 1 ? 'Categories' : 'Category') . ' copied to ' . $sectionNew->name;
    mosRedirect('index2.php?option=com_categories&section=' . $sectionOld . '&mosmsg=' . $msg);
}
예제 #8
0
function menuLink($id)
{
    global $database;
    $section = new mosSection($database);
    $section->bind($_POST);
    $section->checkin();
    $menu = mosGetParam($_POST, 'menuselect', '');
    $name = mosGetParam($_POST, 'link_name', '');
    $type = mosGetParam($_POST, 'link_type', '');
    switch ($type) {
        case 'content_section':
            $link = 'index.php?option=com_content&task=section&id=' . $id;
            $menutype = T_('Section Table');
            break;
        case 'content_blog_section':
            $link = 'index.php?option=com_content&task=blogsection&id=' . $id;
            $menutype = T_('Section Blog');
            break;
        case 'content_archive_section':
            $link = 'index.php?option=com_content&task=archivesection&id=' . $id;
            $menutype = T_('Section Blog Archive');
            break;
    }
    $row = new mosMenu($database);
    $row->menutype = $menu;
    $row->name = $name;
    $row->type = $type;
    $row->published = 1;
    $row->componentid = $id;
    $row->link = $link;
    $row->ordering = 9999;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder('scope="' . $row->scope . '"');
    $msg = sprintf(T_('%s ( %s ) in menu: %s successfully created'), $name, $menutype, $menu);
    mosRedirect('index2.php?option=com_sections&scope=content&task=editA&hidemainmenu=1&id=' . $id, $msg);
}
예제 #9
0
/**
* Save the item(s) to the menu selected
*/
function copyCategorySave($cid, $sectionOld)
{
    global $database;
    $sectionMove = mosGetParam($_REQUEST, 'sectionmove', '');
    $contentid = mosGetParam($_REQUEST, 'item', '');
    $total = count($contentid);
    $category = new mosCategory($database);
    foreach ($cid as $id) {
        $category->load($id);
        $category->id = NULL;
        $category->title = "Copy of " . $category->title;
        $category->name = "Copy of " . $category->name;
        $category->section = $sectionMove;
        if (!$category->check()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$category->store()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $category->checkin();
        // stores original catid
        $newcatids[]["old"] = $id;
        // pulls new catid
        $newcatids[]["new"] = $category->id;
    }
    $content = new mosContent($database);
    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()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$content->store()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $content->checkin();
    }
    $sectionNew = new mosSection($database);
    $sectionNew->load($sectionMove);
    $msg = sprintf(Tn_('%d Category copied to %s', '%d Categories copied to %s', $total), $total, $sectionNew->name);
    mosRedirect('index2.php?option=com_categories&section=' . $sectionOld . '&mosmsg=' . $msg);
}