/** * 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§ion=' . $sectionOld . '&mosmsg=' . $msg); }
/** * changes the access level of a record * @param integer The increment to reorder by */ function changeAccess($id, $access, $option) { global $database; josSpoofCheck(); $row = new mosContent($database); $row->load((int) $id); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } // clean any existing cache files mosCache::cleanCache('com_content'); mosRedirect('index2.php?option=' . $option); }
/** * 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); }
/** * changes the access level of a record * @param integer The increment to reorder by */ function changeAccess($id, $access, $option) { global $database; $row = new mosContent($database); $row->load($id); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } mosRedirect('index2.php?option=' . $option); }
/** * Saves the content item an edit form submit */ function saveContent(&$access) { global $database, $mainframe, $my; global $mosConfig_absolute_path; $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $isNew = $row->id < 1; if ($isNew) { // new record if (!($access->canEdit || $access->canEditOwn)) { mosNotAuth(); return; } $row->created = date('Y-m-d H:i:s'); $row->created_by = $my->id; } else { // existing record if (!($access->canEdit || $access->canEditOwn && $row->created_by == $my->id)) { mosNotAuth(); return; } $row->modified = date('Y-m-d H:i:s'); $row->modified_by = $my->id; } if (trim($row->publish_down) == 'Never') { $row->publish_down = '0000-00-00 00:00:00'; } if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->version++; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // manage frontpage items require_once $mainframe->getPath('class', 'com_frontpage'); $fp = new mosFrontPage($database); if (mosGetParam($_REQUEST, 'frontpage', 0)) { // toggles go to first place if (!$fp->load($row->id)) { // new entry $database->setQuery("INSERT INTO #__content_frontpage VALUES ('{$row->id}','1')"); if (!$database->query()) { echo "<script> alert('" . $database->stderr() . "');</script>\n"; exit; } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete($row->id)) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); $row->updateOrder("catid='{$row->catid}'"); // gets section name of item $database->setQuery("SELECT s.title" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n AND s.id = '" . $row->sectionid . "'"); // gets category name of item $section = $database->loadResult(); $database->setQuery("SELECT c.title" . "\n FROM #__categories AS c" . "\n WHERE c.id = '" . $row->catid . "'"); $category = $database->loadResult(); if ($isNew) { // messaging for new items require_once $mosConfig_absolute_path . '/components/com_messages/messages.class.php'; $database->setQuery("SELECT id FROM #__users WHERE sendEmail = '1'"); $users = $database->loadResultArray(); foreach ($users as $user_id) { $msg = new mosMessage($database); $msg->send($my->id, $user_id, "New Item", sprintf(_ON_NEW_CONTENT, $my->username, $row->title, $section, $category)); } } $Itemid = mosGetParam($_POST, 'Returnid', '0'); mosRedirect('index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $Itemid, $isNew ? _THANK_SUB : _E_ITEM_SAVED); }
function processStep4($option) { global $database; //Get hidden data $separator = mosGetParam($_REQUEST, 'separator', ','); $convertUTF8 = mosGetParam($_REQUEST, 'csv_utf8', 0); //fault here $fileName = mosGetParam($_REQUEST, 'filename', ''); $columns = mosGetParam($_REQUEST, 'columns', null); $fields = mosGetParam($_REQUEST, 'fields', null); $globalColumns = mosGetParam($_REQUEST, 'global_columns', null); $globalValues = mosGetParam($_REQUEST, 'global_value', null); //Get global setting $authorId = mosGetParam($_REQUEST, 'author_id', 0); $sectionId = mosGetParam($_REQUEST, 'section_id', 0); $categoryId = mosGetParam($_REQUEST, 'category_id', 0); $published = mosGetParam($_REQUEST, 'published', 0); $metaKeys = mosGetParam($_REQUEST, 'meta_keys', ''); $metaDes = mosGetParam($_REQUEST, 'meta_des', ''); $createdDate = mosGetParam($_REQUEST, 'created_date', ''); $publishUpDate = mosGetParam($_REQUEST, 'publish_up_date', ''); $publishDownDate = mosGetParam($_REQUEST, 'publish_down_date', ''); $access = mosGetParam($_REQUEST, 'access', 0); $state = mosGetParam($_REQUEST, 'state', 0); //Import data now, go to final step $rowContent = new mosContent($database); //Get all data $arrContentFieldName = array(); $arrContentFieldSTT = array(); $arrJreviewFieldName = array(); $arrJreviewFieldSTT = array(); $totalColumn = count($columns); //Mark the ignore field lists $arrIgnores = array(); for ($i = 0; $i < $totalColumn; $i++) { $column = $columns[$i]; $field = $fields[$i]; $arrField = explode(".", $field); $tableName = $arrField[0]; $fieldName = $arrField[1]; if ($fieldName != 'ignore') { if ($tableName == "jos_content") { $arrContentFieldName[$i] = $fieldName; $arrContentFieldSTT[] = $i; } else { $arrJreviewFieldName[$i] = $fieldName; $arrJreviewFieldSTT[] = $i; } } else { $arrIgnores[] = $i; } } //Set static content vaiable $arrGlobalSetting = array(); $arrGlobalSetting["created_by"] = $authorId; $arrGlobalSetting["sectionid"] = $sectionId; $arrGlobalSetting["catid"] = $categoryId; $arrGlobalSetting["published"] = $published; $arrGlobalSetting["metakey"] = $metaKeys; $arrGlobalSetting["metadesc"] = $metaDes; $arrGlobalSetting["created"] = $createdDate; $arrGlobalSetting["publish_up"] = $publishUpDate; $arrGlobalSetting["publish_down"] = $publishDownDate; $arrGlobalSetting["access"] = $access; $arrGlobalSetting["state"] = $state; //CustomGlobla Varaible $totalGlobalFields = count($globalColumns); $arrJreviewSettings = array(); for ($i = 0; $i < $totalGlobalFields; $i++) { $column = $globalColumns[$i]; $value = $globalValues[$i]; $arrField = explode(".", $column); $field = $arrField[1]; $arrJreviewSettings[$field] = $value; } //Attributes $params = mosGetParam($_POST, 'params', ''); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { if (get_magic_quotes_gpc()) { $v = stripslashes($v); } $txt[] = "{$k}={$v}"; } $attribs = implode("\n", $txt); } //Read the file here //Open File and read the correlative data //cell separator, row separator, value enclosure $csv = new CSV($separator, "\r\n", '"'); //parse the string content $csv->setContent(file_get_contents(PATH_ROOT . "images/csv_import/{$fileName}")); //returns an array with the CSV data if ($convertUTF8) { $csvArray = utf8_encode_mix($csv->getArray()); } else { $csvArray = $csv->getArray(); } //Read the header $line = 1; $arrErrorLine = array(); $arrErrorMessage = array(); $totalImported = 0; $images = mosGetParam($_REQUEST, 'images', ''); while (false != ($cells = next($csvArray))) { $totalCells = count($cells); //Check all the cell $continue = false; for ($k = 0; $k < count($cells); $k++) { if ($cells[$k]) { $continue = true; break; } } if ($continue) { if ($line > 0) { $success = true; $errorLine = 0; $errMsg = ""; $arrContentData = array(); $arrJreviewData = array(); for ($i = 0; $i < $totalCells; $i++) { $cell = $cells[$i]; if (!in_array($i, $arrIgnores)) { if (in_array($i, $arrContentFieldSTT)) { $contentField = $arrContentFieldName[$i]; $arrContentData[$contentField] = convert_characters($cell); } else { $jReviewField = $arrJreviewFieldName[$i]; $arrJreviewData[$jReviewField] = convert_characters($cell); } } } $copyArrGlobalSetting = $arrGlobalSetting; // Overwrite global settings with CSV fields - added v1.0.9 $csvColumns = array('catid', 'sectionid', 'created_by', 'metakey', 'metadesc', 'publish_up', 'publish_down', 'images'); foreach ($csvColumns as $csvColumn) { if (array_key_exists($csvColumn, $arrContentData) && $arrContentData[$csvColumn] != '') { unset($copyArrGlobalSetting[$csvColumn]); } elseif (array_key_exists($csvColumn, $arrContentData)) { unset($arrContentData[$csvColumn]); } } $arrContentData = array_merge($arrContentData, $copyArrGlobalSetting); $arrJreviewData = array_merge($arrJreviewData, $arrJreviewSettings); //Save data to correlative table $rowContent = new mosContent($database); if (!$rowContent->bind($arrContentData, 'id')) { $success = false; $errMsg .= " " . $rowContent->getError(); } $rowContent->id = 0; $rowContent->attribs = $attribs; if ($rowContent->images == '') { $rowContent->images = $images; } if (!$rowContent->store()) { $success = false; $errMsg .= " " . $rowContent->getError(); } if ($success && _JREVIEWS_INSTALLED) { $contentId = $rowContent->id; $arrJreviewData["contentid"] = $contentId; //Build query to insert into content table $err = insertObject("#__jreviews_content", $arrJreviewData); if ($err) { $success = false; $errMsg .= " " . $err; $sql = "Delete From #__content Where id={$rowContent->id}"; $database->setQuery($sql); $database->query(); } } if (!$success) { $arrErrorLine[] = $line + 1; $arrErrorMessage[] = $errMsg; } else { $totalImported++; } } } else { break; } $line++; } //Save profiler $profileName = mosGetParam($_REQUEST, 'profile_name'); if ($profileName) { $rowProfiler = new mosCSVProfiler($database); if (!$rowProfiler->bind($_POST)) { echo "<script> alert('" . $rowProfiler->getError() . "'); window.history.go(-1); </script>\n"; exit; } $rowProfiler->name = $profileName; $rowProfiler->number_run = 1; $rowProfiler->last_run = date("Y-m-d"); $rowProfiler->created = $rowProfiler->last_run; if (!$rowProfiler->store()) { echo "<script> alert('" . $rowProfiler->getError() . "'); window.history.go(-1); </script>\n"; exit; } //Insert data about other fields mapping $profilerId = $rowProfiler->id; for ($i = 0, $n = count($columns); $i < $n; $i++) { $column = $columns[$i]; $field = $fields[$i]; $columnNo = $i + 1; $sql = "Insert Into \r\n\t\t\t\t #__im_fields(\r\n\t\t\t\t profiler_id,\r\n\t\t\t\t column_no,\r\n\t\t\t\t column_title,\r\n\t\t\t\t `field`)\r\n\t\t\t\t Values(\r\n\t\t\t\t {$profilerId},\r\n\t\t\t\t {$columnNo},\r\n\t\t\t\t '{$column}',\r\n\t\t\t\t '{$field}'\t\t\t\t \r\n\t\t\t\t )\r\n\t\t\t\t"; $database->setQuery($sql); if (!$database->query()) { echo "<script> alert('" . $database->getError() . "'); window.history.go(-1); </script>\n"; exit; } } //Insert into global setting tables for ($i = 0, $n = count($globalColumns); $i < $n; $i++) { $column = $globalColumns[$i]; $value = $globalValues[$i]; $sql = "Insert Into \r\n\t\t\t\t #__im_global(\r\n\t\t\t\t profiler_id,\r\n\t\t\t\t field_name,\r\n\t\t\t\t field_value\r\n\t\t\t\t )\r\n\t\t\t\t Values(\r\n\t\t\t\t {$profilerId},\t\t\t\t \r\n\t\t\t\t '{$column}',\r\n\t\t\t\t '{$value}'\t\t\t\t \r\n\t\t\t\t )\r\n\t\t\t\t"; $database->setQuery($sql); if (!$database->query()) { echo "<script> alert('" . $database->getError() . "'); window.history.go(-1); </script>\n"; exit; } } } //Save profile here HTML_csv_import::showImportResult($option, $totalImported, $arrErrorLine, $arrErrorMessage, $sectionId, $categoryId); }
/** * Saves the content item an edit form submit */ function saveContent(&$access, $task) { global $database, $mainframe, $my; global $mosConfig_absolute_path, $mosConfig_offset, $Itemid; // simple spoof check security josSpoofCheck(); $nullDate = $database->getNullDate(); $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // sanitise id field $row->id = (int) $row->id; $isNew = $row->id < 1; if ($isNew) { // new record if (!($access->canEdit || $access->canEditOwn)) { mosNotAuth(); return; } $row->created = date('Y-m-d H:i:s'); $row->created_by = $my->id; } else { // existing record if (!($access->canEdit || $access->canEditOwn && $row->created_by == $my->id)) { mosNotAuth(); return; } $row->modified = date('Y-m-d H:i:s'); $row->modified_by = $my->id; } if (strlen(trim($row->publish_up)) <= 10) { $row->publish_up .= ' 00:00:00'; } $row->publish_up = mosFormatDate($row->publish_up, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset); if (trim($row->publish_down) == 'Never' || trim($row->publish_down) == '') { $row->publish_down = $nullDate; } else { if (strlen(trim($row->publish_down)) <= 10) { $row->publish_down .= ' 00:00:00'; } $row->publish_down = mosFormatDate($row->publish_down, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset); } // code cleaner for xhtml transitional compliance $row->introtext = str_replace('<br>', '<br />', $row->introtext); $row->fulltext = str_replace('<br>', '<br />', $row->fulltext); // remove <br /> take being automatically added to empty fulltext $length = strlen($row->fulltext) < 9; $search = strstr($row->fulltext, '<br />'); if ($length && $search) { $row->fulltext = NULL; } $row->title = ampReplace($row->title); // Publishing state hardening for Authors if (!$access->canPublish) { if ($isNew) { // For new items - author is not allowed to publish - prevent them from doing so $row->state = 0; } else { // For existing items keep existing state - author is not allowed to change status $query = "SELECT state" . "\n FROM #__content" . "\n WHERE id = " . (int) $row->id; $database->setQuery($query); $state = $database->loadResult(); if ($state) { $row->state = 1; } else { $row->state = 0; } } } if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->version++; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // manage frontpage items require_once $mainframe->getPath('class', 'com_frontpage'); $fp = new mosFrontPage($database); if (intval(mosGetParam($_REQUEST, 'frontpage', 0))) { // toggles go to first place if (!$fp->load((int) $row->id)) { // new entry $query = "INSERT INTO #__content_frontpage" . "\n VALUES ( " . (int) $row->id . ", 1 )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->stderr() . "');</script>\n"; exit; } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete((int) $row->id)) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); $row->updateOrder("catid = " . (int) $row->catid); // gets section name of item $query = "SELECT s.title" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n AND s.id = " . (int) $row->sectionid; $database->setQuery($query); // gets category name of item $section = $database->loadResult(); $query = "SELECT c.title" . "\n FROM #__categories AS c" . "\n WHERE c.id = " . (int) $row->catid; $database->setQuery($query); $category = $database->loadResult(); $category = stripslashes($category); if ($isNew) { // messaging for new items require_once $mosConfig_absolute_path . '/components/com_messages/messages.class.php'; $query = "SELECT id" . "\n FROM #__users" . "\n WHERE sendEmail = 1"; $database->setQuery($query); $users = $database->loadResultArray(); foreach ($users as $user_id) { $msg = new mosMessage($database); $msg->send($my->id, $user_id, "New Item", sprintf(_ON_NEW_CONTENT, $my->username, $row->title, $section, $category)); } } $msg = $isNew ? _THANK_SUB : _E_ITEM_SAVED; $msg = $my->usertype == 'Publisher' ? _THANK_SUB_PUB : $msg; switch ($task) { case 'apply': $link = $_SERVER['HTTP_REFERER']; break; case 'apply_new': $Itemid = intval(mosGetParam($_POST, 'Returnid', $Itemid)); $link = 'index.php?option=com_content&task=edit&id=' . $row->id . '&Itemid=' . $Itemid; break; case 'save': default: $Itemid = mosGetParam($_POST, 'Returnid', ''); if ($Itemid) { if ($access->canEdit) { $link = 'index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $Itemid; } else { $link = 'index.php'; } } else { $link = strval(mosGetParam($_POST, 'referer', '')); } break; } mosRedirect($link, $msg); }
/** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu($uid, $access, $option) { global $database; $row = new mosContent($database); $row->load($uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } $redirect = mosGetParam($_POST, 'redirect', $row->sectionid); mosRedirect('index2.php?option=' . $option . '§ionid=' . $redirect); }
/** * @param integer The id of the content item * @param integer The new access level * @param string The URL option */ function accessMenu($uid, $access, $option) { global $database; josSpoofCheck(); $row = new mosContent($database); $row->load((int) $uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } $redirect = mosGetParam($_POST, 'redirect', $row->sectionid); // clean any existing cache files mosCache::cleanCache('com_content'); mosRedirect('index2.php?option=' . $option . '§ionid=' . $redirect); }
/** * 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); }
/** * 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§ion=' . $sectionOld . '&mosmsg=' . $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); }
/** * Saves the content item an edit form submit */ function saveContent(&$access) { global $database, $mainframe, $my; global $mosConfig_absolute_path; $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // sanitize $row->id = intval($row->id); $row->catid = intval($row->catid); $row->sectionid = intval($row->sectionid); $isNew = $row->id < 1; if ($isNew) { // new record if (!($access->canEdit || $access->canEditOwn)) { mosNotAuth(); return; } $row->created = date('Y-m-d H:i:s'); $row->created_by = $my->id; } else { // existing record if (!($access->canEdit || $access->canEditOwn && $row->created_by == $my->id)) { mosNotAuth(); return; } $row->modified = date('Y-m-d H:i:s'); $row->modified_by = $my->id; } if (trim($row->publish_down) == 'Never') { $row->publish_down = '0000-00-00 00:00:00'; } if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->version++; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // manage frontpage items require_once $mainframe->getPath('class', 'com_frontpage'); $fp = new mosFrontPage($database); if (mosGetParam($_REQUEST, 'frontpage', 0)) { // toggles go to first place if (!$fp->load($row->id)) { // new entry $database->setQuery("INSERT INTO #__content_frontpage VALUES ('{$row->id}','1')"); if (!$database->query()) { echo "<script> alert('" . $database->stderr() . "');</script>\n"; exit; } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete($row->id)) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); $row->updateOrder("catid='{$row->catid}'"); // gets section name of item $database->setQuery("SELECT s.title" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n AND s.id = '" . $row->sectionid . "'"); // gets category name of item $section = $database->loadResult(); $database->setQuery("SELECT c.title" . "\n FROM #__categories AS c" . "\n WHERE c.id = '" . $row->catid . "'"); $category = $database->loadResult(); if ($isNew) { // messaging for new items require_once $mosConfig_absolute_path . '/components/com_messages/messages.class.php'; $database->setQuery("SELECT id FROM #__users WHERE sendEmail = '1'"); $users = $database->loadResultArray(); if ($users) { foreach ($users as $user_id) { $msg = new mosMessage($database); $msg->send($my->id, $user_id, T_("New Item"), sprintf(T_('A new content item has been submitted by [ %s ] titled [ %s ] from section [ %s ] and category [ %s ]'), $my->username, $row->title, $section, $category)); } } } $Itemid = mosGetParam($_POST, 'Returnid', '0'); $msg = $isNew ? T_('Thanks for your submission; it will be reviewed before being posted to the site.') : T_('Item saved successfully.'); mosRedirect('index.php', $msg); }
/** * @param integer The id of the content item * @param integer The new access level * @param string The URL option */ function accessMenu($uid, $access) { global $database; $row = new mosContent($database); $row->load($uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } mosRedirect('index2.php?option=com_frontpage'); }
/** * 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§ion=' . $sectionOld . '&mosmsg=' . $msg); }