function addTopic() { global $xoopsDB, $xoopsModule, $xoopsModuleConfig; $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0; $xt = new NewsTopic(); if (!$xt->topicExists($topicpid, $_POST['topic_title'])) { $xt->setTopicPid($topicpid); if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title']) == '') { redirect_header('index.php?op=topicsmanager', 2, _AM_ERRORTOPICNAME); } $xt->setTopicTitle($_POST['topic_title']); //$xt->Settopic_rssurl($_POST['topic_rssfeed']); $xt->setTopic_color($_POST['topic_color']); if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != '') { $xt->setTopicImgurl($_POST['topic_imgurl']); } $xt->setMenu(intval($_POST['submenu'])); $xt->setTopicFrontpage(intval($_POST['topic_frontpage'])); if (isset($_SESSION['items_count'])) { $_SESSION['items_count'] = -1; } if (isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (xoops_trim($fldname != '')) { $sfiles = new sFiles(); $dstpath = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/images/topics'; $destname = $sfiles->createUploadName($dstpath, $fldname, true); $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($uploader->upload()) { $xt->setTopicImgurl(basename($destname)); } else { echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); } } else { echo $uploader->getErrors(); } } } if (isset($_POST['topic_description'])) { $xt->setTopicDescription($_POST['topic_description']); } else { $xt->setTopicDescription(''); } $xt->store(); // Permissions $gperm_handler =& xoops_gethandler('groupperm'); if (isset($_POST['groups_news_can_approve'])) { foreach ($_POST['groups_news_can_approve'] as $onegroup_id) { $gperm_handler->addRight('news_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } if (isset($_POST['groups_news_can_submit'])) { foreach ($_POST['groups_news_can_submit'] as $onegroup_id) { $gperm_handler->addRight('news_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } if (isset($_POST['groups_news_can_view'])) { foreach ($_POST['groups_news_can_view'] as $onegroup_id) { $gperm_handler->addRight('news_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } news_updateCache(); $notification_handler =& xoops_gethandler('notification'); $tags = array(); $tags['TOPIC_NAME'] = $_POST['topic_title']; $notification_handler->triggerEvent('global', 0, 'new_category', $tags); redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED); } else { redirect_header('index.php?op=topicsmanager', 2, _AM_ADD_TOPIC_ERROR); } exit; }
function LaunchExport() { xoops_cp_header(); adminmenu(4); echo "<br />"; $story = new NewsStory(); $topic = new NewsTopic(); $exportedstories = array(); $date1 = $_POST['date1']; $date2 = $_POST['date2']; $timestamp1 = mktime(0, 0, 0, intval(substr($date1, 5, 2)), intval(substr($date1, 8, 2)), intval(substr($date1, 0, 4))); $timestamp2 = mktime(0, 0, 0, intval(substr($date2, 5, 2)), intval(substr($date2, 8, 2)), intval(substr($date2, 0, 4))); $topiclist = ''; if (isset($_POST['export_topics'])) { $topiclist = implode(",", $_POST['export_topics']); } $topicsexport = intval($_POST['includetopics']); $tbltopics = array(); $exportedstories = $story->NewsExport($timestamp1, $timestamp2, $topiclist, $topicsexport, $tbltopics); if (count($exportedstories)) { $xmlfile = XOOPS_ROOT_PATH . '/uploads/stories.xml'; $fp = fopen($xmlfile, 'w'); if (!$fp) { redirect_header('index.php', 4, sprintf(_AM_NEWS_EXPORT_ERROR, $xmlfile)); } fwrite($fp, "<?xml version=\"1.0\" ?>\n"); fwrite($fp, "<xoops_stories>\n"); if ($topicsexport) { foreach ($tbltopics as $onetopic) { fwrite($fp, "<xoops_topic>\n"); $topic->NewsTopic($onetopic); fwrite($fp, sprintf("\t<topic_id>%u</topic_id>\n", $topic->topic_id())); fwrite($fp, sprintf("\t<topic_pid>%u</topic_pid>\n", $topic->topic_pid())); fwrite($fp, sprintf("\t<topic_imgurl>%s</topic_imgurl>\n", $topic->topic_imgurl())); fwrite($fp, sprintf("\t<topic_title>%s</topic_title>\n", $topic->topic_title('F'))); fwrite($fp, sprintf("\t<menu>%d</menu>\n", $topic->menu())); fwrite($fp, sprintf("\t<topic_frontpage>%d</topic_frontpage>\n", $topic->topic_frontpage())); fwrite($fp, sprintf("\t<topic_rssurl>%s</topic_rssurl>\n", $topic->topic_rssurl('E'))); fwrite($fp, sprintf("\t<topic_description>%s</topic_description>\n", $topic->topic_description())); fwrite($fp, sprintf("</xoops_topic>\n")); } } foreach ($exportedstories as $onestory) { fwrite($fp, "<xoops_story>\n"); fwrite($fp, sprintf("\t<storyid>%u</storyid>\n", $onestory->storyid())); fwrite($fp, sprintf("\t<uid>%u</uid>\n", $onestory->uid())); fwrite($fp, sprintf("\t<uname>%s</uname>\n", $onestory->uname())); fwrite($fp, sprintf("\t<title>%s</title>\n", $onestory->title())); fwrite($fp, sprintf("\t<created>%u</created>\n", $onestory->created())); fwrite($fp, sprintf("\t<published>%u</published>\n", $onestory->published())); fwrite($fp, sprintf("\t<expired>%u</expired>\n", $onestory->expired())); fwrite($fp, sprintf("\t<hostname>%s</hostname>\n", $onestory->hostname())); fwrite($fp, sprintf("\t<nohtml>%d</nohtml>\n", $onestory->nohtml())); fwrite($fp, sprintf("\t<nosmiley>%d</nosmiley>\n", $onestory->nosmiley())); fwrite($fp, sprintf("\t<hometext>%s</hometext>\n", $onestory->hometext())); fwrite($fp, sprintf("\t<bodytext>%s</bodytext>\n", $onestory->bodytext())); fwrite($fp, sprintf("\t<description>%s</description>\n", $onestory->description())); fwrite($fp, sprintf("\t<keywords>%s</keywords>\n", $onestory->keywords())); fwrite($fp, sprintf("\t<counter>%u</counter>\n", $onestory->counter())); fwrite($fp, sprintf("\t<topicid>%u</topicid>\n", $onestory->topicid())); fwrite($fp, sprintf("\t<ihome>%d</ihome>\n", $onestory->ihome())); fwrite($fp, sprintf("\t<notifypub>%d</notifypub>\n", $onestory->notifypub())); fwrite($fp, sprintf("\t<story_type>%s</story_type>\n", $onestory->type())); fwrite($fp, sprintf("\t<topicdisplay>%d</topicdisplay>\n", $onestory->topicdisplay())); fwrite($fp, sprintf("\t<topicalign>%s</topicalign>\n", $onestory->topicalign())); fwrite($fp, sprintf("\t<comments>%u</comments>\n", $onestory->comments())); fwrite($fp, sprintf("\t<rating>%f</rating>\n", $onestory->rating())); fwrite($fp, sprintf("\t<votes>%u</votes>\n", $onestory->votes())); fwrite($fp, sprintf("</xoops_story>\n")); } fwrite($fp, "</xoops_stories>\n"); fclose($fp); $xmlfile = XOOPS_URL . '/uploads/stories.xml'; printf(_AM_NEWS_EXPORT_READY, $xmlfile, XOOPS_URL . '/modules/news/admin/index.php?op=deletefile&type=xml'); } else { printf(_AM_NEWS_EXPORT_NOTHING); } }
$topicpid = $ams_news_topics[$one_amstopic['topic_pid']]; } } $news_topic = new NewsTopic(); $news_topic->setTopicPid($topicpid); $news_topic->setTopicTitle($one_amstopic['topic_title']); $news_topic->setTopicImgurl($one_amstopic['topic_imgurl']); $news_topic->setMenu(0); $news_topic->setTopicFrontpage(1); $news_topic->Settopic_rssurl(''); $news_topic->setTopicDescription(''); $news_topic->setTopic_color('000000'); $news_topic->store(); echo '<br>- The following topic was imported : ' . $news_topic->topic_title(); $ams_topicid = $one_amstopic['topic_id']; $news_topicid = $news_topic->topic_id(); $ams_news_topics[$ams_topicid] = $news_topicid; // Then we insert all its articles $result = $db->query('SELECT * FROM ' . $ams_articles . ' WHERE topicid=' . $ams_topicid . ' ORDER BY created'); while ($article = $db->fetchArray($result)) { $ams_newsid = $article['storyid']; // We search for the last version $result2 = $db->query('SELECT * FROM ' . $ams_text . ' WHERE storyid=' . $ams_newsid . ' AND current=1'); $text_lastversion = $db->fetchArray($result2); // We search for the number of votes $result3 = $db->query('SELECT count(*) as cpt FROM ' . $ams_rating . ' WHERE storyid=' . $ams_newsid); $votes = $db->fetchArray($result3); // The links $links = ''; if ($use_extlinks) { $result7 = $db->query('SELECT * FROM ' . $ams_links . ' WHERE storyid=' . $ams_newsid . ' ORDER BY linkid');