/** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu($uid, $access, $option, $section) { global $database; $row = new mosCategory($database); $row->load($uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } mosRedirect('index2.php?option=com_categories§ion=' . $section); }
/** * 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); }
/** * 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); }
function saveOrder(&$cid, $section) { global $database; josSpoofCheck(); $total = count($cid); $order = josGetArrayInts('order'); $row = new mosCategory($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 = "section=" . $database->Quote($row->section); $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 if ($section == 'content') { // clean any existing cache files mosCache::cleanCache('com_content'); } $msg = 'New ordering saved'; mosRedirect('index2.php?option=com_categories§ion=' . $section, $msg); }
/** * 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); }
function saveOrder(&$cid, $section) { global $database; $order = mosGetParam($_POST, 'order', array(0)); $row = new mosCategory($database); $sections = array(); // update ordering values foreach ($cid as $i => $ciditem) { $row->load($ciditem); if ($row->ordering != $order[$i]) { $row->ordering = $order[$i]; if (!$row->store()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } // remember to updateOrder this group $sections[$row->section] = $row->id; } } // execute updateOrder for each group foreach ($sections as $sectionid => $rowid) { $row->updateOrder("section='{$sectionid}'"); } // foreach $msg = T_('New ordering saved'); mosRedirect('index2.php?option=com_categories§ion=' . $section, $msg); }