Exemplo n.º 1
0
/**
* Save the item(s) to the menu selected
*/
function copySectionSave($sectionid)
{
    global $database;
    josSpoofCheck();
    $title = stripslashes(strval(mosGetParam($_REQUEST, 'title', '')));
    $categories = josGetArrayInts('category', $_REQUEST, array(0));
    $items = josGetArrayInts('content', $_REQUEST, array(0));
    // create new section
    $section = new mosSection($database);
    $section->id = null;
    $section->title = $title;
    $section->name = $title;
    $section->scope = 'content';
    $section->published = 1;
    if (!$section->check()) {
        echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$section->store()) {
        echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $section->checkin();
    $newSectionId = $section->id;
    // new section created, now copy categories
    // old/new category lookup array
    $newOldCatLookup = array();
    foreach ($categories as $categoryId) {
        $category = new mosCategory($database);
        $category->load($categoryId);
        $category->id = null;
        $category->section = $newSectionId;
        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();
        $newOldCatLookup[$categoryId] = $category->id;
    }
    // categories copied, now copy content items
    foreach ($items as $itemId) {
        $item = new mosContent($database);
        $item->load($itemId);
        $item->id = null;
        $item->catid = $newOldCatLookup[$item->catid];
        $item->sectionid = $newSectionId;
        if (!$item->check()) {
            echo "<script> alert('" . $item->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$item->store()) {
            echo "<script> alert('" . $item->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $item->checkin();
    }
    $msg = 'Selected sections content copied into ' . $title . ' section.';
    mosRedirect('index2.php?option=com_sections&scope=content&mosmsg=' . $msg);
}
Exemplo n.º 2
0
function menuLink($option)
{
    global $database;
    global $adminLanguage;
    $category = new mosCategory($database);
    $category->bind($_POST);
    $category->checkin();
    $redirect = mosGetParam($_POST, 'redirect', '');
    $menu = mosGetParam($_POST, 'menuselect', '');
    $name = mosGetParam($_POST, 'link_name', '');
    $id = mosGetParam($_POST, 'id', '');
    $sectionid = mosGetParam($_POST, 'sectionid', '');
    $type = mosGetParam($_POST, 'link_type', '');
    switch ($type) {
        case 'content_category':
            $link = 'index.php?option=com_content&task=category&sectionid=' . $sectionid . '&id=' . $id;
            $menutype = 'Category Table';
            break;
        case 'content_blog_category':
            $link = 'index.php?option=com_content&task=blogcategory&id=' . $id;
            $menutype = 'Category Blog';
            break;
        case 'content_archive_category':
            $link = 'index.php?option=com_content&task=archivecategory&id=' . $id;
            $menutype = 'Category 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("section='" . $sectionid . "'");
    $msg = $name . ' ( ' . $menutype . ' ) in menu: ' . $menu . ' successfully created';
    mosRedirect('index2.php?option=' . $option . '&section=' . $redirect, $msg);
}
Exemplo n.º 3
0
/**
* Save the item(s) to the menu selected
*/
function copySectionSave($option, $sectionid, $sectionID)
{
    global $database, $adminLanguage;
    $title = mosGetParam($_REQUEST, 'title', '');
    $contentid = mosGetParam($_REQUEST, 'content', '');
    $categoryid = mosGetParam($_REQUEST, 'category', '');
    $total = count($contentid);
    $sectionids = implode(',', $sectionid);
    $section = new mosSection($database);
    foreach ($sectionid as $id) {
        $section->load($id);
        $section->id = NULL;
        $section->title = $title;
        $section->name = $title;
        if (!$section->check()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$section->store()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $section->checkin();
        $section->updateOrder("section='" . $section->id . "'");
        // stores original catid
        $newsectids[]["old"] = $id;
        // pulls new catid
        $newsectids[]["new"] = $section->id;
    }
    $category = new mosCategory($database);
    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()) {
            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();
        $category->updateOrder("section='" . $category->section . "'");
        // 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->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()) {
            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();
    }
    $sectionOld = new mosSection($database);
    $sectionOld->load($sectionMove);
    $msg = $adminLanguage->A_COMP_SECTION . " " . $sectionOld->name . " " . $adminLanguage->A_COMP_SECT_AND_ALL . " " . $title;
    mosRedirect('index2.php?option=com_sections&scope=content&mosmsg=' . $msg);
}
Exemplo n.º 4
0
/**
* Publishes or Unpublishes one or more categories
*
* @param string $ The name of the category section
* @param integer $ A unique category id (passed from an edit form)
* @param array $ An array of unique category id numbers
* @param integer $ 0 if unpublishing, 1 if publishing
* @param string $ The name of the current user
*/
function publishCategories($section, $categoryid = null, $cid = null, $publish = 1)
{
    DOCMAN_token::check() or die('Invalid Token');
    global $database, $my;
    if (!is_array($cid)) {
        $cid = array();
    }
    if ($categoryid) {
        $cid[] = $categoryid;
    }
    if (count($cid) < 1) {
        $action = $publish ? _PUBLISH : _DML_UNPUBLISH;
        echo "<script> alert('" . _DML_SELECTCATTO . " {$action}'); window.history.go(-1);</script>\n";
        exit;
    }
    $cids = implode(',', $cid);
    $query = "UPDATE #__categories SET published={$publish}" . "\n WHERE id IN ({$cids}) AND (checked_out=0 OR (checked_out={$my->id}))";
    $database->setQuery($query);
    if (!$database->query()) {
        echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (count($cid) == 1) {
        $row = new mosCategory($database);
        $row->checkin($cid[0]);
    }
    mosRedirect('index2.php?option=com_docman&section=categories');
}
Exemplo n.º 5
0
function menuLink($id)
{
    global $database;
    josSpoofCheck();
    $category = new mosCategory($database);
    $category->bind($_POST);
    $category->checkin();
    $redirect = strval(mosGetParam($_POST, 'redirect', ''));
    $menu = stripslashes(strval(mosGetParam($_POST, 'menuselect', '')));
    $name = strval(mosGetParam($_POST, 'link_name', ''));
    $sectionid = mosGetParam($_POST, 'sectionid', '');
    $type = strval(mosGetParam($_POST, 'link_type', ''));
    $name = stripslashes(ampReplace($name));
    switch ($type) {
        case 'content_category':
            $link = 'index.php?option=com_content&task=category&sectionid=' . $sectionid . '&id=' . $id;
            $menutype = 'Content Category Table';
            break;
        case 'content_blog_category':
            $link = 'index.php?option=com_content&task=blogcategory&id=' . $id;
            $menutype = 'Content Category Blog';
            break;
        case 'content_archive_category':
            $link = 'index.php?option=com_content&task=archivecategory&id=' . $id;
            $menutype = 'Content Category Blog Archive';
            break;
        case 'contact_category_table':
            $link = 'index.php?option=com_contact&catid=' . $id;
            $menutype = 'Contact Category Table';
            break;
        case 'newsfeed_category_table':
            $link = 'index.php?option=com_newsfeeds&catid=' . $id;
            $menutype = 'Newsfeed Category Table';
            break;
        case 'weblink_category_table':
            $link = 'index.php?option=com_weblinks&catid=' . $id;
            $menutype = 'Weblink Category Table';
            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 ($type == 'content_blog_category') {
        $row->params = 'categoryid=' . $id;
    }
    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("menutype = " . $database->Quote($menu));
    if ($redirect == 'content') {
        // clean any existing cache files
        mosCache::cleanCache('com_content');
    }
    $msg = $name . ' ( ' . $menutype . ' ) in menu: ' . $menu . ' successfully created';
    mosRedirect('index2.php?option=com_categories&section=' . $redirect . '&task=editA&hidemainmenu=1&id=' . $id, $msg);
}
Exemplo n.º 6
0
/**
* Save the item(s) to the menu selected
*/
function copySectionSave($sectionid)
{
    global $database;
    $title = mosGetParam($_REQUEST, 'title', '');
    $contentid = mosGetParam($_REQUEST, 'content', '');
    $categoryid = mosGetParam($_REQUEST, 'category', '');
    // copy section
    $section = new mosSection($database);
    foreach ($sectionid as $id) {
        $section->load($id);
        $section->id = NULL;
        $section->title = $title;
        $section->name = $title;
        if (!$section->check()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$section->store()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $section->checkin();
        $section->updateOrder("section='" . $section->id . "'");
        // stores original catid
        $newsectids[]["old"] = $id;
        // pulls new catid
        $newsectids[]["new"] = $section->id;
    }
    $sectionMove = $section->id;
    // copy categories
    $category = new mosCategory($database);
    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()) {
            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();
        $category->updateOrder("section='" . $category->section . "'");
        // 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->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()) {
            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();
    }
    $sectionOld = new mosSection($database);
    $sectionOld->load($sectionMove);
    $msg = sprintf(T_('Section %s and all its Categories and Items have been copied as %s'), $sectionOld->name, $title);
    mosRedirect('index2.php?option=com_sections&scope=content&mosmsg=' . $msg);
}
Exemplo n.º 7
0
function menuLink($id)
{
    global $database;
    $category = new mosCategory($database);
    $category->bind($_POST);
    $category->checkin();
    $redirect = mosGetParam($_POST, 'redirect', '');
    $menu = mosGetParam($_POST, 'menuselect', '');
    $name = mosGetParam($_POST, 'link_name', '');
    $sectionid = mosGetParam($_POST, 'sectionid', '');
    $type = mosGetParam($_POST, 'link_type', '');
    switch ($type) {
        case 'content_category':
            $link = 'index.php?option=com_content&task=category&sectionid=' . $sectionid . '&id=' . $id;
            $menutype = T_('Content Category Table');
            break;
        case 'content_blog_category':
            $link = 'index.php?option=com_content&task=blogcategory&id=' . $id;
            $menutype = T_('Content Category Blog');
            break;
        case 'content_archive_category':
            $link = 'index.php?option=com_content&task=archivecategory&id=' . $id;
            $menutype = T_('Content Category Blog Archive');
            break;
        case 'contact_category_table':
            $link = 'index.php?option=com_contact&catid=' . $id;
            $menutype = T_('Contact Category Table');
            break;
        case 'newsfeed_category_table':
            $link = 'index.php?option=com_newsfeeds&catid=' . $id;
            $menutype = T_('News Feed Category Table');
            break;
        case 'weblink_category_table':
            $link = 'index.php?option=com_weblinks&catid=' . $id;
            $menutype = T_('Web Link Category Table');
            break;
        default:
    }
    $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("menutype='" . $menu . "'");
    $msg = sprintf(T_('%s ( %s ) in menu: %s successfully created'), $name, $menutype, $menu);
    mosRedirect('index2.php?option=com_categories&section=' . $redirect . '&task=editA&hidemainmenu=1&id=' . $id, $msg);
}