/** * Cancels an edit operation * @param database A database connector object */ function cancelContent(&$access) { global $database, $my, $task; $row = new mosContent($database); $row->bind($_POST); if ($access->canEdit || $access->canEditOwn && $row->created_by == $my->id) { $row->checkin(); } $Itemid = intval(mosGetParam($_POST, 'Returnid', '0')); $referer = strval(mosGetParam($_POST, 'referer', '')); $parts = parse_url($referer); parse_str($parts['query'], $query); if ($task == 'edit' || $task == 'cancel') { $Itemid = mosGetParam($_POST, 'Returnid', ''); $referer = 'index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $Itemid; } if ($referer && $row->id) { mosRedirect($referer); } else { mosRedirect('index.php'); } }
function menuLink($option) { global $database, $adminLanguage; $content = new mosContent($database); $content->bind($_POST); $content->checkin(); $menu = mosGetParam($_POST, 'menuselect', ''); $link = mosGetParam($_POST, 'link_name', ''); $id = mosGetParam($_POST, 'id', ''); $row = new mosMenu($database); $row->menutype = $menu; $row->name = $link; $row->type = 'content_item_link'; $row->published = 1; $row->componentid = $id; $row->link = 'index.php?option=com_content&task=view&id=' . $id; $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='{$row->menutype}' AND parent='{$row->parent}'"); $msg = $link . " " . $adminLanguage->A_COMP_CONTENT_IN_MENU . ": " . $menu . " " . $adminLanguage->A_COMP_CONTENT_SUCCESS; mosRedirect('index2.php?option=' . $option, $msg); }
function saveOrder(&$cid) { global $database; josSpoofCheck(); $total = count($cid); $order = josGetArrayInts('order'); $row = new mosContent($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 = "catid=" . (int) $row->catid . " AND state >= 0"; $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_typedcontent', $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($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); }
$moduleclass_sfx = $params->get('moduleclass_sfx'); $params->set('intro_only', 1); $params->set('hide_author', 1); $params->set('hide_createdate', 0); $params->set('hide_modifydate', 1); if ($items) { $limit = "LIMIT " . $items; } else { $limit = ""; } $noauth = !$mainframe->getCfg('shownoauth'); // query to determine article count $query = "SELECT a.id" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS b ON b.id = a.catid" . "\n WHERE a.state = 1" . ($noauth ? "\n AND a.access <= '" . $my->gid . "' AND b.access <= '" . $my->gid . "'" : '') . "\n AND (a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '" . $now . "') " . "\n AND (a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '" . $now . "')" . "\n AND catid='" . $catid . "' " . "\n ORDER BY a.ordering" . "\n " . $limit; $database->setQuery($query); $rows = $database->loadResultArray(); $row = new mosContent($database); if (!count($rows)) { return; } $numrows = count($rows); switch ($style) { case 'horiz': echo "\n<table class=\"moduletable" . $moduleclass_sfx . "\">\n"; echo "<tr>\n"; foreach ($rows as $id) { $row->load($id); $row->text = $row->introtext; if ($image == 0) { $row->text = preg_replace('/\\<img[^>]+\\>/i', '', $row->text); } $row->groups = '';
/** * 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; 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($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); }
default: $query = "SELECT a.id, a.title, a.sectionid, a.catid" . "\n FROM #__content AS a" . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id" . "\n WHERE ( a.state = '1' AND a.checked_out = '0' AND a.sectionid > '0' )" . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '" . $now . "' )" . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '" . $now . "' )" . ($access ? "\n AND a.access <= '" . $viewAccess . "'" : '') . ($catid ? "\n AND ( a.catid IN (" . $catid . ") )" : '') . ($secid ? "\n AND ( a.sectionid IN (" . $secid . ") )" : '') . ($show_front == "0" ? "\n AND f.content_id IS NULL" : '') . "\n ORDER BY a.created DESC LIMIT {$count}"; $database->setQuery($query); $rows = $database->loadObjectList(); break; } // needed to reduce queries used by getItemid for Content Items if ($type == 1 || $type == 3) { require_once mamboCore::get('mosConfig_absolute_path') . '/components/com_content/content.class.php'; $handler =& new contentHandler(); $bs = $handler->getBlogSectionCount(); $bc = $handler->getBlogCategoryCount(); $gbs = $handler->getGlobalBlogSectionCount(); } // Output $newrow = new mosContent($database); if ($rows) { switch ($style) { case 'vert': echo "\n<table class=\"moduletable" . $class_sfx . "\">\n"; foreach ($rows as $row) { // get Itemid switch ($type) { case 2: //Static Content only $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE type = 'content_typed'" . "\n AND componentid = {$row->id}"; $database->setQuery($query); $Itemid = $database->loadResult(); break; case 3: //Both
function removeFrontPage(&$cid, $option) { global $database, $adminLanguage; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert(\"" . $adminLanguage->A_COMP_CONTENT_SEL_DEL . "\"); window.history.go(-1);</script>\n"; exit; } $fp = new mosFrontPage($database); foreach ($cid as $id) { if (!$fp->delete($id)) { echo "<script> alert('" . $fp->getError() . "'); </script>\n"; exit; } $obj = new mosContent($database); $obj->load($id); $obj->mask = 0; if (!$obj->store()) { echo "<script> alert('" . $fp->getError() . "'); </script>\n"; exit; } } $fp->updateOrder(); mosRedirect("index2.php?option={$option}"); }
function saveOrder(&$cid) { global $database; $order = mosGetParam($_POST, 'order', array(0)); $redirect = mosGetParam($_POST, 'redirect', 0); $rettask = mosGetParam($_POST, 'returntask', ''); $row = new mosContent($database); $categories = 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 $categories[$row->catid] = $row->id; } } // execute updateOrder for each group foreach ($categories as $catid => $rowid) { $row->updateOrder("catid = {$catid} AND state >= 0"); } // foreach $msg = T_('New ordering saved'); switch ($rettask) { case 'showarchive': mosRedirect('index2.php?option=com_content&task=showarchive§ionid=' . $redirect, $msg); break; default: mosRedirect('index2.php?option=com_content§ionid=' . $redirect, $msg); break; } // switch }
function saveOrder(&$cid) { global $database; josSpoofCheck(); $total = count($cid); $redirect = mosGetParam($_POST, 'redirect', 0); $rettask = strval(mosGetParam($_POST, 'returntask', '')); $order = josGetArrayInts('order'); $row = new mosContent($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 = "catid = " . (int) $row->catid . " AND state >= 0"; $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 = 'Nova ordenação salva'; switch ($rettask) { case 'showarchive': mosRedirect('index2.php?option=com_content&task=showarchive§ionid=' . $redirect, $msg); break; default: mosRedirect('index2.php?option=com_content§ionid=' . $redirect, $msg); break; } // switch }
/** * Shows the email form for a given content item. */ function emailContentForm($uid) { global $database, $mainframe, $my; $row = new mosContent($database); $row->load($uid); if ($row->id === null || $row->access > $my->gid) { mosNotAuth(); return; } else { $template = ''; $database->setQuery("SELECT template FROM #__templates_menu WHERE client_id = '0' AND menuid = '0'"); $template = $database->loadResult(); HTML_content::emailForm($row->id, $row->title, $template); } }
function dofreePDF($database) { global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, $mosConfig_hideModifyDate; $id = intval(mosGetParam($_REQUEST, 'id', 1)); // Access check global $gid; $now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60); $query = "SELECT COUNT(a.id)" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . "\n WHERE a.id='" . $id . "' " . "\n AND (a.state = '1' OR a.state = '-1')" . "\n AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '{$now}')" . "\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '{$now}')" . "\n AND a.access <= " . intval($gid); $database->setQuery($query); if (!$database->loadResult()) { exit(T_('You are not authorized to view this resource.')); } include 'includes/class.ezpdf.php'; $row = new mosContent($database); $row->load($id); //Find Author Name $users_rows = new mosUser($database); $users_rows->load($row->created_by); $row->author = $users_rows->name; $row->usertype = $users_rows->usertype; // Ugly but needed to get rid of all the stuff the PDF class cant handle $row->fulltext = str_replace('<p>', "\n\n", $row->fulltext); $row->fulltext = str_replace('<P>', "\n\n", $row->fulltext); $row->fulltext = str_replace('<br />', "\n", $row->fulltext); $row->fulltext = str_replace('<br>', "\n", $row->fulltext); $row->fulltext = str_replace('<BR />', "\n", $row->fulltext); $row->fulltext = str_replace('<BR>', "\n", $row->fulltext); $row->fulltext = str_replace('<li>', "\n - ", $row->fulltext); $row->fulltext = str_replace('<LI>', "\n - ", $row->fulltext); $row->fulltext = strip_tags($row->fulltext); $row->fulltext = str_replace('{mosimage}', '', $row->fulltext); $row->fulltext = str_replace('{mospagebreak}', '', $row->fulltext); $row->fulltext = decodeHTML($row->fulltext); $row->introtext = str_replace('<p>', "\n\n", $row->introtext); $row->introtext = str_replace('<P>', "\n\n", $row->introtext); $row->introtext = str_replace('<li>', "\n - ", $row->introtext); $row->introtext = str_replace('<LI>', "\n - ", $row->introtext); $row->introtext = strip_tags($row->introtext); $row->introtext = str_replace('{mosimage}', '', $row->introtext); $row->introtext = str_replace('{mospagebreak}', '', $row->introtext); $row->introtext = decodeHTML($row->introtext); $pdf =& new Cezpdf('a4', 'P'); //A4 Portrait $pdf->ezSetCmMargins(2, 1.5, 1, 1); $pdf->selectFont('./fonts/Helvetica.afm'); //choose font $all = $pdf->openObject(); $pdf->saveState(); $pdf->setStrokeColor(0, 0, 0, 1); // footer $pdf->line(10, 40, 578, 40); $pdf->line(10, 822, 578, 822); $pdf->addText(30, 34, 6, $mosConfig_live_site . ' - ' . $mosConfig_sitename); $pdf->addText(250, 34, 6, T_('Powered by Mambo')); $pdf->addText(450, 34, 6, T_('Generated:') . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60)); $pdf->restoreState(); $pdf->closeObject(); $pdf->addObject($all, 'all'); $pdf->ezSetDy(30); $txt1 = $row->title; $pdf->ezText($txt1, 14); $txt2 = NULL; $mod_date = NULL; $create_date = NULL; if (intval($row->modified) != 0) { $mod_date = mosFormatDate($row->modified); } if (intval($row->created) != 0) { $create_date = mosFormatDate($row->created); } if ($mosConfig_hideCreateDate == '0') { $txt2 .= '(' . $create_date . ') - '; } if ($mosConfig_hideAuthor == "0") { if ($row->author != '' && $mosConfig_hideAuthor == '0') { if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator') { $txt2 .= T_('Written by') . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author); } else { $txt2 .= T_('Contributed by') . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author); } } } if ($mosConfig_hideModifyDate == "0") { $txt2 .= ' - ' . T_('Last Updated') . ' (' . $mod_date . ') '; } $txt2 .= "\n\n"; $pdf->ezText($txt2, 8); $txt3 = $row->introtext . "\n" . $row->fulltext; $pdf->ezText($txt3, 10); $pdf->ezStream(); }
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); }
/** * @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; josSpoofCheck(); $row = new mosContent($database); $row->load((int) $uid); $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=com_frontpage'); }
function go2menuitem() { global $database; // checkin content $row = new mosContent($database); $row->bind($_POST); $row->checkin(); $menu = mosGetParam($_POST, 'menu', 'mainmenu'); $id = mosGetParam($_POST, 'menuid', 0); mosRedirect('index2.php?option=com_menus&menutype=' . $menu . '&task=edit&hidemainmenu=1&id=' . $id); }
function dofreePDF($database) { global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, $mosConfig_hideModifyDate; $id = intval(mosGetParam($_REQUEST, 'id', 1)); include 'includes/class.ezpdf.php'; $row = new mosContent($database); $row->load($id); //Find Author Name $users_rows = new mosUser($database); $users_rows->load($row->created_by); $row->author = $users_rows->name; $row->usertype = $users_rows->usertype; // Ugly but needed to get rid of all the stuff the PDF class cant handle $row->fulltext = str_replace('<p>', "\n\n", $row->fulltext); $row->fulltext = str_replace('<P>', "\n\n", $row->fulltext); $row->fulltext = str_replace('<br />', "\n", $row->fulltext); $row->fulltext = str_replace('<br>', "\n", $row->fulltext); $row->fulltext = str_replace('<BR />', "\n", $row->fulltext); $row->fulltext = str_replace('<BR>', "\n", $row->fulltext); $row->fulltext = str_replace('<li>', "\n - ", $row->fulltext); $row->fulltext = str_replace('<LI>', "\n - ", $row->fulltext); $row->fulltext = strip_tags($row->fulltext); $row->fulltext = str_replace('{mosimage}', '', $row->fulltext); $row->fulltext = str_replace('{mospagebreak}', '', $row->fulltext); $row->fulltext = decodeHTML($row->fulltext); $row->introtext = str_replace('<p>', "\n\n", $row->introtext); $row->introtext = str_replace('<P>', "\n\n", $row->introtext); $row->introtext = str_replace('<li>', "\n - ", $row->introtext); $row->introtext = str_replace('<LI>', "\n - ", $row->introtext); $row->introtext = strip_tags($row->introtext); $row->introtext = str_replace('{mosimage}', '', $row->introtext); $row->introtext = str_replace('{mospagebreak}', '', $row->introtext); $row->introtext = decodeHTML($row->introtext); $pdf =& new Cezpdf('a4', 'P'); //A4 Portrait $pdf->ezSetCmMargins(2, 1.5, 1, 1); $pdf->selectFont('./fonts/Helvetica.afm'); //choose font $all = $pdf->openObject(); $pdf->saveState(); $pdf->setStrokeColor(0, 0, 0, 1); // footer $pdf->line(10, 40, 578, 40); $pdf->line(10, 822, 578, 822); $pdf->addText(30, 34, 6, $mosConfig_live_site . ' - ' . $mosConfig_sitename); $pdf->addText(250, 34, 6, 'Powered by Mambo'); $pdf->addText(450, 34, 6, 'Generated: ' . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60)); $pdf->restoreState(); $pdf->closeObject(); $pdf->addObject($all, 'all'); $pdf->ezSetDy(30); $txt1 = $row->title; $pdf->ezText($txt1, 14); $txt2 = NULL; $mod_date = NULL; $create_date = NULL; if (intval($row->modified) != 0) { $mod_date = mosFormatDate($row->modified); } if (intval($row->created) != 0) { $create_date = mosFormatDate($row->created); } if ($mosConfig_hideCreateDate == '0') { $txt2 .= '(' . $create_date . ') - '; } if ($mosConfig_hideAuthor == "0") { if ($row->author != '' && $mosConfig_hideAuthor == '0') { if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator') { $txt2 .= _WRITTEN_BY . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author); } else { $txt2 .= _AUTHOR_BY . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author); } } } if ($mosConfig_hideModifyDate == "0") { $txt2 .= ' - ' . _LAST_UPDATED . ' (' . $mod_date . ') '; } $txt2 .= "\n\n"; $pdf->ezText($txt2, 8); $txt3 = $row->introtext . "\n" . $row->fulltext; $pdf->ezText($txt3, 10); $pdf->ezStream(); }
/** * Permanently deletes the selected list of trash items */ function deleteTrash($cid, $option) { global $database, $mainframe, $adminLanguage; $type = mosGetParam($_POST, 'type', array(0)); $total = count($cid); if ($type == "content") { $obj = new mosContent($database); $fp = new mosFrontPage($database); foreach ($cid as $id) { $id = intval($id); $obj->delete($id); $fp->delete($id); } } else { if ($type == "menu") { $obj = new mosMenu($database); foreach ($cid as $id) { $id = intval($id); $obj->delete($id); } } } $msg = $total . " " . $adminLanguage->A_COMP_TRASH_SUCCESS_DEL; mosRedirect("index2.php?option={$option}&mosmsg=" . $msg . ""); }
/** * Permanently deletes the selected list of trash items */ function deleteTrash($cid, $option) { global $database, $mainframe; $type = mosGetParam($_POST, 'type', array(0)); $total = count($cid); if ($type == "content") { $obj = new mosContent($database); $fp = new mosFrontPage($database); foreach ($cid as $id) { $id = intval($id); $obj->delete($id); $fp->delete($id); } } else { if ($type == "menu") { $obj = new mosMenu($database); foreach ($cid as $id) { $id = intval($id); $obj->delete($id); } } } $msg = sprintf(Tn_('%s Item successfully Deleted', '%s Items successfully Deleted', $total), $total); mosRedirect("index2.php?option={$option}&mosmsg=" . $msg . ""); }
/** * Cancels an edit operation */ function cancelMenu($option) { global $database; $menu = new mosMenu($database); $menu->bind($_POST); $menuid = mosGetParam($_POST, 'menuid', 0); if ($menuid) { $menu->id = $menuid; } $menu->checkin(); if ($menu->type == 'content_typed') { $contentid = mosGetParam($_POST, 'id', 0); $content = new mosContent($database); $content->load($contentid); $content->checkin(); } mosRedirect('index2.php?option=' . $option . '&menutype=' . $menu->menutype); }
/** * 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); }
/** * Permanently deletes the selected list of trash items */ function deleteTrash($cid, $option) { global $database; josSpoofCheck(); $type = mosGetParam($_POST, 'type', array(0)); $total = count($cid); if ($type == 'content') { $obj = new mosContent($database); $fp = new mosFrontPage($database); foreach ($cid as $id) { $id = intval($id); $obj->delete($id); $fp->delete($id); } } else { if ($type == 'menu') { $obj = new mosMenu($database); foreach ($cid as $id) { $id = intval($id); $obj->delete($id); } } } $msg = $total . " Iten(s) apagados com sucesso!"; mosRedirect("index2.php?option={$option}&mosmsg=" . $msg . ""); }
/** * 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); }